@atlaskit/smart-card 26.50.13 → 26.50.15

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 (78) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/extractors/flexible/actions/index.js +17 -0
  3. package/dist/cjs/extractors/flexible/index.js +4 -3
  4. package/dist/cjs/state/flexible-ui-context/types.js +1 -3
  5. package/dist/cjs/state/hooks/use-ai-summary/ai-summary-service/index.js +6 -3
  6. package/dist/cjs/state/hooks/use-ai-summary/index.js +4 -2
  7. package/dist/cjs/utils/analytics/analytics.js +1 -1
  8. package/dist/cjs/view/FlexibleCard/components/actions/index.js +8 -12
  9. package/dist/cjs/view/FlexibleCard/components/actions/preview-action/index.js +83 -0
  10. package/dist/cjs/view/FlexibleCard/components/actions/types.js +5 -0
  11. package/dist/cjs/view/FlexibleCard/components/actions/utils.js +0 -13
  12. package/dist/cjs/view/FlexibleCard/components/blocks/action-group/action-group-item/index.js +8 -6
  13. package/dist/cjs/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +3 -1
  14. package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +45 -11
  15. package/dist/cjs/view/HoverCard/components/ContentContainer.js +6 -3
  16. package/dist/cjs/view/HoverCard/components/views/resolved/index.js +7 -3
  17. package/dist/cjs/view/LinkUrl/index.js +1 -1
  18. package/dist/es2019/extractors/flexible/actions/index.js +9 -0
  19. package/dist/es2019/extractors/flexible/index.js +5 -4
  20. package/dist/es2019/state/flexible-ui-context/types.js +6 -1
  21. package/dist/es2019/state/hooks/use-ai-summary/ai-summary-service/index.js +6 -3
  22. package/dist/es2019/state/hooks/use-ai-summary/index.js +4 -2
  23. package/dist/es2019/utils/analytics/analytics.js +1 -1
  24. package/dist/es2019/view/FlexibleCard/components/actions/index.js +1 -11
  25. package/dist/es2019/view/FlexibleCard/components/actions/preview-action/index.js +52 -0
  26. package/dist/es2019/view/FlexibleCard/components/actions/utils.js +0 -14
  27. package/dist/es2019/view/FlexibleCard/components/blocks/action-group/action-group-item/index.js +8 -6
  28. package/dist/es2019/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +3 -1
  29. package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +42 -33
  30. package/dist/es2019/view/HoverCard/components/ContentContainer.js +7 -4
  31. package/dist/es2019/view/HoverCard/components/views/resolved/index.js +8 -4
  32. package/dist/es2019/view/LinkUrl/index.js +1 -1
  33. package/dist/esm/extractors/flexible/actions/index.js +10 -0
  34. package/dist/esm/extractors/flexible/index.js +5 -4
  35. package/dist/esm/state/flexible-ui-context/types.js +6 -1
  36. package/dist/esm/state/hooks/use-ai-summary/ai-summary-service/index.js +6 -3
  37. package/dist/esm/state/hooks/use-ai-summary/index.js +4 -2
  38. package/dist/esm/utils/analytics/analytics.js +1 -1
  39. package/dist/esm/view/FlexibleCard/components/actions/index.js +1 -11
  40. package/dist/esm/view/FlexibleCard/components/actions/preview-action/index.js +73 -0
  41. package/dist/esm/view/FlexibleCard/components/actions/preview-action/types.js +1 -0
  42. package/dist/esm/view/FlexibleCard/components/actions/types.js +1 -0
  43. package/dist/esm/view/FlexibleCard/components/actions/utils.js +0 -13
  44. package/dist/esm/view/FlexibleCard/components/blocks/action-group/action-group-item/index.js +8 -6
  45. package/dist/esm/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +3 -1
  46. package/dist/esm/view/FlexibleCard/components/blocks/utils.js +45 -11
  47. package/dist/esm/view/HoverCard/components/ContentContainer.js +7 -4
  48. package/dist/esm/view/HoverCard/components/views/resolved/index.js +8 -4
  49. package/dist/esm/view/LinkUrl/index.js +1 -1
  50. package/dist/types/extractors/flexible/actions/index.d.ts +5 -0
  51. package/dist/types/state/flexible-ui-context/types.d.ts +14 -7
  52. package/dist/types/state/hooks/use-ai-summary/ai-summary-service/index.d.ts +1 -0
  53. package/dist/types/state/hooks/use-ai-summary/ai-summary-service/types.d.ts +7 -3
  54. package/dist/types/view/FlexibleCard/components/actions/index.d.ts +1 -7
  55. package/dist/types/view/FlexibleCard/components/actions/preview-action/index.d.ts +4 -0
  56. package/dist/types/view/FlexibleCard/components/actions/preview-action/types.d.ts +2 -0
  57. package/dist/types/view/FlexibleCard/components/actions/types.d.ts +7 -0
  58. package/dist/types/view/FlexibleCard/types.d.ts +20 -2
  59. package/dist/types-ts4.5/extractors/flexible/actions/index.d.ts +5 -0
  60. package/dist/types-ts4.5/state/flexible-ui-context/types.d.ts +14 -7
  61. package/dist/types-ts4.5/state/hooks/use-ai-summary/ai-summary-service/index.d.ts +1 -0
  62. package/dist/types-ts4.5/state/hooks/use-ai-summary/ai-summary-service/types.d.ts +7 -3
  63. package/dist/types-ts4.5/view/FlexibleCard/components/actions/index.d.ts +1 -7
  64. package/dist/types-ts4.5/view/FlexibleCard/components/actions/preview-action/index.d.ts +4 -0
  65. package/dist/types-ts4.5/view/FlexibleCard/components/actions/preview-action/types.d.ts +2 -0
  66. package/dist/types-ts4.5/view/FlexibleCard/components/actions/types.d.ts +7 -0
  67. package/dist/types-ts4.5/view/FlexibleCard/types.d.ts +20 -2
  68. package/package.json +3 -3
  69. package/dist/cjs/view/FlexibleCard/components/actions/action/preview-action/index.js +0 -87
  70. package/dist/es2019/view/FlexibleCard/components/actions/action/preview-action/index.js +0 -63
  71. package/dist/esm/view/FlexibleCard/components/actions/action/preview-action/index.js +0 -80
  72. package/dist/types/view/FlexibleCard/components/actions/action/preview-action/index.d.ts +0 -4
  73. package/dist/types/view/FlexibleCard/components/actions/action/preview-action/types.d.ts +0 -12
  74. package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/preview-action/index.d.ts +0 -4
  75. package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/preview-action/types.d.ts +0 -12
  76. /package/dist/cjs/view/FlexibleCard/components/actions/{action/preview-action → preview-action}/types.js +0 -0
  77. /package/dist/es2019/view/FlexibleCard/components/actions/{action/preview-action → preview-action}/types.js +0 -0
  78. /package/dist/{esm/view/FlexibleCard/components/actions/action/preview-action → es2019/view/FlexibleCard/components/actions}/types.js +0 -0
