-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Workplace Search] Add Account Settings page imported from Security p…
…lugin (#99791) * Copy lazy_wrapper and suspense_error_boundary from Spaces plugin These components are needed to enable async loading of Security components into Enterprise Search. The components are copied without any changes except for i18n ids, so it's easier to DRY out in the future if needed. * Create async versions of personal_info and change_password components * Create ui_api that allows to load Security components asuncronously The patterns were mostly copied from Spaces plugin * Make ui_api available through Security components's lifecycle methods * Import Security plugin into Enterprise Search * Add Security plugin and Notifications service to Kibana Logic file * Export the required components from the Security plugin and use them in the new AccountSettings component * Update link to the Account Settings page * Move getUiApi call to security start and pass core instead of getStartServices * Simplify import of change_password_async component by providing... ... `notifications` and `userAPIClient` props in the security plugin * Remove UserAPIClient from ui_api It's not needed anymore since the components are initiated with this prop already passed * Export ChangePasswordProps and PersonalInfoProps from account_management/index.ts This makes it easier to import these props from outside the account_management folder * Remove notifications service from kibana_logic It is not needed anymore since we're initializing security components with notifications already provided * Add UiApi to SecurityPluginStart interface * Utilize index files for exporting Props types * Replace Pick<...> with two separate interfaces as it doesn't work well with our docs * Add a comment explaining why we're not loading async components through index file
- Loading branch information
1 parent
5ee5720
commit a9a834a
Showing
26 changed files
with
338 additions
and
8 deletions.
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
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.