@atlaskit/smart-card 26.51.0 → 26.52.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 (72) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/extractors/flexible/actions/index.js +5 -2
  3. package/dist/cjs/extractors/flexible/index.js +1 -5
  4. package/dist/cjs/utils/analytics/analytics.js +1 -1
  5. package/dist/cjs/view/BlockCard/views/flexible/FlexibleNotFoundView.js +0 -1
  6. package/dist/cjs/view/FlexibleCard/components/actions/download-action/index.js +76 -0
  7. package/dist/cjs/view/FlexibleCard/components/actions/follow-action/index.js +8 -9
  8. package/dist/cjs/view/FlexibleCard/components/actions/follow-action/types.js +5 -0
  9. package/dist/cjs/view/FlexibleCard/components/actions/index.js +9 -8
  10. package/dist/cjs/view/FlexibleCard/components/actions/utils.js +0 -13
  11. package/dist/cjs/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +41 -26
  12. package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +0 -8
  13. package/dist/cjs/view/HoverCard/components/ContentContainer.js +1 -0
  14. package/dist/cjs/view/HoverCard/components/views/resolved/index.js +1 -0
  15. package/dist/cjs/view/LinkUrl/index.js +1 -1
  16. package/dist/es2019/extractors/flexible/actions/index.js +6 -2
  17. package/dist/es2019/extractors/flexible/index.js +1 -5
  18. package/dist/es2019/utils/analytics/analytics.js +1 -1
  19. package/dist/es2019/view/BlockCard/views/flexible/FlexibleNotFoundView.js +0 -1
  20. package/dist/es2019/view/FlexibleCard/components/actions/download-action/index.js +47 -0
  21. package/dist/es2019/view/FlexibleCard/components/actions/follow-action/index.js +7 -5
  22. package/dist/es2019/view/FlexibleCard/components/actions/index.js +1 -7
  23. package/dist/es2019/view/FlexibleCard/components/actions/utils.js +0 -14
  24. package/dist/es2019/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +43 -22
  25. package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +0 -8
  26. package/dist/es2019/view/HoverCard/components/ContentContainer.js +1 -0
  27. package/dist/es2019/view/HoverCard/components/views/resolved/index.js +1 -0
  28. package/dist/es2019/view/LinkUrl/index.js +1 -1
  29. package/dist/esm/extractors/flexible/actions/index.js +5 -2
  30. package/dist/esm/extractors/flexible/index.js +1 -5
  31. package/dist/esm/utils/analytics/analytics.js +1 -1
  32. package/dist/esm/view/BlockCard/views/flexible/FlexibleNotFoundView.js +0 -1
  33. package/dist/esm/view/FlexibleCard/components/actions/download-action/index.js +66 -0
  34. package/dist/esm/view/FlexibleCard/components/actions/download-action/types.js +1 -0
  35. package/dist/esm/view/FlexibleCard/components/actions/follow-action/index.js +9 -7
  36. package/dist/esm/view/FlexibleCard/components/actions/follow-action/types.js +1 -0
  37. package/dist/esm/view/FlexibleCard/components/actions/index.js +1 -7
  38. package/dist/esm/view/FlexibleCard/components/actions/utils.js +0 -13
  39. package/dist/esm/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +41 -26
  40. package/dist/esm/view/FlexibleCard/components/blocks/utils.js +0 -8
  41. package/dist/esm/view/HoverCard/components/ContentContainer.js +1 -0
  42. package/dist/esm/view/HoverCard/components/views/resolved/index.js +1 -0
  43. package/dist/esm/view/LinkUrl/index.js +1 -1
  44. package/dist/types/__fixtures__/dropbox-file.d.ts +3 -0
  45. package/dist/types/extractors/flexible/actions/index.d.ts +1 -1
  46. package/dist/types/state/flexible-ui-context/types.d.ts +2 -12
  47. package/dist/types/view/FlexibleCard/components/actions/download-action/index.d.ts +4 -0
  48. package/dist/types/view/FlexibleCard/components/actions/download-action/types.d.ts +2 -0
  49. package/dist/types/view/FlexibleCard/components/actions/follow-action/index.d.ts +2 -2
  50. package/dist/types/view/FlexibleCard/components/actions/follow-action/types.d.ts +2 -0
  51. package/dist/types/view/FlexibleCard/components/actions/index.d.ts +1 -7
  52. package/dist/types/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.d.ts +11 -2
  53. package/dist/types-ts4.5/__fixtures__/dropbox-file.d.ts +3 -0
  54. package/dist/types-ts4.5/extractors/flexible/actions/index.d.ts +1 -1
  55. package/dist/types-ts4.5/state/flexible-ui-context/types.d.ts +2 -12
  56. package/dist/types-ts4.5/view/FlexibleCard/components/actions/download-action/index.d.ts +4 -0
  57. package/dist/types-ts4.5/view/FlexibleCard/components/actions/download-action/types.d.ts +2 -0
  58. package/dist/types-ts4.5/view/FlexibleCard/components/actions/follow-action/index.d.ts +2 -2
  59. package/dist/types-ts4.5/view/FlexibleCard/components/actions/follow-action/types.d.ts +2 -0
  60. package/dist/types-ts4.5/view/FlexibleCard/components/actions/index.d.ts +1 -7
  61. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.d.ts +11 -2
  62. package/package.json +4 -4
  63. package/dist/cjs/view/FlexibleCard/components/actions/action/download-action/index.js +0 -72
  64. package/dist/es2019/view/FlexibleCard/components/actions/action/download-action/index.js +0 -47
  65. package/dist/esm/view/FlexibleCard/components/actions/action/download-action/index.js +0 -65
  66. package/dist/types/view/FlexibleCard/components/actions/action/download-action/index.d.ts +0 -4
  67. package/dist/types/view/FlexibleCard/components/actions/action/download-action/types.d.ts +0 -5
  68. package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/download-action/index.d.ts +0 -4
  69. package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/download-action/types.d.ts +0 -5
  70. /package/dist/cjs/view/FlexibleCard/components/actions/{action/download-action → download-action}/types.js +0 -0
  71. /package/dist/es2019/view/FlexibleCard/components/actions/{action/download-action → download-action}/types.js +0 -0
  72. /package/dist/{esm/view/FlexibleCard/components/actions/action/download-action → es2019/view/FlexibleCard/components/actions/follow-action}/types.js +0 -0
