@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
@@ -1,12 +1,16 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
- exports.getSimulatedMetadata = void 0;
7
+ exports.getSimulatedMetadata = exports.getSimulatedBetterMetadata = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
7
9
  var _constants = require("../../constants");
8
10
  var _linkExtractors = require("@atlaskit/link-extractors");
9
11
  var _utils = require("../../extractors/flexible/utils");
12
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
13
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
10
14
  var getSimulatedMetadata = function getSimulatedMetadata() {
11
15
  var extensionKey = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
12
16
  var data = arguments.length > 1 ? arguments[1] : undefined;
@@ -35,7 +39,7 @@ var getSimulatedMetadata = function getSimulatedMetadata() {
35
39
  return {
36
40
  metadata: {
37
41
  primary: [_constants.ElementName.AuthorGroup, primaryAttribution],
38
- secondary: [_constants.ElementName.CommentCount, _constants.ElementName.ReactCount],
42
+ secondary: [_constants.ElementName.ReactCount, _constants.ElementName.CommentCount, _constants.ElementName.ViewCount],
39
43
  subtitle: []
40
44
  }
41
45
  };
@@ -82,4 +86,99 @@ var getSimulatedMetadata = function getSimulatedMetadata() {
82
86
  };
83
87
  }
84
88
  };
