@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
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { useCallback, useEffect, useMemo, useRef } from 'react';
3
3
  import { ActionName, CardDisplay, ElementName, SmartLinkPosition, SmartLinkSize, SmartLinkDirection } from '../../../../../constants';
4
- import { FooterBlock, MetadataBlock, RelatedUrlsBlock, SnippetBlock, TitleBlock, AISummaryBlock, CustomBlock, ActionBlock, AIFooterBlock } from '../../../../FlexibleCard/components/blocks';
4
+ import { FooterBlock, MetadataBlock, RelatedUrlsBlock, SnippetBlock, TitleBlock, AISummaryBlock, CustomBlock } from '../../../../FlexibleCard/components/blocks';
5
5
  import { footerBlockCss, hiddenSnippetStyles, metadataBlockCss } from './styled';
6
6
  import FlexibleCard from '../../../../FlexibleCard';
7
7
  import { getMetadata } from '../../../utils';
@@ -80,7 +80,7 @@ const ConnectedAIBlock = ({
80
80
  return showData ? /*#__PURE__*/React.createElement(React.Fragment, null, !imagePreview && /*#__PURE__*/React.createElement(SnippetBlock, {
81
81
  testId: 'connected-AI',
82
82
  status: SmartLinkStatus.Resolved
83
- }), !getBooleanFF('platform.linking-platform.smart-card.hover-card-action-redesign') && /*#__PURE__*/React.createElement(MetadataBlock, {
83
+ }), /*#__PURE__*/React.createElement(MetadataBlock, {
84
84
  primary: bottomPrimary,
85
85
  size: SmartLinkSize.Large,
86
86
  overrideCss: metadataBlockCss,
@@ -138,7 +138,6 @@ const HoverCardResolvedView = ({
138
138
  data: data,
139
139
  fallbackElementHeight: snippetHeight.current
140
140
  });
141
- const isActionBlockEnabled = getBooleanFF('platform.linking-platform.smart-card.hover-card-action-redesign') ? true : false;
142
141
  return /*#__PURE__*/React.createElement(FlexibleCard, flexibleCardProps, imagePreview, /*#__PURE__*/React.createElement(TitleBlock, _extends({}, titleBlockProps, {
143
142
  metadataPosition: SmartLinkPosition.Top
144
143
  })), /*#__PURE__*/React.createElement(MetadataBlock, {
@@ -166,7 +165,7 @@ const HoverCardResolvedView = ({
166
165
  onRender: onSnippetRender,
167
166
  blockRef: snippetBlockRef,
168
167
  overrideCss: hiddenSnippetStyles
169
- }), !isAISummaryEnabled && !isActionBlockEnabled && /*#__PURE__*/React.createElement(MetadataBlock, {
168
+ }), !isAISummaryEnabled && /*#__PURE__*/React.createElement(MetadataBlock, {
170
169
  primary: tertiary,
171
170
  size: SmartLinkSize.Large,
172
171
  overrideCss: metadataBlockCss,
@@ -181,10 +180,7 @@ const HoverCardResolvedView = ({
181
180
  }],
182
181
  actions: footerActions,
183
182
  aiSummaryMinHeight: connectedAIBlockHeight.current
184
- }), isActionBlockEnabled && /*#__PURE__*/React.createElement(ActionBlock, {
185
- onClick: onActionClick,
186
- spaceInline: "space.100"
187
- }), isActionBlockEnabled && /*#__PURE__*/React.createElement(AIFooterBlock, null), !isAISummaryEnabled && !isActionBlockEnabled && /*#__PURE__*/React.createElement(FooterBlock, {
183
+ }), !isAISummaryEnabled && /*#__PURE__*/React.createElement(FooterBlock, {
188
184
  actions: footerActions,
189
185
  size: SmartLinkSize.Large,
190
186
  overrideCss: footerBlockCss
@@ -0,0 +1,73 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React, { useCallback, useEffect, useMemo, useRef } from 'react';
3
+ import { CardDisplay, SmartLinkPosition, SmartLinkSize, SmartLinkStatus } from '../../../../../constants';
4
+ import { getCanBeDatasource } from '../../../../../state/helpers';
5
+ import FlexibleCard from '../../../../FlexibleCard';
6
+ import { ActionBlock, AIFooterBlock, AISummaryBlock, MetadataBlock, SnippetBlock, TitleBlock } from '../../../../FlexibleCard/components/blocks';
7
+ import { getMetadata } from '../../../utils';
8
+ import ImagePreview from '../../ImagePreview';
9
+ import { hiddenSnippetStyles, metadataBlockCss } from './styled';
10
+ const HoverCardResolvedView = ({
11
+ analytics,
12
+ cardState,
13
+ extensionKey,
14
+ flexibleCardProps,
15
+ isAISummaryEnabled,
16
+ onActionClick,
17
+ titleBlockProps
18
+ }) => {
19
+ var _cardState$details;
20
+ const canBeDatasource = getCanBeDatasource(cardState.details);
21
+ useEffect(() => {
22
+ // Since this hover view is only rendered on resolved status,
23
+ // there is no need to check for statuses.
24
+ analytics.ui.renderSuccessEvent({
25
+ display: CardDisplay.HoverCardPreview,
26
+ status: cardState.status,
27
+ canBeDatasource
28
+ });
29
+ }, [analytics.ui, cardState.status, canBeDatasource]);
30
+ const data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
31
+ const {
32
+ primary,
33
+ secondary
34
+ } = useMemo(() => {
35
+ return getMetadata(extensionKey, data);
36
+ }, [data, extensionKey]);
37
+ const snippetHeight = React.useRef(0);
38
+ const snippetBlockRef = useRef(null);
39
+ const onSnippetRender = useCallback(() => {
40
+ var _snippetBlockRef$curr, _snippetBlockRef$curr2;
41
+ 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;
42
+ }, []);
43
+ const imagePreview = ImagePreview({
44
+ data: data,
45
+ fallbackElementHeight: snippetHeight.current
46
+ });
47
+ const snippet = imagePreview ? null : /*#__PURE__*/React.createElement(SnippetBlock, {
48
+ status: SmartLinkStatus.Resolved
49
+ });
50
+ const aiSummaryMinHeight = snippet ? snippetHeight.current : 0;
51
+ return /*#__PURE__*/React.createElement(FlexibleCard, flexibleCardProps, imagePreview, /*#__PURE__*/React.createElement(TitleBlock, _extends({}, titleBlockProps, {
52
+ metadataPosition: SmartLinkPosition.Top
53
+ })), /*#__PURE__*/React.createElement(MetadataBlock, {
54
+ primary: primary,
55
+ secondary: secondary,
56
+ overrideCss: metadataBlockCss,
57
+ maxLines: 1,
58
+ size: SmartLinkSize.Medium
59
+ }), isAISummaryEnabled ? /*#__PURE__*/React.createElement(AISummaryBlock, {
60
+ aiSummaryMinHeight: aiSummaryMinHeight,
61
+ placeholder: snippet,
62
+ status: SmartLinkStatus.Resolved
63
+ }) : snippet, /*#__PURE__*/React.createElement(SnippetBlock, {
64
+ testId: "hidden-snippet",
65
+ onRender: onSnippetRender,
66
+ blockRef: snippetBlockRef,
67
+ overrideCss: hiddenSnippetStyles
68
+ }), /*#__PURE__*/React.createElement(ActionBlock, {
69
+ onClick: onActionClick,
70
+ spaceInline: "space.100"
71
+ }), /*#__PURE__*/React.createElement(AIFooterBlock, null));
72
+ };
73
+ export default HoverCardResolvedView;
@@ -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.66.0",
10
+ packageVersion: "26.68.0",
11
11
  componentName: 'linkUrl'
12
12
  };
13
13
  const Link = withLinkClickedEvent('a');
@@ -150,6 +150,7 @@ export var 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,46 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
5
+ import { messages } from '../../../messages';
6
+ // This action will not be enabled by default for smart cards, which is opposite of the default behavior for actions.
7
+ // The AutomationAction will only appear if product/resourceType combination is handled by this function.
8
+ var getProductData = function getProductData(meta) {
9
+ var _ProductData$product;
10
+ var tenantId = meta.tenantId;
11
+ var product = meta.product;
12
+ var resourceType = meta.resourceType;
13
+ var ProductData = {
14
+ 'confluence': {
15
+ 'page': {
16
+ //TODO extract to server
17
+ siteAri: "ari:cloud:confluence::site/".concat(tenantId),
18
+ //TODO Move to AutomationAction
19
+ modalTitle: messages.automation_action_confluence_page_modal_title,
20
+ modalDescription: messages.automation_action_confluence_page_modal_description
21
+ }
22
+ }
23
+ };
24
+ return ProductData === null || ProductData === void 0 || (_ProductData$product = ProductData[product]) === null || _ProductData$product === void 0 ? void 0 : _ProductData$product[resourceType];
25
+ };
26
+ export var extractAutomationAction = function extractAutomationAction(response) {
27
+ if (!getBooleanFF('platform.linking-platfom.smart-card.confluence.page.automation-action') || !response.data) {
28
+ return undefined;
29
+ }
30
+ var data = response.data;
31
+ var meta = response.meta;
32
+ var name = data.name,
33
+ objectAri = data["atlassian:ari"];
34
+ var productData = getProductData(meta);
35
+ if (!productData) {
36
+ return undefined;
37
+ }
38
+ return _objectSpread(_objectSpread({}, productData), {}, {
39
+ objectName: name,
40
+ objectAri: objectAri,
41
+ // TODO: The admin experience will be a follow up
42
+ canManageAutomation: false,
43
+ baseAutomationUrl: '',
44
+ analyticsSource: 'smartCard'
45
+ });
46
+ };
@@ -5,10 +5,11 @@ import { extractPreviewAction } from './extract-preview-action';
5
5
  import { extractAISummaryAction } from './extract-ai-summary-action';
6
6
  import extractFollowAction from './extract-follow-action';
7
7
  import { extractCopyLinkAction } from './extract-copy-link-action';
8
+ import { extractAutomationAction } from './extract-automation-action';
8
9
  var extractActions = function extractActions(response, url, actionOptions, id, aiSummaryConfig) {
9
10
  var _action;
10
11
  var data = response.data;
11
- var action = (_action = {}, _defineProperty(_action, ActionName.CopyLinkAction, extractCopyLinkAction(data, actionOptions)), _defineProperty(_action, ActionName.DownloadAction, extractDownloadAction(data, actionOptions)), _defineProperty(_action, ActionName.FollowAction, extractFollowAction(response, actionOptions, id)), _defineProperty(_action, ActionName.PreviewAction, extractPreviewAction(response, actionOptions)), _defineProperty(_action, InternalActionName.AISummaryAction, extractAISummaryAction(response, url, actionOptions, aiSummaryConfig)), _action);
12
+ var action = (_action = {}, _defineProperty(_action, ActionName.CopyLinkAction, extractCopyLinkAction(data, actionOptions)), _defineProperty(_action, ActionName.DownloadAction, extractDownloadAction(data, actionOptions)), _defineProperty(_action, ActionName.FollowAction, extractFollowAction(response, actionOptions, id)), _defineProperty(_action, ActionName.PreviewAction, extractPreviewAction(response, actionOptions)), _defineProperty(_action, ActionName.AutomationAction, extractAutomationAction(response)), _defineProperty(_action, InternalActionName.AISummaryAction, extractAISummaryAction(response, url, actionOptions, aiSummaryConfig)), _action);
12
13
  return Object.values(action).some(function (value) {
13
14
  return Boolean(value);
14
15
  }) ? action : undefined;
@@ -55,11 +55,41 @@ export var 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 var 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 var 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 var 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 var 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 var 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 var 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'];
@@ -32,9 +32,10 @@ export var useAISummary = function useAISummary(props) {
32
32
  var onError = useCallback(function (id, reason) {
33
33
  /**
34
34
  * Errors should only be counted to the SLO if they are not due to acceptable use violations
35
- * or HIPAA content detected.
35
+ * HIPAA content detected or exceeding context length.
36
36
  */
37
- var isSloError = reason !== "ACCEPTABLE_USE_VIOLATIONS" && reason !== "HIPAA_CONTENT_DETECTED";
37
+
38
+ var isSloError = reason === undefined ? true : !['ACCEPTABLE_USE_VIOLATIONS', 'HIPAA_CONTENT_DETECTED', 'EXCEEDING_CONTEXT_LENGTH_ERROR'].includes(reason);
38
39
  fireEvent('operational.summary.failed', {
39
40
  reason: reason || null,
40
41
  isSloError: isSloError
@@ -18,6 +18,10 @@ export var getAISummaryErrorMessage = function getAISummaryErrorMessage(error) {
18
18
  return {
19
19
  message: messages.ai_summary_error_hipaa_content_detected
20
20
  };
21
+ case 'EXCEEDING_CONTEXT_LENGTH_ERROR':
22
+ return {
23
+ message: messages.ai_summary_error_exceeding_context_length_error
24
+ };
21
25
  default:
22
26
  return {
23
27
  message: messages.ai_summary_error_generic,
@@ -15,7 +15,7 @@ export var ANALYTICS_CHANNEL = 'media';
15
15
  export var context = {
16
16
  componentName: 'smart-cards',
17
17
  packageName: "@atlaskit/smart-card",
18
- packageVersion: "26.66.0"
18
+ packageVersion: "26.68.0"
19
19
  };
20
20
  export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
21
21
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -6,5 +6,6 @@ export var 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
  var buttonStyles = xcss({
9
9
  all: 'unset',
10
+ cursor: 'pointer',
10
11
  padding: 'space.050',
11
12
  width: '100%',
12
13
  ':focus:not(:focus-visible)': {
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
- var _excluded = ["action", "onClick"];
5
+ var _excluded = ["action", "onClick", "onError"];
6
6
  import _regeneratorRuntime from "@babel/runtime/regenerator";
7
7
  import React, { useCallback, useState } from 'react';
8
8
  import useInvoke from '../../../../../../state/hooks/use-invoke';
@@ -14,6 +14,7 @@ import { useFlexibleUiAnalyticsContext } from '../../../../../../state/flexible-
14
14
  var ServerAction = function ServerAction(_ref) {
15
15
  var action = _ref.action,
16
16
  onClick = _ref.onClick,
17
+ onErrorCallback = _ref.onError,
17
18
  props = _objectWithoutProperties(_ref, _excluded);
18
19
  var _useState = useState(false),
19
20
  _useState2 = _slicedToArray(_useState, 2),
@@ -28,7 +29,7 @@ var ServerAction = function ServerAction(_ref) {
28
29
  while (1) switch (_context.prev = _context.next) {
29
30
  case 0:
30
31
  if (!action) {
31
- _context.next = 21;
32
+ _context.next = 22;
32
33
  break;
33
34
  }
34
35
  smartLinkActionType = (_action$action = action.action) === null || _action$action === void 0 ? void 0 : _action$action.actionType;
@@ -58,7 +59,7 @@ var ServerAction = function ServerAction(_ref) {
58
59
  if (onClick) {
59
60
  onClick();
60
61
  }
61
- _context.next = 21;
62
+ _context.next = 22;
62
63
  break;
63
64
  case 17:
64
65
  _context.prev = 17;
@@ -68,12 +69,13 @@ var ServerAction = function ServerAction(_ref) {
68
69
  smartLinkActionType: smartLinkActionType,
69
70
  reason: getInvokeFailureReason(_context.t0)
70
71
  });
71
- case 21:
72
+ onErrorCallback === null || onErrorCallback === void 0 || onErrorCallback();
73
+ case 22:
72
74
  case "end":
73
75
  return _context.stop();
74
76
  }
75
77
  }, _callee, null, [[2, 17]]);
76
- })), [action, analytics === null || analytics === void 0 ? void 0 : analytics.track, analytics === null || analytics === void 0 ? void 0 : analytics.ui, invoke, onClick, reload]);
78
+ })), [action, analytics === null || analytics === void 0 ? void 0 : analytics.track, analytics === null || analytics === void 0 ? void 0 : analytics.ui, invoke, onClick, onErrorCallback, reload]);
77
79
  return /*#__PURE__*/React.createElement(Action, _extends({}, props, {
78
80
  isLoading: isLoading,
79
81
  onClick: handleClick
@@ -0,0 +1,47 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ import React, { useState } from 'react';
4
+ import { FormattedMessage, useIntl } from 'react-intl-next';
5
+ import AutomationManualTriggersGlyph from './manaul-triggers-icon';
6
+ import Action from '../action';
7
+ import { useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
8
+ import { ActionName } from '../../../../../constants';
9
+ import { messages } from '../../../../../messages';
10
+ // import { useSmartLinkContext } from '../../../../../../../link-provider/src';
11
+
12
+ var handleAutomateActionClick = function handleAutomateActionClick(setIsModalOpen) {
13
+ setIsModalOpen(true);
14
+ };
15
+ var AutomationAction = function AutomationAction(props) {
16
+ var _context$actions;
17
+ var _useState = useState(false),
18
+ _useState2 = _slicedToArray(_useState, 2),
19
+ _isModalOpen = _useState2[0],
20
+ setIsModalOpen = _useState2[1];
21
+ var _useIntl = useIntl(),
22
+ formatMessage = _useIntl.formatMessage;
23
+ // const { connections } = useSmartLinkContext();
24
+
25
+ // const env = connections.client.envKey ?? 'prod';
26
+ var context = useFlexibleUiContext();
27
+ var data = context === null || context === void 0 || (_context$actions = context.actions) === null || _context$actions === void 0 ? void 0 : _context$actions[ActionName.AutomationAction];
28
+ if (!data) {
29
+ return null;
30
+ }
31
+ var automationActionTitle = /*#__PURE__*/React.createElement(FormattedMessage, messages.automation_action_title);
32
+ var automationActionTooltip = /*#__PURE__*/React.createElement(FormattedMessage, messages.automation_action_tooltip);
33
+ var automationActionIconLabel = formatMessage(messages.automation_action_icon_label);
34
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Action, _extends({
35
+ content: automationActionTitle,
36
+ icon: /*#__PURE__*/React.createElement(AutomationManualTriggersGlyph, {
37
+ label: automationActionIconLabel
38
+ }),
39
+ testId: "smart-action-automation-action",
40
+ tooltipMessage: automationActionTooltip
41
+ }, data, props, {
42
+ onClick: function onClick() {
43
+ return handleAutomateActionClick(setIsModalOpen);
44
+ }
45
+ })));
46
+ };
47
+ export default AutomationAction;
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ var AutomationManualTriggersGlyph = function AutomationManualTriggersGlyph(_ref) {
3
+ var label = _ref.label;
4
+ return /*#__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
+ };
24
+ export default AutomationManualTriggersGlyph;
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["value"];
3
+ var _excluded = ["value", "isProject"];
4
4
  import InviteTeamIcon from '@atlaskit/icon/glyph/invite-team';
5
5
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
6
6
  import React from 'react';
@@ -11,6 +11,7 @@ import { useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
11
11
  import ServerAction from '../action/server-action';
12
12
  import UnfollowIcon from './unfollow-icon';
13
13
  import { importIcon } from '../../utils';
14
+ import { getFollowActionErrorMessage } from './utils';
14
15
  var importIconMapper = {
15
16
  goal: function goal() {
16
17
  return import( /* webpackChunkName: "glyphGoal" */'./goal-icon').then(function (_ref) {
@@ -45,16 +46,16 @@ var getIconFF = function getIconFF(iconFFEnabled, defaultIcon) {
45
46
  return defaultIcon;
46
47
  };
47
48
  var FollowAction = function FollowAction(props) {
48
- var _context$actions, _context$actions2;
49
+ var _context$actions;
49
50
  var context = useFlexibleUiContext();
50
- if (!context || !(context !== null && context !== void 0 && (_context$actions = context.actions) !== null && _context$actions !== void 0 && _context$actions[ActionName.FollowAction])) {
51
+ var actionData = context === null || context === void 0 || (_context$actions = context.actions) === null || _context$actions === void 0 ? void 0 : _context$actions[ActionName.FollowAction];
52
+ if (!context || !actionData) {
51
53
  return null;
52
54
  }
53
- var _context$actions$Acti = context === null || context === void 0 || (_context$actions2 = context.actions) === null || _context$actions2 === void 0 ? void 0 : _context$actions2[ActionName.FollowAction],
54
- value = _context$actions$Acti.value,
55
- data = _objectWithoutProperties(_context$actions$Acti, _excluded);
55
+ var value = actionData.value,
56
+ isProject = actionData.isProject,
57
+ data = _objectWithoutProperties(actionData, _excluded);
56
58
  var isStackItem = props.as === 'stack-item';
57
- var isProject = data.isProject;
58
59
  var message = value ? messages.follow : messages.unfollow;
59
60
  var projectMessage = value ? messages.follow_project : messages.unfollow_project;
60
61
  var goalMessage = value ? messages.follow_goal : messages.unfollow_goal;
@@ -76,11 +77,21 @@ var FollowAction = function FollowAction(props) {
76
77
  testId: "smart-action-follow-action-".concat(stackIconType, "-icon")
77
78
  });
78
79
  var followIcon = isStackItem ? stackIcon : getIconFF(stackIcon, icon);
80
+ var handleError = function handleError() {
81
+ var onErrorCallback = props.onError;
82
+ var errorMessage = getFollowActionErrorMessage(isProject, value);
83
+ onErrorCallback === null || onErrorCallback === void 0 || onErrorCallback({
84
+ title: /*#__PURE__*/React.createElement(FormattedMessage, errorMessage),
85
+ appearance: 'error'
86
+ });
87
+ };
79
88
  return /*#__PURE__*/React.createElement(ServerAction, _extends({
80
89
  content: /*#__PURE__*/React.createElement(FormattedMessage, label),
81
90
  icon: followIcon,
82
91
  testId: "smart-action-follow-action",
83
92
  tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, tooltipMessage)
84
- }, data, props));
93
+ }, data, props, {
94
+ onError: handleError
95
+ }));
85
96
  };
86
97
  export default FollowAction;
@@ -0,0 +1,18 @@
1
+ import { messages } from '../../../../../messages';
2
+ export var getFollowActionErrorMessage = function getFollowActionErrorMessage() {
3
+ var isProject = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
4
+ var isFollow = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
5
+ if (isProject && isFollow) {
6
+ return messages.follow_project_error;
7
+ }
8
+ if (isProject && !isFollow) {
9
+ return messages.unfollow_project_error;
10
+ }
11
+ if (!isProject && isFollow) {
12
+ return messages.follow_goal_error;
13
+ }
14
+ if (!isProject && !isFollow) {
15
+ return messages.unfollow_goal_error;
16
+ }
17
+ return messages.generic_error_message;
18
+ };
@@ -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';
@@ -28,16 +28,16 @@ export var AIFooterMetadata = function AIFooterMetadata(_ref) {
28
28
  grow: "fill"
29
29
  }, /*#__PURE__*/React.createElement(Tooltip, {
30
30
  content: /*#__PURE__*/React.createElement(FormattedMessage, messages.ai_summarized_info_short),
31
- position: "top"
31
+ position: "bottom"
32
32
  }, function (tooltipProps) {
33
33
  return /*#__PURE__*/React.createElement(Box, tooltipProps, /*#__PURE__*/React.createElement(InfoIcon, {
34
34
  label: "Information",
35
35
  size: "small",
36
36
  primaryColor: "var(--ds-icon-subtle, #626F86)"
37
37
  }));
38
- }), /*#__PURE__*/React.createElement(AIStateIndicator, {
39
- appearance: "icon-only",
40
- state: "done",
41
- testId: "ai-tooltip"
38
+ }), /*#__PURE__*/React.createElement(AIIcon, {
39
+ label: "AI",
40
+ size: "small",
41
+ primaryColor: "var(--ds-icon-subtle, #626F86)"
42
42
  }));
43
43
  };