@atlaskit/smart-card 33.1.0 → 33.2.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 (132) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/cjs/extractors/flexible/actions/extract-copy-link-action.js +1 -20
  3. package/dist/cjs/extractors/flexible/actions/extract-download-action.js +1 -23
  4. package/dist/cjs/extractors/flexible/actions/extract-preview-action.js +1 -34
  5. package/dist/cjs/extractors/flexible/actions/index.js +2 -15
  6. package/dist/cjs/extractors/flexible/extract-state.js +1 -5
  7. package/dist/cjs/extractors/flexible/index.js +3 -7
  8. package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +18 -190
  9. package/dist/cjs/state/hooks/use-invoke-client-action/index.js +21 -44
  10. package/dist/cjs/state/hooks-external/useSmartLinkActions.js +4 -18
  11. package/dist/cjs/utils/analytics/SmartLinkAnalyticsContext.js +3 -37
  12. package/dist/cjs/utils/analytics/analytics.js +1 -1
  13. package/dist/cjs/view/CardWithUrl/component.js +12 -25
  14. package/dist/cjs/view/CardWithUrl/loader.js +10 -22
  15. package/dist/cjs/view/EmbedModal/components/analytics/index.js +40 -89
  16. package/dist/cjs/view/EmbedModal/index.js +8 -65
  17. package/dist/cjs/view/FlexibleCard/components/actions/copy-link-action/index.js +26 -63
  18. package/dist/cjs/view/FlexibleCard/components/actions/download-action/index.js +4 -40
  19. package/dist/cjs/view/FlexibleCard/components/actions/preview-action/index.js +4 -47
  20. package/dist/cjs/view/FlexibleCard/components/elements/lozenge/lozenge-action/index.js +3 -3
  21. package/dist/cjs/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.js +10 -26
  22. package/dist/cjs/view/FlexibleCard/components/utils.js +1 -28
  23. package/dist/cjs/view/HoverCard/components/views/resolved/index.js +13 -30
  24. package/dist/cjs/view/HoverCard/index.js +10 -22
  25. package/dist/cjs/view/LinkUrl/index.js +1 -1
  26. package/dist/es2019/extractors/flexible/actions/extract-copy-link-action.js +0 -19
  27. package/dist/es2019/extractors/flexible/actions/extract-download-action.js +0 -21
  28. package/dist/es2019/extractors/flexible/actions/extract-preview-action.js +0 -34
  29. package/dist/es2019/extractors/flexible/actions/index.js +4 -23
  30. package/dist/es2019/extractors/flexible/extract-state.js +1 -5
  31. package/dist/es2019/extractors/flexible/index.js +3 -4
  32. package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +2 -172
  33. package/dist/es2019/state/hooks/use-invoke-client-action/index.js +21 -44
  34. package/dist/es2019/state/hooks-external/useSmartLinkActions.js +4 -18
  35. package/dist/es2019/utils/analytics/SmartLinkAnalyticsContext.js +3 -40
  36. package/dist/es2019/utils/analytics/analytics.js +1 -1
  37. package/dist/es2019/view/CardWithUrl/component.js +13 -26
  38. package/dist/es2019/view/CardWithUrl/loader.js +11 -23
  39. package/dist/es2019/view/EmbedModal/components/analytics/index.js +39 -88
  40. package/dist/es2019/view/EmbedModal/index.js +10 -33
  41. package/dist/es2019/view/FlexibleCard/components/actions/copy-link-action/index.js +11 -32
  42. package/dist/es2019/view/FlexibleCard/components/actions/download-action/index.js +4 -22
  43. package/dist/es2019/view/FlexibleCard/components/actions/preview-action/index.js +4 -27
  44. package/dist/es2019/view/FlexibleCard/components/elements/lozenge/lozenge-action/index.js +3 -3
  45. package/dist/es2019/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.js +6 -24
  46. package/dist/es2019/view/FlexibleCard/components/utils.js +0 -25
  47. package/dist/es2019/view/HoverCard/components/views/resolved/index.js +12 -25
  48. package/dist/es2019/view/HoverCard/index.js +11 -23
  49. package/dist/es2019/view/LinkUrl/index.js +1 -1
  50. package/dist/esm/extractors/flexible/actions/extract-copy-link-action.js +0 -19
  51. package/dist/esm/extractors/flexible/actions/extract-download-action.js +0 -23
  52. package/dist/esm/extractors/flexible/actions/extract-preview-action.js +0 -34
  53. package/dist/esm/extractors/flexible/actions/index.js +4 -17
  54. package/dist/esm/extractors/flexible/extract-state.js +1 -5
  55. package/dist/esm/extractors/flexible/index.js +3 -4
  56. package/dist/esm/state/analytics/useSmartLinkAnalytics.js +19 -191
  57. package/dist/esm/state/hooks/use-invoke-client-action/index.js +21 -44
  58. package/dist/esm/state/hooks-external/useSmartLinkActions.js +4 -18
  59. package/dist/esm/utils/analytics/SmartLinkAnalyticsContext.js +3 -37
  60. package/dist/esm/utils/analytics/analytics.js +1 -1
  61. package/dist/esm/view/CardWithUrl/component.js +13 -26
  62. package/dist/esm/view/CardWithUrl/loader.js +10 -22
  63. package/dist/esm/view/EmbedModal/components/analytics/index.js +40 -89
  64. package/dist/esm/view/EmbedModal/index.js +10 -67
  65. package/dist/esm/view/FlexibleCard/components/actions/copy-link-action/index.js +26 -63
  66. package/dist/esm/view/FlexibleCard/components/actions/download-action/index.js +4 -40
  67. package/dist/esm/view/FlexibleCard/components/actions/preview-action/index.js +4 -47
  68. package/dist/esm/view/FlexibleCard/components/elements/lozenge/lozenge-action/index.js +3 -3
  69. package/dist/esm/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.js +6 -26
  70. package/dist/esm/view/FlexibleCard/components/utils.js +0 -27
  71. package/dist/esm/view/HoverCard/components/views/resolved/index.js +13 -30
  72. package/dist/esm/view/HoverCard/index.js +10 -22
  73. package/dist/esm/view/LinkUrl/index.js +1 -1
  74. package/dist/types/extractors/flexible/actions/extract-copy-link-action.d.ts +0 -7
  75. package/dist/types/extractors/flexible/actions/extract-download-action.d.ts +0 -7
  76. package/dist/types/extractors/flexible/actions/extract-preview-action.d.ts +0 -7
  77. package/dist/types/extractors/flexible/actions/index.d.ts +0 -6
  78. package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +2 -60
  79. package/dist/types/state/flexible-ui-context/types.d.ts +4 -19
  80. package/dist/types/state/hooks/use-invoke/types.d.ts +0 -6
  81. package/dist/types/state/hooks/use-invoke-client-action/index.d.ts +1 -1
  82. package/dist/types/state/hooks/useSmartLink.d.ts +1 -16
  83. package/dist/types/utils/analytics/SmartLinkAnalyticsContext.d.ts +1 -1
  84. package/dist/types/utils/mocks.d.ts +1 -16
  85. package/dist/types/view/EmbedModal/index.d.ts +0 -2
  86. package/dist/types/view/EmbedModal/types.d.ts +0 -3
  87. package/dist/types/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.d.ts +1 -1
  88. package/dist/types/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/types.d.ts +0 -6
  89. package/dist/types/view/FlexibleCard/components/utils.d.ts +0 -6
  90. package/dist/types/view/HoverCard/components/CustomPopupContainer.d.ts +1 -1
  91. package/dist/types/view/HoverCard/components/views/resolved/index.d.ts +1 -1
  92. package/dist/types-ts4.5/extractors/flexible/actions/extract-copy-link-action.d.ts +0 -7
  93. package/dist/types-ts4.5/extractors/flexible/actions/extract-download-action.d.ts +0 -7
  94. package/dist/types-ts4.5/extractors/flexible/actions/extract-preview-action.d.ts +0 -7
  95. package/dist/types-ts4.5/extractors/flexible/actions/index.d.ts +0 -6
  96. package/dist/types-ts4.5/state/analytics/useSmartLinkAnalytics.d.ts +2 -60
  97. package/dist/types-ts4.5/state/flexible-ui-context/types.d.ts +4 -19
  98. package/dist/types-ts4.5/state/hooks/use-invoke/types.d.ts +0 -6
  99. package/dist/types-ts4.5/state/hooks/use-invoke-client-action/index.d.ts +1 -1
  100. package/dist/types-ts4.5/state/hooks/useSmartLink.d.ts +1 -16
  101. package/dist/types-ts4.5/utils/analytics/SmartLinkAnalyticsContext.d.ts +1 -1
  102. package/dist/types-ts4.5/utils/mocks.d.ts +1 -16
  103. package/dist/types-ts4.5/view/EmbedModal/index.d.ts +0 -2
  104. package/dist/types-ts4.5/view/EmbedModal/types.d.ts +0 -3
  105. package/dist/types-ts4.5/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.d.ts +1 -1
  106. package/dist/types-ts4.5/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/types.d.ts +0 -6
  107. package/dist/types-ts4.5/view/FlexibleCard/components/utils.d.ts +0 -6
  108. package/dist/types-ts4.5/view/HoverCard/components/CustomPopupContainer.d.ts +1 -1
  109. package/dist/types-ts4.5/view/HoverCard/components/views/resolved/index.d.ts +1 -1
  110. package/package.json +1 -4
  111. package/dist/cjs/extractors/action/extractDownloadActionProps.js +0 -32
  112. package/dist/cjs/extractors/action/extractPreviewActionProps.js +0 -47
  113. package/dist/cjs/extractors/action/extractViewActionProps.js +0 -31
  114. package/dist/cjs/extractors/flexible/actions/extract-view-action.js +0 -27
  115. package/dist/es2019/extractors/action/extractDownloadActionProps.js +0 -24
  116. package/dist/es2019/extractors/action/extractPreviewActionProps.js +0 -36
  117. package/dist/es2019/extractors/action/extractViewActionProps.js +0 -23
  118. package/dist/es2019/extractors/flexible/actions/extract-view-action.js +0 -20
  119. package/dist/esm/extractors/action/extractDownloadActionProps.js +0 -27
  120. package/dist/esm/extractors/action/extractPreviewActionProps.js +0 -41
  121. package/dist/esm/extractors/action/extractViewActionProps.js +0 -26
  122. package/dist/esm/extractors/flexible/actions/extract-view-action.js +0 -22
  123. package/dist/types/extractors/action/extractDownloadActionProps.d.ts +0 -7
  124. package/dist/types/extractors/action/extractPreviewActionProps.d.ts +0 -7
  125. package/dist/types/extractors/action/extractViewActionProps.d.ts +0 -7
  126. package/dist/types/extractors/flexible/actions/extract-view-action.d.ts +0 -7
  127. package/dist/types/view/FlexibleCard/components/actions/follow-action/__fixtures__/follow-goal-context.d.ts +0 -3
  128. package/dist/types-ts4.5/extractors/action/extractDownloadActionProps.d.ts +0 -7
  129. package/dist/types-ts4.5/extractors/action/extractPreviewActionProps.d.ts +0 -7
  130. package/dist/types-ts4.5/extractors/action/extractViewActionProps.d.ts +0 -7
  131. package/dist/types-ts4.5/extractors/flexible/actions/extract-view-action.d.ts +0 -7
  132. package/dist/types-ts4.5/view/FlexibleCard/components/actions/follow-action/__fixtures__/follow-goal-context.d.ts +0 -3
