@atlaskit/smart-card 23.10.0 → 23.10.2

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 (47) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/messages.js +1 -1
  3. package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +47 -17
  4. package/dist/cjs/utils/analytics/analytics.js +30 -2
  5. package/dist/cjs/utils/analytics/index.js +6 -0
  6. package/dist/cjs/utils/index.js +65 -2
  7. package/dist/cjs/version.json +1 -1
  8. package/dist/cjs/view/CardWithUrl/loader.js +19 -8
  9. package/dist/cjs/view/InlineCard/ForbiddenView/index.js +40 -18
  10. package/dist/cjs/view/InlineCard/IconAndTitleLayout/index.js +5 -2
  11. package/dist/cjs/view/InlineCard/IconAndTitleLayout/styled.js +1 -1
  12. package/dist/cjs/view/InlineCard/ResolvedView/index.js +2 -2
  13. package/dist/es2019/messages.js +1 -1
  14. package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +32 -1
  15. package/dist/es2019/utils/analytics/analytics.js +24 -0
  16. package/dist/es2019/utils/analytics/index.js +1 -1
  17. package/dist/es2019/utils/index.js +16 -1
  18. package/dist/es2019/version.json +1 -1
  19. package/dist/es2019/view/CardWithUrl/loader.js +16 -8
  20. package/dist/es2019/view/InlineCard/ForbiddenView/index.js +40 -19
  21. package/dist/es2019/view/InlineCard/IconAndTitleLayout/index.js +6 -2
  22. package/dist/es2019/view/InlineCard/IconAndTitleLayout/styled.js +0 -3
  23. package/dist/es2019/view/InlineCard/ResolvedView/index.js +3 -3
  24. package/dist/esm/messages.js +1 -1
  25. package/dist/esm/state/analytics/useSmartLinkAnalytics.js +48 -18
  26. package/dist/esm/utils/analytics/analytics.js +25 -0
  27. package/dist/esm/utils/analytics/index.js +1 -1
  28. package/dist/esm/utils/index.js +56 -1
  29. package/dist/esm/version.json +1 -1
  30. package/dist/esm/view/CardWithUrl/loader.js +19 -9
  31. package/dist/esm/view/InlineCard/ForbiddenView/index.js +40 -19
  32. package/dist/esm/view/InlineCard/IconAndTitleLayout/index.js +6 -2
  33. package/dist/esm/view/InlineCard/IconAndTitleLayout/styled.js +1 -1
  34. package/dist/esm/view/InlineCard/ResolvedView/index.js +3 -3
  35. package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +8 -0
  36. package/dist/types/state/flexible-ui-context/index.d.ts +2 -0
  37. package/dist/types/state/hooks/useSmartLink.d.ts +1 -0
  38. package/dist/types/utils/analytics/analytics.d.ts +1 -0
  39. package/dist/types/utils/analytics/index.d.ts +1 -1
  40. package/dist/types/utils/index.d.ts +2 -0
  41. package/dist/types/utils/mocks.d.ts +1 -0
  42. package/dist/types/utils/types.d.ts +1 -1
  43. package/dist/types/view/InlineCard/ForbiddenView/index.d.ts +3 -0
  44. package/dist/types/view/InlineCard/IconAndTitleLayout/index.d.ts +4 -0
  45. package/package.json +1 -1
  46. package/report.api.md +12 -0
  47. package/tmp/api-report-tmp.d.ts +2 -1
