@atlaskit/smart-card 26.57.1 → 26.57.2

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 26.57.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#92944](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/92944) [`1d66db78c1c9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/1d66db78c1c9) - Refactor hover card metadata function
8
+ - Updated dependencies
9
+
3
10
  ## 26.57.1
4
11
 
5
12
  ### Patch Changes
@@ -22,7 +22,7 @@ var ANALYTICS_CHANNEL = exports.ANALYTICS_CHANNEL = 'media';
22
22
  var context = exports.context = {
23
23
  componentName: 'smart-cards',
24
24
  packageName: "@atlaskit/smart-card",
25
- packageVersion: "26.57.1"
25
+ packageVersion: "26.57.2"
26
26
  };
27
27
  var TrackQuickActionType = exports.TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
28
28
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -15,7 +15,6 @@ var _copy = _interopRequireDefault(require("@atlaskit/icon/glyph/copy"));
15
15
  var _react2 = _interopRequireWildcard(require("react"));
16
16
  var _linkProvider = require("@atlaskit/link-provider");
17
17
  var _constants = require("../../../constants");
18
- var _extractMetadata2 = require("../../../extractors/hover/extractMetadata");
19
18
  var _analytics2 = require("../../../state/analytics");
20
19
  var _helpers = require("../../../state/helpers");
21
20
  var _utils = require("../../../utils");
@@ -144,8 +143,8 @@ var HoverCardContent = function HoverCardContent(_ref) {
144
143
  return [getCopyAction(url)];
145
144
  }, [url]);
146
145
  var data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
147
- var _extractMetadata = (0, _extractMetadata2.extractMetadata)((0, _utils2.getSimulatedMetadata)(extensionKey, data)),
148
- subtitle = _extractMetadata.subtitle;
146
+ var _getMetadata = (0, _utils2.getMetadata)(extensionKey, data),
147
+ subtitle = _getMetadata.subtitle;
149
148
  var titleMaxLines = subtitle && subtitle.length > 0 ? 1 : 2;