@@ -2,9 +2,7 @@ import React, { lazy, Suspense, useCallback, useEffect, useState } from 'react';
2
2
  import { ErrorBoundary } from 'react-error-boundary';
3
3
  import { di } from 'react-magnetic-di';
4
4
  import uuid from 'uuid';
5
- import { fg } from '@atlaskit/platform-feature-flags';
6
5
  import { useAnalyticsEvents } from '../../common/analytics/generated/use-analytics-events';
7
- import { useSmartLinkAnalytics } from '../../state';
8
6
  import { failUfoExperience, startUfoExperience } from '../../state/analytics';
9
7
  import { importWithRetry } from '../../utils';
10
8
  import { useSmartLinkAnalyticsContext } from '../../utils/analytics/SmartLinkAnalyticsContext';
@@ -51,7 +49,6 @@ export function CardWithURLRenderer(props) {
51
49
  resolvingPlaceholder,
52
50
  truncateInline
53
51
  } = props;
54
- const analytics = useSmartLinkAnalytics(url !== null && url !== void 0 ? url : '', id);
55
52
  const isFlexibleUi = isFlexibleUiCard(children);
56
53
  const analyticsContext = useSmartLinkAnalyticsContext({
57
54
  display: isFlexibleUi ? 'flexible' : appearance,
@@ -79,32 +76,23 @@ export function CardWithURLRenderer(props) {
79
76
  definitionId: null
80
77
  });
81
78
  } else if (error.name !== 'APIError') {
82
- if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
83
- startUfoExperience('smart-link-rendered', id || 'NULL');
84
- failUfoExperience('smart-link-rendered', id || 'NULL');
85
- failUfoExperience('smart-link-authenticated', id || 'NULL');
86
- fireEvent('ui.smartLink.renderFailed', {
87
- ...(analyticsContext === null || analyticsContext === void 0 ? void 0 : analyticsContext.attributes),
88
- display: isFlexibleUi ? 'flexible' : appearance,
89
- id: id !== null && id !== void 0 ? id : null,
90
- error: error,
91
- errorInfo: errorInfo
92
- });
93
- } else {
94
- analytics.ui.renderFailedEvent({
95
- display: isFlexibleUi ? 'flexible' : appearance,
96
- id,
97
- error,
98
- errorInfo
99
- });
100
- }
79
+ startUfoExperience('smart-link-rendered', id || 'NULL');
80
+ failUfoExperience('smart-link-rendered', id || 'NULL');
81
+ failUfoExperience('smart-link-authenticated', id || 'NULL');
82
+ fireEvent('ui.smartLink.renderFailed', {
83
+ ...(analyticsContext === null || analyticsContext === void 0 ? void 0 : analyticsContext.attributes),
84
+ display: isFlexibleUi ? 'flexible' : appearance,
85
+ id: id !== null && id !== void 0 ? id : null,
86
+ error: error,
87
+ errorInfo: errorInfo
88
+ });
101
89
  }