@@ -10,7 +10,9 @@ 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 } from '../styled';
13
+ import { IconStyledButton } from '../styled';
14
+ import Lozenge from '@atlaskit/lozenge';
15
+ import { LozengeWrapper, LozengeBlockWrapper } from '../IconAndTitleLayout/styled';
14
16
  const FallbackForbiddenIcon = /*#__PURE__*/React.createElement(AKIconWrapper, null, /*#__PURE__*/React.createElement(LockIcon, {
15
17
  label: "error",
16
18
  size: "small",
@@ -18,8 +20,14 @@ const FallbackForbiddenIcon = /*#__PURE__*/React.createElement(AKIconWrapper, nu
18
20
  }));
19
21
  export class InlineCardForbiddenView extends React.Component {
20
22
  constructor(...args) {
23
+ var _this$props, _this$props$requestAc;
24
+
21
25
  super(...args);
22
26
 
27
+ _defineProperty(this, "state", {
28
+ hasRequestAccessContextMessage: !!((_this$props = this.props) !== null && _this$props !== void 0 && (_this$props$requestAc = _this$props.requestAccessContext) !== null && _this$props$requestAc !== void 0 && _this$props$requestAc.callToActionMessageKey)
29
+ });
30
+
23
31
  _defineProperty(this, "handleRetry", event => {
24
32
  const {
25
33
  onAuthorise
@@ -30,16 +38,16 @@ export class InlineCardForbiddenView extends React.Component {
30
38
  if (onAuthorise) {
31
39
  onAuthorise();
32
40
  } else {
33
- var _this$props, _this$props$requestAc, _this$props$requestAc2;
41
+ var _this$props2, _this$props2$requestA, _this$props2$requestA2;
34
42
 
35
- (_this$props = this.props) === null || _this$props === void 0 ? void 0 : (_this$props$requestAc = _this$props.requestAccessContext) === null || _this$props$requestAc === void 0 ? void 0 : (_this$props$requestAc2 = _this$props$requestAc.action) === null || _this$props$requestAc2 === void 0 ? void 0 : _this$props$requestAc2.promise();
43
+ (_this$props2 = this.props) === null || _this$props2 === void 0 ? void 0 : (_this$props2$requestA = _this$props2.requestAccessContext) === null || _this$props2$requestA === void 0 ? void 0 : (_this$props2$requestA2 = _this$props2$requestA.action) === null || _this$props2$requestA2 === void 0 ? void 0 : _this$props2$requestA2.promise();
36
44
  }
37
45
  });
38
46
 
39
47
  _defineProperty(this, "renderForbiddenAccessMessage", () => {
40
- var _this$props2, _this$props2$requestA;
48
+ var _this$props3, _this$props3$requestA;
41
49
 
42
- if ((_this$props2 = this.props) !== null && _this$props2 !== void 0 && (_this$props2$requestA = _this$props2.requestAccessContext) !== null && _this$props2$requestA !== void 0 && _this$props2$requestA.callToActionMessageKey) {
50
+ if ((_this$props3 = this.props) !== null && _this$props3 !== void 0 && (_this$props3$requestA = _this$props3.requestAccessContext) !== null && _this$props3$requestA !== void 0 && _this$props3$requestA.callToActionMessageKey) {
43
51
  const {
44
52
  callToActionMessageKey
45
53
  } = this.props.requestAccessContext;
@@ -51,26 +59,38 @@ export class InlineCardForbiddenView extends React.Component {
51
59
  }
52
60
 
53
61
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormattedMessage, messages.invalid_permissions, formattedMessage => {
54
- return /*#__PURE__*/React.createElement(React.Fragment, null, formattedMessage, ", ");
55
- }), /*#__PURE__*/React.createElement(FormattedMessage, messages.try_another_account, formattedMessage => {
56
- return /*#__PURE__*/React.createElement(LowercaseAppearance, null, formattedMessage);
62
+ return /*#__PURE__*/React.createElement(React.Fragment, null, formattedMessage);
57
63
  }));
58
64
  });
59
65
 
60
66
  _defineProperty(this, "renderRightSide", () => {
61
- var _this$props3, _this$props3$requestA;
62
-
63
67
  const {
64
68
  onAuthorise
65
69
  } = this.props;
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;
67
- return onAuthorise || hasRequestAccessContextMessage ? /*#__PURE__*/React.createElement(Button, {
68
- spacing: "none",
69
- appearance: "subtle-link",
70
- onClick: this.handleRetry,
71
- component: IconStyledButton,
72
- testId: "button-connect-other-account"
73
- }, this.renderForbiddenAccessMessage()) : null;
70
+
71
+ if (this.state.hasRequestAccessContextMessage) {
72
+ return /*#__PURE__*/React.createElement(Button, {
73
+ spacing: "none",
74
+ appearance: "subtle-link",
75
+ onClick: this.handleRetry,
76
+ component: IconStyledButton,
77
+ testId: "button-connect-other-account"
78
+ }, this.renderForbiddenAccessMessage());
79
+ }
80
+
81
+ if (onAuthorise) {
82
+ return /*#__PURE__*/React.createElement(LozengeBlockWrapper, null, /*#__PURE__*/React.createElement(Button, {
83
+ spacing: "none",
84
+ appearance: "subtle-link",
85
+ onClick: this.handleRetry,
86
+ component: IconStyledButton,
87
+ testId: "button-connect-other-account"
88
+ }, /*#__PURE__*/React.createElement(LozengeWrapper, null, /*#__PURE__*/React.createElement(Lozenge, {
89
+ appearance: 'moved'
90
+ }, this.renderForbiddenAccessMessage()))));
91
+ }
92
+
93
+ return null;
74
94
  });
75
95
  }
76
96
 
@@ -90,8 +110,9 @@ export class InlineCardForbiddenView extends React.Component {
90
110
  link: url,
91
111
  title: url,
92
112
  onClick: onClick,
113
+ titleColor: token('color.text.subtle', N500),
93
114
  rightSide: this.renderRightSide(),
94
- titleColor: token('color.text.subtle', N500)
115
+ rightSideSpacer: this.state.hasRequestAccessContextMessage
95
116
  }));
96
117
  }
97
118
 
@@ -134,7 +134,11 @@ export class IconAndTitleLayout extends React.Component {
134
134
  href: link,
135
135
  onClick: this.handleClick,
136
136
  onKeyPress: this.handleKeyPress
137
- }, titlePart) : titlePart, rightSide ? /*#__PURE__*/React.createElement(NoLinkAppearance, null, ' - ', rightSide) : null));
137
+ }, titlePart) : titlePart, rightSide ? /*#__PURE__*/React.createElement(NoLinkAppearance, null, this.props.rightSideSpacer && ' - ', rightSide) : null));
138
138
  }