150
149
  var titleBlockProps = {
151
150
  actions: (0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-card.hover-card-action-redesign') ? undefined : titleActions,
@@ -15,7 +15,6 @@ var _styled = require("./styled");
15
15
  var _FlexibleCard = _interopRequireDefault(require("../../../../FlexibleCard"));
16
16
  var _utils = require("../../../utils");
17
17
  var _ImagePreview = _interopRequireDefault(require("../../ImagePreview"));
18
- var _extractMetadata = require("../../../../../extractors/hover/extractMetadata");
19
18
  var _messages = require("../../../../../messages");
20
19
  var _reactIntlNext = require("react-intl-next");
21
20
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
@@ -119,16 +118,11 @@ var HoverCardResolvedView = function HoverCardResolvedView(_ref2) {
119
118
  }, [cardActions, onActionClick]);
120
119
  var data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
121
120
  var _useMemo = (0, _react.useMemo)(function () {
122
- var betterMetadata = (0, _utils.getSimulatedBetterMetadata)(extensionKey, data);
123
- return {
124
- topPrimary: (0, _extractMetadata.elementNamesToItems)(betterMetadata.topMetadataBlock.primary),
125
- topSecondary: (0, _extractMetadata.elementNamesToItems)(betterMetadata.topMetadataBlock.secondary),
126
- bottomPrimary: (0, _extractMetadata.elementNamesToItems)(betterMetadata.bottomMetadataBlock.primary)
127
- };
121
+ return (0, _utils.getMetadata)(extensionKey, data);
128
122
  }, [data, extensionKey]),
129
- topPrimary = _useMemo.topPrimary,
130
- topSecondary = _useMemo.topSecondary,
131
- bottomPrimary = _useMemo.bottomPrimary;
123
+ primary = _useMemo.primary,
124
+ secondary = _useMemo.secondary,
125
+ tertiary = _useMemo.tertiary;
132
126
  var snippetHeight = _react.default.useRef(0);
133
127
  var snippetBlockRef = (0, _react.useRef)(null);
134
128
  var onSnippetRender = (0, _react.useCallback)(function () {
@@ -152,8 +146,8 @@ var HoverCardResolvedView = function HoverCardResolvedView(_ref2) {
152
146
  return /*#__PURE__*/_react.default.createElement(_FlexibleCard.default, flexibleCardProps, imagePreview, /*#__PURE__*/_react.default.createElement(_blocks.TitleBlock, (0, _extends2.default)({}, titleBlockProps, {
153
147
  metadataPosition: _constants.SmartLinkPosition.Top
154
148
  })), /*#__PURE__*/_react.default.createElement(_blocks.MetadataBlock, {
155
- primary: topPrimary,
156
- secondary: topSecondary,
149
+ primary: primary,
150
+ secondary: secondary,
157
151
  overrideCss: _styled.metadataBlockCss,
158
152
  maxLines: 1,
159
153
  size: _constants.SmartLinkSize.Medium
@@ -167,7 +161,7 @@ var HoverCardResolvedView = function HoverCardResolvedView(_ref2) {
167
161
  blockRef: connectedAIBlockRef
168
162
  }, /*#__PURE__*/_react.default.createElement(ConnectedAIBlock, {
169
163
  imagePreview: !!imagePreview,
170
- bottomPrimary: bottomPrimary,
164
+ bottomPrimary: tertiary,
171
165
  data: data
172
166
  })), !isAISummaryEnabled && !imagePreview && /*#__PURE__*/_react.default.createElement(_blocks.SnippetBlock, {
173
167
  status: _constants.SmartLinkStatus.Resolved
@@ -177,7 +171,7 @@ var HoverCardResolvedView = function HoverCardResolvedView(_ref2) {
177
171
  blockRef: snippetBlockRef,
178
172
  overrideCss: _styled.hiddenSnippetStyles
179
173
  }), !isAISummaryEnabled && /*#__PURE__*/_react.default.createElement(_blocks.MetadataBlock, {
180
- primary: bottomPrimary,
174
+ primary: tertiary,
181
175
  size: _constants.SmartLinkSize.Large,
182
176
  overrideCss: _styled.metadataBlockCss,
183
177
  maxLines: 1,
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.getSimulatedMetadata = exports.getSimulatedBetterMetadata = void 0;
7
+ exports.getMetadata = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _constants = require("../../constants");
10
10
  var _linkExtractors = require("@atlaskit/link-extractors");
@@ -12,197 +12,93 @@ var _utils = require("../../extractors/flexible/utils");
12
12
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
13
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
14
14
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
15
- var getSimulatedMetadata = exports.getSimulatedMetadata = function getSimulatedMetadata() {
16
- var extensionKey = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
17
- var data = arguments.length > 1 ? arguments[1] : undefined;
15
+ var getSimulatedBetterMetadata = function getSimulatedBetterMetadata(extensionKey, data) {
16
+ var _data$Type$includes, _data$Type;
18
17
  var types = data ? (0, _linkExtractors.extractType)(data) : undefined;
18
+ var defaultMetadata = {
19
+ primary: [_constants.ElementName.AuthorGroup, _constants.ElementName.ModifiedOn]
20
+ };
19
21
  switch (extensionKey) {
20
22
  case 'bitbucket-object-provider':
21
23
  case 'native-bitbucket-object-provider':
22
24
  if (types !== null && types !== void 0 && types.includes('atlassian:SourceCodePullRequest')) {
23
25
  return {
24
- metadata: {
25
- primary: [_constants.ElementName.AuthorGroup, _constants.ElementName.ModifiedOn, _constants.ElementName.SubscriberCount, _constants.ElementName.State],
26
- secondary: [],
27
- subtitle: [_constants.ElementName.SourceBranch, _constants.ElementName.TargetBranch]
28
- }
26
+ primary: [_constants.ElementName.AuthorGroup, _constants.ElementName.ModifiedOn, _constants.ElementName.SubscriberCount, _constants.ElementName.State],
27
+ subtitle: [_constants.ElementName.SourceBranch, _constants.ElementName.TargetBranch]
29
28
  };
30
29
  }
31
- return {
32
- metadata: {
33
- primary: [_constants.ElementName.ModifiedOn, _constants.ElementName.CreatedBy],
34
- secondary: [],
35
- subtitle: []
36
- }
37
- };
38
- case 'confluence-object-provider':
39
- var primaryAttribution = data && (0, _utils.extractOwnedBy)(data) ? _constants.ElementName.OwnedBy : _constants.ElementName.CreatedBy;
40
- return {
41
- metadata: {
42
- primary: [_constants.ElementName.AuthorGroup, primaryAttribution],
43
- secondary: [_constants.ElementName.ReactCount, _constants.ElementName.CommentCount, _constants.ElementName.ViewCount],
44
- subtitle: []
45
- }
46
- };
47
- case 'jira-object-provider':
48
- return {
49
- metadata: {
50
- primary: [_constants.ElementName.AuthorGroup, _constants.ElementName.State, _constants.ElementName.Priority],
51
- secondary: [],
52
- subtitle: []
53
- }
54
- };
55
- case 'trello-object-provider':
56
- return {
57
- metadata: {
58
- primary: [_constants.ElementName.AuthorGroup, _constants.ElementName.State, _constants.ElementName.DueOn],
59
- secondary: [_constants.ElementName.ReactCount, _constants.ElementName.CommentCount, _constants.ElementName.AttachmentCount, _constants.ElementName.ChecklistProgress],
60
- subtitle: [_constants.ElementName.Location]
61
- }
62
- };
63
- case 'watermelon-object-provider':
64
- if (types !== null && types !== void 0 && types.includes('atlassian:Project')) {
30
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.extractor.improve-bitbucket-file-links') && types !== null && types !== void 0 && types.includes('schema:DigitalDocument')) {
65
31
  return {
66
- metadata: {
67
- primary: [_constants.ElementName.AuthorGroup, _constants.ElementName.ModifiedOn, _constants.ElementName.State, _constants.ElementName.DueOn],
68
- secondary: [],
69
- subtitle: []
70
- }
32
+ primary: [_constants.ElementName.LatestCommit, _constants.ElementName.CollaboratorGroup, _constants.ElementName.ModifiedOn]
71
33
  };
72
34
  }
73
35
  return {
74
- metadata: {
75
- primary: [_constants.ElementName.AuthorGroup, _constants.ElementName.State, _constants.ElementName.DueOn],
76
- secondary: [],
77
- subtitle: []
78
- }
79
- };
80
- default:
81
- return {
82
- metadata: {
83
- primary: [_constants.ElementName.ModifiedOn, _constants.ElementName.CreatedBy],
84
- secondary: [],
85
- subtitle: []
86
- }
36
+ primary: [_constants.ElementName.AuthorGroup, _constants.ElementName.ModifiedOn]
87
37
  };
88
- }
89
- };
90
- var getSimulatedBetterMetadata = exports.getSimulatedBetterMetadata = function getSimulatedBetterMetadata() {
91
- var _data$Type$includes, _data$Type;
92
- var extensionKey = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
93
- var data = arguments.length > 1 ? arguments[1] : undefined;
94
- var types = data ? (0, _linkExtractors.extractType)(data) : undefined;
95
- var defaultMetadata = {
96
- topMetadataBlock: {
97
- primary: [_constants.ElementName.AuthorGroup, _constants.ElementName.ModifiedOn],
98
- secondary: [],
99
- subtitle: []
100
- },
101
- bottomMetadataBlock: {
102
- primary: [],
103
- secondary: [],
104
- subtitle: []
105
- }
106
- };
107
- switch (extensionKey) {
108
- case 'bitbucket-object-provider':
109
- case 'native-bitbucket-object-provider':
110
- if (types !== null && types !== void 0 && types.includes('atlassian:SourceCodePullRequest')) {
111
- return _objectSpread(_objectSpread({}, defaultMetadata), {}, {
112
- topMetadataBlock: {
113
- primary: [_constants.ElementName.AuthorGroup, _constants.ElementName.ModifiedOn, _constants.ElementName.SubscriberCount, _constants.ElementName.State],
114
- secondary: [],
115
- subtitle: [_constants.ElementName.SourceBranch, _constants.ElementName.TargetBranch]
116
- }
117
- });
118
- }
119
- if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.extractor.improve-bitbucket-file-links') && types !== null && types !== void 0 && types.includes('schema:DigitalDocument')) {
120
- return _objectSpread(_objectSpread({}, defaultMetadata), {}, {
121
- topMetadataBlock: {
122
- primary: [_constants.ElementName.LatestCommit, _constants.ElementName.CollaboratorGroup, _constants.ElementName.ModifiedOn],
123
- secondary: [],
124
- subtitle: []
125
- }
126
- });
127
- }
128
- return _objectSpread(_objectSpread({}, defaultMetadata), {}, {
129
- topMetadataBlock: {
130
- primary: [_constants.ElementName.AuthorGroup, _constants.ElementName.ModifiedOn],
131
- secondary: [],
132
- subtitle: []
133
- }
134
- });
135
38
  case 'confluence-object-provider':
136
39
  var primaryAttribution = data && (0, _utils.extractOwnedBy)(data) ? _constants.ElementName.OwnedByGroup : _constants.ElementName.AuthorGroup;
137
40
  return {
138
- topMetadataBlock: {
139
- primary: [primaryAttribution, _constants.ElementName.ModifiedOn],
140
- secondary: [],
141
- subtitle: []
142
- },
143
- bottomMetadataBlock: {
144
- primary: [_constants.ElementName.ReactCount, _constants.ElementName.CommentCount, _constants.ElementName.ViewCount],
145
- secondary: [],
146
- subtitle: []
147
- }
41
+ primary: [primaryAttribution, _constants.ElementName.ModifiedOn],
42
+ tertiary: [_constants.ElementName.ReactCount, _constants.ElementName.CommentCount, _constants.ElementName.ViewCount]
148
43
  };
149
44
  case 'jira-object-provider':
150
- var isJiraTask = (_data$Type$includes = (_data$Type = data['@type']) === null || _data$Type === void 0 ? void 0 : _data$Type.includes('atlassian:Task')) !== null && _data$Type$includes !== void 0 ? _data$Type$includes : false;
45
+ var isJiraTask = (_data$Type$includes = data === null || data === void 0 || (_data$Type = data['@type']) === null || _data$Type === void 0 ? void 0 : _data$Type.includes('atlassian:Task')) !== null && _data$Type$includes !== void 0 ? _data$Type$includes : false;
151
46
  return _objectSpread(_objectSpread({}, defaultMetadata), isJiraTask && {
152
- topMetadataBlock: {
153
- primary: [_constants.ElementName.AssignedToGroup, _constants.ElementName.State, _constants.ElementName.StoryPoints, _constants.ElementName.Priority],
154
- secondary: [],
155
- subtitle: []
156
- }
47
+ primary: [_constants.ElementName.AssignedToGroup, _constants.ElementName.State, _constants.ElementName.StoryPoints, _constants.ElementName.Priority]
157
48
  });
158
49
  case 'trello-object-provider':
159
- return _objectSpread(_objectSpread({}, defaultMetadata), {}, {
160
- topMetadataBlock: {
161
- primary: [_constants.ElementName.AuthorGroup, _constants.ElementName.State, _constants.ElementName.DueOn],
162
- secondary: [_constants.ElementName.ReactCount, _constants.ElementName.CommentCount, _constants.ElementName.AttachmentCount, _constants.ElementName.ChecklistProgress],
163
- subtitle: [_constants.ElementName.Location]
164
- }
165
- });
50
+ return {
51
+ primary: [_constants.ElementName.AuthorGroup, _constants.ElementName.State, _constants.ElementName.DueOn],
52
+ secondary: [_constants.ElementName.ReactCount, _constants.ElementName.CommentCount, _constants.ElementName.AttachmentCount, _constants.ElementName.ChecklistProgress],
53
+ subtitle: [_constants.ElementName.Location]
54
+ };
166
55
  case 'watermelon-object-provider':
167
56
  if (types !== null && types !== void 0 && types.includes('atlassian:Project')) {
168
- return _objectSpread(_objectSpread({}, defaultMetadata), {}, {
169
- topMetadataBlock: {
170
- primary: [_constants.ElementName.AuthorGroup, _constants.ElementName.ModifiedOn, _constants.ElementName.State, _constants.ElementName.DueOn],
171
- secondary: [],
172
- subtitle: []
173
- }
174
- });
57
+ return {
58
+ primary: [_constants.ElementName.AuthorGroup, _constants.ElementName.ModifiedOn, _constants.ElementName.State, _constants.ElementName.DueOn]
59
+ };
175
60
  }
176
- return _objectSpread(_objectSpread({}, defaultMetadata), {}, {
177
- topMetadataBlock: {
178
- primary: [_constants.ElementName.AuthorGroup, _constants.ElementName.State, _constants.ElementName.DueOn],
179
- secondary: [],
180
- subtitle: []
181
- }
182
- });
61
+ return {
62
+ primary: [_constants.ElementName.AuthorGroup, _constants.ElementName.State, _constants.ElementName.DueOn]
63
+ };
183
64
  case 'slack-object-provider':
184
65
  return {
185
- topMetadataBlock: {
186
- primary: [_constants.ElementName.AuthorGroup, _constants.ElementName.SentOn],
187
- secondary: [],
188
- subtitle: []
189
- },
190
- bottomMetadataBlock: {
191
- primary: [_constants.ElementName.ReactCount, _constants.ElementName.CommentCount],
192
- secondary: [],
193
- subtitle: []
194
- }
66
+ primary: [_constants.ElementName.AuthorGroup, _constants.ElementName.SentOn],
67
+ tertiary: [_constants.ElementName.ReactCount, _constants.ElementName.CommentCount]
195
68
  };
196
69
  case 'google-object-provider':
197
70
  case 'figma-object-provider':
198
- return _objectSpread(_objectSpread({}, defaultMetadata), {}, {
199
- topMetadataBlock: {
200
- primary: [_constants.ElementName.AuthorGroup, _constants.ElementName.ModifiedOn],
201
- secondary: [],
202
- subtitle: []
203
- }
204
- });
71
+ return {
72
+ primary: [_constants.ElementName.AuthorGroup, _constants.ElementName.ModifiedOn]
73
+ };
205
74
  default:
206
75
  return defaultMetadata;
207
76
  }
77
+ };
78
+ var AvatarGroupsWithNamePrefix = [_constants.ElementName.AssignedToGroup, _constants.ElementName.OwnedByGroup, _constants.ElementName.AuthorGroup];
79
+ var toElementItem = function toElementItem(name) {
80
+ var showNamePrefix = AvatarGroupsWithNamePrefix.indexOf(name) !== -1 ? true : undefined;
81
+ var testId = "".concat(name.toLowerCase(), "-metadata-element");
82
+ return {
83
+ name: name,
84
+ showNamePrefix: showNamePrefix,
85
+ testId: testId
86
+ };
87
+ };
88
+ var toElementItems = function toElementItems(elementNames) {
89
+ if (!(elementNames !== null && elementNames !== void 0 && elementNames.length)) {
90
+ return;
91
+ }
92
+ return elementNames.filter(function (name) {
93
+ return name in _constants.ElementName;
94
+ }).map(toElementItem);
95
+ };
96
+ var getMetadata = exports.getMetadata = function getMetadata(extensionKey, data) {
97
+ var metadata = getSimulatedBetterMetadata(extensionKey, data);
98
+ return {
99
+ subtitle: toElementItems(metadata.subtitle),
100
+ primary: toElementItems(metadata.primary),
101
+ secondary: toElementItems(metadata.secondary),
102
+ tertiary: toElementItems(metadata.tertiary)
103
+ };
208
104
  };
@@ -17,7 +17,7 @@ var _excluded = ["href", "children", "checkSafety", "onClick", "testId"],
17
17
  _excluded2 = ["isLinkSafe", "showSafetyWarningModal"];
18
18
  var PACKAGE_DATA = {
19
19
  packageName: "@atlaskit/smart-card",
20
- packageVersion: "26.57.1",
20
+ packageVersion: "26.57.2",
21
21
  componentName: 'linkUrl'
22
22
  };
23
23
  var Link = (0, _click.withLinkClickedEvent)('a');
@@ -4,7 +4,7 @@ export const ANALYTICS_CHANNEL = 'media';
4
4
  export const context = {
5
5
  componentName: 'smart-cards',
6
6
  packageName: "@atlaskit/smart-card",
7
- packageVersion: "26.57.1"
7
+ packageVersion: "26.57.2"
8
8
  };
9
9
  export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
10
10
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -6,12 +6,11 @@ import CopyIcon from '@atlaskit/icon/glyph/copy';
6
6
  import React, { useCallback, useEffect, useMemo, useRef } from 'react';
7
7
  import { useSmartLinkContext } from '@atlaskit/link-provider';
8
8
  import { ActionName, CardDisplay, SmartLinkPosition, SmartLinkSize } from '../../../constants';
9
- import { extractMetadata } from '../../../extractors/hover/extractMetadata';
10
9
  import { useSmartLinkAnalytics } from '../../../state/analytics';
11
10
  import { getExtensionKey, getServices } from '../../../state/helpers';
12
11
  import { isSpecialEvent } from '../../../utils';
13
12
  import { flexibleUiOptions, titleBlockCss } from '../styled';
14
- import { getSimulatedMetadata } from '../utils';
13
+ import { getMetadata } from '../utils';
15
14
  import HoverCardLoadingView from './views/resolving';
16
15
  import HoverCardUnauthorisedView from './views/unauthorised';
17
16
  import HoverCardResolvedView from './views/resolved';
@@ -109,7 +108,7 @@ const HoverCardContent = ({
109
108
  const data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
110
109
  const {
111
110
  subtitle
112
- } = extractMetadata(getSimulatedMetadata(extensionKey, data));
111
+ } = getMetadata(extensionKey, data);
113
112
  const titleMaxLines = subtitle && subtitle.length > 0 ? 1 : 2;
114
113
  const titleBlockProps = {
115
114
  actions: getBooleanFF('platform.linking-platform.smart-card.hover-card-action-redesign') ? undefined : titleActions,
@@ -4,9 +4,8 @@ import { ActionName, CardDisplay, ElementName, SmartLinkPosition, SmartLinkSize,
4
4
  import { FooterBlock, MetadataBlock, RelatedUrlsBlock, SnippetBlock, TitleBlock, AISummaryBlock, CustomBlock, ActionBlock } from '../../../../FlexibleCard/components/blocks';
5
5
  import { footerBlockCss, hiddenSnippetStyles, metadataBlockCss } from './styled';
6
6
  import FlexibleCard from '../../../../FlexibleCard';
7
- import { getSimulatedBetterMetadata } from '../../../utils';
7
+ import { getMetadata } from '../../../utils';
8
8
  import ImagePreview from '../../ImagePreview';
9
- import { elementNamesToItems } from '../../../../../extractors/hover/extractMetadata';
10
9
  import { messages } from '../../../../../messages';
11
10
  import { FormattedMessage } from 'react-intl-next';
12
11
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
@@ -111,16 +110,11 @@ const HoverCardResolvedView = ({
111
110
  const footerActions = useMemo(() => toFooterActions(cardActions, onActionClick), [cardActions, onActionClick]);
112
111
  const data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
113
112
  const {
114
- topPrimary,
115
- topSecondary,
116
- bottomPrimary
113
+ primary,
114
+ secondary,
115
+ tertiary
117
116
  } = useMemo(() => {
118
- const betterMetadata = getSimulatedBetterMetadata(extensionKey, data);
119
- return {
120
- topPrimary: elementNamesToItems(betterMetadata.topMetadataBlock.primary),
121
- topSecondary: elementNamesToItems(betterMetadata.topMetadataBlock.secondary),
122
- bottomPrimary: elementNamesToItems(betterMetadata.bottomMetadataBlock.primary)
123
- };
117
+ return getMetadata(extensionKey, data);
124
118
  }, [data, extensionKey]);
125
119
  const snippetHeight = React.useRef(0);
126
120
  const snippetBlockRef = useRef(null);
@@ -145,8 +139,8 @@ const HoverCardResolvedView = ({
145
139
  return /*#__PURE__*/React.createElement(FlexibleCard, flexibleCardProps, imagePreview, /*#__PURE__*/React.createElement(TitleBlock, _extends({}, titleBlockProps, {
146
140
  metadataPosition: SmartLinkPosition.Top
147
141
  })), /*#__PURE__*/React.createElement(MetadataBlock, {
148
- primary: topPrimary,
149
- secondary: topSecondary,
142
+ primary: primary,
143
+ secondary: secondary,
150
144
  overrideCss: metadataBlockCss,
151
145
  maxLines: 1,
152
146
  size: SmartLinkSize.Medium
@@ -160,7 +154,7 @@ const HoverCardResolvedView = ({
160
154
  blockRef: connectedAIBlockRef
161
155
  }, /*#__PURE__*/React.createElement(ConnectedAIBlock, {
162
156
  imagePreview: !!imagePreview,
163
- bottomPrimary: bottomPrimary,
157
+ bottomPrimary: tertiary,
164
158
  data: data
165
159
  })), !isAISummaryEnabled && !imagePreview && /*#__PURE__*/React.createElement(SnippetBlock, {
166
160
  status: SmartLinkStatus.Resolved
@@ -170,7 +164,7 @@ const HoverCardResolvedView = ({
170
164
  blockRef: snippetBlockRef,
171
165
  overrideCss: hiddenSnippetStyles
172
166
  }), !isAISummaryEnabled && /*#__PURE__*/React.createElement(MetadataBlock, {
173
- primary: bottomPrimary,
167
+ primary: tertiary,
174
168
  size: SmartLinkSize.Large,
175
169
  overrideCss: metadataBlockCss,
176
170
  maxLines: 1,
@@ -2,203 +2,94 @@ import { ElementName } from '../../constants';
2
2
  import { extractType } from '@atlaskit/link-extractors';
3
3
  import { extractOwnedBy } from '../../extractors/flexible/utils';
4
4
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
5
- export const getSimulatedMetadata = (extensionKey = '', data) => {
6
- const types = data ? extractType(data) : undefined;
7
- switch (extensionKey) {
8
- case 'bitbucket-object-provider':
9
- case 'native-bitbucket-object-provider':
10
- if (types !== null && types !== void 0 && types.includes('atlassian:SourceCodePullRequest')) {
11
- return {
12
- metadata: {
13
- primary: [ElementName.AuthorGroup, ElementName.ModifiedOn, ElementName.SubscriberCount, ElementName.State],
14
- secondary: [],
15
- subtitle: [ElementName.SourceBranch, ElementName.TargetBranch]
16
- }
17
- };
18
- }
19
- return {
20
- metadata: {
21
- primary: [ElementName.ModifiedOn, ElementName.CreatedBy],
22
- secondary: [],
23
- subtitle: []
24
- }
25
- };
26
- case 'confluence-object-provider':
27
- const primaryAttribution = data && extractOwnedBy(data) ? ElementName.OwnedBy : ElementName.CreatedBy;
28
- return {
29
- metadata: {
30
- primary: [ElementName.AuthorGroup, primaryAttribution],
31
- secondary: [ElementName.ReactCount, ElementName.CommentCount, ElementName.ViewCount],
32
- subtitle: []
33
- }
34
- };
35
- case 'jira-object-provider':
36
- return {
37
- metadata: {
38
- primary: [ElementName.AuthorGroup, ElementName.State, ElementName.Priority],
39
- secondary: [],
40
- subtitle: []
41
- }
42
- };
43
- case 'trello-object-provider':
44
- return {
45
- metadata: {
46
- primary: [ElementName.AuthorGroup, ElementName.State, ElementName.DueOn],
47
- secondary: [ElementName.ReactCount, ElementName.CommentCount, ElementName.AttachmentCount, ElementName.ChecklistProgress],
48
- subtitle: [ElementName.Location]
49
- }
50
- };
51
- case 'watermelon-object-provider':
52
- if (types !== null && types !== void 0 && types.includes('atlassian:Project')) {
53
- return {
54
- metadata: {
55
- primary: [ElementName.AuthorGroup, ElementName.ModifiedOn, ElementName.State, ElementName.DueOn],
56
- secondary: [],
57
- subtitle: []
58
- }
59
- };
60
- }
61
- return {
62
- metadata: {
63
- primary: [ElementName.AuthorGroup, ElementName.State, ElementName.DueOn],
64
- secondary: [],
65
- subtitle: []
66
- }
67
- };
68
- default:
69
- return {
70
- metadata: {
71
- primary: [ElementName.ModifiedOn, ElementName.CreatedBy],
72
- secondary: [],
73
- subtitle: []
74
- }
75
- };
76
- }
77
- };
78
- export const getSimulatedBetterMetadata = (extensionKey = '', data) => {
5
+ const getSimulatedBetterMetadata = (extensionKey, data) => {
79
6
  var _data$Type$includes, _data$Type;
80
7
  const types = data ? extractType(data) : undefined;
81
8
  const defaultMetadata = {
82
- topMetadataBlock: {
83
- primary: [ElementName.AuthorGroup, ElementName.ModifiedOn],
84
- secondary: [],
85
- subtitle: []
86
- },
87
- bottomMetadataBlock: {
88
- primary: [],
89
- secondary: [],
90
- subtitle: []
91
- }
9
+ primary: [ElementName.AuthorGroup, ElementName.ModifiedOn]
92
10
  };
93
11
  switch (extensionKey) {
94
12
  case 'bitbucket-object-provider':
95
13
  case 'native-bitbucket-object-provider':
96
14
  if (types !== null && types !== void 0 && types.includes('atlassian:SourceCodePullRequest')) {
97
15
  return {
98
- ...defaultMetadata,
99
- topMetadataBlock: {
100
- primary: [ElementName.AuthorGroup, ElementName.ModifiedOn, ElementName.SubscriberCount, ElementName.State],
101
- secondary: [],
102
- subtitle: [ElementName.SourceBranch, ElementName.TargetBranch]
103
- }
16
+ primary: [ElementName.AuthorGroup, ElementName.ModifiedOn, ElementName.SubscriberCount, ElementName.State],
17
+ subtitle: [ElementName.SourceBranch, ElementName.TargetBranch]
104
18
  };
105
19
  }
106
20
  if (getBooleanFF('platform.linking-platform.extractor.improve-bitbucket-file-links') && types !== null && types !== void 0 && types.includes('schema:DigitalDocument')) {
107
21
  return {
108
- ...defaultMetadata,
109
- topMetadataBlock: {
110
- primary: [ElementName.LatestCommit, ElementName.CollaboratorGroup, ElementName.ModifiedOn],
111
- secondary: [],
112
- subtitle: []
113
- }
22
+ primary: [ElementName.LatestCommit, ElementName.CollaboratorGroup, ElementName.ModifiedOn]
114
23
  };
115
24
  }
116
25
  return {
117
- ...defaultMetadata,
118
- topMetadataBlock: {
119
- primary: [ElementName.AuthorGroup, ElementName.ModifiedOn],
120
- secondary: [],
121
- subtitle: []
122
- }
26
+ primary: [ElementName.AuthorGroup, ElementName.ModifiedOn]
123
27
  };
124
28
  case 'confluence-object-provider':
125
29
  const primaryAttribution = data && extractOwnedBy(data) ? ElementName.OwnedByGroup : ElementName.AuthorGroup;
126
30
  return {
127
- topMetadataBlock: {
128
- primary: [primaryAttribution, ElementName.ModifiedOn],
129
- secondary: [],
130
- subtitle: []
131
- },
132
- bottomMetadataBlock: {
133
- primary: [ElementName.ReactCount, ElementName.CommentCount, ElementName.ViewCount],
134
- secondary: [],
135
- subtitle: []
136
- }
31
+ primary: [primaryAttribution, ElementName.ModifiedOn],
32
+ tertiary: [ElementName.ReactCount, ElementName.CommentCount, ElementName.ViewCount]
137
33
  };
138
34
  case 'jira-object-provider':
139
- const isJiraTask = (_data$Type$includes = (_data$Type = data['@type']) === null || _data$Type === void 0 ? void 0 : _data$Type.includes('atlassian:Task')) !== null && _data$Type$includes !== void 0 ? _data$Type$includes : false;
35
+ const isJiraTask = (_data$Type$includes = data === null || data === void 0 ? void 0 : (_data$Type = data['@type']) === null || _data$Type === void 0 ? void 0 : _data$Type.includes('atlassian:Task')) !== null && _data$Type$includes !== void 0 ? _data$Type$includes : false;
140
36
  return {
141
37
  ...defaultMetadata,
142
38
  ...(isJiraTask && {
143
- topMetadataBlock: {
144
- primary: [ElementName.AssignedToGroup, ElementName.State, ElementName.StoryPoints, ElementName.Priority],
145
- secondary: [],
146
- subtitle: []
147
- }
39
+ primary: [ElementName.AssignedToGroup, ElementName.State, ElementName.StoryPoints, ElementName.Priority]
148
40
  })
149
41
  };
150
42
  case 'trello-object-provider':
151
43
  return {
152
- ...defaultMetadata,
153
- topMetadataBlock: {
154
- primary: [ElementName.AuthorGroup, ElementName.State, ElementName.DueOn],
155
- secondary: [ElementName.ReactCount, ElementName.CommentCount, ElementName.AttachmentCount, ElementName.ChecklistProgress],
156
- subtitle: [ElementName.Location]
157
- }
44
+ primary: [ElementName.AuthorGroup, ElementName.State, ElementName.DueOn],
45
+ secondary: [ElementName.ReactCount, ElementName.CommentCount, ElementName.AttachmentCount, ElementName.ChecklistProgress],
46
+ subtitle: [ElementName.Location]
158
47
  };
159
48
  case 'watermelon-object-provider':
160
49
  if (types !== null && types !== void 0 && types.includes('atlassian:Project')) {
161
50
  return {
162
- ...defaultMetadata,
163
- topMetadataBlock: {
164
- primary: [ElementName.AuthorGroup, ElementName.ModifiedOn, ElementName.State, ElementName.DueOn],
165
- secondary: [],
166
- subtitle: []
167
- }
51
+ primary: [ElementName.AuthorGroup, ElementName.ModifiedOn, ElementName.State, ElementName.DueOn]
168
52
  };
169
53
  }
170
54
  return {
171
- ...defaultMetadata,
172
- topMetadataBlock: {
173
- primary: [ElementName.AuthorGroup, ElementName.State, ElementName.DueOn],
174
- secondary: [],
175
- subtitle: []
176
- }
55
+ primary: [ElementName.AuthorGroup, ElementName.State, ElementName.DueOn]
177
56
  };
178
57
  case 'slack-object-provider':
179
58
  return {
180
- topMetadataBlock: {
181
- primary: [ElementName.AuthorGroup, ElementName.SentOn],
182
- secondary: [],
183
- subtitle: []
184
- },
185
- bottomMetadataBlock: {
186
- primary: [ElementName.ReactCount, ElementName.CommentCount],
187
- secondary: [],
188
- subtitle: []
189
- }
59
+ primary: [ElementName.AuthorGroup, ElementName.SentOn],
60
+ tertiary: [ElementName.ReactCount, ElementName.CommentCount]
190
61
  };
191
62
  case 'google-object-provider':
192
63
  case 'figma-object-provider':
193
64
  return {
194
- ...defaultMetadata,
195
- topMetadataBlock: {
196
- primary: [ElementName.AuthorGroup, ElementName.ModifiedOn],
197
- secondary: [],
198
- subtitle: []
199
- }
65
+ primary: [ElementName.AuthorGroup, ElementName.ModifiedOn]
200
66
  };
201
67
  default:
202
68
  return defaultMetadata;
203
69
  }
70
+ };
71
+ const AvatarGroupsWithNamePrefix = [ElementName.AssignedToGroup, ElementName.OwnedByGroup, ElementName.AuthorGroup];
72
+ const toElementItem = name => {
73
+ const showNamePrefix = AvatarGroupsWithNamePrefix.indexOf(name) !== -1 ? true : undefined;
74
+ const testId = `${name.toLowerCase()}-metadata-element`;
75
+ return {
76
+ name,
77
+ showNamePrefix,
78
+ testId
79
+ };
80
+ };
81
+ const toElementItems = elementNames => {
82
+ if (!(elementNames !== null && elementNames !== void 0 && elementNames.length)) {
83
+ return;
84
+ }
85
+ return elementNames.filter(name => name in ElementName).map(toElementItem);
86
+ };
87
+ export const getMetadata = (extensionKey, data) => {
88
+ const metadata = getSimulatedBetterMetadata(extensionKey, data);
89
+ return {
90
+ subtitle: toElementItems(metadata.subtitle),
91
+ primary: toElementItems(metadata.primary),
92
+ secondary: toElementItems(metadata.secondary),
93
+ tertiary: toElementItems(metadata.tertiary)
94
+ };
204
95
  };
@@ -7,7 +7,7 @@ import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-m
7
7
  import LinkWarningModal from './LinkWarningModal';
8
8
  const PACKAGE_DATA = {
9
9
  packageName: "@atlaskit/smart-card",
10
- packageVersion: "26.57.1",
10
+ packageVersion: "26.57.2",
11
11
  componentName: 'linkUrl'
12
12
  };
13
13
  const Link = withLinkClickedEvent('a');
@@ -15,7 +15,7 @@ export var ANALYTICS_CHANNEL = 'media';
15
15
  export var context = {
16
16
  componentName: 'smart-cards',
17
17
  packageName: "@atlaskit/smart-card",
18
- packageVersion: "26.57.1"
18
+ packageVersion: "26.57.2"
19
19
  };
20
20
  export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
21
21
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -8,12 +8,11 @@ import CopyIcon from '@atlaskit/icon/glyph/copy';
8
8
  import React, { useCallback, useEffect, useMemo, useRef } from 'react';
9
9
  import { useSmartLinkContext } from '@atlaskit/link-provider';
10
10
  import { ActionName, CardDisplay, SmartLinkPosition, SmartLinkSize } from '../../../constants';
11
- import { extractMetadata } from '../../../extractors/hover/extractMetadata';
12
11
  import { useSmartLinkAnalytics } from '../../../state/analytics';
13
12
  import { getExtensionKey, getServices } from '../../../state/helpers';
14
13
  import { isSpecialEvent } from '../../../utils';
15
14
  import { flexibleUiOptions, titleBlockCss } from '../styled';
16
- import { getSimulatedMetadata } from '../utils';
15
+ import { getMetadata } from '../utils';
17
16
  import HoverCardLoadingView from './views/resolving';
18
17
  import HoverCardUnauthorisedView from './views/unauthorised';
19
18
  import HoverCardResolvedView from './views/resolved';
@@ -133,8 +132,8 @@ var HoverCardContent = function HoverCardContent(_ref) {
133
132
  return [getCopyAction(url)];
134
133
  }, [url]);
135
134
  var data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
136
- var _extractMetadata = extractMetadata(getSimulatedMetadata(extensionKey, data)),
137
- subtitle = _extractMetadata.subtitle;
135
+ var _getMetadata = getMetadata(extensionKey, data),
136
+ subtitle = _getMetadata.subtitle;
138
137
  var titleMaxLines = subtitle && subtitle.length > 0 ? 1 : 2;
139
138
  var titleBlockProps = {
140
139
  actions: getBooleanFF('platform.linking-platform.smart-card.hover-card-action-redesign') ? undefined : titleActions,
@@ -5,9 +5,8 @@ import { ActionName, CardDisplay, ElementName, SmartLinkPosition, SmartLinkSize,
5
5
  import { FooterBlock, MetadataBlock, RelatedUrlsBlock, SnippetBlock, TitleBlock, AISummaryBlock, CustomBlock, ActionBlock } from '../../../../FlexibleCard/components/blocks';
6
6
  import { footerBlockCss, hiddenSnippetStyles, metadataBlockCss } from './styled';
7
7
  import FlexibleCard from '../../../../FlexibleCard';
8
- import { getSimulatedBetterMetadata } from '../../../utils';
8
+ import { getMetadata } from '../../../utils';
9
9
  import ImagePreview from '../../ImagePreview';
10
- import { elementNamesToItems } from '../../../../../extractors/hover/extractMetadata';
11
10
  import { messages } from '../../../../../messages';
12
11
  import { FormattedMessage } from 'react-intl-next';
13
12
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
@@ -110,16 +109,11 @@ var HoverCardResolvedView = function HoverCardResolvedView(_ref2) {
110
109
  }, [cardActions, onActionClick]);
111
110
  var data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
112
111
  var _useMemo = useMemo(function () {
113
- var betterMetadata = getSimulatedBetterMetadata(extensionKey, data);
114
- return {
115
- topPrimary: elementNamesToItems(betterMetadata.topMetadataBlock.primary),
116
- topSecondary: elementNamesToItems(betterMetadata.topMetadataBlock.secondary),
117
- bottomPrimary: elementNamesToItems(betterMetadata.bottomMetadataBlock.primary)
118
- };
112
+ return getMetadata(extensionKey, data);
119
113
  }, [data, extensionKey]),
120
- topPrimary = _useMemo.topPrimary,
121
- topSecondary = _useMemo.topSecondary,
122
- bottomPrimary = _useMemo.bottomPrimary;
114
+ primary = _useMemo.primary,
115
+ secondary = _useMemo.secondary,
116
+ tertiary = _useMemo.tertiary;
123
117
  var snippetHeight = React.useRef(0);
124
118
  var snippetBlockRef = useRef(null);
125
119
  var onSnippetRender = useCallback(function () {
@@ -143,8 +137,8 @@ var HoverCardResolvedView = function HoverCardResolvedView(_ref2) {
143
137
  return /*#__PURE__*/React.createElement(FlexibleCard, flexibleCardProps, imagePreview, /*#__PURE__*/React.createElement(TitleBlock, _extends({}, titleBlockProps, {
144
138
  metadataPosition: SmartLinkPosition.Top
145
139
  })), /*#__PURE__*/React.createElement(MetadataBlock, {
146
- primary: topPrimary,
147
- secondary: topSecondary,
140
+ primary: primary,
141
+ secondary: secondary,
148
142
  overrideCss: metadataBlockCss,
149
143
  maxLines: 1,
150
144
  size: SmartLinkSize.Medium
@@ -158,7 +152,7 @@ var HoverCardResolvedView = function HoverCardResolvedView(_ref2) {
158
152
  blockRef: connectedAIBlockRef
159
153
  }, /*#__PURE__*/React.createElement(ConnectedAIBlock, {
160
154
  imagePreview: !!imagePreview,
161
- bottomPrimary: bottomPrimary,
155
+ bottomPrimary: tertiary,
162
156
  data: data
163
157
  })), !isAISummaryEnabled && !imagePreview && /*#__PURE__*/React.createElement(SnippetBlock, {
164
158
  status: SmartLinkStatus.Resolved
@@ -168,7 +162,7 @@ var HoverCardResolvedView = function HoverCardResolvedView(_ref2) {
168
162
  blockRef: snippetBlockRef,
169
163
  overrideCss: hiddenSnippetStyles
170
164
  }), !isAISummaryEnabled && /*#__PURE__*/React.createElement(MetadataBlock, {
171
- primary: bottomPrimary,
165
+ primary: tertiary,
172
166
  size: SmartLinkSize.Large,
173
167
  overrideCss: metadataBlockCss,
174
168
  maxLines: 1,
@@ -5,197 +5,93 @@ import { ElementName } from '../../constants';
5
5
  import { extractType } from '@atlaskit/link-extractors';
6
6
  import { extractOwnedBy } from '../../extractors/flexible/utils';
7
7
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
8
- export var getSimulatedMetadata = function getSimulatedMetadata() {
9
- var extensionKey = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
10
- var data = arguments.length > 1 ? arguments[1] : undefined;
8
+ var getSimulatedBetterMetadata = function getSimulatedBetterMetadata(extensionKey, data) {
9
+ var _data$Type$includes, _data$Type;
11
10
  var types = data ? extractType(data) : undefined;
11
+ var defaultMetadata = {
12
+ primary: [ElementName.AuthorGroup, ElementName.ModifiedOn]
13
+ };
12
14
  switch (extensionKey) {
13
15
  case 'bitbucket-object-provider':
14
16
  case 'native-bitbucket-object-provider':
15
17
  if (types !== null && types !== void 0 && types.includes('atlassian:SourceCodePullRequest')) {
16
18
  return {
17
- metadata: {
18
- primary: [ElementName.AuthorGroup, ElementName.ModifiedOn, ElementName.SubscriberCount, ElementName.State],
19
- secondary: [],
20
- subtitle: [ElementName.SourceBranch, ElementName.TargetBranch]
21
- }
19
+ primary: [ElementName.AuthorGroup, ElementName.ModifiedOn, ElementName.SubscriberCount, ElementName.State],
20
+ subtitle: [ElementName.SourceBranch, ElementName.TargetBranch]
22
21
  };
23
22
  }
24
- return {
25
- metadata: {
26
- primary: [ElementName.ModifiedOn, ElementName.CreatedBy],
27
- secondary: [],
28
- subtitle: []
29
- }
30
- };
31
- case 'confluence-object-provider':
32
- var primaryAttribution = data && extractOwnedBy(data) ? ElementName.OwnedBy : ElementName.CreatedBy;
33
- return {
34
- metadata: {
35
- primary: [ElementName.AuthorGroup, primaryAttribution],
36
- secondary: [ElementName.ReactCount, ElementName.CommentCount, ElementName.ViewCount],
37
- subtitle: []
38
- }
39
- };
40
- case 'jira-object-provider':
41
- return {
42
- metadata: {
43
- primary: [ElementName.AuthorGroup, ElementName.State, ElementName.Priority],
44
- secondary: [],
45
- subtitle: []
46
- }
47
- };
48
- case 'trello-object-provider':
49
- return {
50
- metadata: {
51
- primary: [ElementName.AuthorGroup, ElementName.State, ElementName.DueOn],
52
- secondary: [ElementName.ReactCount, ElementName.CommentCount, ElementName.AttachmentCount, ElementName.ChecklistProgress],
53
- subtitle: [ElementName.Location]
54
- }
55
- };
56
- case 'watermelon-object-provider':
57
- if (types !== null && types !== void 0 && types.includes('atlassian:Project')) {
23
+ if (getBooleanFF('platform.linking-platform.extractor.improve-bitbucket-file-links') && types !== null && types !== void 0 && types.includes('schema:DigitalDocument')) {
58
24
  return {
59
- metadata: {
60
- primary: [ElementName.AuthorGroup, ElementName.ModifiedOn, ElementName.State, ElementName.DueOn],
61
- secondary: [],
62
- subtitle: []
63
- }
25
+ primary: [ElementName.LatestCommit, ElementName.CollaboratorGroup, ElementName.ModifiedOn]
64
26
  };
65
27
  }
66
28
  return {
67
- metadata: {
68
- primary: [ElementName.AuthorGroup, ElementName.State, ElementName.DueOn],
69
- secondary: [],
70
- subtitle: []
71
- }
72
- };
73
- default:
74
- return {
75
- metadata: {
76
- primary: [ElementName.ModifiedOn, ElementName.CreatedBy],
77
- secondary: [],
78
- subtitle: []
79
- }
29
+ primary: [ElementName.AuthorGroup, ElementName.ModifiedOn]
80
30
  };
81
- }
82
- };
83
- export var getSimulatedBetterMetadata = function getSimulatedBetterMetadata() {
84
- var _data$Type$includes, _data$Type;
85
- var extensionKey = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
86
- var data = arguments.length > 1 ? arguments[1] : undefined;
87
- var types = data ? extractType(data) : undefined;
88
- var defaultMetadata = {
89
- topMetadataBlock: {
90
- primary: [ElementName.AuthorGroup, ElementName.ModifiedOn],
91
- secondary: [],
92
- subtitle: []
93
- },
94
- bottomMetadataBlock: {
95
- primary: [],
96
- secondary: [],
97
- subtitle: []
98
- }
99
- };
100
- switch (extensionKey) {
101
- case 'bitbucket-object-provider':
102
- case 'native-bitbucket-object-provider':
103
- if (types !== null && types !== void 0 && types.includes('atlassian:SourceCodePullRequest')) {
104
- return _objectSpread(_objectSpread({}, defaultMetadata), {}, {
105
- topMetadataBlock: {
106
- primary: [ElementName.AuthorGroup, ElementName.ModifiedOn, ElementName.SubscriberCount, ElementName.State],
107
- secondary: [],
108
- subtitle: [ElementName.SourceBranch, ElementName.TargetBranch]
109
- }
110
- });
111
- }
112
- if (getBooleanFF('platform.linking-platform.extractor.improve-bitbucket-file-links') && types !== null && types !== void 0 && types.includes('schema:DigitalDocument')) {
113
- return _objectSpread(_objectSpread({}, defaultMetadata), {}, {
114
- topMetadataBlock: {
115
- primary: [ElementName.LatestCommit, ElementName.CollaboratorGroup, ElementName.ModifiedOn],
116
- secondary: [],
117
- subtitle: []
118
- }
119
- });
120
- }
121
- return _objectSpread(_objectSpread({}, defaultMetadata), {}, {
122
- topMetadataBlock: {
123
- primary: [ElementName.AuthorGroup, ElementName.ModifiedOn],
124
- secondary: [],
125
- subtitle: []
126
- }
127
- });
128
31
  case 'confluence-object-provider':
129
32
  var primaryAttribution = data && extractOwnedBy(data) ? ElementName.OwnedByGroup : ElementName.AuthorGroup;
130
33
  return {
131
- topMetadataBlock: {
132
- primary: [primaryAttribution, ElementName.ModifiedOn],
133
- secondary: [],
134
- subtitle: []
135
- },
136
- bottomMetadataBlock: {
137
- primary: [ElementName.ReactCount, ElementName.CommentCount, ElementName.ViewCount],
138
- secondary: [],
139
- subtitle: []
140
- }
34
+ primary: [primaryAttribution, ElementName.ModifiedOn],
35
+ tertiary: [ElementName.ReactCount, ElementName.CommentCount, ElementName.ViewCount]
141
36
  };
142
37
  case 'jira-object-provider':
143
- var isJiraTask = (_data$Type$includes = (_data$Type = data['@type']) === null || _data$Type === void 0 ? void 0 : _data$Type.includes('atlassian:Task')) !== null && _data$Type$includes !== void 0 ? _data$Type$includes : false;
38
+ var isJiraTask = (_data$Type$includes = data === null || data === void 0 || (_data$Type = data['@type']) === null || _data$Type === void 0 ? void 0 : _data$Type.includes('atlassian:Task')) !== null && _data$Type$includes !== void 0 ? _data$Type$includes : false;
144
39
  return _objectSpread(_objectSpread({}, defaultMetadata), isJiraTask && {
145
- topMetadataBlock: {
146
- primary: [ElementName.AssignedToGroup, ElementName.State, ElementName.StoryPoints, ElementName.Priority],
147
- secondary: [],
148
- subtitle: []
149
- }
40
+ primary: [ElementName.AssignedToGroup, ElementName.State, ElementName.StoryPoints, ElementName.Priority]
150
41
  });
151
42
  case 'trello-object-provider':
152
- return _objectSpread(_objectSpread({}, defaultMetadata), {}, {
153
- topMetadataBlock: {
154
- primary: [ElementName.AuthorGroup, ElementName.State, ElementName.DueOn],
155
- secondary: [ElementName.ReactCount, ElementName.CommentCount, ElementName.AttachmentCount, ElementName.ChecklistProgress],
156
- subtitle: [ElementName.Location]
157
- }
158
- });
43
+ return {
44
+ primary: [ElementName.AuthorGroup, ElementName.State, ElementName.DueOn],
45
+ secondary: [ElementName.ReactCount, ElementName.CommentCount, ElementName.AttachmentCount, ElementName.ChecklistProgress],
46
+ subtitle: [ElementName.Location]
47
+ };
159
48
  case 'watermelon-object-provider':
160
49
  if (types !== null && types !== void 0 && types.includes('atlassian:Project')) {
161
- return _objectSpread(_objectSpread({}, defaultMetadata), {}, {
162
- topMetadataBlock: {
163
- primary: [ElementName.AuthorGroup, ElementName.ModifiedOn, ElementName.State, ElementName.DueOn],
164
- secondary: [],
165
- subtitle: []
166
- }
167
- });
50
+ return {
51
+ primary: [ElementName.AuthorGroup, ElementName.ModifiedOn, ElementName.State, ElementName.DueOn]
52
+ };
168
53
  }
169
- return _objectSpread(_objectSpread({}, defaultMetadata), {}, {
170
- topMetadataBlock: {
171
- primary: [ElementName.AuthorGroup, ElementName.State, ElementName.DueOn],
172
- secondary: [],
173
- subtitle: []
174
- }
175
- });
54
+ return {
55
+ primary: [ElementName.AuthorGroup, ElementName.State, ElementName.DueOn]
56
+ };
176
57
  case 'slack-object-provider':
177
58
  return {
178
- topMetadataBlock: {
179
- primary: [ElementName.AuthorGroup, ElementName.SentOn],
180
- secondary: [],
181
- subtitle: []
182
- },
183
- bottomMetadataBlock: {
184
- primary: [ElementName.ReactCount, ElementName.CommentCount],
185
- secondary: [],
186
- subtitle: []
187
- }
59
+ primary: [ElementName.AuthorGroup, ElementName.SentOn],
60
+ tertiary: [ElementName.ReactCount, ElementName.CommentCount]
188
61
  };
189
62
  case 'google-object-provider':
190
63
  case 'figma-object-provider':
191
- return _objectSpread(_objectSpread({}, defaultMetadata), {}, {
192
- topMetadataBlock: {
193
- primary: [ElementName.AuthorGroup, ElementName.ModifiedOn],
194
- secondary: [],
195
- subtitle: []
196
- }
197
- });
64
+ return {
65
+ primary: [ElementName.AuthorGroup, ElementName.ModifiedOn]
66
+ };
198
67
  default:
199
68
  return defaultMetadata;
200
69
  }
70
+ };
71
+ var AvatarGroupsWithNamePrefix = [ElementName.AssignedToGroup, ElementName.OwnedByGroup, ElementName.AuthorGroup];
72
+ var toElementItem = function toElementItem(name) {
73
+ var showNamePrefix = AvatarGroupsWithNamePrefix.indexOf(name) !== -1 ? true : undefined;
74
+ var testId = "".concat(name.toLowerCase(), "-metadata-element");
75
+ return {
76
+ name: name,
77
+ showNamePrefix: showNamePrefix,
78
+ testId: testId
79
+ };
80
+ };
81
+ var toElementItems = function toElementItems(elementNames) {
82
+ if (!(elementNames !== null && elementNames !== void 0 && elementNames.length)) {
83
+ return;
84
+ }
85
+ return elementNames.filter(function (name) {
86
+ return name in ElementName;
87
+ }).map(toElementItem);
88
+ };
89
+ export var getMetadata = function getMetadata(extensionKey, data) {
90
+ var metadata = getSimulatedBetterMetadata(extensionKey, data);
91
+ return {
92
+ subtitle: toElementItems(metadata.subtitle),
93
+ primary: toElementItems(metadata.primary),
94
+ secondary: toElementItems(metadata.secondary),
95
+ tertiary: toElementItems(metadata.tertiary)
96
+ };
201
97
  };
@@ -10,7 +10,7 @@ import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-m
10
10
  import LinkWarningModal from './LinkWarningModal';
11
11
  var PACKAGE_DATA = {
12
12
  packageName: "@atlaskit/smart-card",
13
- packageVersion: "26.57.1",
13
+ packageVersion: "26.57.2",
14
14
  componentName: 'linkUrl'
15
15
  };
16
16
  var Link = withLinkClickedEvent('a');
@@ -1,5 +1,4 @@
1
1
  import { WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
2
- import { ElementItem } from '../FlexibleCard/components/blocks/types';
3
2
  import { AnalyticsFacade } from '../../state/analytics';
4
3
  import { LinkAction } from '../../state/hooks-external/useSmartLinkActions';
5
4
  import { CardState } from '@atlaskit/linking-common';
@@ -82,11 +81,6 @@ export interface HoverCardComponentProps extends HoverCardProps, HoverCardIntern
82
81
  }
83
82
  export type PreviewDisplay = 'card' | 'embed';
84
83
  export type PreviewInvokeMethod = 'keyboard' | 'mouse_hover' | 'mouse_click';
85
- export interface MetadataOptions {
86
- primary: Array<ElementItem>;
87
- secondary: Array<ElementItem>;
88
- subtitle: Array<ElementItem>;
89
- }
90
84
  export type HoverCardContentProps = {
91
85
  id?: string;
92
86
  analytics?: AnalyticsFacade;
@@ -1,3 +1,8 @@
1
1
  import type { JsonLd } from 'json-ld-types';
2
- export declare const getSimulatedMetadata: (extensionKey: string | undefined, data: JsonLd.Data.BaseData) => JsonLd.Primitives.Property<any>;
3
- export declare const getSimulatedBetterMetadata: (extensionKey: string | undefined, data: JsonLd.Data.BaseData) => JsonLd.Primitives.Property<any>;
2
+ import type { ElementItem } from '../FlexibleCard/components/blocks/types';
3
+ export declare const getMetadata: (extensionKey?: string, data?: JsonLd.Data.BaseData) => {
4
+ subtitle: ElementItem[] | undefined;
5
+ primary: ElementItem[] | undefined;
6
+ secondary: ElementItem[] | undefined;
7
+ tertiary: ElementItem[] | undefined;
8
+ };
@@ -1,5 +1,4 @@
1
1
  import { WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
2
- import { ElementItem } from '../FlexibleCard/components/blocks/types';
3
2
  import { AnalyticsFacade } from '../../state/analytics';
4
3
  import { LinkAction } from '../../state/hooks-external/useSmartLinkActions';
5
4
  import { CardState } from '@atlaskit/linking-common';
@@ -82,11 +81,6 @@ export interface HoverCardComponentProps extends HoverCardProps, HoverCardIntern
82
81
  }
83
82
  export type PreviewDisplay = 'card' | 'embed';
84
83
  export type PreviewInvokeMethod = 'keyboard' | 'mouse_hover' | 'mouse_click';
85
- export interface MetadataOptions {
86
- primary: Array<ElementItem>;
87
- secondary: Array<ElementItem>;
88
- subtitle: Array<ElementItem>;
89
- }
90
84
  export type HoverCardContentProps = {
91
85
  id?: string;
92
86
  analytics?: AnalyticsFacade;
@@ -1,3 +1,8 @@
1
1
  import type { JsonLd } from 'json-ld-types';
2
- export declare const getSimulatedMetadata: (extensionKey: string | undefined, data: JsonLd.Data.BaseData) => JsonLd.Primitives.Property<any>;
3
- export declare const getSimulatedBetterMetadata: (extensionKey: string | undefined, data: JsonLd.Data.BaseData) => JsonLd.Primitives.Property<any>;
2
+ import type { ElementItem } from '../FlexibleCard/components/blocks/types';
3
+ export declare const getMetadata: (extensionKey?: string, data?: JsonLd.Data.BaseData) => {
4
+ subtitle: ElementItem[] | undefined;
5
+ primary: ElementItem[] | undefined;
6
+ secondary: ElementItem[] | undefined;
7
+ tertiary: ElementItem[] | undefined;
8
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "26.57.1",
3
+ "version": "26.57.2",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -33,7 +33,7 @@
33
33
  "@atlaskit/avatar": "^21.5.0",
34
34
  "@atlaskit/avatar-group": "^9.5.0",
35
35
  "@atlaskit/badge": "^16.0.0",
36
- "@atlaskit/button": "^17.12.0",
36
+ "@atlaskit/button": "^17.13.0",
37
37
  "@atlaskit/dropdown-menu": "^12.9.0",
38
38
  "@atlaskit/frontend-utilities": "^2.7.0",
39
39
  "@atlaskit/icon": "^22.1.0",
@@ -1,33 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.extractMetadata = exports.elementNamesToItems = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _constants = require("../../constants");
10
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
11
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
12
- var AvatarGroupsWithNamePrefix = [_constants.ElementName.AssignedToGroup, _constants.ElementName.OwnedByGroup, _constants.ElementName.AuthorGroup];
13
- var elementNamesToItems = exports.elementNamesToItems = function elementNamesToItems(elementNames) {
14
- return elementNames.filter(function (element) {
15
- return element in _constants.ElementName;
16
- }).map(function (elementName) {
17
- return _objectSpread({
18
- name: elementName,
19
- testId: "".concat(elementName.toLowerCase(), "-metadata-element")
20
- }, AvatarGroupsWithNamePrefix.includes(elementName) && {
21
- showNamePrefix: true
22
- });
23
- });
24
- };
25
- var extractMetadata = exports.extractMetadata = function extractMetadata(jsonLd) {
26
- var _jsonLd$metadata, _metadata$primary, _metadata$secondary, _metadata$subtitle;
27
- var metadata = (_jsonLd$metadata = jsonLd.metadata) !== null && _jsonLd$metadata !== void 0 ? _jsonLd$metadata : [];
28
- return {
29
- primary: elementNamesToItems((_metadata$primary = metadata.primary) !== null && _metadata$primary !== void 0 ? _metadata$primary : []),
30
- secondary: elementNamesToItems((_metadata$secondary = metadata.secondary) !== null && _metadata$secondary !== void 0 ? _metadata$secondary : []),
31
- subtitle: elementNamesToItems((_metadata$subtitle = metadata.subtitle) !== null && _metadata$subtitle !== void 0 ? _metadata$subtitle : [])
32
- };
33
- };
@@ -1,20 +0,0 @@
1
- import { ElementName } from '../../constants';
2
- const AvatarGroupsWithNamePrefix = [ElementName.AssignedToGroup, ElementName.OwnedByGroup, ElementName.AuthorGroup];
3
- export const elementNamesToItems = elementNames => {
4
- return elementNames.filter(element => element in ElementName).map(elementName => ({
5
- name: elementName,
6
- testId: `${elementName.toLowerCase()}-metadata-element`,
7
- ...(AvatarGroupsWithNamePrefix.includes(elementName) && {
8
- showNamePrefix: true
9
- })
10
- }));
11
- };
12
- export const extractMetadata = jsonLd => {
13
- var _jsonLd$metadata, _metadata$primary, _metadata$secondary, _metadata$subtitle;
14
- const metadata = (_jsonLd$metadata = jsonLd.metadata) !== null && _jsonLd$metadata !== void 0 ? _jsonLd$metadata : [];
15
- return {
16
- primary: elementNamesToItems((_metadata$primary = metadata.primary) !== null && _metadata$primary !== void 0 ? _metadata$primary : []),
17
- secondary: elementNamesToItems((_metadata$secondary = metadata.secondary) !== null && _metadata$secondary !== void 0 ? _metadata$secondary : []),
18
- subtitle: elementNamesToItems((_metadata$subtitle = metadata.subtitle) !== null && _metadata$subtitle !== void 0 ? _metadata$subtitle : [])
19
- };
20
- };
@@ -1,26 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
- import { ElementName } from '../../constants';
5
- var AvatarGroupsWithNamePrefix = [ElementName.AssignedToGroup, ElementName.OwnedByGroup, ElementName.AuthorGroup];
6
- export var elementNamesToItems = function elementNamesToItems(elementNames) {
7
- return elementNames.filter(function (element) {
8
- return element in ElementName;
9
- }).map(function (elementName) {
10
- return _objectSpread({
11
- name: elementName,
12
- testId: "".concat(elementName.toLowerCase(), "-metadata-element")
13
- }, AvatarGroupsWithNamePrefix.includes(elementName) && {
14
- showNamePrefix: true
15
- });
16
- });
17
- };
18
- export var extractMetadata = function extractMetadata(jsonLd) {
19
- var _jsonLd$metadata, _metadata$primary, _metadata$secondary, _metadata$subtitle;
20
- var metadata = (_jsonLd$metadata = jsonLd.metadata) !== null && _jsonLd$metadata !== void 0 ? _jsonLd$metadata : [];
21
- return {
22
- primary: elementNamesToItems((_metadata$primary = metadata.primary) !== null && _metadata$primary !== void 0 ? _metadata$primary : []),
23
- secondary: elementNamesToItems((_metadata$secondary = metadata.secondary) !== null && _metadata$secondary !== void 0 ? _metadata$secondary : []),
24
- subtitle: elementNamesToItems((_metadata$subtitle = metadata.subtitle) !== null && _metadata$subtitle !== void 0 ? _metadata$subtitle : [])
25
- };
26
- };
@@ -1,5 +0,0 @@
1
- import { ElementItem } from '../../view/FlexibleCard/components/blocks/types';
2
- import { MetadataOptions } from '../../view/HoverCard/types';
3
- import { JsonLd } from 'json-ld-types';
4
- export declare const elementNamesToItems: (elementNames: string[]) => ElementItem[];
5
- export declare const extractMetadata: (jsonLd: JsonLd.Primitives.Property<any>) => MetadataOptions;
@@ -1,5 +0,0 @@
1
- import { ElementItem } from '../../view/FlexibleCard/components/blocks/types';
2
- import { MetadataOptions } from '../../view/HoverCard/types';
3
- import { JsonLd } from 'json-ld-types';
4
- export declare const elementNamesToItems: (elementNames: string[]) => ElementItem[];
5
- export declare const extractMetadata: (jsonLd: JsonLd.Primitives.Property<any>) => MetadataOptions;