-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main' into ml-func-test-random…
…-sampler-controls
- Loading branch information
Showing
134 changed files
with
2,649 additions
and
2,212 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
import React, { FunctionComponent } from 'react'; | ||
import { UserAvatarTip, UserToolTip } from '@kbn/user-profile-components'; | ||
import type { UserProfile, UserProfileAvatarData } from '@kbn/user-profile-components'; | ||
import { EuiCommentList, EuiComment } from '@elastic/eui'; | ||
import { PanelWithCodeBlock } from './panel_with_code_block'; | ||
|
||
export const ToolTipDemo: FunctionComponent = () => { | ||
const userProfile: UserProfile<{ avatar: UserProfileAvatarData }> = { | ||
uid: 'u_9xDEQqUqoYCnFnPPLq5mIRHKL8gBTo_NiKgOnd5gGk0_0', | ||
enabled: true, | ||
user: { | ||
username: 'wet_dingo', | ||
email: 'wet_dingo@elastic.co', | ||
full_name: 'Wet Dingo', | ||
}, | ||
data: { | ||
avatar: { | ||
color: '#09e8ca', | ||
initials: 'WD', | ||
imageUrl: 'https://source.unsplash.com/64x64/?dingo', | ||
}, | ||
}, | ||
}; | ||
|
||
return ( | ||
<PanelWithCodeBlock title="Tooltip" code={code}> | ||
<EuiCommentList> | ||
<EuiComment | ||
timelineAvatar={ | ||
<UserAvatarTip user={userProfile.user} avatar={userProfile.data.avatar} /> | ||
} | ||
username={ | ||
<UserToolTip | ||
position="top" | ||
delay="regular" | ||
user={userProfile.user} | ||
avatar={userProfile.data.avatar} | ||
> | ||
<strong>{userProfile.user.full_name}</strong> | ||
</UserToolTip> | ||
} | ||
event="pushed incident X0Z235 on Jan 3, 2020" | ||
/> | ||
</EuiCommentList> | ||
</PanelWithCodeBlock> | ||
); | ||
}; | ||
|
||
const code = `import { UserToolTip, UserAvatarTip } from '@kbn/user-profile-components'; | ||
<UserToolTip user={userProfile.user} avatar={userProfile.data.avatar}> | ||
<!-- An inline element to trigger the tooltip --> | ||
</UserToolTip> | ||
<UserAvatarTip user={userProfile.user} avatar={userProfile.data.avatar} />`; |
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
73 changes: 73 additions & 0 deletions
73
packages/kbn-user-profile-components/src/user_avatar_tip.test.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,73 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { shallow } from 'enzyme'; | ||
import React from 'react'; | ||
|
||
import { UserAvatarTip } from './user_avatar_tip'; | ||
|
||
describe('UserAvatarTip', () => { | ||
it('should render `UserToolTip` correctly with `UserAvatar`', () => { | ||
const wrapper = shallow( | ||
<UserAvatarTip | ||
user={{ | ||
username: 'delighted_nightingale', | ||
email: 'delighted_nightingale@elastic.co', | ||
full_name: 'Delighted Nightingale', | ||
}} | ||
avatar={{ | ||
color: '#09e8ca', | ||
initials: 'DN', | ||
imageUrl: 'https://source.unsplash.com/64x64/?cat', | ||
}} | ||
/> | ||
); | ||
expect(wrapper).toMatchInlineSnapshot(` | ||
<UserToolTip | ||
avatar={ | ||
Object { | ||
"color": "#09e8ca", | ||
"imageUrl": "https://source.unsplash.com/64x64/?cat", | ||
"initials": "DN", | ||
} | ||
} | ||
delay="regular" | ||
position="top" | ||
user={ | ||
Object { | ||
"email": "delighted_nightingale@elastic.co", | ||
"full_name": "Delighted Nightingale", | ||
"username": "delighted_nightingale", | ||
} | ||
} | ||
> | ||
<UserAvatar | ||
avatar={ | ||
Object { | ||
"color": "#09e8ca", | ||
"imageUrl": "https://source.unsplash.com/64x64/?cat", | ||
"initials": "DN", | ||
} | ||
} | ||
user={ | ||
Object { | ||
"email": "delighted_nightingale@elastic.co", | ||
"full_name": "Delighted Nightingale", | ||
"username": "delighted_nightingale", | ||
} | ||
} | ||
/> | ||
</UserToolTip> | ||
`); | ||
}); | ||
|
||
it('should not render `UserToolTip` when user is not set', () => { | ||
const wrapper = shallow(<UserAvatarTip />); | ||
expect(wrapper).toMatchInlineSnapshot(`<UserAvatar />`); | ||
}); | ||
}); |
29 changes: 29 additions & 0 deletions
29
packages/kbn-user-profile-components/src/user_avatar_tip.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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import type { FunctionComponent } from 'react'; | ||
import React from 'react'; | ||
|
||
import type { UserAvatarProps } from './user_avatar'; | ||
import { UserAvatar } from './user_avatar'; | ||
import { UserToolTip } from './user_tooltip'; | ||
|
||
/** | ||
* Renders a user avatar with tooltip | ||
*/ | ||
export const UserAvatarTip: FunctionComponent<UserAvatarProps> = ({ user, avatar, ...rest }) => { | ||
if (!user) { | ||
return <UserAvatar {...rest} />; | ||
} | ||
|
||
return ( | ||
<UserToolTip user={user} avatar={avatar} position="top" delay="regular"> | ||
<UserAvatar user={user} avatar={avatar} {...rest} /> | ||
</UserToolTip> | ||
); | ||
}; |
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
91 changes: 91 additions & 0 deletions
91
packages/kbn-user-profile-components/src/user_tooltip.test.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,91 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { shallow } from 'enzyme'; | ||
import React from 'react'; | ||
|
||
import { UserToolTip } from './user_tooltip'; | ||
|
||
describe('UserToolTip', () => { | ||
it('should render `EuiToolTip` correctly with `UserAvatar`', () => { | ||
const wrapper = shallow( | ||
<UserToolTip | ||
user={{ | ||
username: 'delighted_nightingale', | ||
email: 'delighted_nightingale@elastic.co', | ||
full_name: 'Delighted Nightingale', | ||
}} | ||
avatar={{ | ||
color: '#09e8ca', | ||
initials: 'DN', | ||
imageUrl: 'https://source.unsplash.com/64x64/?cat', | ||
}} | ||
position="top" | ||
delay="regular" | ||
> | ||
<button>Toggle</button> | ||
</UserToolTip> | ||
); | ||
expect(wrapper).toMatchInlineSnapshot(` | ||
<EuiToolTip | ||
content={ | ||
<EuiFlexGroup | ||
alignItems="center" | ||
gutterSize="s" | ||
> | ||
<EuiFlexItem | ||
grow={false} | ||
> | ||
<UserAvatar | ||
avatar={ | ||
Object { | ||
"color": "#09e8ca", | ||
"imageUrl": "https://source.unsplash.com/64x64/?cat", | ||
"initials": "DN", | ||
} | ||
} | ||
size="l" | ||
user={ | ||
Object { | ||
"email": "delighted_nightingale@elastic.co", | ||
"full_name": "Delighted Nightingale", | ||
"username": "delighted_nightingale", | ||
} | ||
} | ||
/> | ||
</EuiFlexItem> | ||
<EuiFlexItem | ||
grow={true} | ||
> | ||
<EuiFlexGroup | ||
direction="column" | ||
gutterSize="none" | ||
> | ||
<EuiFlexItem> | ||
<strong> | ||
Delighted Nightingale | ||
</strong> | ||
</EuiFlexItem> | ||
<EuiFlexItem> | ||
delighted_nightingale@elastic.co | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
} | ||
delay="regular" | ||
display="inlineBlock" | ||
position="top" | ||
> | ||
<button> | ||
Toggle | ||
</button> | ||
</EuiToolTip> | ||
`); | ||
}); | ||
}); |
Oops, something went wrong.