139
139
 
140
- }
140
+ }
141
+
142
+ _defineProperty(IconAndTitleLayout, "defaultProps", {
143
+ rightSideSpacer: true
144
+ });
@@ -62,9 +62,6 @@ export const IconTitleWrapper = styled.span`
62
62
  export const LozengeWrapper = styled.span`
63
63
  display: inline-block;
64
64
  vertical-align: 1px;
65
- & > span {
66
- margin-left: 4px;
67
- }
68
65
  `; // TODO: Replace overrides with proper AtlasKit solution.
69
66
 
70
67
  export const LozengeBlockWrapper = styled.span`
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { Frame } from '../Frame';
3
3
  import Lozenge from '@atlaskit/lozenge';
4
4
  import { IconAndTitleLayout } from '../IconAndTitleLayout';
5
- import { LozengeWrapper } from '../IconAndTitleLayout/styled';
5
+ import { LozengeWrapper, LozengeBlockWrapper } from '../IconAndTitleLayout/styled';
6
6
  import { HoverCard } from '../../../view/HoverCard/index';
7
7
  export class InlineCardResolvedView extends React.Component {
8
8
  renderLozenge() {
@@ -14,10 +14,10 @@ export class InlineCardResolvedView extends React.Component {
14
14
  return null;
15
15
  }
16
16
 
17
- return /*#__PURE__*/React.createElement(LozengeWrapper, null, /*#__PURE__*/React.createElement(Lozenge, {
17
+ return /*#__PURE__*/React.createElement(LozengeBlockWrapper, null, /*#__PURE__*/React.createElement(LozengeWrapper, null, /*#__PURE__*/React.createElement(Lozenge, {
18
18
  appearance: lozenge.appearance || 'default',
19
19
  isBold: lozenge.isBold
20
- }, lozenge.text));
20
+ }, lozenge.text)));
21
21
  }
22
22
 
23
23
  render() {
@@ -127,7 +127,7 @@ export var messages = defineMessages({
127
127
  },
128
128
  invalid_permissions: {
129
129
  id: 'fabric.linking.invalid_permissions',
130
- defaultMessage: 'Restricted link',
130
+ defaultMessage: 'Restricted content',
131
131
  description: 'Message shown when a user does not have permissions to view an item'
132
132
  },
133
133
  invalid_permissions_description: {
@@ -7,7 +7,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
7
7
 
8
8
  import { useMemo } from 'react';
9
9
  import { getUrl } from '@atlaskit/linking-common';
10
- import { connectFailedEvent as _connectFailedEvent, connectSucceededEvent as _connectSucceededEvent, context, instrumentEvent, invokeFailedEvent as _invokeFailedEvent, invokeSucceededEvent as _invokeSucceededEvent, screenAuthPopupEvent, trackAppAccountAuthStarted, trackAppAccountConnected, uiActionClickedEvent, uiAuthAlternateAccountEvent, uiAuthEvent, uiCardClickedEvent, uiClosedAuthEvent, uiHoverCardDismissedEvent, uiHoverCardOpenLinkClickedEvent, uiHoverCardViewedEvent, uiLearnMoreLinkClickedEvent, uiRenderFailedEvent, uiRenderSuccessEvent } from '../../utils/analytics';
10
+ import { chunkloadFailedEvent as _chunkloadFailedEvent, connectFailedEvent as _connectFailedEvent, connectSucceededEvent as _connectSucceededEvent, context, instrumentEvent, invokeFailedEvent as _invokeFailedEvent, invokeSucceededEvent as _invokeSucceededEvent, screenAuthPopupEvent, trackAppAccountAuthStarted, trackAppAccountConnected, uiActionClickedEvent, uiAuthAlternateAccountEvent, uiAuthEvent, uiCardClickedEvent, uiClosedAuthEvent, uiHoverCardDismissedEvent, uiHoverCardOpenLinkClickedEvent, uiHoverCardViewedEvent, uiLearnMoreLinkClickedEvent, uiRenderFailedEvent, uiRenderSuccessEvent } from '../../utils/analytics';
11
11
  import { failUfoExperience, startUfoExperience, succeedUfoExperience } from './ufoExperiences';
12
12
  import { getDefinitionId, getExtensionKey, getProduct, getResourceType, getSubproduct } from '../helpers';
13
13
  import { useSmartLinkContext } from '@atlaskit/link-provider';
@@ -601,6 +601,36 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchA
601
601
  if (event) {
602
602
  dispatchAnalytics(applyCommonAttributes(event, commonAttributes));
603
603
  }
604
+ },
605
+
606
+ /**
607
+ * This fires an event that represents when a Smart Link renders unsuccessfuly.
608
+ * @param display Whether the card was an Inline, Block, Embed or Flexible UI.
609
+ * @param id The unique ID for this Smart Link.
610
+ * @param error: An error representing why the Smart Link render failed.
611
+ * @param errorInfo: Additional details about the error including the stack trace.
612
+ */
613
+ chunkloadFailedEvent: function chunkloadFailedEvent(_ref16) {
614
+ var display = _ref16.display,
615
+ error = _ref16.error,
616
+ errorInfo = _ref16.errorInfo,
617
+ extensionKey = _ref16.extensionKey,
618
+ definitionId = _ref16.definitionId,
619
+ resourceType = _ref16.resourceType,
620
+ destinationProduct = _ref16.destinationProduct,
621
+ destinationSubproduct = _ref16.destinationSubproduct,
622
+ location = _ref16.location;
623
+ dispatchAnalytics(applyCommonAttributes(_chunkloadFailedEvent({
624
+ display: display,
625
+ error: error,
626
+ errorInfo: errorInfo,
627
+ extensionKey: extensionKey,
628
+ definitionId: definitionId,
629
+ resourceType: resourceType,
630
+ destinationProduct: destinationProduct,
631
+ destinationSubproduct: destinationSubproduct,
632
+ location: location
633
+ }), commonAttributes));
604
634
  }
605
635
  };
606
636
  }, [defaultId, commonAttributes, dispatchAnalytics]);
