Skip to content

Commit

Permalink
Sync UserProfile interface in kbn/user-profile-components package…
Browse files Browse the repository at this point in the history
… with the one in Security plugin. (#138704)
  • Loading branch information
azasypkin authored Aug 12, 2022
1 parent 5188e4b commit c868daa
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 2 deletions.
5 changes: 4 additions & 1 deletion examples/user_profile_examples/public/avatar_demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
7 changes: 6 additions & 1 deletion examples/user_profile_examples/public/popover_demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const PopoverDemo: FunctionComponent = () => {
const [selectedOptions, setSelectedOptions] = useState<UserProfileWithAvatar[]>([
{
uid: 'u_BOulL4QMPSyV9jg5lQI2JmCkUnokHTazBnet3xVHNv0_0',
enabled: true,
data: {},
user: {
username: 'delighted_nightingale',
Expand All @@ -26,6 +27,7 @@ export const PopoverDemo: FunctionComponent = () => {
const defaultOptions: UserProfileWithAvatar[] = [
{
uid: 'u_J41Oh6L9ki-Vo2tOogS8WRTENzhHurGtRc87NgEAlkc_0',
enabled: true,
data: {},
user: {
username: 'damaged_raccoon',
Expand All @@ -35,6 +37,7 @@ export const PopoverDemo: FunctionComponent = () => {
},
{
uid: 'u_A_tM4n0wPkdiQ9smmd8o0Hr_h61XQfu8aRPh9GMoRoc_0',
enabled: true,
data: {},
user: {
username: 'physical_dinosaur',
Expand All @@ -44,6 +47,7 @@ export const PopoverDemo: FunctionComponent = () => {
},
{
uid: 'u_9xDEQqUqoYCnFnPPLq5mIRHKL8gBTo_NiKgOnd5gGk0_0',
enabled: true,
data: {},
user: {
username: 'wet_dingo',
Expand Down Expand Up @@ -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',
Expand All @@ -92,7 +97,7 @@ const [selectedOptions, setSelectedOptions] = useState([
},
]);
<UserProfilesPopover
<UserProfilesPopover
title="Edit assignees"
button={
<EuiButton>
Expand Down
5 changes: 5 additions & 0 deletions examples/user_profile_examples/public/selectable_demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const SelectableDemo: FunctionComponent = () => {
const [selectedOptions, setSelectedOptions] = useState<UserProfileWithAvatar[]>([
{
uid: 'u_BOulL4QMPSyV9jg5lQI2JmCkUnokHTazBnet3xVHNv0_0',
enabled: true,
data: {},
user: {
username: 'delighted_nightingale',
Expand All @@ -25,6 +26,7 @@ export const SelectableDemo: FunctionComponent = () => {
const defaultOptions: UserProfileWithAvatar[] = [
{
uid: 'u_J41Oh6L9ki-Vo2tOogS8WRTENzhHurGtRc87NgEAlkc_0',
enabled: true,
data: {},
user: {
username: 'damaged_raccoon',
Expand All @@ -34,6 +36,7 @@ export const SelectableDemo: FunctionComponent = () => {
},
{
uid: 'u_A_tM4n0wPkdiQ9smmd8o0Hr_h61XQfu8aRPh9GMoRoc_0',
enabled: true,
data: {},
user: {
username: 'physical_dinosaur',
Expand All @@ -43,6 +46,7 @@ export const SelectableDemo: FunctionComponent = () => {
},
{
uid: 'u_9xDEQqUqoYCnFnPPLq5mIRHKL8gBTo_NiKgOnd5gGk0_0',
enabled: true,
data: {},
user: {
username: 'wet_dingo',
Expand All @@ -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',
Expand Down
5 changes: 5 additions & 0 deletions packages/kbn-user-profile-components/src/user_profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ export interface UserProfile<D extends UserProfileData = UserProfileData> {
*/
uid: string;

/**
* Indicates whether user profile is enabled or not.
*/
enabled: boolean;

/**
* Information about the user that owns profile.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { UserProfilesPopover } from './user_profiles_popover';
const userProfiles = [
{
uid: 'u_BOulL4QMPSyV9jg5lQI2JmCkUnokHTazBnet3xVHNv0_0',
enabled: true,
data: {},
user: {
username: 'delighted_nightingale',
Expand All @@ -23,6 +24,7 @@ const userProfiles = [
},
{
uid: 'u_J41Oh6L9ki-Vo2tOogS8WRTENzhHurGtRc87NgEAlkc_0',
enabled: true,
data: {},
user: {
username: 'damaged_raccoon',
Expand All @@ -32,6 +34,7 @@ const userProfiles = [
},
{
uid: 'u_A_tM4n0wPkdiQ9smmd8o0Hr_h61XQfu8aRPh9GMoRoc_0',
enabled: true,
data: {},
user: {
username: 'physical_dinosaur',
Expand All @@ -41,6 +44,7 @@ const userProfiles = [
},
{
uid: 'u_9xDEQqUqoYCnFnPPLq5mIRHKL8gBTo_NiKgOnd5gGk0_0',
enabled: true,
data: {},
user: {
username: 'wet_dingo',
Expand Down Expand Up @@ -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",
Expand All @@ -101,6 +106,7 @@ describe('UserProfilesPopover', () => {
Array [
Object {
"data": Object {},
"enabled": true,
"uid": "u_BOulL4QMPSyV9jg5lQI2JmCkUnokHTazBnet3xVHNv0_0",
"user": Object {
"email": "delighted_nightingale@profiles.elastic.co",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { UserProfilesSelectable } from './user_profiles_selectable';
const userProfiles = [
{
uid: 'u_BOulL4QMPSyV9jg5lQI2JmCkUnokHTazBnet3xVHNv0_0',
enabled: true,
data: {},
user: {
username: 'delighted_nightingale',
Expand All @@ -23,6 +24,7 @@ const userProfiles = [
},
{
uid: 'u_J41Oh6L9ki-Vo2tOogS8WRTENzhHurGtRc87NgEAlkc_0',
enabled: true,
data: {},
user: {
username: 'damaged_raccoon',
Expand All @@ -32,6 +34,7 @@ const userProfiles = [
},
{
uid: 'u_A_tM4n0wPkdiQ9smmd8o0Hr_h61XQfu8aRPh9GMoRoc_0',
enabled: true,
data: {},
user: {
username: 'physical_dinosaur',
Expand All @@ -41,6 +44,7 @@ const userProfiles = [
},
{
uid: 'u_9xDEQqUqoYCnFnPPLq5mIRHKL8gBTo_NiKgOnd5gGk0_0',
enabled: true,
data: {},
user: {
username: 'wet_dingo',
Expand Down

0 comments on commit c868daa

Please sign in to comment.