@@ -10,7 +10,8 @@ export const useAISummary = props => {
10
10
  url,
11
11
  baseUrl,
12
12
  headers,
13
- product
13
+ product,
14
+ ari
14
15
  } = props;
15
16
  const [state, setState] = useState(((_AISummariesStore$get = AISummariesStore.get(url)) === null || _AISummariesStore$get === void 0 ? void 0 : _AISummariesStore$get.state) || {
16
17
  status: 'ready',
@@ -37,6 +38,7 @@ export const useAISummary = props => {
37
38
  if (!AISummariesStore.get(url)) {
38
39
  AISummariesStore.set(url, new AISummaryService({
39
40
  url,
41
+ ari,
40
42
  baseUrl,
41
43
  headers,
42
44
  onError,
@@ -48,7 +50,7 @@ export const useAISummary = props => {
48
50
 
49
51
  //returns function that calls unsubscribe method
50
52
  return (_AISummariesStore$get2 = AISummariesStore.get(url)) === null || _AISummariesStore$get2 === void 0 ? void 0 : _AISummariesStore$get2.subscribe(setState);
51
- }, [url, baseUrl, headers, onError, onStart, onSuccess, product]);
53
+ }, [url, baseUrl, headers, onError, onStart, onSuccess, product, ari]);
52
54
  const summariseUrl = () => {
53
55
  var _AISummariesStore$get3;
54
56
  return (_AISummariesStore$get3 = AISummariesStore.get(url)) === null || _AISummariesStore$get3 === void 0 ? void 0 : _AISummariesStore$get3.summariseUrl();
@@ -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.50.13"
7
+ packageVersion: "26.50.15"
8
8
  };
9
9
  export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
10
10
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -1,10 +1,7 @@
1
1
  import { ActionName } from '../../../../constants';
2
2
  import { createDataAction, createUIAction } from './utils';
3
3
  export { default as FollowAction } from './follow-action';
4
-
5
- // Attention: Keep the export name and action name the same.
6
- // This will help reducing the code for mapping action inside
7
- // createAction and renderActionItems
4
+ export { default as PreviewAction } from './preview-action';
8
5
 
9
6
  /**
10
7
  * Creates a DeleteAction component. Accepts default ActionProps, but defaults
@@ -19,13 +16,6 @@ export const DeleteAction = createUIAction(ActionName.DeleteAction);
19
16
  */
20
17
  export const EditAction = createUIAction(ActionName.EditAction);
21
18
 
22
- /**
23
- * Creates a PreviewAction component. Accepts default PreviewActionProps, and defaults
24
- * to the text 'Preview' inside the button.
25
- * @see Action
26
- */
27
- export const PreviewAction = createDataAction(ActionName.PreviewAction);
28
-
29
19
  /**
30
20
  * Creates a ViewAction component. Accepts default ViewActionProps, and defaults
31
21
  * to the text 'View' inside the button.
@@ -0,0 +1,52 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import VidFullScreenOnIcon from '@atlaskit/icon/glyph/vid-full-screen-on';
3
+ import React, { useCallback } from 'react';
4
+ import { FormattedMessage } from 'react-intl-next';
5
+ import { ActionName } from '../../../../../constants';
6
+ import { messages } from '../../../../../messages';
7
+ import { useFlexibleUiAnalyticsContext, useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
8
+ import useInvokeClientAction from '../../../../../state/hooks/use-invoke-client-action';
9
+ import { openEmbedModalWithFlexibleUiIcon } from '../../utils';
10
+ import Action from '../action';
11
+ const PreviewAction = ({
12
+ onClick: onClickCallback,
13
+ ...props
14
+ }) => {
15
+ var _context$actions;
16
+ const context = useFlexibleUiContext();
17
+ const analytics = useFlexibleUiAnalyticsContext();
18
+ const invoke = useInvokeClientAction({
19
+ analytics
20
+ });
21
+ const data = context === null || context === void 0 ? void 0 : (_context$actions = context.actions) === null || _context$actions === void 0 ? void 0 : _context$actions[ActionName.PreviewAction];
22
+ const onClick = useCallback(() => {
23
+ if (data) {
24
+ invoke({
25
+ actionType: ActionName.PreviewAction,
26
+ actionFn: async () => openEmbedModalWithFlexibleUiIcon({
27
+ download: data === null || data === void 0 ? void 0 : data.downloadUrl,
28
+ extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey,
29
+ analytics,
30
+ ...data
31
+ }),
32
+ // These values have already been set in analytics context.
33
+ // We only pass these here for ufo experience.
34
+ display: analytics === null || analytics === void 0 ? void 0 : analytics.display,
35
+ extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey
36
+ });
37
+ }
38
+ if (onClickCallback) {
39
+ onClickCallback();
40
+ }
41
+ }, [analytics, data, invoke, onClickCallback]);
42
+ return data ? /*#__PURE__*/React.createElement(Action, _extends({
43
+ content: /*#__PURE__*/React.createElement(FormattedMessage, messages.preview_improved),
44
+ icon: /*#__PURE__*/React.createElement(VidFullScreenOnIcon, {
45
+ label: "Open preview"
46
+ }),
47
+ onClick: onClick,
48
+ testId: "smart-action-preview-action",
49
+ tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.preview_improved)
50
+ }, data, props)) : null;
51
+ };
52
+ export default PreviewAction;
@@ -7,8 +7,6 @@ import { FormattedMessage } from 'react-intl-next';
7
7
  import { messages } from '../../../../messages';
8
8
  import CrossIcon from '@atlaskit/icon/glyph/cross';
9
9
  import EditIcon from '@atlaskit/icon/glyph/edit';
10
- import PreviewAction from './action/preview-action';
11
- import VidFullScreenOnIcon from '@atlaskit/icon/glyph/vid-full-screen-on';
12
10
  import ViewAction from './action/view-action';
13
11
  import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
14
12
  import DownloadAction from './action/download-action';
@@ -40,17 +38,6 @@ const actionMappings = {
40
38
  tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.edit)
41
39
  }
42
40
  },