@@ -9,8 +9,6 @@ import CrossIcon from '@atlaskit/icon/glyph/cross';
9
9
  import EditIcon from '@atlaskit/icon/glyph/edit';
10
10
  import ViewAction from './action/view-action';
11
11
  import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
12
- import DownloadAction from './action/download-action';
13
- import DownloadIcon from '@atlaskit/icon/glyph/download';
14
12
  const actionMappings = {
15
13
  [ActionName.CustomAction]: {
16
14
  component: Action,
@@ -48,17 +46,6 @@ const actionMappings = {
48
46
  }),
49
47
  tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.view)
50
48
  }
51
- },
52
- [ActionName.DownloadAction]: {
53
- component: DownloadAction,
54
- props: {
55
- testId: 'smart-action-download-action',
56
- content: /*#__PURE__*/React.createElement(FormattedMessage, messages.download),
57
- icon: /*#__PURE__*/React.createElement(DownloadIcon, {
58
- label: "Download"
59
- }),
60
- tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.download)
61
- }
62
49
  }
63
50
  };
64
51
  const getContextKey = name => {
@@ -73,7 +60,6 @@ const getActionData = (actionName, contextKey, context) => {
73
60
  const data = context[contextKey];
74
61
  switch (actionName) {
75
62
  case ActionName.ViewAction:
76
- case ActionName.DownloadAction:
77
63
  return data;
78
64
  default:
79
65
  return undefined;
@@ -1,5 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import React, { useCallback, useMemo, useRef, useState, useEffect } from 'react';
2
+ import React, { useCallback, useMemo, useRef, useEffect } from 'react';
3
3
  import { FormattedMessage } from 'react-intl-next';
4
4
  import { Box, Inline } from '@atlaskit/primitives';
5
5
  import { ActionName, SmartLinkDirection, SmartLinkSize, SmartLinkWidth } from '../../../../../../constants';
@@ -16,16 +16,46 @@ import AISummary from '../../../../../common/ai-summary';
16
16
  import { useAnalyticsEvents } from '../../../../../../common/analytics/generated/use-analytics-events';
17
17
  import AIEventSummaryViewed from '../ai-event-summary-viewed';
18
18
  import AIEventErrorViewed from '../ai-event-error-viewed';
19
+ import { di } from 'react-magnetic-di';
20
+ export const AISummaryBlockErrorIndicator = ({
21
+ showErrorIndicator,
22
+ error,
23
+ testId
24
+ }) => {
25
+ return showErrorIndicator ? /*#__PURE__*/React.createElement(Inline, {
26
+ grow: "fill"
27
+ }, /*#__PURE__*/React.createElement(AIEventErrorViewed, {
28
+ reason: error
29
+ }), /*#__PURE__*/React.createElement(AIStateIndicator, {
30
+ error: error,
31
+ state: 'error',
32
+ testId: testId
33
+ })) : null;
34
+ };
35
+ export const AISummaryBlockStatusIndicator = ({
36
+ showStatusIndicator,
37
+ metadata,
38
+ status,
39
+ testId
40
+ }) => {
41
+ const metadataElements = renderElementItems(metadata);
42
+ return showStatusIndicator ? /*#__PURE__*/React.createElement(AIStateIndicator, {
43
+ state: status,
44
+ testId: `${testId}-state-indicator`
45
+ }) : /*#__PURE__*/React.createElement(ElementGroup, {
46
+ width: SmartLinkWidth.FitToContent,
47
+ testId: `${testId}-metadata-group`
48
+ }, metadataElements);
49
+ };
19
50
  const AISummaryBlockResolvedView = props => {
20
51
  const {
21
52
  actions = [],
22
- metadata,
23
53
  onActionMenuOpenChange,
24
54
  size = SmartLinkSize.Medium,
25
55
  testId,
26
- aiSummaryMinHeight
56
+ aiSummaryMinHeight,
57
+ metadata
27
58
  } = props;
28
- const metadataElements = renderElementItems(metadata);
29
59
  const {
30
60
  fireEvent
31
61
  } = useAnalyticsEvents();
@@ -48,15 +78,11 @@ const AISummaryBlockResolvedView = props => {
48
78
  status === 'loading' && !!content;
49
79
  const isSummarisedOnMountRef = useRef(status === 'done');
50
80
  const isErroredOnMountRef = useRef(status === 'error');
51
- const [showAISummaryErrorMessage, setShowAISummaryErrorMessage] = useState(false);
52
81
  useEffect(() => {
53
82
  // if the error was apparent on mount and the status is changed to loading we can
54
83
  // clear the initial error on mount state
55
84
  if (isErroredOnMountRef.current && status === 'loading') {
56
85
  isErroredOnMountRef.current = false;
57
- } else {
58
- // if a new error occurs and it was not an apparent error on mount, we can show the error message
59
- setShowAISummaryErrorMessage(!isErroredOnMountRef.current && status === 'error');
60
86
  }
61
87
  }, [status]);
62
88
  const combinedActions = useMemo(() => {
@@ -99,25 +125,20 @@ const AISummaryBlockResolvedView = props => {
99
125
  alignInline: "end",
100
126
  grow: "fill",
101
127
  spread: "space-between"
102
- }, /*#__PURE__*/React.createElement(Box, null, !isSummarisedOnMountRef.current && (status === 'loading' || status === 'done') ? /*#__PURE__*/React.createElement(AIStateIndicator, {
103
- state: status,
104
- testId: `${testId}-state-indicator`
105
- }) : /*#__PURE__*/React.createElement(ElementGroup, {
106
- width: SmartLinkWidth.FitToContent,
107
- testId: `${testId}-metadata-group`
108
- }, metadataElements)), /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(ActionGroup, {
128
+ }, /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(AISummaryBlockStatusIndicator, {
129
+ metadata: metadata,
130
+ showStatusIndicator: !isSummarisedOnMountRef.current && (status === 'loading' || status === 'done'),
131
+ status: status,
132
+ testId: testId
133
+ })), /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(ActionGroup, {
109
134
  onDropdownOpenChange: onDropdownOpenChange,
110
135
  items: combinedActions,
111
136
  appearance: "default",
112
137
  size: size
113
- }))), showAISummaryErrorMessage && /*#__PURE__*/React.createElement(Inline, {
114
- grow: "fill"
115
- }, /*#__PURE__*/React.createElement(AIEventErrorViewed, {
116
- reason: error
117
- }), /*#__PURE__*/React.createElement(AIStateIndicator, {
138
+ }))), /*#__PURE__*/React.createElement(AISummaryBlockErrorIndicator, {
139
+ showErrorIndicator: !isErroredOnMountRef.current && status === 'error',
118
140
  error: error,
119
- state: status,
120
141
  testId: testId
121
- })));
142
+ }));
122
143
  };