102
90
  onError && onError({
103
91
  status: 'errored',
104
92
  url: url !== null && url !== void 0 ? url : '',
105
93
  err: error
106
94
  });
107
- }, [analytics.ui, analyticsContext, appearance, id, onError, url, isFlexibleUi, fireEvent]);
95
+ }, [analyticsContext === null || analyticsContext === void 0 ? void 0 : analyticsContext.attributes, appearance, fireEvent, id, isFlexibleUi, onError, url]);
108
96
  if (!url) {
109
97
  throw new Error('@atlaskit/smart-card: url property is missing.');
110
98
  }
@@ -1,13 +1,11 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { useCallback } from 'react';
3
- import { fg } from '@atlaskit/platform-feature-flags';
4
3
  import { CardDisplay } from '../../../../constants';
5
4
  import { failUfoExperience, startUfoExperience, succeedUfoExperience } from '../../../../state/analytics';
6
5
  import { EmbedModalSize } from '../../types';
7
6
  const getResizeFrom = size => size === EmbedModalSize.Small ? EmbedModalSize.Large : EmbedModalSize.Small;
8
7
  const withAnalytics = Component => props => {
9
8
  const {
10
- analytics,
11
9
  fireEvent,
12
10
  extensionKey,
13
11
  id,
@@ -18,108 +16,61 @@ const withAnalytics = Component => props => {
18
16
  origin
19
17
  } = props;
20
18
  const handleOnOpen = useCallback(context => {
21
- if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
22
- fireEvent === null || fireEvent === void 0 ? void 0 : fireEvent('screen.embedPreviewModal.viewed', {
23
- origin: origin !== null && origin !== void 0 ? origin : null,
24
- size: context.size
25
- });
26
- } else {
27
- analytics === null || analytics === void 0 ? void 0 : analytics.screen.modalViewedEvent({
28
- name: 'embedPreviewModal',
29
- attributes: {
30
- origin,
31
- size: context.size
32
- }
33
- });
34
- }
35
- if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
36
- succeedUfoExperience('smart-link-rendered', id || 'NULL', {
37
- extensionKey,
38
- display: CardDisplay.EmbedPreview
39
- });
19
+ fireEvent === null || fireEvent === void 0 ? void 0 : fireEvent('screen.embedPreviewModal.viewed', {
20
+ origin: origin !== null && origin !== void 0 ? origin : null,
21
+ size: context.size
22
+ });
23
+ succeedUfoExperience('smart-link-rendered', id || 'NULL', {
24
+ extensionKey,
25
+ display: CardDisplay.EmbedPreview
26
+ });
40
27
 
41
- // UFO will disregard this if authentication experience has not yet been started
42
- succeedUfoExperience('smart-link-authenticated', id || 'NULL', {
43
- display: CardDisplay.EmbedPreview
44
- });
45
- fireEvent === null || fireEvent === void 0 ? void 0 : fireEvent('ui.smartLink.renderSuccess', {
46
- display: CardDisplay.EmbedPreview
47
- });
48
- } else {
49
- analytics === null || analytics === void 0 ? void 0 : analytics.ui.renderSuccessEvent({
50
- status: 'resolved',
51
- display: CardDisplay.EmbedPreview
52
- });
53
- }
28
+ // UFO will disregard this if authentication experience has not yet been started
29
+ succeedUfoExperience('smart-link-authenticated', id || 'NULL', {
30
+ display: CardDisplay.EmbedPreview
31
+ });
32
+ fireEvent === null || fireEvent === void 0 ? void 0 : fireEvent('ui.smartLink.renderSuccess', {
33
+ display: CardDisplay.EmbedPreview
34
+ });
54
35
  if (onOpen) {
55
36
  onOpen(context);
56
37
  }
57
- }, [analytics === null || analytics === void 0 ? void 0 : analytics.screen, analytics === null || analytics === void 0 ? void 0 : analytics.ui, fireEvent, extensionKey, id, onOpen, origin]);
38
+ }, [fireEvent, extensionKey, id, onOpen, origin]);
58
39
  const handleOnOpenFailed = useCallback((error, errorInfo) => {
59
- if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
60
- startUfoExperience('smart-link-rendered', id || 'NULL');
61
- failUfoExperience('smart-link-rendered', id || 'NULL');
62
- failUfoExperience('smart-link-authenticated', id || 'NULL');
63
- fireEvent === null || fireEvent === void 0 ? void 0 : fireEvent('ui.smartLink.renderFailed', {
64
- display: CardDisplay.EmbedPreview,
65
- error: error,
66
- errorInfo: errorInfo,
67
- id: id !== null && id !== void 0 ? id : null
68
- });
69
- } else {
70
- analytics === null || analytics === void 0 ? void 0 : analytics.ui.renderFailedEvent({
71
- display: CardDisplay.EmbedPreview,
72
- error,
73
- errorInfo
74
- });
75
- }
40
+ startUfoExperience('smart-link-rendered', id || 'NULL');
41
+ failUfoExperience('smart-link-rendered', id || 'NULL');
42
+ failUfoExperience('smart-link-authenticated', id || 'NULL');
43
+ fireEvent === null || fireEvent === void 0 ? void 0 : fireEvent('ui.smartLink.renderFailed', {
44
+ display: CardDisplay.EmbedPreview,
45
+ error: error,
46
+ errorInfo: errorInfo,
47
+ id: id !== null && id !== void 0 ? id : null
48
+ });
76
49
  if (onOpenFailed) {
77
50
  onOpenFailed(error, errorInfo);
78
51
  }
79
- }, [analytics === null || analytics === void 0 ? void 0 : analytics.ui, fireEvent, id, onOpenFailed]);
52
+ }, [fireEvent, id, onOpenFailed]);
80
53
  const handleOnClose = useCallback(context => {
81
- if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
82
- var _context$duration;
83
- fireEvent === null || fireEvent === void 0 ? void 0 : fireEvent('ui.modal.closed.embedPreview', {
84
- origin: origin !== null && origin !== void 0 ? origin : null,
85
- previewTime: (_context$duration = context.duration) !== null && _context$duration !== void 0 ? _context$duration : null,
86
- size: context.size
87
- });
88
- } else {
89
- analytics === null || analytics === void 0 ? void 0 : analytics.ui.modalClosedEvent({
90
- actionSubjectId: 'embedPreview',
91
- attributes: {
92
- origin,
93
- previewTime: context.duration,
94
- size: context.size
95
- }
96
- });
97
- }
54
+ var _context$duration;
55
+ fireEvent === null || fireEvent === void 0 ? void 0 : fireEvent('ui.modal.closed.embedPreview', {
56
+ origin: origin !== null && origin !== void 0 ? origin : null,
57
+ previewTime: (_context$duration = context.duration) !== null && _context$duration !== void 0 ? _context$duration : null,
58
+ size: context.size
59
+ });
98
60
  if (onClose) {
99
61
  onClose(context);
100
62
  }
101
- }, [analytics === null || analytics === void 0 ? void 0 : analytics.ui, fireEvent, onClose, origin]);
63
+ }, [fireEvent, onClose, origin]);
102
64
  const handleOnResize = useCallback(context => {
103
- if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
104
- fireEvent === null || fireEvent === void 0 ? void 0 : fireEvent('ui.button.clicked.embedPreviewResize', {
105
- newSize: context.size,
106
- origin: origin !== null && origin !== void 0 ? origin : null,
107
- previousSize: getResizeFrom(context.size)
108
- });
109
- } else {
110
- analytics === null || analytics === void 0 ? void 0 : analytics.ui.buttonClickedEvent({
111
- actionSubjectId: 'embedPreviewResize',
112
- attributes: {
113
- newSize: context.size,
114
- origin,
115
- previousSize: getResizeFrom(context.size)
116
- }
117
- });
118
- }
65
+ fireEvent === null || fireEvent === void 0 ? void 0 : fireEvent('ui.button.clicked.embedPreviewResize', {
66
+ newSize: context.size,
67
+ origin: origin !== null && origin !== void 0 ? origin : null,
68
+ previousSize: getResizeFrom(context.size)
69
+ });
119
70
  if (onResize) {
120
71
  onResize(context);
121
72
  }
122
- }, [analytics === null || analytics === void 0 ? void 0 : analytics.ui, fireEvent, onResize, origin]);
73
+ }, [fireEvent, onResize, origin]);
123
74
  return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
124
75
  onClose: handleOnClose,
125
76
  onOpen: handleOnOpen,
@@ -1,11 +1,10 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { useCallback, useRef, useState } from 'react';
3
3
  import ModalDialog, { ModalBody, ModalTransition } from '@atlaskit/modal-dialog';
4
- import { fg } from '@atlaskit/platform-feature-flags';
5
4
  import { useThemeObserver } from '@atlaskit/tokens';
6
- import { ActionName, CardDisplay, SmartLinkSize } from '../../constants';
5
+ import { SmartLinkSize } from '../../constants';
7
6
  import useInvokeClientAction from '../../state/hooks/use-invoke-client-action';
8
- import { downloadUrl, getPreviewUrlWithTheme, openUrl } from '../../utils';
7
+ import { getPreviewUrlWithTheme } from '../../utils';
9
8
  import Icon from '../FlexibleCard/components/elements/icon';
10
9
  import withAnalytics from './components/analytics';
11
10
  import EmbedContent from './components/embed-content';
@@ -17,11 +16,8 @@ const toSize = width => width === MAX_MODAL_SIZE ? EmbedModalSize.Large : EmbedM
17
16
  const toWidth = size => size === EmbedModalSize.Large ? MAX_MODAL_SIZE : MIN_MODAL_SIZE;
