@atlaskit/smart-card 26.13.0 → 26.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/constants.js +5 -0
  3. package/dist/cjs/extractors/flexible/index.js +5 -0
  4. package/dist/cjs/extractors/flexible/utils.js +23 -2
  5. package/dist/cjs/extractors/hover/extractMetadata.js +2 -1
  6. package/dist/cjs/messages.js +31 -1
  7. package/dist/cjs/version.json +1 -1
  8. package/dist/cjs/view/BlockCard/views/flexible/FlexibleResolvedView.js +21 -37
  9. package/dist/cjs/view/BlockCard/views/flexible/FlexibleUnauthorisedView.js +15 -5
  10. package/dist/cjs/view/BlockCard/views/flexible/styled.js +15 -0
  11. package/dist/cjs/view/BlockCard/views/flexible/utils.js +116 -0
  12. package/dist/cjs/view/EmbedCard/views/UnauthorisedView.js +31 -18
  13. package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +1 -1
  14. package/dist/cjs/view/FlexibleCard/components/elements/index.js +33 -4
  15. package/dist/cjs/view/FlexibleCard/components/elements/utils.js +20 -0
  16. package/dist/cjs/view/HoverCard/components/views/resolved/index.js +28 -12
  17. package/dist/cjs/view/HoverCard/utils.js +102 -3
  18. package/dist/es2019/constants.js +6 -0
  19. package/dist/es2019/extractors/flexible/index.js +7 -2
  20. package/dist/es2019/extractors/flexible/utils.js +18 -1
  21. package/dist/es2019/extractors/hover/extractMetadata.js +1 -1
  22. package/dist/es2019/messages.js +31 -1
  23. package/dist/es2019/version.json +1 -1
  24. package/dist/es2019/view/BlockCard/views/flexible/FlexibleResolvedView.js +24 -38
  25. package/dist/es2019/view/BlockCard/views/flexible/FlexibleUnauthorisedView.js +13 -5
  26. package/dist/es2019/view/BlockCard/views/flexible/styled.js +14 -0
  27. package/dist/es2019/view/BlockCard/views/flexible/utils.js +108 -0
  28. package/dist/es2019/view/EmbedCard/views/UnauthorisedView.js +33 -20
  29. package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +5 -0
  30. package/dist/es2019/view/FlexibleCard/components/elements/index.js +24 -0
  31. package/dist/es2019/view/FlexibleCard/components/elements/utils.js +25 -0
  32. package/dist/es2019/view/HoverCard/components/views/resolved/index.js +30 -14
  33. package/dist/es2019/view/HoverCard/utils.js +100 -1
  34. package/dist/esm/constants.js +6 -0
  35. package/dist/esm/extractors/flexible/index.js +7 -2
  36. package/dist/esm/extractors/flexible/utils.js +18 -1
  37. package/dist/esm/extractors/hover/extractMetadata.js +1 -1
  38. package/dist/esm/messages.js +31 -1
  39. package/dist/esm/version.json +1 -1
  40. package/dist/esm/view/BlockCard/views/flexible/FlexibleResolvedView.js +23 -38
  41. package/dist/esm/view/BlockCard/views/flexible/FlexibleUnauthorisedView.js +15 -5
  42. package/dist/esm/view/BlockCard/views/flexible/styled.js +7 -0
  43. package/dist/esm/view/BlockCard/views/flexible/utils.js +108 -0
  44. package/dist/esm/view/EmbedCard/views/UnauthorisedView.js +33 -20
  45. package/dist/esm/view/FlexibleCard/components/blocks/utils.js +1 -1
  46. package/dist/esm/view/FlexibleCard/components/elements/index.js +24 -0
  47. package/dist/esm/view/FlexibleCard/components/elements/utils.js +20 -0
  48. package/dist/esm/view/HoverCard/components/views/resolved/index.js +30 -14
  49. package/dist/esm/view/HoverCard/utils.js +98 -1
  50. package/dist/types/constants.d.ts +5 -0
  51. package/dist/types/extractors/flexible/utils.d.ts +5 -0
  52. package/dist/types/extractors/hover/extractMetadata.d.ts +2 -0
  53. package/dist/types/messages.d.ts +1 -1
  54. package/dist/types/state/flexible-ui-context/types.d.ts +25 -0
  55. package/dist/types/view/BlockCard/views/flexible/styled.d.ts +2 -0
  56. package/dist/types/view/BlockCard/views/flexible/utils.d.ts +10 -0
  57. package/dist/types/view/FlexibleCard/components/blocks/types.d.ts +35 -2
  58. package/dist/types/view/FlexibleCard/components/elements/index.d.ts +24 -0
  59. package/dist/types/view/HoverCard/utils.d.ts +1 -0
  60. package/dist/types-ts4.5/constants.d.ts +5 -0
  61. package/dist/types-ts4.5/extractors/flexible/utils.d.ts +5 -0
  62. package/dist/types-ts4.5/extractors/hover/extractMetadata.d.ts +2 -0
  63. package/dist/types-ts4.5/messages.d.ts +1 -1
  64. package/dist/types-ts4.5/state/flexible-ui-context/types.d.ts +25 -0
  65. package/dist/types-ts4.5/view/BlockCard/views/flexible/styled.d.ts +2 -0
  66. package/dist/types-ts4.5/view/BlockCard/views/flexible/utils.d.ts +10 -0
  67. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/types.d.ts +35 -2
  68. package/dist/types-ts4.5/view/FlexibleCard/components/elements/index.d.ts +24 -0
  69. package/dist/types-ts4.5/view/HoverCard/utils.d.ts +1 -0
  70. package/package.json +5 -2
  71. package/report.api.md +40 -0
  72. package/tmp/api-report-tmp.d.ts +36 -1
