@atlaskit/smart-card 26.56.4 → 26.57.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/constants.js +5 -1
  3. package/dist/cjs/extractors/flexible/actions/extract-ai-summary-action.js +20 -0
  4. package/dist/cjs/extractors/flexible/actions/extract-follow-action.js +4 -1
  5. package/dist/cjs/extractors/flexible/actions/index.js +4 -2
  6. package/dist/cjs/extractors/flexible/index.js +3 -2
  7. package/dist/cjs/messages.js +50 -0
  8. package/dist/cjs/state/hooks/use-ai-summary-config/index.js +19 -0
  9. package/dist/cjs/state/hooks/use-ai-summary-config/types.js +5 -0
  10. package/dist/cjs/utils/analytics/analytics.js +1 -1
  11. package/dist/cjs/utils/get-is-ai-summary-enabled.js +13 -0
  12. package/dist/cjs/view/Card/types.js +1 -0
  13. package/dist/cjs/view/FlexibleCard/components/actions/ai-summary-action/ai-summary-action-component.js +60 -0
  14. package/dist/cjs/view/FlexibleCard/components/actions/ai-summary-action/index.js +19 -0
  15. package/dist/cjs/view/FlexibleCard/components/actions/ai-summary-action/types.js +5 -0
  16. package/dist/cjs/view/FlexibleCard/components/actions/follow-action/goal-icon/index.js +29 -0
  17. package/dist/cjs/view/FlexibleCard/components/actions/follow-action/index.js +53 -3
  18. package/dist/cjs/view/FlexibleCard/components/actions/follow-action/projects-icon/index.js +29 -0
  19. package/dist/cjs/view/FlexibleCard/components/actions/index.js +8 -1
  20. package/dist/cjs/view/FlexibleCard/components/blocks/action-block/index.js +1 -1
  21. package/dist/cjs/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +2 -2
  22. package/dist/cjs/view/FlexibleCard/components/blocks/snippet-block/index.js +1 -1
  23. package/dist/cjs/view/FlexibleCard/components/utils.js +14 -1
  24. package/dist/cjs/view/FlexibleCard/index.js +4 -1
  25. package/dist/cjs/view/HoverCard/components/HoverCardContent.js +2 -1
  26. package/dist/cjs/view/HoverCard/utils.js +1 -7
  27. package/dist/cjs/view/LinkUrl/index.js +1 -1
  28. package/dist/es2019/constants.js +4 -1
  29. package/dist/es2019/extractors/flexible/actions/extract-ai-summary-action.js +14 -0
  30. package/dist/es2019/extractors/flexible/actions/extract-follow-action.js +5 -2
  31. package/dist/es2019/extractors/flexible/actions/index.js +6 -3
  32. package/dist/es2019/extractors/flexible/index.js +3 -2
  33. package/dist/es2019/messages.js +50 -0
  34. package/dist/es2019/state/flexible-ui-context/types.js +1 -1
  35. package/dist/es2019/state/hooks/use-ai-summary-config/index.js +12 -0
  36. package/dist/es2019/state/hooks/use-ai-summary-config/types.js +1 -0
  37. package/dist/es2019/utils/analytics/analytics.js +1 -1
  38. package/dist/es2019/utils/get-is-ai-summary-enabled.js +5 -0
  39. package/dist/es2019/view/Card/types.js +1 -0
  40. package/dist/es2019/view/FlexibleCard/components/actions/ai-summary-action/ai-summary-action-component.js +51 -0
  41. package/dist/es2019/view/FlexibleCard/components/actions/ai-summary-action/index.js +12 -0
  42. package/dist/es2019/view/FlexibleCard/components/actions/ai-summary-action/types.js +1 -0
  43. package/dist/es2019/view/FlexibleCard/components/actions/follow-action/goal-icon/index.js +18 -0
  44. package/dist/es2019/view/FlexibleCard/components/actions/follow-action/index.js +40 -3
  45. package/dist/es2019/view/FlexibleCard/components/actions/follow-action/projects-icon/index.js +18 -0
  46. package/dist/es2019/view/FlexibleCard/components/actions/index.js +2 -1
  47. package/dist/es2019/view/FlexibleCard/components/blocks/action-block/index.js +2 -2
  48. package/dist/es2019/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +2 -2
  49. package/dist/es2019/view/FlexibleCard/components/blocks/snippet-block/index.js +1 -1
  50. package/dist/es2019/view/FlexibleCard/components/utils.js +7 -0
  51. package/dist/es2019/view/FlexibleCard/index.js +4 -1
  52. package/dist/es2019/view/HoverCard/components/HoverCardContent.js +2 -1
  53. package/dist/es2019/view/HoverCard/utils.js +0 -4
  54. package/dist/es2019/view/LinkUrl/index.js +1 -1
  55. package/dist/esm/constants.js +4 -1
  56. package/dist/esm/extractors/flexible/actions/extract-ai-summary-action.js +14 -0
  57. package/dist/esm/extractors/flexible/actions/extract-follow-action.js +5 -2
  58. package/dist/esm/extractors/flexible/actions/index.js +5 -3
  59. package/dist/esm/extractors/flexible/index.js +3 -2
  60. package/dist/esm/messages.js +50 -0
  61. package/dist/esm/state/flexible-ui-context/types.js +1 -1
  62. package/dist/esm/state/hooks/use-ai-summary-config/index.js +13 -0
  63. package/dist/esm/state/hooks/use-ai-summary-config/types.js +1 -0
  64. package/dist/esm/utils/analytics/analytics.js +1 -1
  65. package/dist/esm/utils/get-is-ai-summary-enabled.js +7 -0
  66. package/dist/esm/view/Card/types.js +1 -0
  67. package/dist/esm/view/FlexibleCard/components/actions/ai-summary-action/ai-summary-action-component.js +50 -0
  68. package/dist/esm/view/FlexibleCard/components/actions/ai-summary-action/index.js +12 -0
  69. package/dist/esm/view/FlexibleCard/components/actions/ai-summary-action/types.js +1 -0
  70. package/dist/esm/view/FlexibleCard/components/actions/follow-action/goal-icon/index.js +22 -0
  71. package/dist/esm/view/FlexibleCard/components/actions/follow-action/index.js +46 -3
  72. package/dist/esm/view/FlexibleCard/components/actions/follow-action/projects-icon/index.js +22 -0
  73. package/dist/esm/view/FlexibleCard/components/actions/index.js +2 -1
  74. package/dist/esm/view/FlexibleCard/components/blocks/action-block/index.js +2 -2
  75. package/dist/esm/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +2 -2
  76. package/dist/esm/view/FlexibleCard/components/blocks/snippet-block/index.js +1 -1
  77. package/dist/esm/view/FlexibleCard/components/utils.js +13 -0
  78. package/dist/esm/view/FlexibleCard/index.js +4 -1
  79. package/dist/esm/view/HoverCard/components/HoverCardContent.js +2 -1
  80. package/dist/esm/view/HoverCard/utils.js +0 -6
  81. package/dist/esm/view/LinkUrl/index.js +1 -1
  82. package/dist/types/constants.d.ts +4 -0
  83. package/dist/types/extractors/common/__mocks__/jsonld.d.ts +2 -0
  84. package/dist/types/extractors/flexible/actions/extract-ai-summary-action.d.ts +5 -0
  85. package/dist/types/extractors/flexible/actions/index.d.ts +2 -1
  86. package/dist/types/extractors/flexible/index.d.ts +1 -1
  87. package/dist/types/messages.d.ts +1 -1
  88. package/dist/types/state/flexible-ui-context/types.d.ts +9 -1
  89. package/dist/types/state/hooks/use-ai-summary-config/index.d.ts +2 -0
  90. package/dist/types/state/hooks/use-ai-summary-config/types.d.ts +5 -0
  91. package/dist/types/utils/get-is-ai-summary-enabled.d.ts +2 -0
  92. package/dist/types/view/Card/types.d.ts +2 -1
  93. package/dist/types/view/FlexibleCard/components/actions/ai-summary-action/ai-summary-action-component.d.ts +4 -0
  94. package/dist/types/view/FlexibleCard/components/actions/ai-summary-action/index.d.ts +4 -0
  95. package/dist/types/view/FlexibleCard/components/actions/ai-summary-action/types.d.ts +2 -0
  96. package/dist/types/view/FlexibleCard/components/actions/follow-action/__fixtures__/follow-goal-context.d.ts +3 -0
  97. package/dist/types/view/FlexibleCard/components/actions/follow-action/goal-icon/index.d.ts +3 -0
  98. package/dist/types/view/FlexibleCard/components/actions/follow-action/projects-icon/index.d.ts +3 -0
  99. package/dist/types/view/FlexibleCard/components/actions/index.d.ts +1 -0
  100. package/dist/types/view/FlexibleCard/components/blocks/action-block/index.d.ts +2 -2
  101. package/dist/types/view/FlexibleCard/components/blocks/action-block/types.d.ts +2 -2
  102. package/dist/types/view/FlexibleCard/components/utils.d.ts +1 -0
  103. package/dist/types/view/FlexibleCard/types.d.ts +2 -0
  104. package/dist/types/view/HoverCard/utils.d.ts +0 -1
  105. package/dist/types-ts4.5/constants.d.ts +4 -0
  106. package/dist/types-ts4.5/extractors/common/__mocks__/jsonld.d.ts +2 -0
  107. package/dist/types-ts4.5/extractors/flexible/actions/extract-ai-summary-action.d.ts +5 -0
  108. package/dist/types-ts4.5/extractors/flexible/actions/index.d.ts +2 -1
  109. package/dist/types-ts4.5/extractors/flexible/index.d.ts +1 -1
  110. package/dist/types-ts4.5/messages.d.ts +1 -1
  111. package/dist/types-ts4.5/state/flexible-ui-context/types.d.ts +9 -1
  112. package/dist/types-ts4.5/state/hooks/use-ai-summary-config/index.d.ts +2 -0
  113. package/dist/types-ts4.5/state/hooks/use-ai-summary-config/types.d.ts +5 -0
  114. package/dist/types-ts4.5/utils/get-is-ai-summary-enabled.d.ts +2 -0
  115. package/dist/types-ts4.5/view/Card/types.d.ts +2 -1
  116. package/dist/types-ts4.5/view/FlexibleCard/components/actions/ai-summary-action/ai-summary-action-component.d.ts +4 -0
  117. package/dist/types-ts4.5/view/FlexibleCard/components/actions/ai-summary-action/index.d.ts +4 -0
  118. package/dist/types-ts4.5/view/FlexibleCard/components/actions/ai-summary-action/types.d.ts +2 -0
  119. package/dist/types-ts4.5/view/FlexibleCard/components/actions/follow-action/__fixtures__/follow-goal-context.d.ts +3 -0
  120. package/dist/types-ts4.5/view/FlexibleCard/components/actions/follow-action/goal-icon/index.d.ts +3 -0
  121. package/dist/types-ts4.5/view/FlexibleCard/components/actions/follow-action/projects-icon/index.d.ts +3 -0
  122. package/dist/types-ts4.5/view/FlexibleCard/components/actions/index.d.ts +1 -0
  123. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/action-block/index.d.ts +2 -2
  124. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/action-block/types.d.ts +2 -2
  125. package/dist/types-ts4.5/view/FlexibleCard/components/utils.d.ts +1 -0
  126. package/dist/types-ts4.5/view/FlexibleCard/types.d.ts +2 -0
  127. package/dist/types-ts4.5/view/HoverCard/utils.d.ts +0 -1
  128. package/package.json +1 -1
