-
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
[Workplace Search] Add Account Settings page imported from Security plugin #99791
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
4d7bb8a
Copy lazy_wrapper and suspense_error_boundary from Spaces plugin
yakhinvadim c416ab9
Create async versions of personal_info and change_password components
yakhinvadim f994ba5
Create ui_api that allows to load Security components asuncronously
yakhinvadim e09f42a
Make ui_api available through Security components's lifecycle methods
yakhinvadim 897615a
Import Security plugin into Enterprise Search
yakhinvadim 3080c1c
Add Security plugin and Notifications service to Kibana Logic file
yakhinvadim cfc1386
Export the required components from the Security plugin and
yakhinvadim efa7d68
Update link to the Account Settings page
yakhinvadim 62aab12
Merge branch 'master' into account-settings
yakhinvadim 4f8f832
Move getUiApi call to security start and pass core instead of getStar…
yakhinvadim 9f18ea9
Simplify import of change_password_async component by providing...
yakhinvadim 706ac2e
Remove UserAPIClient from ui_api
yakhinvadim ebc2753
Export ChangePasswordProps and PersonalInfoProps from account_managem…
yakhinvadim 140cd91
Remove notifications service from kibana_logic
yakhinvadim e152365
Merge branch 'master' into account-settings
yakhinvadim 8ec9379
Add UiApi to SecurityPluginStart interface
yakhinvadim 9b932dc
Utilize index files for exporting Props types
yakhinvadim 2425821
Replace Pick<...> with two separate interfaces as it doesn't work wel…
yakhinvadim 1880755
Add a comment explaining why we're not loading async components throu…
yakhinvadim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,6 @@ export const SETUP_GUIDE_PATH = '/setup_guide'; | |
|
||
export const NOT_FOUND_PATH = '/404'; | ||
export const LOGOUT_ROUTE = '/logout'; | ||
export const KIBANA_ACCOUNT_ROUTE = '/security/account'; | ||
|
||
export const LEAVE_FEEDBACK_EMAIL = '[email protected]'; | ||
export const LEAVE_FEEDBACK_URL = `mailto:${LEAVE_FEEDBACK_EMAIL}?Subject=Elastic%20Workplace%20Search%20Feedback`; | ||
|
39 changes: 39 additions & 0 deletions
39
...e_search/public/applications/workplace_search/views/account_settings/account_settings.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React, { useState, useEffect, useMemo } from 'react'; | ||
|
||
import { useValues } from 'kea'; | ||
|
||
import type { AuthenticatedUser } from '../../../../../../security/public'; | ||
import { KibanaLogic } from '../../../shared/kibana/kibana_logic'; | ||
|
||
export const AccountSettings: React.FC = () => { | ||
const { security } = useValues(KibanaLogic); | ||
|
||
const [currentUser, setCurrentUser] = useState<AuthenticatedUser | null>(null); | ||
|
||
useEffect(() => { | ||
security!.authc!.getCurrentUser().then(setCurrentUser); | ||
}, [security.authc]); | ||
|
||
const PersonalInfo = useMemo(() => security!.uiApi!.components.getPersonalInfo, [security.uiApi]); | ||
const ChangePassword = useMemo(() => security!.uiApi!.components.getChangePassword, [ | ||
security.uiApi, | ||
]); | ||
|
||
if (!currentUser) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<> | ||
<PersonalInfo user={currentUser} /> | ||
<ChangePassword user={currentUser} /> | ||
</> | ||
); | ||
}; |
8 changes: 8 additions & 0 deletions
8
...ns/enterprise_search/public/applications/workplace_search/views/account_settings/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
export { AccountSettings } from './account_settings'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
x-pack/plugins/security/public/account_management/change_password/change_password_async.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import type { CoreStart } from 'src/core/public'; | ||
|
||
import { UserAPIClient } from '../../management/users'; | ||
import type { ChangePasswordProps } from './change_password'; | ||
|
||
export const getChangePasswordComponent = async ( | ||
core: CoreStart | ||
): Promise<React.FC<ChangePasswordProps>> => { | ||
const { ChangePassword } = await import('./change_password'); | ||
|
||
return (props: ChangePasswordProps) => { | ||
return ( | ||
<ChangePassword | ||
notifications={core.notifications} | ||
userAPIClient={new UserAPIClient(core.http)} | ||
{...props} | ||
/> | ||
); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,5 @@ | |
*/ | ||
|
||
export { PersonalInfo } from './personal_info'; | ||
|
||
export type { PersonalInfoProps } from './personal_info'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
x-pack/plugins/security/public/account_management/personal_info/personal_info_async.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import type { PersonalInfoProps } from './personal_info'; | ||
|
||
export const getPersonalInfoComponent = async (): Promise<React.FC<PersonalInfoProps>> => { | ||
const { PersonalInfo } = await import('./personal_info'); | ||
return (props: PersonalInfoProps) => { | ||
return <PersonalInfo {...props} />; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
x-pack/plugins/security/public/suspense_error_boundary/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
export { SuspenseErrorBoundary } from './suspense_error_boundary'; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
question: won't we have an unhandled exception here in case security plugin is disabled?
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.
Thanks for checking our plugin code as well! Good question.
No, if this component loads, we are guaranteed to have the security plugin enabled.
One of the requirements for being able to run Workplace Search is to have security enabled (see Step 2 in our installation docs). If security is disabled, Workplace Search won't run and this page could not be opened.
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.
Got it, thanks for clarifying! Was just confused by these
!
and was wondering ifsecurity
and its properties can really beundefined
or not (by the way it seems!
isn't strictly needed forsecurity
itself and is only needed to access its properties).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.
You're right. I guess I overdid it here. 😄
I plan to do a follow-up PR with some cleanup in the enterprise_search plugin only.
I'll update this line there if you don't mind.
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.
Sounds good to me 👍