@atlaskit/smart-card 26.66.0 → 26.68.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 (109) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/CONTRIBUTING.md +3 -0
  3. package/dist/cjs/constants.js +1 -0
  4. package/dist/cjs/extractors/flexible/actions/extract-automation-action.js +53 -0
  5. package/dist/cjs/extractors/flexible/actions/index.js +2 -1
  6. package/dist/cjs/messages.js +50 -0
  7. package/dist/cjs/state/hooks/use-ai-summary/ai-summary-service/types.js +1 -1
  8. package/dist/cjs/state/hooks/use-ai-summary/index.js +3 -2
  9. package/dist/cjs/utils/ai-summary.js +4 -0
  10. package/dist/cjs/utils/analytics/analytics.js +1 -1
  11. package/dist/cjs/view/Card/types.js +1 -0
  12. package/dist/cjs/view/FlexibleCard/components/actions/action/action-stack-item/index.js +1 -0
  13. package/dist/cjs/view/FlexibleCard/components/actions/action/server-action/index.js +7 -5
  14. package/dist/cjs/view/FlexibleCard/components/actions/automation-action/index.js +57 -0
  15. package/dist/cjs/view/FlexibleCard/components/actions/automation-action/manaul-triggers-icon/index.js +31 -0
  16. package/dist/cjs/view/FlexibleCard/components/actions/follow-action/index.js +19 -8
  17. package/dist/cjs/view/FlexibleCard/components/actions/follow-action/utils.js +24 -0
  18. package/dist/cjs/view/FlexibleCard/components/actions/index.js +8 -1
  19. package/dist/cjs/view/FlexibleCard/components/blocks/ai-footer-block/resolved/ai-footer-metadata.js +7 -7
  20. package/dist/cjs/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +8 -3
  21. package/dist/cjs/view/HoverCard/components/HoverCardContent.js +13 -0
  22. package/dist/cjs/view/HoverCard/components/views/resolved/index.js +3 -7
  23. package/dist/cjs/view/HoverCard/components/views/resolved/redesign.js +81 -0
  24. package/dist/cjs/view/LinkUrl/index.js +1 -1
  25. package/dist/es2019/constants.js +1 -0
  26. package/dist/es2019/extractors/flexible/actions/extract-automation-action.js +48 -0
  27. package/dist/es2019/extractors/flexible/actions/index.js +2 -0
  28. package/dist/es2019/messages.js +50 -0
  29. package/dist/es2019/state/flexible-ui-context/types.js +3 -1
  30. package/dist/es2019/state/hooks/use-ai-summary/ai-summary-service/types.js +1 -1
  31. package/dist/es2019/state/hooks/use-ai-summary/index.js +3 -2
  32. package/dist/es2019/utils/ai-summary.js +4 -0
  33. package/dist/es2019/utils/analytics/analytics.js +1 -1
  34. package/dist/es2019/view/Card/types.js +1 -0
  35. package/dist/es2019/view/FlexibleCard/components/actions/action/action-stack-item/index.js +1 -0
  36. package/dist/es2019/view/FlexibleCard/components/actions/action/server-action/index.js +3 -1
  37. package/dist/es2019/view/FlexibleCard/components/actions/automation-action/index.js +42 -0
  38. package/dist/es2019/view/FlexibleCard/components/actions/automation-action/manaul-triggers-icon/index.js +23 -0
  39. package/dist/es2019/view/FlexibleCard/components/actions/follow-action/index.js +19 -5
  40. package/dist/es2019/view/FlexibleCard/components/actions/follow-action/utils.js +16 -0
  41. package/dist/es2019/view/FlexibleCard/components/actions/index.js +2 -1
  42. package/dist/es2019/view/FlexibleCard/components/blocks/ai-footer-block/resolved/ai-footer-metadata.js +7 -7
  43. package/dist/es2019/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +8 -3
  44. package/dist/es2019/view/HoverCard/components/HoverCardContent.js +13 -0
  45. package/dist/es2019/view/HoverCard/components/views/resolved/index.js +4 -8
  46. package/dist/es2019/view/HoverCard/components/views/resolved/redesign.js +73 -0
  47. package/dist/es2019/view/LinkUrl/index.js +1 -1
  48. package/dist/esm/constants.js +1 -0
  49. package/dist/esm/extractors/flexible/actions/extract-automation-action.js +46 -0
  50. package/dist/esm/extractors/flexible/actions/index.js +2 -1
  51. package/dist/esm/messages.js +50 -0
  52. package/dist/esm/state/flexible-ui-context/types.js +3 -1
  53. package/dist/esm/state/hooks/use-ai-summary/ai-summary-service/types.js +1 -1
  54. package/dist/esm/state/hooks/use-ai-summary/index.js +3 -2
  55. package/dist/esm/utils/ai-summary.js +4 -0
  56. package/dist/esm/utils/analytics/analytics.js +1 -1
  57. package/dist/esm/view/Card/types.js +1 -0
  58. package/dist/esm/view/FlexibleCard/components/actions/action/action-stack-item/index.js +1 -0
  59. package/dist/esm/view/FlexibleCard/components/actions/action/server-action/index.js +7 -5
  60. package/dist/esm/view/FlexibleCard/components/actions/automation-action/index.js +47 -0
  61. package/dist/esm/view/FlexibleCard/components/actions/automation-action/manaul-triggers-icon/index.js +24 -0
  62. package/dist/esm/view/FlexibleCard/components/actions/follow-action/index.js +19 -8
  63. package/dist/esm/view/FlexibleCard/components/actions/follow-action/utils.js +18 -0
  64. package/dist/esm/view/FlexibleCard/components/actions/index.js +2 -1
  65. package/dist/esm/view/FlexibleCard/components/blocks/ai-footer-block/resolved/ai-footer-metadata.js +7 -7
  66. package/dist/esm/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +8 -3
  67. package/dist/esm/view/HoverCard/components/HoverCardContent.js +13 -0
  68. package/dist/esm/view/HoverCard/components/views/resolved/index.js +4 -8
  69. package/dist/esm/view/HoverCard/components/views/resolved/redesign.js +71 -0
  70. package/dist/esm/view/LinkUrl/index.js +1 -1
  71. package/dist/types/__fixtures__/flexible-ui-data-context.d.ts +1 -1
  72. package/dist/types/constants.d.ts +1 -0
  73. package/dist/types/extractors/flexible/actions/extract-automation-action.d.ts +3 -0
  74. package/dist/types/extractors/flexible/actions/index.d.ts +1 -1
  75. package/dist/types/messages.d.ts +1 -1
  76. package/dist/types/state/flexible-ui-context/types.d.ts +12 -0
  77. package/dist/types/state/hooks/use-ai-summary/ai-summary-service/types.d.ts +1 -1
  78. package/dist/types/view/Card/types.d.ts +2 -1
  79. package/dist/types/view/FlexibleCard/components/actions/action/server-action/index.d.ts +3 -3
  80. package/dist/types/view/FlexibleCard/components/actions/action/server-action/types.d.ts +4 -3
  81. package/dist/types/view/FlexibleCard/components/actions/automation-action/index.d.ts +4 -0
  82. package/dist/types/view/FlexibleCard/components/actions/automation-action/manaul-triggers-icon/index.d.ts +5 -0
  83. package/dist/types/view/FlexibleCard/components/actions/follow-action/index.d.ts +2 -2
  84. package/dist/types/view/FlexibleCard/components/actions/follow-action/utils.d.ts +2 -0
  85. package/dist/types/view/FlexibleCard/components/actions/index.d.ts +1 -0
  86. package/dist/types/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.d.ts +1 -1
  87. package/dist/types/view/FlexibleCard/components/blocks/ai-summary-block/types.d.ts +7 -2
  88. package/dist/types/view/FlexibleCard/components/blocks/types.d.ts +5 -5
  89. package/dist/types/view/HoverCard/components/views/resolved/redesign.d.ts +4 -0
  90. package/dist/types-ts4.5/__fixtures__/flexible-ui-data-context.d.ts +1 -1
  91. package/dist/types-ts4.5/constants.d.ts +1 -0
  92. package/dist/types-ts4.5/extractors/flexible/actions/extract-automation-action.d.ts +3 -0
  93. package/dist/types-ts4.5/extractors/flexible/actions/index.d.ts +1 -1
  94. package/dist/types-ts4.5/messages.d.ts +1 -1
  95. package/dist/types-ts4.5/state/flexible-ui-context/types.d.ts +12 -0
  96. package/dist/types-ts4.5/state/hooks/use-ai-summary/ai-summary-service/types.d.ts +2 -1
  97. package/dist/types-ts4.5/view/Card/types.d.ts +2 -1
  98. package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/server-action/index.d.ts +3 -3
  99. package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/server-action/types.d.ts +4 -3
  100. package/dist/types-ts4.5/view/FlexibleCard/components/actions/automation-action/index.d.ts +4 -0
  101. package/dist/types-ts4.5/view/FlexibleCard/components/actions/automation-action/manaul-triggers-icon/index.d.ts +5 -0
  102. package/dist/types-ts4.5/view/FlexibleCard/components/actions/follow-action/index.d.ts +2 -2
  103. package/dist/types-ts4.5/view/FlexibleCard/components/actions/follow-action/utils.d.ts +2 -0
  104. package/dist/types-ts4.5/view/FlexibleCard/components/actions/index.d.ts +1 -0
  105. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.d.ts +1 -1
  106. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/ai-summary-block/types.d.ts +7 -2
  107. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/types.d.ts +5 -5
  108. package/dist/types-ts4.5/view/HoverCard/components/views/resolved/redesign.d.ts +4 -0
  109. package/package.json +6 -3