@@ -30,6 +30,7 @@ var _click = require("../../../utils/analytics/click");
30
30
  var _store = require("../../../state/store");
31
31
  var _forbidden = _interopRequireDefault(require("./views/forbidden"));
32
32
  var _ContentContainer = _interopRequireDefault(require("./ContentContainer"));
33
+ var _getIsAiSummaryEnabled = require("../../../utils/get-is-ai-summary-enabled");
33
34
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
34
35
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
35
36
  /** @jsx jsx */
@@ -93,7 +94,7 @@ var HoverCardContent = function HoverCardContent(_ref) {
93
94
  var linkStatus = (_linkState$status = linkState.status) !== null && _linkState$status !== void 0 ? _linkState$status : 'pending';
94
95
  var _useSmartLinkContext = (0, _linkProvider.useSmartLinkContext)(),
95
96
  isAdminHubAIEnabled = _useSmartLinkContext.isAdminHubAIEnabled;
96
- var isAISummaryEnabled = (0, _utils2.getIsAISummaryEnabled)(isAdminHubAIEnabled, cardState.details);
97
+ var isAISummaryEnabled = (0, _getIsAiSummaryEnabled.getIsAISummaryEnabled)(isAdminHubAIEnabled, cardState.details);
97
98
  var services = (0, _helpers.getServices)(linkState.details);
98
99
  var statusRef = (0, _react2.useRef)(linkStatus);
99
100
  var analyticsRef = (0, _react2.useRef)(analytics);
@@ -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 = exports.getIsAISummaryEnabled = void 0;
7
+ exports.getSimulatedMetadata = exports.getSimulatedBetterMetadata = 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");
@@ -205,10 +205,4 @@ var getSimulatedBetterMetadata = exports.getSimulatedBetterMetadata = function g
205
205
  default:
206
206
  return defaultMetadata;
207
207
  }
208
- };
209
- var getIsAISummaryEnabled = exports.getIsAISummaryEnabled = function getIsAISummaryEnabled() {
210
- var _response$meta;
211
- var isAdminHubAIEnabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
212
- var response = arguments.length > 1 ? arguments[1] : undefined;
213
- return Boolean((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-card.hover-card-ai-summaries') && isAdminHubAIEnabled && (response === null || response === void 0 || (_response$meta = response.meta) === null || _response$meta === void 0 || (_response$meta = _response$meta.supportedFeature) === null || _response$meta === void 0 ? void 0 : _response$meta.includes('AISummary')));
214
208
  };
@@ -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.56.4",
20
+ packageVersion: "26.57.0",
21
21
  componentName: 'linkUrl'
22
22
  };
23
23
  var Link = (0, _click.withLinkClickedEvent)('a');
@@ -155,7 +155,10 @@ export let ActionName = /*#__PURE__*/function (ActionName) {
155
155
  ActionName["CustomAction"] = "CustomAction";
156
156
  return ActionName;
157
157
  }({});
158
-
158
+ export let InternalActionName = /*#__PURE__*/function (InternalActionName) {
159
+ InternalActionName["AISummaryAction"] = "AISummaryAction";
160
+ return InternalActionName;
161
+ }({});
159
162
  /**
160
163
  * Flexible UI icons - each mapped to AK icons.
161
164
  */
@@ -0,0 +1,14 @@
1
+ import { CardAction } from '../../../view/Card/types';
2
+ import { canShowAction } from '../../../utils/actions/can-show-action';
3
+ import { getIsAISummaryEnabled } from '../../../utils/get-is-ai-summary-enabled';
4
+ import { extractAri } from '@atlaskit/link-extractors';
5
+ export const extractAISummaryAction = (response, url, actionOptions, aiSummaryConfig) => {
6
+ if (!canShowAction(CardAction.AISummaryAction, actionOptions) || !getIsAISummaryEnabled(aiSummaryConfig === null || aiSummaryConfig === void 0 ? void 0 : aiSummaryConfig.isAdminHubAIEnabled, response) || !(aiSummaryConfig !== null && aiSummaryConfig !== void 0 && aiSummaryConfig.product) || !url) {
7
+ return;
8
+ }
9
+ return {
10
+ url,
11
+ ari: extractAri(response.data),
12
+ product: aiSummaryConfig === null || aiSummaryConfig === void 0 ? void 0 : aiSummaryConfig.product
13
+ };
14
+ };
@@ -1,4 +1,4 @@
1
- import { extractLink } from '@atlaskit/link-extractors';
1
+ import { extractLink, extractType } from '@atlaskit/link-extractors';
2
2
  import { SmartLinkActionType } from '@atlaskit/linking-types';
3
3
  import { getExtensionKey } from '../../../state/helpers';
4
4
  import extractServerAction from '../extract-server-action';
@@ -12,6 +12,8 @@ const extractFollowAction = (response, actionOptions, id) => {
12
12
  const extensionKey = getExtensionKey(response);
13
13
  const data = response === null || response === void 0 ? void 0 : response.data;
14
14
  const actions = extractServerAction(data);
15
+ const type = extractType(data);
16
+ const isProject = type === null || type === void 0 ? void 0 : type.includes('atlassian:Project');
15
17
  if (!extensionKey || actions.length === 0) {
16
18
  return;
17
19
  }
@@ -41,7 +43,8 @@ const extractFollowAction = (response, actionOptions, id) => {
41
43
  providerKey: extensionKey,
42
44
  reload
43
45
  },
44
- value: actionType === SmartLinkActionType.FollowEntityAction
46
+ value: actionType === SmartLinkActionType.FollowEntityAction,
47
+ isProject
45
48
  };
46
49
  };
47
50
  export default extractFollowAction;