123
144
  export default AISummaryBlockResolvedView;
@@ -130,14 +130,6 @@ export const filterActionItems = (items = [], context) => {
130
130
  case ActionName.CustomAction:
131
131
  // Named and custom actions that user defines.
132
132
  return Boolean(ActionName[item.name]);
133
- case ActionName.DownloadAction:
134
- // Remove once DownloadAction is refactored to context.action
135
- // https://product-fabric.atlassian.net/browse/EDM-9545
136
- return Boolean(context === null || context === void 0 ? void 0 : context.downloadAction);
137
- // Remove once FollowAction is refactored to context.action
138
- // https://product-fabric.atlassian.net/browse/EDM-9559
139
- case ActionName.FollowAction:
140
- return Boolean(context === null || context === void 0 ? void 0 : context.followAction);
141
133
  // Remove once ViewAction is retired
142
134
  // https://product-fabric.atlassian.net/browse/EDM-9547
143
135
  case ActionName.ViewAction:
@@ -9,6 +9,7 @@ import { hoverCardClassName } from './HoverCardContent';
9
9
  import { useAISummary } from '../../../state/hooks/use-ai-summary';
10
10
  import { useSmartCardState } from '../../../state/store';
11
11
  import { extractAri, extractLink } from '@atlaskit/link-extractors';
12
+ import { di } from 'react-magnetic-di';
12
13
  const ConnectedAIPrismContainer = ({
13
14
  children,
14
15
  isAIEnabled = false,
@@ -14,6 +14,7 @@ import { getCanBeDatasource } from '../../../../../state/helpers';
14
14
  import { useAISummary } from '../../../../../state/hooks/use-ai-summary';
15
15
  import { extractAri, extractLink } from '@atlaskit/link-extractors';
16
16
  import { SmartLinkStatus } from '../../../../../constants';
17
+ import { di } from 'react-magnetic-di';
17
18
  export const toFooterActions = (cardActions, onActionClick) => {
18
19
  const followAction = {
19
20
  hideIcon: true,
@@ -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.51.0",
10
+ packageVersion: "26.52.0",
11
11
  componentName: 'linkUrl'
12
12
  };
13
13
  const Link = withLinkClickedEvent('a');
@@ -1,8 +1,11 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { ActionName } from '../../../constants';
3
+ import { extractDownloadAction } from './extract-download-action';
3
4
  import { extractPreviewAction } from './extract-preview-action';
4
- var extractActions = function extractActions(response, actionOptions) {
5
- var action = _defineProperty({}, ActionName.PreviewAction, extractPreviewAction(response, actionOptions));
5
+ import extractFollowAction from './extract-follow-action';
6
+ var extractActions = function extractActions(response, data, actionOptions, id) {
7
+ var _action;
8
+ var action = (_action = {}, _defineProperty(_action, ActionName.PreviewAction, extractPreviewAction(response, actionOptions)), _defineProperty(_action, ActionName.DownloadAction, extractDownloadAction(data, actionOptions)), _defineProperty(_action, ActionName.FollowAction, extractFollowAction(response, actionOptions, id)), _action);
6
9
  return Object.values(action).some(function (value) {
7
10
  return Boolean(value);
8
11
  }) ? action : undefined;
@@ -1,6 +1,5 @@
1
1
  import { extractSummary } from '../common/primitives';
2
2
  import extractActions from './actions';
3
- import extractFollowAction from './actions/extract-follow-action';
4
3
  import { extractLinkIcon } from './icon';
5
4
  import { extractAttachmentCount, extractChecklistProgress, extractCommentCount, extractCreatedBy, extractModifiedBy, extractProgrammingLanguage, extractSubscriberCount, extractViewCount, extractReactCount, extractVoteCount, extractSourceBranch, extractTargetBranch, extractDueOn, extractLocation, extractOwnedBy, extractAssignedTo, extractSubTasksProgress, extractStoryPoints, extractReadTime, extractSentOn, extractPersonAssignedToAsArray } from './utils';
6
5
  import { extractPersonsUpdatedBy } from './collaboratorGroup';
@@ -10,7 +9,6 @@ import extractProviderIcon from './icon/extract-provider-icon';
10
9
  import extractPreview from './extract-preview';
11
10
  import extractState from './extract-state';
12
11
  import { extractLatestCommit } from './latest-commit';
13
- import { extractDownloadAction } from './actions/extract-download-action';
14
12
  import { extractViewAction } from './actions/extract-view-action';
15
13
  var extractFlexibleUiContext = function extractFlexibleUiContext() {
16
14
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
@@ -24,7 +22,7 @@ var extractFlexibleUiContext = function extractFlexibleUiContext() {
24
22
  var data = response.data;
25
23
  var url = extractLink(data);
26
24
  return {
27
- actions: extractActions(response, actionOptions),
25
+ actions: extractActions(response, data, actionOptions, id),
28
26
  assignedToGroup: extractPersonAssignedToAsArray(data),
29
27
  attachmentCount: extractAttachmentCount(data),
30
28
  authorGroup: extractPersonCreatedBy(data),
@@ -40,9 +38,7 @@ var extractFlexibleUiContext = function extractFlexibleUiContext() {
40
38
  assignedTo: extractAssignedTo(data),
41
39
  createdOn: extractDateCreated(data),
42
40
  dueOn: extractDueOn(data),
43
- followAction: extractFollowAction(response, actionOptions, id),
44
41
  viewAction: extractViewAction(data, actionOptions),
45
- downloadAction: extractDownloadAction(data, actionOptions),
46
42
  latestCommit: extractLatestCommit(data),
47
43
  linkIcon: extractLinkIcon(response, renderers),
48
44
  location: extractLocation(data),
@@ -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.51.0"
18
+ packageVersion: "26.52.0"
19
19
  };
20
20
  export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
21
21
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -40,7 +40,6 @@ var FlexibleNotFoundView = function FlexibleNotFoundView(_ref) {
40
40
  };
41
41
  }, []);
42
42
  return /*#__PURE__*/React.createElement(UnresolvedView, _extends({}, props, {
43
- showPreview: true,
44
43
  testId: testId,
45
44
  title: title
46
45
  }), /*#__PURE__*/React.createElement(LockIcon, {
@@ -0,0 +1,66 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
+ var _excluded = ["onClick"];
5
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
6
+ import React, { useCallback } from 'react';
7
+ import { downloadUrl as download } from '../../../../../utils';
8
+ import { FormattedMessage } from 'react-intl-next';
9
+ import { ActionName } from '../../../../../constants';
10
+ import { messages } from '../../../../../messages';
11
+ import Action from '../action';
12
+ import { useFlexibleUiAnalyticsContext, useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
13
+ import useInvokeClientAction from '../../../../../state/hooks/use-invoke-client-action';
14
+ import DownloadIcon from '@atlaskit/icon/glyph/download';
15
+ var DownloadAction = function DownloadAction(_ref) {
16
+ var _context$actions;
17
+ var onClickCallback = _ref.onClick,
18
+ props = _objectWithoutProperties(_ref, _excluded);
19
+ var context = useFlexibleUiContext();
20
+ var analytics = useFlexibleUiAnalyticsContext();
21
+ var invoke = useInvokeClientAction({
22
+ analytics: analytics
23
+ });
24
+ var data = context === null || context === void 0 || (_context$actions = context.actions) === null || _context$actions === void 0 ? void 0 : _context$actions[ActionName.DownloadAction];
25
+ var onClick = useCallback(function () {
26
+ if (data !== null && data !== void 0 && data.downloadUrl) {
27
+ invoke({
28
+ actionType: ActionName.DownloadAction,
29
+ actionFn: function () {
30
+ var _actionFn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
31
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
32
+ while (1) switch (_context.prev = _context.next) {
33
+ case 0:
34
+ return _context.abrupt("return", download(data === null || data === void 0 ? void 0 : data.downloadUrl));
35
+ case 1:
36
+ case "end":
37
+ return _context.stop();
38
+ }
39
+ }, _callee);
40
+ }));
41
+ function actionFn() {
42
+ return _actionFn.apply(this, arguments);
43
+ }
44
+ return actionFn;
45
+ }(),
46
+ // These values have already been set in analytics context.
47
+ // We only pass these here for ufo experience.
48
+ display: analytics === null || analytics === void 0 ? void 0 : analytics.display,
49
+ extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey
50
+ });
51
+ if (onClickCallback) {
52
+ onClickCallback();
53
+ }
54
+ }
55
+ }, [analytics, data === null || data === void 0 ? void 0 : data.downloadUrl, invoke, onClickCallback]);
56
+ return data ? /*#__PURE__*/React.createElement(Action, _extends({
57
+ content: /*#__PURE__*/React.createElement(FormattedMessage, messages.download),
58
+ icon: /*#__PURE__*/React.createElement(DownloadIcon, {
59
+ label: "Download"
60
+ }),
61
+ onClick: onClick,
62
+ testId: "smart-action-download-action",
63
+ tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.download)
64
+ }, data, props)) : null;
65
+ };
66
+ export default DownloadAction;
@@ -2,20 +2,22 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  var _excluded = ["value"];
4
4
  import InviteTeamIcon from '@atlaskit/icon/glyph/invite-team';
5
- import React, { useContext } from 'react';
5
+ import React from 'react';
6
6
  import { FormattedMessage } from 'react-intl-next';
7
+ import { ActionName } from '../../../../../constants';
7
8
  import { messages } from '../../../../../messages';
8
- import { FlexibleUiContext } from '../../../../../state/flexible-ui-context';
9
+ import { useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
9
10
  import ServerAction from '../action/server-action';
10
11
  import UnfollowIcon from './unfollow-icon';
11
12
  var FollowAction = function FollowAction(props) {
12
- var context = useContext(FlexibleUiContext);
13
- if (!context || !context.followAction) {
13
+ var _context$actions, _context$actions2;
14
+ var context = useFlexibleUiContext();
15
+ if (!context || !(context !== null && context !== void 0 && (_context$actions = context.actions) !== null && _context$actions !== void 0 && _context$actions[ActionName.FollowAction])) {
14
16
  return null;
15
17
  }
16
- var _context$followAction = context.followAction,
17
- value = _context$followAction.value,
18
- data = _objectWithoutProperties(_context$followAction, _excluded);
18
+ var _context$actions$Acti = context === null || context === void 0 || (_context$actions2 = context.actions) === null || _context$actions2 === void 0 ? void 0 : _context$actions2[ActionName.FollowAction],
19
+ value = _context$actions$Acti.value,
20
+ data = _objectWithoutProperties(_context$actions$Acti, _excluded);
19
21
  var message = value ? messages.follow : messages.unfollow;
20
22
  var icon = value ? /*#__PURE__*/React.createElement(InviteTeamIcon, {
21
23
  label: "Follow"
@@ -2,6 +2,7 @@ import { ActionName } from '../../../../constants';
2
2
  import { createDataAction, createUIAction } from './utils';
3
3
  export { default as FollowAction } from './follow-action';
4
4
  export { default as PreviewAction } from './preview-action';
5
+ export { default as DownloadAction } from './download-action';
5
6
 
6
7
  /**
7
8
  * Creates a DeleteAction component. Accepts default ActionProps, but defaults
@@ -23,13 +24,6 @@ export var EditAction = createUIAction(ActionName.EditAction);
23
24
  */
24
25
  export var ViewAction = createDataAction(ActionName.ViewAction);
25
26
 
26
- /**
27
- * Creates a DownloadAction component. Accepts default DownloadActionProps, and defaults
28
- * to the text 'Download' inside the button.
29
- * @see Action
30
- */
31
- export var DownloadAction = createDataAction(ActionName.DownloadAction);
32
-
33
27
  /**
34
28
  * Creates a CustomAction component. Accepts default ActionProps. Required to provide
35
29
  * your own icon or text.
@@ -14,8 +14,6 @@ import CrossIcon from '@atlaskit/icon/glyph/cross';
14
14
  import EditIcon from '@atlaskit/icon/glyph/edit';
15
15
  import ViewAction from './action/view-action';
16
16
  import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
17
- import DownloadAction from './action/download-action';
18
- import DownloadIcon from '@atlaskit/icon/glyph/download';
19
17
  var actionMappings = (_actionMappings = {}, _defineProperty(_actionMappings, ActionName.CustomAction, {
20
18
  component: Action,
21
19
  props: {}
@@ -49,16 +47,6 @@ var actionMappings = (_actionMappings = {}, _defineProperty(_actionMappings, Act
49
47
  }),
50
48
  tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.view)
51
49
  }
52
- }), _defineProperty(_actionMappings, ActionName.DownloadAction, {
53
- component: DownloadAction,
54
- props: {
55
- testId: 'smart-action-download-action',
56
- content: /*#__PURE__*/React.createElement(FormattedMessage, messages.download),
57
- icon: /*#__PURE__*/React.createElement(DownloadIcon, {
58
- label: "Download"
59
- }),
60
- tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.download)
61
- }
62
50
  }), _actionMappings);
63
51
  var getContextKey = function getContextKey(name) {
64
52
  // Attempt to predict context prop name in advance to reduce the amount of
@@ -72,7 +60,6 @@ var getActionData = function getActionData(actionName, contextKey, context) {
72
60
  var data = context[contextKey];
73
61
  switch (actionName) {
74
62
  case ActionName.ViewAction:
75
- case ActionName.DownloadAction:
76
63
  return data;
77
64
  default:
78
65
  return undefined;
@@ -1,7 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
- import React, { useCallback, useMemo, useRef, useState, useEffect } from 'react';
3
+ import React, { useCallback, useMemo, useRef, useEffect } from 'react';
5
4
  import { FormattedMessage } from 'react-intl-next';
6
5
  import { Box, Inline } from '@atlaskit/primitives';
7
6
  import { ActionName, SmartLinkDirection, SmartLinkSize, SmartLinkWidth } from '../../../../../../constants';
@@ -18,16 +17,44 @@ import AISummary from '../../../../../common/ai-summary';
18
17
  import { useAnalyticsEvents } from '../../../../../../common/analytics/generated/use-analytics-events';
19
18
  import AIEventSummaryViewed from '../ai-event-summary-viewed';
20
19
  import AIEventErrorViewed from '../ai-event-error-viewed';
20
+ import { di } from 'react-magnetic-di';
21
+ export var AISummaryBlockErrorIndicator = function AISummaryBlockErrorIndicator(_ref) {
22
+ var showErrorIndicator = _ref.showErrorIndicator,
23
+ error = _ref.error,
24
+ testId = _ref.testId;
25
+ return showErrorIndicator ? /*#__PURE__*/React.createElement(Inline, {
26
+ grow: "fill"
27
+ }, /*#__PURE__*/React.createElement(AIEventErrorViewed, {
28
+ reason: error
29
+ }), /*#__PURE__*/React.createElement(AIStateIndicator, {
30
+ error: error,
31
+ state: 'error',
32
+ testId: testId
33
+ })) : null;
34
+ };
35
+ export var AISummaryBlockStatusIndicator = function AISummaryBlockStatusIndicator(_ref2) {
36
+ var showStatusIndicator = _ref2.showStatusIndicator,
37
+ metadata = _ref2.metadata,
38
+ status = _ref2.status,
39
+ testId = _ref2.testId;
40
+ var metadataElements = renderElementItems(metadata);
41
+ return showStatusIndicator ? /*#__PURE__*/React.createElement(AIStateIndicator, {
42
+ state: status,
43
+ testId: "".concat(testId, "-state-indicator")
44
+ }) : /*#__PURE__*/React.createElement(ElementGroup, {
45
+ width: SmartLinkWidth.FitToContent,
46
+ testId: "".concat(testId, "-metadata-group")
47
+ }, metadataElements);
48
+ };
21
49
  var AISummaryBlockResolvedView = function AISummaryBlockResolvedView(props) {
22
50
  var _props$actions = props.actions,
23
51
  actions = _props$actions === void 0 ? [] : _props$actions,
24
- metadata = props.metadata,
25
52
  onActionMenuOpenChange = props.onActionMenuOpenChange,
26
53
  _props$size = props.size,
27
54
  size = _props$size === void 0 ? SmartLinkSize.Medium : _props$size,
28
55
  testId = props.testId,
29
- aiSummaryMinHeight = props.aiSummaryMinHeight;
30
- var metadataElements = renderElementItems(metadata);
56
+ aiSummaryMinHeight = props.aiSummaryMinHeight,
57
+ metadata = props.metadata;
31
58
  var _useAnalyticsEvents = useAnalyticsEvents(),
32
59
  fireEvent = _useAnalyticsEvents.fireEvent;
33
60
  var context = useFlexibleUiContext();
@@ -47,18 +74,11 @@ var AISummaryBlockResolvedView = function AISummaryBlockResolvedView(props) {
47
74
  status === 'loading' && !!content;
48
75
  var isSummarisedOnMountRef = useRef(status === 'done');
49
76
  var isErroredOnMountRef = useRef(status === 'error');
50
- var _useState = useState(false),
51
- _useState2 = _slicedToArray(_useState, 2),
52
- showAISummaryErrorMessage = _useState2[0],
53
- setShowAISummaryErrorMessage = _useState2[1];
54
77
  useEffect(function () {
55
78
  // if the error was apparent on mount and the status is changed to loading we can
56
79
  // clear the initial error on mount state
57
80
  if (isErroredOnMountRef.current && status === 'loading') {
58
81
  isErroredOnMountRef.current = false;
59
- } else {
60
- // if a new error occurs and it was not an apparent error on mount, we can show the error message
61
- setShowAISummaryErrorMessage(!isErroredOnMountRef.current && status === 'error');
62
82
  }
63
83
  }, [status]);
64
84
  var combinedActions = useMemo(function () {
@@ -101,25 +121,20 @@ var AISummaryBlockResolvedView = function AISummaryBlockResolvedView(props) {
101
121
  alignInline: "end",
102
122
  grow: "fill",
103
123
  spread: "space-between"
104
- }, /*#__PURE__*/React.createElement(Box, null, !isSummarisedOnMountRef.current && (status === 'loading' || status === 'done') ? /*#__PURE__*/React.createElement(AIStateIndicator, {
105
- state: status,
106
- testId: "".concat(testId, "-state-indicator")
107
- }) : /*#__PURE__*/React.createElement(ElementGroup, {
108
- width: SmartLinkWidth.FitToContent,
109
- testId: "".concat(testId, "-metadata-group")
110
- }, metadataElements)), /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(ActionGroup, {
124
+ }, /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(AISummaryBlockStatusIndicator, {
125
+ metadata: metadata,
126
+ showStatusIndicator: !isSummarisedOnMountRef.current && (status === 'loading' || status === 'done'),
127
+ status: status,
128
+ testId: testId
129
+ })), /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(ActionGroup, {
111
130
  onDropdownOpenChange: onDropdownOpenChange,
112
131
  items: combinedActions,
113
132
  appearance: "default",
114
133
  size: size
115
- }))), showAISummaryErrorMessage && /*#__PURE__*/React.createElement(Inline, {
116
- grow: "fill"
117
- }, /*#__PURE__*/React.createElement(AIEventErrorViewed, {
118
- reason: error
119
- }), /*#__PURE__*/React.createElement(AIStateIndicator, {
134
+ }))), /*#__PURE__*/React.createElement(AISummaryBlockErrorIndicator, {
135
+ showErrorIndicator: !isErroredOnMountRef.current && status === 'error',
120
136
  error: error,
121
- state: status,
122
137
  testId: testId
123
- })));
138
+ }));
124
139
  };
125
140
  export default AISummaryBlockResolvedView;
@@ -99,14 +99,6 @@ export var filterActionItems = function filterActionItems() {
99
99
  case ActionName.CustomAction:
100
100
  // Named and custom actions that user defines.
101
101
  return Boolean(ActionName[item.name]);
102
- case ActionName.DownloadAction:
103
- // Remove once DownloadAction is refactored to context.action
104
- // https://product-fabric.atlassian.net/browse/EDM-9545
105
- return Boolean(context === null || context === void 0 ? void 0 : context.downloadAction);
106
- // Remove once FollowAction is refactored to context.action
107
- // https://product-fabric.atlassian.net/browse/EDM-9559
108
- case ActionName.FollowAction:
109
- return Boolean(context === null || context === void 0 ? void 0 : context.followAction);
110
102
  // Remove once ViewAction is retired
111
103
  // https://product-fabric.atlassian.net/browse/EDM-9547
112
104
  case ActionName.ViewAction:
@@ -13,6 +13,7 @@ import { hoverCardClassName } from './HoverCardContent';
13
13
  import { useAISummary } from '../../../state/hooks/use-ai-summary';
14
14
  import { useSmartCardState } from '../../../state/store';
15
15
  import { extractAri, extractLink } from '@atlaskit/link-extractors';
16
+ import { di } from 'react-magnetic-di';
16
17
  var ConnectedAIPrismContainer = function ConnectedAIPrismContainer(_ref) {
17
18
  var _cardState$details, _extractLink, _extractAri;
18
19
  var children = _ref.children,
@@ -15,6 +15,7 @@ import { getCanBeDatasource } from '../../../../../state/helpers';
15
15
  import { useAISummary } from '../../../../../state/hooks/use-ai-summary';
16
16
  import { extractAri, extractLink } from '@atlaskit/link-extractors';
17
17
  import { SmartLinkStatus } from '../../../../../constants';
18
+ import { di } from 'react-magnetic-di';
18
19
  export var toFooterActions = function toFooterActions(cardActions, onActionClick) {
19
20
  var followAction = {
20
21
  hideIcon: true,
@@ -10,7 +10,7 @@ import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-m
10
10
  import LinkWarningModal from './LinkWarningModal';
11
11
  var PACKAGE_DATA = {
12
12
  packageName: "@atlaskit/smart-card",
13
- packageVersion: "26.51.0",
13
+ packageVersion: "26.52.0",
14
14
  componentName: 'linkUrl'
15
15
  };
16
16
  var Link = withLinkClickedEvent('a');
@@ -0,0 +1,3 @@
1
+ import { JsonLd } from 'json-ld-types';
2
+ declare const _default: JsonLd.Response<JsonLd.Data.BaseData>;
3
+ export default _default;
@@ -1,5 +1,5 @@
1
1
  import type { JsonLd } from 'json-ld-types';
2
2
  import type { FlexibleUiActions } from '../../../state/flexible-ui-context/types';
3
3
  import type { CardActionOptions } from '../../../view/Card/types';
4
- declare const extractActions: (response: JsonLd.Response, actionOptions?: CardActionOptions) => FlexibleUiActions | undefined;
4
+ declare const extractActions: (response: JsonLd.Response, data: JsonLd.Data.BaseData, actionOptions?: CardActionOptions, id?: string) => FlexibleUiActions | undefined;
5
5
  export default extractActions;
@@ -52,12 +52,6 @@ export type FlexibleUiDataContext = {
52
52
  * @see DueOn
53
53
  */
54
54
  dueOn?: string;
55
- /**
56
- * Contains data needed to perform follow action.
57
- * @type PreviewActionData
58
- * @see FollowAction
59
- */
60
- followAction?: ServerActionProp<boolean>;
61
55
  /**
62
56
  * Contains the number of views of the linked resource.
63
57
  * @type number
@@ -112,12 +106,6 @@ export type FlexibleUiDataContext = {
112
106
  * @see ViewAction
113
107
  */
114
108
  viewAction?: ViewActionData;
115
- /**
116
- * Contains data needed to show a download action.
117
- * @type DownloadActionData
118
- * @see DownloadAction
119
- */
120
- downloadAction?: DownloadActionData;
121
109
  /**
122
110
  * Contains the information about the latest commit in the repository
123
111
  */
@@ -254,6 +242,8 @@ export type Media = {
254
242
  };
255
243
  export type FlexibleUiActions = {
256
244
  [ActionName.PreviewAction]?: PreviewActionData;
245
+ [ActionName.DownloadAction]?: DownloadActionData;
246
+ [ActionName.FollowAction]?: ServerActionProp<boolean>;
257
247
  };
258
248
  export type PreviewActionData = {
259
249
  downloadUrl?: string;
@@ -0,0 +1,4 @@
1
+ import { type FC } from 'react';
2
+ import type { DownloadActionProps } from './types';
3
+ declare const DownloadAction: FC<DownloadActionProps>;
4
+ export default DownloadAction;
@@ -0,0 +1,2 @@
1
+ import { LinkActionProps } from '../types';
2
+ export type DownloadActionProps = LinkActionProps;
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
- import type { ActionProps } from '../action/types';
3
- declare const FollowAction: React.FC<ActionProps>;
2
+ import { FollowActionProps } from './types';
3
+ declare const FollowAction: React.FC<FollowActionProps>;
4
4
  export default FollowAction;