@atlaskit/smart-card 23.7.2 → 23.8.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 (220) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/constants.js +14 -2
  3. package/dist/cjs/extractors/common/actions/extractPreviewAction.js +3 -1
  4. package/dist/cjs/i18n/cs.js +6 -1
  5. package/dist/cjs/i18n/da.js +7 -1
  6. package/dist/cjs/i18n/de.js +6 -1
  7. package/dist/cjs/i18n/en.js +8 -1
  8. package/dist/cjs/i18n/en_GB.js +8 -1
  9. package/dist/cjs/i18n/es.js +5 -1
  10. package/dist/cjs/i18n/fi.js +7 -1
  11. package/dist/cjs/i18n/fr.js +7 -1
  12. package/dist/cjs/i18n/hu.js +6 -1
  13. package/dist/cjs/i18n/it.js +7 -1
  14. package/dist/cjs/i18n/ja.js +11 -5
  15. package/dist/cjs/i18n/ko.js +7 -1
  16. package/dist/cjs/i18n/nb.js +6 -1
  17. package/dist/cjs/i18n/nl.js +7 -1
  18. package/dist/cjs/i18n/pl.js +6 -1
  19. package/dist/cjs/i18n/pt_BR.js +7 -1
  20. package/dist/cjs/i18n/ru.js +7 -1
  21. package/dist/cjs/i18n/sv.js +7 -1
  22. package/dist/cjs/i18n/th.js +7 -1
  23. package/dist/cjs/i18n/tr.js +6 -1
  24. package/dist/cjs/i18n/uk.js +6 -1
  25. package/dist/cjs/i18n/vi.js +7 -1
  26. package/dist/cjs/i18n/zh.js +6 -1
  27. package/dist/cjs/i18n/zh_TW.js +6 -1
  28. package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +41 -13
  29. package/dist/cjs/utils/analytics/analytics.js +128 -96
  30. package/dist/cjs/utils/analytics/index.js +12 -0
  31. package/dist/cjs/version.json +1 -1
  32. package/dist/cjs/view/BlockCard/components/flexible/footer/index.js +1 -1
  33. package/dist/cjs/view/BlockCard/index.js +4 -2
  34. package/dist/cjs/view/BlockCard/views/flexible/FlexibleNotFoundView.js +1 -1
  35. package/dist/cjs/view/BlockCard/views/flexible/FlexibleResolvedView.js +3 -3
  36. package/dist/cjs/view/BlockCard/views/flexible/FlexibleUnauthorisedView.js +17 -4
  37. package/dist/cjs/view/CardWithUrl/component.js +3 -1
  38. package/dist/cjs/view/EmbedCard/index.js +6 -2
  39. package/dist/cjs/view/EmbedCard/views/UnauthorisedView.js +21 -4
  40. package/dist/cjs/view/EmbedModal/components/analytics/index.js +4 -2
  41. package/dist/cjs/view/HoverCard/components/HoverCardComponent.js +11 -10
  42. package/dist/cjs/view/HoverCard/components/HoverCardContent.js +6 -4
  43. package/dist/cjs/view/HoverCard/components/views/resolved/index.js +1 -1
  44. package/dist/cjs/view/HoverCard/components/views/unauthorised/index.js +26 -7
  45. package/dist/cjs/view/HoverCard/index.js +6 -3
  46. package/dist/cjs/view/HoverCard/utils.js +1 -4
  47. package/dist/cjs/view/InlineCard/ErroredView/index.js +6 -11
  48. package/dist/cjs/view/InlineCard/ForbiddenView/index.js +17 -21
  49. package/dist/cjs/view/InlineCard/Frame/index.js +4 -4
  50. package/dist/cjs/view/InlineCard/Frame/styled.js +22 -34
  51. package/dist/cjs/view/InlineCard/IconAndTitleLayout/index.js +52 -7
  52. package/dist/cjs/view/InlineCard/ResolvingView/index.js +3 -5
  53. package/dist/cjs/view/InlineCard/UnauthorisedView/index.js +10 -12
  54. package/dist/cjs/view/InlineCard/index.js +2 -1
  55. package/dist/cjs/view/InlineCard/styled.js +2 -2
  56. package/dist/cjs/view/common/UnauthorisedViewContent.js +14 -3
  57. package/dist/es2019/constants.js +12 -1
  58. package/dist/es2019/extractors/common/actions/extractPreviewAction.js +2 -1
  59. package/dist/es2019/i18n/cs.js +6 -1
  60. package/dist/es2019/i18n/da.js +7 -1
  61. package/dist/es2019/i18n/de.js +6 -1
  62. package/dist/es2019/i18n/en.js +8 -1
  63. package/dist/es2019/i18n/en_GB.js +8 -1
  64. package/dist/es2019/i18n/es.js +5 -1
  65. package/dist/es2019/i18n/fi.js +7 -1
  66. package/dist/es2019/i18n/fr.js +7 -1
  67. package/dist/es2019/i18n/hu.js +6 -1
  68. package/dist/es2019/i18n/it.js +7 -1
  69. package/dist/es2019/i18n/ja.js +11 -5
  70. package/dist/es2019/i18n/ko.js +7 -1
  71. package/dist/es2019/i18n/nb.js +6 -1
  72. package/dist/es2019/i18n/nl.js +7 -1
  73. package/dist/es2019/i18n/pl.js +6 -1
  74. package/dist/es2019/i18n/pt_BR.js +7 -1
  75. package/dist/es2019/i18n/ru.js +7 -1
  76. package/dist/es2019/i18n/sv.js +7 -1
  77. package/dist/es2019/i18n/th.js +7 -1
  78. package/dist/es2019/i18n/tr.js +6 -1
  79. package/dist/es2019/i18n/uk.js +6 -1
  80. package/dist/es2019/i18n/vi.js +7 -1
  81. package/dist/es2019/i18n/zh.js +6 -1
  82. package/dist/es2019/i18n/zh_TW.js +6 -1
  83. package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +33 -8
  84. package/dist/es2019/utils/analytics/analytics.js +28 -4
  85. package/dist/es2019/utils/analytics/index.js +1 -1
  86. package/dist/es2019/version.json +1 -1
  87. package/dist/es2019/view/BlockCard/components/flexible/footer/index.js +1 -1
  88. package/dist/es2019/view/BlockCard/index.js +4 -2
  89. package/dist/es2019/view/BlockCard/views/flexible/FlexibleNotFoundView.js +1 -1
  90. package/dist/es2019/view/BlockCard/views/flexible/FlexibleResolvedView.js +4 -4
  91. package/dist/es2019/view/BlockCard/views/flexible/FlexibleUnauthorisedView.js +15 -3
  92. package/dist/es2019/view/CardWithUrl/component.js +2 -1
  93. package/dist/es2019/view/EmbedCard/index.js +6 -2
  94. package/dist/es2019/view/EmbedCard/views/UnauthorisedView.js +14 -3
  95. package/dist/es2019/view/EmbedModal/components/analytics/index.js +3 -2
  96. package/dist/es2019/view/HoverCard/components/HoverCardComponent.js +11 -10
  97. package/dist/es2019/view/HoverCard/components/HoverCardContent.js +8 -6
  98. package/dist/es2019/view/HoverCard/components/views/resolved/index.js +3 -3
  99. package/dist/es2019/view/HoverCard/components/views/unauthorised/index.js +23 -7
  100. package/dist/es2019/view/HoverCard/index.js +6 -3
  101. package/dist/es2019/view/HoverCard/utils.js +0 -1
  102. package/dist/es2019/view/InlineCard/ErroredView/index.js +7 -9
  103. package/dist/es2019/view/InlineCard/ForbiddenView/index.js +8 -9
  104. package/dist/es2019/view/InlineCard/Frame/index.js +4 -4
  105. package/dist/es2019/view/InlineCard/Frame/styled.js +18 -31
  106. package/dist/es2019/view/InlineCard/IconAndTitleLayout/index.js +47 -6
  107. package/dist/es2019/view/InlineCard/ResolvingView/index.js +3 -5
  108. package/dist/es2019/view/InlineCard/UnauthorisedView/index.js +11 -11
  109. package/dist/es2019/view/InlineCard/index.js +2 -1
  110. package/dist/es2019/view/InlineCard/styled.js +1 -6
  111. package/dist/es2019/view/common/UnauthorisedViewContent.js +18 -11
  112. package/dist/esm/constants.js +12 -1
  113. package/dist/esm/extractors/common/actions/extractPreviewAction.js +2 -1
  114. package/dist/esm/i18n/cs.js +6 -1
  115. package/dist/esm/i18n/da.js +7 -1
  116. package/dist/esm/i18n/de.js +6 -1
  117. package/dist/esm/i18n/en.js +8 -1
  118. package/dist/esm/i18n/en_GB.js +8 -1
  119. package/dist/esm/i18n/es.js +5 -1
  120. package/dist/esm/i18n/fi.js +7 -1
  121. package/dist/esm/i18n/fr.js +7 -1
  122. package/dist/esm/i18n/hu.js +6 -1
  123. package/dist/esm/i18n/it.js +7 -1
  124. package/dist/esm/i18n/ja.js +11 -5
  125. package/dist/esm/i18n/ko.js +7 -1
  126. package/dist/esm/i18n/nb.js +6 -1
  127. package/dist/esm/i18n/nl.js +7 -1
  128. package/dist/esm/i18n/pl.js +6 -1
  129. package/dist/esm/i18n/pt_BR.js +7 -1
  130. package/dist/esm/i18n/ru.js +7 -1
  131. package/dist/esm/i18n/sv.js +7 -1
  132. package/dist/esm/i18n/th.js +7 -1
  133. package/dist/esm/i18n/tr.js +6 -1
  134. package/dist/esm/i18n/uk.js +6 -1
  135. package/dist/esm/i18n/vi.js +7 -1
  136. package/dist/esm/i18n/zh.js +6 -1
  137. package/dist/esm/i18n/zh_TW.js +6 -1
  138. package/dist/esm/state/analytics/useSmartLinkAnalytics.js +42 -14
  139. package/dist/esm/utils/analytics/analytics.js +118 -92
  140. package/dist/esm/utils/analytics/index.js +1 -1
  141. package/dist/esm/version.json +1 -1
  142. package/dist/esm/view/BlockCard/components/flexible/footer/index.js +1 -1
  143. package/dist/esm/view/BlockCard/index.js +4 -2
  144. package/dist/esm/view/BlockCard/views/flexible/FlexibleNotFoundView.js +1 -1
  145. package/dist/esm/view/BlockCard/views/flexible/FlexibleResolvedView.js +4 -4
  146. package/dist/esm/view/BlockCard/views/flexible/FlexibleUnauthorisedView.js +18 -5
  147. package/dist/esm/view/CardWithUrl/component.js +2 -1
  148. package/dist/esm/view/EmbedCard/index.js +6 -2
  149. package/dist/esm/view/EmbedCard/views/UnauthorisedView.js +15 -4
  150. package/dist/esm/view/EmbedModal/components/analytics/index.js +3 -2
  151. package/dist/esm/view/HoverCard/components/HoverCardComponent.js +11 -10
  152. package/dist/esm/view/HoverCard/components/HoverCardContent.js +8 -6
  153. package/dist/esm/view/HoverCard/components/views/resolved/index.js +3 -3
  154. package/dist/esm/view/HoverCard/components/views/unauthorised/index.js +27 -9
  155. package/dist/esm/view/HoverCard/index.js +6 -3
  156. package/dist/esm/view/HoverCard/utils.js +0 -1
  157. package/dist/esm/view/InlineCard/ErroredView/index.js +7 -9
  158. package/dist/esm/view/InlineCard/ForbiddenView/index.js +18 -20
  159. package/dist/esm/view/InlineCard/Frame/index.js +4 -4
  160. package/dist/esm/view/InlineCard/Frame/styled.js +17 -31
  161. package/dist/esm/view/InlineCard/IconAndTitleLayout/index.js +49 -7
  162. package/dist/esm/view/InlineCard/ResolvingView/index.js +3 -5
  163. package/dist/esm/view/InlineCard/UnauthorisedView/index.js +11 -11
  164. package/dist/esm/view/InlineCard/index.js +2 -1
  165. package/dist/esm/view/InlineCard/styled.js +2 -2
  166. package/dist/esm/view/common/UnauthorisedViewContent.js +8 -3
  167. package/dist/types/constants.d.ts +8 -0
  168. package/dist/types/i18n/cs.d.ts +5 -0
  169. package/dist/types/i18n/da.d.ts +6 -0
  170. package/dist/types/i18n/de.d.ts +5 -0
  171. package/dist/types/i18n/en.d.ts +7 -0
  172. package/dist/types/i18n/en_GB.d.ts +7 -0
  173. package/dist/types/i18n/es.d.ts +4 -0
  174. package/dist/types/i18n/fi.d.ts +6 -0
  175. package/dist/types/i18n/fr.d.ts +6 -0
  176. package/dist/types/i18n/hu.d.ts +5 -0
  177. package/dist/types/i18n/it.d.ts +6 -0
  178. package/dist/types/i18n/ja.d.ts +6 -0
  179. package/dist/types/i18n/ko.d.ts +6 -0
  180. package/dist/types/i18n/nb.d.ts +5 -0
  181. package/dist/types/i18n/nl.d.ts +6 -0
  182. package/dist/types/i18n/pl.d.ts +5 -0
  183. package/dist/types/i18n/pt_BR.d.ts +6 -0
  184. package/dist/types/i18n/ru.d.ts +6 -0
  185. package/dist/types/i18n/sv.d.ts +6 -0
  186. package/dist/types/i18n/th.d.ts +6 -0
  187. package/dist/types/i18n/tr.d.ts +5 -0
  188. package/dist/types/i18n/uk.d.ts +5 -0
  189. package/dist/types/i18n/vi.d.ts +6 -0
  190. package/dist/types/i18n/zh.d.ts +5 -0
  191. package/dist/types/i18n/zh_TW.d.ts +5 -0
  192. package/dist/types/state/actions/index.d.ts +1 -2
  193. package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +17 -4
  194. package/dist/types/state/flexible-ui-context/index.d.ts +8 -4
  195. package/dist/types/state/hooks/useSmartLink.d.ts +5 -3
  196. package/dist/types/utils/analytics/analytics.d.ts +4 -2
  197. package/dist/types/utils/analytics/index.d.ts +1 -1
  198. package/dist/types/utils/analytics/types.d.ts +2 -0
  199. package/dist/types/utils/mocks.d.ts +4 -2
  200. package/dist/types/utils/types.d.ts +1 -1
  201. package/dist/types/view/BlockCard/components/flexible/footer/index.d.ts +1 -1
  202. package/dist/types/view/BlockCard/views/flexible/FlexibleUnauthorisedView.d.ts +1 -1
  203. package/dist/types/view/BlockCard/views/flexible/types.d.ts +17 -13
  204. package/dist/types/view/Card/types.d.ts +1 -1
  205. package/dist/types/view/EmbedCard/views/UnauthorisedView.d.ts +3 -0
  206. package/dist/types/view/HoverCard/components/views/unauthorised/types.d.ts +15 -4
  207. package/dist/types/view/HoverCard/types.d.ts +0 -2
  208. package/dist/types/view/HoverCard/utils.d.ts +0 -1
  209. package/dist/types/view/InlineCard/ErroredView/index.d.ts +1 -1
  210. package/dist/types/view/InlineCard/ForbiddenView/index.d.ts +1 -1
  211. package/dist/types/view/InlineCard/Frame/index.d.ts +0 -1
  212. package/dist/types/view/InlineCard/Frame/styled.d.ts +3 -2
  213. package/dist/types/view/InlineCard/IconAndTitleLayout/index.d.ts +5 -0
  214. package/dist/types/view/InlineCard/ResolvingView/index.d.ts +0 -1
  215. package/dist/types/view/InlineCard/UnauthorisedView/index.d.ts +3 -1
  216. package/dist/types/view/InlineCard/styled.d.ts +1 -1
  217. package/dist/types/view/common/UnauthorisedViewContent.d.ts +7 -1
  218. package/package.json +5 -5
  219. package/report.api.md +15 -1
  220. package/tmp/api-report-tmp.d.ts +8 -4
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "23.7.2",
3
+ "version": "23.8.0",
4
4
  "sideEffects": false