85
- exports.getSimulatedMetadata = getSimulatedMetadata;
89
+ exports.getSimulatedMetadata = getSimulatedMetadata;
90
+ var getSimulatedBetterMetadata = function getSimulatedBetterMetadata() {
91
+ var extensionKey = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
92
+ var data = arguments.length > 1 ? arguments[1] : undefined;
93
+ var types = data ? (0, _linkExtractors.extractType)(data) : undefined;
94
+ var defaultMetadata = {
95
+ topMetadataBlock: {
96
+ primary: [_constants.ElementName.ModifiedOn, _constants.ElementName.CreatedBy],
97
+ secondary: [],
98
+ subtitle: []
99
+ },
100
+ bottomMetadataBlock: {
101
+ primary: [],
102
+ secondary: [],
103
+ subtitle: []
104
+ }
105
+ };
106
+ switch (extensionKey) {
107
+ case 'bitbucket-object-provider':
108
+ case 'native-bitbucket-object-provider':
109
+ if (types !== null && types !== void 0 && types.includes('atlassian:SourceCodePullRequest')) {
110
+ return _objectSpread(_objectSpread({}, defaultMetadata), {}, {
111
+ topMetadataBlock: {
112
+ primary: [_constants.ElementName.AuthorGroup, _constants.ElementName.ModifiedOn, _constants.ElementName.SubscriberCount, _constants.ElementName.State],
113
+ secondary: [],
114
+ subtitle: [_constants.ElementName.SourceBranch, _constants.ElementName.TargetBranch]
115
+ }
116
+ });
117
+ }
118
+ return _objectSpread(_objectSpread({}, defaultMetadata), {}, {
119
+ topMetadataBlock: {
120
+ primary: [_constants.ElementName.ModifiedOn, _constants.ElementName.CreatedBy],
121
+ secondary: [],
122
+ subtitle: []
123
+ }
124
+ });
125
+ case 'confluence-object-provider':
126
+ var primaryAttribution = data && (0, _utils.extractOwnedBy)(data) ? _constants.ElementName.OwnedByGroup : _constants.ElementName.AuthorGroup;
127
+ return {
128
+ topMetadataBlock: {
129
+ primary: [primaryAttribution, _constants.ElementName.ModifiedOn],
130
+ secondary: [],
131
+ subtitle: []
132
+ },
133
+ bottomMetadataBlock: {
134
+ primary: [_constants.ElementName.CommentCount, _constants.ElementName.ReactCount, _constants.ElementName.ViewCount],
135
+ secondary: [],
136
+ subtitle: []
137
+ }
138
+ };
139
+ case 'jira-object-provider':
140
+ return _objectSpread(_objectSpread({}, defaultMetadata), {}, {
141
+ topMetadataBlock: {
142
+ primary: [_constants.ElementName.AssignedToGroup, _constants.ElementName.State, _constants.ElementName.Priority],
143
+ secondary: [],
144
+ subtitle: []
145
+ }
146
+ });
147
+ case 'trello-object-provider':
148
+ return _objectSpread(_objectSpread({}, defaultMetadata), {}, {
149
+ topMetadataBlock: {
150
+ primary: [_constants.ElementName.AuthorGroup, _constants.ElementName.State, _constants.ElementName.DueOn],
151
+ secondary: [_constants.ElementName.ReactCount, _constants.ElementName.CommentCount, _constants.ElementName.AttachmentCount, _constants.ElementName.ChecklistProgress],
152
+ subtitle: [_constants.ElementName.Location]
153
+ }
154
+ });
155
+ case 'watermelon-object-provider':
156
+ if (types !== null && types !== void 0 && types.includes('atlassian:Project')) {
157
+ return _objectSpread(_objectSpread({}, defaultMetadata), {}, {
158
+ topMetadataBlock: {
159
+ primary: [_constants.ElementName.AuthorGroup, _constants.ElementName.ModifiedOn, _constants.ElementName.State, _constants.ElementName.DueOn],
160
+ secondary: [],
161
+ subtitle: []
162
+ }
163
+ });
164
+ }
165
+ return _objectSpread(_objectSpread({}, defaultMetadata), {}, {
166
+ topMetadataBlock: {
167
+ primary: [_constants.ElementName.AuthorGroup, _constants.ElementName.State, _constants.ElementName.DueOn],
168
+ secondary: [],
169
+ subtitle: []
170
+ }
171
+ });
172
+ case 'google-object-provider':
173
+ return _objectSpread(_objectSpread({}, defaultMetadata), {}, {
174
+ topMetadataBlock: {
175
+ primary: [_constants.ElementName.AuthorGroup, _constants.ElementName.ModifiedOn],
176
+ secondary: [],
177
+ subtitle: []
178
+ }
179
+ });
180
+ default:
181
+ return defaultMetadata;
182
+ }
183
+ };
184
+ exports.getSimulatedBetterMetadata = getSimulatedBetterMetadata;
@@ -100,6 +100,8 @@ export let SmartLinkWidth = /*#__PURE__*/function (SmartLinkWidth) {
100
100
  * (src/view/FlexibleCard/components/blocks/utils.tsx)
101
101
  */
102
102
  export let 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 let 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 let ActionName = /*#__PURE__*/function (ActionName) {
146
151
  /**
147
152
  * Flexible UI icons - each mapped to AK icons.
148
153
  */
154
+
149
155
  export let 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 @@ const extractFlexibleUiContext = ({
25
25
  const url = extractLink(data);
26
26
  const 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 @@ const 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 @@ const 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
@@ -1,4 +1,4 @@
1
- import { extractPersonOwnedBy, extractPersonCreatedBy, extractPersonUpdatedBy } from '@atlaskit/link-extractors';
1
+ import { extractPersonOwnedBy, extractPersonCreatedBy, extractPersonUpdatedBy, extractPersonAssignedTo } from '@atlaskit/link-extractors';
2
2
  const extractLinkName = link => {
3
3
  if (link && typeof link === 'object' && link['@type'] === 'Link') {
4
4
  return link.name;
@@ -18,6 +18,16 @@ export const extractOwnedBy = data => {
18
18
  return persons[0].name;
19
19
  }
20
20
  };
21
+ export const extractAssignedTo = data => {
22
+ const person = extractPersonAssignedTo(data);
23
+ if (person) {
24
+ return person.name;
25
+ }
26
+ };
27
+ export const extractPersonAssignedToAsArray = data => {
28
+ const person = extractPersonAssignedTo(data);
29
+ return person ? [person] : undefined;
30
+ };
21
31
  export const extractCreatedBy = data => {
22
32
  const persons = extractPersonCreatedBy(data);
23
33
  if (persons && persons.length) {
@@ -50,4 +60,11 @@ export const extractLocation = data => {
50
60
  url
51
61
  };
52
62
  }
63
+ };
64
+ export const extractSubTasksProgress = data => {
65
+ const subTasksObject = extractValue(data, 'atlassian:subTasks');
66
+ return subTasksObject && subTasksObject.totalCount ? `${subTasksObject.resolvedCount}/${subTasksObject.totalCount}` : undefined;
67
+ };
68
+ export const extractReadTime = data => {
69
+ return extractValue(data, 'atlassian:readTimeInMinutes');
53
70
  };
@@ -1,5 +1,5 @@
1
1
  import { ElementName } from '../../constants';
2
- const elementNamesToItems = elementNames => {
2
+ export const elementNamesToItems = elementNames => {
3
3
  return elementNames.filter(element => element in ElementName).map(elementName => ({
4
4
  name: elementName,
5
5
  testId: `${elementName.toLowerCase()}-metadata-element`
@@ -10,6 +10,11 @@ export const 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 const 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,10 +1,14 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
1
2
  import React, { useEffect, useState } from 'react';
2
3
  import FlexibleCard from '../../../FlexibleCard';
3
4
  import TitleBlock from '../../../FlexibleCard/components/blocks/title-block';
4
5
  import { FooterBlock, MetadataBlock, PreviewBlock, SnippetBlock } from '../../../FlexibleCard/components/blocks';
5
- import { ActionName, CardDisplay, ElementName, MediaPlacement, SmartLinkPosition } from '../../../../constants';
6
+ import { metadataBlockCss, titleBlockCss } from './styled';
7
+ import { ActionName, CardDisplay, ElementName, MediaPlacement, SmartLinkPosition, SmartLinkSize } from '../../../../constants';
6
8
  import uuid from 'uuid';
7
- import { extractOwnedBy } from '../../../../extractors/flexible/utils';
9
+ import { getSimulatedMetadata, getSimulatedBetterMetadata } from './utils';
10
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
11
+
8
12
  /**
9
13
  * This view represents a Block card that has an 'Resolved' status.
10
14
  * @see SmartLinkStatus
@@ -23,36 +27,16 @@ const FlexibleResolvedView = ({
23
27
  url,
24
28
  analytics
25
29
  }) => {
26
- var _cardState$details, _cardState$details2;
27
30
  const [isPreviewBlockErrored, setIsPreviewBlockErrored] = useState(false);
28
31
  useEffect(() => {
29
32
  setIsPreviewBlockErrored(false);
30
33
  }, [url, cardState]);
31
34
  const [analyticsId] = useState(() => id ? id : uuid());
32
- const baseMetadata = [{
33
- name: ElementName.ModifiedOn
34
- }, {
35
- name: ElementName.AttachmentCount
36
- }, {
37
- name: ElementName.CommentCount
38
- }, {
39
- name: ElementName.ReactCount
40
- }, {
41
- name: ElementName.SubscriberCount
42
- }, {
43
- name: ElementName.ViewCount
44
- }, {
45
- name: ElementName.VoteCount
46
- }, {
47
- name: ElementName.ChecklistProgress
48
- }, {
49
- name: ElementName.DueOn
50
- }];
51
- const 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) ? [{
52
- name: ElementName.OwnedBy
53
- }, ...baseMetadata] : [{
54
- name: ElementName.ModifiedBy
55
- }, ...baseMetadata];
35
+ const {
36
+ titleMetadata,
37
+ topMetadata,
38
+ bottomMetadata
39
+ } = getBooleanFF('platform.linking-platform.smart-card.enable-better-metadata_iojwg') ? getSimulatedBetterMetadata(cardState.details) : getSimulatedMetadata(cardState.details);
56
40
  return /*#__PURE__*/React.createElement(FlexibleCard, {
57
41
  analytics: analytics,
58
42
  appearance: "block",
@@ -64,25 +48,27 @@ const FlexibleResolvedView = ({
64
48
  testId: testId,
65
49
  ui: ui,
66
50
  url: url
67
- }, /*#__PURE__*/React.createElement(TitleBlock, {
51
+ }, /*#__PURE__*/React.createElement(TitleBlock, _extends({
68
52
  position: SmartLinkPosition.Center,
69
- metadata: [{
70
- name: ElementName.AuthorGroup
71
- }, {
72
- name: ElementName.Priority
73
- }, {
74
- name: ElementName.State
75
- }],
53
+ metadata: titleMetadata,
76
54
  hideRetry: true,
77
55
  subtitle: [{
78
56
  name: ElementName.Location
79
57
  }],
80
58
  metadataPosition: SmartLinkPosition.Top,
81
59
  anchorTarget: anchorTarget
82
- }), /*#__PURE__*/React.createElement(MetadataBlock, {
83
- primary: metadata,
60
+ }, getBooleanFF('platform.linking-platform.smart-card.enable-better-metadata_iojwg') && {
61
+ overrideCss: titleBlockCss,
62
+ size: SmartLinkSize.Large
63
+ })), /*#__PURE__*/React.createElement(MetadataBlock, _extends({
64
+ primary: topMetadata,
65
+ maxLines: 1
66
+ }, getBooleanFF('platform.linking-platform.smart-card.enable-better-metadata_iojwg') && {
67
+ overrideCss: metadataBlockCss
68
+ })), /*#__PURE__*/React.createElement(SnippetBlock, null), getBooleanFF('platform.linking-platform.smart-card.enable-better-metadata_iojwg') && /*#__PURE__*/React.createElement(MetadataBlock, {
69
+ primary: bottomMetadata,
84
70
  maxLines: 1
85
- }), /*#__PURE__*/React.createElement(SnippetBlock, null), !isPreviewBlockErrored ? /*#__PURE__*/React.createElement(PreviewBlock, {
71
+ }), !isPreviewBlockErrored ? /*#__PURE__*/React.createElement(PreviewBlock, {
86
72
  placement: MediaPlacement.Right,
87
73
  ignoreContainerPadding: true,
88
74
  onError: () => {
@@ -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
+ };
@@ -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: