@atlaskit/smart-card 26.66.0 → 26.67.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 (85) hide show
  1. package/CHANGELOG.md +15 -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/server-action/index.js +7 -5
  13. package/dist/cjs/view/FlexibleCard/components/actions/automation-action/index.js +56 -0
  14. package/dist/cjs/view/FlexibleCard/components/actions/automation-action/manaul-triggers-icon/index.js +31 -0
  15. package/dist/cjs/view/FlexibleCard/components/actions/follow-action/index.js +19 -8
  16. package/dist/cjs/view/FlexibleCard/components/actions/follow-action/utils.js +24 -0
  17. package/dist/cjs/view/FlexibleCard/components/actions/index.js +8 -1
  18. package/dist/cjs/view/LinkUrl/index.js +1 -1
  19. package/dist/es2019/constants.js +1 -0
  20. package/dist/es2019/extractors/flexible/actions/extract-automation-action.js +48 -0
  21. package/dist/es2019/extractors/flexible/actions/index.js +2 -0
  22. package/dist/es2019/messages.js +50 -0
  23. package/dist/es2019/state/flexible-ui-context/types.js +3 -1
  24. package/dist/es2019/state/hooks/use-ai-summary/ai-summary-service/types.js +1 -1
  25. package/dist/es2019/state/hooks/use-ai-summary/index.js +3 -2
  26. package/dist/es2019/utils/ai-summary.js +4 -0
  27. package/dist/es2019/utils/analytics/analytics.js +1 -1
  28. package/dist/es2019/view/Card/types.js +1 -0
  29. package/dist/es2019/view/FlexibleCard/components/actions/action/server-action/index.js +3 -1
  30. package/dist/es2019/view/FlexibleCard/components/actions/automation-action/index.js +41 -0
  31. package/dist/es2019/view/FlexibleCard/components/actions/automation-action/manaul-triggers-icon/index.js +23 -0
  32. package/dist/es2019/view/FlexibleCard/components/actions/follow-action/index.js +19 -5
  33. package/dist/es2019/view/FlexibleCard/components/actions/follow-action/utils.js +16 -0
  34. package/dist/es2019/view/FlexibleCard/components/actions/index.js +2 -1
  35. package/dist/es2019/view/LinkUrl/index.js +1 -1
  36. package/dist/esm/constants.js +1 -0
  37. package/dist/esm/extractors/flexible/actions/extract-automation-action.js +46 -0
  38. package/dist/esm/extractors/flexible/actions/index.js +2 -1
  39. package/dist/esm/messages.js +50 -0
  40. package/dist/esm/state/flexible-ui-context/types.js +3 -1
  41. package/dist/esm/state/hooks/use-ai-summary/ai-summary-service/types.js +1 -1
  42. package/dist/esm/state/hooks/use-ai-summary/index.js +3 -2
  43. package/dist/esm/utils/ai-summary.js +4 -0
  44. package/dist/esm/utils/analytics/analytics.js +1 -1
  45. package/dist/esm/view/Card/types.js +1 -0
  46. package/dist/esm/view/FlexibleCard/components/actions/action/server-action/index.js +7 -5
  47. package/dist/esm/view/FlexibleCard/components/actions/automation-action/index.js +46 -0
  48. package/dist/esm/view/FlexibleCard/components/actions/automation-action/manaul-triggers-icon/index.js +24 -0
  49. package/dist/esm/view/FlexibleCard/components/actions/follow-action/index.js +19 -8
  50. package/dist/esm/view/FlexibleCard/components/actions/follow-action/utils.js +18 -0
  51. package/dist/esm/view/FlexibleCard/components/actions/index.js +2 -1
  52. package/dist/esm/view/LinkUrl/index.js +1 -1
  53. package/dist/types/constants.d.ts +1 -0
  54. package/dist/types/extractors/flexible/actions/extract-automation-action.d.ts +3 -0
  55. package/dist/types/extractors/flexible/actions/index.d.ts +1 -1
  56. package/dist/types/messages.d.ts +1 -1
  57. package/dist/types/state/flexible-ui-context/types.d.ts +12 -0
  58. package/dist/types/state/hooks/use-ai-summary/ai-summary-service/types.d.ts +1 -1
  59. package/dist/types/view/Card/types.d.ts +2 -1
  60. package/dist/types/view/FlexibleCard/components/actions/action/server-action/index.d.ts +3 -3
  61. package/dist/types/view/FlexibleCard/components/actions/action/server-action/types.d.ts +4 -3
  62. package/dist/types/view/FlexibleCard/components/actions/automation-action/index.d.ts +4 -0
  63. package/dist/types/view/FlexibleCard/components/actions/automation-action/manaul-triggers-icon/index.d.ts +5 -0
  64. package/dist/types/view/FlexibleCard/components/actions/follow-action/index.d.ts +2 -2
  65. package/dist/types/view/FlexibleCard/components/actions/follow-action/utils.d.ts +2 -0
  66. package/dist/types/view/FlexibleCard/components/actions/index.d.ts +1 -0
  67. package/dist/types/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.d.ts +1 -1
  68. package/dist/types/view/FlexibleCard/components/blocks/types.d.ts +5 -5
  69. package/dist/types-ts4.5/constants.d.ts +1 -0
  70. package/dist/types-ts4.5/extractors/flexible/actions/extract-automation-action.d.ts +3 -0
  71. package/dist/types-ts4.5/extractors/flexible/actions/index.d.ts +1 -1
  72. package/dist/types-ts4.5/messages.d.ts +1 -1
  73. package/dist/types-ts4.5/state/flexible-ui-context/types.d.ts +12 -0
  74. package/dist/types-ts4.5/state/hooks/use-ai-summary/ai-summary-service/types.d.ts +2 -1
  75. package/dist/types-ts4.5/view/Card/types.d.ts +2 -1
  76. package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/server-action/index.d.ts +3 -3
  77. package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/server-action/types.d.ts +4 -3
  78. package/dist/types-ts4.5/view/FlexibleCard/components/actions/automation-action/index.d.ts +4 -0
  79. package/dist/types-ts4.5/view/FlexibleCard/components/actions/automation-action/manaul-triggers-icon/index.d.ts +5 -0
  80. package/dist/types-ts4.5/view/FlexibleCard/components/actions/follow-action/index.d.ts +2 -2
  81. package/dist/types-ts4.5/view/FlexibleCard/components/actions/follow-action/utils.d.ts +2 -0
  82. package/dist/types-ts4.5/view/FlexibleCard/components/actions/index.d.ts +1 -0
  83. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.d.ts +1 -1
  84. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/types.d.ts +5 -5
  85. package/package.json +6 -3
@@ -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.67.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
  }({});
@@ -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,41 @@
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({}, data, props, {
32
+ content: automationActionTitle,
33
+ icon: /*#__PURE__*/React.createElement(AutomationManualTriggersGlyph, {
34
+ label: automationActionIconLabel
35
+ }),
36
+ onClick: () => handleAutomateActionClick(setIsModalOpen),
37
+ testId: "smart-action-automation-action",
38
+ tooltipMessage: automationActionTooltip
39
+ })));
40
+ };
41
+ 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';
@@ -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.67.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.67.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
  }({});
@@ -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,46 @@
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({}, data, props, {
35
+ content: automationActionTitle,
36
+ icon: /*#__PURE__*/React.createElement(AutomationManualTriggersGlyph, {
37
+ label: automationActionIconLabel
38
+ }),
39
+ onClick: function onClick() {
40
+ return handleAutomateActionClick(setIsModalOpen);
41
+ },
42
+ testId: "smart-action-automation-action",
43
+ tooltipMessage: automationActionTooltip
44
+ })));
45
+ };
46
+ export default AutomationAction;