5
5
  }
@@ -22,7 +22,7 @@ const providerStyles = css`
22
22
  }
23
23
  `;
24
24
  /**
25
- * This Components is a footer that is used in a Block Card with Flexible UI.
25
+ * This Component is a footer that is used in a Block Card with Flexible UI.
26
26
  * It contains a provider icon if provider is present and an actions list if one is passed.
27
27
  * To be shown as a part of Flexible UI, needs to be wrapped inside of a CustomBlock
28
28
  *
@@ -55,11 +55,12 @@ export const BlockCard = ({
55
55
  } = cardState;
56
56
  const data = details && details.data || getEmptyJsonLd();
57
57
  const meta = details && details.meta;
58
+ const extensionKey = getExtensionKey(details);
58
59
  const extractorOpts = {
59
60
  analytics,
60
61
  origin: 'smartLinkCard',
61
62
  handleInvoke,
62
- extensionKey: getExtensionKey(details)
63
+ extensionKey
63
64
  };
64
65
 
65
66
  if (enableFlexibleBlockCard) {
@@ -74,7 +75,8 @@ export const BlockCard = ({
74
75
  onError,
75
76
  renderers,
76
77
  ui,
77
- analytics
78
+ analytics,
79
+ extensionKey
78
80
  };
79
81
 
80
82
  switch (status) {
@@ -45,7 +45,7 @@ const FlexibleNotFoundView = ({
45
45
  message: {
46
46
  descriptor: messages.not_found_description
47
47
  },
48
- testId: testId
48
+ testId: `${testId}-message`
49
49
  })), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(BlockCardFooter, {
50
50
  status: status
51
51
  })));
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react';
2
2
  import FlexibleCard from '../../../FlexibleCard';
3
3
  import TitleBlock from '../../../FlexibleCard/components/blocks/title-block';
4
4
  import { FooterBlock, MetadataBlock, PreviewBlock, SnippetBlock } from '../../../FlexibleCard/components/blocks';
5
- import { ActionName, ElementName, MediaPlacement, SmartLinkPosition } from '../../../../constants';
5
+ import { ActionName, CardDisplay, ElementName, MediaPlacement, SmartLinkPosition } from '../../../../constants';
6
6
  import uuid from 'uuid';
7
7
  /**
8
8
  * This view represents a Block card that has an 'Resolved' status.
@@ -79,7 +79,7 @@ const FlexibleResolvedView = ({
79
79
  analytics.operational.invokeSucceededEvent({
80
80
  id: analyticsId,
81
81
  actionType: 'preview',
82
- display: 'block'
82
+ display: CardDisplay.Block
83
83
  });
84
84
  }
85
85
  }, {
@@ -89,7 +89,7 @@ const FlexibleResolvedView = ({
89
89
  analytics.operational.invokeSucceededEvent({
90
90
  id: analyticsId,
91
91
  actionType: 'view',
92
- display: 'block'
92
+ display: CardDisplay.Block
93
93
  });
94
94
  }
95
95
  }, {
@@ -99,7 +99,7 @@ const FlexibleResolvedView = ({
99
99
  analytics.operational.invokeSucceededEvent({
100
100
  id: analyticsId,
101
101
  actionType: 'download',
102
- display: 'block'
102
+ display: CardDisplay.Block
103
103
  });
104
104
  }
105
105
  }]
@@ -1,4 +1,4 @@
1
- import React, { useMemo } from 'react';
1
+ import React, { useCallback, useMemo } from 'react';
2
2
  import FlexibleCard from '../../../FlexibleCard';
3
3
  import { AuthorizeAction } from '../../actions/flexible/AuthorizeAction';
4
4
  import BlockCardFooter from '../../components/flexible/footer';
@@ -22,7 +22,9 @@ const contentStyles = css`
22
22
  */
