@atlaskit/smart-card 26.13.1 → 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 (66) hide show
  1. package/CHANGELOG.md +6 -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 +10 -0
  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/styled.js +15 -0
  10. package/dist/cjs/view/BlockCard/views/flexible/utils.js +116 -0
  11. package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +1 -1
  12. package/dist/cjs/view/FlexibleCard/components/elements/index.js +33 -4
  13. package/dist/cjs/view/FlexibleCard/components/elements/utils.js +20 -0
  14. package/dist/cjs/view/HoverCard/components/views/resolved/index.js +28 -12
  15. package/dist/cjs/view/HoverCard/utils.js +102 -3
  16. package/dist/es2019/constants.js +6 -0
  17. package/dist/es2019/extractors/flexible/index.js +7 -2
  18. package/dist/es2019/extractors/flexible/utils.js +18 -1
  19. package/dist/es2019/extractors/hover/extractMetadata.js +1 -1
  20. package/dist/es2019/messages.js +10 -0
  21. package/dist/es2019/version.json +1 -1
  22. package/dist/es2019/view/BlockCard/views/flexible/FlexibleResolvedView.js +24 -38
  23. package/dist/es2019/view/BlockCard/views/flexible/styled.js +14 -0
  24. package/dist/es2019/view/BlockCard/views/flexible/utils.js +108 -0
  25. package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +5 -0
  26. package/dist/es2019/view/FlexibleCard/components/elements/index.js +24 -0
  27. package/dist/es2019/view/FlexibleCard/components/elements/utils.js +25 -0
  28. package/dist/es2019/view/HoverCard/components/views/resolved/index.js +30 -14
  29. package/dist/es2019/view/HoverCard/utils.js +100 -1
  30. package/dist/esm/constants.js +6 -0
  31. package/dist/esm/extractors/flexible/index.js +7 -2
  32. package/dist/esm/extractors/flexible/utils.js +18 -1
  33. package/dist/esm/extractors/hover/extractMetadata.js +1 -1
  34. package/dist/esm/messages.js +10 -0
  35. package/dist/esm/version.json +1 -1
  36. package/dist/esm/view/BlockCard/views/flexible/FlexibleResolvedView.js +23 -38
  37. package/dist/esm/view/BlockCard/views/flexible/styled.js +7 -0
  38. package/dist/esm/view/BlockCard/views/flexible/utils.js +108 -0
  39. package/dist/esm/view/FlexibleCard/components/blocks/utils.js +1 -1
  40. package/dist/esm/view/FlexibleCard/components/elements/index.js +24 -0
  41. package/dist/esm/view/FlexibleCard/components/elements/utils.js +20 -0
  42. package/dist/esm/view/HoverCard/components/views/resolved/index.js +30 -14
  43. package/dist/esm/view/HoverCard/utils.js +98 -1
  44. package/dist/types/constants.d.ts +5 -0
  45. package/dist/types/extractors/flexible/utils.d.ts +5 -0
  46. package/dist/types/extractors/hover/extractMetadata.d.ts +2 -0
  47. package/dist/types/messages.d.ts +1 -1
  48. package/dist/types/state/flexible-ui-context/types.d.ts +25 -0
  49. package/dist/types/view/BlockCard/views/flexible/styled.d.ts +2 -0
  50. package/dist/types/view/BlockCard/views/flexible/utils.d.ts +10 -0
  51. package/dist/types/view/FlexibleCard/components/blocks/types.d.ts +35 -2
  52. package/dist/types/view/FlexibleCard/components/elements/index.d.ts +24 -0
  53. package/dist/types/view/HoverCard/utils.d.ts +1 -0
  54. package/dist/types-ts4.5/constants.d.ts +5 -0
  55. package/dist/types-ts4.5/extractors/flexible/utils.d.ts +5 -0
  56. package/dist/types-ts4.5/extractors/hover/extractMetadata.d.ts +2 -0
  57. package/dist/types-ts4.5/messages.d.ts +1 -1
  58. package/dist/types-ts4.5/state/flexible-ui-context/types.d.ts +25 -0
  59. package/dist/types-ts4.5/view/BlockCard/views/flexible/styled.d.ts +2 -0
  60. package/dist/types-ts4.5/view/BlockCard/views/flexible/utils.d.ts +10 -0
  61. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/types.d.ts +35 -2
  62. package/dist/types-ts4.5/view/FlexibleCard/components/elements/index.d.ts +24 -0
  63. package/dist/types-ts4.5/view/HoverCard/utils.d.ts +1 -0
  64. package/package.json +4 -1
  65. package/report.api.md +40 -0
  66. package/tmp/api-report-tmp.d.ts +36 -1
