@atlaskit/smart-card 32.7.0 → 32.7.1

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 (160) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/analytics.spec.yaml +63 -9
  3. package/dist/cjs/common/analytics/types.js +5 -0
  4. package/dist/cjs/extractors/action/extract-invoke-copy-link-action.js +53 -0
  5. package/dist/cjs/extractors/action/extract-invoke-download-action.js +57 -0
  6. package/dist/cjs/extractors/action/extract-invoke-preview-action.js +78 -0
  7. package/dist/cjs/extractors/action/extract-invoke-view-action.js +60 -0
  8. package/dist/cjs/extractors/action/extractDownloadActionProps.js +4 -0
  9. package/dist/cjs/extractors/action/extractPreviewActionProps.js +4 -0
  10. package/dist/cjs/extractors/action/extractViewActionProps.js +4 -0
  11. package/dist/cjs/extractors/action/types.js +5 -0
  12. package/dist/cjs/extractors/flexible/actions/extract-copy-link-action.js +12 -1
  13. package/dist/cjs/extractors/flexible/actions/extract-download-action.js +12 -1
  14. package/dist/cjs/extractors/flexible/actions/extract-preview-action.js +12 -1
  15. package/dist/cjs/extractors/flexible/actions/extract-view-action.js +3 -0
  16. package/dist/cjs/extractors/flexible/actions/index.js +40 -3
  17. package/dist/cjs/extractors/flexible/extract-state.js +19 -5
  18. package/dist/cjs/extractors/flexible/index.js +22 -8
  19. package/dist/cjs/state/hooks/use-invoke-client-action/index.js +56 -17
  20. package/dist/cjs/state/hooks-external/useSmartLinkActions.js +22 -3
  21. package/dist/cjs/utils/analytics/LinkAnalyticsContext.js +7 -2
  22. package/dist/cjs/utils/analytics/analytics.js +1 -1
  23. package/dist/cjs/utils/mocks.js +4 -1
  24. package/dist/cjs/view/BlockCard/views/flexible/FlexibleResolvedView.js +1 -0
  25. package/dist/cjs/view/BlockCard/views/flexible/unresolved-view/index.js +1 -0
  26. package/dist/cjs/view/CardWithUrl/component.js +1 -0
  27. package/dist/cjs/view/EmbedModal/index.js +72 -51
  28. package/dist/cjs/view/FlexibleCard/components/actions/copy-link-action/index.js +65 -32
  29. package/dist/cjs/view/FlexibleCard/components/actions/download-action/index.js +36 -28
  30. package/dist/cjs/view/FlexibleCard/components/actions/preview-action/index.js +40 -32
  31. package/dist/cjs/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.js +13 -6
  32. package/dist/cjs/view/FlexibleCard/components/utils.js +4 -0
  33. package/dist/cjs/view/FlexibleCard/index.js +11 -1
  34. package/dist/cjs/view/HoverCard/components/HoverCardContent.js +1 -0
  35. package/dist/cjs/view/LinkUrl/index.js +1 -1
  36. package/dist/es2019/common/analytics/types.js +1 -0
  37. package/dist/es2019/extractors/action/extract-invoke-copy-link-action.js +29 -0
  38. package/dist/es2019/extractors/action/extract-invoke-download-action.js +31 -0
  39. package/dist/es2019/extractors/action/extract-invoke-preview-action.js +57 -0
  40. package/dist/es2019/extractors/action/extract-invoke-view-action.js +34 -0
  41. package/dist/es2019/extractors/action/extractDownloadActionProps.js +5 -0
  42. package/dist/es2019/extractors/action/extractPreviewActionProps.js +5 -0
  43. package/dist/es2019/extractors/action/extractViewActionProps.js +5 -0
  44. package/dist/es2019/extractors/action/types.js +1 -0
  45. package/dist/es2019/extractors/flexible/actions/extract-copy-link-action.js +11 -0
  46. package/dist/es2019/extractors/flexible/actions/extract-download-action.js +12 -0
  47. package/dist/es2019/extractors/flexible/actions/extract-preview-action.js +12 -0
  48. package/dist/es2019/extractors/flexible/actions/extract-view-action.js +4 -0
  49. package/dist/es2019/extractors/flexible/actions/index.js +48 -3
  50. package/dist/es2019/extractors/flexible/extract-state.js +17 -5
  51. package/dist/es2019/extractors/flexible/index.js +17 -6
  52. package/dist/es2019/state/hooks/use-invoke-client-action/index.js +91 -43
  53. package/dist/es2019/state/hooks-external/useSmartLinkActions.js +21 -3
  54. package/dist/es2019/utils/analytics/LinkAnalyticsContext.js +3 -0
  55. package/dist/es2019/utils/analytics/analytics.js +1 -1
  56. package/dist/es2019/utils/mocks.js +4 -1
  57. package/dist/es2019/view/BlockCard/views/flexible/FlexibleResolvedView.js +1 -0
  58. package/dist/es2019/view/BlockCard/views/flexible/unresolved-view/index.js +1 -0
  59. package/dist/es2019/view/CardWithUrl/component.js +1 -0
  60. package/dist/es2019/view/EmbedModal/index.js +41 -20
  61. package/dist/es2019/view/FlexibleCard/components/actions/copy-link-action/index.js +31 -16
  62. package/dist/es2019/view/FlexibleCard/components/actions/download-action/index.js +20 -12
  63. package/dist/es2019/view/FlexibleCard/components/actions/preview-action/index.js +25 -17
  64. package/dist/es2019/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.js +14 -7
  65. package/dist/es2019/view/FlexibleCard/components/utils.js +4 -0
  66. package/dist/es2019/view/FlexibleCard/index.js +12 -1
  67. package/dist/es2019/view/HoverCard/components/HoverCardContent.js +1 -0
  68. package/dist/es2019/view/LinkUrl/index.js +1 -1
  69. package/dist/esm/common/analytics/types.js +1 -0
  70. package/dist/esm/extractors/action/extract-invoke-copy-link-action.js +46 -0
  71. package/dist/esm/extractors/action/extract-invoke-download-action.js +50 -0
  72. package/dist/esm/extractors/action/extract-invoke-preview-action.js +71 -0
  73. package/dist/esm/extractors/action/extract-invoke-view-action.js +53 -0
  74. package/dist/esm/extractors/action/extractDownloadActionProps.js +5 -0
  75. package/dist/esm/extractors/action/extractPreviewActionProps.js +5 -0
  76. package/dist/esm/extractors/action/extractViewActionProps.js +5 -0
  77. package/dist/esm/extractors/action/types.js +1 -0
  78. package/dist/esm/extractors/flexible/actions/extract-copy-link-action.js +11 -0
  79. package/dist/esm/extractors/flexible/actions/extract-download-action.js +12 -0
  80. package/dist/esm/extractors/flexible/actions/extract-preview-action.js +12 -0
  81. package/dist/esm/extractors/flexible/actions/extract-view-action.js +4 -0
  82. package/dist/esm/extractors/flexible/actions/index.js +42 -5
  83. package/dist/esm/extractors/flexible/extract-state.js +19 -5
  84. package/dist/esm/extractors/flexible/index.js +19 -8
  85. package/dist/esm/state/hooks/use-invoke-client-action/index.js +56 -17
  86. package/dist/esm/state/hooks-external/useSmartLinkActions.js +22 -3
  87. package/dist/esm/utils/analytics/LinkAnalyticsContext.js +7 -2
  88. package/dist/esm/utils/analytics/analytics.js +1 -1
  89. package/dist/esm/utils/mocks.js +4 -1
  90. package/dist/esm/view/BlockCard/views/flexible/FlexibleResolvedView.js +1 -0
  91. package/dist/esm/view/BlockCard/views/flexible/unresolved-view/index.js +1 -0
  92. package/dist/esm/view/CardWithUrl/component.js +1 -0
  93. package/dist/esm/view/EmbedModal/index.js +73 -52
  94. package/dist/esm/view/FlexibleCard/components/actions/copy-link-action/index.js +65 -32
  95. package/dist/esm/view/FlexibleCard/components/actions/download-action/index.js +36 -28
  96. package/dist/esm/view/FlexibleCard/components/actions/preview-action/index.js +40 -32
  97. package/dist/esm/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.js +13 -6
  98. package/dist/esm/view/FlexibleCard/components/utils.js +4 -0
  99. package/dist/esm/view/FlexibleCard/index.js +11 -1
  100. package/dist/esm/view/HoverCard/components/HoverCardContent.js +1 -0
  101. package/dist/esm/view/LinkUrl/index.js +1 -1
  102. package/dist/types/common/analytics/generated/analytics.types.d.ts +63 -2
  103. package/dist/types/common/analytics/types.d.ts +2 -0
  104. package/dist/types/extractors/action/extract-invoke-copy-link-action.d.ts +3 -0
  105. package/dist/types/extractors/action/extract-invoke-download-action.d.ts +3 -0
  106. package/dist/types/extractors/action/extract-invoke-preview-action.d.ts +11 -0
  107. package/dist/types/extractors/action/extract-invoke-view-action.d.ts +3 -0
  108. package/dist/types/extractors/action/extractDownloadActionProps.d.ts +4 -0
  109. package/dist/types/extractors/action/extractPreviewActionProps.d.ts +5 -1
  110. package/dist/types/extractors/action/extractViewActionProps.d.ts +4 -0
  111. package/dist/types/extractors/action/types.d.ts +9 -0
  112. package/dist/types/extractors/flexible/actions/extract-copy-link-action.d.ts +6 -0
  113. package/dist/types/extractors/flexible/actions/extract-download-action.d.ts +6 -0
  114. package/dist/types/extractors/flexible/actions/extract-preview-action.d.ts +6 -0
  115. package/dist/types/extractors/flexible/actions/extract-view-action.d.ts +3 -0
  116. package/dist/types/extractors/flexible/actions/index.d.ts +21 -4
  117. package/dist/types/extractors/flexible/extract-state.d.ts +5 -2
  118. package/dist/types/extractors/flexible/index.d.ts +1 -1
  119. package/dist/types/state/flexible-ui-context/types.d.ts +9 -3
  120. package/dist/types/state/hooks/use-invoke/types.d.ts +7 -1
  121. package/dist/types/state/hooks/use-invoke-client-action/index.d.ts +2 -2
  122. package/dist/types/state/hooks/use-invoke-client-action/types.d.ts +24 -2
  123. package/dist/types/state/hooks/use-resolve/index.d.ts +1 -0
  124. package/dist/types/view/EmbedModal/index.d.ts +4 -0
  125. package/dist/types/view/EmbedModal/types.d.ts +7 -0
  126. package/dist/types/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.d.ts +1 -1
  127. package/dist/types/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/types.d.ts +6 -0
  128. package/dist/types/view/FlexibleCard/components/utils.d.ts +3 -0
  129. package/dist/types/view/FlexibleCard/index.d.ts +1 -1
  130. package/dist/types/view/FlexibleCard/types.d.ts +12 -3
  131. package/dist/types-ts4.5/common/analytics/generated/analytics.types.d.ts +63 -2
  132. package/dist/types-ts4.5/common/analytics/types.d.ts +2 -0
  133. package/dist/types-ts4.5/extractors/action/extract-invoke-copy-link-action.d.ts +3 -0
  134. package/dist/types-ts4.5/extractors/action/extract-invoke-download-action.d.ts +3 -0
  135. package/dist/types-ts4.5/extractors/action/extract-invoke-preview-action.d.ts +11 -0
  136. package/dist/types-ts4.5/extractors/action/extract-invoke-view-action.d.ts +3 -0
  137. package/dist/types-ts4.5/extractors/action/extractDownloadActionProps.d.ts +4 -0
  138. package/dist/types-ts4.5/extractors/action/extractPreviewActionProps.d.ts +5 -1
  139. package/dist/types-ts4.5/extractors/action/extractViewActionProps.d.ts +4 -0
  140. package/dist/types-ts4.5/extractors/action/types.d.ts +9 -0
  141. package/dist/types-ts4.5/extractors/flexible/actions/extract-copy-link-action.d.ts +6 -0
  142. package/dist/types-ts4.5/extractors/flexible/actions/extract-download-action.d.ts +6 -0
  143. package/dist/types-ts4.5/extractors/flexible/actions/extract-preview-action.d.ts +6 -0
  144. package/dist/types-ts4.5/extractors/flexible/actions/extract-view-action.d.ts +3 -0
  145. package/dist/types-ts4.5/extractors/flexible/actions/index.d.ts +21 -4
  146. package/dist/types-ts4.5/extractors/flexible/extract-state.d.ts +5 -2
  147. package/dist/types-ts4.5/extractors/flexible/index.d.ts +1 -1
  148. package/dist/types-ts4.5/state/flexible-ui-context/types.d.ts +9 -3
  149. package/dist/types-ts4.5/state/hooks/use-invoke/types.d.ts +7 -1
  150. package/dist/types-ts4.5/state/hooks/use-invoke-client-action/index.d.ts +2 -2
  151. package/dist/types-ts4.5/state/hooks/use-invoke-client-action/types.d.ts +24 -2
  152. package/dist/types-ts4.5/state/hooks/use-resolve/index.d.ts +1 -0
  153. package/dist/types-ts4.5/view/EmbedModal/index.d.ts +8 -0
  154. package/dist/types-ts4.5/view/EmbedModal/types.d.ts +7 -0
  155. package/dist/types-ts4.5/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.d.ts +1 -1
  156. package/dist/types-ts4.5/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/types.d.ts +6 -0
  157. package/dist/types-ts4.5/view/FlexibleCard/components/utils.d.ts +3 -0
  158. package/dist/types-ts4.5/view/FlexibleCard/index.d.ts +1 -1
  159. package/dist/types-ts4.5/view/FlexibleCard/types.d.ts +12 -3
  160. package/package.json +4 -1