23
23
 
24
24
  const FlexibleUnauthorisedView = ({
25
+ analytics,
25
26
  cardState,
27
+ extensionKey = '',
26
28
  onAuthorize,
27
29
  onClick,
28
30
  onError,
@@ -34,7 +36,15 @@ const FlexibleUnauthorisedView = ({
34
36
 
35
37
  const data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
36
38
  const providerName = (_extractProvider = extractProvider(data)) === null || _extractProvider === void 0 ? void 0 : _extractProvider.text;
37
- const actions = useMemo(() => onAuthorize ? [AuthorizeAction(onAuthorize, providerName)] : [], [onAuthorize, providerName]);
39
+ const handleAuthorize = useCallback(() => {
40
+ if (onAuthorize) {
41
+ analytics.track.appAccountAuthStarted({
42
+ extensionKey
43
+ });
44
+ onAuthorize();
45
+ }
46
+ }, [onAuthorize, extensionKey, analytics.track]);
47
+ const actions = useMemo(() => onAuthorize ? [AuthorizeAction(handleAuthorize, providerName)] : [], [handleAuthorize, onAuthorize, providerName]);
38
48
  return /*#__PURE__*/React.createElement(FlexibleCard, {
39
49
  appearance: "block",
40
50
  cardState: cardState,
@@ -50,7 +60,9 @@ const FlexibleUnauthorisedView = ({
50
60
  overrideCss: contentStyles,
51
61
  testId: `${testId}-content`
52
62
  }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(UnauthorisedViewContent, {
53
- providerName: providerName
63
+ providerName: providerName,
64
+ analytics: analytics,
65
+ testId: testId
54
66
  }))), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(BlockCardFooter, {
55
67
  actions: actions,
56
68
  status: SmartLinkStatus.Unauthorized,
@@ -10,6 +10,7 @@ import { EmbedCard } from '../EmbedCard';
10
10
  import { isFlexibleUiCard } from '../../utils/flexible';
11
11
  import FlexibleCard from '../FlexibleCard';
12
12
  import { APIError } from '../..';
13
+ import { CardDisplay } from '../../constants';
13
14
  export function CardWithUrlContent({
14
15
  id,
15
16
  url,
@@ -66,7 +67,7 @@ export function CardWithUrlContent({
66
67
  const isModifierKeyPressed = isSpecialEvent(event);
67
68
  analytics.ui.cardClickedEvent({
68
69
  id,
69
- display: isFlexibleUi ? 'flexible' : appearance,
70
+ display: isFlexibleUi ? CardDisplay.Flexible : appearance,
70
71
  status: state.status,
71
72
  definitionId,
72
73
  extensionKey,
@@ -37,6 +37,7 @@ export const EmbedCard = /*#__PURE__*/React.forwardRef(({
37
37
 
38
38
  const data = details && details.data || getEmptyJsonLd();
39
39
  const meta = details && details.meta;
40
+ const extensionKey = getExtensionKey(details);
40
41
 
41
42
  switch (status) {
42
43
  case 'pending':
@@ -82,7 +83,7 @@ export const EmbedCard = /*#__PURE__*/React.forwardRef(({
82
83
  analytics,
83
84
  origin: 'smartLinkEmbed',
84
85
  handleInvoke,
85
- extensionKey: getExtensionKey(details)
86
+ extensionKey
86
87
  });
87
88
  return /*#__PURE__*/React.createElement(BlockCardResolvedView, _extends({}, resolvedBlockViewProps, {
88
89
  isSelected: isSelected,
@@ -105,7 +106,10 @@ export const EmbedCard = /*#__PURE__*/React.forwardRef(({
105
106
  isSelected: isSelected,
106
107
  onAuthorise: handleAuthorize,
107
108
  inheritDimensions: inheritDimensions,
108
- onClick: handleFrameClick
109
+ onClick: handleFrameClick,
110
+ analytics: analytics,
111
+ extensionKey: extensionKey,
112
+ testId: testId
109
113
  }));
110
114
 
111
115
  case 'forbidden':
@@ -1,23 +1,33 @@
1
- import React from 'react';
1
+ import React, { useCallback } from 'react';
2
2
  import { EmbedCardUnresolvedView } from './UnresolvedView';
3
3
  import { UnauthorisedImage } from '../constants';
4
4
  import { ExpandedFrame } from '../components/ExpandedFrame';
5
5
  import { ImageIcon } from '../components/ImageIcon';
6
6
  import UnauthorisedViewContent from '../../common/UnauthorisedViewContent';
7
7
  export const EmbedCardUnauthorisedView = ({
8
+ analytics,
8
9
  link,
9
10
  context,
10
11
  isSelected,
11
12
  testId = 'embed-card-unauthorized-view',
12
13
  onAuthorise,
13
14
  inheritDimensions,
14
- onClick
15
+ onClick,
16
+ extensionKey
15
17
  }) => {
16
18
  var _context$image;
17
19
 
18
20
  const icon = context && context.icon && /*#__PURE__*/React.createElement(ImageIcon, {
19
21
  src: typeof context.icon === 'string' ? context.icon : undefined
20
22
  });
23
+ const handleOnAuthorizeClick = useCallback(() => {
24
+ if (onAuthorise) {
25
+ analytics.track.appAccountAuthStarted({
26
+ extensionKey: extensionKey
27
+ });
28
+ onAuthorise();
29
+ }
30
+ }, [onAuthorise, analytics.track, extensionKey]);
21
31
  return /*#__PURE__*/React.createElement(ExpandedFrame, {
22
32
  href: link,
23
33
  icon: icon,
@@ -38,9 +48,10 @@ export const EmbedCardUnauthorisedView = ({
38
48
  text: 'connect_unauthorised_account_action',
39
49
  testId: 'connect-account'
40
50
  },
41
- onClick: onAuthorise,
51
+ onClick: handleOnAuthorizeClick,
42
52
  testId: testId
43
53
  }, /*#__PURE__*/React.createElement(UnauthorisedViewContent, {
54
+ analytics: analytics,
44
55
  providerName: context === null || context === void 0 ? void 0 : context.text,
45
56
  testId: testId
46
57
  })));
@@ -1,6 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { useCallback } from 'react';
3
3
  import { EmbedModalSize } from '../../types';
4
+ import { CardDisplay } from '../../../../constants';
4
5
 
5
6
  const getResizeFrom = size => size === EmbedModalSize.Small ? EmbedModalSize.Large : EmbedModalSize.Small;
6
7
 
@@ -23,7 +24,7 @@ const withAnalytics = Component => props => {
23
24
  });
24
25
  analytics.ui.renderSuccessEvent({
25
26
  status: 'resolved',
26
- display: 'preview'
27
+ display: CardDisplay.EmbedPreview
27
28
  });
28
29
 
29
30
  if (onOpen) {
@@ -32,7 +33,7 @@ const withAnalytics = Component => props => {
32
33
  }, [analytics.screen, analytics.ui, onOpen, origin]);
33
34
  const handleOnOpenFailed = useCallback((error, errorInfo) => {
34
35
  analytics.ui.renderFailedEvent({
35
- display: 'preview',
36
+ display: CardDisplay.EmbedPreview,
36
37
  error,
37
38
  errorInfo
38
39
  });
@@ -9,14 +9,13 @@ import { useSmartLinkRenderers } from '../../../state/renderers';
9
9
  import { useSmartCardState as useLinkState } from '../../../state/store';
10
10
  import HoverCardContent from '../components/HoverCardContent';
11
11
  import { HoverCardContainer, CARD_GAP_PX } from '../styled';
12
- import { SMART_CARD_ANALYTICS_DISPLAY } from '../utils';
12
+ import { CardDisplay } from '../../../constants';
13
13
  export const hoverCardClassName = 'smart-links-hover-preview';
14
14
  export const HoverCardComponent = ({
15
15
  children,
16
16
  url,
17
17
  analyticsHandler,
18
- analytics,
19
- onAuthorize
18
+ analytics
20
19
  }) => {
21
20
  const delay = 300;
22
21
  const [isOpen, setIsOpen] = React.useState(false);
@@ -28,6 +27,7 @@ export const HoverCardComponent = ({
28
27
  const parentSpan = useRef(null);
29
28
  const renderers = useSmartLinkRenderers();
30
29
  const linkState = useLinkState(url);
30
+ const linkStatus = linkState.status;
31
31
  const hoverDisplay = 'card';
32
32
  const invokeMethod = 'mouse_hover';
33
33
  const setMousePosition = useCallback(event => {
@@ -47,12 +47,13 @@ export const HoverCardComponent = ({
47
47
  analytics.ui.hoverCardDismissedEvent({
48
48
  previewDisplay: 'card',
49
49
  hoverTime,
50
- previewInvokeMethod: 'mouse_hover'
50
+ previewInvokeMethod: 'mouse_hover',
51
+ status: linkStatus
51
52
  });
52
53
  }
53
54
 
54
55
  setIsOpen(false);
55
- }, [analytics.ui, isOpen]);
56
+ }, [analytics.ui, isOpen, linkStatus]);
56
57
  const initHideCard = useCallback(() => {
57
58
  if (fadeInTimeoutId.current) {
58
59
  clearTimeout(fadeInTimeoutId.current);
@@ -73,7 +74,8 @@ export const HoverCardComponent = ({
73
74
  cardOpenTime.current = Date.now();
74
75
  analytics.ui.hoverCardViewedEvent({
75
76
  previewDisplay: hoverDisplay,
76
- previewInvokeMethod: invokeMethod
77
+ previewInvokeMethod: invokeMethod,
78
+ status: linkStatus
77
79
  });
78
80
  } //If these are undefined then popupOffset is undefined and we fallback to default bottom-start placement
79
81
 
@@ -88,10 +90,10 @@ export const HoverCardComponent = ({
88
90
 
89
91
  setIsOpen(true);
90
92
  }, delay);
91
- }, [isOpen, setMousePosition, analytics.ui]);
93
+ }, [isOpen, setMousePosition, analytics.ui, linkStatus]);
92
94
  const linkActions = useSmartLinkActions({
93
95
  url,
94
- appearance: SMART_CARD_ANALYTICS_DISPLAY,
96
+ appearance: CardDisplay.HoverCardPreview,
95
97
  analyticsHandler,
96
98
  origin: 'smartLinkPreviewHoverCard'
97
99
  });
@@ -125,8 +127,7 @@ export const HoverCardComponent = ({
125
127
  onActionClick: onActionClick,
126
128
  onResolve: update,
127
129
  renderers: renderers,
128
- url: url,
129
- onAuthorize: onAuthorize
130
+ url: url
130
131
  })),
131
132
  trigger: triggerProps => jsx("span", {
132
133
  ref: parentSpan
@@ -1,12 +1,12 @@
1
1
  import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
2
2
  import { extractType } from '@atlaskit/linking-common/extractors';
3
3
  import React, { useCallback, useMemo } from 'react';
4
- import { ActionName, SmartLinkPosition, SmartLinkSize } from '../../../constants';
4
+ import { ActionName, CardDisplay, SmartLinkPosition, SmartLinkSize } from '../../../constants';
5
5
  import { extractMetadata } from '../../../extractors/hover/extractMetadata';
6
6
  import { getExtensionKey } from '../../../state/helpers';
7
7
  import { isSpecialEvent } from '../../../utils';
8
8
  import { flexibleUiOptions, titleBlockCss } from '../styled';
9
- import { getSimulatedMetadata, SMART_CARD_ANALYTICS_DISPLAY } from '../utils';
9
+ import { getSimulatedMetadata } from '../utils';
10
10
  import HoverCardLoadingView from './views/resolving';
11
11
  import HoverCardUnauthorisedView from './views/unauthorised';
12
12
  import HoverCardResolvedView from './views/resolved';
@@ -41,8 +41,7 @@ const HoverCardContent = ({
41
41
  onActionClick,
42
42
  onResolve,
43
43
  renderers,
44
- url,
45
- onAuthorize
44
+ url
46
45
  }) => {
47
46
  var _cardState$details;
48
47
 
@@ -51,7 +50,7 @@ const HoverCardContent = ({
51
50
  const isModifierKeyPressed = isSpecialEvent(event);
52
51
  analytics.ui.cardClickedEvent({
53
52
  id,
54
- display: SMART_CARD_ANALYTICS_DISPLAY,
53
+ display: CardDisplay.HoverCardPreview,
55
54
  status: cardState.status,
56
55
  isModifierKeyPressed,
57
56
  actionSubjectId: 'titleGoToLink'
@@ -91,8 +90,11 @@ const HoverCardContent = ({
91
90
 
92
91
  if (cardState.status === 'unauthorized') {
93
92
  return /*#__PURE__*/React.createElement(HoverCardUnauthorisedView, {
93
+ analytics: analytics,
94
+ extensionKey: extensionKey,
95
+ id: id,
94
96
  flexibleCardProps: flexibleCardProps,
95
- onAuthorize: onAuthorize
97
+ url: url
96
98
  });
97
99
  } // if metadataStatus is 'errored' simply render using data available (normal path)
98
100
 
@@ -1,12 +1,12 @@
1
1
  import React, { useCallback, useEffect, useMemo, useRef } from 'react';
2
2
  import { useFeatureFlag } from '@atlaskit/link-provider';
3
3
  import { extractType } from '@atlaskit/linking-common/extractors';
4
- import { ActionName, SmartLinkSize } from '../../../../../constants';
4
+ import { ActionName, CardDisplay, SmartLinkSize } from '../../../../../constants';
5
5
  import { FooterBlock, MetadataBlock, SnippetBlock, TitleBlock } from '../../../../FlexibleCard/components/blocks';
6
6
  import { footerBlockCss, hiddenSnippetStyles, metadataBlockCss } from './styled';
7
7
  import FlexibleCard from '../../../../FlexibleCard';
8
8
  import { useSmartCardActions } from '../../../../../state/actions';
9
- import { getSimulatedMetadata, toActionableMetadata, SMART_CARD_ANALYTICS_DISPLAY } from '../../../utils';
9
+ import { getSimulatedMetadata, toActionableMetadata } from '../../../utils';
10
10
  import SnippetOrPreview from '../../SnippetOrPreview';
11
11
  import { extractMetadata } from '../../../../../extractors/hover/extractMetadata';
12
12
  export const toFooterActions = (cardActions, onActionClick) => cardActions.map(action => ({
@@ -44,7 +44,7 @@ const HoverCardResolvedView = ({
44
44
  // Since this hover view is only rendered on resolved status,
45
45
  // there is no need to check for statuses.
46
46
  analytics.ui.renderSuccessEvent({
47
- display: SMART_CARD_ANALYTICS_DISPLAY,
47
+ display: CardDisplay.HoverCardPreview,
48
48
  status: cardState.status
49
49
  });
50
50
  }, [analytics.ui, cardState.status]);
@@ -1,5 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import React, { useMemo } from 'react';
2
+ import React, { useCallback, useMemo } from 'react';
3
3
  import { FormattedMessage } from 'react-intl-next';
4
4
  import FlexibleCard from '../../../../FlexibleCard';
5
5
  import { messages } from '../../../../../messages';
@@ -9,12 +9,16 @@ import { connectButtonStyles, mainTextStyles, titleBlockStyles } from './styled'
9
9
  import UnauthorisedViewContent from '../../../../common/UnauthorisedViewContent';
10
10
  import ActionGroup from '../../../../FlexibleCard/components/blocks/action-group';
11
11
  import { LinkIcon } from '../../../../FlexibleCard/components/elements';
12
- import { ActionName } from '../../../../../constants';
12
+ import { ActionName, CardDisplay } from '../../../../../constants';
13
+ import { useSmartCardActions } from '../../../../../state/actions';
13
14
 
14
15
  const HoverCardUnauthorisedView = ({
16
+ analytics,
17
+ extensionKey,
18
+ id = '',
15
19
  flexibleCardProps,
16
20
  testId = 'hover-card-unauthorised-view',
17
- onAuthorize
21
+ url
18
22
  }) => {
19
23
  var _cardState$details, _extractProvider;
20
24
 
@@ -23,15 +27,26 @@ const HoverCardUnauthorisedView = ({
23
27
  } = flexibleCardProps;
24
28
  const data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
25
29
  const providerName = (_extractProvider = extractProvider(data)) === null || _extractProvider === void 0 ? void 0 : _extractProvider.text;
26
- const actions = useMemo(() => onAuthorize ? [{
30
+ const {
31
+ authorize
32
+ } = useSmartCardActions(id, url, analytics);
33
+ const handleAuthorize = useCallback(() => {
34
+ if (authorize) {
35
+ analytics.track.appAccountAuthStarted({
36
+ extensionKey
37
+ });
38
+ authorize(CardDisplay.HoverCardPreview);
39
+ }
40
+ }, [authorize, extensionKey, analytics.track]);
41
+ const actions = useMemo(() => [{
27
42
  name: ActionName.CustomAction,
28
43
  content: /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.connect_unauthorised_account_action, {
29
44
  values: {
30
45
  context: providerName
31
46
  }
32
47
  })),
33
- onClick: onAuthorize
34
- }] : [], [onAuthorize, providerName]);
48
+ onClick: handleAuthorize
49
+ }], [handleAuthorize, providerName]);
35
50
  return /*#__PURE__*/React.createElement(FlexibleCard, _extends({}, flexibleCardProps, {
36
51
  testId: testId
37
52
  }), /*#__PURE__*/React.createElement(CustomBlock, {
@@ -45,7 +60,8 @@ const HoverCardUnauthorisedView = ({
45
60
  overrideCss: mainTextStyles,
46
61
  testId: `${testId}-content`
47
62
  }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(UnauthorisedViewContent, {
48
- providerName: providerName
63
+ providerName: providerName,
64
+ analytics: analytics
49
65
  }))), /*#__PURE__*/React.createElement(CustomBlock, {
50
66
  overrideCss: connectButtonStyles,
51
67
  testId: `${testId}-button`
@@ -8,7 +8,7 @@ import { ErrorBoundary } from 'react-error-boundary';
8
8
  import { useSmartLinkAnalytics } from '../../state/analytics';
9
9
  import { fireSmartLinkEvent } from '../../utils/analytics';
10
10
  import { HoverCardComponent } from './components/HoverCardComponent';
11
- import { SMART_CARD_ANALYTICS_DISPLAY } from './utils';
11
+ import { CardDisplay } from '../../constants';
12
12
 
13
13
  const HoverCardWithErrorBoundary = props => {
14
14
  const {
@@ -23,7 +23,7 @@ const HoverCardWithErrorBoundary = props => {
23
23
  const analytics = useSmartLinkAnalytics(url, analyticsHandler, id);
24
24
  const onError = useCallback((error, info) => {
25
25
  analytics.ui.renderFailedEvent({
26
- display: SMART_CARD_ANALYTICS_DISPLAY,
26
+ display: CardDisplay.HoverCardPreview,
27
27
  id,
28
28
  error,
29
29
  errorInfo: info
@@ -39,5 +39,8 @@ const HoverCardWithErrorBoundary = props => {
39
39
  };
40
40
 
41
41
  export const HoverCard = withAnalyticsContext({
42
- source: 'smartLinkPreviewHoverCard'
42
+ source: 'smartLinkPreviewHoverCard',
43
+ attributes: {
44
+ display: CardDisplay.HoverCardPreview
45
+ }
43
46
  })(withAnalyticsEvents()(HoverCardWithErrorBoundary));
@@ -1,5 +1,4 @@
1
1
  import { ElementName } from '../../constants';
2
- export const SMART_CARD_ANALYTICS_DISPLAY = 'flexible';
3
2
  export const getSimulatedMetadata = (extensionKey = '', types = []) => {
4
3
  switch (extensionKey) {
5
4
  case 'bitbucket-object-provider':
@@ -9,7 +9,7 @@ import { IconAndTitleLayout } from '../IconAndTitleLayout';
9
9
  import { AKIconWrapper } from '../Icon';
10
10
  import { messages } from '../../../messages';
11
11
  import { FormattedMessage } from 'react-intl-next';
12
- import { LinkAppearance, IconStyledButton, LowercaseAppearance, NoLinkAppearance } from '../styled';
12
+ import { IconStyledButton, LowercaseAppearance } from '../styled';
13
13
  export class InlineCardErroredView extends React.Component {
14
14
  constructor(...args) {
15
15
  super(...args);
@@ -26,15 +26,12 @@ export class InlineCardErroredView extends React.Component {
26
26
  }
27
27
  });
28
28
 
29
- _defineProperty(this, "renderMessage", () => {
29
+ _defineProperty(this, "renderRightSide", () => {
30
30
  const {
31
31
  onRetry,
32
- url,
33
32
  message
34
33
  } = this.props;
35
- const link = /*#__PURE__*/React.createElement(LinkAppearance, null, url);
36
- const errorMessage = /*#__PURE__*/React.createElement(NoLinkAppearance, null, message);
37
- return !onRetry ? /*#__PURE__*/React.createElement(React.Fragment, null, link, " - ", errorMessage) : /*#__PURE__*/React.createElement(React.Fragment, null, link, " - ", errorMessage, ",\xA0", /*#__PURE__*/React.createElement(Button, {
34
+ return !onRetry ? message : /*#__PURE__*/React.createElement(React.Fragment, null, message, ', ', /*#__PURE__*/React.createElement(Button, {
38
35
  spacing: "none",
39
36
  appearance: "subtle-link",
40
37
  component: IconStyledButton,
@@ -55,8 +52,6 @@ export class InlineCardErroredView extends React.Component {
55
52
  } = this.props;
56
53
  return /*#__PURE__*/React.createElement(Frame, {
57
54
  testId: testId,
58
- link: url,
59
- onClick: onClick,
60
55
  isSelected: isSelected
61
56
  }, /*#__PURE__*/React.createElement(IconAndTitleLayout, {
62
57
  icon: icon || /*#__PURE__*/React.createElement(AKIconWrapper, null, /*#__PURE__*/React.createElement(ErrorIcon, {
@@ -64,7 +59,10 @@ export class InlineCardErroredView extends React.Component {
64
59
  size: "small",
65
60
  primaryColor: token('color.icon.danger', R300)
66
61
  })),
67
- title: this.renderMessage()
62
+ link: url,
63
+ title: url,
64
+ onClick: onClick,
65
+ rightSide: this.renderRightSide()
68
66
  }));
69
67
  }
70
68
 
@@ -10,7 +10,7 @@ import { IconAndTitleLayout } from '../IconAndTitleLayout';
10
10
  import { AKIconWrapper } from '../Icon';
11
11
  import { messages } from '../../../messages';
12
12
  import { FormattedMessage } from 'react-intl-next';
13
- import { IconStyledButton, LowercaseAppearance, LinkAppearance } from '../styled';
13
+ import { IconStyledButton, LowercaseAppearance } from '../styled';
14
14
  const FallbackForbiddenIcon = /*#__PURE__*/React.createElement(AKIconWrapper, null, /*#__PURE__*/React.createElement(LockIcon, {
15
15
  label: "error",
16
16
  size: "small",
@@ -57,22 +57,20 @@ export class InlineCardForbiddenView extends React.Component {
57
57
  }));
58
58
  });
59
59
 
60
- _defineProperty(this, "renderMessage", () => {
60
+ _defineProperty(this, "renderRightSide", () => {
61
61
  var _this$props3, _this$props3$requestA;
62
62
 
63
63
  const {
64
- url,
65
64
  onAuthorise
66
65
  } = this.props;
67
- const link = /*#__PURE__*/React.createElement(LinkAppearance, null, url);
68
66
  const hasRequestAccessContextMessage = (_this$props3 = this.props) === null || _this$props3 === void 0 ? void 0 : (_this$props3$requestA = _this$props3.requestAccessContext) === null || _this$props3$requestA === void 0 ? void 0 : _this$props3$requestA.callToActionMessageKey;
69
- return !onAuthorise && !hasRequestAccessContextMessage ? link : /*#__PURE__*/React.createElement(React.Fragment, null, link, ' - ', /*#__PURE__*/React.createElement(Button, {
67
+ return onAuthorise || hasRequestAccessContextMessage ? /*#__PURE__*/React.createElement(Button, {
70
68
  spacing: "none",
71
69
  appearance: "subtle-link",
72
70
  onClick: this.handleRetry,
73
71
  component: IconStyledButton,
74
72
  testId: "button-connect-other-account"
75
- }, this.renderForbiddenAccessMessage()));
73
+ }, this.renderForbiddenAccessMessage()) : null;
76
74
  });
77
75
  }
78
76
 
@@ -86,12 +84,13 @@ export class InlineCardForbiddenView extends React.Component {
86
84
  } = this.props;
87
85
  return /*#__PURE__*/React.createElement(Frame, {
88
86
  testId: testId,
89
- link: url,
90
- onClick: onClick,
91
87
  isSelected: isSelected
92
88
  }, /*#__PURE__*/React.createElement(IconAndTitleLayout, {
93
89
  icon: icon ? icon : FallbackForbiddenIcon,
94
- title: this.renderMessage(),
90
+ link: url,
91
+ title: url,
92
+ onClick: onClick,
93
+ rightSide: this.renderRightSide(),
95
94
  titleColor: token('color.text.subtle', N500)
96
95
  }));
97
96
  }
@@ -1,6 +1,6 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import { useGlobalTheme } from '@atlaskit/theme/components';
3
- import { Wrapper } from './styled';
3
+ import { WrapperAnchor, WrapperSpan } from './styled';
4
4
  export const Frame = props => {
5
5
  const {
6
6
  isSelected,
@@ -8,7 +8,6 @@ export const Frame = props => {
8
8
  onClick,
9
9
  link,
10
10
  withoutBackground,
11
- withoutHover,
12
11
  testId,
13
12
  className
14
13
  } = props;
@@ -30,14 +29,15 @@ export const Frame = props => {
30
29
  onClick(event);
31
30
  }
32
31
  }, [onClick]);
33
- const isInteractive = Boolean(onClick); // TODO Theming doesn't work right now in editor. Required React context does not trickle down atm.
32
+ const isInteractive = Boolean(onClick); // Depending on whenever Frame was given onClick or link itself we display span or anchor elements
33
+
34
+ const Wrapper = link || onClick ? WrapperAnchor : WrapperSpan; // TODO Theming doesn't work right now in editor. Required React context does not trickle down atm.
34
35
  // It will be worked as part of https://product-fabric.atlassian.net/jira/servicedesk/projects/DTR/queues/issue/DTR-154
35
36
 
36
37
  return /*#__PURE__*/React.createElement(Wrapper, {
37
38
  theme: useGlobalTheme(),
38
39
  href: link,
39
40
  withoutBackground: withoutBackground,
40
- withoutHover: withoutHover,
41
41
  isSelected: isSelected,
42
42
  isInteractive: isInteractive,
43
43
  tabIndex: isInteractive ? 0 : undefined,