From 28d09492dc65c9e77af36fbb6437d2d04c5e5385 Mon Sep 17 00:00:00 2001 From: Aleh Zasypkin Date: Fri, 12 Aug 2022 10:23:10 +0200 Subject: [PATCH 1/3] Sync `UserProfile` interface in `kbn/user-profile-components` packages with the one in Security plugin. --- packages/kbn-user-profile-components/src/user_profile.ts | 5 +++++ .../src/user_profiles_popover.test.tsx | 6 ++++++ .../src/user_profiles_selectable.test.tsx | 4 ++++ 3 files changed, 15 insertions(+) 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', From 19ae485d25526b56229adc752d5816210a12639b Mon Sep 17 00:00:00 2001 From: Aleh Zasypkin Date: Fri, 12 Aug 2022 11:05:23 +0200 Subject: [PATCH 2/3] Update example plugin. --- examples/user_profile_examples/public/avatar_demo.tsx | 2 ++ examples/user_profile_examples/public/popover_demo.tsx | 7 ++++++- examples/user_profile_examples/public/selectable_demo.tsx | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/examples/user_profile_examples/public/avatar_demo.tsx b/examples/user_profile_examples/public/avatar_demo.tsx index b80bfa8b575a6..a0cb26b4df734 100644 --- a/examples/user_profile_examples/public/avatar_demo.tsx +++ b/examples/user_profile_examples/public/avatar_demo.tsx @@ -13,6 +13,7 @@ import { PanelWithCodeBlock } from './panel_with_code_block'; export const AvatarDemo: FunctionComponent = () => { const userProfile = { uid: 'u_J41Oh6L9ki-Vo2tOogS8WRTENzhHurGtRc87NgEAlkc_0', + enabled: true, user: { username: 'delighted_nightingale', email: 'delighted_nightingale@elastic.co', @@ -49,6 +50,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', From 69f40964573a4adac082b7e9ae72c3f18ef455e1 Mon Sep 17 00:00:00 2001 From: Aleh Zasypkin Date: Fri, 12 Aug 2022 17:05:40 +0200 Subject: [PATCH 3/3] Review#1: type mock user profiles in `avatar_demo`. --- examples/user_profile_examples/public/avatar_demo.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/user_profile_examples/public/avatar_demo.tsx b/examples/user_profile_examples/public/avatar_demo.tsx index a0cb26b4df734..061ce0fa0e8bc 100644 --- a/examples/user_profile_examples/public/avatar_demo.tsx +++ b/examples/user_profile_examples/public/avatar_demo.tsx @@ -8,10 +8,11 @@ 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: {