18
17
  const EmbedModal = ({
19
18
  analytics,
20
- download,
21
19
  invokeDownloadAction,
22
- extensionKey,
23
20
  fireEvent,
24
- icon,
25
21
  iframeName,
26
22
  isSupportTheming,
27
23
  isTrusted = false,
@@ -35,7 +31,6 @@ const EmbedModal = ({
35
31
  src,
36
32
  testId = 'smart-embed-preview-modal',
37
33
  title,
38
- url,
39
34
  invokeViewAction
40
35
  }) => {
41
36
  const defaultWidth = toWidth(size);
@@ -76,29 +71,11 @@ const EmbedModal = ({
76
71
  const themeState = useThemeObserver();
77
72
  let previewUrl = src;
78
73
  const handleOnViewActionClick = useCallback(() => {
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]);
74
+ invokeViewAction && invoke(invokeViewAction);
75
+ }, [invoke, invokeViewAction]);
90
76
  const handleOnDownloadActionClick = useCallback(() => {
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]);
77
+ invokeDownloadAction && invoke(invokeDownloadAction);
78
+ }, [invokeDownloadAction, invoke]);
102
79
  if (previewUrl && isSupportTheming) {
103
80
  previewUrl = getPreviewUrlWithTheme(previewUrl, themeState);
104
81
  }
@@ -110,15 +87,15 @@ const EmbedModal = ({
110
87
  testId: testId,
111
88
  width: width
112
89
  }, /*#__PURE__*/React.createElement(LinkInfo, {
113
- icon: fg('platform-smart-card-migrate-embed-modal-analytics') ? linkIcon ? {
90
+ icon: linkIcon && {
114
91
  icon: /*#__PURE__*/React.createElement(Icon, _extends({}, linkIcon, {
115
92
  size: SmartLinkSize.Large
116
93
  })),
117
94
  isFlexibleUi: true
118
- } : undefined : icon,
95
+ },
119
96
  providerName: providerName,
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,
97
+ onViewButtonClick: invokeViewAction ? handleOnViewActionClick : undefined,
98
+ onDownloadButtonClick: invokeDownloadAction ? handleOnDownloadActionClick : undefined,
122
99
  onResizeButtonClick: handleOnResizeClick,
123
100
  size: width,
124
101
  title: title,
@@ -2,7 +2,6 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { useCallback, useState } from 'react';
3
3
  import { FormattedMessage } from 'react-intl-next';
4
4
  import LinkIcon from '@atlaskit/icon/core/migration/link';
5
- import { fg } from '@atlaskit/platform-feature-flags';
6
5
  import { ActionName } from '../../../../../constants';
7
6
  import { messages } from '../../../../../messages';
8
7
  import { useFlexibleUiAnalyticsContext, useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
@@ -21,38 +20,18 @@ const CopyLinkAction = ({
21
20
  const data = context === null || context === void 0 ? void 0 : (_context$actions = context.actions) === null || _context$actions === void 0 ? void 0 : _context$actions[ActionName.CopyLinkAction];
22
21
  const [tooltipMessage, setTooltipMessage] = useState(messages.copy_url_to_clipboard);
23
22
  const onClick = useCallback(() => {
24
- if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
25
- if (data !== null && data !== void 0 && data.invokeAction) {
26
- invoke({
27
- ...data.invokeAction,
28
- actionFn: async () => {
29
- var _data$invokeAction;
30
- await ((_data$invokeAction = data.invokeAction) === null || _data$invokeAction === void 0 ? void 0 : _data$invokeAction.actionFn());
31
- setTooltipMessage(messages.copied_url_to_clipboard);
32
- }
33
- });
34
- onClickCallback === null || onClickCallback === void 0 ? void 0 : onClickCallback();
35
- }
36
- } else {
37
- if (data && data.url) {
38
- invoke({
39
- actionType: ActionName.CopyLinkAction,
40
- actionFn: async () => {
41
- var _data$url;
42
- await navigator.clipboard.writeText((_data$url = data.url) !== null && _data$url !== void 0 ? _data$url : '');
43
- setTooltipMessage(messages.copied_url_to_clipboard);
44
- },
45
- // These values have already been set in analytics context.
46
- // We only pass these here for ufo experience.
47
- display: analytics === null || analytics === void 0 ? void 0 : analytics.display,
48
- extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey
49
- });
50
- }
51
- if (onClickCallback) {
52
- onClickCallback();
53
- }
23
+ if (data !== null && data !== void 0 && data.invokeAction) {
24
+ invoke({
25
+ ...data.invokeAction,
26
+ actionFn: async () => {
27
+ var _data$invokeAction;
28
+ await ((_data$invokeAction = data.invokeAction) === null || _data$invokeAction === void 0 ? void 0 : _data$invokeAction.actionFn());
29
+ setTooltipMessage(messages.copied_url_to_clipboard);
30
+ }
31
+ });
32
+ onClickCallback === null || onClickCallback === void 0 ? void 0 : onClickCallback();
54
33
  }
55
- }, [analytics, data, invoke, onClickCallback]);
34
+ }, [data, invoke, onClickCallback]);
56
35
  return data ? /*#__PURE__*/React.createElement(Action, _extends({
57
36
  content: /*#__PURE__*/React.createElement(FormattedMessage, messages.copy_url_to_clipboard),
58
37
  icon: /*#__PURE__*/React.createElement(LinkIcon, {
@@ -2,12 +2,10 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { useCallback } from 'react';
3
3
  import { FormattedMessage } from 'react-intl-next';
4
4
  import DownloadIcon from '@atlaskit/icon/core/migration/download';
5
- import { fg } from '@atlaskit/platform-feature-flags';
6
5
  import { ActionName } from '../../../../../constants';
7
6
  import { messages } from '../../../../../messages';
8
7
  import { useFlexibleUiAnalyticsContext, useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
9
8
  import useInvokeClientAction from '../../../../../state/hooks/use-invoke-client-action';
10
- import { downloadUrl as download } from '../../../../../utils';
11
9
  import Action from '../action';
12
10
  const DownloadAction = ({
13
11
  onClick: onClickCallback,
@@ -21,27 +19,11 @@ const DownloadAction = ({
21
19
  });
22
20
  const data = context === null || context === void 0 ? void 0 : (_context$actions = context.actions) === null || _context$actions === void 0 ? void 0 : _context$actions[ActionName.DownloadAction];
23
21
  const onClick = useCallback(() => {
24
- if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
25
- if (data !== null && data !== void 0 && data.invokeAction) {
26
- invoke(data.invokeAction);
27
- onClickCallback === null || onClickCallback === void 0 ? void 0 : onClickCallback();
28
- }
29
- } else {
30
- if (data !== null && data !== void 0 && data.downloadUrl) {
31
- invoke({
32
- actionType: ActionName.DownloadAction,
33
- actionFn: async () => download(data === null || data === void 0 ? void 0 : data.downloadUrl),
34
- // These values have already been set in analytics context.
35
- // We only pass these here for ufo experience.
36
- display: analytics === null || analytics === void 0 ? void 0 : analytics.display,
37
- extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey
38
- });
39
- if (onClickCallback) {
40
- onClickCallback();
41
- }
42
- }
22
+ if (data !== null && data !== void 0 && data.invokeAction) {
23
+ invoke(data.invokeAction);
24
+ onClickCallback === null || onClickCallback === void 0 ? void 0 : onClickCallback();
43
25
  }
44
- }, [analytics, data, invoke, onClickCallback]);
26
+ }, [data, invoke, onClickCallback]);
45
27
  const isStackItem = props.as === 'stack-item';
46
28
  const label = isStackItem ? messages.download_file : messages.download;
47
29
  const tooltipMessage = isStackItem ? messages.download_description : messages.download;
@@ -2,12 +2,10 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { useCallback } from 'react';
3
3
  import { FormattedMessage } from 'react-intl-next';
4
4
  import MediaServicesActualSizeIcon from '@atlaskit/icon/core/migration/grow-diagonal--media-services-actual-size';
5
- import { fg } from '@atlaskit/platform-feature-flags';
6
5
  import { ActionName } from '../../../../../constants';
7
6
  import { messages } from '../../../../../messages';
8
7
  import { useFlexibleUiAnalyticsContext, useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
9
8
  import useInvokeClientAction from '../../../../../state/hooks/use-invoke-client-action';
10
- import { openEmbedModalWithFlexibleUiIcon } from '../../utils';
11
9
  import Action from '../action';
12
10
  const PreviewAction = ({
13
11
  onClick: onClickCallback,
@@ -21,32 +19,11 @@ const PreviewAction = ({
21
19
  });
22
20
  const data = context === null || context === void 0 ? void 0 : (_context$actions = context.actions) === null || _context$actions === void 0 ? void 0 : _context$actions[ActionName.PreviewAction];
23
21
  const onClick = useCallback(() => {
24
- if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
25
- if (data !== null && data !== void 0 && data.invokeAction) {
26
- invoke(data.invokeAction);
27
- onClickCallback === null || onClickCallback === void 0 ? void 0 : onClickCallback();
28
- }
29
- } else {
30
- if (data) {
31
- invoke({
32
- actionType: ActionName.PreviewAction,
33
- actionFn: async () => openEmbedModalWithFlexibleUiIcon({
34
- download: data === null || data === void 0 ? void 0 : data.downloadUrl,
35
- extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey,
36
- analytics,
37
- ...data
38
- }),
39
- // These values have already been set in analytics context.
40
- // We only pass these here for ufo experience.
41
- display: analytics === null || analytics === void 0 ? void 0 : analytics.display,
42
- extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey
43
- });
44
- }
45
- if (onClickCallback) {
46
- onClickCallback();
47
- }
22
+ if (data !== null && data !== void 0 && data.invokeAction) {
23
+ invoke(data.invokeAction);
24
+ onClickCallback === null || onClickCallback === void 0 ? void 0 : onClickCallback();
48
25
  }
49
- }, [analytics, data, invoke, onClickCallback]);
26
+ }, [data, invoke, onClickCallback]);
50
27
  const isStackItem = props.as === 'stack-item';
51
28
  const tooltipMessage = isStackItem ? messages.preview_description : messages.preview_improved;
52
29
  return data ? /*#__PURE__*/React.createElement(Action, _extends({
@@ -55,7 +55,7 @@ const LozengeAction = ({
55
55
  const {
56
56
  url,
57
57
  id: linkId,
58
- previewData
58
+ invokePreviewAction
59
59
  } = (action === null || action === void 0 ? void 0 : (_action$update = action.update) === null || _action$update === void 0 ? void 0 : _action$update.details) || {};
60
60
  const handleOpenChange = useCallback(async args => {
61
61
  setIsOpen(args.isOpen);
@@ -135,7 +135,7 @@ const LozengeAction = ({
135
135
  errorMessage: errorMessage,
136
136
  testId: testId,
137
137
  url: url,
138
- previewData: previewData
138
+ invokePreviewAction: invokePreviewAction
139
139
  });
140
140
  }
141
141
  if (items && items.length > 0) {
@@ -145,7 +145,7 @@ const LozengeAction = ({
145
145
  onClick: handleItemClick
146
146
  });
147
147
  }
148
- }, [errorMessage, handleItemClick, items, previewData, testId, url]);
148
+ }, [errorMessage, handleItemClick, items, invokePreviewAction, testId, url]);
149
149
  return jsx(DropdownMenu, {
150
150
  isLoading: isLoading,
151
151
  isOpen: isOpen,
@@ -9,50 +9,32 @@ import { jsx } from '@emotion/react';
9
9
  import { FormattedMessage } from 'react-intl-next';
10
10
  import { DropdownItem, DropdownItemGroup } from '@atlaskit/dropdown-menu';
11
11
  import ErrorIcon from '@atlaskit/icon/core/migration/error';
12
- import { fg } from '@atlaskit/platform-feature-flags';
13
12
  import { R50, R500 } from '@atlaskit/theme/colors';
14
13
  import { useAnalyticsEvents } from '../../../../../../../common/analytics/generated/use-analytics-events';
15
14
  import { messages } from '../../../../../../../messages';
16
- import { useFlexibleUiAnalyticsContext } from '../../../../../../../state/flexible-ui-context';
17
15
  import useInvokeClientAction from '../../../../../../../state/hooks/use-invoke-client-action';
18
- import useResolve from '../../../../../../../state/hooks/use-resolve';
19
- import { getFormattedMessage, openEmbedModalWithFlexibleUiIcon } from '../../../../utils';
16
+ import { getFormattedMessage } from '../../../../utils';
20
17
  import { contentStyles, dropdownItemGroupStyles, linkStyles, textStyles } from './styled';
21
18
  const MAX_LINE_NUMBER = 8;
22
19
  const LozengeActionError = ({
23
20
  errorMessage,
24
21
  testId,
25
22
  maxLineNumber = MAX_LINE_NUMBER,
26
- invokePreviewAction,
27
- url,
28
- previewData
23
+ invokePreviewAction
29
24
  }) => {
30
25
  const {
31
26
  fireEvent
32
27
  } = useAnalyticsEvents();
33
- const reload = useResolve();
34
- const analytics = useFlexibleUiAnalyticsContext();
35
28
  const invoke = useInvokeClientAction({});
36
- const isPreviewAvailable = fg('platform-smart-card-migrate-embed-modal-analytics') ? invokePreviewAction !== undefined : previewData && previewData.src !== undefined;
37
- const handlePreviewClose = useCallback(() => {
38
- if (url) {
39
- reload(url, true);
40
- }
41
- }, [reload, url]);
29
+ const isPreviewAvailable = invokePreviewAction !== undefined;
42
30
  const handlePreviewOpen = useCallback(() => {
43
31
  if (isPreviewAvailable) {
44
32
  fireEvent('ui.button.clicked.smartLinkStatusOpenPreview', {});
45
- if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
46
- invokePreviewAction && invoke(invokePreviewAction);
47
- } else {
48
- return openEmbedModalWithFlexibleUiIcon({
49
- ...previewData,
50
- analytics,
51
- onClose: handlePreviewClose
52
- });
33
+ if (invokePreviewAction) {
34
+ invoke(invokePreviewAction);
53
35
  }
54
36
  }
55
- }, [analytics, handlePreviewClose, isPreviewAvailable, invoke, invokePreviewAction, previewData, fireEvent]);
37
+ }, [isPreviewAvailable, invoke, invokePreviewAction, fireEvent]);
56
38
  const content = useMemo(() => {
57
39
  return jsx(Fragment, null, jsx("div", {
58
40
  css: contentStyles
@@ -6,8 +6,6 @@ import { css } from '@emotion/react';
6
6
  import { FormattedMessage } from 'react-intl-next';
7
7
  import Loadable from 'react-loadable';
8
8
  import { SmartLinkSize } from '../../../constants';
9
- import { openEmbedModal } from '../../EmbedModal/utils';
10
- import Icon from './elements/icon';
11
9
  export const sizeToButtonSpacing = {
12
10
  [SmartLinkSize.Small]: 'none',
13
11
  [SmartLinkSize.Medium]: 'compact',
@@ -194,27 +192,4 @@ export const getTruncateStyles = (maxLines, lineHeight = '1rem', wordBreak = 'br
194
192
  });
195
193
  export const hasWhiteSpace = str => {
196
194
  return str.search(/\s/) >= 0;
197
- };
198
-
199
- /**
200
- * TODO: Remove on cleanup of platform-smart-card-migrate-embed-modal-analytics
201
- */
202
- export const openEmbedModalWithFlexibleUiIcon = ({
203
- linkIcon,
204
- ...props
205
- }) => {
206
- const icon = {
207
- icon: /*#__PURE__*/React.createElement(Icon, _extends({}, linkIcon, {
208
- size: SmartLinkSize.Large
209
- })),
210
- isFlexibleUi: true
211
- };
212
- return openEmbedModal({
213
- ...props,
214
- icon,
215
- // Flex should not send origin as block card. It should be able to support
216
- // its internal parent components like hover card, block card and
217
- // itself as a standalone. To be investigated and fix in EDM-7520.
218
- origin: 'smartLinkCard'
219
- });
220
195
  };
@@ -1,17 +1,14 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { useCallback, useEffect, useMemo, useRef } from 'react';
3
- import { fg } from '@atlaskit/platform-feature-flags';
4
3
  import { useAnalyticsEvents } from '../../../../../common/analytics/generated/use-analytics-events';
5
4
  import { CardDisplay, SmartLinkPosition, SmartLinkSize, SmartLinkStatus } from '../../../../../constants';
6
5
  import { succeedUfoExperience } from '../../../../../state/analytics';
7
- import { getCanBeDatasource, getDefinitionId } from '../../../../../state/helpers';
8
6
  import FlexibleCard from '../../../../FlexibleCard';
9
7
  import { ActionBlock, AIFooterBlock, AISummaryBlock, MetadataBlock, SnippetBlock, TitleBlock } from '../../../../FlexibleCard/components/blocks';
10
8
  import { getMetadata } from '../../../utils';
11
9
  import ImagePreview from '../../ImagePreview';
12
10
  import { hiddenSnippetStyles, metadataBlockCss } from './styled';
13
11
  const HoverCardResolvedView = ({
14
- analytics,
15
12
  cardState,
16
13
  extensionKey,
17
14
  flexibleCardProps,
@@ -24,32 +21,22 @@ const HoverCardResolvedView = ({
24
21
  const {
25
22
  fireEvent
26
23
  } = useAnalyticsEvents();
27
- const definitionId = React.useMemo(() => getDefinitionId(cardState.details), [cardState.details]);
28
- const canBeDatasource = React.useMemo(() => getCanBeDatasource(cardState.details), [cardState.details]);
29
24
  useEffect(() => {
30
25
  // Since this hover view is only rendered on resolved status,
31
26
  // there is no need to check for statuses.
32
- if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
33
- succeedUfoExperience('smart-link-rendered', id || 'NULL', {
34
- extensionKey,
35
- display: CardDisplay.HoverCardPreview
36
- });
27
+ succeedUfoExperience('smart-link-rendered', id || 'NULL', {
28
+ extensionKey,
29
+ display: CardDisplay.HoverCardPreview
30
+ });
37
31
 
38
- // UFO will disregard this if authentication experience has not yet been started
39
- succeedUfoExperience('smart-link-authenticated', id || 'NULL', {
40
- display: CardDisplay.HoverCardPreview
41
- });
42
- fireEvent('ui.smartLink.renderSuccess', {
43
- display: CardDisplay.HoverCardPreview
44
- });
45
- } else {
46
- analytics.ui.renderSuccessEvent({
47
- display: CardDisplay.HoverCardPreview,
48
- status: cardState.status,
49
- canBeDatasource
50
- });
51
- }
52
- }, [analytics.ui, cardState.status, canBeDatasource, fireEvent, definitionId, extensionKey, id]);
32
+ // UFO will disregard this if authentication experience has not yet been started
33
+ succeedUfoExperience('smart-link-authenticated', id || 'NULL', {
34
+ display: CardDisplay.HoverCardPreview
35
+ });
36
+ fireEvent('ui.smartLink.renderSuccess', {
37
+ display: CardDisplay.HoverCardPreview
38
+ });
39
+ }, [extensionKey, fireEvent, id]);
53
40
  const data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
54
41
  const {
55
42
  primary,