43
- [ActionName.PreviewAction]: {
44
- component: PreviewAction,
45
- props: {
46
- testId: 'smart-action-preview-action',
47
- content: /*#__PURE__*/React.createElement(FormattedMessage, messages.preview_improved),
48
- icon: /*#__PURE__*/React.createElement(VidFullScreenOnIcon, {
49
- label: "Open preview"
50
- }),
51
- tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.preview_improved)
52
- }
53
- },
54
41
  [ActionName.ViewAction]: {
55
42
  component: ViewAction,
56
43
  props: {
@@ -85,7 +72,6 @@ const getActionData = (actionName, contextKey, context) => {
85
72
  }
86
73
  const data = context[contextKey];
87
74
  switch (actionName) {
88
- case ActionName.PreviewAction:
89
75
  case ActionName.ViewAction:
90
76
  case ActionName.DownloadAction:
91
77
  return data;
@@ -3,7 +3,6 @@ import _extends from "@babel/runtime/helpers/extends";
3
3
  import { jsx } from '@emotion/react';
4
4
  import React, { useCallback } from 'react';
5
5
  import * as Actions from '../../../actions';
6
- import { isJSXElementNull } from '../../utils';
7
6
  const ActionGroupItem = ({
8
7
  item,
9
8
  size,
@@ -40,7 +39,14 @@ const ActionGroupItem = ({
40
39
  if (hideIcon) {
41
40
  actionProps.icon = undefined;
42
41
  }
43
- const action = jsx(Action, _extends({
42
+ return jsx(Action
43
+ // Remove url once ViewAction is retired.
44
+ // This seems to be a typescript workaround
45
+ // because ViewAction marks it as required,
46
+ // which does not reflect actual implementation as the url
47
+ // came from data context and not all actions require url.
48
+ // https://product-fabric.atlassian.net/browse/EDM-9547
49
+ , _extends({
44
50
  url: "",
45
51
  asDropDownItem: asDropDownItems,
46
52
  size: size,
@@ -48,9 +54,5 @@ const ActionGroupItem = ({
48
54
  onClick: handleOnClick,
49
55
  isDisabled: isDisabled
50
56
  }, actionProps));
51
- if (!isJSXElementNull(action)) {
52
- return action;
53
- }
54
- return null;
55
57
  };
56
58
  export default ActionGroupItem;
@@ -31,6 +31,7 @@ const AISummaryBlockResolvedView = props => {
31
31
  } = useAnalyticsEvents();
32
32
  const context = useFlexibleUiContext();
33
33
  const url = (context === null || context === void 0 ? void 0 : context.url) || '';
34
+ const ari = (context === null || context === void 0 ? void 0 : context.ari) || '';
34
35
  const {
35
36
  summariseUrl,
36
37
  state: {
@@ -39,7 +40,8 @@ const AISummaryBlockResolvedView = props => {
39
40
  error
40
41
  }
41
42
  } = useAISummary({
42
- url
43
+ url,
44
+ ari
43
45
  });
44
46
  const showAISummary = status === 'done' ||
45
47
  // We want to display the AI Summary component only when there is content available during the loading process.
@@ -48,16 +48,16 @@ export const ElementDisplaySchema = {
48
48
  const getDirectionStyles = direction => {
49
49
  switch (direction) {
50
50
  case SmartLinkDirection.Vertical:
51
- return css`
52
- flex-direction: column;
53
- align-items: flex-start;
54
- `;
51
+ return css({
52
+ flexDirection: 'column',
53
+ alignItems: 'flex-start'
54
+ });
55
55
  case SmartLinkDirection.Horizontal:
56
56
  default:
57
- return css`
58
- flex-direction: row;
59
- align-items: center;
60
- `;
57
+ return css({
58
+ flexDirection: 'row',
59
+ alignItems: 'center'
60
+ });
61
61
  }
62
62
  };
63
63
  export const getGapSize = size => {
@@ -73,24 +73,24 @@ export const getGapSize = size => {
73
73
  return 0.25;
74
74
  }
75
75
  };
76
- export const getBaseStyles = (direction, size) => css`
77
- align-items: center;
78
- display: flex;
79
- gap: ${getGapSize(size)}rem;
80
- line-height: 1rem;
81
- min-width: 0;
82
- overflow: hidden;
83
- ${getDirectionStyles(direction)};
84
- &:empty {
85
- display: none;
76
+ export const getBaseStyles = (direction, size) => css({
77
+ alignItems: 'center',
78
+ display: 'flex',
79
+ gap: `${getGapSize(size)}rem`,
80
+ lineHeight: '1rem',
81
+ minWidth: 0,
82
+ overflow: 'hidden'
83
+ }, getDirectionStyles(direction), {
84
+ '&:empty': {
85
+ display: 'none'
86
+ },
87
+ '& > *': {
88
+ minWidth: 0
89
+ },
90
+ '& > [data-fit-to-content]': {
91
+ minWidth: 'fit-content'
86
92
  }
87
- & > * {
88
- min-width: 0;
89
- }
90
- & > [data-fit-to-content] {
91
- min-width: fit-content;
92
- }
93
- `;
93
+ });
94
94
  export const highlightRemoveStyles = css`
95
95
  outline: none !important;
96
96
  outline-color: inherit;
@@ -116,26 +116,35 @@ export const getActionGroupStyles = size => {
116
116
  // The biggest height of the action button exceeds the max line-height
117
117
  // of the elements causing the action on the block with x-large size to
118
118
  // get cut at the bottom.
119
- return css`
120
- max-height: 2rem;
121
- `;
119
+ return css({
120
+ maxHeight: '2rem'
121
+ });
122
122
  }
123
123
  };
124
124
  export const filterActionItems = (items = [], context) => {
125
125
  return items.filter(item => {
126
+ var _context$actions;
126
127
  switch (item.name) {
127
- // Action that require data from the data context to render.
128
+ case ActionName.DeleteAction:
129
+ case ActionName.EditAction:
130
+ case ActionName.CustomAction:
131
+ // Named and custom actions that user defines.
132
+ return Boolean(ActionName[item.name]);
128
133
  case ActionName.DownloadAction:
134
+ // Remove once DownloadAction is refactored to context.action
135
+ // https://product-fabric.atlassian.net/browse/EDM-9545
129
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
130
139
  case ActionName.FollowAction:
131
140
  return Boolean(context === null || context === void 0 ? void 0 : context.followAction);
132
- case ActionName.PreviewAction:
133
- return Boolean(context === null || context === void 0 ? void 0 : context.previewAction);
141
+ // Remove once ViewAction is retired
142
+ // https://product-fabric.atlassian.net/browse/EDM-9547
134
143
  case ActionName.ViewAction:
135
144
  return Boolean(context === null || context === void 0 ? void 0 : context.viewAction);
136
145
  default:
137
- // Named and custom actions that user defines.
138
- return Boolean(ActionName[item.name]);
146
+ // Action that require data from the data context to render.
147
+ return Boolean(context === null || context === void 0 ? void 0 : (_context$actions = context.actions) === null || _context$actions === void 0 ? void 0 : _context$actions[item.name]);
139
148
  }
140
149
  });
141
150
  };
@@ -8,7 +8,7 @@ import AIPrism from '../../common/ai-prism';
8
8
  import { hoverCardClassName } from './HoverCardContent';
9
9
  import { useAISummary } from '../../../state/hooks/use-ai-summary';
10
10
  import { useSmartCardState } from '../../../state/store';
11
- import { extractLink } from '@atlaskit/link-extractors';
11
+ import { extractAri, extractLink } from '@atlaskit/link-extractors';
12
12
  const ConnectedAIPrismContainer = ({
13
13
  children,
14
14
  isAIEnabled = false,
@@ -16,15 +16,18 @@ const ConnectedAIPrismContainer = ({
16
16
  url,
17
17
  ...props
18
18
  }) => {
19
- var _extractLink, _cardState$details;
19
+ var _cardState$details, _extractLink, _extractAri;
20
20
  const cardState = useSmartCardState(url);
21
- const dataUrl = (_extractLink = extractLink(cardState === null || cardState === void 0 ? void 0 : (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data)) !== null && _extractLink !== void 0 ? _extractLink : '';
21
+ const data = cardState === null || cardState === void 0 ? void 0 : (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
22
+ const dataUrl = (_extractLink = extractLink(data)) !== null && _extractLink !== void 0 ? _extractLink : '';
23
+ const dataAri = (_extractAri = extractAri(data)) !== null && _extractAri !== void 0 ? _extractAri : '';
22
24
  const {
23
25
  state: {
24
26
  status
25
27
  }
26
28
  } = useAISummary({
27
- url: dataUrl
29
+ url: dataUrl,
30
+ ari: dataAri
28
31
  });
29
32
  const [showPrism, setShowPrism] = useState(status === 'loading');
30
33
  useEffect(() => {
@@ -12,7 +12,7 @@ import { FormattedMessage } from 'react-intl-next';
12
12
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
13
13
  import { getCanBeDatasource } from '../../../../../state/helpers';
14
14
  import { useAISummary } from '../../../../../state/hooks/use-ai-summary';
15
- import { extractLink } from '@atlaskit/link-extractors';
15
+ import { extractAri, extractLink } from '@atlaskit/link-extractors';
16
16
  import { SmartLinkStatus } from '../../../../../constants';
17
17
  export const toFooterActions = (cardActions, onActionClick) => {
18
18
  const followAction = {
@@ -53,7 +53,8 @@ export const toFooterActions = (cardActions, onActionClick) => {
53
53
  const ConnectedAIBlock = ({
54
54
  bottomPrimary,
55
55
  imagePreview,
56
- url
56
+ url,
57
+ ari
57
58
  }) => {
58
59
  const {
59
60
  state: {
@@ -61,7 +62,8 @@ const ConnectedAIBlock = ({
61
62
  content
62
63
  }
63
64
  } = useAISummary({
64
- url
65
+ url,
66
+ ari
65
67
  });
66
68
  const showData = status === 'ready' || status === 'error' ||
67
69
  // Description & bottom metadata should only disappear when we start getting summary content
@@ -88,7 +90,7 @@ const HoverCardResolvedView = ({
88
90
  extensionKey,
89
91
  url
90
92
  }) => {
91
- var _cardState$details, _extractLink;
93
+ var _cardState$details, _extractLink, _extractAri;
92
94
  const canBeDatasource = getCanBeDatasource(cardState.details);
93
95
  useEffect(() => {
94
96
  // Since this hover view is only rendered on resolved status,
@@ -102,6 +104,7 @@ const HoverCardResolvedView = ({
102
104
  const footerActions = useMemo(() => toFooterActions(cardActions, onActionClick), [cardActions, onActionClick]);
103
105
  const data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
104
106
  const dataUrl = (_extractLink = extractLink(data)) !== null && _extractLink !== void 0 ? _extractLink : '';
107
+ const dataAri = (_extractAri = extractAri(data)) !== null && _extractAri !== void 0 ? _extractAri : '';
105
108
  const {
106
109
  topPrimary,
107
110
  topSecondary,
@@ -152,6 +155,7 @@ const HoverCardResolvedView = ({
152
155
  }, /*#__PURE__*/React.createElement(ConnectedAIBlock, {
153
156
  imagePreview: !!imagePreview,
154
157
  url: dataUrl,
158
+ ari: dataAri,
155
159
  bottomPrimary: bottomPrimary
156
160
  })), !isAISummaryEnabled && !imagePreview && /*#__PURE__*/React.createElement(SnippetBlock, {
157
161
  status: SmartLinkStatus.Resolved
@@ -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.50.13",
10
+ packageVersion: "26.50.15",
11
11
  componentName: 'linkUrl'
12
12
  };
13
13
  const Link = withLinkClickedEvent('a');
@@ -0,0 +1,10 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import { ActionName } from '../../../constants';
3
+ import { extractPreviewAction } from './extract-preview-action';
4
+ var extractActions = function extractActions(response, actionOptions) {
5
+ var action = _defineProperty({}, ActionName.PreviewAction, extractPreviewAction(response, actionOptions));
6
+ return Object.values(action).some(function (value) {
7
+ return Boolean(value);
8
+ }) ? action : undefined;
9
+ };
10
+ export default extractActions;
@@ -1,15 +1,15 @@
1
1
  import { extractSummary } from '../common/primitives';
2
+ import extractActions from './actions';
2
3
  import extractFollowAction from './actions/extract-follow-action';
3
4
  import { extractLinkIcon } from './icon';
4
5
  import { extractAttachmentCount, extractChecklistProgress, extractCommentCount, extractCreatedBy, extractModifiedBy, extractProgrammingLanguage, extractSubscriberCount, extractViewCount, extractReactCount, extractVoteCount, extractSourceBranch, extractTargetBranch, extractDueOn, extractLocation, extractOwnedBy, extractAssignedTo, extractSubTasksProgress, extractStoryPoints, extractReadTime, extractSentOn, extractPersonAssignedToAsArray } from './utils';
5
6
  import { extractPersonsUpdatedBy } from './collaboratorGroup';
6
- import { extractPersonCreatedBy, extractTitle, extractDateUpdated, extractDateCreated, extractLink, extractPersonOwnedBy } from '@atlaskit/link-extractors';
7
+ import { extractPersonCreatedBy, extractTitle, extractDateUpdated, extractDateCreated, extractLink, extractPersonOwnedBy, extractAri } from '@atlaskit/link-extractors';
7
8
  import extractPriority from './extract-priority';
8
9
  import extractProviderIcon from './icon/extract-provider-icon';
9
10
  import extractPreview from './extract-preview';
10
11
  import extractState from './extract-state';
11
12
  import { extractLatestCommit } from './latest-commit';
12
- import { extractPreviewAction } from './actions/extract-preview-action';
13
13
  import { extractDownloadAction } from './actions/extract-download-action';
14
14
  import { extractViewAction } from './actions/extract-view-action';
15
15
  var extractFlexibleUiContext = function extractFlexibleUiContext() {
@@ -24,6 +24,7 @@ var extractFlexibleUiContext = function extractFlexibleUiContext() {
24
24
  var data = response.data;
25
25
  var url = extractLink(data);
26
26
  return {
27
+ actions: extractActions(response, actionOptions),
27
28
  assignedToGroup: extractPersonAssignedToAsArray(data),
28
29
  attachmentCount: extractAttachmentCount(data),
29
30
  authorGroup: extractPersonCreatedBy(data),
@@ -40,7 +41,6 @@ var extractFlexibleUiContext = function extractFlexibleUiContext() {
40
41
  createdOn: extractDateCreated(data),
41
42
  dueOn: extractDueOn(data),
42
43
  followAction: extractFollowAction(response, actionOptions, id),
43
- previewAction: extractPreviewAction(response, actionOptions),
44
44
  viewAction: extractViewAction(data, actionOptions),
45
45
  downloadAction: extractDownloadAction(data, actionOptions),
46
46
  latestCommit: extractLatestCommit(data),
@@ -63,7 +63,8 @@ var extractFlexibleUiContext = function extractFlexibleUiContext() {
63
63
  storyPoints: extractStoryPoints(data),
64
64
  targetBranch: extractTargetBranch(data),
65
65
  title: extractTitle(data) || url,
66
- url: url
66
+ url: url,
67
+ ari: extractAri(data)
67
68
  };
68
69
  };
69
70
  export default extractFlexibleUiContext;
@@ -1 +1,6 @@
1
- export {};
1
+ import { ActionName } from '../../constants';
2
+
3
+ /**
4
+ * This provides the data that will be used by Smart Links Flexible UI to populate it's
5
+ * underlying elements.
6
+ */
@@ -30,9 +30,11 @@ export var AISummaryService = /*#__PURE__*/function () {
30
30
  case 0:
31
31
  payload = {
32
32
  recipient_agent_named_id: 'summary_agent',
33
- agent_input: {
34
- urls: [_this.url],
35
- summary_style: summaryStyle
33
+ agent_input_context: {
34
+ content_url: _this.url,
35
+ content_ari: _this.ari,
36
+ summary_style: summaryStyle,
37
+ summary_output_mimetype: 'text/markdown'
36
38
  }
37
39
  };
38
40
  options = {
@@ -77,6 +79,7 @@ export var AISummaryService = /*#__PURE__*/function () {
77
79
  headers: _objectSpread({}, props.headers || defaultConfig.headers)
78
80
  };
79
81
  this.url = props.url;
82
+ this.ari = props.ari;
80
83
  this.onStart = props.onStart;
81
84
  this.onSuccess = props.onSuccess;
82
85
  this.onError = props.onError;
@@ -10,7 +10,8 @@ export var useAISummary = function useAISummary(props) {
10
10
  var url = props.url,
11
11
  baseUrl = props.baseUrl,
12
12
  headers = props.headers,
13
- product = props.product;
13
+ product = props.product,
14
+ ari = props.ari;
14
15
  var _useState = useState(((_AISummariesStore$get = AISummariesStore.get(url)) === null || _AISummariesStore$get === void 0 ? void 0 : _AISummariesStore$get.state) || {
15
16
  status: 'ready',
16
17
  content: ''
@@ -38,6 +39,7 @@ export var useAISummary = function useAISummary(props) {
38
39
  if (!AISummariesStore.get(url)) {
39
40
  AISummariesStore.set(url, new AISummaryService({
40
41
  url: url,
42
+ ari: ari,
41
43
  baseUrl: baseUrl,
42
44
  headers: headers,
43
45
  onError: onError,
@@ -49,7 +51,7 @@ export var useAISummary = function useAISummary(props) {
49
51
 
50
52
  //returns function that calls unsubscribe method
51
53
  return (_AISummariesStore$get2 = AISummariesStore.get(url)) === null || _AISummariesStore$get2 === void 0 ? void 0 : _AISummariesStore$get2.subscribe(setState);
52
- }, [url, baseUrl, headers, onError, onStart, onSuccess, product]);
54
+ }, [url, baseUrl, headers, onError, onStart, onSuccess, product, ari]);
53
55
  var summariseUrl = function summariseUrl() {
54
56
  var _AISummariesStore$get3;
55
57
  return (_AISummariesStore$get3 = AISummariesStore.get(url)) === null || _AISummariesStore$get3 === void 0 ? void 0 : _AISummariesStore$get3.summariseUrl();
@@ -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.50.13"
18
+ packageVersion: "26.50.15"
19
19
  };
20
20
  export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
21
21
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -1,10 +1,7 @@
1
1
  import { ActionName } from '../../../../constants';
2
2
  import { createDataAction, createUIAction } from './utils';
3
3
  export { default as FollowAction } from './follow-action';
4
-
5
- // Attention: Keep the export name and action name the same.
6
- // This will help reducing the code for mapping action inside
7
- // createAction and renderActionItems
4
+ export { default as PreviewAction } from './preview-action';
8
5
 
9
6
  /**
10
7
  * Creates a DeleteAction component. Accepts default ActionProps, but defaults
@@ -19,13 +16,6 @@ export var DeleteAction = createUIAction(ActionName.DeleteAction);
19
16
  */
20
17
  export var EditAction = createUIAction(ActionName.EditAction);
21
18
 
22
- /**
23
- * Creates a PreviewAction component. Accepts default PreviewActionProps, and defaults
24
- * to the text 'Preview' inside the button.
25
- * @see Action
26
- */
27
- export var PreviewAction = createDataAction(ActionName.PreviewAction);
28
-
29
19
  /**
30
20
  * Creates a ViewAction component. Accepts default ViewActionProps, and defaults
31
21
  * to the text 'View' inside the button.
@@ -0,0 +1,73 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
4
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
+ var _excluded = ["onClick"];
6
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
7
+ 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; }
8
+ 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; }
9
+ import VidFullScreenOnIcon from '@atlaskit/icon/glyph/vid-full-screen-on';
10
+ import React, { useCallback } from 'react';
11
+ import { FormattedMessage } from 'react-intl-next';
12
+ import { ActionName } from '../../../../../constants';
13
+ import { messages } from '../../../../../messages';
14
+ import { useFlexibleUiAnalyticsContext, useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
15
+ import useInvokeClientAction from '../../../../../state/hooks/use-invoke-client-action';
16
+ import { openEmbedModalWithFlexibleUiIcon } from '../../utils';
17
+ import Action from '../action';
18
+ var PreviewAction = function PreviewAction(_ref) {
19
+ var _context$actions;
20
+ var onClickCallback = _ref.onClick,
21
+ props = _objectWithoutProperties(_ref, _excluded);
22
+ var context = useFlexibleUiContext();
23
+ var analytics = useFlexibleUiAnalyticsContext();
24
+ var invoke = useInvokeClientAction({
25
+ analytics: analytics
26
+ });
27
+ var data = context === null || context === void 0 || (_context$actions = context.actions) === null || _context$actions === void 0 ? void 0 : _context$actions[ActionName.PreviewAction];
28
+ var onClick = useCallback(function () {
29
+ if (data) {
30
+ invoke({
31
+ actionType: ActionName.PreviewAction,
32
+ actionFn: function () {
33
+ var _actionFn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
34
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
35
+ while (1) switch (_context.prev = _context.next) {
36
+ case 0:
37
+ return _context.abrupt("return", openEmbedModalWithFlexibleUiIcon(_objectSpread({
38
+ download: data === null || data === void 0 ? void 0 : data.downloadUrl,
39
+ extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey,
40
+ analytics: analytics
41
+ }, data)));
42
+ case 1:
43
+ case "end":
44
+ return _context.stop();
45
+ }
46
+ }, _callee);
47
+ }));
48
+ function actionFn() {
49
+ return _actionFn.apply(this, arguments);
50
+ }
51
+ return actionFn;
52
+ }(),
53
+ // These values have already been set in analytics context.
54
+ // We only pass these here for ufo experience.
55
+ display: analytics === null || analytics === void 0 ? void 0 : analytics.display,
56
+ extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey
57
+ });
58
+ }
59
+ if (onClickCallback) {
60
+ onClickCallback();
61
+ }
62
+ }, [analytics, data, invoke, onClickCallback]);
63
+ return data ? /*#__PURE__*/React.createElement(Action, _extends({
64
+ content: /*#__PURE__*/React.createElement(FormattedMessage, messages.preview_improved),
65
+ icon: /*#__PURE__*/React.createElement(VidFullScreenOnIcon, {
66
+ label: "Open preview"
67
+ }),
68
+ onClick: onClick,
69
+ testId: "smart-action-preview-action",
70
+ tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.preview_improved)
71
+ }, data, props)) : null;
72
+ };
73
+ export default PreviewAction;