@@ -1,14 +1,17 @@
1
- import { ActionName } from '../../../constants';
1
+ import { ActionName, InternalActionName } from '../../../constants';
2
2
  import { extractDownloadAction } from './extract-download-action';
3
3
  import { extractPreviewAction } from './extract-preview-action';
4
+ import { extractAISummaryAction } from './extract-ai-summary-action';
4
5
  import extractFollowAction from './extract-follow-action';
5
6
  import { extractCopyLinkAction } from './extract-copy-link-action';
6
- const extractActions = (response, data, actionOptions, id) => {
7
+ const extractActions = (response, url, actionOptions, id, aiSummaryConfig) => {
8
+ const data = response.data;
7
9
  const action = {
8
10
  [ActionName.CopyLinkAction]: extractCopyLinkAction(data, actionOptions),
9
11
  [ActionName.DownloadAction]: extractDownloadAction(data, actionOptions),
10
12
  [ActionName.FollowAction]: extractFollowAction(response, actionOptions, id),
11
- [ActionName.PreviewAction]: extractPreviewAction(response, actionOptions)
13
+ [ActionName.PreviewAction]: extractPreviewAction(response, actionOptions),
14
+ [InternalActionName.AISummaryAction]: extractAISummaryAction(response, url, actionOptions, aiSummaryConfig)
12
15
  };
13
16
  return Object.values(action).some(value => Boolean(value)) ? action : undefined;
14
17
  };
@@ -14,7 +14,8 @@ const extractFlexibleUiContext = ({
14
14
  id,
15
15
  renderers,
16
16
  actionOptions,
17
- response
17
+ response,
18
+ aiSummaryConfig
18
19
  } = {}) => {
19
20
  if (!response) {
20
21
  return undefined;
@@ -22,7 +23,7 @@ const extractFlexibleUiContext = ({
22
23
  const data = response.data;
23
24
  const url = extractLink(data);
24
25
  return {
25
- actions: extractActions(response, data, actionOptions, id),
26
+ actions: extractActions(response, url, actionOptions, id, aiSummaryConfig),
26
27
  assignedToGroup: extractPersonAssignedToAsArray(data),
27
28
  attachmentCount: extractAttachmentCount(data),
28
29
  authorGroup: extractPersonCreatedBy(data),
@@ -195,6 +195,16 @@ export const messages = defineMessages({
195
195
  defaultMessage: 'Download file',
196
196
  description: 'Allow a user to download a file'
197
197
  },
198
+ ai_summary_action: {
199
+ id: 'fabric.linking.ai_summary_action.nonfinal',
200
+ defaultMessage: 'Summarize with AI',
201
+ description: 'Allow a user to summarize a link'
202
+ },
203
+ ai_summary_action_description: {
204
+ id: 'fabric.linking.ai_summary_action_description.nonfinal',
205
+ defaultMessage: 'Summarize the content of this link using Atlassian Intelligence.',
206
+ description: 'Description of what the summarize link with AI action does'
207
+ },
198
208
  edit: {
199
209
  id: 'fabric.linking.edit',
200
210
  defaultMessage: 'Edit',
@@ -205,6 +215,26 @@ export const messages = defineMessages({
205
215
  defaultMessage: 'Follow',
206
216
  description: 'Click to follow a project.'
207
217
  },
218
+ follow_project_description: {
219
+ id: 'fabric.linking.follow_project_description.nonfinal',
220
+ defaultMessage: 'Follow to get notifications on this project',
221
+ description: 'Description on what Follow does'
222
+ },
223
+ follow_project: {
224
+ id: 'fabric.linking.follow_project.nonfinal',
225
+ defaultMessage: 'Follow project',
226
+ description: 'Click to follow a project.'
227
+ },
228
+ follow_goal_description: {
229
+ id: 'fabric.linking.follow_goal_description.nonfinal',
230
+ defaultMessage: 'Follow this goal to get notifications on updates',
231
+ description: 'Description on what Follow does'
232
+ },
233
+ follow_goal: {
234
+ id: 'fabric.linking.follow_goal.nonfinal',
235
+ defaultMessage: 'Follow goal',
236
+ description: 'Click to follow a project.'
237
+ },
208
238
  go_back: {
209
239
  id: 'fabric.linking.go_back',
210
240
  defaultMessage: 'Go back',
@@ -465,6 +495,26 @@ export const messages = defineMessages({
465
495
  defaultMessage: 'Unfollow',
466
496
  description: 'Click to unfollow a project.'
467
497
  },
498
+ unfollow_project_description: {
499
+ id: 'fabric.linking.unfollow_project_description.nonfinal',
500
+ defaultMessage: 'Unfollow to stop receiving project notifications',
501
+ description: 'Description on what Unfollow does'
502
+ },
503
+ unfollow_project: {
504
+ id: 'fabric.linking.unfollow_project.nonfinal',
505
+ defaultMessage: 'Unfollow project',
506
+ description: 'Click to unfollow a project.'
507
+ },
508
+ unfollow_goal_description: {
509
+ id: 'fabric.linking.unfollow_goal_description.nonfinal',
510
+ defaultMessage: 'Unfollow to stop receiving notifications for this goal',
511
+ description: 'Description on what Unfollow does'
512
+ },
513
+ unfollow_goal: {
514
+ id: 'fabric.linking.unfollow_goal.nonfinal',
515
+ defaultMessage: 'Unfollow goal',
516
+ description: 'Click to unfollow a project.'
517
+ },
468
518
  unlink_account: {
469
519
  id: 'fabric.linking.unlink_account',
470
520
  defaultMessage: 'Unlink Account',
@@ -1,4 +1,4 @@
1
- import { ActionName } from '../../constants';
1
+ import { ActionName, InternalActionName } from '../../constants';
2
2
 
3
3
  /**
4
4
  * This provides the data that will be used by Smart Links Flexible UI to populate it's
@@ -0,0 +1,12 @@
1
+ import { useSmartLinkContext } from '@atlaskit/link-provider';
2
+ import { useMemo } from 'react';
3
+ export const useAISummaryConfig = () => {
4
+ const {
5
+ product,
6
+ isAdminHubAIEnabled
7
+ } = useSmartLinkContext();
8
+ return useMemo(() => ({
9
+ product,
10
+ isAdminHubAIEnabled
11
+ }), [product, isAdminHubAIEnabled]);
12
+ };
@@ -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.56.4"
7
+ packageVersion: "26.57.0"
8
8
  };
9
9
  export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
10
10
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -0,0 +1,5 @@
1
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
2
+ export const getIsAISummaryEnabled = (isAdminHubAIEnabled = false, response) => {
3
+ var _response$meta, _response$meta$suppor;
4
+ return Boolean(getBooleanFF('platform.linking-platform.smart-card.hover-card-ai-summaries') && isAdminHubAIEnabled && (response === null || response === void 0 ? void 0 : (_response$meta = response.meta) === null || _response$meta === void 0 ? void 0 : (_response$meta$suppor = _response$meta.supportedFeature) === null || _response$meta$suppor === void 0 ? void 0 : _response$meta$suppor.includes('AISummary')));
5
+ };
@@ -5,5 +5,6 @@ export let CardAction = /*#__PURE__*/function (CardAction) {
5
5
  CardAction["ChangeStatusAction"] = "ChangeStatusAction";
6
6
  CardAction["FollowAction"] = "FollowAction";
7
7
  CardAction["CopyLinkAction"] = "CopyLinkAction";
8
+ CardAction["AISummaryAction"] = "AISummaryAction";
8
9
  return CardAction;
9
10
  }({});
@@ -0,0 +1,51 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React, { useCallback } from 'react';
3
+ import { FormattedMessage } from 'react-intl-next';
4
+ import { messages } from '../../../../../messages';
5
+ import Action from '../action';
6
+ import AiIcon from '../../../../common/ai-icon';
7
+ import { useAnalyticsEvents } from '../../../../../common/analytics/generated/use-analytics-events';
8
+ import { useAISummary } from '../../../../../state/hooks/use-ai-summary';
9
+ export const AISummaryActionComponent = ({
10
+ onClick: onClickCallback,
11
+ url = '',
12
+ ari = '',
13
+ product,
14
+ ...props
15
+ }) => {
16
+ const {
17
+ fireEvent
18
+ } = useAnalyticsEvents();
19
+ const {
20
+ state: {
21
+ status
22
+ },
23
+ summariseUrl
24
+ } = useAISummary({
25
+ url,
26
+ ari,
27
+ product
28
+ });
29
+ const handleActionClick = useCallback(() => {
30
+ fireEvent('ui.button.clicked.aiSummary', {});
31
+ fireEvent('track.aiInteraction.initiated', {
32
+ aiFeatureName: 'Smart Links Summary',
33
+ proactiveAIGenerated: 0,
34
+ userGeneratedAI: 1
35
+ });
36
+ summariseUrl();
37
+ onClickCallback === null || onClickCallback === void 0 ? void 0 : onClickCallback();
38
+ }, [fireEvent, onClickCallback, summariseUrl]);
39
+ if (status === 'ready' || status === 'error') {
40
+ return /*#__PURE__*/React.createElement(Action, _extends({
41
+ content: /*#__PURE__*/React.createElement(FormattedMessage, messages.ai_summary_action),
42
+ icon: /*#__PURE__*/React.createElement(AiIcon, {
43
+ label: "Summarise with AI"
44
+ }),
45
+ onClick: handleActionClick,
46
+ testId: "smart-action-ai-summary-action",
47
+ tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.ai_summary_action_description)
48
+ }, props));
49
+ }
50
+ return null;
51
+ };
@@ -0,0 +1,12 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React from 'react';
3
+ import { useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
4
+ import { InternalActionName } from '../../../../../constants';
5
+ import { AISummaryActionComponent } from './ai-summary-action-component';
6
+ const AISummaryAction = props => {
7
+ var _context$actions;
8
+ const context = useFlexibleUiContext();
9
+ const actionData = context === null || context === void 0 ? void 0 : (_context$actions = context.actions) === null || _context$actions === void 0 ? void 0 : _context$actions[InternalActionName.AISummaryAction];
10
+ return actionData ? /*#__PURE__*/React.createElement(AISummaryActionComponent, _extends({}, actionData, props)) : null;
11
+ };
12
+ export default AISummaryAction;
@@ -0,0 +1,18 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import Icon from '@atlaskit/icon';
3
+ import React from 'react';
4
+ const GoalGlyph = props => /*#__PURE__*/React.createElement("svg", {
5
+ xmlns: "http://www.w3.org/2000/svg",
6
+ width: "16",
7
+ height: "16",
8
+ viewBox: "0 0 16 16",
9
+ fill: "none"
10
+ }, /*#__PURE__*/React.createElement("path", {
11
+ fillRule: "evenodd",
12
+ clipRule: "evenodd",
13
+ d: "M12.6667 8C12.6667 10.5773 10.5773 12.6667 8 12.6667C5.42267 12.6667 3.33333 10.5773 3.33333 8C3.33333 5.42267 5.42267 3.33333 8 3.33333C10.5773 3.33333 12.6667 5.42267 12.6667 8ZM14 8C14 11.3137 11.3137 14 8 14C4.68629 14 2 11.3137 2 8C2 4.68629 4.68629 2 8 2C11.3137 2 14 4.68629 14 8ZM9.33333 8C9.33333 8.73638 8.73638 9.33333 8 9.33333C7.26362 9.33333 6.66667 8.73638 6.66667 8C6.66667 7.26362 7.26362 6.66667 8 6.66667C8.73638 6.66667 9.33333 7.26362 9.33333 8ZM10.6667 8C10.6667 9.47276 9.47276 10.6667 8 10.6667C6.52724 10.6667 5.33333 9.47276 5.33333 8C5.33333 6.52724 6.52724 5.33333 8 5.33333C9.47276 5.33333 10.6667 6.52724 10.6667 8Z",
14
+ fill: "#0C66E4"
15
+ }));
16
+ export const GoalIcon = props => /*#__PURE__*/React.createElement(Icon, _extends({
17
+ glyph: GoalGlyph
18
+ }, props));
@@ -7,6 +7,26 @@ import { messages } from '../../../../../messages';
7
7
  import { useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
8
8
  import ServerAction from '../action/server-action';
9
9
  import UnfollowIcon from './unfollow-icon';
10
+ import { importIcon } from '../../utils';
11
+ const importIconMapper = {
12
+ goal: () => import( /* webpackChunkName: "glyphGoal" */'./goal-icon').then(({
13
+ GoalIcon
14
+ }) => ({
15
+ default: GoalIcon
16
+ })),
17
+ projects: () => import( /* webpackChunkName: "glyphProjects" */'./projects-icon').then(({
18
+ ProjectsIcon
19
+ }) => ({
20
+ default: ProjectsIcon
21
+ }))
22
+ };
23
+ const getIcon = stackIconType => {
24
+ const importFn = importIconMapper[stackIconType];
25
+ if (!importFn) {
26
+ return null;
27
+ }
28
+ return importIcon(importFn);
29
+ };
10
30
  const FollowAction = props => {
11
31
  var _context$actions, _context$actions2;
12
32
  const context = useFlexibleUiContext();
@@ -17,17 +37,34 @@ const FollowAction = props => {
17
37
  value,
18
38
  ...data
19
39
  } = context === null || context === void 0 ? void 0 : (_context$actions2 = context.actions) === null || _context$actions2 === void 0 ? void 0 : _context$actions2[ActionName.FollowAction];
40
+ const isStackItem = props.as === 'stack-item';
41
+ const isProject = data.isProject;
20
42
  const message = value ? messages.follow : messages.unfollow;
43
+ const projectMessage = value ? messages.follow_project : messages.unfollow_project;
44
+ const goalMessage = value ? messages.follow_goal : messages.unfollow_goal;
45
+ const stackMessage = isProject ? projectMessage : goalMessage;
46
+ const label = isStackItem ? stackMessage : message;
47
+ const projectTooltipMessage = value ? messages.follow_project_description : messages.unfollow_project_description;
48
+ const goalTooltipMessage = value ? messages.follow_goal_description : messages.unfollow_goal_description;
49
+ const stackTooltipMessage = isProject ? projectTooltipMessage : goalTooltipMessage;
50
+ const tooltipMessage = isStackItem ? stackTooltipMessage : message;
21
51
  const icon = value ? /*#__PURE__*/React.createElement(InviteTeamIcon, {
22
52
  label: "Follow"
23
53
  }) : /*#__PURE__*/React.createElement(UnfollowIcon, {
24
54
  label: "Unfollow"
25
55
  });
56
+ const stackIconType = isProject ? 'projects' : 'goal';
57
+ const ImportedIcon = getIcon(stackIconType);
58
+ const stackIcon = /*#__PURE__*/React.createElement(ImportedIcon, {
59
+ label: "Follow",
60
+ testId: `smart-action-follow-action-${stackIconType}-icon`
61
+ });
62
+ const followIcon = isStackItem ? stackIcon : icon;
26
63
  return /*#__PURE__*/React.createElement(ServerAction, _extends({
27
- content: /*#__PURE__*/React.createElement(FormattedMessage, message),
28
- icon: icon,
64
+ content: /*#__PURE__*/React.createElement(FormattedMessage, label),
65
+ icon: followIcon,
29
66
  testId: "smart-action-follow-action",
30
- tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, message)
67
+ tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, tooltipMessage)
31
68
  }, data, props));
32
69
  };
33
70
  export default FollowAction;
@@ -0,0 +1,18 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import Icon from '@atlaskit/icon';
3
+ import React from 'react';
4
+ const ProjectsGlyph = props => /*#__PURE__*/React.createElement("svg", {
5
+ xmlns: "http://www.w3.org/2000/svg",
6
+ width: "16",
7
+ height: "16",
8
+ viewBox: "0 0 16 16",
9
+ fill: "none"
10
+ }, /*#__PURE__*/React.createElement("path", {
11
+ fillRule: "evenodd",
12
+ clipRule: "evenodd",
13
+ d: "M9.88573 4.00002C9.70892 4.00002 9.53935 4.07026 9.41433 4.19528L6.97282 6.63678L4.20525 6.94429C4.05479 6.96101 3.91451 7.02844 3.80746 7.13548L3.60959 7.33335L4.35367 8.07743C4.6791 8.40287 4.6791 8.93051 4.35367 9.25594L3.47152 10.1381C3.21117 10.3984 2.78906 10.3984 2.52871 10.1381C2.26836 9.87774 2.26836 9.45563 2.52871 9.19528L3.0573 8.66669L2.43108 8.04046C2.04055 7.64993 2.04055 7.01677 2.43108 6.62625L2.86465 6.19267C3.18578 5.87154 3.60664 5.66927 4.05801 5.61911L6.36073 5.36326L8.47152 3.25247C8.84659 2.8774 9.3553 2.66669 9.88573 2.66669H12.0001C12.7365 2.66669 13.3334 3.26364 13.3334 4.00002V6.1144C13.3334 6.64483 13.1227 7.15354 12.7477 7.52862L10.6369 9.6394L10.381 11.9421C10.3309 12.3935 10.1286 12.8143 9.80746 13.1355L9.37389 13.5691C8.98336 13.9596 8.3502 13.9596 7.95967 13.5691L7.33345 12.9428L6.80485 13.4714C6.5445 13.7318 6.12239 13.7318 5.86204 13.4714C5.60169 13.2111 5.60169 12.789 5.86204 12.5286L6.74419 11.6465C7.06963 11.321 7.59726 11.321 7.9227 11.6465L8.66678 12.3905L8.86466 12.1927C8.9717 12.0856 9.03912 11.9453 9.05584 11.7949L9.36335 9.02731L11.8049 6.58581C11.9299 6.46078 12.0001 6.29121 12.0001 6.1144V4.00002H9.88573ZM5.80486 10.1953C6.06521 10.4556 6.06521 10.8777 5.80486 11.1381L3.80486 13.1381C3.54451 13.3984 3.1224 13.3984 2.86205 13.1381C2.6017 12.8777 2.6017 12.4556 2.86205 12.1953L4.86205 10.1953C5.1224 9.93493 5.54451 9.93493 5.80486 10.1953ZM10.0001 6.66669C10.3683 6.66669 10.6668 6.36821 10.6668 6.00002C10.6668 5.63183 10.3683 5.33335 10.0001 5.33335C9.63193 5.33335 9.33346 5.63183 9.33346 6.00002C9.33346 6.36821 9.63193 6.66669 10.0001 6.66669Z",
14
+ fill: "#0C66E4"
15
+ }));
16
+ export const ProjectsIcon = props => /*#__PURE__*/React.createElement(Icon, _extends({
17
+ glyph: ProjectsGlyph
18
+ }, props));
@@ -4,4 +4,5 @@ export { default as EditAction } from './edit-action';
4
4
  export { default as DownloadAction } from './download-action';
5
5
  export { default as FollowAction } from './follow-action';
6
6
  export { default as PreviewAction } from './preview-action';
7
- export { default as CopyLinkAction } from './copy-link-action';
7
+ export { default as CopyLinkAction } from './copy-link-action';
8
+ export { default as AISummaryAction } from './ai-summary-action';
@@ -1,6 +1,6 @@
1
1
  import { Stack, xcss } from '@atlaskit/primitives';
2
2
  import React, { useMemo } from 'react';
3
- import { ActionName, SmartLinkSize } from '../../../../../constants';
3
+ import { SmartLinkSize } from '../../../../../constants';
4
4
  import { useFlexibleUiContext, useFlexibleUiOptionContext } from '../../../../../state/flexible-ui-context';
5
5
  import * as Actions from '../../actions';
6
6
  import { getPrimitivesPaddingSpaceBySize } from '../../utils';
@@ -10,7 +10,7 @@ const ignoreContainerPaddingStyles = xcss({
10
10
  marginLeft: 'calc(var(--container-gap-left) * -1)',
11
11
  marginRight: 'calc(var(--container-gap-right) * -1)'
12
12
  });
13
- const DEFAULT_SORT_ORDER = [ActionName.PreviewAction, ActionName.CopyLinkAction];
13
+ const DEFAULT_SORT_ORDER = ['PreviewAction', 'CopyLinkAction', 'AISummaryAction'];
14
14
  const sort = (a, b) => {
15
15
  let idxA = DEFAULT_SORT_ORDER.indexOf(a);
16
16
  let idxB = DEFAULT_SORT_ORDER.indexOf(b);
@@ -11,8 +11,6 @@ import AIStateIndicator from '../ai-state-indicator';
11
11
  import { renderElementItems } from '../../utils';
12
12
  import { messages } from '../../../../../../messages';
13
13
  import { useAISummary } from '../../../../../../state/hooks/use-ai-summary';
14
- import { useFlexibleUiContext } from '../../../../../../state/flexible-ui-context';
15
- import { useSmartLinkContext } from '@atlaskit/link-provider';
16
14
  import AIIcon from '../../../../../common/ai-icon';
17
15
  import AISummary from '../../../../../common/ai-summary';
18
16
  import { useAnalyticsEvents } from '../../../../../../common/analytics/generated/use-analytics-events';
@@ -21,6 +19,8 @@ import AIEventErrorViewed from '../ai-event-error-viewed';
21
19
  import { di } from 'react-magnetic-di';
22
20
  import { css } from '@emotion/react';
23
21
  import FeatureDiscovery from '../feature-discovery';
22
+ import { useFlexibleUiContext } from '../../../../../../state/flexible-ui-context';
23
+ import { useSmartLinkContext } from '@atlaskit/link-provider';
24
24
  export const AISummaryBlockErrorIndicator = ({
25
25
  showErrorIndicator,
26
26
  error,
@@ -5,7 +5,7 @@ import { SmartLinkStatus } from '../../../../../constants';
5
5
  import { Snippet } from '../../elements';
6
6
  import { getMaxLines } from '../../utils';
7
7
  const DEFAULT_MAX_LINES = 3;
8
- const MAXIMUM_MAX_LINES = 3;
8
+ const MAXIMUM_MAX_LINES = 6;
9
9
  const MINIMUM_MAX_LINES = 1;
10
10
 
11
11
  /**
@@ -5,6 +5,7 @@ import { FormattedMessage } from 'react-intl-next';
5
5
  import { SmartLinkSize } from '../../../constants';
6
6
  import Icon from './elements/icon';
7
7
  import { openEmbedModal } from '../../EmbedModal/utils';
8
+ import Loadable from 'react-loadable';
8
9
  export const sizeToButtonSpacing = {
9
10
  [SmartLinkSize.Small]: 'none',
10
11
  [SmartLinkSize.Medium]: 'compact',
@@ -67,6 +68,12 @@ export const getIconWidth = size => {
67
68
  return '.75rem';
68
69
  }
69
70
  };
71
+ export const importIcon = importFn => {
72
+ return Loadable({
73
+ loader: () => importFn().then(module => module.default),
74
+ loading: () => null
75
+ }); // Because we're using dynamic loading here, TS will not be able to infer the type.
76
+ };
70
77
  export const getLinkLineHeight = size => {
71
78
  switch (size) {
72
79
  case SmartLinkSize.XLarge:
@@ -4,6 +4,7 @@ import { SmartLinkStatus } from '../../constants';
4
4
  import Container from './components/container';
5
5
  import { FlexibleUiAnalyticsContext, FlexibleUiContext, FlexibleUiOptionContext } from '../../state/flexible-ui-context';
6
6
  import { getContextByStatus, getRetryOptions } from './utils';
7
+ import { useAISummaryConfig } from '../../state/hooks/use-ai-summary-config';
7
8
 
8
9
  /**
9
10
  * This represents a Flexible Card: a link represented by a card with metadata.
@@ -30,19 +31,21 @@ const FlexibleCard = ({
30
31
  url
31
32
  }) => {
32
33
  var _details$meta2;
34
+ const aiSummaryConfig = useAISummaryConfig();
33
35
  const {
34
36
  status: cardType,
35
37
  details
36
38
  } = cardState;
37
39
  const status = cardType;
38
40
  const context = useMemo(() => getContextByStatus({
41
+ aiSummaryConfig,
39
42
  response: details,
40
43
  id,
41
44
  renderers,
42
45
  actionOptions,
43
46
  status,
44
47
  url
45
- }), [details, id, renderers, actionOptions, status, url]);
48
+ }), [aiSummaryConfig, details, id, renderers, actionOptions, status, url]);
46
49
  const retry = getRetryOptions(url, status, details, onAuthorize);
47
50
  const {
48
51
  title
@@ -11,7 +11,7 @@ import { useSmartLinkAnalytics } from '../../../state/analytics';
11
11
  import { getExtensionKey, getServices } from '../../../state/helpers';
12
12
  import { isSpecialEvent } from '../../../utils';
13
13
  import { flexibleUiOptions, titleBlockCss } from '../styled';
14
- import { getSimulatedMetadata, getIsAISummaryEnabled } from '../utils';
14
+ import { getSimulatedMetadata } from '../utils';
15
15
  import HoverCardLoadingView from './views/resolving';
16
16
  import HoverCardUnauthorisedView from './views/unauthorised';
17
17
  import HoverCardResolvedView from './views/resolved';
@@ -21,6 +21,7 @@ import { fireLinkClickedEvent } from '../../../utils/analytics/click';
21
21
  import { useSmartCardState } from '../../../state/store';
22
22
  import HoverCardForbiddenView from './views/forbidden';
23
23
  import ContentContainer from './ContentContainer';
24
+ import { getIsAISummaryEnabled } from '../../../utils/get-is-ai-summary-enabled';
24
25
  export const hoverCardClassName = 'smart-links-hover-preview';
25
26
  export const getCopyAction = url => ({
26
27
  name: ActionName.CustomAction,
@@ -201,8 +201,4 @@ export const getSimulatedBetterMetadata = (extensionKey = '', data) => {
201
201
  default:
202
202
  return defaultMetadata;
203
203
  }
204
- };
205
- export const getIsAISummaryEnabled = (isAdminHubAIEnabled = false, response) => {
206
- var _response$meta, _response$meta$suppor;
207
- return Boolean(getBooleanFF('platform.linking-platform.smart-card.hover-card-ai-summaries') && isAdminHubAIEnabled && (response === null || response === void 0 ? void 0 : (_response$meta = response.meta) === null || _response$meta === void 0 ? void 0 : (_response$meta$suppor = _response$meta.supportedFeature) === null || _response$meta$suppor === void 0 ? void 0 : _response$meta$suppor.includes('AISummary')));
208
204
  };
@@ -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.56.4",
10
+ packageVersion: "26.57.0",
11
11
  componentName: 'linkUrl'
12
12
  };
13
13
  const Link = withLinkClickedEvent('a');
@@ -155,7 +155,10 @@ export var ActionName = /*#__PURE__*/function (ActionName) {
155
155
  ActionName["CustomAction"] = "CustomAction";
156
156
  return ActionName;
157
157
  }({});
158
-
158
+ export var InternalActionName = /*#__PURE__*/function (InternalActionName) {
159
+ InternalActionName["AISummaryAction"] = "AISummaryAction";
160
+ return InternalActionName;
161
+ }({});
159
162
  /**
160
163
  * Flexible UI icons - each mapped to AK icons.
161
164
  */
@@ -0,0 +1,14 @@
1
+ import { CardAction } from '../../../view/Card/types';
2
+ import { canShowAction } from '../../../utils/actions/can-show-action';
3
+ import { getIsAISummaryEnabled } from '../../../utils/get-is-ai-summary-enabled';
4
+ import { extractAri } from '@atlaskit/link-extractors';
5
+ export var extractAISummaryAction = function extractAISummaryAction(response, url, actionOptions, aiSummaryConfig) {
6
+ if (!canShowAction(CardAction.AISummaryAction, actionOptions) || !getIsAISummaryEnabled(aiSummaryConfig === null || aiSummaryConfig === void 0 ? void 0 : aiSummaryConfig.isAdminHubAIEnabled, response) || !(aiSummaryConfig !== null && aiSummaryConfig !== void 0 && aiSummaryConfig.product) || !url) {
7
+ return;
8
+ }
9
+ return {
10
+ url: url,
11
+ ari: extractAri(response.data),
12
+ product: aiSummaryConfig === null || aiSummaryConfig === void 0 ? void 0 : aiSummaryConfig.product
13
+ };
14
+ };