@atlaskit/smart-card 40.2.0 → 40.3.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 40.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#186963](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/186963)
8
+ [`182e8c5b1a888`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/182e8c5b1a888) -
9
+ NAVX-1050 adding message and conversation entity types and using entity data to render slack links
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
3
15
  ## 40.2.0
4
16
 
5
17
  ### Minor Changes
@@ -60,9 +60,9 @@ var extractFlexibleUiContext = function extractFlexibleUiContext() {
60
60
  authorGroup: (0, _linkExtractors.extractSmartLinkAuthorGroup)(response),
61
61
  ownedByGroup: (0, _linkExtractors.extractPersonOwnedBy)(data),
62
62
  collaboratorGroup: (0, _collaboratorGroup.extractPersonsUpdatedBy)(data),
63
- commentCount: (0, _utils.extractCommentCount)(data),
63
+ commentCount: (0, _utils.extractSmartLinkCommentCount)(response),
64
64
  viewCount: (0, _utils.extractViewCount)(data),
65
- reactCount: (0, _utils.extractReactCount)(data),
65
+ reactCount: (0, _utils.extractSmartLinkReactCount)(response),
66
66
  voteCount: (0, _utils.extractVoteCount)(data),
67
67
  checklistProgress: (0, _utils.extractChecklistProgress)(data),
68
68
  createdBy: (0, _linkExtractors.extractSmartLinkCreatedBy)(response),
@@ -81,7 +81,7 @@ var extractFlexibleUiContext = function extractFlexibleUiContext() {
81
81
  provider: (0, _extractProviderIcon.extractSmartLinkProviderIcon)(response),
82
82
  programmingLanguage: (0, _utils.extractProgrammingLanguage)(data),
83
83
  readTime: (0, _utils.extractReadTime)(data),
84
- sentOn: (0, _utils.extractSentOn)(data),
84
+ sentOn: (0, _utils.extractSmartLinkSentOn)(response),
85
85
  snippet: (0, _extractSummary.extractSmartLinkSummary)(response) || undefined,
86
86
  // Explicitly set here to remove an empty string
87
87
  sourceBranch: (0, _utils.extractSourceBranch)(data),
@@ -4,9 +4,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.extractVoteCount = exports.extractViewCount = exports.extractUserAttributes = exports.extractTeamMemberCount = exports.extractTargetBranch = exports.extractSubscriberCount = exports.extractSubTasksProgress = exports.extractStoryPoints = exports.extractSourceBranch = exports.extractSentOn = exports.extractReadTime = exports.extractReactCount = exports.extractProgrammingLanguage = exports.extractPersonAssignedToAsArray = exports.extractOwnedBy = exports.extractModifiedBy = exports.extractMetaTenantId = exports.extractMetaResourceType = exports.extractMetaObjectId = exports.extractLocation = exports.extractDueOn = exports.extractCreatedBy = exports.extractCommentCount = exports.extractChecklistProgress = exports.extractAttachmentCount = exports.extractAssignedTo = exports.extractAppliedToComponentsCount = void 0;
7
+ exports.extractVoteCount = exports.extractViewCount = exports.extractUserAttributes = exports.extractTeamMemberCount = exports.extractTargetBranch = exports.extractSubscriberCount = exports.extractSubTasksProgress = exports.extractStoryPoints = exports.extractSourceBranch = exports.extractSmartLinkSentOn = exports.extractSmartLinkReactCount = exports.extractSmartLinkCommentCount = exports.extractSentOn = exports.extractReadTime = exports.extractReactCount = exports.extractProgrammingLanguage = exports.extractPersonAssignedToAsArray = exports.extractOwnedBy = exports.extractModifiedBy = exports.extractMetaTenantId = exports.extractMetaResourceType = exports.extractMetaObjectId = exports.extractLocation = exports.extractDueOn = exports.extractCreatedBy = exports.extractCommentCount = exports.extractChecklistProgress = exports.extractAttachmentCount = exports.extractAssignedTo = exports.extractAppliedToComponentsCount = void 0;
8
8
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
9
9
  var _linkExtractors = require("@atlaskit/link-extractors");
10
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
11
  var extractLinkName = function extractLinkName(link) {
11
12
  if (link && (0, _typeof2.default)(link) === 'object' && link['@type'] === 'Link') {
12
13
  return link.name;
@@ -18,6 +19,22 @@ var extractValue = function extractValue(data, key) {
18
19
  var extractCommentCount = exports.extractCommentCount = function extractCommentCount(data) {
19
20
  return extractValue(data, 'schema:commentCount');
20
21
  };
22
+
23
+ /**
24
+ * Should be moved to link-extractors when jsonLd is deprecated
25
+ */
26
+ var extractSmartLinkCommentCount = exports.extractSmartLinkCommentCount = function extractSmartLinkCommentCount(response) {
27
+ if (!response || !response.data) {
28
+ return undefined;
29
+ }
30
+ if ((0, _platformFeatureFlags.fg)('platform-linking-slack-entity-support')) {
31
+ if ((0, _linkExtractors.isEntityPresent)(response)) {
32
+ var entity = (0, _linkExtractors.extractEntity)(response);
33
+ return entity && 'commentCount' in entity && typeof entity.commentCount === 'number' ? entity === null || entity === void 0 ? void 0 : entity.commentCount : undefined;
34
+ }
35
+ }
36
+ return (response === null || response === void 0 ? void 0 : response.data) && extractCommentCount(response === null || response === void 0 ? void 0 : response.data);
37
+ };
21
38
  var extractAppliedToComponentsCount = exports.extractAppliedToComponentsCount = function extractAppliedToComponentsCount(data) {
22
39
  return extractValue(data, 'atlassian:appliedToComponentsCount');
23
40
  };
@@ -30,6 +47,25 @@ var extractViewCount = exports.extractViewCount = function extractViewCount(data
30
47
  var extractReactCount = exports.extractReactCount = function extractReactCount(data) {
31
48
  return extractValue(data, 'atlassian:reactCount');
32
49
  };
50
+
51
+ /**
52
+ * Should be moved to link-extractors when jsonLd is deprecated
53
+ */
54
+ var extractSmartLinkReactCount = exports.extractSmartLinkReactCount = function extractSmartLinkReactCount(response) {
55
+ if (!response || !response.data) {
56
+ return undefined;
57
+ }
58
+ if ((0, _platformFeatureFlags.fg)('platform-linking-slack-entity-support')) {
59
+ if ((0, _linkExtractors.isEntityPresent)(response)) {
60
+ var entity = (0, _linkExtractors.extractEntity)(response);
61
+ var reactions = entity && 'reactions' in entity && Array.isArray(entity.reactions) ? entity.reactions : undefined;
62
+ return reactions === null || reactions === void 0 ? void 0 : reactions.reduce(function (total, reaction) {
63
+ return total + (reaction === null || reaction === void 0 ? void 0 : reaction.total);
64
+ }, 0);
65
+ }
66
+ }
67
+ return (response === null || response === void 0 ? void 0 : response.data) && extractReactCount(response === null || response === void 0 ? void 0 : response.data);
68
+ };
33
69
  var extractVoteCount = exports.extractVoteCount = function extractVoteCount(data) {
34
70
  return extractValue(data, 'atlassian:voteCount');
35
71
  };
@@ -108,6 +144,22 @@ var extractReadTime = exports.extractReadTime = function extractReadTime(data) {
108
144
  var extractSentOn = exports.extractSentOn = function extractSentOn(data) {
109
145
  return extractValue(data, 'dateSent');
110
146
  };
147
+
148
+ /**
149
+ * Should be moved to link-extractors when jsonLd is deprecated
150
+ */
151
+ var extractSmartLinkSentOn = exports.extractSmartLinkSentOn = function extractSmartLinkSentOn(response) {
152
+ if (!response || !response.data) {
153
+ return undefined;
154
+ }
155
+ if ((0, _platformFeatureFlags.fg)('platform-linking-slack-entity-support')) {
156
+ if ((0, _linkExtractors.isEntityPresent)(response)) {
157
+ var _extractEntity;
158
+ return (_extractEntity = (0, _linkExtractors.extractEntity)(response)) === null || _extractEntity === void 0 ? void 0 : _extractEntity.createdAt;
159
+ }
160
+ }
161
+ return (response === null || response === void 0 ? void 0 : response.data) && extractSentOn(response === null || response === void 0 ? void 0 : response.data);
162
+ };
111
163
  var extractStoryPoints = exports.extractStoryPoints = function extractStoryPoints(data) {
112
164
  return extractValue(data, 'atlassian:storyPoints');
113
165
  };
package/dist/cjs/index.js CHANGED
@@ -459,6 +459,24 @@ Object.defineProperty(exports, "embedHeaderHeight", {
459
459
  return _styled.embedHeaderHeight;
460
460
  }
461
461
  });
462
+ Object.defineProperty(exports, "getObjectAri", {
463
+ enumerable: true,
464
+ get: function get() {
465
+ return _helpers.getObjectAri;
466
+ }
467
+ });
468
+ Object.defineProperty(exports, "getObjectIconUrl", {
469
+ enumerable: true,
470
+ get: function get() {
471
+ return _helpers.getObjectIconUrl;
472
+ }
473
+ });
474
+ Object.defineProperty(exports, "getObjectName", {
475
+ enumerable: true,
476
+ get: function get() {
477
+ return _helpers.getObjectName;
478
+ }
479
+ });
462
480
  Object.defineProperty(exports, "loadingPlaceholderClassName", {
463
481
  enumerable: true,
464
482
  get: function get() {
@@ -489,4 +507,5 @@ var _LazyFallback = require("./view/CardWithUrl/component-lazy/LazyFallback");
489
507
  var _constants = require("./constants");
490
508
  var _blocks = require("./view/FlexibleCard/components/blocks");
491
509
  var _external = require("./view/FlexibleCard/external");
510
+ var _helpers = require("./state/helpers");
492
511
  var _linkProvider = require("@atlaskit/link-provider");
@@ -11,7 +11,7 @@ var ANALYTICS_CHANNEL = exports.ANALYTICS_CHANNEL = 'media';
11
11
  var context = exports.context = {
12
12
  componentName: 'smart-cards',
13
13
  packageName: "@atlaskit/smart-card",
14
- packageVersion: "40.1.0"
14
+ packageVersion: "40.2.0"
15
15
  };
16
16
  var TrackQuickActionType = exports.TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
17
17
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", {
8
8
  exports.CardWithUrlContent = void 0;
9
9
  var _react = _interopRequireWildcard(require("react"));
10
10
  var _analyticsNext = require("@atlaskit/analytics-next");
11
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
12
  var _useAnalyticsEvents2 = require("../../common/analytics/generated/use-analytics-events");
12
13
  var _constants = require("../../constants");
13
14
  var _state = require("../../state");
@@ -93,7 +94,7 @@ function Component(_ref) {
93
94
  // delegate the click to the preview panel handler
94
95
  if (!isModifierKeyPressed && ari && name && openPreviewPanel && isPreviewPanelAvailable !== null && isPreviewPanelAvailable !== void 0 && isPreviewPanelAvailable({
95
96
  ari: ari
96
- })) {
97
+ }) && !(0, _platformFeatureFlags.fg)('platform_editor_preview_panel_linking')) {
97
98
  event.preventDefault();
98
99
  event.stopPropagation();
99
100
  openPreviewPanel({
@@ -20,7 +20,7 @@ var _excluded = ["href", "children", "checkSafety", "onClick", "testId", "isLink
20
20
  _excluded2 = ["isLinkSafe", "showSafetyWarningModal"];
21
21
  var PACKAGE_DATA = {
22
22
  packageName: "@atlaskit/smart-card",
23
- packageVersion: "40.1.0",
23
+ packageVersion: "40.2.0",
24
24
  componentName: 'linkUrl'
25
25
  };
26
26
  var Anchor = (0, _click.withLinkClickedEvent)('a');
@@ -10,7 +10,7 @@ import extractState from './extract-state';
10
10
  import { extractSmartLinkIcon } from './icon';
11
11
  import { extractSmartLinkProviderIcon } from './icon/extract-provider-icon';
12
12
  import { extractLatestCommit } from './latest-commit';
13
- import { extractAppliedToComponentsCount, extractAssignedTo, extractAttachmentCount, extractChecklistProgress, extractCommentCount, extractDueOn, extractLocation, extractMetaObjectId, extractMetaResourceType, extractMetaTenantId, extractOwnedBy, extractPersonAssignedToAsArray, extractProgrammingLanguage, extractReactCount, extractReadTime, extractSentOn, extractSourceBranch, extractStoryPoints, extractSubscriberCount, extractSubTasksProgress, extractTargetBranch, extractTeamMemberCount, extractUserAttributes, extractViewCount, extractVoteCount } from './utils';
13
+ import { extractAppliedToComponentsCount, extractAssignedTo, extractAttachmentCount, extractChecklistProgress, extractDueOn, extractLocation, extractMetaObjectId, extractMetaResourceType, extractMetaTenantId, extractOwnedBy, extractPersonAssignedToAsArray, extractProgrammingLanguage, extractReadTime, extractSmartLinkCommentCount, extractSmartLinkReactCount, extractSmartLinkSentOn, extractSourceBranch, extractStoryPoints, extractSubscriberCount, extractSubTasksProgress, extractTargetBranch, extractTeamMemberCount, extractUserAttributes, extractViewCount, extractVoteCount } from './utils';
14
14
  const extractFlexibleUiContext = ({
15
15
  appearance,
16
16
  fireEvent,
@@ -48,9 +48,9 @@ const extractFlexibleUiContext = ({
48
48
  authorGroup: extractSmartLinkAuthorGroup(response),
49
49
  ownedByGroup: extractPersonOwnedBy(data),
50
50
  collaboratorGroup: extractPersonsUpdatedBy(data),
51
- commentCount: extractCommentCount(data),
51
+ commentCount: extractSmartLinkCommentCount(response),
52
52
  viewCount: extractViewCount(data),
53
- reactCount: extractReactCount(data),
53
+ reactCount: extractSmartLinkReactCount(response),
54
54
  voteCount: extractVoteCount(data),
55
55
  checklistProgress: extractChecklistProgress(data),
56
56
  createdBy: extractSmartLinkCreatedBy(response),
@@ -69,7 +69,7 @@ const extractFlexibleUiContext = ({
69
69
  provider: extractSmartLinkProviderIcon(response),
70
70
  programmingLanguage: extractProgrammingLanguage(data),
71
71
  readTime: extractReadTime(data),
72
- sentOn: extractSentOn(data),
72
+ sentOn: extractSmartLinkSentOn(response),
73
73
  snippet: extractSmartLinkSummary(response) || undefined,
74
74
  // Explicitly set here to remove an empty string
75
75
  sourceBranch: extractSourceBranch(data),
@@ -1,4 +1,5 @@
1
- import { extractPersonAssignedTo, extractPersonCreatedBy, extractPersonOwnedBy, extractPersonUpdatedBy } from '@atlaskit/link-extractors';
1
+ import { extractEntity, extractPersonAssignedTo, extractPersonCreatedBy, extractPersonOwnedBy, extractPersonUpdatedBy, isEntityPresent } from '@atlaskit/link-extractors';
2
+ import { fg } from '@atlaskit/platform-feature-flags';
2
3
  const extractLinkName = link => {
3
4
  if (link && typeof link === 'object' && link['@type'] === 'Link') {
4
5
  return link.name;
@@ -8,10 +9,43 @@ const extractValue = (data, key) => {
8
9
  return data === null || data === void 0 ? void 0 : data[key];
9
10
  };
10
11
  export const extractCommentCount = data => extractValue(data, 'schema:commentCount');
12
+
13
+ /**
14
+ * Should be moved to link-extractors when jsonLd is deprecated
15
+ */
16
+ export const extractSmartLinkCommentCount = response => {
17
+ if (!response || !response.data) {
18
+ return undefined;
19
+ }
20
+ if (fg('platform-linking-slack-entity-support')) {
21
+ if (isEntityPresent(response)) {
22
+ const entity = extractEntity(response);
23
+ return entity && 'commentCount' in entity && typeof entity.commentCount === 'number' ? entity === null || entity === void 0 ? void 0 : entity.commentCount : undefined;
24
+ }
25
+ }
26
+ return (response === null || response === void 0 ? void 0 : response.data) && extractCommentCount(response === null || response === void 0 ? void 0 : response.data);
27
+ };
11
28
  export const extractAppliedToComponentsCount = data => extractValue(data, 'atlassian:appliedToComponentsCount');
12
29
  export const extractDueOn = data => extractValue(data, 'endTime');
13
30
  export const extractViewCount = data => extractValue(data, 'atlassian:viewCount');
14
31
  export const extractReactCount = data => extractValue(data, 'atlassian:reactCount');
32
+
33
+ /**
34
+ * Should be moved to link-extractors when jsonLd is deprecated
35
+ */
36
+ export const extractSmartLinkReactCount = response => {
37
+ if (!response || !response.data) {
38
+ return undefined;
39
+ }
40
+ if (fg('platform-linking-slack-entity-support')) {
41
+ if (isEntityPresent(response)) {
42
+ const entity = extractEntity(response);
43
+ const reactions = entity && 'reactions' in entity && Array.isArray(entity.reactions) ? entity.reactions : undefined;
44
+ return reactions === null || reactions === void 0 ? void 0 : reactions.reduce((total, reaction) => total + (reaction === null || reaction === void 0 ? void 0 : reaction.total), 0);
45
+ }
46
+ }
47
+ return (response === null || response === void 0 ? void 0 : response.data) && extractReactCount(response === null || response === void 0 ? void 0 : response.data);
48
+ };
15
49
  export const extractVoteCount = data => extractValue(data, 'atlassian:voteCount');
16
50
  export const extractOwnedBy = data => {
17
51
  const persons = extractPersonOwnedBy(data);
@@ -79,6 +113,22 @@ export const extractReadTime = data => {
79
113
  export const extractSentOn = data => {
80
114
  return extractValue(data, 'dateSent');
81
115
  };
116
+
117
+ /**
118
+ * Should be moved to link-extractors when jsonLd is deprecated
119
+ */
120
+ export const extractSmartLinkSentOn = response => {
121
+ if (!response || !response.data) {
122
+ return undefined;
123
+ }
124
+ if (fg('platform-linking-slack-entity-support')) {
125
+ if (isEntityPresent(response)) {
126
+ var _extractEntity;
127
+ return (_extractEntity = extractEntity(response)) === null || _extractEntity === void 0 ? void 0 : _extractEntity.createdAt;
128
+ }
129
+ }
130
+ return (response === null || response === void 0 ? void 0 : response.data) && extractSentOn(response === null || response === void 0 ? void 0 : response.data);
131
+ };
82
132
  export const extractStoryPoints = data => {
83
133
  return extractValue(data, 'atlassian:storyPoints');
84
134
  };
@@ -16,5 +16,6 @@ export { ActionName, ElementName, MediaPlacement, SmartLinkDirection, SmartLinkP
16
16
  export { MetadataBlock, PreviewBlock, SnippetBlock, TitleBlock, FooterBlock, CustomBlock } from './view/FlexibleCard/components/blocks';
17
17
  export { AssignedToElement, AssignedToGroupElement, AttachmentCountElement, AuthorGroupElement, ChecklistProgressElement, CollaboratorGroupElement, CommentCountElement, CreatedOnElement, CreatedByElement, DueOnElement, LatestCommitElement, LinkIconElement, LocationElement, ModifiedByElement, ModifiedOnElement, OwnedByElement, OwnedByGroupElement, PreviewElement, PriorityElement, ProgrammingLanguageElement, ProviderElement, ReactCountElement, ReadTimeElement, SentOnElement, SnippetElement, SourceBranchElement, StateElement, StoryPointsElement, SubscriberCountElement, SubTasksProgressElement, TargetBranchElement, TitleElement, ViewCountElement, VoteCountElement, CustomByAccessTypeElement, CustomByStatusElement } from './view/FlexibleCard/external';
18
18
  export { CopyLinkAction, CustomAction, DownloadAction, FollowAction, PreviewAction, UnresolvedAction, CustomUnresolvedAction } from './view/FlexibleCard/external';
19
+ export { getObjectAri, getObjectName, getObjectIconUrl } from './state/helpers';
19
20
  /** @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-661 Internal documentation for deprecation (no external access)} */
20
21
  export { editorCardProvider, EditorCardProvider } from '@atlaskit/link-provider';
@@ -2,7 +2,7 @@ export const ANALYTICS_CHANNEL = 'media';
2
2
  export const context = {
3
3
  componentName: 'smart-cards',
4
4
  packageName: "@atlaskit/smart-card",
5
- packageVersion: "40.1.0"
5
+ packageVersion: "40.2.0"
6
6
  };
7
7
  export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
8
8
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -1,5 +1,6 @@
1
1
  import React, { useCallback, useEffect, useMemo } from 'react';
2
2
  import { useAnalyticsEvents as useAnalyticsEventsNext } from '@atlaskit/analytics-next';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
3
4
  import { useAnalyticsEvents } from '../../common/analytics/generated/use-analytics-events';
4
5
  import { CardDisplay } from '../../constants';
5
6
  import { useSmartLink } from '../../state';
@@ -86,7 +87,7 @@ function Component({
86
87
  // delegate the click to the preview panel handler
87
88
  if (!isModifierKeyPressed && ari && name && openPreviewPanel && isPreviewPanelAvailable !== null && isPreviewPanelAvailable !== void 0 && isPreviewPanelAvailable({
88
89
  ari
89
- })) {
90
+ }) && !fg('platform_editor_preview_panel_linking')) {
90
91
  event.preventDefault();
91
92
  event.stopPropagation();
92
93
  openPreviewPanel({
@@ -10,7 +10,7 @@ import LinkWarningModal from './LinkWarningModal';
10
10
  import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
11
11
  const PACKAGE_DATA = {
12
12
  packageName: "@atlaskit/smart-card",
13
- packageVersion: "40.1.0",
13
+ packageVersion: "40.2.0",
14
14
  componentName: 'linkUrl'
15
15
  };
16
16
  const Anchor = withLinkClickedEvent('a');
@@ -15,7 +15,7 @@ import extractState from './extract-state';
15
15
  import { extractSmartLinkIcon } from './icon';
16
16
  import { extractSmartLinkProviderIcon } from './icon/extract-provider-icon';
17
17
  import { extractLatestCommit } from './latest-commit';
18
- import { extractAppliedToComponentsCount, extractAssignedTo, extractAttachmentCount, extractChecklistProgress, extractCommentCount, extractDueOn, extractLocation, extractMetaObjectId, extractMetaResourceType, extractMetaTenantId, extractOwnedBy, extractPersonAssignedToAsArray, extractProgrammingLanguage, extractReactCount, extractReadTime, extractSentOn, extractSourceBranch, extractStoryPoints, extractSubscriberCount, extractSubTasksProgress, extractTargetBranch, extractTeamMemberCount, extractUserAttributes, extractViewCount, extractVoteCount } from './utils';
18
+ import { extractAppliedToComponentsCount, extractAssignedTo, extractAttachmentCount, extractChecklistProgress, extractDueOn, extractLocation, extractMetaObjectId, extractMetaResourceType, extractMetaTenantId, extractOwnedBy, extractPersonAssignedToAsArray, extractProgrammingLanguage, extractReadTime, extractSmartLinkCommentCount, extractSmartLinkReactCount, extractSmartLinkSentOn, extractSourceBranch, extractStoryPoints, extractSubscriberCount, extractSubTasksProgress, extractTargetBranch, extractTeamMemberCount, extractUserAttributes, extractViewCount, extractVoteCount } from './utils';
19
19
  var extractFlexibleUiContext = function extractFlexibleUiContext() {
20
20
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
21
21
  var appearance = _ref.appearance,
@@ -53,9 +53,9 @@ var extractFlexibleUiContext = function extractFlexibleUiContext() {
53
53
  authorGroup: extractSmartLinkAuthorGroup(response),
54
54
  ownedByGroup: extractPersonOwnedBy(data),
55
55
  collaboratorGroup: extractPersonsUpdatedBy(data),
56
- commentCount: extractCommentCount(data),
56
+ commentCount: extractSmartLinkCommentCount(response),
57
57
  viewCount: extractViewCount(data),
58
- reactCount: extractReactCount(data),
58
+ reactCount: extractSmartLinkReactCount(response),
59
59
  voteCount: extractVoteCount(data),
60
60
  checklistProgress: extractChecklistProgress(data),
61
61
  createdBy: extractSmartLinkCreatedBy(response),
@@ -74,7 +74,7 @@ var extractFlexibleUiContext = function extractFlexibleUiContext() {
74
74
  provider: extractSmartLinkProviderIcon(response),
75
75
  programmingLanguage: extractProgrammingLanguage(data),
76
76
  readTime: extractReadTime(data),
77
- sentOn: extractSentOn(data),
77
+ sentOn: extractSmartLinkSentOn(response),
78
78
  snippet: extractSmartLinkSummary(response) || undefined,
79
79
  // Explicitly set here to remove an empty string
80
80
  sourceBranch: extractSourceBranch(data),
@@ -1,5 +1,6 @@
1
1
  import _typeof from "@babel/runtime/helpers/typeof";
2
- import { extractPersonAssignedTo, extractPersonCreatedBy, extractPersonOwnedBy, extractPersonUpdatedBy } from '@atlaskit/link-extractors';
2
+ import { extractEntity, extractPersonAssignedTo, extractPersonCreatedBy, extractPersonOwnedBy, extractPersonUpdatedBy, isEntityPresent } from '@atlaskit/link-extractors';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
3
4
  var extractLinkName = function extractLinkName(link) {
4
5
  if (link && _typeof(link) === 'object' && link['@type'] === 'Link') {
5
6
  return link.name;
@@ -11,6 +12,22 @@ var extractValue = function extractValue(data, key) {
11
12
  export var extractCommentCount = function extractCommentCount(data) {
12
13
  return extractValue(data, 'schema:commentCount');
13
14
  };
15
+
16
+ /**
17
+ * Should be moved to link-extractors when jsonLd is deprecated
18
+ */
19
+ export var extractSmartLinkCommentCount = function extractSmartLinkCommentCount(response) {
20
+ if (!response || !response.data) {
21
+ return undefined;
22
+ }
23
+ if (fg('platform-linking-slack-entity-support')) {
24
+ if (isEntityPresent(response)) {
25
+ var entity = extractEntity(response);
26
+ return entity && 'commentCount' in entity && typeof entity.commentCount === 'number' ? entity === null || entity === void 0 ? void 0 : entity.commentCount : undefined;
27
+ }
28
+ }
29
+ return (response === null || response === void 0 ? void 0 : response.data) && extractCommentCount(response === null || response === void 0 ? void 0 : response.data);
30
+ };
14
31
  export var extractAppliedToComponentsCount = function extractAppliedToComponentsCount(data) {
15
32
  return extractValue(data, 'atlassian:appliedToComponentsCount');
16
33
  };
@@ -23,6 +40,25 @@ export var extractViewCount = function extractViewCount(data) {
23
40
  export var extractReactCount = function extractReactCount(data) {
24
41
  return extractValue(data, 'atlassian:reactCount');
25
42
  };
43
+
44
+ /**
45
+ * Should be moved to link-extractors when jsonLd is deprecated
46
+ */
47
+ export var extractSmartLinkReactCount = function extractSmartLinkReactCount(response) {
48
+ if (!response || !response.data) {
49
+ return undefined;
50
+ }
51
+ if (fg('platform-linking-slack-entity-support')) {
52
+ if (isEntityPresent(response)) {
53
+ var entity = extractEntity(response);
54
+ var reactions = entity && 'reactions' in entity && Array.isArray(entity.reactions) ? entity.reactions : undefined;
55
+ return reactions === null || reactions === void 0 ? void 0 : reactions.reduce(function (total, reaction) {
56
+ return total + (reaction === null || reaction === void 0 ? void 0 : reaction.total);
57
+ }, 0);
58
+ }
59
+ }
60
+ return (response === null || response === void 0 ? void 0 : response.data) && extractReactCount(response === null || response === void 0 ? void 0 : response.data);
61
+ };
26
62
  export var extractVoteCount = function extractVoteCount(data) {
27
63
  return extractValue(data, 'atlassian:voteCount');
28
64
  };
@@ -101,6 +137,22 @@ export var extractReadTime = function extractReadTime(data) {
101
137
  export var extractSentOn = function extractSentOn(data) {
102
138
  return extractValue(data, 'dateSent');
103
139
  };
140
+
141
+ /**
142
+ * Should be moved to link-extractors when jsonLd is deprecated
143
+ */
144
+ export var extractSmartLinkSentOn = function extractSmartLinkSentOn(response) {
145
+ if (!response || !response.data) {
146
+ return undefined;
147
+ }
148
+ if (fg('platform-linking-slack-entity-support')) {
149
+ if (isEntityPresent(response)) {
150
+ var _extractEntity;
151
+ return (_extractEntity = extractEntity(response)) === null || _extractEntity === void 0 ? void 0 : _extractEntity.createdAt;
152
+ }
153
+ }
154
+ return (response === null || response === void 0 ? void 0 : response.data) && extractSentOn(response === null || response === void 0 ? void 0 : response.data);
155
+ };
104
156
  export var extractStoryPoints = function extractStoryPoints(data) {
105
157
  return extractValue(data, 'atlassian:storyPoints');
106
158
  };
package/dist/esm/index.js CHANGED
@@ -16,5 +16,6 @@ export { ActionName, ElementName, MediaPlacement, SmartLinkDirection, SmartLinkP
16
16
  export { MetadataBlock, PreviewBlock, SnippetBlock, TitleBlock, FooterBlock, CustomBlock } from './view/FlexibleCard/components/blocks';
17
17
  export { AssignedToElement, AssignedToGroupElement, AttachmentCountElement, AuthorGroupElement, ChecklistProgressElement, CollaboratorGroupElement, CommentCountElement, CreatedOnElement, CreatedByElement, DueOnElement, LatestCommitElement, LinkIconElement, LocationElement, ModifiedByElement, ModifiedOnElement, OwnedByElement, OwnedByGroupElement, PreviewElement, PriorityElement, ProgrammingLanguageElement, ProviderElement, ReactCountElement, ReadTimeElement, SentOnElement, SnippetElement, SourceBranchElement, StateElement, StoryPointsElement, SubscriberCountElement, SubTasksProgressElement, TargetBranchElement, TitleElement, ViewCountElement, VoteCountElement, CustomByAccessTypeElement, CustomByStatusElement } from './view/FlexibleCard/external';
18
18
  export { CopyLinkAction, CustomAction, DownloadAction, FollowAction, PreviewAction, UnresolvedAction, CustomUnresolvedAction } from './view/FlexibleCard/external';
19
+ export { getObjectAri, getObjectName, getObjectIconUrl } from './state/helpers';
19
20
  /** @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-661 Internal documentation for deprecation (no external access)} */
20
21
  export { editorCardProvider, EditorCardProvider } from '@atlaskit/link-provider';
@@ -4,7 +4,7 @@ export var ANALYTICS_CHANNEL = 'media';
4
4
  export var context = {
5
5
  componentName: 'smart-cards',
6
6
  packageName: "@atlaskit/smart-card",
7
- packageVersion: "40.1.0"
7
+ packageVersion: "40.2.0"
8
8
  };
9
9
  export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
10
10
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -1,5 +1,6 @@
1
1
  import React, { useCallback, useEffect, useMemo } from 'react';
2
2
  import { useAnalyticsEvents as useAnalyticsEventsNext } from '@atlaskit/analytics-next';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
3
4
  import { useAnalyticsEvents } from '../../common/analytics/generated/use-analytics-events';
4
5
  import { CardDisplay } from '../../constants';
5
6
  import { useSmartLink } from '../../state';
@@ -84,7 +85,7 @@ function Component(_ref) {
84
85
  // delegate the click to the preview panel handler
85
86
  if (!isModifierKeyPressed && ari && name && openPreviewPanel && isPreviewPanelAvailable !== null && isPreviewPanelAvailable !== void 0 && isPreviewPanelAvailable({
86
87
  ari: ari
87
- })) {
88
+ }) && !fg('platform_editor_preview_panel_linking')) {
88
89
  event.preventDefault();
89
90
  event.stopPropagation();
90
91
  openPreviewPanel({
@@ -13,7 +13,7 @@ import LinkWarningModal from './LinkWarningModal';
13
13
  import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
14
14
  var PACKAGE_DATA = {
15
15
  packageName: "@atlaskit/smart-card",
16
- packageVersion: "40.1.0",
16
+ packageVersion: "40.2.0",
17
17
  componentName: 'linkUrl'
18
18
  };
19
19
  var Anchor = withLinkClickedEvent('a');
@@ -0,0 +1,3 @@
1
+ import type { SmartLinkResponse } from "@atlaskit/linking-types";
2
+ declare const _default: SmartLinkResponse;
3
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import type { SmartLinkResponse } from "@atlaskit/linking-types";
2
+ declare const _default: SmartLinkResponse;
3
+ export default _default;
@@ -1,12 +1,21 @@
1
1
  import { type JsonLd } from '@atlaskit/json-ld-types';
2
2
  import { type LinkPerson } from '@atlaskit/link-extractors';
3
+ import type { SmartLinkResponse } from "@atlaskit/linking-types";
3
4
  import { type LinkLocation } from '../../state/flexible-ui-context/types';
4
5
  export type LinkCommentType = JsonLd.Data.Document | JsonLd.Data.Page | JsonLd.Data.Project | JsonLd.Data.SourceCodeCommit | JsonLd.Data.TaskType;
5
6
  export declare const extractCommentCount: (data: JsonLd.Data.BaseData) => number | undefined;
7
+ /**
8
+ * Should be moved to link-extractors when jsonLd is deprecated
9
+ */
10
+ export declare const extractSmartLinkCommentCount: (response?: SmartLinkResponse) => number | undefined;
6
11
  export declare const extractAppliedToComponentsCount: (data: JsonLd.Data.BaseData) => number | undefined;
7
12
  export declare const extractDueOn: (data: JsonLd.Data.BaseData) => string | undefined;
8
13
  export declare const extractViewCount: (data: JsonLd.Data.BaseData) => number | undefined;
9
14
  export declare const extractReactCount: (data: JsonLd.Data.BaseData) => number | undefined;
15
+ /**
16
+ * Should be moved to link-extractors when jsonLd is deprecated
17
+ */
18
+ export declare const extractSmartLinkReactCount: (response?: SmartLinkResponse) => number | undefined;
10
19
  export declare const extractVoteCount: (data: JsonLd.Data.BaseData) => number | undefined;
11
20
  export declare const extractOwnedBy: (data: JsonLd.Data.BaseData) => string | undefined;
12
21
  export declare const extractAssignedTo: (data: JsonLd.Data.BaseData) => string | undefined;
@@ -28,6 +37,10 @@ export declare const extractSubTasksProgress: (data: JsonLd.Data.BaseData) => st
28
37
  export declare const extractUserAttributes: (data: JsonLd.Data.BaseData) => JsonLd.Primitives.UserAttributes | undefined;
29
38
  export declare const extractReadTime: (data: JsonLd.Data.BaseData) => string | undefined;
30
39
  export declare const extractSentOn: (data: JsonLd.Data.BaseData) => string | undefined;
40
+ /**
41
+ * Should be moved to link-extractors when jsonLd is deprecated
42
+ */
43
+ export declare const extractSmartLinkSentOn: (response?: SmartLinkResponse) => string | undefined;
31
44
  export declare const extractStoryPoints: (data: JsonLd.Data.BaseData) => number | undefined;
32
45
  export declare const extractMetaObjectId: (meta: JsonLd.Meta.BaseMeta) => string | undefined;
33
46
  export declare const extractMetaResourceType: (meta: JsonLd.Meta.BaseMeta) => string | undefined;
@@ -12,6 +12,7 @@ export { ActionName, ElementName, MediaPlacement, SmartLinkDirection, SmartLinkP
12
12
  export { MetadataBlock, PreviewBlock, SnippetBlock, TitleBlock, FooterBlock, CustomBlock, } from './view/FlexibleCard/components/blocks';
13
13
  export { AssignedToElement, AssignedToGroupElement, AttachmentCountElement, AuthorGroupElement, ChecklistProgressElement, CollaboratorGroupElement, CommentCountElement, CreatedOnElement, CreatedByElement, DueOnElement, LatestCommitElement, LinkIconElement, LocationElement, ModifiedByElement, ModifiedOnElement, OwnedByElement, OwnedByGroupElement, PreviewElement, PriorityElement, ProgrammingLanguageElement, ProviderElement, ReactCountElement, ReadTimeElement, SentOnElement, SnippetElement, SourceBranchElement, StateElement, StoryPointsElement, SubscriberCountElement, SubTasksProgressElement, TargetBranchElement, TitleElement, ViewCountElement, VoteCountElement, CustomByAccessTypeElement, CustomByStatusElement, } from './view/FlexibleCard/external';
14
14
  export { CopyLinkAction, CustomAction, DownloadAction, FollowAction, PreviewAction, UnresolvedAction, CustomUnresolvedAction, } from './view/FlexibleCard/external';
15
+ export { getObjectAri, getObjectName, getObjectIconUrl } from './state/helpers';
15
16
  export type { ActionItem, ElementItem, OnActionMenuOpenChangeOptions, } from './view/FlexibleCard/components/blocks/types';
16
17
  export type { AnalyticsAction, AnalyticsActionSubject, AnalyticsPayload, AnalyticsHandler, } from './utils/types';
17
18
  /** @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-661 Internal documentation for deprecation (no external access)} */
@@ -0,0 +1,3 @@
1
+ import type { SmartLinkResponse } from "@atlaskit/linking-types";
2
+ declare const _default: SmartLinkResponse;
3
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import type { SmartLinkResponse } from "@atlaskit/linking-types";
2
+ declare const _default: SmartLinkResponse;
3
+ export default _default;
@@ -1,12 +1,21 @@
1
1
  import { type JsonLd } from '@atlaskit/json-ld-types';
2
2
  import { type LinkPerson } from '@atlaskit/link-extractors';
3
+ import type { SmartLinkResponse } from "@atlaskit/linking-types";
3
4
  import { type LinkLocation } from '../../state/flexible-ui-context/types';
4
5
  export type LinkCommentType = JsonLd.Data.Document | JsonLd.Data.Page | JsonLd.Data.Project | JsonLd.Data.SourceCodeCommit | JsonLd.Data.TaskType;
5
6
  export declare const extractCommentCount: (data: JsonLd.Data.BaseData) => number | undefined;
7
+ /**
8
+ * Should be moved to link-extractors when jsonLd is deprecated
9
+ */
10
+ export declare const extractSmartLinkCommentCount: (response?: SmartLinkResponse) => number | undefined;
6
11
  export declare const extractAppliedToComponentsCount: (data: JsonLd.Data.BaseData) => number | undefined;
7
12
  export declare const extractDueOn: (data: JsonLd.Data.BaseData) => string | undefined;
8
13
  export declare const extractViewCount: (data: JsonLd.Data.BaseData) => number | undefined;
9
14
  export declare const extractReactCount: (data: JsonLd.Data.BaseData) => number | undefined;
15
+ /**
16
+ * Should be moved to link-extractors when jsonLd is deprecated
17
+ */
18
+ export declare const extractSmartLinkReactCount: (response?: SmartLinkResponse) => number | undefined;
10
19
  export declare const extractVoteCount: (data: JsonLd.Data.BaseData) => number | undefined;
11
20
  export declare const extractOwnedBy: (data: JsonLd.Data.BaseData) => string | undefined;
12
21
  export declare const extractAssignedTo: (data: JsonLd.Data.BaseData) => string | undefined;
@@ -28,6 +37,10 @@ export declare const extractSubTasksProgress: (data: JsonLd.Data.BaseData) => st
28
37
  export declare const extractUserAttributes: (data: JsonLd.Data.BaseData) => JsonLd.Primitives.UserAttributes | undefined;
29
38
  export declare const extractReadTime: (data: JsonLd.Data.BaseData) => string | undefined;
30
39
  export declare const extractSentOn: (data: JsonLd.Data.BaseData) => string | undefined;
40
+ /**
41
+ * Should be moved to link-extractors when jsonLd is deprecated
42
+ */
43
+ export declare const extractSmartLinkSentOn: (response?: SmartLinkResponse) => string | undefined;
31
44
  export declare const extractStoryPoints: (data: JsonLd.Data.BaseData) => number | undefined;
32
45
  export declare const extractMetaObjectId: (meta: JsonLd.Meta.BaseMeta) => string | undefined;
33
46
  export declare const extractMetaResourceType: (meta: JsonLd.Meta.BaseMeta) => string | undefined;
@@ -12,6 +12,7 @@ export { ActionName, ElementName, MediaPlacement, SmartLinkDirection, SmartLinkP
12
12
  export { MetadataBlock, PreviewBlock, SnippetBlock, TitleBlock, FooterBlock, CustomBlock, } from './view/FlexibleCard/components/blocks';
13
13
  export { AssignedToElement, AssignedToGroupElement, AttachmentCountElement, AuthorGroupElement, ChecklistProgressElement, CollaboratorGroupElement, CommentCountElement, CreatedOnElement, CreatedByElement, DueOnElement, LatestCommitElement, LinkIconElement, LocationElement, ModifiedByElement, ModifiedOnElement, OwnedByElement, OwnedByGroupElement, PreviewElement, PriorityElement, ProgrammingLanguageElement, ProviderElement, ReactCountElement, ReadTimeElement, SentOnElement, SnippetElement, SourceBranchElement, StateElement, StoryPointsElement, SubscriberCountElement, SubTasksProgressElement, TargetBranchElement, TitleElement, ViewCountElement, VoteCountElement, CustomByAccessTypeElement, CustomByStatusElement, } from './view/FlexibleCard/external';
14
14
  export { CopyLinkAction, CustomAction, DownloadAction, FollowAction, PreviewAction, UnresolvedAction, CustomUnresolvedAction, } from './view/FlexibleCard/external';
15
+ export { getObjectAri, getObjectName, getObjectIconUrl } from './state/helpers';
15
16
  export type { ActionItem, ElementItem, OnActionMenuOpenChangeOptions, } from './view/FlexibleCard/components/blocks/types';
16
17
  export type { AnalyticsAction, AnalyticsActionSubject, AnalyticsPayload, AnalyticsHandler, } from './utils/types';
17
18
  /** @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-661 Internal documentation for deprecation (no external access)} */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "40.2.0",
3
+ "version": "40.3.0",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -52,7 +52,7 @@
52
52
  "@atlaskit/link-extractors": "^2.4.0",
53
53
  "@atlaskit/link-test-helpers": "^8.2.0",
54
54
  "@atlaskit/linking-common": "^9.1.0",
55
- "@atlaskit/linking-types": "^13.0.0",
55
+ "@atlaskit/linking-types": "^14.0.0",
56
56
  "@atlaskit/logo": "^19.5.0",
57
57
  "@atlaskit/lozenge": "^13.0.0",
58
58
  "@atlaskit/menu": "^8.0.0",
@@ -244,6 +244,9 @@
244
244
  "platform_renderer_blindspots": {
245
245
  "type": "boolean"
246
246
  },
247
+ "platform_editor_preview_panel_linking": {
248
+ "type": "boolean"
249
+ },
247
250
  "platform-linking-enable-avatar-data-separator": {
248
251
  "type": "boolean"
249
252
  },
@@ -252,6 +255,9 @@
252
255
  },
253
256
  "platform-linking-fix-smart-card-avatar-overrides": {
254
257
  "type": "boolean"
258
+ },
259
+ "platform-linking-slack-entity-support": {
260
+ "type": "boolean"
255
261
  }
256
262
  },
257
263
  "compassUnitTestMetricSourceId": "ari:cloud:compass:a436116f-02ce-4520-8fbb-7301462a1674:metric-source/c5751cc6-3513-4070-9deb-af31e86aed34/f74ef1bc-7240-4aac-9dc8-9dc43b502089"