@@ -614,13 +644,13 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchA
614
644
  * @param extensionKey The extensionKey of the Smart Link resovler invoked.
615
645
  * @returns
616
646
  */
617
- appAccountConnected: function appAccountConnected(_ref16) {
618
- var extensionKey = _ref16.extensionKey,
619
- definitionId = _ref16.definitionId,
620
- resourceType = _ref16.resourceType,
621
- destinationProduct = _ref16.destinationProduct,
622
- destinationSubproduct = _ref16.destinationSubproduct,
623
- location = _ref16.location;
647
+ appAccountConnected: function appAccountConnected(_ref17) {
648
+ var extensionKey = _ref17.extensionKey,
649
+ definitionId = _ref17.definitionId,
650
+ resourceType = _ref17.resourceType,
651
+ destinationProduct = _ref17.destinationProduct,
652
+ destinationSubproduct = _ref17.destinationSubproduct,
653
+ location = _ref17.location;
624
654
  return dispatchAnalytics(applyCommonAttributes(trackAppAccountConnected(_objectSpread(_objectSpread({}, commonAttributes), {}, {
625
655
  extensionKey: extensionKey,
626
656
  definitionId: definitionId,
@@ -637,9 +667,9 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchA
637
667
  * @param extensionKey The extensionKey of the Smart Link resolver invoked.
638
668
  * @returns
639
669
  */
640
- appAccountAuthStarted: function appAccountAuthStarted(_ref17) {
641
- var extensionKey = _ref17.extensionKey,
642
- location = _ref17.location;
670
+ appAccountAuthStarted: function appAccountAuthStarted(_ref18) {
671
+ var extensionKey = _ref18.extensionKey,
672
+ location = _ref18.location;
643
673
  return dispatchAnalytics(applyCommonAttributes(trackAppAccountAuthStarted(_objectSpread(_objectSpread({}, commonAttributes), {}, {
644
674
  extensionKey: extensionKey,
645
675
  location: location
@@ -657,13 +687,13 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchA
657
687
  * @param extensionKey The extensionKey of the Smart Link resovler invoked.
658
688
  * @returns
659
689
  */
660
- authPopupEvent: function authPopupEvent(_ref18) {
661
- var extensionKey = _ref18.extensionKey,
662
- definitionId = _ref18.definitionId,
663
- resourceType = _ref18.resourceType,
664
- destinationProduct = _ref18.destinationProduct,
665
- destinationSubproduct = _ref18.destinationSubproduct,
666
- location = _ref18.location;
690
+ authPopupEvent: function authPopupEvent(_ref19) {
691
+ var extensionKey = _ref19.extensionKey,
692
+ definitionId = _ref19.definitionId,
693
+ resourceType = _ref19.resourceType,
694
+ destinationProduct = _ref19.destinationProduct,
695
+ destinationSubproduct = _ref19.destinationSubproduct,
696
+ location = _ref19.location;
667
697
  return dispatchAnalytics(applyCommonAttributes(screenAuthPopupEvent(_objectSpread(_objectSpread({}, commonAttributes), {}, {
668
698
  extensionKey: extensionKey,
669
699
  definitionId: definitionId,
@@ -504,4 +504,29 @@ export var uiLearnMoreLinkClickedEvent = function uiLearnMoreLinkClickedEvent()
504
504
  eventType: 'ui',
505
505
  attributes: _objectSpread({}, context)
506
506
  };
507
+ };
508
+ export var chunkloadFailedEvent = function chunkloadFailedEvent(_ref19) {
509
+ var display = _ref19.display,
510
+ error = _ref19.error,
511
+ errorInfo = _ref19.errorInfo,
512
+ extensionKey = _ref19.extensionKey,
513
+ definitionId = _ref19.definitionId,
514
+ destinationProduct = _ref19.destinationProduct,
515
+ destinationSubproduct = _ref19.destinationSubproduct,
516
+ location = _ref19.location;
517
+ return {
518
+ action: 'chunkLoadFailed',
519
+ actionSubject: 'smartLink',
520
+ eventType: 'operational',
521
+ attributes: _objectSpread(_objectSpread({}, context), {}, {
522
+ error: error,
523
+ errorInfo: errorInfo,
524
+ display: display,
525
+ extensionKey: extensionKey,
526
+ definitionId: definitionId,
527
+ destinationProduct: destinationProduct,
528
+ destinationSubproduct: destinationSubproduct,
529
+ location: location
530
+ })
531
+ };
507
532
  };
@@ -6,7 +6,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
6
6
 
7
7
  import { getMeasure } from '../performance';
8
8
  import { resolvedEvent, unresolvedEvent } from './analytics';
9
- export { ANALYTICS_CHANNEL, context, fireSmartLinkEvent, resolvedEvent, unresolvedEvent, invokeSucceededEvent, invokeFailedEvent, connectSucceededEvent, connectFailedEvent, trackAppAccountAuthStarted, trackAppAccountConnected, uiAuthEvent, uiAuthAlternateAccountEvent, uiCardClickedEvent, uiActionClickedEvent, uiClosedAuthEvent, screenAuthPopupEvent, uiRenderSuccessEvent, uiRenderFailedEvent, uiHoverCardViewedEvent, uiHoverCardDismissedEvent, uiHoverCardOpenLinkClickedEvent, uiLearnMoreLinkClickedEvent } from './analytics';
9
+ export { ANALYTICS_CHANNEL, context, fireSmartLinkEvent, resolvedEvent, unresolvedEvent, invokeSucceededEvent, invokeFailedEvent, chunkloadFailedEvent, connectSucceededEvent, connectFailedEvent, trackAppAccountAuthStarted, trackAppAccountConnected, uiAuthEvent, uiAuthAlternateAccountEvent, uiCardClickedEvent, uiActionClickedEvent, uiClosedAuthEvent, screenAuthPopupEvent, uiRenderSuccessEvent, uiRenderFailedEvent, uiHoverCardViewedEvent, uiHoverCardDismissedEvent, uiHoverCardOpenLinkClickedEvent, uiLearnMoreLinkClickedEvent } from './analytics';
10
10
  export var instrumentEvent = function instrumentEvent(_ref) {
11
11
  var id = _ref.id,
12
12
  status = _ref.status,
@@ -1,4 +1,6 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
1
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
2
4
  import React from 'react';
3
5
  import Loadable from 'react-loadable';
4
6
  export var isCardWithData = function isCardWithData(props) {
@@ -227,4 +229,57 @@ export var handleOnClick = function handleOnClick(handler) {
227
229
  };
228
230
  export var isIntersectionObserverSupported = function isIntersectionObserverSupported() {
229
231
  return typeof IntersectionObserver !== 'undefined';
230
- };
232
+ };
233
+ export var sleep = function sleep(ms) {
234
+ return new Promise(function (resolve) {
235
+ return setTimeout(resolve, ms);
236
+ });
237
+ };
238
+ export var importWithRetry = /*#__PURE__*/function () {
239
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(importFn) {
240
+ var retries,
241
+ interval,
242
+ _args = arguments;
243
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
244
+ while (1) {
245
+ switch (_context.prev = _context.next) {
246
+ case 0:
247
+ retries = _args.length > 1 && _args[1] !== undefined ? _args[1] : 2;
248
+ interval = _args.length > 2 && _args[2] !== undefined ? _args[2] : 500;
249
+ _context.prev = 2;
250
+ _context.next = 5;
251
+ return importFn();
252
+
253
+ case 5:
254
+ return _context.abrupt("return", _context.sent);
255
+
256
+ case 8:
257
+ _context.prev = 8;
258
+ _context.t0 = _context["catch"](2);
259
+
260
+ if (!(_context.t0.name === 'ChunkLoadError' && retries > 0)) {
261
+ _context.next = 16;
262
+ break;
263
+ }
264
+
265
+ _context.next = 13;
266
+ return sleep(interval);
267
+
268
+ case 13:
269
+ return _context.abrupt("return", importWithRetry(importFn, retries - 1, interval));
270
+
271
+ case 16:
272
+ throw _context.t0;
273
+
274
+ case 17:
275
+ case "end":
276
+ return _context.stop();
277
+ }
278
+ }
279
+ }, _callee, null, [[2, 8]]);
280
+ }));
281
+
282
+ return function importWithRetry(_x) {
283
+ return _ref.apply(this, arguments);
284
+ };
285
+ }();
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "23.10.0",
3
+ "version": "23.10.2",
4
4
  "sideEffects": false
5
5
  }
@@ -6,10 +6,13 @@ import { clearMarks, clearMeasures } from '../../utils/performance';
6
6
  import { ErrorBoundary } from 'react-error-boundary';
7
7
  import { useSmartLinkAnalytics } from '../../state/analytics';
8
8
  import { LoadingCardLink } from './component-lazy/LazyFallback';
9
+ import { importWithRetry } from '../../utils';
9
10
  var LazyCardWithUrlContent = /*#__PURE__*/lazy(function () {
10
- return import(
11
- /* webpackChunkName: "@atlaskit-internal_smartcard-urlcardcontent" */
12
- './component-lazy/index');
11
+ return importWithRetry(function () {
12
+ return import(
13
+ /* webpackChunkName: "@atlaskit-internal_smartcard-urlcardcontent" */
14
+ './component-lazy/index');
15
+ });
13
16
  });
14
17
  export function CardWithURLRenderer(props) {
15
18
  var _useState = useState(function () {
@@ -59,15 +62,22 @@ export function CardWithURLRenderer(props) {
59
62
  }, [appearance, createAnalyticsEvent]);
60
63
  var analytics = useSmartLinkAnalytics(url !== null && url !== void 0 ? url : '', dispatchAnalytics, id);
61
64
  var logError = useCallback(function (error, info) {
62
- var componentStack = info.componentStack; // NB: APIErrors are thrown in response to Object Resolver Service. We do not
65
+ var componentStack = info.componentStack;
66
+ var errorInfo = {
67
+ componentStack: componentStack
68
+ }; // NB: APIErrors are thrown in response to Object Resolver Service. We do not
63
69
  // fire an event for these, as they do not cover failed UI render events.
64
70
  // The rest of the errors caught here are unexpected, and correlate
65
71
  // to the reliability of the smart-card front-end components.
72
+ // Likewise, chunk loading errors are not caused by a failure of smart-card rendering.
66
73
 
67
- if (error.name !== 'APIError') {
68
- var errorInfo = {
69
- componentStack: componentStack
70
- };
74
+ if (error.name === 'ChunkLoadError') {
75
+ analytics.operational.chunkloadFailedEvent({
76
+ display: appearance,
77
+ error: error,
78
+ errorInfo: errorInfo
79
+ });
80
+ } else if (error.name !== 'APIError') {
71
81
  analytics.ui.renderFailedEvent({
72
82
  display: appearance,
73
83
  id: id,
@@ -79,7 +89,7 @@ export function CardWithURLRenderer(props) {
79
89
 
80
90
 
81
91
  throw error;
82
- }, [analytics.ui, appearance, id]);
92
+ }, [analytics.operational, analytics.ui, appearance, id]);
83
93
 
84
94
  if (!url) {
85
95
  throw new Error('@atlaskit/smart-card: url property is missing.');
@@ -21,7 +21,9 @@ import { IconAndTitleLayout } from '../IconAndTitleLayout';
21
21
  import { AKIconWrapper } from '../Icon';
22
22
  import { messages } from '../../../messages';
23
23
  import { FormattedMessage } from 'react-intl-next';
24
- import { IconStyledButton, LowercaseAppearance } from '../styled';
24
+ import { IconStyledButton } from '../styled';
25
+ import Lozenge from '@atlaskit/lozenge';
26
+ import { LozengeWrapper, LozengeBlockWrapper } from '../IconAndTitleLayout/styled';
25
27
  var FallbackForbiddenIcon = /*#__PURE__*/React.createElement(AKIconWrapper, null, /*#__PURE__*/React.createElement(LockIcon, {
26
28
  label: "error",
27
29
  size: "small",
@@ -33,6 +35,8 @@ export var InlineCardForbiddenView = /*#__PURE__*/function (_React$Component) {
33
35
  var _super = _createSuper(InlineCardForbiddenView);
34
36
 
35
37
  function InlineCardForbiddenView() {
38
+ var _this$props, _this$props$requestAc;
39
+
36
40
  var _this;
37
41
 
38
42
  _classCallCheck(this, InlineCardForbiddenView);
@@ -43,6 +47,10 @@ export var InlineCardForbiddenView = /*#__PURE__*/function (_React$Component) {
43
47
 
44
48
  _this = _super.call.apply(_super, [this].concat(args));
45
49
 
50
+ _defineProperty(_assertThisInitialized(_this), "state", {
51
+ hasRequestAccessContextMessage: !!((_this$props = _this.props) !== null && _this$props !== void 0 && (_this$props$requestAc = _this$props.requestAccessContext) !== null && _this$props$requestAc !== void 0 && _this$props$requestAc.callToActionMessageKey)
52
+ });
53
+
46
54
  _defineProperty(_assertThisInitialized(_this), "handleRetry", function (event) {
47
55
  var onAuthorise = _this.props.onAuthorise;
48
56
  event.preventDefault();
@@ -51,16 +59,16 @@ export var InlineCardForbiddenView = /*#__PURE__*/function (_React$Component) {
51
59
  if (onAuthorise) {
52
60
  onAuthorise();
53
61
  } else {
54
- var _this$props, _this$props$requestAc, _this$props$requestAc2;
62
+ var _this$props2, _this$props2$requestA, _this$props2$requestA2;
55
63
 
56
- (_this$props = _this.props) === null || _this$props === void 0 ? void 0 : (_this$props$requestAc = _this$props.requestAccessContext) === null || _this$props$requestAc === void 0 ? void 0 : (_this$props$requestAc2 = _this$props$requestAc.action) === null || _this$props$requestAc2 === void 0 ? void 0 : _this$props$requestAc2.promise();
64
+ (_this$props2 = _this.props) === null || _this$props2 === void 0 ? void 0 : (_this$props2$requestA = _this$props2.requestAccessContext) === null || _this$props2$requestA === void 0 ? void 0 : (_this$props2$requestA2 = _this$props2$requestA.action) === null || _this$props2$requestA2 === void 0 ? void 0 : _this$props2$requestA2.promise();
57
65
  }
58
66
  });
59
67
 
60
68
  _defineProperty(_assertThisInitialized(_this), "renderForbiddenAccessMessage", function () {
61
- var _this$props2, _this$props2$requestA;
69
+ var _this$props3, _this$props3$requestA;
62
70
 
63
- if ((_this$props2 = _this.props) !== null && _this$props2 !== void 0 && (_this$props2$requestA = _this$props2.requestAccessContext) !== null && _this$props2$requestA !== void 0 && _this$props2$requestA.callToActionMessageKey) {
71
+ if ((_this$props3 = _this.props) !== null && _this$props3 !== void 0 && (_this$props3$requestA = _this$props3.requestAccessContext) !== null && _this$props3$requestA !== void 0 && _this$props3$requestA.callToActionMessageKey) {
64
72
  var callToActionMessageKey = _this.props.requestAccessContext.callToActionMessageKey;
65
73
  return /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages[callToActionMessageKey], {
66
74
  values: {
@@ -70,24 +78,36 @@ export var InlineCardForbiddenView = /*#__PURE__*/function (_React$Component) {
70
78
  }
71
79
 
72
80
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormattedMessage, messages.invalid_permissions, function (formattedMessage) {
73
- return /*#__PURE__*/React.createElement(React.Fragment, null, formattedMessage, ", ");
74
- }), /*#__PURE__*/React.createElement(FormattedMessage, messages.try_another_account, function (formattedMessage) {
75
- return /*#__PURE__*/React.createElement(LowercaseAppearance, null, formattedMessage);
81
+ return /*#__PURE__*/React.createElement(React.Fragment, null, formattedMessage);
76
82
  }));
77
83
  });
78
84
 
79
85
  _defineProperty(_assertThisInitialized(_this), "renderRightSide", function () {
80
- var _this$props3, _this$props3$requestA;
81
-
82
86
  var onAuthorise = _this.props.onAuthorise;
83
- var 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;
84
- return onAuthorise || hasRequestAccessContextMessage ? /*#__PURE__*/React.createElement(Button, {
85
- spacing: "none",
86
- appearance: "subtle-link",
87
- onClick: _this.handleRetry,
88
- component: IconStyledButton,
89
- testId: "button-connect-other-account"
90
- }, _this.renderForbiddenAccessMessage()) : null;
87
+
88
+ if (_this.state.hasRequestAccessContextMessage) {
89
+ return /*#__PURE__*/React.createElement(Button, {
90
+ spacing: "none",
91
+ appearance: "subtle-link",
92
+ onClick: _this.handleRetry,
93
+ component: IconStyledButton,
94
+ testId: "button-connect-other-account"
95
+ }, _this.renderForbiddenAccessMessage());
96
+ }
97
+
98
+ if (onAuthorise) {
99
+ return /*#__PURE__*/React.createElement(LozengeBlockWrapper, null, /*#__PURE__*/React.createElement(Button, {
100
+ spacing: "none",
101
+ appearance: "subtle-link",
102
+ onClick: _this.handleRetry,
103
+ component: IconStyledButton,
104
+ testId: "button-connect-other-account"
105
+ }, /*#__PURE__*/React.createElement(LozengeWrapper, null, /*#__PURE__*/React.createElement(Lozenge, {
106
+ appearance: 'moved'
107
+ }, _this.renderForbiddenAccessMessage()))));
108
+ }
109
+
110
+ return null;
91
111
  });
92
112
 
93
113
  return _this;
@@ -111,8 +131,9 @@ export var InlineCardForbiddenView = /*#__PURE__*/function (_React$Component) {
111
131
  link: url,
112
132
  title: url,
113
133
  onClick: onClick,
134
+ titleColor: token('color.text.subtle', N500),
114
135
  rightSide: this.renderRightSide(),
115
- titleColor: token('color.text.subtle', N500)
136
+ rightSideSpacer: this.state.hasRequestAccessContextMessage
116
137
  }));
117
138
  }
118
139
  }]);
@@ -156,9 +156,13 @@ export var IconAndTitleLayout = /*#__PURE__*/function (_React$Component) {
156
156
  href: link,
157
157
  onClick: this.handleClick,
158
158
  onKeyPress: this.handleKeyPress
159
- }, titlePart) : titlePart, rightSide ? /*#__PURE__*/React.createElement(NoLinkAppearance, null, ' - ', rightSide) : null));
159
+ }, titlePart) : titlePart, rightSide ? /*#__PURE__*/React.createElement(NoLinkAppearance, null, this.props.rightSideSpacer && ' - ', rightSide) : null));
160
160
  }
161
161
  }]);
162
162
 
163
163
  return IconAndTitleLayout;
164
- }(React.Component);
164
+ }(React.Component);
165
+
166
+ _defineProperty(IconAndTitleLayout, "defaultProps", {
167
+ rightSideSpacer: true
168
+ });
@@ -21,7 +21,7 @@ export var EmojiWrapper = styled.span(_templateObject2 || (_templateObject2 = _t
21
21
 
22
22
  export var IconTitleWrapper = styled.span(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n white-space: pre-wrap;\n word-break: break-all;\n"]))); // TODO: Replace overrides with proper AtlasKit solution.
23
23
 
24
- export var LozengeWrapper = styled.span(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n display: inline-block;\n vertical-align: 1px;\n & > span {\n margin-left: 4px;\n }\n"]))); // TODO: Replace overrides with proper AtlasKit solution.
24
+ export var LozengeWrapper = styled.span(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n display: inline-block;\n vertical-align: 1px;\n"]))); // TODO: Replace overrides with proper AtlasKit solution.
25
25
 
26
26
  export var LozengeBlockWrapper = styled.span(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n & > span {\n margin-left: 4px;\n }\n"])));
27
27
  export var RightIconPositionWrapper = styled.span(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n margin-left: 2px;\n margin-right: 4px;\n position: relative;\n display: inline-block;\n"]))); // The following components are used to absolutely position icons in the vertical center.
@@ -12,7 +12,7 @@ import React from 'react';
12
12
  import { Frame } from '../Frame';
13
13
  import Lozenge from '@atlaskit/lozenge';
14
14
  import { IconAndTitleLayout } from '../IconAndTitleLayout';
15
- import { LozengeWrapper } from '../IconAndTitleLayout/styled';
15
+ import { LozengeWrapper, LozengeBlockWrapper } from '../IconAndTitleLayout/styled';
16
16
  import { HoverCard } from '../../../view/HoverCard/index';
17
17
  export var InlineCardResolvedView = /*#__PURE__*/function (_React$Component) {
18
18
  _inherits(InlineCardResolvedView, _React$Component);
@@ -34,10 +34,10 @@ export var InlineCardResolvedView = /*#__PURE__*/function (_React$Component) {
34
34
  return null;
35
35
  }
36
36
 
37
- return /*#__PURE__*/React.createElement(LozengeWrapper, null, /*#__PURE__*/React.createElement(Lozenge, {
37
+ return /*#__PURE__*/React.createElement(LozengeBlockWrapper, null, /*#__PURE__*/React.createElement(LozengeWrapper, null, /*#__PURE__*/React.createElement(Lozenge, {
38
38
  appearance: lozenge.appearance || 'default',
39
39
  isBold: lozenge.isBold
40
- }, lozenge.text));
40
+ }, lozenge.text)));
41
41
  }
42
42
  }, {
43
43
  key: "render",
@@ -171,6 +171,14 @@ export declare const useSmartLinkAnalytics: (url: string, dispatchAnalytics: Ana
171
171
  * @param error An error representing why the Smart Link request failed.
172
172
  */
173
173
  instrument: ({ id, status, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, error, }: InstrumentEventProps) => void;
174
+ /**
175
+ * This fires an event that represents when a Smart Link renders unsuccessfuly.
176
+ * @param display Whether the card was an Inline, Block, Embed or Flexible UI.
177
+ * @param id The unique ID for this Smart Link.
178
+ * @param error: An error representing why the Smart Link render failed.
179
+ * @param errorInfo: Additional details about the error including the stack trace.
180
+ */
181
+ chunkloadFailedEvent: ({ display, error, errorInfo, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: UiRenderFailedEventProps) => void;
174
182
  };
175
183
  track: {
176
184
  /**
@@ -36,6 +36,7 @@ export declare const FlexibleUiAnalyticsContext: import("react").Context<{
36
36
  connectSucceededEvent: ({ id, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("../../utils/analytics/types").ConnectSucceededEventProps) => void;
37
37
  connectFailedEvent: ({ id, reason, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("../../utils/analytics/types").ConnectFailedEventProps) => void;
38
38
  instrument: ({ id, status, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, error, }: import("../../utils/analytics/types").InstrumentEventProps) => void;
39
+ chunkloadFailedEvent: ({ display, error, errorInfo, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("../../utils/analytics/types").UiRenderFailedEventProps) => void;
39
40
  };
40
41
  track: {
41
42
  appAccountConnected: ({ extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("../../utils/analytics/types").CommonEventProps) => void;
@@ -74,6 +75,7 @@ export declare const useFlexibleUiAnalyticsContext: () => {
74
75
  connectSucceededEvent: ({ id, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("../../utils/analytics/types").ConnectSucceededEventProps) => void;
75
76
  connectFailedEvent: ({ id, reason, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("../../utils/analytics/types").ConnectFailedEventProps) => void;
76
77
  instrument: ({ id, status, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, error, }: import("../../utils/analytics/types").InstrumentEventProps) => void;
78
+ chunkloadFailedEvent: ({ display, error, errorInfo, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("../../utils/analytics/types").UiRenderFailedEventProps) => void;
77
79
  };
78
80
  track: {
79
81
  appAccountConnected: ({ extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: import("../../utils/analytics/types").CommonEventProps) => void;