@@ -86,7 +86,7 @@ var ConnectedAIBlock = function ConnectedAIBlock(_ref) {
86
86
  return showData ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, !imagePreview && /*#__PURE__*/_react.default.createElement(_blocks.SnippetBlock, {
87
87
  testId: 'connected-AI',
88
88
  status: _constants.SmartLinkStatus.Resolved
89
- }), !(0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-card.hover-card-action-redesign') && /*#__PURE__*/_react.default.createElement(_blocks.MetadataBlock, {
89
+ }), /*#__PURE__*/_react.default.createElement(_blocks.MetadataBlock, {
90
90
  primary: bottomPrimary,
91
91
  size: _constants.SmartLinkSize.Large,
92
92
  overrideCss: _styled.metadataBlockCss,
@@ -145,7 +145,6 @@ var HoverCardResolvedView = function HoverCardResolvedView(_ref2) {
145
145
  data: data,
146
146
  fallbackElementHeight: snippetHeight.current
147
147
  });
148
- var isActionBlockEnabled = (0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-card.hover-card-action-redesign') ? true : false;
149
148
  return /*#__PURE__*/_react.default.createElement(_FlexibleCard.default, flexibleCardProps, imagePreview, /*#__PURE__*/_react.default.createElement(_blocks.TitleBlock, (0, _extends2.default)({}, titleBlockProps, {
150
149
  metadataPosition: _constants.SmartLinkPosition.Top
151
150
  })), /*#__PURE__*/_react.default.createElement(_blocks.MetadataBlock, {
@@ -173,7 +172,7 @@ var HoverCardResolvedView = function HoverCardResolvedView(_ref2) {
173
172
  onRender: onSnippetRender,
174
173
  blockRef: snippetBlockRef,
175
174
  overrideCss: _styled.hiddenSnippetStyles
176
- }), !isAISummaryEnabled && !isActionBlockEnabled && /*#__PURE__*/_react.default.createElement(_blocks.MetadataBlock, {
175
+ }), !isAISummaryEnabled && /*#__PURE__*/_react.default.createElement(_blocks.MetadataBlock, {
177
176
  primary: tertiary,
178
177
  size: _constants.SmartLinkSize.Large,
179
178
  overrideCss: _styled.metadataBlockCss,
@@ -188,10 +187,7 @@ var HoverCardResolvedView = function HoverCardResolvedView(_ref2) {
188
187
  }],
189
188
  actions: footerActions,
190
189
  aiSummaryMinHeight: connectedAIBlockHeight.current
191
- }), isActionBlockEnabled && /*#__PURE__*/_react.default.createElement(_blocks.ActionBlock, {
192
- onClick: onActionClick,
193
- spaceInline: "space.100"
194
- }), isActionBlockEnabled && /*#__PURE__*/_react.default.createElement(_blocks.AIFooterBlock, null), !isAISummaryEnabled && !isActionBlockEnabled && /*#__PURE__*/_react.default.createElement(_blocks.FooterBlock, {
190
+ }), !isAISummaryEnabled && /*#__PURE__*/_react.default.createElement(_blocks.FooterBlock, {
195
191
  actions: footerActions,
196
192
  size: _constants.SmartLinkSize.Large,
197
193
  overrideCss: _styled.footerBlockCss
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
+ var _react = _interopRequireWildcard(require("react"));
11
+ var _constants = require("../../../../../constants");
12
+ var _helpers = require("../../../../../state/helpers");
13
+ var _FlexibleCard = _interopRequireDefault(require("../../../../FlexibleCard"));
14
+ var _blocks = require("../../../../FlexibleCard/components/blocks");
15
+ var _utils = require("../../../utils");
16
+ var _ImagePreview = _interopRequireDefault(require("../../ImagePreview"));
17
+ var _styled = require("./styled");
18
+ 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); }
19
+ 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; }
20
+ var HoverCardResolvedView = function HoverCardResolvedView(_ref) {
21
+ var _cardState$details;
22
+ var analytics = _ref.analytics,
23
+ cardState = _ref.cardState,
24
+ extensionKey = _ref.extensionKey,
25
+ flexibleCardProps = _ref.flexibleCardProps,
26
+ isAISummaryEnabled = _ref.isAISummaryEnabled,
27
+ onActionClick = _ref.onActionClick,
28
+ titleBlockProps = _ref.titleBlockProps;
29
+ var canBeDatasource = (0, _helpers.getCanBeDatasource)(cardState.details);
30
+ (0, _react.useEffect)(function () {
31
+ // Since this hover view is only rendered on resolved status,
32
+ // there is no need to check for statuses.
33
+ analytics.ui.renderSuccessEvent({
34
+ display: _constants.CardDisplay.HoverCardPreview,
35
+ status: cardState.status,
36
+ canBeDatasource: canBeDatasource
37
+ });
38
+ }, [analytics.ui, cardState.status, canBeDatasource]);
39
+ var data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
40
+ var _useMemo = (0, _react.useMemo)(function () {
41
+ return (0, _utils.getMetadata)(extensionKey, data);
42
+ }, [data, extensionKey]),
43
+ primary = _useMemo.primary,
44
+ secondary = _useMemo.secondary;
45
+ var snippetHeight = _react.default.useRef(0);
46
+ var snippetBlockRef = (0, _react.useRef)(null);
47
+ var onSnippetRender = (0, _react.useCallback)(function () {
48
+ var _snippetBlockRef$curr, _snippetBlockRef$curr2;
49
+ snippetHeight.current = (_snippetBlockRef$curr = (_snippetBlockRef$curr2 = snippetBlockRef.current) === null || _snippetBlockRef$curr2 === void 0 ? void 0 : _snippetBlockRef$curr2.getBoundingClientRect().height) !== null && _snippetBlockRef$curr !== void 0 ? _snippetBlockRef$curr : 0;
50
+ }, []);
51
+ var imagePreview = (0, _ImagePreview.default)({
52
+ data: data,
53
+ fallbackElementHeight: snippetHeight.current
54
+ });
55
+ var snippet = imagePreview ? null : /*#__PURE__*/_react.default.createElement(_blocks.SnippetBlock, {
56
+ status: _constants.SmartLinkStatus.Resolved
57
+ });
58
+ var aiSummaryMinHeight = snippet ? snippetHeight.current : 0;
59
+ return /*#__PURE__*/_react.default.createElement(_FlexibleCard.default, flexibleCardProps, imagePreview, /*#__PURE__*/_react.default.createElement(_blocks.TitleBlock, (0, _extends2.default)({}, titleBlockProps, {
60
+ metadataPosition: _constants.SmartLinkPosition.Top
61
+ })), /*#__PURE__*/_react.default.createElement(_blocks.MetadataBlock, {
62
+ primary: primary,
63
+ secondary: secondary,
64
+ overrideCss: _styled.metadataBlockCss,
65
+ maxLines: 1,
66
+ size: _constants.SmartLinkSize.Medium
67
+ }), isAISummaryEnabled ? /*#__PURE__*/_react.default.createElement(_blocks.AISummaryBlock, {
68
+ aiSummaryMinHeight: aiSummaryMinHeight,
69
+ placeholder: snippet,
70
+ status: _constants.SmartLinkStatus.Resolved
71
+ }) : snippet, /*#__PURE__*/_react.default.createElement(_blocks.SnippetBlock, {
72
+ testId: "hidden-snippet",
73
+ onRender: onSnippetRender,
74
+ blockRef: snippetBlockRef,
75
+ overrideCss: _styled.hiddenSnippetStyles
76
+ }), /*#__PURE__*/_react.default.createElement(_blocks.ActionBlock, {
77
+ onClick: onActionClick,
78
+ spaceInline: "space.100"
79
+ }), /*#__PURE__*/_react.default.createElement(_blocks.AIFooterBlock, null));
80
+ };
81
+ var _default = exports.default = HoverCardResolvedView;
@@ -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.66.0",
20
+ packageVersion: "26.68.0",
21
21
  componentName: 'linkUrl'
22
22
  };
23
23
  var Link = (0, _click.withLinkClickedEvent)('a');
@@ -150,6 +150,7 @@ export let ActionName = /*#__PURE__*/function (ActionName) {
150
150
  ActionName["EditAction"] = "EditAction";
151
151
  ActionName["FollowAction"] = "FollowAction";
152
152
  ActionName["PreviewAction"] = "PreviewAction";
153
+ ActionName["AutomationAction"] = "AutomationAction";
153
154
  ActionName["ViewAction"] = "ViewAction";
154
155
  ActionName["DownloadAction"] = "DownloadAction";
155
156
  ActionName["CustomAction"] = "CustomAction";
@@ -0,0 +1,48 @@
1
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
2
+ import { messages } from '../../../messages';
3
+ // This action will not be enabled by default for smart cards, which is opposite of the default behavior for actions.
4
+ // The AutomationAction will only appear if product/resourceType combination is handled by this function.
5
+ const getProductData = meta => {
6
+ var _ProductData$product;
7
+ const {
8
+ tenantId
9
+ } = meta;
10
+ const product = meta.product;
11
+ const resourceType = meta.resourceType;
12
+ const ProductData = {
13
+ 'confluence': {
14
+ 'page': {
15
+ //TODO extract to server
16
+ siteAri: `ari:cloud:confluence::site/${tenantId}`,
17
+ //TODO Move to AutomationAction
18
+ modalTitle: messages.automation_action_confluence_page_modal_title,
19
+ modalDescription: messages.automation_action_confluence_page_modal_description
20
+ }
21
+ }
22
+ };
23
+ return ProductData === null || ProductData === void 0 ? void 0 : (_ProductData$product = ProductData[product]) === null || _ProductData$product === void 0 ? void 0 : _ProductData$product[resourceType];
24
+ };
25
+ export const extractAutomationAction = response => {
26
+ if (!getBooleanFF('platform.linking-platfom.smart-card.confluence.page.automation-action') || !response.data) {
27
+ return undefined;
28
+ }
29
+ const data = response.data;
30
+ const meta = response.meta;
31
+ const {
32
+ name,
33
+ "atlassian:ari": objectAri
34
+ } = data;
35
+ const productData = getProductData(meta);
36
+ if (!productData) {
37
+ return undefined;
38
+ }
39
+ return {
40
+ ...productData,
41
+ objectName: name,
42
+ objectAri: objectAri,
43
+ // TODO: The admin experience will be a follow up
44
+ canManageAutomation: false,
45
+ baseAutomationUrl: '',
46
+ analyticsSource: 'smartCard'
47
+ };
48
+ };
@@ -4,6 +4,7 @@ import { extractPreviewAction } from './extract-preview-action';
4
4
  import { extractAISummaryAction } from './extract-ai-summary-action';
5
5
  import extractFollowAction from './extract-follow-action';
6
6
  import { extractCopyLinkAction } from './extract-copy-link-action';
7
+ import { extractAutomationAction } from './extract-automation-action';
7
8
  const extractActions = (response, url, actionOptions, id, aiSummaryConfig) => {
8
9
  const data = response.data;
9
10
  const action = {
@@ -11,6 +12,7 @@ const extractActions = (response, url, actionOptions, id, aiSummaryConfig) => {
11
12
  [ActionName.DownloadAction]: extractDownloadAction(data, actionOptions),
12
13
  [ActionName.FollowAction]: extractFollowAction(response, actionOptions, id),
13
14
  [ActionName.PreviewAction]: extractPreviewAction(response, actionOptions),
15
+ [ActionName.AutomationAction]: extractAutomationAction(response),
14
16
  [InternalActionName.AISummaryAction]: extractAISummaryAction(response, url, actionOptions, aiSummaryConfig)
15
17
  };
16
18
  return Object.values(action).some(value => Boolean(value)) ? action : undefined;
@@ -55,11 +55,41 @@ export const messages = defineMessages({
55
55
  defaultMessage: 'Atlassian Intelligence was unable to process your request as your content contains links to HIPAA restricted content.',
56
56
  description: 'Shown when the AI summary is summarising the link resource content and the content contains HIPAA restricted content.'
57
57
  },
58
+ ai_summary_error_exceeding_context_length_error: {
59
+ id: 'fabric.linking.ai_summary_error_exceeding_context_length_error',
60
+ defaultMessage: "Atlassian Intelligence can't generate a summary for you right now as there is too much content to summarize.",
61
+ description: 'Shown when the AI summary is summarising the link resource content and the content is too large to summarize.'
62
+ },
58
63
  assigned_to: {
59
64
  id: 'fabric.linking.assigned_to',
60
65
  defaultMessage: 'Assigned to {context}',
61
66
  description: 'Indicates the person or entity that the resource is assigned to.'
62
67
  },
68
+ automation_action_title: {
69
+ id: 'fabric.linking.automation-action.title',
70
+ defaultMessage: 'Run automation...',
71
+ description: 'The title of the button in a hover card to open an automation menu for a given SmartLink.'
72
+ },
73
+ automation_action_icon_label: {
74
+ id: 'fabric.linking.automation-action.icon.label',
75
+ defaultMessage: 'Automation icon',
76
+ description: 'The label for the automation icon inside of the button opening the automation menu.'
77
+ },
78
+ automation_action_tooltip: {
79
+ id: 'fabric.linking.automation-action.tooltip',
80
+ defaultMessage: 'Open an automation modal',
81
+ description: 'The tooltip for the automation action indicating that a button will open an automation modal.'
82
+ },
83
+ automation_action_confluence_page_modal_title: {
84
+ id: 'fabric.linking.automation-action.confluence.page.modal.title',
85
+ defaultMessage: 'Page automations',
86
+ description: 'The title of the automation modal when the SmartLink is a Confluence page'
87
+ },
88
+ automation_action_confluence_page_modal_description: {
89
+ id: 'fabric.linking.automation-action.confluence.page.modal.description',
90
+ defaultMessage: 'Apply an automation to <b>{name}</b>.{br}The available selections are controlled by Confluence and space administrators.',
91
+ description: 'The description in the automation modal when the SmartLink is a Confluence page. Indicating which page the automation will apply to, and who controls the available automations.'
92
+ },
63
93
  cancel: {
64
94
  id: 'fabric.linking.cancel',
65
95
  defaultMessage: 'Cancel',
@@ -245,6 +275,11 @@ export const messages = defineMessages({
245
275
  defaultMessage: 'Follow project',
246
276
  description: 'Click to follow a project.'
247
277
  },
278
+ follow_project_error: {
279
+ id: 'fabric.linking.follow_project_error.nonfinal',
280
+ defaultMessage: 'We encountered an error while trying to follow the project. Check your connection or refresh the page and try again.',
281
+ description: 'Shown when an unknown error occurs when following an Atlas project'
282
+ },
248
283
  follow_goal_description: {
249
284
  id: 'fabric.linking.follow_goal_description.nonfinal',
250
285
  defaultMessage: 'Follow this goal to get notifications on updates',
@@ -255,6 +290,11 @@ export const messages = defineMessages({
255
290
  defaultMessage: 'Follow goal',
256
291
  description: 'Click to follow a project.'
257
292
  },
293
+ follow_goal_error: {
294
+ id: 'fabric.linking.follow_goal_error.nonfinal',
295
+ defaultMessage: 'We encountered an error while trying to follow the goal. Check your connection or refresh the page and try again.',
296
+ description: 'Shown when an unknown error occurs when following an Atlas goal'
297
+ },
258
298
  go_back: {
259
299
  id: 'fabric.linking.go_back',
260
300
  defaultMessage: 'Go back',
@@ -525,6 +565,11 @@ export const messages = defineMessages({
525
565
  defaultMessage: 'Unfollow project',
526
566
  description: 'Click to unfollow a project.'
527
567
  },
568
+ unfollow_project_error: {
569
+ id: 'fabric.linking.unfollow_project_error.nonfinal',
570
+ defaultMessage: 'We encountered an error while trying to unfollow the project. Check your connection or refresh the page and try again.',
571
+ description: 'Shown when an unknown error occurs when unfollowing an Atlas project'
572
+ },
528
573
  unfollow_goal_description: {
529
574
  id: 'fabric.linking.unfollow_goal_description.nonfinal',
530
575
  defaultMessage: 'Unfollow to stop receiving notifications for this goal',
@@ -535,6 +580,11 @@ export const messages = defineMessages({
535
580
  defaultMessage: 'Unfollow goal',
536
581
  description: 'Click to unfollow a project.'
537
582
  },
583
+ unfollow_goal_error: {
584
+ id: 'fabric.linking.unfollow_goal_error.nonfinal',
585
+ defaultMessage: 'We encountered an error while trying to unfollow the goal. Check your connection or refresh the page and try again.',
586
+ description: 'Shown when an unknown error occurs when unfollowing an Atlas goal'
587
+ },
538
588
  unlink_account: {
539
589
  id: 'fabric.linking.unlink_account',
540
590
  defaultMessage: 'Unlink Account',
@@ -3,4 +3,6 @@ import { ActionName, InternalActionName } from '../../constants';
3
3
  /**
4
4
  * This provides the data that will be used by Smart Links Flexible UI to populate it's
5
5
  * underlying elements.
6
- */
6
+ */
7
+
8
+ // TODO: types more specific once modal is implemented
@@ -1 +1 @@
1
- export const errorMessages = ['NETWORK_ERROR', 'NO_ANSWER', 'RATE_LIMIT', 'NO_AGENT', 'PLUGIN_ERRORED', 'OPENAI_RATE_LIMIT_USER_ABUSE', 'ACCEPTABLE_USE_VIOLATIONS', 'AI_DISABLED', 'UNEXPECTED', 'HIPAA_CONTENT_DETECTED'];
1
+ export const errorMessages = ['NETWORK_ERROR', 'NO_ANSWER', 'RATE_LIMIT', 'NO_AGENT', 'PLUGIN_ERRORED', 'OPENAI_RATE_LIMIT_USER_ABUSE', 'ACCEPTABLE_USE_VIOLATIONS', 'AI_DISABLED', 'UNEXPECTED', 'HIPAA_CONTENT_DETECTED', 'EXCEEDING_CONTEXT_LENGTH_ERROR'];
@@ -31,9 +31,10 @@ export const useAISummary = props => {
31
31
  const onError = useCallback((id, reason) => {
32
32
  /**
33
33
  * Errors should only be counted to the SLO if they are not due to acceptable use violations
34
- * or HIPAA content detected.
34
+ * HIPAA content detected or exceeding context length.
35
35
  */
36
- const isSloError = reason !== "ACCEPTABLE_USE_VIOLATIONS" && reason !== "HIPAA_CONTENT_DETECTED";
36
+
37
+ const isSloError = reason === undefined ? true : !['ACCEPTABLE_USE_VIOLATIONS', 'HIPAA_CONTENT_DETECTED', 'EXCEEDING_CONTEXT_LENGTH_ERROR'].includes(reason);
37
38
  fireEvent('operational.summary.failed', {
38
39
  reason: reason || null,
39
40
  isSloError
@@ -16,6 +16,10 @@ export const getAISummaryErrorMessage = error => {
16
16
  return {
17
17
  message: messages.ai_summary_error_hipaa_content_detected
18
18
  };
19
+ case 'EXCEEDING_CONTEXT_LENGTH_ERROR':
20
+ return {
21
+ message: messages.ai_summary_error_exceeding_context_length_error
22
+ };
19
23
  default:
20
24
  return {
21
25
  message: messages.ai_summary_error_generic,
@@ -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.66.0"
7
+ packageVersion: "26.68.0"
8
8
  };
9
9
  export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
10
10
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -6,5 +6,6 @@ export let CardAction = /*#__PURE__*/function (CardAction) {
6
6
  CardAction["FollowAction"] = "FollowAction";
7
7
  CardAction["CopyLinkAction"] = "CopyLinkAction";
8
8
  CardAction["AISummaryAction"] = "AISummaryAction";
9
+ CardAction["AutomationAction"] = "AutomationAction";
9
10
  return CardAction;
10
11
  }({});
@@ -7,6 +7,7 @@ import { getPrimitivesInlineSpaceBySize } from '../../../utils';
7
7
  import ActionIcon from '../action-icon';
8
8
  const buttonStyles = xcss({
9
9
  all: 'unset',
10
+ cursor: 'pointer',
10
11
  padding: 'space.050',
11
12
  width: '100%',
12
13
  ':focus:not(:focus-visible)': {
@@ -9,6 +9,7 @@ import { useFlexibleUiAnalyticsContext } from '../../../../../../state/flexible-
9
9
  const ServerAction = ({
10
10
  action,
11
11
  onClick,
12
+ onError: onErrorCallback,
12
13
  ...props
13
14
  }) => {
14
15
  const [isLoading, setIsLoading] = useState(false);
@@ -45,9 +46,10 @@ const ServerAction = ({
45
46
  smartLinkActionType,
46
47
  reason: getInvokeFailureReason(err)
47
48
  });
49
+ onErrorCallback === null || onErrorCallback === void 0 ? void 0 : onErrorCallback();
48
50
  }
49
51
  }
50
- }, [action, analytics === null || analytics === void 0 ? void 0 : analytics.track, analytics === null || analytics === void 0 ? void 0 : analytics.ui, invoke, onClick, reload]);
52
+ }, [action, analytics === null || analytics === void 0 ? void 0 : analytics.track, analytics === null || analytics === void 0 ? void 0 : analytics.ui, invoke, onClick, onErrorCallback, reload]);
51
53
  return /*#__PURE__*/React.createElement(Action, _extends({}, props, {
52
54
  isLoading: isLoading,
53
55
  onClick: handleClick
@@ -0,0 +1,42 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React, { useState } from 'react';
3
+ import { FormattedMessage, useIntl } from 'react-intl-next';
4
+ import AutomationManualTriggersGlyph from './manaul-triggers-icon';
5
+ import Action from '../action';
6
+ import { useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
7
+ import { ActionName } from '../../../../../constants';
8
+ import { messages } from '../../../../../messages';
9
+ // import { useSmartLinkContext } from '../../../../../../../link-provider/src';
10
+
11
+ const handleAutomateActionClick = setIsModalOpen => {
12
+ setIsModalOpen(true);
13
+ };
14
+ const AutomationAction = props => {
15
+ var _context$actions;
16
+ const [_isModalOpen, setIsModalOpen] = useState(false);
17
+ const {
18
+ formatMessage
19
+ } = useIntl();
20
+ // const { connections } = useSmartLinkContext();
21
+
22
+ // const env = connections.client.envKey ?? 'prod';
23
+ const context = useFlexibleUiContext();
24
+ const data = context === null || context === void 0 ? void 0 : (_context$actions = context.actions) === null || _context$actions === void 0 ? void 0 : _context$actions[ActionName.AutomationAction];
25
+ if (!data) {
26
+ return null;
27
+ }
28
+ const automationActionTitle = /*#__PURE__*/React.createElement(FormattedMessage, messages.automation_action_title);
29
+ const automationActionTooltip = /*#__PURE__*/React.createElement(FormattedMessage, messages.automation_action_tooltip);
30
+ const automationActionIconLabel = formatMessage(messages.automation_action_icon_label);
31
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Action, _extends({
32
+ content: automationActionTitle,
33
+ icon: /*#__PURE__*/React.createElement(AutomationManualTriggersGlyph, {
34
+ label: automationActionIconLabel
35
+ }),
36
+ testId: "smart-action-automation-action",
37
+ tooltipMessage: automationActionTooltip
38
+ }, data, props, {
39
+ onClick: () => handleAutomateActionClick(setIsModalOpen)
40
+ })));
41
+ };
42
+ export default AutomationAction;
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ const AutomationManualTriggersGlyph = ({
3
+ label
4
+ }) => /*#__PURE__*/React.createElement("svg", {
5
+ "aria-label": label,
6
+ width: "24",
7
+ height: "24",
8
+ viewBox: "0 0 24 24",
9
+ fill: "none",
10
+ xmlns: "http://www.w3.org/2000/svg"
11
+ }, /*#__PURE__*/React.createElement("path", {
12
+ d: "M14 5L10 19",
13
+ stroke: "currentColor",
14
+ strokeWidth: "2",
15
+ strokeLinecap: "round"
16
+ }), /*#__PURE__*/React.createElement("path", {
17
+ d: "M14 5L7 12H17L10 19",
18
+ stroke: "currentColor",
19
+ strokeWidth: "2",
20
+ strokeLinecap: "round",
21
+ strokeLinejoin: "round"
22
+ }));
23
+ export default AutomationManualTriggersGlyph;
@@ -9,6 +9,7 @@ import { useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
9
9
  import ServerAction from '../action/server-action';
10
10
  import UnfollowIcon from './unfollow-icon';
11
11
  import { importIcon } from '../../utils';
12
+ import { getFollowActionErrorMessage } from './utils';
12
13
  const importIconMapper = {
13
14
  goal: () => import( /* webpackChunkName: "glyphGoal" */'./goal-icon').then(({
14
15
  GoalIcon
@@ -37,17 +38,18 @@ const getIconFF = (iconFFEnabled, defaultIcon) => {
37
38
  return defaultIcon;
38
39
  };
39
40
  const FollowAction = props => {
40
- var _context$actions, _context$actions2;
41
+ var _context$actions;
41
42
  const context = useFlexibleUiContext();
42
- if (!context || !(context !== null && context !== void 0 && (_context$actions = context.actions) !== null && _context$actions !== void 0 && _context$actions[ActionName.FollowAction])) {
43
+ const actionData = context === null || context === void 0 ? void 0 : (_context$actions = context.actions) === null || _context$actions === void 0 ? void 0 : _context$actions[ActionName.FollowAction];
44
+ if (!context || !actionData) {
43
45
  return null;
44
46
  }
45
47
  const {
46
48
  value,
49
+ isProject,
47
50
  ...data
48
- } = context === null || context === void 0 ? void 0 : (_context$actions2 = context.actions) === null || _context$actions2 === void 0 ? void 0 : _context$actions2[ActionName.FollowAction];
51
+ } = actionData;
49
52
  const isStackItem = props.as === 'stack-item';
50
- const isProject = data.isProject;
51
53
  const message = value ? messages.follow : messages.unfollow;
52
54
  const projectMessage = value ? messages.follow_project : messages.unfollow_project;
53
55
  const goalMessage = value ? messages.follow_goal : messages.unfollow_goal;
@@ -69,11 +71,23 @@ const FollowAction = props => {
69
71
  testId: `smart-action-follow-action-${stackIconType}-icon`
70
72
  });
71
73
  const followIcon = isStackItem ? stackIcon : getIconFF(stackIcon, icon);
74
+ const handleError = () => {
75
+ const {
76
+ onError: onErrorCallback
77
+ } = props;
78
+ const errorMessage = getFollowActionErrorMessage(isProject, value);
79
+ onErrorCallback === null || onErrorCallback === void 0 ? void 0 : onErrorCallback({
80
+ title: /*#__PURE__*/React.createElement(FormattedMessage, errorMessage),
81
+ appearance: 'error'
82
+ });
83
+ };
72
84
  return /*#__PURE__*/React.createElement(ServerAction, _extends({
73
85
  content: /*#__PURE__*/React.createElement(FormattedMessage, label),
74
86
  icon: followIcon,
75
87
  testId: "smart-action-follow-action",
76
88
  tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, tooltipMessage)
77
- }, data, props));
89
+ }, data, props, {
90
+ onError: handleError
91
+ }));
78
92
  };
79
93
  export default FollowAction;
@@ -0,0 +1,16 @@
1
+ import { messages } from '../../../../../messages';
2
+ export const getFollowActionErrorMessage = (isProject = false, isFollow = false) => {
3
+ if (isProject && isFollow) {
4
+ return messages.follow_project_error;
5
+ }
6
+ if (isProject && !isFollow) {
7
+ return messages.unfollow_project_error;
8
+ }
9
+ if (!isProject && isFollow) {
10
+ return messages.follow_goal_error;
11
+ }
12
+ if (!isProject && !isFollow) {
13
+ return messages.unfollow_goal_error;
14
+ }
15
+ return messages.generic_error_message;
16
+ };
@@ -5,4 +5,5 @@ 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
7
  export { default as CopyLinkAction } from './copy-link-action';
8
- export { default as AISummaryAction } from './ai-summary-action';
8
+ export { default as AISummaryAction } from './ai-summary-action';
9
+ export { default as AutomationAction } from './automation-action';
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
+ import Tooltip from '@atlaskit/tooltip';
2
3
  import { di } from 'react-magnetic-di';
3
4
  import { FormattedMessage } from 'react-intl-next';
4
- import Tooltip from '@atlaskit/tooltip';
5
5
  import { Box, Inline } from '@atlaskit/primitives';
6
- import AIStateIndicator from '../../ai-summary-block/ai-state-indicator';
6
+ import AIIcon from '../../../../../common/ai-icon';
7
7
  import { InfoIcon } from '../icons/info';
8
8
  import { messages } from '../../../../../../messages';
9
9
  import { useAISummary } from '../../../../../../state/hooks/use-ai-summary';
@@ -32,14 +32,14 @@ export const AIFooterMetadata = ({
32
32
  grow: "fill"
33
33
  }, /*#__PURE__*/React.createElement(Tooltip, {
34
34
  content: /*#__PURE__*/React.createElement(FormattedMessage, messages.ai_summarized_info_short),
35
- position: "top"
35
+ position: "bottom"
36
36
  }, tooltipProps => /*#__PURE__*/React.createElement(Box, tooltipProps, /*#__PURE__*/React.createElement(InfoIcon, {
37
37
  label: "Information",
38
38
  size: "small",
39
39
  primaryColor: "var(--ds-icon-subtle, #626F86)"
40
- }))), /*#__PURE__*/React.createElement(AIStateIndicator, {
41
- appearance: "icon-only",
42
- state: "done",
43
- testId: "ai-tooltip"
40
+ }))), /*#__PURE__*/React.createElement(AIIcon, {
41
+ label: "AI",
42
+ size: "small",
43
+ primaryColor: "var(--ds-icon-subtle, #626F86)"
44
44
  }));
45
45
  };
@@ -60,7 +60,8 @@ const AISummaryBlockResolvedView = props => {
60
60
  size = SmartLinkSize.Medium,
61
61
  testId,
62
62
  aiSummaryMinHeight = 0,
63
- metadata
63
+ metadata,
64
+ placeholder
64
65
  } = props;
65
66
  const {
66
67
  fireEvent
@@ -91,6 +92,7 @@ const AISummaryBlockResolvedView = props => {
91
92
  status === 'loading' && !!content;
92
93
  const isSummarisedOnMountRef = useRef(status === 'done');
93
94
  const isErroredOnMountRef = useRef(status === 'error');
95
+ const minHeight = getBooleanFF('platform.linking-platform.smart-card.hover-card-action-redesign') && isSummarisedOnMountRef.current ? 0 : aiSummaryMinHeight;
94
96
  useEffect(() => {
95
97
  // if the error was apparent on mount and the status is changed to loading we can
96
98
  // clear the initial error on mount state
@@ -133,6 +135,9 @@ const AISummaryBlockResolvedView = props => {
133
135
  });
134
136
  }
135
137
  }, [onActionMenuOpenChange]);
138
+ if (!showAISummary && getBooleanFF('platform.linking-platform.smart-card.hover-card-action-redesign')) {
139
+ return /*#__PURE__*/React.createElement(React.Fragment, null, placeholder);
140
+ }
136
141
  return /*#__PURE__*/React.createElement(Block, _extends({}, props, {
137
142
  direction: SmartLinkDirection.Vertical,
138
143
  testId: `${testId}-resolved-view`
@@ -146,12 +151,12 @@ const AISummaryBlockResolvedView = props => {
146
151
  }), status === 'done' && /*#__PURE__*/React.createElement(AIEventSummaryViewed, {
147
152
  fromCache: isSummarisedOnMountRef.current
148
153
  }), /*#__PURE__*/React.createElement(MotionWrapper, {
149
- minHeight: aiSummaryMinHeight,
154
+ minHeight: minHeight,
150
155
  show: showAISummary,
151
156
  showTransition: !isSummarisedOnMountRef.current
152
157
  }, /*#__PURE__*/React.createElement(AISummary, {
153
158
  testId: `${testId}-ai-summary`,
154
- minHeight: aiSummaryMinHeight,
159
+ minHeight: minHeight,
155
160
  content: content,
156
161
  showIcon: !getBooleanFF('platform.linking-platform.smart-card.hover-card-action-redesign') && isSummarisedOnMountRef.current
157
162
  })), !getBooleanFF('platform.linking-platform.smart-card.hover-card-action-redesign') && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Inline, {
@@ -14,6 +14,7 @@ import { getMetadata } from '../utils';
14
14
  import HoverCardLoadingView from './views/resolving';
15
15
  import HoverCardUnauthorisedView from './views/unauthorised';
16
16
  import HoverCardResolvedView from './views/resolved';
17
+ import HoverCardRedesignedResolvedView from './views/resolved/redesign';
17
18
  import { FormattedMessage } from 'react-intl-next';
18
19
  import { messages } from '../../../messages';
19
20
  import { fireLinkClickedEvent } from '../../../utils/analytics/click';
@@ -153,6 +154,18 @@ const HoverCardContent = ({
153
154
  });
154
155
  }
155
156
  if (cardState.status === 'resolved') {
157
+ if (getBooleanFF('platform.linking-platform.smart-card.hover-card-action-redesign')) {
158
+ return jsx(HoverCardRedesignedResolvedView, {
159
+ analytics: analytics,
160
+ cardState: cardState,
161
+ extensionKey: extensionKey,
162
+ flexibleCardProps: flexibleCardProps,
163
+ isAISummaryEnabled: isAISummaryEnabled,
164
+ onActionClick: onActionClick,
165
+ titleBlockProps: titleBlockProps,
166
+ url: url
167
+ });
168
+ }
156
169
  return jsx(HoverCardResolvedView, {
157
170
  id: id,
158
171
  url: url,