@@ -1,4 +1,6 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
1
2
  import React, { useCallback, useMemo } from 'react';
3
+ import { FormattedMessage } from 'react-intl-next';
2
4
  import FlexibleCard from '../../../FlexibleCard';
3
5
  import { AuthorizeAction } from '../../actions/flexible/AuthorizeAction';
4
6
  import BlockCardFooter from '../../components/flexible/footer';
@@ -8,6 +10,7 @@ import { extractProvider } from '@atlaskit/link-extractors';
8
10
  import UnauthorisedViewContent from '../../../common/UnauthorisedViewContent';
9
11
  import { css } from '@emotion/react';
10
12
  import { tokens } from '../../../../utils/token';
13
+ import { messages } from '../../../../messages';
11
14
  const contentStyles = css`
12
15
  color: ${tokens.text};
13
16
  margin-top: 0.5rem;
@@ -44,6 +47,15 @@ const FlexibleUnauthorisedView = ({
44
47
  onAuthorize();
45
48
  }
46
49
  }, [onAuthorize, extensionKey, analytics.track]);
50
+ const content = useMemo(() => onAuthorize ? /*#__PURE__*/React.createElement(UnauthorisedViewContent, {
51
+ providerName: providerName,
52
+ analytics: analytics,
53
+ testId: testId
54
+ }) : /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages[providerName ? 'unauthorised_account_description' : 'unauthorised_account_description_no_provider'], {
55
+ values: {
56
+ context: providerName
57
+ }
58
+ })), [analytics, onAuthorize, providerName, testId]);
47
59
  const actions = useMemo(() => onAuthorize ? [AuthorizeAction(handleAuthorize, providerName)] : [], [handleAuthorize, onAuthorize, providerName]);
48
60
  return /*#__PURE__*/React.createElement(FlexibleCard, {
49
61
  appearance: "block",
@@ -60,11 +72,7 @@ const FlexibleUnauthorisedView = ({
60
72
  }), /*#__PURE__*/React.createElement(CustomBlock, {
61
73
  overrideCss: contentStyles,
62
74
  testId: `${testId}-content`
63
- }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(UnauthorisedViewContent, {
64
- providerName: providerName,
65
- analytics: analytics,
66
- testId: testId
67
- }))), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(BlockCardFooter, {
75
+ }, /*#__PURE__*/React.createElement("div", null, content)), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(BlockCardFooter, {
68
76
  actions: actions,
69
77
  status: SmartLinkStatus.Unauthorized,
70
78
  actionGroupAppearance: "primary"
@@ -0,0 +1,14 @@
1
+ import { css } from '@emotion/react';
2
+
3
+ // in editor prosemirror adds padding-left so we need to overwrite it
4
+ export const metadataBlockCss = css`
5
+ /* primary element group */
6
+ [data-smart-element-avatar-group] {
7
+ > ul {
8
+ padding-left: 0px;
9
+ }
10
+ }
11
+ `;
12
+ export const titleBlockCss = css`
13
+ gap: 0.5em;
14
+ `;
@@ -0,0 +1,108 @@
1
+ import { ElementName } from '../../../../constants';
2
+ import { extractOwnedBy, extractAssignedTo } from '../../../../extractors/flexible/utils';
3
+ import { getExtensionKey } from '../../../../state/helpers';
4
+ const baseTopMetadata = [{
5
+ name: ElementName.ModifiedOn
6
+ }, {
7
+ name: ElementName.AttachmentCount
8
+ }, {
9
+ name: ElementName.SubscriberCount
10
+ }, {
11
+ name: ElementName.VoteCount
12
+ }, {
13
+ name: ElementName.DueOn
14
+ }, {
15
+ name: ElementName.ReadTime
16
+ }];
17
+ const baseBottomMetaData = [{
18
+ name: ElementName.ReactCount
19
+ }, {
20
+ name: ElementName.CommentCount
21
+ }, {
22
+ name: ElementName.ViewCount
23
+ }, {
24
+ name: ElementName.Priority
25
+ }, {
26
+ name: ElementName.SubTasksProgress
27
+ }, {
28
+ name: ElementName.ChecklistProgress
29
+ }];
30
+ export const getSimulatedBetterMetadata = cardDetails => {
31
+ var _getExtensionKey;
32
+ const extensionKey = (_getExtensionKey = getExtensionKey(cardDetails)) !== null && _getExtensionKey !== void 0 ? _getExtensionKey : '';
33
+ const data = cardDetails === null || cardDetails === void 0 ? void 0 : cardDetails.data;
34
+ const defaultTitleMetadata = [{
35
+ name: ElementName.State
36
+ }];
37
+ const defaultTopMetadata = [{
38
+ name: ElementName.AuthorGroup
39
+ }, {
40
+ name: ElementName.CreatedBy
41
+ }, ...baseTopMetadata];
42
+ const defaultBottomMetadata = baseBottomMetaData;
43
+ switch (extensionKey) {
44
+ case 'confluence-object-provider':
45
+ return {
46
+ titleMetadata: defaultTitleMetadata,
47
+ topMetadata: extractOwnedBy(data) ? [{
48
+ name: ElementName.OwnedByGroup
49
+ }, {
50
+ name: ElementName.OwnedBy
51
+ }, ...baseTopMetadata] : defaultTopMetadata,
52
+ bottomMetadata: defaultBottomMetadata
53
+ };
54
+ case 'jira-object-provider':
55
+ return {
56
+ titleMetadata: defaultTitleMetadata,
57
+ topMetadata: extractAssignedTo(data) ? [{
58
+ name: ElementName.AssignedToGroup
59
+ }, {
60
+ name: ElementName.AssignedTo
61
+ }, ...baseTopMetadata] : defaultTopMetadata,
62
+ bottomMetadata: defaultBottomMetadata
63
+ };
64
+ default:
65
+ return {
66
+ titleMetadata: defaultTitleMetadata,
67
+ topMetadata: defaultTopMetadata,
68
+ bottomMetadata: defaultBottomMetadata
69
+ };
70
+ }
71
+ };
72
+ export const getSimulatedMetadata = cardDetails => {
73
+ const baseMetadata = [{
74
+ name: ElementName.ModifiedOn
75
+ }, {
76
+ name: ElementName.AttachmentCount
77
+ }, {
78
+ name: ElementName.CommentCount
79
+ }, {
80
+ name: ElementName.ReactCount
81
+ }, {
82
+ name: ElementName.SubscriberCount
83
+ }, {
84
+ name: ElementName.ViewCount
85
+ }, {
86
+ name: ElementName.VoteCount
87
+ }, {
88
+ name: ElementName.ChecklistProgress
89
+ }, {
90
+ name: ElementName.DueOn
91
+ }];
92
+ const topMetadata = cardDetails !== null && cardDetails !== void 0 && cardDetails.data && extractOwnedBy(cardDetails === null || cardDetails === void 0 ? void 0 : cardDetails.data) ? [{
93
+ name: ElementName.OwnedBy
94
+ }, ...baseMetadata] : [{
95
+ name: ElementName.ModifiedBy
96
+ }, ...baseMetadata];
97
+ const titleMetadata = [{
98
+ name: ElementName.AuthorGroup
99
+ }, {
100
+ name: ElementName.Priority
101
+ }, {
102
+ name: ElementName.State
103
+ }];
104
+ return {
105
+ titleMetadata,
106
+ topMetadata
107
+ };
108
+ };
@@ -1,6 +1,6 @@
1
- import React, { useCallback } from 'react';
1
+ import React, { useCallback, useMemo } from 'react';
2
2
  import { EmbedCardUnresolvedView } from './UnresolvedView';
3
- import { UnauthorisedImage } from '../constants';
3
+ import { LockImage, UnauthorisedImage } from '../constants';
4
4
  import { ExpandedFrame } from '../components/ExpandedFrame';
5
5
  import { ImageIcon } from '../components/ImageIcon';
6
6
  import UnauthorisedViewContent from '../../common/UnauthorisedViewContent';
@@ -15,7 +15,6 @@ export const EmbedCardUnauthorisedView = ({
15
15
  onClick,
16
16
  extensionKey
17
17
  }) => {
18
- var _context$image;
19
18
  const icon = context && context.icon && /*#__PURE__*/React.createElement(ImageIcon, {
20
19
  src: typeof context.icon === 'string' ? context.icon : undefined
21
20
  });
@@ -27,6 +26,36 @@ export const EmbedCardUnauthorisedView = ({
27
26
  onAuthorise();
28
27
  }
29
28
  }, [onAuthorise, analytics.track, extensionKey]);
29
+ const view = useMemo(() => {
30
+ var _context$image2;
31
+ if (onAuthorise) {
32
+ var _context$image;
33
+ return /*#__PURE__*/React.createElement(EmbedCardUnresolvedView, {
34
+ button: {
35
+ appearance: 'primary',
36
+ text: 'connect_unauthorised_account_action',
37
+ testId: 'connect-account'
38
+ },
39
+ context: context && context.text,
40
+ description: "connect_unauthorised_account_description",
41
+ image: (_context$image = context === null || context === void 0 ? void 0 : context.image) !== null && _context$image !== void 0 ? _context$image : UnauthorisedImage,
42
+ onClick: handleOnAuthorizeClick,
43
+ testId: testId,
44
+ title: "connect_link_account_card_name"
45
+ }, /*#__PURE__*/React.createElement(UnauthorisedViewContent, {
46
+ analytics: analytics,
47
+ providerName: context === null || context === void 0 ? void 0 : context.text,
48
+ testId: testId
49
+ }));
50
+ }
51
+ return /*#__PURE__*/React.createElement(EmbedCardUnresolvedView, {
52
+ description: context !== null && context !== void 0 && context.text ? 'unauthorised_account_description' : 'unauthorised_account_description_no_provider',
53
+ image: (_context$image2 = context === null || context === void 0 ? void 0 : context.image) !== null && _context$image2 !== void 0 ? _context$image2 : LockImage,
54
+ context: context === null || context === void 0 ? void 0 : context.text,
55
+ testId: testId,
56
+ title: context !== null && context !== void 0 && context.text ? 'unauthorised_account_name' : 'unauthorised_account_name_no_provider'
57
+ });
58
+ }, [analytics, context, handleOnAuthorizeClick, onAuthorise, testId]);
30
59
  return /*#__PURE__*/React.createElement(ExpandedFrame, {
31
60
  href: link,
32
61
  icon: icon,
@@ -37,21 +66,5 @@ export const EmbedCardUnauthorisedView = ({
37
66
  onClick: onClick,
38
67
  testId: testId,
39
68
  allowScrollBar: true
40
- }, /*#__PURE__*/React.createElement(EmbedCardUnresolvedView, {
41
- image: (_context$image = context === null || context === void 0 ? void 0 : context.image) !== null && _context$image !== void 0 ? _context$image : UnauthorisedImage,
42
- title: "connect_link_account_card_name",
43
- description: "connect_unauthorised_account_description",
44
- context: context && context.text,
45
- button: onAuthorise ? {
46
- appearance: 'primary',
47
- text: 'connect_unauthorised_account_action',
48
- testId: 'connect-account'
49
- } : undefined,
50
- onClick: onAuthorise ? handleOnAuthorizeClick : undefined,
51
- testId: testId
52
- }, /*#__PURE__*/React.createElement(UnauthorisedViewContent, {
53
- analytics: analytics,
54
- providerName: context === null || context === void 0 ? void 0 : context.text,
55
- testId: testId
56
- })));
69
+ }, view);
57
70
  };
@@ -10,6 +10,8 @@ import ElementGroup from './element-group';
10
10
  // Determine whether the element can be display as inline/block.
11
11
 
12
12
  export const ElementDisplaySchema = {
13
+ [ElementName.AssignedTo]: ['inline'],
14
+ [ElementName.AssignedToGroup]: ['inline'],
13
15
  [ElementName.AttachmentCount]: ['inline'],
14
16
  [ElementName.AuthorGroup]: ['inline'],
15
17
  [ElementName.ChecklistProgress]: ['inline'],
@@ -24,15 +26,18 @@ export const ElementDisplaySchema = {
24
26
  [ElementName.ModifiedBy]: ['inline'],
25
27
  [ElementName.ModifiedOn]: ['inline'],
26
28
  [ElementName.OwnedBy]: ['inline'],
29
+ [ElementName.OwnedByGroup]: ['inline'],
27
30
  [ElementName.Preview]: ['block'],
28
31
  [ElementName.Priority]: ['inline'],
29
32
  [ElementName.ProgrammingLanguage]: ['inline'],
30
33
  [ElementName.Provider]: ['inline'],
31
34
  [ElementName.ReactCount]: ['inline'],
35
+ [ElementName.ReadTime]: ['inline'],
32
36
  [ElementName.Snippet]: ['block'],
33
37
  [ElementName.SourceBranch]: ['inline'],
34
38
  [ElementName.State]: ['inline'],
35
39
  [ElementName.SubscriberCount]: ['inline'],
40
+ [ElementName.SubTasksProgress]: ['inline'],
36
41
  [ElementName.TargetBranch]: ['inline'],
37
42
  [ElementName.Title]: ['inline'],
38
43
  [ElementName.ViewCount]: ['inline'],
@@ -3,6 +3,16 @@ import { ElementName } from '../../../../constants';
3
3
  // Attention: Keep the export name and element name the same.
4
4
  // This will help reducing the code for mapping elements inside
5
5
  // createElement and renderElementItems
6
+ /**
7
+ * Creates a AssignedTo text element using the data from AssignedTo in the Flexible UI Context.
8
+ * @see Text
9
+ */
10
+ export const AssignedTo = createElement(ElementName.AssignedTo);
11
+ /**
12
+ * An AvatarGroup element using the data from AssignedToGroup in the Flexible UI Context.
13
+ * @see AvatarGroup
14
+ */
15
+ export const AssignedToGroup = createElement(ElementName.AssignedToGroup);
6
16
  /**
7
17
  * Creates a AttachmentCount Badge element using the data from AttachmentCount in the Flexible UI Context.
8
18
  * @see Badge
@@ -73,6 +83,11 @@ export const ModifiedOn = createElement(ElementName.ModifiedOn);
73
83
  * @see Text
74
84
  */
75
85
  export const OwnedBy = createElement(ElementName.OwnedBy);
86
+ /**
87
+ * An AvatarGroup element using the data from OwnedByGroup in the Flexible UI Context.
88
+ * @see AvatarGroup
89
+ */
90
+ export const OwnedByGroup = createElement(ElementName.OwnedByGroup);
76
91
  /**
77
92
  * Creates a Preview element using the data from Preview in the Flexible UI Context.
78
93
  * @see Preview
@@ -98,6 +113,10 @@ export const Provider = createElement(ElementName.Provider);
98
113
  * @see Badge
99
114
  */
100
115
  export const ReactCount = createElement(ElementName.ReactCount);
116
+ /**
117
+ * Creates a ReadTime Text element using the data from readTime in the Flexible UI Context
118
+ */
119
+ export const ReadTime = createElement(ElementName.ReadTime);
101
120
  /**
102
121
  * Creates a Snippet element using the data from Snippet in the Flexible UI Context.
103
122
  * @see Text
@@ -118,6 +137,11 @@ export const State = createElement(ElementName.State);
118
137
  * @see Badge
119
138
  */
120
139
  export const SubscriberCount = createElement(ElementName.SubscriberCount);
140
+ /**
141
+ * Create a SubTasks Badge element using the data from subTasks in the Flexible UI Context.
142
+ * @see Badge
143
+ */
144
+ export const SubTasksProgress = createElement(ElementName.SubTasksProgress);
121
145
  /**
122
146
  * Creates a TargetBranch Text element using the data from targetBranch in the Flexible UI Context.
123
147
  * @see Text
@@ -64,6 +64,15 @@ const elementMappings = {
64
64
  [ElementName.OwnedBy]: {
65
65
  component: Text
66
66
  },
67
+ [ElementName.AssignedTo]: {
68
+ component: Text
69
+ },
70
+ [ElementName.AssignedToGroup]: {
71
+ component: AvatarGroup
72
+ },
73
+ [ElementName.OwnedByGroup]: {
74
+ component: AvatarGroup
75
+ },
67
76
  [ElementName.CreatedOn]: {
68
77
  component: DateTime
69
78
  },
@@ -100,6 +109,9 @@ const elementMappings = {
100
109
  [ElementName.Provider]: {
101
110
  component: Badge
102
111
  },
112
+ [ElementName.ReadTime]: {
113
+ component: Text
114
+ },
103
115
  [ElementName.Snippet]: {
104
116
  component: Text,
105
117
  props: {
@@ -121,6 +133,12 @@ const elementMappings = {
121
133
  icon: IconType.Subscriber
122
134
  }
123
135
  },
136
+ [ElementName.SubTasksProgress]: {
137
+ component: Badge,
138
+ props: {
139
+ icon: IconType.CheckItem
140
+ }
141
+ },
124
142
  [ElementName.TargetBranch]: {
125
143
  component: Text
126
144
  },
@@ -146,7 +164,9 @@ const getData = (elementName, contextKey, context) => {
146
164
  const data = context[contextKey];
147
165
  switch (elementName) {
148
166
  case ElementName.AuthorGroup:
167
+ case ElementName.AssignedToGroup:
149
168
  case ElementName.CollaboratorGroup:
169
+ case ElementName.OwnedByGroup:
150
170
  return toAvatarGroupProps(data);
151
171
  case ElementName.AttachmentCount:
152
172
  case ElementName.ChecklistProgress:
@@ -157,9 +177,12 @@ const getData = (elementName, contextKey, context) => {
157
177
  case ElementName.ProgrammingLanguage:
158
178
  case ElementName.SubscriberCount:
159
179
  case ElementName.LatestCommit:
180
+ case ElementName.SubTasksProgress:
160
181
  return toBadgeProps(data);
161
182
  case ElementName.CreatedBy:
162
183
  return toFormattedTextProps(messages.created_by, context.createdBy);
184
+ case ElementName.AssignedTo:
185
+ return toFormattedTextProps(messages.assigned_to, context.assignedTo);
163
186
  case ElementName.OwnedBy:
164
187
  return toFormattedTextProps(messages.owned_by, context.ownedBy);
165
188
  case ElementName.CreatedOn:
@@ -170,6 +193,8 @@ const getData = (elementName, contextKey, context) => {
170
193
  return toFormattedTextProps(messages.modified_by, context.modifiedBy);
171
194
  case ElementName.ModifiedOn:
172
195
  return toDateTimeProps('modified', context.modifiedOn);
196
+ case ElementName.ReadTime:
197
+ return toFormattedTextProps(messages.read_time, data);
173
198
  case ElementName.Snippet:
174
199
  case ElementName.SourceBranch:
175
200
  case ElementName.TargetBranch:
@@ -5,11 +5,12 @@ import { ActionName, CardDisplay, SmartLinkPosition, SmartLinkSize } from '../..
5
5
  import { FooterBlock, MetadataBlock, SnippetBlock, TitleBlock } from '../../../../FlexibleCard/components/blocks';
6
6
  import { footerBlockCss, hiddenSnippetStyles, metadataBlockCss } from './styled';
7
7
  import FlexibleCard from '../../../../FlexibleCard';
8
- import { getSimulatedMetadata } from '../../../utils';
8
+ import { getSimulatedMetadata, getSimulatedBetterMetadata } from '../../../utils';
9
9
  import SnippetOrPreview from '../../SnippetOrPreview';
10
- import { extractMetadata } from '../../../../../extractors/hover/extractMetadata';
10
+ import { extractMetadata, elementNamesToItems } from '../../../../../extractors/hover/extractMetadata';
11
11
  import { messages } from '../../../../../messages';
12
12
  import { FormattedMessage } from 'react-intl-next';
13
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
13
14
  export const toFooterActions = (cardActions, onActionClick, enableImprovedPreviewAction) => {
14
15
  const appearance = enableImprovedPreviewAction ? {
15
16
  appearance: 'primary'
@@ -67,15 +68,23 @@ const HoverCardResolvedView = ({
67
68
  const footerActions = useMemo(() => toFooterActions(cardActions, onActionClick, Boolean(enableImprovedPreviewAction)), [cardActions, onActionClick, enableImprovedPreviewAction]);
68
69
  const data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
69
70
  const {
70
- primary,
71
- secondary
71
+ topPrimary,
72
+ topSecondary,
73
+ bottomPrimary
72
74
  } = useMemo(() => {
73
- //TODO: EDM-3224 deleted simulated and use real JsonLd
75
+ if (getBooleanFF('platform.linking-platform.smart-card.enable-better-metadata_iojwg')) {
76
+ const betterMetadata = getSimulatedBetterMetadata(extensionKey, data);
77
+ return {
78
+ topPrimary: elementNamesToItems(betterMetadata.topMetadataBlock.primary),
79
+ topSecondary: elementNamesToItems(betterMetadata.topMetadataBlock.secondary),
80
+ bottomPrimary: elementNamesToItems(betterMetadata.bottomMetadataBlock.primary)
81
+ };
82
+ }
74
83
  const metadata = extractMetadata(getSimulatedMetadata(extensionKey, data));
75
84
  return {
76
- primary: metadata.primary,
77
- secondary: metadata.secondary,
78
- subtitle: metadata.subtitle
85
+ topPrimary: metadata.primary,
86
+ topSecondary: metadata.secondary,
87
+ bottomPrimary: []
79
88
  };
80
89
  }, [data, extensionKey]);
81
90
  const snippetHeight = React.useRef(0);
@@ -90,17 +99,24 @@ const HoverCardResolvedView = ({
90
99
  });
91
100
  return /*#__PURE__*/React.createElement(FlexibleCard, flexibleCardProps, /*#__PURE__*/React.createElement(TitleBlock, _extends({}, titleBlockProps, {
92
101
  metadataPosition: SmartLinkPosition.Top
93
- })), /*#__PURE__*/React.createElement(MetadataBlock, {
94
- primary: primary,
95
- secondary: secondary,
96
- size: SmartLinkSize.Large,
102
+ })), /*#__PURE__*/React.createElement(MetadataBlock, _extends({
103
+ primary: topPrimary,
104
+ secondary: topSecondary,
97
105
  overrideCss: metadataBlockCss,
98
- maxLines: 1
99
- }), body, /*#__PURE__*/React.createElement(SnippetBlock, {
106
+ maxLines: 1,
107
+ size: SmartLinkSize.Large
108
+ }, getBooleanFF('platform.linking-platform.smart-card.enable-better-metadata_iojwg') && {
109
+ size: SmartLinkSize.Medium
110
+ })), body, /*#__PURE__*/React.createElement(SnippetBlock, {
100
111
  testId: 'hidden-snippet',
101
112
  onRender: onSnippetRender,
102
113
  blockRef: snippetBlockRef,
103
114
  overrideCss: hiddenSnippetStyles
115
+ }), getBooleanFF('platform.linking-platform.smart-card.enable-better-metadata_iojwg') && /*#__PURE__*/React.createElement(MetadataBlock, {
116
+ primary: bottomPrimary,
117
+ size: SmartLinkSize.Large,
118
+ overrideCss: metadataBlockCss,
119
+ maxLines: 1
104
120
  }), /*#__PURE__*/React.createElement(FooterBlock, {
105
121
  actions: footerActions,
106
122
  size: SmartLinkSize.Large,
@@ -27,7 +27,7 @@ export const getSimulatedMetadata = (extensionKey = '', data) => {
27
27
  return {
28
28
  metadata: {
29
29
  primary: [ElementName.AuthorGroup, primaryAttribution],
30
- secondary: [ElementName.CommentCount, ElementName.ReactCount],
30
+ secondary: [ElementName.ReactCount, ElementName.CommentCount, ElementName.ViewCount],
31
31
  subtitle: []
32
32
  }
33
33
  };
@@ -73,4 +73,103 @@ export const getSimulatedMetadata = (extensionKey = '', data) => {
73
73
  }
74
74
  };
75
75
  }
76
+ };
77
+ export const getSimulatedBetterMetadata = (extensionKey = '', data) => {
78
+ const types = data ? extractType(data) : undefined;
79
+ const defaultMetadata = {
80
+ topMetadataBlock: {
81
+ primary: [ElementName.ModifiedOn, ElementName.CreatedBy],
82
+ secondary: [],
83
+ subtitle: []
84
+ },
85
+ bottomMetadataBlock: {
86
+ primary: [],
87
+ secondary: [],
88
+ subtitle: []
89
+ }
90
+ };
91
+ switch (extensionKey) {
92
+ case 'bitbucket-object-provider':
93
+ case 'native-bitbucket-object-provider':
94
+ if (types !== null && types !== void 0 && types.includes('atlassian:SourceCodePullRequest')) {
95
+ return {
96
+ ...defaultMetadata,
97
+ topMetadataBlock: {
98
+ primary: [ElementName.AuthorGroup, ElementName.ModifiedOn, ElementName.SubscriberCount, ElementName.State],
99
+ secondary: [],
100
+ subtitle: [ElementName.SourceBranch, ElementName.TargetBranch]
101
+ }
102
+ };
103
+ }
104
+ return {
105
+ ...defaultMetadata,
106
+ topMetadataBlock: {
107
+ primary: [ElementName.ModifiedOn, ElementName.CreatedBy],
108
+ secondary: [],
109
+ subtitle: []
110
+ }
111
+ };
112
+ case 'confluence-object-provider':
113
+ const primaryAttribution = data && extractOwnedBy(data) ? ElementName.OwnedByGroup : ElementName.AuthorGroup;
114
+ return {
115
+ topMetadataBlock: {
116
+ primary: [primaryAttribution, ElementName.ModifiedOn],
117
+ secondary: [],
118
+ subtitle: []
119
+ },
120
+ bottomMetadataBlock: {
121
+ primary: [ElementName.CommentCount, ElementName.ReactCount, ElementName.ViewCount],
122
+ secondary: [],
123
+ subtitle: []
124
+ }
125
+ };
126
+ case 'jira-object-provider':
127
+ return {
128
+ ...defaultMetadata,
129
+ topMetadataBlock: {
130
+ primary: [ElementName.AssignedToGroup, ElementName.State, ElementName.Priority],
131
+ secondary: [],
132
+ subtitle: []
133
+ }
134
+ };
135
+ case 'trello-object-provider':
136
+ return {
137
+ ...defaultMetadata,
138
+ topMetadataBlock: {
139
+ primary: [ElementName.AuthorGroup, ElementName.State, ElementName.DueOn],
140
+ secondary: [ElementName.ReactCount, ElementName.CommentCount, ElementName.AttachmentCount, ElementName.ChecklistProgress],
141
+ subtitle: [ElementName.Location]
142
+ }
143
+ };
144
+ case 'watermelon-object-provider':
145
+ if (types !== null && types !== void 0 && types.includes('atlassian:Project')) {
146
+ return {
147
+ ...defaultMetadata,
148
+ topMetadataBlock: {
149
+ primary: [ElementName.AuthorGroup, ElementName.ModifiedOn, ElementName.State, ElementName.DueOn],
150
+ secondary: [],
151
+ subtitle: []
152
+ }
153
+ };
154
+ }
155
+ return {
156
+ ...defaultMetadata,
157
+ topMetadataBlock: {
158
+ primary: [ElementName.AuthorGroup, ElementName.State, ElementName.DueOn],
159
+ secondary: [],
160
+ subtitle: []
161
+ }
162
+ };
163
+ case 'google-object-provider':
164
+ return {
165
+ ...defaultMetadata,
166
+ topMetadataBlock: {
167
+ primary: [ElementName.AuthorGroup, ElementName.ModifiedOn],
168
+ secondary: [],
169
+ subtitle: []
170
+ }
171
+ };
172
+ default:
173
+ return defaultMetadata;
174
+ }
76
175
  };
@@ -100,6 +100,8 @@ export var SmartLinkWidth = /*#__PURE__*/function (SmartLinkWidth) {
100
100
  * (src/view/FlexibleCard/components/blocks/utils.tsx)
101
101
  */
102
102
  export var ElementName = /*#__PURE__*/function (ElementName) {
103
+ ElementName["AssignedTo"] = "AssignedTo";
104
+ ElementName["AssignedToGroup"] = "AssignedToGroup";
103
105
  ElementName["AttachmentCount"] = "AttachmentCount";
104
106
  ElementName["AuthorGroup"] = "AuthorGroup";
105
107
  ElementName["ChecklistProgress"] = "ChecklistProgress";
@@ -114,15 +116,18 @@ export var ElementName = /*#__PURE__*/function (ElementName) {
114
116
  ElementName["ModifiedBy"] = "ModifiedBy";
115
117
  ElementName["ModifiedOn"] = "ModifiedOn";
116
118
  ElementName["OwnedBy"] = "OwnedBy";
119
+ ElementName["OwnedByGroup"] = "OwnedByGroup";
117
120
  ElementName["Preview"] = "Preview";
118
121
  ElementName["Priority"] = "Priority";
119
122
  ElementName["ProgrammingLanguage"] = "ProgrammingLanguage";
120
123
  ElementName["Provider"] = "Provider";
121
124
  ElementName["ReactCount"] = "ReactCount";
125
+ ElementName["ReadTime"] = "ReadTime";
122
126
  ElementName["Snippet"] = "Snippet";
123
127
  ElementName["SourceBranch"] = "SourceBranch";
124
128
  ElementName["State"] = "State";
125
129
  ElementName["SubscriberCount"] = "SubscriberCount";
130
+ ElementName["SubTasksProgress"] = "SubTasksProgress";
126
131
  ElementName["TargetBranch"] = "TargetBranch";
127
132
  ElementName["Title"] = "Title";
128
133
  ElementName["ViewCount"] = "ViewCount";
@@ -146,6 +151,7 @@ export var ActionName = /*#__PURE__*/function (ActionName) {
146
151
  /**
147
152
  * Flexible UI icons - each mapped to AK icons.
148
153
  */
154
+
149
155
  export var IconType = /*#__PURE__*/function (IconType) {
150
156
  IconType["Archive"] = "FileType:Archive";
151
157
  IconType["Audio"] = "FileType:Audio";
@@ -1,8 +1,8 @@
1
1
  import { extractSummary } from '../common/primitives';
2
2
  import { extractLinkIcon } from './icon';
3
- import { extractAttachmentCount, extractChecklistProgress, extractCommentCount, extractCreatedBy, extractModifiedBy, extractProgrammingLanguage, extractSubscriberCount, extractViewCount, extractReactCount, extractVoteCount, extractSourceBranch, extractTargetBranch, extractDueOn, extractLocation, extractOwnedBy } from './utils';
3
+ import { extractAttachmentCount, extractChecklistProgress, extractCommentCount, extractCreatedBy, extractModifiedBy, extractProgrammingLanguage, extractSubscriberCount, extractViewCount, extractReactCount, extractVoteCount, extractSourceBranch, extractTargetBranch, extractDueOn, extractLocation, extractOwnedBy, extractAssignedTo, extractSubTasksProgress, extractReadTime, extractPersonAssignedToAsArray } from './utils';
4
4
  import { extractPersonsUpdatedBy } from './collaboratorGroup';
5
- import { extractPersonCreatedBy, extractTitle, extractDateUpdated, extractDateCreated, extractLink } from '@atlaskit/link-extractors';
5
+ import { extractPersonCreatedBy, extractTitle, extractDateUpdated, extractDateCreated, extractLink, extractPersonOwnedBy } from '@atlaskit/link-extractors';
6
6
  import extractPriority from './extract-priority';
7
7
  import extractProviderIcon from './icon/extract-provider-icon';
8
8
  import extractPreview from './extract-preview';
@@ -25,8 +25,10 @@ var extractFlexibleUiContext = function extractFlexibleUiContext() {
25
25
  var url = extractLink(data);
26
26
  var showLozengeAction = (featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.useLozengeAction) === 'experiment';
27
27
  return {
28
+ assignedToGroup: extractPersonAssignedToAsArray(data),
28
29
  attachmentCount: extractAttachmentCount(data),
29
30
  authorGroup: extractPersonCreatedBy(data),
31
+ ownedByGroup: extractPersonOwnedBy(data),
30
32
  collaboratorGroup: extractPersonsUpdatedBy(data),
31
33
  commentCount: extractCommentCount(data),
32
34
  viewCount: extractViewCount(data),
@@ -35,6 +37,7 @@ var extractFlexibleUiContext = function extractFlexibleUiContext() {
35
37
  checklistProgress: extractChecklistProgress(data),
36
38
  createdBy: extractCreatedBy(data),
37
39
  ownedBy: extractOwnedBy(data),
40
+ assignedTo: extractAssignedTo(data),
38
41
  createdOn: extractDateCreated(data),
39
42
  dueOn: extractDueOn(data),
40
43
  previewAction: extractPreviewAction(response),
@@ -49,11 +52,13 @@ var extractFlexibleUiContext = function extractFlexibleUiContext() {
49
52
  priority: extractPriority(data),
50
53
  provider: extractProviderIcon(data),
51
54
  programmingLanguage: extractProgrammingLanguage(data),
55
+ readTime: extractReadTime(data),
52
56
  snippet: extractSummary(data) || undefined,
53
57
  // Explicitly set here to remove an empty string
54
58
  sourceBranch: extractSourceBranch(data),
55
59
  state: extractState(response, showServerActions || showLozengeAction, id),
56
60
  subscriberCount: extractSubscriberCount(data),
61
+ subTasksProgress: extractSubTasksProgress(data),
57
62
  targetBranch: extractTargetBranch(data),
58
63
  title: extractTitle(data) || url,
59
64
  url: url