Skip to content

Commit

Permalink
Merge branch 'main' into cft/skip-requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
jbudz authored Oct 3, 2022
2 parents 7559d03 + 8ad95df commit 7873445
Show file tree
Hide file tree
Showing 110 changed files with 2,181 additions and 1,953 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

The {sn-itom} connector uses the
https://docs.servicenow.com/bundle/rome-it-operations-management/page/product/event-management/task/send-events-via-web-service.html[event API]
to create {sn} events.
to create {sn} events. You can use the connector for rule actions.

[float]
[[servicenow-itom-connector-prerequisites]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

The {sn-sir} connector uses the
https://developer.servicenow.com/dev.do#!/reference/api/sandiego/rest/c_ImportSetAPI[import set API]
to create {sn} security incidents.
to create {sn} security incidents. You can use the connector for rule actions and cases.

[float]
[[servicenow-sir-connector-prerequisites]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

The {sn-itsm} connector uses the
https://developer.servicenow.com/dev.do#!/reference/api/sandiego/rest/c_ImportSetAPI[import set API]
to create {sn} incidents.
to create {sn} incidents. You can use the connector for rule actions and cases.

[float]
[[servicenow-itsm-connector-prerequisites]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,5 @@ export const PanelWithCodeBlock: React.FunctionComponent<PanelWithCodeBlockProps
</EuiCodeBlock>
</EuiSplitPanel.Inner>
</EuiSplitPanel.Outer>
<EuiSpacer size="l" />
</>
);
23 changes: 15 additions & 8 deletions examples/user_profile_examples/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { KibanaPageTemplate } from '@kbn/shared-ux-page-kibana-template';
import { AvatarDemo } from './avatar_demo';
import { PopoverDemo } from './popover_demo';
import { SelectableDemo } from './selectable_demo';
import { ToolTipDemo } from './tooltip_demo';

interface SetupDeps {
developerExamples: DeveloperExamplesSetup;
Expand All @@ -38,14 +39,20 @@ export class UserProfilesPlugin implements Plugin<void, void, SetupDeps, StartDe
// });

ReactDOM.render(
<KibanaPageTemplate
pageHeader={{
pageTitle: 'User profile components',
}}
>
<AvatarDemo />
<SelectableDemo />
<PopoverDemo />
<KibanaPageTemplate>
<KibanaPageTemplate.Header pageTitle="User profile components" />
<KibanaPageTemplate.Section>
<AvatarDemo />
</KibanaPageTemplate.Section>
<KibanaPageTemplate.Section>
<ToolTipDemo />
</KibanaPageTemplate.Section>
<KibanaPageTemplate.Section>
<SelectableDemo />
</KibanaPageTemplate.Section>
<KibanaPageTemplate.Section>
<PopoverDemo />
</KibanaPageTemplate.Section>
</KibanaPageTemplate>,
element
);
Expand Down
62 changes: 62 additions & 0 deletions examples/user_profile_examples/public/tooltip_demo.tsx
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: '[email protected]',
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} />`;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@
"react-fast-compare": "^2.0.4",
"react-focus-on": "^3.6.0",
"react-grid-layout": "^1.3.4",
"react-hook-form": "^7.35.0",
"react-hook-form": "^7.36.1",
"react-intl": "^2.8.0",
"react-is": "^17.0.2",
"react-markdown": "^6.0.3",
Expand Down
3 changes: 3 additions & 0 deletions packages/kbn-user-profile-components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
*/

export type { UserAvatarProps, UserProfileWithAvatar } from './src/user_avatar';
export type { UserToolTipProps } from './src/user_tooltip';
export type { UserProfilesSelectableProps } from './src/user_profiles_selectable';
export type { UserProfilesPopoverProps } from './src/user_profiles_popover';
export { UserAvatar } from './src/user_avatar';
export { UserAvatarTip } from './src/user_avatar_tip';
export { UserToolTip } from './src/user_tooltip';
export { UserProfilesSelectable } from './src/user_profiles_selectable';
export { UserProfilesPopover } from './src/user_profiles_popover';
export { getUserDisplayName } from './src/user_profile';
Expand Down
73 changes: 73 additions & 0 deletions packages/kbn-user-profile-components/src/user_avatar_tip.test.tsx
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: '[email protected]',
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": "[email protected]",
"full_name": "Delighted Nightingale",
"username": "delighted_nightingale",
}
}
>
<UserAvatar
avatar={
Object {
"color": "#09e8ca",
"imageUrl": "https://source.unsplash.com/64x64/?cat",
"initials": "DN",
}
}
user={
Object {
"email": "[email protected]",
"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 packages/kbn-user-profile-components/src/user_avatar_tip.tsx
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>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ export const UserProfilesSelectable = <Option extends UserProfileWithAvatar | nu
<EuiFlexItem grow={false}>
<EuiHighlight search={searchValue}>{option.label}</EuiHighlight>
</EuiFlexItem>
{option.user.email ? (
{option.user.email && option.user.email !== option.label ? (
<EuiFlexItem grow={false}>
<EuiTextColor color="subdued">
{searchValue ? (
Expand Down
91 changes: 91 additions & 0 deletions packages/kbn-user-profile-components/src/user_tooltip.test.tsx
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: '[email protected]',
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": "[email protected]",
"full_name": "Delighted Nightingale",
"username": "delighted_nightingale",
}
}
/>
</EuiFlexItem>
<EuiFlexItem
grow={true}
>
<EuiFlexGroup
direction="column"
gutterSize="none"
>
<EuiFlexItem>
<strong>
Delighted Nightingale
</strong>
</EuiFlexItem>
<EuiFlexItem>
[email protected]
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem>
</EuiFlexGroup>
}
delay="regular"
display="inlineBlock"
position="top"
>
<button>
Toggle
</button>
</EuiToolTip>
`);
});
});
Loading

0 comments on commit 7873445

Please sign in to comment.