-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Search][Onboarding] api-key plugin #191926
Conversation
x-pack/plugins/search_api_keys/public/components/api_key_form.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/search_api_keys/public/components/api_key_form.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/search_api_keys/public/components/api_key_form.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/search_api_keys/public/components/api_key_form.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/search_api_keys/public/hooks/use_search_api_key.ts
Outdated
Show resolved
Hide resolved
|
||
return apiKey; | ||
} catch (e) { | ||
logger.error(`Error creating API Key for elasticsearch start`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better error message here (focus on api-keys plugin)
|
||
return apiKey.api_keys?.[0]; | ||
} catch (e) { | ||
logger.error(`Error getting API Key for elasticsearch start`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here: better error message, associating with api-key plugin
Flaky Test Runner Stats🟠 Some tests failed. - kibana-flaky-test-suite-runner#7045[❌] x-pack/test_serverless/functional/test_suites/search/config.feature_flags.ts: 0/25 tests passed. |
} | ||
}; | ||
|
||
export const useSearchApiKey = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The contents of this hook could be broken up into more composable pieces. But at a minimum we will need a hook exported to get the session API key for the code examples.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep that makes sense. I've updated the code to also do the code sample replacement.
const codeParams = useMemo(() => { | ||
return { | ||
indexName: createIndexForm.indexName || undefined, | ||
elasticsearchURL: elasticsearchUrl, | ||
apiKey: apiKeyIsVisible && apiKey ? apiKey : undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we'll need to do this for the index details no data view too here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep was done as part of the change
Line 70 in cd87f44
apiKey: apiKeyIsVisible && apiKey ? apiKey : undefined, |
}, | ||
}); | ||
|
||
useEffect(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since we're rendering this provider in the search_indices
application now this will be called for all search_indices routes on page load.
With this going out to serverless only for now, I'm ok with it for now. But I think we'll need to refine this in the future to be more explicit about when the creation logic is called vs when we just check and read for an existing key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep this useEffect will run on page routes but the API creation code will only be executed once a hook has been mounted and will only be run once until the provider is unmounted.
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Public APIs missing exports
Page load bundle
Unknown metric groupsAPI count
async chunk count
ESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
Flaky Test Runner Stats🎉 All tests passed! - kibana-flaky-test-suite-runner#7056[✅] x-pack/test_serverless/api_integration/test_suites/search/config.feature_flags.ts: 25/25 tests passed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API Key flyout changes LGTM
Starting backport for target branches: 8.x |
💔 All backports failed
Manual backportTo create the backport manually run:
Questions ?Please refer to the Backport tool documentation |
@yansavitski if you'd like to backport this, you'll have to accommodate for changes in #194144 - (like #194676) |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
## Summary Kibana plugin that helps manage the session for the api-key that provides two exports: - React custom hook to read the api-key stored in session. This hook should return the api-key if it exists, otherwise null. - Component to present either the api key in storage or action to create api key and store into sessionStorage after callback. <img width="1255" alt="Screenshot 2024-09-27 at 20 52 52" src="https://github.com/user-attachments/assets/dc5bcd39-7fe6-433c-8aaa-ad3578a68b62"> <img width="1248" alt="Screenshot 2024-09-27 at 20 52 39" src="https://github.com/user-attachments/assets/d760c163-9017-4f57-ba1a-38ee8ee21534"> <img width="676" alt="Screenshot 2024-09-27 at 20 52 28" src="https://github.com/user-attachments/assets/e908d20a-7e0c-4f3b-9ea2-8e2d1a74c9eb"> (cherry picked from commit c5aa739) # Conflicts: # .github/CODEOWNERS
Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync. |
# Backport This will backport the following commits from `main` to `8.x`: - [[Search][Onboarding] api-key plugin (#191926)](#191926) <!--- Backport version: 8.9.8 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Yan Savitski","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-02T08:45:20Z","message":"[Search][Onboarding] api-key plugin (#191926)\n\n## Summary\r\nKibana plugin that helps manage the session for the api-key that\r\nprovides two exports:\r\n- React custom hook to read the api-key stored in session. This hook\r\nshould return the api-key if it exists, otherwise null.\r\n- Component to present either the api key in storage or action to create\r\napi key and store into sessionStorage after callback.\r\n<img width=\"1255\" alt=\"Screenshot 2024-09-27 at 20 52 52\"\r\nsrc=\"https://github.com/user-attachments/assets/dc5bcd39-7fe6-433c-8aaa-ad3578a68b62\">\r\n<img width=\"1248\" alt=\"Screenshot 2024-09-27 at 20 52 39\"\r\nsrc=\"https://github.com/user-attachments/assets/d760c163-9017-4f57-ba1a-38ee8ee21534\">\r\n<img width=\"676\" alt=\"Screenshot 2024-09-27 at 20 52 28\"\r\nsrc=\"https://github.com/user-attachments/assets/e908d20a-7e0c-4f3b-9ea2-8e2d1a74c9eb\">","sha":"c5aa73991463dee50b036bb51645e03cc283bb8c","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor"],"number":191926,"url":"https://github.com/elastic/kibana/pull/191926","mergeCommit":{"message":"[Search][Onboarding] api-key plugin (#191926)\n\n## Summary\r\nKibana plugin that helps manage the session for the api-key that\r\nprovides two exports:\r\n- React custom hook to read the api-key stored in session. This hook\r\nshould return the api-key if it exists, otherwise null.\r\n- Component to present either the api key in storage or action to create\r\napi key and store into sessionStorage after callback.\r\n<img width=\"1255\" alt=\"Screenshot 2024-09-27 at 20 52 52\"\r\nsrc=\"https://github.com/user-attachments/assets/dc5bcd39-7fe6-433c-8aaa-ad3578a68b62\">\r\n<img width=\"1248\" alt=\"Screenshot 2024-09-27 at 20 52 39\"\r\nsrc=\"https://github.com/user-attachments/assets/d760c163-9017-4f57-ba1a-38ee8ee21534\">\r\n<img width=\"676\" alt=\"Screenshot 2024-09-27 at 20 52 28\"\r\nsrc=\"https://github.com/user-attachments/assets/e908d20a-7e0c-4f3b-9ea2-8e2d1a74c9eb\">","sha":"c5aa73991463dee50b036bb51645e03cc283bb8c"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/191926","number":191926,"mergeCommit":{"message":"[Search][Onboarding] api-key plugin (#191926)\n\n## Summary\r\nKibana plugin that helps manage the session for the api-key that\r\nprovides two exports:\r\n- React custom hook to read the api-key stored in session. This hook\r\nshould return the api-key if it exists, otherwise null.\r\n- Component to present either the api key in storage or action to create\r\napi key and store into sessionStorage after callback.\r\n<img width=\"1255\" alt=\"Screenshot 2024-09-27 at 20 52 52\"\r\nsrc=\"https://github.com/user-attachments/assets/dc5bcd39-7fe6-433c-8aaa-ad3578a68b62\">\r\n<img width=\"1248\" alt=\"Screenshot 2024-09-27 at 20 52 39\"\r\nsrc=\"https://github.com/user-attachments/assets/d760c163-9017-4f57-ba1a-38ee8ee21534\">\r\n<img width=\"676\" alt=\"Screenshot 2024-09-27 at 20 52 28\"\r\nsrc=\"https://github.com/user-attachments/assets/e908d20a-7e0c-4f3b-9ea2-8e2d1a74c9eb\">","sha":"c5aa73991463dee50b036bb51645e03cc283bb8c"}}]}] BACKPORT--> --------- Co-authored-by: Yan Savitski <[email protected]>
Flaky Test Runner Stats🎉 All tests passed! - kibana-flaky-test-suite-runner#7133[✅] x-pack/test_serverless/api_integration/test_suites/search/config.feature_flags.ts: 25/25 tests passed. |
Summary
Kibana plugin that helps manage the session for the api-key that provides two exports:
Checklist
Delete any items that are not applicable to this PR.