@@ -1,6 +1,11 @@
1
1
  import { extractLink } from '@atlaskit/link-extractors';
2
2
  import { canShowAction } from '../../../utils/actions/can-show-action';
3
3
  import { CardAction } from '../../../view/Card/types';
4
+ import { extractInvokeCopyLinkAction } from '../../action/extract-invoke-copy-link-action';
5
+ /**
6
+ * TODO: Remove on cleanup of platform-smart-card-migrate-embed-modal-analytics
7
+ * Replaced with extractCopyLinkClientAction()
8
+ */
4
9
  export const extractCopyLinkAction = (data, actionOptions) => {
5
10
  if (!canShowAction(CardAction.CopyLinkAction, actionOptions)) {
6
11
  return;
@@ -12,4 +17,10 @@ export const extractCopyLinkAction = (data, actionOptions) => {
12
17
  return {
13
18
  url
14
19
  };
20
+ };
21
+ export const extractCopyLinkClientAction = param => {
22
+ const invokeAction = extractInvokeCopyLinkAction(param);
23
+ return invokeAction ? {
24
+ invokeAction
25
+ } : undefined;
15
26
  };
@@ -1,7 +1,13 @@
1
1
  import { canShowAction } from '../../../utils/actions/can-show-action';
2
2
  import { CardAction } from '../../../view/Card/types';
3
+ import { extractInvokeDownloadAction } from '../../action/extract-invoke-download-action';
3
4
  import { getActionsFromJsonLd } from '../../common/actions/extractActions';
4
5
  import { extractDownloadUrl } from '../../common/detail';
6
+
7
+ /**
8
+ * TODO: Remove on cleanup of platform-smart-card-migrate-embed-modal-analytics
9
+ * Replaced with extractDownloadClientAction()
10
+ */
5
11
  export const extractDownloadAction = (data, actionOptions) => {
6
12
  if (!canShowAction(CardAction.DownloadAction, actionOptions)) {
7
13
  return;
@@ -13,4 +19,10 @@ export const extractDownloadAction = (data, actionOptions) => {
13
19
  };
14
20
  }
15
21
  return;
22
+ };
23
+ export const extractDownloadClientAction = param => {
24
+ const invokeAction = extractInvokeDownloadAction(param);
25
+ return invokeAction ? {
26
+ invokeAction
27
+ } : undefined;
16
28
  };
@@ -1,10 +1,16 @@
1
1
  import { extractLink, extractPreview as extractPreviewData, extractProvider, extractTitle } from '@atlaskit/link-extractors';
2
2
  import { canShowAction } from '../../../utils/actions/can-show-action';
3
3
  import { CardAction } from '../../../view/Card/types';
4
+ import { extractInvokePreviewAction } from '../../action/extract-invoke-preview-action';
4
5
  import { extractDownloadUrl } from '../../common/detail';
5
6
  import { extractIsSupportTheming } from '../../common/meta/extractIsSupportTheming';
6
7
  import { extractIsTrusted } from '../../common/meta/extractIsTrusted';
7
8
  import { extractLinkIcon } from '../icon';
9
+
10
+ /**
11
+ * TODO: Remove on cleanup of platform-smart-card-migrate-embed-modal-analytics
12
+ * Replaced with extractPreviewClientAction()
13
+ */
8
14
  export const extractPreviewAction = (response, actionOptions) => {
9
15
  var _extractPreviewData;
10
16
  if (!canShowAction(CardAction.PreviewAction, actionOptions)) {
@@ -26,4 +32,10 @@ export const extractPreviewAction = (response, actionOptions) => {
26
32
  isTrusted: extractIsTrusted(meta)
27
33
  };
28
34
  }
35
+ };
36
+ export const extractPreviewClientAction = param => {
37
+ const invokeAction = extractInvokePreviewAction(param);
38
+ return invokeAction ? {
39
+ invokeAction
40
+ } : undefined;
29
41
  };
@@ -2,6 +2,10 @@ import { extractLink } from '@atlaskit/link-extractors';
2
2
  import { canShowAction } from '../../../utils/actions/can-show-action';
3
3
  import { CardAction } from '../../../view/Card/types';
4
4
  import { getActionsFromJsonLd } from '../../common/actions/extractActions';
5
+
6
+ /**
7
+ * TODO: Remove on cleanup of platform-smart-card-migrate-embed-modal-analytics
8
+ */
5
9
  export const extractViewAction = (data, actionOptions) => {
6
10
  if (!canShowAction(CardAction.ViewAction, actionOptions)) {
7
11
  return;
@@ -2,11 +2,56 @@ import { fg } from '@atlaskit/platform-feature-flags';
2
2
  import { ActionName, InternalActionName } from '../../../constants';
3
3
  import { extractAISummaryAction } from './extract-ai-summary-action';
4
4
  import { extractAutomationAction } from './extract-automation-action';
5
- import { extractCopyLinkAction } from './extract-copy-link-action';
6
- import { extractDownloadAction } from './extract-download-action';
5
+ import { extractCopyLinkAction, extractCopyLinkClientAction } from './extract-copy-link-action';
6
+ import { extractDownloadAction, extractDownloadClientAction } from './extract-download-action';
7
7
  import extractFollowAction from './extract-follow-action';
8
- import { extractPreviewAction } from './extract-preview-action';
8
+ import { extractPreviewAction, extractPreviewClientAction } from './extract-preview-action';
9
9
  import { extractViewRelatedLinksAction } from './extract-view-related-links-action';
10
+ export const extractFlexibleCardActions = ({
11
+ actionOptions,
12
+ aiSummaryConfig,
13
+ appearance,
14
+ fireEvent,
15
+ id,
16
+ origin,
17
+ response,
18
+ url
19
+ }) => {
20
+ const action = {
21
+ [ActionName.CopyLinkAction]: extractCopyLinkClientAction({
22
+ actionOptions,
23
+ appearance,
24
+ id,
25
+ response
26
+ }),
27
+ [ActionName.DownloadAction]: extractDownloadClientAction({
28
+ actionOptions,
29
+ appearance,
30
+ id,
31
+ response
32
+ }),
33
+ [ActionName.FollowAction]: extractFollowAction(response, actionOptions, id),
34
+ [ActionName.PreviewAction]: extractPreviewClientAction({
35
+ actionOptions,
36
+ appearance,
37
+ fireEvent,
38
+ id,
39
+ origin,
40
+ response
41
+ }),
42
+ [ActionName.AutomationAction]: extractAutomationAction(response),
43
+ [InternalActionName.AISummaryAction]: extractAISummaryAction(response, url, actionOptions, aiSummaryConfig),
44
+ ...(fg('platform-smart-card-view-related-urls-action') ? {
45
+ [InternalActionName.ViewRelatedLinksAction]: extractViewRelatedLinksAction(response)
46
+ } : {})
47
+ };
48
+ return Object.values(action).some(value => Boolean(value)) ? action : undefined;
49
+ };
50
+
51
+ /**
52
+ * TODO: Remove on cleanup of platform-smart-card-migrate-embed-modal-analytics
53
+ * Replaced with extractFlexibleCardActions()
54
+ */
10
55
  const extractActions = (response, url, actionOptions, id, aiSummaryConfig) => {
11
56
  const data = response.data;
12
57
  const action = {
@@ -1,7 +1,9 @@
1
1
  import { extractLink } from '@atlaskit/link-extractors';
2
+ import { fg } from '@atlaskit/platform-feature-flags';
2
3
  import { getExtensionKey } from '../../state/helpers';
3
4
  import { canShowAction } from '../../utils/actions/can-show-action';
4
5
  import { CardAction } from '../../view/Card/types';
6
+ import { extractInvokePreviewAction } from '../action/extract-invoke-preview-action';
5
7
  import { extractLozenge } from '../common/lozenge';
6
8
  import { extractPreviewAction } from './actions/extract-preview-action';
7
9
  import extractServerAction from './extract-server-action';
@@ -18,7 +20,7 @@ const toInvokeRequest = (extensionKey, resourceIdentifiers, actionType, details)
18
20
  details
19
21
  };
20
22
  };
21
- const extractAction = (response, id) => {
23
+ const extractAction = (response, id, actionOptions, appearance, origin, fireEvent, resolve) => {
22
24
  var _action$dataRetrieval, _action$dataUpdateAct;
23
25
  const extensionKey = getExtensionKey(response);
24
26
  const data = response === null || response === void 0 ? void 0 : response.data;
@@ -32,11 +34,21 @@ const extractAction = (response, id) => {
32
34
  }
33
35
  const read = toInvokeRequest(extensionKey, action.resourceIdentifiers, (_action$dataRetrieval = action.dataRetrievalAction) === null || _action$dataRetrieval === void 0 ? void 0 : _action$dataRetrieval.name);
34
36
  const url = extractLink(data);
35
- const previewData = response ? extractPreviewAction(response) : null;
37
+ const previewData = !fg('platform-smart-card-migrate-embed-modal-analytics') ? response ? extractPreviewAction(response) : null : undefined;
38
+ const invokePreviewAction = response && fg('platform-smart-card-migrate-embed-modal-analytics') ? extractInvokePreviewAction({
39
+ actionOptions,
40
+ appearance,
41
+ fireEvent,
42
+ id,
43
+ onClose: resolve ? () => url && resolve(url, true) : undefined,
44
+ origin,
45
+ response
46
+ }) : undefined;
36
47
  const details = {
37
48
  id,
38
49
  url,
39
- previewData
50
+ previewData,
51
+ invokePreviewAction
40
52
  };
41
53
  const update = toInvokeRequest(extensionKey, action.resourceIdentifiers, (_action$dataUpdateAct = action.dataUpdateAction) === null || _action$dataUpdateAct === void 0 ? void 0 : _action$dataUpdateAct.name, details);
42
54
  return read || update ? {
@@ -44,7 +56,7 @@ const extractAction = (response, id) => {
44
56
  update
45
57
  } : undefined;
46
58
  };
47
- const extractState = (response, actionOptions, id) => {
59
+ const extractState = (response, actionOptions, id, appearance, origin, fireEvent, resolve) => {
48
60
  if (!response || !response.data) {
49
61
  return;
50
62
  }
@@ -55,7 +67,7 @@ const extractState = (response, actionOptions, id) => {
55
67
  if (!canShowAction(CardAction.ChangeStatusAction, actionOptions)) {
56
68
  return lozenge;
57
69
  }
58
- const action = extractAction(response, id);
70
+ const action = extractAction(response, id, actionOptions, appearance, origin, fireEvent, resolve);
59
71
  return {
60
72
  ...lozenge,
61
73
  action
@@ -1,7 +1,7 @@
1
1
  import { extractAri, extractDateCreated, extractDateUpdated, extractLink, extractPersonCreatedBy, extractPersonOwnedBy, extractTitle } from '@atlaskit/link-extractors';
2
+ import { fg } from '@atlaskit/platform-feature-flags';
2
3
  import { extractSummary } from '../common/primitives';
3
- import extractActions from './actions';
4
- import { extractViewAction } from './actions/extract-view-action';
4
+ import extractActions, { extractFlexibleCardActions } from './actions';
5
5
  import { extractPersonsUpdatedBy } from './collaboratorGroup';
6
6
  import extractPreview from './extract-preview';
7
7
  import extractPriority from './extract-priority';
@@ -11,8 +11,12 @@ import extractProviderIcon from './icon/extract-provider-icon';
11
11
  import { extractLatestCommit } from './latest-commit';
12
12
  import { extractAssignedTo, extractAttachmentCount, extractChecklistProgress, extractCommentCount, extractCreatedBy, extractDueOn, extractLocation, extractModifiedBy, extractOwnedBy, extractPersonAssignedToAsArray, extractProgrammingLanguage, extractReactCount, extractReadTime, extractSentOn, extractSourceBranch, extractStoryPoints, extractSubscriberCount, extractSubTasksProgress, extractTargetBranch, extractViewCount, extractVoteCount } from './utils';
13
13
  const extractFlexibleUiContext = ({
14
+ appearance,
15
+ fireEvent,
14
16
  id,
17
+ origin,
15
18
  renderers,
19
+ resolve,
16
20
  actionOptions,
17
21
  response,
18
22
  aiSummaryConfig,
@@ -24,8 +28,16 @@ const extractFlexibleUiContext = ({
24
28
  const data = response.data;
25
29
  const url = extractLink(data);
26
30
  return {
27
- // Use the original URL in edge cases, such as short links for AI summary and copy link actions.
28
- actions: extractActions(response, props.url, actionOptions, id, aiSummaryConfig),
31
+ actions: fg('platform-smart-card-migrate-embed-modal-analytics') ? extractFlexibleCardActions({
32
+ actionOptions,
33
+ aiSummaryConfig,
34
+ appearance,
35
+ fireEvent,
36
+ id,
37
+ origin,
38
+ response,
39
+ url: props.url // Use the original URL in edge cases, such as short links for AI summary and copy link actions.
40
+ }) : extractActions(response, props.url, actionOptions, id, aiSummaryConfig),
29
41
  assignedToGroup: extractPersonAssignedToAsArray(data),
30
42
  attachmentCount: extractAttachmentCount(data),
31
43
  authorGroup: extractPersonCreatedBy(data),
@@ -41,7 +53,6 @@ const extractFlexibleUiContext = ({
41
53
  assignedTo: extractAssignedTo(data),
42
54
  createdOn: extractDateCreated(data),
43
55
  dueOn: extractDueOn(data),
44
- viewAction: extractViewAction(data, actionOptions),
45
56
  latestCommit: extractLatestCommit(data),
46
57
  linkIcon: extractLinkIcon(response, renderers),
47
58
  location: extractLocation(data),
@@ -56,7 +67,7 @@ const extractFlexibleUiContext = ({
56
67
  snippet: extractSummary(data) || undefined,
57
68
  // Explicitly set here to remove an empty string
58
69
  sourceBranch: extractSourceBranch(data),
59
- state: extractState(response, actionOptions, id),
70
+ state: extractState(response, actionOptions, id, appearance, origin, fireEvent, resolve),
60
71
  subscriberCount: extractSubscriberCount(data),
61
72
  subTasksProgress: extractSubTasksProgress(data),
62
73
  storyPoints: extractStoryPoints(data),
@@ -1,5 +1,7 @@
1
1
  import { useCallback } from 'react';
2
2
  import uuid from 'uuid';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
4
+ import { useAnalyticsEvents } from '../../../common/analytics/generated/use-analytics-events';
3
5
  import * as measure from '../../../utils/performance';
4
6
  import { failUfoExperience, startUfoExperience, succeedUfoExperience } from '../../analytics';
5
7
  const ACTION_EXPERIENCE_NAME = 'smart-link-action-invocation';
@@ -8,51 +10,97 @@ const ACTION_EXPERIENCE_NAME = 'smart-link-action-invocation';
8
10
  * Invoke client action such as preview, download and open link
9
11
  */
10
12
  const useInvokeClientAction = ({
11
- analytics
12
- }) => useCallback(async ({
13
- actionType,
14
- actionFn,
15
- extensionKey,
16
- display
13
+ analytics,
14
+ fireEvent: fireEventProp
17
15
  }) => {
18
- const experienceId = uuid();
16
+ const {
17
+ fireEvent: defaultFireEvent
18
+ } = useAnalyticsEvents();
19
+ const fireEvent = fireEventProp !== null && fireEventProp !== void 0 ? fireEventProp : defaultFireEvent;
20
+ return useCallback(async ({
21
+ actionSubjectId,
22
+ actionType,
23
+ actionFn,
24
+ definitionId = null,
25
+ extensionKey,
26
+ display,
27
+ id,
28
+ resourceType = null
29
+ }) => {
30
+ const experienceId = uuid();
19
31
 
20
- // Begin performance instrumentation.
21
- const markName = `${experienceId}-${actionType}`;
22
- measure.mark(markName, 'pending');
23
- try {
24
- // Begin UFO experience
25
- startUfoExperience(ACTION_EXPERIENCE_NAME, experienceId, {
26
- actionType,
27
- display,
28
- extensionKey,
29
- invokeType: 'client'
30
- });
32
+ // Begin performance instrumentation.
33
+ const markName = `${experienceId}-${actionType}`;
34
+ measure.mark(markName, 'pending');
35
+ try {
36
+ // Begin UFO experience
37
+ startUfoExperience(ACTION_EXPERIENCE_NAME, experienceId, {
38
+ actionType,
39
+ display,
40
+ extensionKey,
41
+ invokeType: 'client'
42
+ });
31
43
 
32
- // Begin analytics instrumentation.
33
- analytics === null || analytics === void 0 ? void 0 : analytics.ui.actionClickedEvent({
34
- actionType,
35
- display
36
- });
44
+ // Begin analytics instrumentation.
45
+ if (actionSubjectId && fg('platform-smart-card-migrate-embed-modal-analytics')) {
46
+ fireEvent(`ui.button.clicked.${actionSubjectId}`, {
47
+ actionType: actionType !== null && actionType !== void 0 ? actionType : null,
48
+ definitionId,
49
+ display: display !== null && display !== void 0 ? display : null,
50
+ id: id !== null && id !== void 0 ? id : experienceId,
51
+ resourceType
52
+ });
53
+ } else {
54
+ analytics === null || analytics === void 0 ? void 0 : analytics.ui.actionClickedEvent({
55
+ actionType,
56
+ display
57
+ });
58
+ }
37
59
 
38
- // Invoke action
39
- const result = await actionFn();
40
- measure.mark(markName, 'resolved');
41
- succeedUfoExperience(ACTION_EXPERIENCE_NAME, experienceId);
42
- analytics === null || analytics === void 0 ? void 0 : analytics.operational.invokeSucceededEvent({
43
- actionType,
44
- display
45
- });
46
- return result;
47
- } catch (err) {
48
- measure.mark(markName, 'errored');
49
- failUfoExperience(ACTION_EXPERIENCE_NAME, experienceId);
50
- const reason = typeof err === 'string' ? err : err === null || err === void 0 ? void 0 : err.message;
51
- analytics === null || analytics === void 0 ? void 0 : analytics.operational.invokeFailedEvent({
52
- actionType,
53
- display,
54
- reason
55
- });
56
- }
57
- }, [analytics === null || analytics === void 0 ? void 0 : analytics.operational, analytics === null || analytics === void 0 ? void 0 : analytics.ui]);
60
+ // Invoke action
61
+ const result = await actionFn();
62
+ measure.mark(markName, 'resolved');
63
+ succeedUfoExperience(ACTION_EXPERIENCE_NAME, experienceId);
64
+ if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
65
+ var _measure$getMeasure$d, _measure$getMeasure;
66
+ fireEvent('operational.smartLinkAction.resolved', {
67
+ actionType: actionType !== null && actionType !== void 0 ? actionType : null,
68
+ definitionId,
69
+ display: display !== null && display !== void 0 ? display : null,
70
+ duration: (_measure$getMeasure$d = (_measure$getMeasure = measure.getMeasure(markName, 'resolved')) === null || _measure$getMeasure === void 0 ? void 0 : _measure$getMeasure.duration) !== null && _measure$getMeasure$d !== void 0 ? _measure$getMeasure$d : null,
71
+ id: id !== null && id !== void 0 ? id : experienceId,
72
+ resourceType
73
+ });
74
+ } else {
75
+ analytics === null || analytics === void 0 ? void 0 : analytics.operational.invokeSucceededEvent({
76
+ actionType,
77
+ display
78
+ });
79
+ }
80
+ return result;
81
+ } catch (err) {
82
+ measure.mark(markName, 'errored');
83
+ failUfoExperience(ACTION_EXPERIENCE_NAME, experienceId);
84
+ const reason = typeof err === 'string' ? err : err === null || err === void 0 ? void 0 : err.message;
85
+ if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
86
+ var _measure$getMeasure$d2, _measure$getMeasure2;
87
+ fireEvent('operational.smartLinkAction.unresolved', {
88
+ actionType: actionType !== null && actionType !== void 0 ? actionType : null,
89
+ definitionId,
90
+ display: display !== null && display !== void 0 ? display : null,
91
+ duration: (_measure$getMeasure$d2 = (_measure$getMeasure2 = measure.getMeasure(markName, 'errored')) === null || _measure$getMeasure2 === void 0 ? void 0 : _measure$getMeasure2.duration) !== null && _measure$getMeasure$d2 !== void 0 ? _measure$getMeasure$d2 : null,
92
+ id: id !== null && id !== void 0 ? id : experienceId,
93
+ reason,
94
+ resourceType
95
+ });
96
+ } else {
97
+ analytics === null || analytics === void 0 ? void 0 : analytics.operational.invokeFailedEvent({
98
+ actionType,
99
+ display,
100
+ reason
101
+ });
102
+ }
103
+ }
104
+ }, [analytics === null || analytics === void 0 ? void 0 : analytics.operational, analytics === null || analytics === void 0 ? void 0 : analytics.ui, fireEvent]);
105
+ };
58
106
  export default useInvokeClientAction;
@@ -1,5 +1,10 @@
1
1
  import { useMemo } from 'react';
2
2
  import uuid from 'uuid';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
4
+ import { useAnalyticsEvents } from '../../common/analytics/generated/use-analytics-events';
5
+ import { extractInvokeDownloadAction } from '../../extractors/action/extract-invoke-download-action';
6
+ import { extractInvokePreviewAction } from '../../extractors/action/extract-invoke-preview-action';
7
+ import { extractInvokeViewAction } from '../../extractors/action/extract-invoke-view-action';
3
8
  import { extractDownloadActionProps } from '../../extractors/action/extractDownloadActionProps';
4
9
  import { extractPreviewActionProps } from '../../extractors/action/extractPreviewActionProps';
5
10
  import { extractViewActionProps } from '../../extractors/action/extractViewActionProps';
@@ -18,6 +23,9 @@ export function useSmartLinkActions({
18
23
  const id = useMemo(() => uuid(), []);
19
24
  const linkState = useLinkState(url);
20
25
  const linkAnalytics = useLinkAnalytics(url, id);
26
+ const {
27
+ fireEvent
28
+ } = useAnalyticsEvents();
21
29
  const invokeClientAction = useInvokeClientAction({
22
30
  analytics: linkAnalytics
23
31
  });
@@ -32,15 +40,25 @@ export function useSmartLinkActions({
32
40
  actionOptions
33
41
  };
34
42
  const actions = [];
35
- const downloadActionProps = extractDownloadActionProps(opts);
43
+ const invokeParam = {
44
+ actionOptions,
45
+ appearance,
46
+ id,
47
+ response: linkState.details
48
+ };
49
+ const downloadActionProps = fg('platform-smart-card-migrate-embed-modal-analytics') ? extractInvokeDownloadAction(invokeParam) : extractDownloadActionProps(opts);
36
50
  if (downloadActionProps) {
37
51
  actions.push(toAction(downloadActionProps, invokeClientAction, messages.download, 'download-content'));
38
52
  }
39
- const viewActionProps = extractViewActionProps(opts);
53
+ const viewActionProps = fg('platform-smart-card-migrate-embed-modal-analytics') ? extractInvokeViewAction(invokeParam) : extractViewActionProps(opts);
40
54
  if (viewActionProps) {
41
55
  actions.push(toAction(viewActionProps, invokeClientAction, messages.view, 'view-content'));
42
56
  }
43
- const previewActionProps = extractPreviewActionProps(opts);
57
+ const previewActionProps = fg('platform-smart-card-migrate-embed-modal-analytics') ? extractInvokePreviewAction({
58
+ ...invokeParam,
59
+ fireEvent,
60
+ origin
61
+ }) : extractPreviewActionProps(opts);
44
62
  if (previewActionProps) {
45
63
  actions.push(toAction(previewActionProps, invokeClientAction, messages.preview_improved, 'preview-content'));
46
64
  }
@@ -1,5 +1,7 @@
1
1
  import React from 'react';
2
2
  import { AnalyticsContext } from '@atlaskit/analytics-next';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
4
+ import { context } from './analytics';
3
5
  /**
4
6
  * Provides an analytics context to supply attributes to events based on a URL
5
7
  */
@@ -14,6 +16,7 @@ export const LinkAnalyticsContext = ({
14
16
  data: {
15
17
  source,
16
18
  attributes: {
19
+ ...(fg('platform-smart-card-migrate-embed-modal-analytics') ? context : {}),
17
20
  displayCategory,
18
21
  display,
19
22
  id
@@ -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: "32.7.0"
7
+ packageVersion: "32.7.1"
8
8
  };
9
9
  export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
10
10
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -16,7 +16,10 @@ export const mockByUrl = url => {
16
16
  access: 'granted',
17
17
  auth: [],
18
18
  definitionId: 'd1',
19
- key: 'object-provider'
19
+ key: 'object-provider',
20
+ resourceType: 'object-resource',
21
+ subproduct: 'object-subproduct',
22
+ product: 'object-product'
20
23
  },
21
24
  data: {
22
25
  '@context': {
@@ -48,6 +48,7 @@ const FlexibleResolvedView = ({
48
48
  onClick: onClick,
49
49
  onError: onError,
50
50
  onResolve: onResolve,
51
+ origin: "smartLinkCard",
51
52
  actionOptions: actionOptions,
52
53
  testId: testId,
53
54
  ui: FlexibleCardUiOptions,
@@ -26,6 +26,7 @@ const UnresolvedView = ({
26
26
  onAuthorize: onAuthorize,
27
27
  onClick: onClick,
28
28
  onError: onError,
29
+ origin: "smartLinkCard",
29
30
  testId: testId,
30
31
  ui: FlexibleCardUiOptions,
31
32
  url: url
@@ -196,6 +196,7 @@ function Component({
196
196
  cardState: cardState,
197
197
  onAuthorize: services.length && handleAuthorize || undefined,
198
198
  onClick: handleClickWrapper,
199
+ origin: "smartLinkCard",
199
200
  renderers: renderers,
200
201
  ui: ui,
201
202
  showHoverPreview: showHoverPreview,
@@ -1,9 +1,12 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
1
2
  import React, { useCallback, useRef, useState } from 'react';
2
3
  import ModalDialog, { ModalBody, ModalTransition } from '@atlaskit/modal-dialog';
4
+ import { fg } from '@atlaskit/platform-feature-flags';
3
5
  import { useThemeObserver } from '@atlaskit/tokens';
4
- import { ActionName, CardDisplay } from '../../constants';
6
+ import { ActionName, CardDisplay, SmartLinkSize } from '../../constants';
5
7
  import useInvokeClientAction from '../../state/hooks/use-invoke-client-action';
6
8
  import { downloadUrl, getPreviewUrlWithTheme, openUrl } from '../../utils';
9
+ import Icon from '../FlexibleCard/components/elements/icon';
7
10
  import withAnalytics from './components/analytics';
8
11
  import EmbedContent from './components/embed-content';
9
12
  import withErrorBoundary from './components/error-boundary';
@@ -15,11 +18,14 @@ const toWidth = size => size === EmbedModalSize.Large ? MAX_MODAL_SIZE : MIN_MOD
15
18
  const EmbedModal = ({
16
19
  analytics,
17
20
  download,
21
+ invokeDownloadAction,
18
22
  extensionKey,
23
+ fireEvent,
19
24
  icon,
20
25
  iframeName,
21
26
  isSupportTheming,
22
27
  isTrusted = false,
28
+ linkIcon,
23
29
  onClose,
24
30
  onOpen,
25
31
  onResize,
@@ -29,14 +35,16 @@ const EmbedModal = ({
29
35
  src,
30
36
  testId = 'smart-embed-preview-modal',
31
37
  title,
32
- url
38
+ url,
39
+ invokeViewAction
33
40
  }) => {
34
41
  const defaultWidth = toWidth(size);
35
42
  const [isOpen, setIsOpen] = useState(showModal);
36
43
  const [width, setWidth] = useState(defaultWidth);
37
44
  const openAt = useRef();
38
45
  const invoke = useInvokeClientAction({
39
- analytics
46
+ analytics,
47
+ fireEvent
40
48
  });
41
49
  const handleOnOpenComplete = useCallback(() => {
42
50
  openAt.current = Date.now();
@@ -68,21 +76,29 @@ const EmbedModal = ({
68
76
  const themeState = useThemeObserver();
69
77
  let previewUrl = src;
70
78
  const handleOnViewActionClick = useCallback(() => {
71
- invoke({
72
- actionType: 'ViewAction',
73
- actionFn: async () => openUrl(url),
74
- display: CardDisplay.EmbedPreview,
75
- extensionKey
76
- });
77
- }, [extensionKey, invoke, url]);
79
+ if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
80
+ invokeViewAction && invoke(invokeViewAction);
81
+ } else {
82
+ invoke({
83
+ actionType: 'ViewAction',
84
+ actionFn: async () => openUrl(url),
85
+ display: CardDisplay.EmbedPreview,
86
+ extensionKey
87
+ });
88
+ }
89
+ }, [extensionKey, invoke, url, invokeViewAction]);
78
90
  const handleOnDownloadActionClick = useCallback(() => {
79
- invoke({
80
- actionType: ActionName.DownloadAction,
81
- actionFn: async () => downloadUrl(download),
82
- display: CardDisplay.EmbedPreview,
83
- extensionKey
84
- });
85
- }, [download, extensionKey, invoke]);
91
+ if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
92
+ invokeDownloadAction && invoke(invokeDownloadAction);
93
+ } else {
94
+ invoke({
95
+ actionType: ActionName.DownloadAction,
96
+ actionFn: async () => downloadUrl(download),
97
+ display: CardDisplay.EmbedPreview,
98
+ extensionKey
99
+ });
100
+ }
101
+ }, [download, invokeDownloadAction, extensionKey, invoke]);
86
102
  if (previewUrl && isSupportTheming) {
87
103
  previewUrl = getPreviewUrlWithTheme(previewUrl, themeState);
88
104
  }
@@ -94,10 +110,15 @@ const EmbedModal = ({
94
110
  testId: testId,
95
111
  width: width
96
112
  }, /*#__PURE__*/React.createElement(LinkInfo, {
97
- icon: icon,
113
+ icon: fg('platform-smart-card-migrate-embed-modal-analytics') ? linkIcon ? {
114
+ icon: /*#__PURE__*/React.createElement(Icon, _extends({}, linkIcon, {
115
+ size: SmartLinkSize.Large
116
+ })),
117
+ isFlexibleUi: true
118
+ } : undefined : icon,
98
119
  providerName: providerName,
99
- onViewButtonClick: url ? handleOnViewActionClick : undefined,
100
- onDownloadButtonClick: download ? handleOnDownloadActionClick : undefined,
120
+ onViewButtonClick: fg('platform-smart-card-migrate-embed-modal-analytics') ? invokeViewAction ? handleOnViewActionClick : undefined : url ? handleOnViewActionClick : undefined,
121
+ onDownloadButtonClick: fg('platform-smart-card-migrate-embed-modal-analytics') ? invokeDownloadAction ? handleOnDownloadActionClick : undefined : download ? handleOnDownloadActionClick : undefined,
101
122
  onResizeButtonClick: handleOnResizeClick,
102
123
  size: width,
103
124
  title: title,