@@ -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
@@ -1,5 +1,5 @@
1
1
  import _typeof from "@babel/runtime/helpers/typeof";
2
- import { extractPersonOwnedBy, extractPersonCreatedBy, extractPersonUpdatedBy } from '@atlaskit/link-extractors';
2
+ import { extractPersonOwnedBy, extractPersonCreatedBy, extractPersonUpdatedBy, extractPersonAssignedTo } from '@atlaskit/link-extractors';
3
3
  var extractLinkName = function extractLinkName(link) {
4
4
  if (link && _typeof(link) === 'object' && link['@type'] === 'Link') {
5
5
  return link.name;
@@ -29,6 +29,16 @@ export var extractOwnedBy = function extractOwnedBy(data) {
29
29
  return persons[0].name;
30
30
  }
31
31
  };
32
+ export var extractAssignedTo = function extractAssignedTo(data) {
33
+ var person = extractPersonAssignedTo(data);
34
+ if (person) {
35
+ return person.name;
36
+ }
37
+ };
38
+ export var extractPersonAssignedToAsArray = function extractPersonAssignedToAsArray(data) {
39
+ var person = extractPersonAssignedTo(data);
40
+ return person ? [person] : undefined;
41
+ };
32
42
  export var extractCreatedBy = function extractCreatedBy(data) {
33
43
  var persons = extractPersonCreatedBy(data);
34
44
  if (persons && persons.length) {
@@ -70,4 +80,11 @@ export var extractLocation = function extractLocation(data) {
70
80
  url: url
71
81
  };
72
82
  }
83
+ };
84
+ export var extractSubTasksProgress = function extractSubTasksProgress(data) {
85
+ var subTasksObject = extractValue(data, 'atlassian:subTasks');
86
+ return subTasksObject && subTasksObject.totalCount ? "".concat(subTasksObject.resolvedCount, "/").concat(subTasksObject.totalCount) : undefined;
87
+ };
88
+ export var extractReadTime = function extractReadTime(data) {
89
+ return extractValue(data, 'atlassian:readTimeInMinutes');
73
90
  };
@@ -1,5 +1,5 @@
1
1
  import { ElementName } from '../../constants';
2
- var elementNamesToItems = function elementNamesToItems(elementNames) {
2
+ export var elementNamesToItems = function elementNamesToItems(elementNames) {
3
3
  return elementNames.filter(function (element) {
4
4
  return element in ElementName;
5
5
  }).map(function (elementName) {
@@ -10,6 +10,11 @@ export var messages = defineMessages({
10
10
  defaultMessage: 'Add account',
11
11
  description: 'Allows to add a new account'
12
12
  },
13
+ assigned_to: {
14
+ id: 'fabric.linking.assigned_to',
15
+ defaultMessage: 'Assigned to {context}',
16
+ description: 'Indicates the person or entity that the resource is assigned to.'
17
+ },
13
18
  cancel: {
14
19
  id: 'fabric.linking.cancel',
15
20
  defaultMessage: 'Cancel',
@@ -306,6 +311,11 @@ export var messages = defineMessages({
306
311
  defaultMessage: 'Your access request is pending',
307
312
  description: 'Shown when a user has requested an access but status is pending.'
308
313
  },
314
+ read_time: {
315
+ id: 'fabric.linking.read_time',
316
+ defaultMessage: '{context} min read',
317
+ description: 'Estimated time to read this resource'
318
+ },
309
319
  restricted_link: {
310
320
  id: 'fabric.linking.restricted_link',
311
321
  defaultMessage: 'Restricted link, try another account',
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "26.13.1",
3
+ "version": "26.14.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,18 +1,21 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
1
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
3
  import React, { useEffect, useState } from 'react';
3
4
  import FlexibleCard from '../../../FlexibleCard';
4
5
  import TitleBlock from '../../../FlexibleCard/components/blocks/title-block';
5
6
  import { FooterBlock, MetadataBlock, PreviewBlock, SnippetBlock } from '../../../FlexibleCard/components/blocks';
6
- import { ActionName, CardDisplay, ElementName, MediaPlacement, SmartLinkPosition } from '../../../../constants';
7
+ import { metadataBlockCss, titleBlockCss } from './styled';
8
+ import { ActionName, CardDisplay, ElementName, MediaPlacement, SmartLinkPosition, SmartLinkSize } from '../../../../constants';
7
9
  import uuid from 'uuid';
8
- import { extractOwnedBy } from '../../../../extractors/flexible/utils';
10
+ import { getSimulatedMetadata, getSimulatedBetterMetadata } from './utils';
11
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
12
+
9
13
  /**
10
14
  * This view represents a Block card that has an 'Resolved' status.
11
15
  * @see SmartLinkStatus
12
16
  * @see FlexibleCardProps
13
17
  */
14
18
  var FlexibleResolvedView = function FlexibleResolvedView(_ref) {
15
- var _cardState$details, _cardState$details2;
16
19
  var id = _ref.id,
17
20
  cardState = _ref.cardState,
18
21
  onClick = _ref.onClick,
@@ -37,30 +40,10 @@ var FlexibleResolvedView = function FlexibleResolvedView(_ref) {
37
40
  }),
38
41
  _useState4 = _slicedToArray(_useState3, 1),
39
42
  analyticsId = _useState4[0];
40
- var baseMetadata = [{
41
- name: ElementName.ModifiedOn
42
- }, {
43
- name: ElementName.AttachmentCount
44
- }, {
45
- name: ElementName.CommentCount
46
- }, {
47
- name: ElementName.ReactCount
48
- }, {
49
- name: ElementName.SubscriberCount
50
- }, {
51
- name: ElementName.ViewCount
52
- }, {
53
- name: ElementName.VoteCount
54
- }, {
55
- name: ElementName.ChecklistProgress
56
- }, {
57
- name: ElementName.DueOn
58
- }];
59
- var metadata = cardState !== null && cardState !== void 0 && (_cardState$details = cardState.details) !== null && _cardState$details !== void 0 && _cardState$details.data && extractOwnedBy(cardState === null || cardState === void 0 ? void 0 : (_cardState$details2 = cardState.details) === null || _cardState$details2 === void 0 ? void 0 : _cardState$details2.data) ? [{
60
- name: ElementName.OwnedBy
61
- }].concat(baseMetadata) : [{
62
- name: ElementName.ModifiedBy
63
- }].concat(baseMetadata);
43
+ var _ref2 = getBooleanFF('platform.linking-platform.smart-card.enable-better-metadata_iojwg') ? getSimulatedBetterMetadata(cardState.details) : getSimulatedMetadata(cardState.details),
44
+ titleMetadata = _ref2.titleMetadata,
45
+ topMetadata = _ref2.topMetadata,
46
+ bottomMetadata = _ref2.bottomMetadata;
64
47
  return /*#__PURE__*/React.createElement(FlexibleCard, {
65
48
  analytics: analytics,
66
49
  appearance: "block",
@@ -72,25 +55,27 @@ var FlexibleResolvedView = function FlexibleResolvedView(_ref) {
72
55
  testId: testId,
73
56
  ui: ui,
74
57
  url: url
75
- }, /*#__PURE__*/React.createElement(TitleBlock, {
58
+ }, /*#__PURE__*/React.createElement(TitleBlock, _extends({
76
59
  position: SmartLinkPosition.Center,
77
- metadata: [{
78
- name: ElementName.AuthorGroup
79
- }, {
80
- name: ElementName.Priority
81
- }, {
82
- name: ElementName.State
83
- }],
60
+ metadata: titleMetadata,
84
61
  hideRetry: true,
85
62
  subtitle: [{
86
63
  name: ElementName.Location
87
64
  }],
88
65
  metadataPosition: SmartLinkPosition.Top,
89
66
  anchorTarget: anchorTarget
90
- }), /*#__PURE__*/React.createElement(MetadataBlock, {
91
- primary: metadata,
67
+ }, getBooleanFF('platform.linking-platform.smart-card.enable-better-metadata_iojwg') && {
68
+ overrideCss: titleBlockCss,
69
+ size: SmartLinkSize.Large
70
+ })), /*#__PURE__*/React.createElement(MetadataBlock, _extends({
71
+ primary: topMetadata,
72
+ maxLines: 1
73
+ }, getBooleanFF('platform.linking-platform.smart-card.enable-better-metadata_iojwg') && {
74
+ overrideCss: metadataBlockCss
75
+ })), /*#__PURE__*/React.createElement(SnippetBlock, null), getBooleanFF('platform.linking-platform.smart-card.enable-better-metadata_iojwg') && /*#__PURE__*/React.createElement(MetadataBlock, {
76
+ primary: bottomMetadata,
92
77
  maxLines: 1
93
- }), /*#__PURE__*/React.createElement(SnippetBlock, null), !isPreviewBlockErrored ? /*#__PURE__*/React.createElement(PreviewBlock, {
78
+ }), !isPreviewBlockErrored ? /*#__PURE__*/React.createElement(PreviewBlock, {
94
79
  placement: MediaPlacement.Right,
95
80
  ignoreContainerPadding: true,
96
81
  onError: function onError() {
@@ -0,0 +1,7 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
+ var _templateObject, _templateObject2;
3
+ import { css } from '@emotion/react';
4
+
5
+ // in editor prosemirror adds padding-left so we need to overwrite it
6
+ export var metadataBlockCss = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n /* primary element group */\n [data-smart-element-avatar-group] {\n > ul {\n padding-left: 0px;\n }\n }\n"])));
7
+ export var titleBlockCss = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n gap: 0.5em;\n"])));
@@ -0,0 +1,108 @@
1
+ import { ElementName } from '../../../../constants';
2
+ import { extractOwnedBy, extractAssignedTo } from '../../../../extractors/flexible/utils';
3
+ import { getExtensionKey } from '../../../../state/helpers';
4
+ var 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
+ var 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 var getSimulatedBetterMetadata = function getSimulatedBetterMetadata(cardDetails) {
31
+ var _getExtensionKey;
32
+ var extensionKey = (_getExtensionKey = getExtensionKey(cardDetails)) !== null && _getExtensionKey !== void 0 ? _getExtensionKey : '';
33
+ var data = cardDetails === null || cardDetails === void 0 ? void 0 : cardDetails.data;
34
+ var defaultTitleMetadata = [{
35
+ name: ElementName.State
36
+ }];
37
+ var defaultTopMetadata = [{
38
+ name: ElementName.AuthorGroup
39
+ }, {
40
+ name: ElementName.CreatedBy
41
+ }].concat(baseTopMetadata);
42
+ var 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
+ }].concat(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
+ }].concat(baseTopMetadata) : defaultTopMetadata,
62
+ bottomMetadata: defaultBottomMetadata
63
+ };
64
+ default:
65
+ return {
66
+ titleMetadata: defaultTitleMetadata,
67
+ topMetadata: defaultTopMetadata,
68
+ bottomMetadata: defaultBottomMetadata
69
+ };
70
+ }
71
+ };
72
+ export var getSimulatedMetadata = function getSimulatedMetadata(cardDetails) {
73
+ var 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
+ var topMetadata = cardDetails !== null && cardDetails !== void 0 && cardDetails.data && extractOwnedBy(cardDetails === null || cardDetails === void 0 ? void 0 : cardDetails.data) ? [{
93
+ name: ElementName.OwnedBy
94
+ }].concat(baseMetadata) : [{
95
+ name: ElementName.ModifiedBy
96
+ }].concat(baseMetadata);
97
+ var titleMetadata = [{
98
+ name: ElementName.AuthorGroup
99
+ }, {
100
+ name: ElementName.Priority
101
+ }, {
102
+ name: ElementName.State
103
+ }];
104
+ return {
105
+ titleMetadata: titleMetadata,
106
+ topMetadata: topMetadata
107
+ };
108
+ };
@@ -15,7 +15,7 @@ import ElementGroup from './element-group';
15
15
 
16
16
  // Determine whether the element can be display as inline/block.
17
17
 
18
- export var ElementDisplaySchema = (_ElementDisplaySchema = {}, _defineProperty(_ElementDisplaySchema, ElementName.AttachmentCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.AuthorGroup, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ChecklistProgress, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CollaboratorGroup, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CommentCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CreatedBy, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CreatedOn, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.DueOn, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.LatestCommit, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.LinkIcon, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Location, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ModifiedBy, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ModifiedOn, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.OwnedBy, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Preview, ['block']), _defineProperty(_ElementDisplaySchema, ElementName.Priority, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ProgrammingLanguage, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Provider, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ReactCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Snippet, ['block']), _defineProperty(_ElementDisplaySchema, ElementName.SourceBranch, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.State, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.SubscriberCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.TargetBranch, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Title, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ViewCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.VoteCount, ['inline']), _ElementDisplaySchema);
18
+ export var ElementDisplaySchema = (_ElementDisplaySchema = {}, _defineProperty(_ElementDisplaySchema, ElementName.AssignedTo, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.AssignedToGroup, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.AttachmentCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.AuthorGroup, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ChecklistProgress, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CollaboratorGroup, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CommentCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CreatedBy, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CreatedOn, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.DueOn, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.LatestCommit, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.LinkIcon, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Location, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ModifiedBy, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ModifiedOn, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.OwnedBy, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.OwnedByGroup, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Preview, ['block']), _defineProperty(_ElementDisplaySchema, ElementName.Priority, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ProgrammingLanguage, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Provider, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ReactCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ReadTime, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Snippet, ['block']), _defineProperty(_ElementDisplaySchema, ElementName.SourceBranch, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.State, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.SubscriberCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.SubTasksProgress, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.TargetBranch, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Title, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ViewCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.VoteCount, ['inline']), _ElementDisplaySchema);
19
19
  var getDirectionStyles = function getDirectionStyles(direction) {
20
20
  switch (direction) {
21
21
  case SmartLinkDirection.Vertical:
@@ -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 var 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 var 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 var ModifiedOn = createElement(ElementName.ModifiedOn);
73
83
  * @see Text
74
84
  */
75
85
  export var 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 var 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 var Provider = createElement(ElementName.Provider);
98
113
  * @see Badge
99
114
  */
100
115
  export var ReactCount = createElement(ElementName.ReactCount);
116
+ /**
117
+ * Creates a ReadTime Text element using the data from readTime in the Flexible UI Context
118
+ */
119
+ export var 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 var State = createElement(ElementName.State);
118
137
  * @see Badge
119
138
  */
120
139
  export var 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 var 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