From 5125f252b97c5f797edcc9c77b93c3e3088ba466 Mon Sep 17 00:00:00 2001 From: Aleh Zasypkin Date: Fri, 12 Aug 2022 21:56:13 +0200 Subject: [PATCH] Sync `UserProfile` interface in `kbn/user-profile-components` package with the one in Security plugin. (#138704) --- examples/user_profile_examples/public/avatar_demo.tsx | 5 ++++- examples/user_profile_examples/public/popover_demo.tsx | 7 ++++++- examples/user_profile_examples/public/selectable_demo.tsx | 5 +++++ packages/kbn-user-profile-components/src/user_profile.ts | 5 +++++ .../src/user_profiles_popover.test.tsx | 6 ++++++ .../src/user_profiles_selectable.test.tsx | 4 ++++ 6 files changed, 30 insertions(+), 2 deletions(-) diff --git a/examples/user_profile_examples/public/avatar_demo.tsx b/examples/user_profile_examples/public/avatar_demo.tsx index b80bfa8b575a6..061ce0fa0e8bc 100644 --- a/examples/user_profile_examples/public/avatar_demo.tsx +++ b/examples/user_profile_examples/public/avatar_demo.tsx @@ -8,11 +8,13 @@ import React, { FunctionComponent } from 'react'; import { EuiTitle, EuiSpacer } from '@elastic/eui'; import { UserAvatar } from '@kbn/user-profile-components'; +import type { UserProfile, UserProfileAvatarData } from '@kbn/user-profile-components'; import { PanelWithCodeBlock } from './panel_with_code_block'; export const AvatarDemo: FunctionComponent = () => { - const userProfile = { + const userProfile: UserProfile<{ avatar: UserProfileAvatarData }> = { uid: 'u_J41Oh6L9ki-Vo2tOogS8WRTENzhHurGtRc87NgEAlkc_0', + enabled: true, user: { username: 'delighted_nightingale', email: 'delighted_nightingale@elastic.co', @@ -49,6 +51,7 @@ const code = `import { UserAvatar } from '@kbn/user-profile-components'; const userProfile = { uid: 'u_J41Oh6L9ki-Vo2tOogS8WRTENzhHurGtRc87NgEAlkc_0', + enabled: true, user: { username: 'delighted_nightingale', email: 'delighted_nightingale@elastic.co', diff --git a/examples/user_profile_examples/public/popover_demo.tsx b/examples/user_profile_examples/public/popover_demo.tsx index 5b9ef060fd277..243441ee12aa1 100644 --- a/examples/user_profile_examples/public/popover_demo.tsx +++ b/examples/user_profile_examples/public/popover_demo.tsx @@ -15,6 +15,7 @@ export const PopoverDemo: FunctionComponent = () => { const [selectedOptions, setSelectedOptions] = useState([ { uid: 'u_BOulL4QMPSyV9jg5lQI2JmCkUnokHTazBnet3xVHNv0_0', + enabled: true, data: {}, user: { username: 'delighted_nightingale', @@ -26,6 +27,7 @@ export const PopoverDemo: FunctionComponent = () => { const defaultOptions: UserProfileWithAvatar[] = [ { uid: 'u_J41Oh6L9ki-Vo2tOogS8WRTENzhHurGtRc87NgEAlkc_0', + enabled: true, data: {}, user: { username: 'damaged_raccoon', @@ -35,6 +37,7 @@ export const PopoverDemo: FunctionComponent = () => { }, { uid: 'u_A_tM4n0wPkdiQ9smmd8o0Hr_h61XQfu8aRPh9GMoRoc_0', + enabled: true, data: {}, user: { username: 'physical_dinosaur', @@ -44,6 +47,7 @@ export const PopoverDemo: FunctionComponent = () => { }, { uid: 'u_9xDEQqUqoYCnFnPPLq5mIRHKL8gBTo_NiKgOnd5gGk0_0', + enabled: true, data: {}, user: { username: 'wet_dingo', @@ -83,6 +87,7 @@ const code = `import { UserProfilesPopover } from '@kbn/user-profile-components' const [selectedOptions, setSelectedOptions] = useState([ { uid: 'u_BOulL4QMPSyV9jg5lQI2JmCkUnokHTazBnet3xVHNv0_0', + enabled: true, data: {}, user: { username: 'delighted_nightingale', @@ -92,7 +97,7 @@ const [selectedOptions, setSelectedOptions] = useState([ }, ]); - diff --git a/examples/user_profile_examples/public/selectable_demo.tsx b/examples/user_profile_examples/public/selectable_demo.tsx index 09b0f6ce54758..d5116cf4aee01 100644 --- a/examples/user_profile_examples/public/selectable_demo.tsx +++ b/examples/user_profile_examples/public/selectable_demo.tsx @@ -13,6 +13,7 @@ export const SelectableDemo: FunctionComponent = () => { const [selectedOptions, setSelectedOptions] = useState([ { uid: 'u_BOulL4QMPSyV9jg5lQI2JmCkUnokHTazBnet3xVHNv0_0', + enabled: true, data: {}, user: { username: 'delighted_nightingale', @@ -25,6 +26,7 @@ export const SelectableDemo: FunctionComponent = () => { const defaultOptions: UserProfileWithAvatar[] = [ { uid: 'u_J41Oh6L9ki-Vo2tOogS8WRTENzhHurGtRc87NgEAlkc_0', + enabled: true, data: {}, user: { username: 'damaged_raccoon', @@ -34,6 +36,7 @@ export const SelectableDemo: FunctionComponent = () => { }, { uid: 'u_A_tM4n0wPkdiQ9smmd8o0Hr_h61XQfu8aRPh9GMoRoc_0', + enabled: true, data: {}, user: { username: 'physical_dinosaur', @@ -43,6 +46,7 @@ export const SelectableDemo: FunctionComponent = () => { }, { uid: 'u_9xDEQqUqoYCnFnPPLq5mIRHKL8gBTo_NiKgOnd5gGk0_0', + enabled: true, data: {}, user: { username: 'wet_dingo', @@ -68,6 +72,7 @@ const code = `import { UserProfilesSelectable } from '@kbn/user-profile-componen const [selectedOptions, setSelectedOptions] = useState([ { uid: 'u_BOulL4QMPSyV9jg5lQI2JmCkUnokHTazBnet3xVHNv0_0', + enabled: true, data: {}, user: { username: 'delighted_nightingale', diff --git a/packages/kbn-user-profile-components/src/user_profile.ts b/packages/kbn-user-profile-components/src/user_profile.ts index 59c5f2f5a12a8..eb6f67f1d25ca 100644 --- a/packages/kbn-user-profile-components/src/user_profile.ts +++ b/packages/kbn-user-profile-components/src/user_profile.ts @@ -26,6 +26,11 @@ export interface UserProfile { */ uid: string; + /** + * Indicates whether user profile is enabled or not. + */ + enabled: boolean; + /** * Information about the user that owns profile. */ diff --git a/packages/kbn-user-profile-components/src/user_profiles_popover.test.tsx b/packages/kbn-user-profile-components/src/user_profiles_popover.test.tsx index 608ea32f7caa6..b0d0806a0def9 100644 --- a/packages/kbn-user-profile-components/src/user_profiles_popover.test.tsx +++ b/packages/kbn-user-profile-components/src/user_profiles_popover.test.tsx @@ -14,6 +14,7 @@ import { UserProfilesPopover } from './user_profiles_popover'; const userProfiles = [ { uid: 'u_BOulL4QMPSyV9jg5lQI2JmCkUnokHTazBnet3xVHNv0_0', + enabled: true, data: {}, user: { username: 'delighted_nightingale', @@ -23,6 +24,7 @@ const userProfiles = [ }, { uid: 'u_J41Oh6L9ki-Vo2tOogS8WRTENzhHurGtRc87NgEAlkc_0', + enabled: true, data: {}, user: { username: 'damaged_raccoon', @@ -32,6 +34,7 @@ const userProfiles = [ }, { uid: 'u_A_tM4n0wPkdiQ9smmd8o0Hr_h61XQfu8aRPh9GMoRoc_0', + enabled: true, data: {}, user: { username: 'physical_dinosaur', @@ -41,6 +44,7 @@ const userProfiles = [ }, { uid: 'u_9xDEQqUqoYCnFnPPLq5mIRHKL8gBTo_NiKgOnd5gGk0_0', + enabled: true, data: {}, user: { username: 'wet_dingo', @@ -88,6 +92,7 @@ describe('UserProfilesPopover', () => { Array [ Object { "data": Object {}, + "enabled": true, "uid": "u_J41Oh6L9ki-Vo2tOogS8WRTENzhHurGtRc87NgEAlkc_0", "user": Object { "email": "damaged_raccoon@profiles.elastic.co", @@ -101,6 +106,7 @@ describe('UserProfilesPopover', () => { Array [ Object { "data": Object {}, + "enabled": true, "uid": "u_BOulL4QMPSyV9jg5lQI2JmCkUnokHTazBnet3xVHNv0_0", "user": Object { "email": "delighted_nightingale@profiles.elastic.co", diff --git a/packages/kbn-user-profile-components/src/user_profiles_selectable.test.tsx b/packages/kbn-user-profile-components/src/user_profiles_selectable.test.tsx index 6231a3c2f1509..bdb0be25ce9cf 100644 --- a/packages/kbn-user-profile-components/src/user_profiles_selectable.test.tsx +++ b/packages/kbn-user-profile-components/src/user_profiles_selectable.test.tsx @@ -14,6 +14,7 @@ import { UserProfilesSelectable } from './user_profiles_selectable'; const userProfiles = [ { uid: 'u_BOulL4QMPSyV9jg5lQI2JmCkUnokHTazBnet3xVHNv0_0', + enabled: true, data: {}, user: { username: 'delighted_nightingale', @@ -23,6 +24,7 @@ const userProfiles = [ }, { uid: 'u_J41Oh6L9ki-Vo2tOogS8WRTENzhHurGtRc87NgEAlkc_0', + enabled: true, data: {}, user: { username: 'damaged_raccoon', @@ -32,6 +34,7 @@ const userProfiles = [ }, { uid: 'u_A_tM4n0wPkdiQ9smmd8o0Hr_h61XQfu8aRPh9GMoRoc_0', + enabled: true, data: {}, user: { username: 'physical_dinosaur', @@ -41,6 +44,7 @@ const userProfiles = [ }, { uid: 'u_9xDEQqUqoYCnFnPPLq5mIRHKL8gBTo_NiKgOnd5gGk0_0', + enabled: true, data: {}, user: { username: 'wet_dingo',