@atlaskit/smart-card 26.37.2 → 26.38.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/utils/analytics/analytics.js +1 -1
  3. package/dist/cjs/view/BlockCard/actions/flexible/AuthorizeAction.js +1 -0
  4. package/dist/cjs/view/BlockCard/index.js +5 -18
  5. package/dist/cjs/view/BlockCard/views/flexible/FlexibleErroredView.js +12 -34
  6. package/dist/cjs/view/BlockCard/views/flexible/FlexibleForbiddenView.js +25 -51
  7. package/dist/cjs/view/BlockCard/views/flexible/FlexibleForbiddenViewOld.js +13 -32
  8. package/dist/cjs/view/BlockCard/views/flexible/FlexibleNotFoundView.js +9 -31
  9. package/dist/cjs/view/BlockCard/views/flexible/FlexibleResolvedView.js +7 -18
  10. package/dist/cjs/view/BlockCard/views/flexible/FlexibleUnauthorisedView.js +28 -51
  11. package/dist/cjs/view/BlockCard/views/flexible/styled.js +5 -5
  12. package/dist/cjs/view/BlockCard/views/flexible/unresolved-view/index.js +41 -0
  13. package/dist/cjs/view/BlockCard/views/flexible/utils/index.js +30 -1
  14. package/dist/cjs/view/FlexibleCard/components/blocks/footer-block/index.js +12 -57
  15. package/dist/cjs/view/FlexibleCard/components/blocks/footer-block/resolved/index.js +65 -0
  16. package/dist/cjs/view/FlexibleCard/components/blocks/index.js +8 -1
  17. package/dist/cjs/view/FlexibleCard/components/blocks/snippet-block/index.js +4 -2
  18. package/dist/cjs/view/FlexibleCard/components/elements/text/index.js +3 -2
  19. package/dist/cjs/view/LinkUrl/index.js +1 -1
  20. package/dist/es2019/utils/analytics/analytics.js +1 -1
  21. package/dist/es2019/view/BlockCard/actions/flexible/AuthorizeAction.js +1 -0
  22. package/dist/es2019/view/BlockCard/index.js +1 -15
  23. package/dist/es2019/view/BlockCard/views/flexible/FlexibleErroredView.js +8 -32
  24. package/dist/es2019/view/BlockCard/views/flexible/FlexibleForbiddenView.js +25 -52
  25. package/dist/es2019/view/BlockCard/views/flexible/FlexibleForbiddenViewOld.js +12 -31
  26. package/dist/es2019/view/BlockCard/views/flexible/FlexibleNotFoundView.js +15 -41
  27. package/dist/es2019/view/BlockCard/views/flexible/FlexibleResolvedView.js +10 -21
  28. package/dist/es2019/view/BlockCard/views/flexible/FlexibleUnauthorisedView.js +24 -43
  29. package/dist/es2019/view/BlockCard/views/flexible/styled.js +3 -4
  30. package/dist/es2019/view/BlockCard/views/flexible/unresolved-view/index.js +33 -0
  31. package/dist/es2019/view/BlockCard/views/flexible/utils/index.js +27 -2
  32. package/dist/es2019/view/FlexibleCard/components/blocks/footer-block/index.js +11 -54
  33. package/dist/es2019/view/FlexibleCard/components/blocks/footer-block/resolved/index.js +56 -0
  34. package/dist/es2019/view/FlexibleCard/components/blocks/index.js +4 -1
  35. package/dist/es2019/view/FlexibleCard/components/blocks/snippet-block/index.js +3 -1
  36. package/dist/es2019/view/FlexibleCard/components/elements/text/index.js +3 -2
  37. package/dist/es2019/view/LinkUrl/index.js +1 -1
  38. package/dist/esm/utils/analytics/analytics.js +1 -1
  39. package/dist/esm/view/BlockCard/actions/flexible/AuthorizeAction.js +1 -0
  40. package/dist/esm/view/BlockCard/index.js +3 -18
  41. package/dist/esm/view/BlockCard/views/flexible/FlexibleErroredView.js +12 -34
  42. package/dist/esm/view/BlockCard/views/flexible/FlexibleForbiddenView.js +26 -52
  43. package/dist/esm/view/BlockCard/views/flexible/FlexibleForbiddenViewOld.js +13 -32
  44. package/dist/esm/view/BlockCard/views/flexible/FlexibleNotFoundView.js +9 -31
  45. package/dist/esm/view/BlockCard/views/flexible/FlexibleResolvedView.js +10 -21
  46. package/dist/esm/view/BlockCard/views/flexible/FlexibleUnauthorisedView.js +25 -45
  47. package/dist/esm/view/BlockCard/views/flexible/styled.js +4 -4
  48. package/dist/esm/view/BlockCard/views/flexible/unresolved-view/index.js +35 -0
  49. package/dist/esm/view/BlockCard/views/flexible/utils/index.js +30 -1
  50. package/dist/esm/view/FlexibleCard/components/blocks/footer-block/index.js +13 -54
  51. package/dist/esm/view/FlexibleCard/components/blocks/footer-block/resolved/index.js +55 -0
  52. package/dist/esm/view/FlexibleCard/components/blocks/index.js +4 -1
  53. package/dist/esm/view/FlexibleCard/components/blocks/snippet-block/index.js +4 -2
  54. package/dist/esm/view/FlexibleCard/components/elements/text/index.js +3 -2
  55. package/dist/esm/view/LinkUrl/index.js +1 -1
  56. package/dist/types/view/BlockCard/views/flexible/FlexibleUnauthorisedView.d.ts +3 -1
  57. package/dist/types/view/BlockCard/views/flexible/styled.d.ts +0 -1
  58. package/dist/types/view/BlockCard/views/flexible/types.d.ts +2 -83
  59. package/dist/types/view/BlockCard/views/flexible/unresolved-view/index.d.ts +4 -0
  60. package/dist/types/view/BlockCard/views/flexible/unresolved-view/types.d.ts +7 -0
  61. package/dist/types/view/BlockCard/views/flexible/utils/index.d.ts +8 -0
  62. package/dist/types/view/FlexibleCard/components/blocks/footer-block/resolved/index.d.ts +4 -0
  63. package/dist/types/view/FlexibleCard/components/blocks/index.d.ts +1 -0
  64. package/dist/types/view/FlexibleCard/components/blocks/snippet-block/types.d.ts +4 -0
  65. package/dist/types/view/FlexibleCard/components/elements/text/types.d.ts +4 -0
  66. package/dist/types-ts4.5/view/BlockCard/views/flexible/FlexibleUnauthorisedView.d.ts +3 -1
  67. package/dist/types-ts4.5/view/BlockCard/views/flexible/styled.d.ts +0 -1
  68. package/dist/types-ts4.5/view/BlockCard/views/flexible/types.d.ts +2 -83
  69. package/dist/types-ts4.5/view/BlockCard/views/flexible/unresolved-view/index.d.ts +4 -0
  70. package/dist/types-ts4.5/view/BlockCard/views/flexible/unresolved-view/types.d.ts +7 -0
  71. package/dist/types-ts4.5/view/BlockCard/views/flexible/utils/index.d.ts +8 -0
  72. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/footer-block/resolved/index.d.ts +4 -0
  73. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/index.d.ts +1 -0
  74. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/snippet-block/types.d.ts +4 -0
  75. package/dist/types-ts4.5/view/FlexibleCard/components/elements/text/types.d.ts +4 -0
  76. package/package.json +1 -1
  77. package/report.api.md +1 -0
  78. package/tmp/api-report-tmp.d.ts +1 -0
  79. package/dist/cjs/view/BlockCard/components/flexible/footer/index.js +0 -56
  80. package/dist/es2019/view/BlockCard/components/flexible/footer/index.js +0 -52
  81. package/dist/esm/view/BlockCard/components/flexible/footer/index.js +0 -49
  82. package/dist/types/view/BlockCard/components/flexible/footer/index.d.ts +0 -12
  83. package/dist/types/view/BlockCard/components/flexible/footer/types.d.ts +0 -5
  84. package/dist/types-ts4.5/view/BlockCard/components/flexible/footer/index.d.ts +0 -12
  85. package/dist/types-ts4.5/view/BlockCard/components/flexible/footer/types.d.ts +0 -5
  86. /package/dist/cjs/view/BlockCard/{components/flexible/footer → views/flexible/unresolved-view}/types.js +0 -0
  87. /package/dist/es2019/view/BlockCard/{components/flexible/footer → views/flexible/unresolved-view}/types.js +0 -0
  88. /package/dist/esm/view/BlockCard/{components/flexible/footer → views/flexible/unresolved-view}/types.js +0 -0
@@ -1,7 +1,4 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
2
  /** @jsx jsx */
6
3
 
7
4
  import { getExtensionKey } from '../../state/helpers';
@@ -26,8 +23,6 @@ import FlexibleErroredView from './views/flexible/FlexibleErroredView';
26
23
  import { jsx } from '@emotion/react';
27
24
  import { handleClickCommon } from './utils/handlers';
28
25
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
29
- import { titleBlockCss } from './views/flexible/styled';
30
- import { SmartLinkSize } from '../../constants';
31
26
  export { default as PreviewAction } from './actions/PreviewAction';
32
27
  export { ForbiddenAction, AuthorizeAction, BlockCardResolvedView, BlockCardResolvingView, BlockCardUnauthorisedView, BlockCardForbiddenView, BlockCardErroredView, BlockCardNotFoundView };
33
28
  export var BlockCard = function BlockCard(_ref) {
@@ -62,13 +57,7 @@ export var BlockCard = function BlockCard(_ref) {
62
57
  extensionKey: extensionKey
63
58
  };
64
59
  if (enableFlexibleBlockCard) {
65
- var anchorTarget = getBooleanFF('platform.linking-platform.smart-card.enable-block-card-clicks-opening-in-same-tab') ? '_self' : undefined;
66
- var titleBlockProps = _objectSpread({
67
- overrideCss: titleBlockCss
68
- }, getBooleanFF('platform.linking-platform.smart-card.enable-better-metadata_iojwg') && {
69
- size: SmartLinkSize.Large
70
- });
71
- var flexibleBlockCardProps = _objectSpread({
60
+ var flexibleBlockCardProps = {
72
61
  id: id,
73
62
  cardState: cardState,
74
63
  url: url,
@@ -80,12 +69,8 @@ export var BlockCard = function BlockCard(_ref) {
80
69
  onResolve: onResolve,
81
70
  renderers: renderers,
82
71
  showServerActions: showServerActions,
83
- analytics: analytics,
84
- extensionKey: extensionKey,
85
- titleBlockProps: titleBlockProps
86
- }, anchorTarget ? {
87
- anchorTarget: anchorTarget
88
- } : {});
72
+ analytics: analytics
73
+ };
89
74
  switch (status) {
90
75
  case 'pending':
91
76
  case 'resolving':
@@ -1,14 +1,13 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["testId"];
2
4
  import React, { useMemo } from 'react';
3
- import FlexibleCard from '../../../FlexibleCard';
4
- import TitleBlock from '../../../FlexibleCard/components/blocks/title-block';
5
5
  import { messages } from '../../../../messages';
6
6
  import { R300 } from '@atlaskit/theme/colors';
7
7
  import WarningIcon from '@atlaskit/icon/glyph/warning';
8
- import BlockCardFooter from '../../components/flexible/footer';
9
8
  import { RetryAction } from '../../actions/flexible/RetryAction';
10
- import { CustomBlock } from '../../../FlexibleCard/components/blocks';
11
9
  import Text from '../../../FlexibleCard/components/elements/text';
10
+ import UnresolvedView from './unresolved-view';
12
11
  import { withFlexibleUIBlockCardStyle } from './utils/withFlexibleUIBlockCardStyle';
13
12
 
14
13
  /**
@@ -18,34 +17,16 @@ import { withFlexibleUIBlockCardStyle } from './utils/withFlexibleUIBlockCardSty
18
17
  * @see FlexibleCardProps
19
18
  */
20
19
  var FlexibleErroredView = function FlexibleErroredView(_ref) {
21
- var anchorTarget = _ref.anchorTarget,
22
- cardState = _ref.cardState,
23
- onAuthorize = _ref.onAuthorize,
24
- onError = _ref.onError,
25
- url = _ref.url,
26
- onClick = _ref.onClick,
27
- _ref$testId = _ref.testId,
20
+ var _ref$testId = _ref.testId,
28
21
  testId = _ref$testId === void 0 ? 'smart-block-errored-view' : _ref$testId,
29
- titleBlockProps = _ref.titleBlockProps;
30
- var status = cardState.status;
22
+ props = _objectWithoutProperties(_ref, _excluded);
31
23
  var actions = useMemo(function () {
32
- return onAuthorize ? [RetryAction(onAuthorize)] : [];
33
- }, [onAuthorize]);
34
- return /*#__PURE__*/React.createElement(FlexibleCard, {
35
- appearance: "block",
36
- cardState: cardState,
37
- onAuthorize: onAuthorize,
38
- onClick: onClick,
39
- onError: onError,
40
- testId: testId,
41
- ui: {
42
- hideElevation: true
43
- },
44
- url: url
45
- }, /*#__PURE__*/React.createElement(TitleBlock, _extends({
46
- hideRetry: true,
47
- anchorTarget: anchorTarget
48
- }, titleBlockProps)), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(WarningIcon, {
24
+ return props.onAuthorize ? [RetryAction(props.onAuthorize)] : [];
25
+ }, [props.onAuthorize]);
26
+ return /*#__PURE__*/React.createElement(UnresolvedView, _extends({}, props, {
27
+ actions: actions,
28
+ testId: testId
29
+ }), /*#__PURE__*/React.createElement(WarningIcon, {
49
30
  label: "errored-warning-icon",
50
31
  size: "small",
51
32
  primaryColor: "var(--ds-icon-warning, ".concat(R300, ")"),
@@ -54,9 +35,6 @@ var FlexibleErroredView = function FlexibleErroredView(_ref) {
54
35
  message: {
55
36
  descriptor: messages.could_not_load_link
56
37
  }
57
- })), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(BlockCardFooter, {
58
- actions: actions,
59
- status: status
60
- })));
38
+ }));
61
39
  };
62
40
  export default withFlexibleUIBlockCardStyle(FlexibleErroredView);
@@ -1,21 +1,20 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
+ var _excluded = ["testId"];
3
5
  import React, { useMemo } from 'react';
4
- import FlexibleCard from '../../../FlexibleCard';
5
- import { CustomBlock, PreviewBlock, TitleBlock } from '../../../FlexibleCard/components/blocks';
6
+ import { toMessage } from '../../../../utils/intl-utils';
6
7
  import { R300 } from '@atlaskit/theme/colors';
7
8
  import { messages } from '../../../../messages';
8
9
  import LockIcon from '@atlaskit/icon/glyph/lock';
9
- import BlockCardFooter from '../../components/flexible/footer';
10
10
  import { ForbiddenAction } from '../../actions/flexible/ForbiddenAction';
11
11
  import Text from '../../../FlexibleCard/components/elements/text';
12
- import { MediaPlacement, SmartLinkSize } from '../../../../constants';
13
12
  import { getForbiddenJsonLd } from '../../../../utils/jsonld';
14
13
  import { extractProvider } from '@atlaskit/link-extractors';
14
+ import UnresolvedView from './unresolved-view';
15
15
  import { withFlexibleUIBlockCardStyle } from './utils/withFlexibleUIBlockCardStyle';
16
16
  import { extractRequestAccessContextImproved } from '../../../../extractors/common/context/extractAccessContext';
17
- import { FormattedMessage } from 'react-intl-next';
18
- import { forbiddenViewTitleStyle } from './styled';
17
+ import { useIntl } from 'react-intl-next';
19
18
  import extractHostname from '../../../../extractors/common/hostname/extractHostname';
20
19
 
21
20
  /**
@@ -27,16 +26,13 @@ import extractHostname from '../../../../extractors/common/hostname/extractHostn
27
26
  */
28
27
  var FlexibleForbiddenView = function FlexibleForbiddenView(_ref) {
29
28
  var _details$meta;
30
- var anchorTarget = _ref.anchorTarget,
31
- cardState = _ref.cardState,
32
- onAuthorize = _ref.onAuthorize,
33
- onClick = _ref.onClick,
34
- onError = _ref.onError,
35
- _ref$testId = _ref.testId,
29
+ var _ref$testId = _ref.testId,
36
30
  testId = _ref$testId === void 0 ? 'smart-block-forbidden-view' : _ref$testId,
37
- url = _ref.url,
38
- titleBlockProps = _ref.titleBlockProps;
39
- var status = cardState.status;
31
+ props = _objectWithoutProperties(_ref, _excluded);
32
+ var intl = useIntl();
33
+ var cardState = props.cardState,
34
+ onAuthorize = props.onAuthorize,
35
+ url = props.url;
40
36
  var details = cardState === null || cardState === void 0 ? void 0 : cardState.details;
41
37
  var cardMetadata = (_details$meta = details === null || details === void 0 ? void 0 : details.meta) !== null && _details$meta !== void 0 ? _details$meta : getForbiddenJsonLd().meta;
42
38
  var provider = extractProvider(details === null || details === void 0 ? void 0 : details.data);
@@ -55,44 +51,28 @@ var FlexibleForbiddenView = function FlexibleForbiddenView(_ref) {
55
51
  product: providerName
56
52
  });
57
53
  }, [cardMetadata, providerName, url]);
58
- var descriptiveMessageKey = requestAccessContext && requestAccessContext.descriptiveMessageKey ? requestAccessContext.descriptiveMessageKey : 'invalid_permissions_description';
59
- var _ref2 = requestAccessContext !== null && requestAccessContext !== void 0 ? requestAccessContext : {},
60
- titleMessageKey = _ref2.titleMessageKey,
61
- buttonDisabled = _ref2.buttonDisabled;
54
+ var title = useMemo(function () {
55
+ var descriptor = toMessage(messages.invalid_permissions, requestAccessContext === null || requestAccessContext === void 0 ? void 0 : requestAccessContext.titleMessageKey);
56
+ return intl.formatMessage(descriptor, {
57
+ product: providerName
58
+ });
59
+ }, [intl, providerName, requestAccessContext === null || requestAccessContext === void 0 ? void 0 : requestAccessContext.titleMessageKey]);
62
60
  var actions = useMemo(function () {
63
61
  var actionFromAccessContext = [];
64
62
  var tryAnotherAccountAction = onAuthorize ? [ForbiddenAction(onAuthorize, 'try_another_account')] : [];
65
63
  if (requestAccessContext) {
66
64
  var action = requestAccessContext.action,
67
65
  callToActionMessageKey = requestAccessContext.callToActionMessageKey;
68
- actionFromAccessContext = action && callToActionMessageKey ? [ForbiddenAction(action.promise, callToActionMessageKey, messageContext, buttonDisabled)] : [];
66
+ actionFromAccessContext = action && callToActionMessageKey ? [ForbiddenAction(action.promise, callToActionMessageKey, messageContext, requestAccessContext === null || requestAccessContext === void 0 ? void 0 : requestAccessContext.buttonDisabled)] : [];
69
67
  }
70
68
  return [].concat(tryAnotherAccountAction, _toConsumableArray(actionFromAccessContext));
71
- }, [onAuthorize, requestAccessContext, messageContext, buttonDisabled]);
72
- return /*#__PURE__*/React.createElement(FlexibleCard, {
73
- appearance: "block",
74
- cardState: cardState,
75
- onAuthorize: onAuthorize,
76
- onClick: onClick,
77
- onError: onError,
69
+ }, [onAuthorize, requestAccessContext, messageContext]);
70
+ return /*#__PURE__*/React.createElement(UnresolvedView, _extends({}, props, {
71
+ actions: actions,
72
+ showPreview: true,
78
73
  testId: testId,
79
- ui: {
80
- hideElevation: true,
81
- size: SmartLinkSize.Medium
82
- },
83
- url: url
84
- }, titleMessageKey ? /*#__PURE__*/React.createElement(CustomBlock, {
85
- overrideCss: forbiddenViewTitleStyle,
86
- testId: "".concat(testId, "-title")
87
- }, /*#__PURE__*/React.createElement("a", {
88
- target: anchorTarget,
89
- href: url
90
- }, /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages[titleMessageKey], {
91
- values: messageContext
92
- })))) : /*#__PURE__*/React.createElement(TitleBlock, _extends({
93
- hideRetry: true,
94
- anchorTarget: anchorTarget
95
- }, titleBlockProps)), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(LockIcon, {
74
+ title: title
75
+ }), /*#__PURE__*/React.createElement(LockIcon, {
96
76
  label: "forbidden-lock-icon",
97
77
  size: "small",
98
78
  primaryColor: "var(--ds-icon-danger, ".concat(R300, ")"),
@@ -100,15 +80,9 @@ var FlexibleForbiddenView = function FlexibleForbiddenView(_ref) {
100
80
  }), /*#__PURE__*/React.createElement(Text, {
101
81
  maxLines: 2,
102
82
  message: {
103
- descriptor: messages[descriptiveMessageKey],
83
+ descriptor: toMessage(messages.invalid_permissions_description, requestAccessContext === null || requestAccessContext === void 0 ? void 0 : requestAccessContext.descriptiveMessageKey),
104
84
  values: messageContext
105
85
  }
106
- })), /*#__PURE__*/React.createElement(PreviewBlock, {
107
- placement: MediaPlacement.Right,
108
- ignoreContainerPadding: true
109
- }), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(BlockCardFooter, {
110
- actions: actions,
111
- status: status
112
- })));
86
+ }));
113
87
  };
114
88
  export default withFlexibleUIBlockCardStyle(FlexibleForbiddenView);
@@ -1,18 +1,17 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
+ var _excluded = ["testId"];
3
5
  import React, { useMemo } from 'react';
4
- import FlexibleCard from '../../../FlexibleCard';
5
- import TitleBlock from '../../../FlexibleCard/components/blocks/title-block';
6
- import { CustomBlock } from '../../../FlexibleCard/components/blocks';
7
6
  import { R300 } from '@atlaskit/theme/colors';
8
7
  import { messages } from '../../../../messages';
9
8
  import LockIcon from '@atlaskit/icon/glyph/lock-filled';
10
- import BlockCardFooter from '../../components/flexible/footer';
11
9
  import { ForbiddenAction } from '../../actions/flexible/ForbiddenAction';
12
10
  import Text from '../../../FlexibleCard/components/elements/text';
13
11
  import { getForbiddenJsonLd } from '../../../../utils/jsonld';
14
12
  import { extractProvider } from '@atlaskit/link-extractors';
15
13
  import { extractRequestAccessContext } from '../../../../extractors/common/context';
14
+ import UnresolvedView from './unresolved-view';
16
15
  import { withFlexibleUIBlockCardStyle } from './utils/withFlexibleUIBlockCardStyle';
17
16
 
18
17
  /**
@@ -22,16 +21,12 @@ import { withFlexibleUIBlockCardStyle } from './utils/withFlexibleUIBlockCardSty
22
21
  */
23
22
  var FlexibleForbiddenView = function FlexibleForbiddenView(_ref) {
24
23
  var _details$meta;
25
- var anchorTarget = _ref.anchorTarget,
26
- cardState = _ref.cardState,
27
- onAuthorize = _ref.onAuthorize,
28
- onClick = _ref.onClick,
29
- onError = _ref.onError,
30
- _ref$testId = _ref.testId,
24
+ var _ref$testId = _ref.testId,
31
25
  testId = _ref$testId === void 0 ? 'smart-block-forbidden-view' : _ref$testId,
32
- url = _ref.url,
33
- titleBlockProps = _ref.titleBlockProps;
34
- var status = cardState.status;
26
+ props = _objectWithoutProperties(_ref, _excluded);
27
+ var cardState = props.cardState,
28
+ onAuthorize = props.onAuthorize,
29
+ url = props.url;
35
30
  var details = cardState === null || cardState === void 0 ? void 0 : cardState.details;
36
31
  var cardMetadata = (_details$meta = details === null || details === void 0 ? void 0 : details.meta) !== null && _details$meta !== void 0 ? _details$meta : getForbiddenJsonLd().meta;
37
32
  var provider = extractProvider(details === null || details === void 0 ? void 0 : details.data);
@@ -54,21 +49,10 @@ var FlexibleForbiddenView = function FlexibleForbiddenView(_ref) {
54
49
  }
55
50
  return [].concat(tryAnotherAccountAction, _toConsumableArray(actionFromAccessContext));
56
51
  }, [onAuthorize, requestAccessContext, providerName]);
57
- return /*#__PURE__*/React.createElement(FlexibleCard, {
58
- appearance: "block",
59
- cardState: cardState,
60
- onAuthorize: onAuthorize,
61
- onClick: onClick,
62
- onError: onError,
63
- testId: testId,
64
- ui: {
65
- hideElevation: true
66
- },
67
- url: url
68
- }, /*#__PURE__*/React.createElement(TitleBlock, _extends({
69
- hideRetry: true,
70
- anchorTarget: anchorTarget
71
- }, titleBlockProps)), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(LockIcon, {
52
+ return /*#__PURE__*/React.createElement(UnresolvedView, _extends({}, props, {
53
+ actions: actions,
54
+ testId: testId
55
+ }), /*#__PURE__*/React.createElement(LockIcon, {
72
56
  label: "forbidden-lock-icon",
73
57
  size: "small",
74
58
  primaryColor: "var(--ds-icon-danger, ".concat(R300, ")"),
@@ -80,10 +64,7 @@ var FlexibleForbiddenView = function FlexibleForbiddenView(_ref) {
80
64
  context: providerName
81
65
  }
82
66
  }
83
- })), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(BlockCardFooter, {
84
- actions: actions,
85
- status: status
86
- })));
67
+ }));
87
68
  };
88
69
 
89
70
  /**
@@ -1,13 +1,12 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["testId"];
2
4
  import React from 'react';
3
- import FlexibleCard from '../../../FlexibleCard';
4
- import TitleBlock from '../../../FlexibleCard/components/blocks/title-block';
5
5
  import { messages } from '../../../../messages';
6
6
  import WarningIcon from '@atlaskit/icon/glyph/warning';
7
7
  import { R300 } from '@atlaskit/theme/colors';
8
- import BlockCardFooter from '../../components/flexible/footer';
9
8
  import Text from '../../../FlexibleCard/components/elements/text';
10
- import { CustomBlock } from '../../../FlexibleCard/components/blocks';
9
+ import UnresolvedView from './unresolved-view';
11
10
  import { withFlexibleUIBlockCardStyle } from './utils/withFlexibleUIBlockCardStyle';
12
11
 
13
12
  /**
@@ -17,31 +16,12 @@ import { withFlexibleUIBlockCardStyle } from './utils/withFlexibleUIBlockCardSty
17
16
  * @see FlexibleCardProps
18
17
  */
19
18
  var FlexibleNotFoundView = function FlexibleNotFoundView(_ref) {
20
- var anchorTarget = _ref.anchorTarget,
21
- cardState = _ref.cardState,
22
- onAuthorize = _ref.onAuthorize,
23
- onError = _ref.onError,
24
- url = _ref.url,
25
- onClick = _ref.onClick,
26
- _ref$testId = _ref.testId,
19
+ var _ref$testId = _ref.testId,
27
20
  testId = _ref$testId === void 0 ? 'smart-block-not-found-view' : _ref$testId,
28
- titleBlockProps = _ref.titleBlockProps;
29
- var status = cardState.status;
30
- return /*#__PURE__*/React.createElement(FlexibleCard, {
31
- appearance: "block",
32
- cardState: cardState,
33
- onAuthorize: onAuthorize,
34
- onClick: onClick,
35
- onError: onError,
36
- testId: testId,
37
- ui: {
38
- hideElevation: true
39
- },
40
- url: url
41
- }, /*#__PURE__*/React.createElement(TitleBlock, _extends({
42
- hideRetry: true,
43
- anchorTarget: anchorTarget
44
- }, titleBlockProps)), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(WarningIcon, {
21
+ props = _objectWithoutProperties(_ref, _excluded);
22
+ return /*#__PURE__*/React.createElement(UnresolvedView, _extends({}, props, {
23
+ testId: testId
24
+ }), /*#__PURE__*/React.createElement(WarningIcon, {
45
25
  label: "not-found-warning-icon",
46
26
  size: "small",
47
27
  primaryColor: "var(--ds-icon-warning, ".concat(R300, ")"),
@@ -51,8 +31,6 @@ var FlexibleNotFoundView = function FlexibleNotFoundView(_ref) {
51
31
  descriptor: messages.not_found_description
52
32
  },
53
33
  testId: "".concat(testId, "-message")
54
- })), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(BlockCardFooter, {
55
- status: status
56
- })));
34
+ }));
57
35
  };
58
36
  export default withFlexibleUIBlockCardStyle(FlexibleNotFoundView);
@@ -3,9 +3,9 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import React, { useEffect, useMemo, useState } from 'react';
4
4
  import FlexibleCard from '../../../FlexibleCard';
5
5
  import { FooterBlock, MetadataBlock, PreviewBlock, SnippetBlock, TitleBlock } from '../../../FlexibleCard/components/blocks';
6
- import { metadataBlockCss, footerBlockCss } from './styled';
7
- import { ActionName, ElementName, MediaPlacement, SmartLinkPosition } from '../../../../constants';
8
- import { getSimulatedMetadata, getSimulatedBetterMetadata } from './utils';
6
+ import { metadataBlockCss } from './styled';
7
+ import { ActionName, ElementName, SmartLinkPosition } from '../../../../constants';
8
+ import { getSimulatedMetadata, getSimulatedBetterMetadata, getTitleBlockOptions, getFooterBlockOptions, PreviewBlockOptions, FlexibleCardUiOptions } from './utils';
9
9
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
10
10
  import { withFlexibleUIBlockCardStyle } from './utils/withFlexibleUIBlockCardStyle';
11
11
  /**
@@ -19,12 +19,10 @@ var FlexibleResolvedView = function FlexibleResolvedView(_ref) {
19
19
  onError = _ref.onError,
20
20
  onResolve = _ref.onResolve,
21
21
  showServerActions = _ref.showServerActions,
22
- anchorTarget = _ref.anchorTarget,
23
22
  _ref$testId = _ref.testId,
24
23
  testId = _ref$testId === void 0 ? 'smart-block-resolved-view' : _ref$testId,
25
24
  url = _ref.url,
26
- analytics = _ref.analytics,
27
- titleBlockProps = _ref.titleBlockProps;
25
+ analytics = _ref.analytics;
28
26
  var _useState = useState(false),
29
27
  _useState2 = _slicedToArray(_useState, 2),
30
28
  isPreviewBlockErrored = _useState2[0],
@@ -60,20 +58,15 @@ var FlexibleResolvedView = function FlexibleResolvedView(_ref) {
60
58
  onResolve: onResolve,
61
59
  showServerActions: showServerActions,
62
60
  testId: testId,
63
- ui: {
64
- hideElevation: true
65
- },
61
+ ui: FlexibleCardUiOptions,
66
62
  url: url
67
- }, /*#__PURE__*/React.createElement(TitleBlock, _extends({
68
- position: SmartLinkPosition.Center,
63
+ }, /*#__PURE__*/React.createElement(TitleBlock, _extends({}, getTitleBlockOptions(), {
69
64
  metadata: titleMetadata,
70
- hideRetry: true,
71
65
  subtitle: [{
72
66
  name: ElementName.Location
73
67
  }],
74
- metadataPosition: SmartLinkPosition.Top,
75
- anchorTarget: anchorTarget
76
- }, titleBlockProps)), /*#__PURE__*/React.createElement(MetadataBlock, _extends({
68
+ metadataPosition: SmartLinkPosition.Top
69
+ })), /*#__PURE__*/React.createElement(MetadataBlock, _extends({
77
70
  primary: topMetadata,
78
71
  maxLines: 1
79
72
  }, getBooleanFF('platform.linking-platform.smart-card.enable-better-metadata_iojwg') && {
@@ -82,15 +75,11 @@ var FlexibleResolvedView = function FlexibleResolvedView(_ref) {
82
75
  primary: bottomMetadata,
83
76
  maxLines: 1,
84
77
  overrideCss: metadataBlockCss
85
- }), !isPreviewBlockErrored ? /*#__PURE__*/React.createElement(PreviewBlock, {
86
- placement: MediaPlacement.Right,
87
- ignoreContainerPadding: true,
78
+ }), !isPreviewBlockErrored ? /*#__PURE__*/React.createElement(PreviewBlock, _extends({}, PreviewBlockOptions, {
88
79
  onError: function onError() {
89
80
  setIsPreviewBlockErrored(true);
90
81
  }
91
- }) : null, /*#__PURE__*/React.createElement(FooterBlock, _extends({}, getBooleanFF('platform.linking-platform.smart-card.enable-better-metadata_iojwg') && {
92
- overrideCss: footerBlockCss
93
- }, {
82
+ })) : null, /*#__PURE__*/React.createElement(FooterBlock, _extends({}, getFooterBlockOptions(), {
94
83
  actions: footerActions
95
84
  })));
96
85
  };
@@ -1,20 +1,20 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
2
3
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
4
+ var _excluded = ["testId"];
3
5
  var _templateObject;
4
- import React, { useCallback, useMemo } from 'react';
6
+ /** @jsx jsx */
7
+ import { css, jsx } from '@emotion/react';
8
+ import { useCallback, useMemo } from 'react';
5
9
  import { FormattedMessage } from 'react-intl-next';
6
- import FlexibleCard from '../../../FlexibleCard';
10
+ import { getExtensionKey } from '../../../../state/helpers';
7
11
  import { AuthorizeAction } from '../../actions/flexible/AuthorizeAction';
8
- import BlockCardFooter from '../../components/flexible/footer';
9
- import { CustomBlock, TitleBlock } from '../../../FlexibleCard/components/blocks';
10
- import { SmartLinkStatus } from '../../../../constants';
11
12
  import { extractProvider } from '@atlaskit/link-extractors';
12
13
  import UnauthorisedViewContent from '../../../common/UnauthorisedViewContent';
13
- import { css } from '@emotion/react';
14
- import { tokens } from '../../../../utils/token';
15
14
  import { messages } from '../../../../messages';
15
+ import UnresolvedView from './unresolved-view';
16
16
  import { withFlexibleUIBlockCardStyle } from './utils/withFlexibleUIBlockCardStyle';
17
- var contentStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n margin-top: 0.5rem;\n font-size: 0.75rem;\n"])), tokens.text);
17
+ var contentStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n margin-top: 0.5rem;\n font-size: 0.75rem;\n"])), "var(--ds-text-subtlest, #626F86)");
18
18
 
19
19
  /**
20
20
  * This view represents a Block card that has an 'Unauthorized' status .
@@ -24,35 +24,30 @@ var contentStyles = css(_templateObject || (_templateObject = _taggedTemplateLit
24
24
  * @see FlexibleCardProps
25
25
  */
26
26
  var FlexibleUnauthorisedView = function FlexibleUnauthorisedView(_ref) {
27
- var _cardState$details, _extractProvider;
28
- var anchorTarget = _ref.anchorTarget,
29
- analytics = _ref.analytics,
30
- cardState = _ref.cardState,
31
- _ref$extensionKey = _ref.extensionKey,
32
- extensionKey = _ref$extensionKey === void 0 ? '' : _ref$extensionKey,
33
- onAuthorize = _ref.onAuthorize,
34
- onClick = _ref.onClick,
35
- onError = _ref.onError,
36
- _ref$testId = _ref.testId,
27
+ var _getExtensionKey, _cardState$details, _extractProvider;
28
+ var _ref$testId = _ref.testId,
37
29
  testId = _ref$testId === void 0 ? 'smart-block-unauthorized-view' : _ref$testId,
38
- url = _ref.url,
39
- titleBlockProps = _ref.titleBlockProps;
30
+ props = _objectWithoutProperties(_ref, _excluded);
31
+ var analytics = props.analytics,
32
+ cardState = props.cardState,
33
+ onAuthorize = props.onAuthorize;
34
+ var extensionKey = (_getExtensionKey = getExtensionKey(cardState === null || cardState === void 0 ? void 0 : cardState.details)) !== null && _getExtensionKey !== void 0 ? _getExtensionKey : '';
40
35
  var data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
41
36
  var providerName = (_extractProvider = extractProvider(data)) === null || _extractProvider === void 0 ? void 0 : _extractProvider.text;
42
37
  var handleAuthorize = useCallback(function () {
43
38
  if (onAuthorize) {
44
- analytics.track.appAccountAuthStarted({
39
+ analytics === null || analytics === void 0 || analytics.track.appAccountAuthStarted({
45
40
  extensionKey: extensionKey
46
41
  });
47
42
  onAuthorize();
48
43
  }
49
- }, [onAuthorize, extensionKey, analytics.track]);
44
+ }, [onAuthorize, extensionKey, analytics === null || analytics === void 0 ? void 0 : analytics.track]);
50
45
  var content = useMemo(function () {
51
- return onAuthorize ? /*#__PURE__*/React.createElement(UnauthorisedViewContent, {
46
+ return onAuthorize ? jsx(UnauthorisedViewContent, {
52
47
  providerName: providerName,
53
48
  analytics: analytics,
54
49
  testId: testId
55
- }) : /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages[providerName ? 'unauthorised_account_description' : 'unauthorised_account_description_no_provider'], {
50
+ }) : jsx(FormattedMessage, _extends({}, messages[providerName ? 'unauthorised_account_description' : 'unauthorised_account_description_no_provider'], {
56
51
  values: {
57
52
  context: providerName
58
53
  }
@@ -61,27 +56,12 @@ var FlexibleUnauthorisedView = function FlexibleUnauthorisedView(_ref) {
61
56
  var actions = useMemo(function () {
62
57
  return onAuthorize ? [AuthorizeAction(handleAuthorize, providerName)] : [];
63
58
  }, [handleAuthorize, onAuthorize, providerName]);
64
- return /*#__PURE__*/React.createElement(FlexibleCard, {
65
- appearance: "block",
66
- cardState: cardState,
67
- onAuthorize: onAuthorize,
68
- onClick: onClick,
69
- onError: onError,
70
- testId: testId,
71
- ui: {
72
- hideElevation: true
73
- },
74
- url: url
75
- }, /*#__PURE__*/React.createElement(TitleBlock, _extends({
76
- hideRetry: true,
77
- anchorTarget: anchorTarget
78
- }, titleBlockProps)), /*#__PURE__*/React.createElement(CustomBlock, {
79
- overrideCss: contentStyles,
80
- testId: "".concat(testId, "-content")
81
- }, /*#__PURE__*/React.createElement("div", null, content)), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(BlockCardFooter, {
59
+ return jsx(UnresolvedView, _extends({}, props, {
82
60
  actions: actions,
83
- status: SmartLinkStatus.Unauthorized,
84
- actionGroupAppearance: "primary"
85
- })));
61
+ testId: testId
62
+ }), jsx("div", {
63
+ css: contentStyles,
64
+ "data-testid": "".concat(testId, "-content")
65
+ }, content));
86
66
  };
87
67
  export default withFlexibleUIBlockCardStyle(FlexibleUnauthorisedView);
@@ -1,15 +1,15 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
2
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
3
3
  import { tokens } from '../../../../utils/token';
4
4
  import { css } from '@emotion/react';
5
5
  import { N40 } from '@atlaskit/theme/colors';
6
6
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
7
7
 
8
8
  // in editor prosemirror adds padding-left so we need to overwrite it
9
- export var metadataBlockCss = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n /* primary element group */\n span[data-smart-element-avatar-group] {\n > ul {\n padding-left: 0px;\n }\n }\n [data-smart-element-group] {\n line-height: 1rem;\n }\n"])));
9
+ // renderer overwrites the margin-right so we need to add it here
10
+ export var metadataBlockCss = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n /* primary element group */\n span[data-smart-element-avatar-group] {\n > ul {\n padding-left: 0px;\n margin-right: 0.5rem;\n }\n }\n [data-smart-element-group] {\n line-height: 1rem;\n }\n"])));
10
11
  export var titleBlockCss = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n ", "\n ", "\n"])), getBooleanFF('platform.linking-platform.smart-card.enable-better-metadata_iojwg') ? "gap: 0.5em;" : "", getBooleanFF('platform.linking-platform.smart-card.show-smart-links-refreshed-design') ? "[data-smart-element=\"Title\"] {\n font-weight: 600;\n }" : "");
11
12
  export var footerBlockCss = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n height: 1.5rem;\n\n .actions-button-group {\n button,\n button:hover,\n button:focus,\n button:active {\n font-size: 0.875rem;\n }\n }\n"])));
12
13
  var flexibleBlockCardElevationStyle = css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n border-radius: 1.5px;\n box-shadow: ", ";\n margin: ", ";\n"])), tokens.elevation, "var(--ds-space-025, 2px)");
13
14
  var refreshedFlexibleBlockCardStyle = css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n & > div {\n border-radius: ", ";\n border: 1px solid ", ";\n }\n"])), "var(--ds-border-radius-200, 8px)", "var(--ds-border, ".concat(N40, ")"));
14
- export var flexibleBlockCardStyle = getBooleanFF('platform.linking-platform.smart-card.show-smart-links-refreshed-design') ? refreshedFlexibleBlockCardStyle : flexibleBlockCardElevationStyle;
15
- export var forbiddenViewTitleStyle = css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n font-weight: 600;\n"])));
15
+ export var flexibleBlockCardStyle = getBooleanFF('platform.linking-platform.smart-card.show-smart-links-refreshed-design') ? refreshedFlexibleBlockCardStyle : flexibleBlockCardElevationStyle;
@@ -0,0 +1,35 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import { CustomBlock, PreviewBlock, TitleBlock } from '../../../../FlexibleCard/components/blocks';
3
+ import React from 'react';
4
+ import FlexibleCard from '../../../../FlexibleCard';
5
+ import { InternalFooterBlock } from '../../../../FlexibleCard/components/blocks';
6
+ import { FlexibleCardUiOptions, getFooterBlockOptions, PreviewBlockOptions, getTitleBlockOptions } from '../utils';
7
+ var UnresolvedView = function UnresolvedView(_ref) {
8
+ var actions = _ref.actions,
9
+ cardState = _ref.cardState,
10
+ children = _ref.children,
11
+ onAuthorize = _ref.onAuthorize,
12
+ onClick = _ref.onClick,
13
+ onError = _ref.onError,
14
+ _ref$showPreview = _ref.showPreview,
15
+ showPreview = _ref$showPreview === void 0 ? false : _ref$showPreview,
16
+ testId = _ref.testId,
17
+ title = _ref.title,
18
+ url = _ref.url;
19
+ return /*#__PURE__*/React.createElement(FlexibleCard, {
20
+ appearance: "block",
21
+ cardState: cardState,
22
+ onAuthorize: onAuthorize,
23
+ onClick: onClick,
24
+ onError: onError,
25
+ testId: testId,
26
+ ui: FlexibleCardUiOptions,
27
+ url: url
28
+ }, /*#__PURE__*/React.createElement(TitleBlock, _extends({}, getTitleBlockOptions(), {
29
+ text: title
30
+ })), /*#__PURE__*/React.createElement(CustomBlock, null, children), showPreview && /*#__PURE__*/React.createElement(PreviewBlock, PreviewBlockOptions), /*#__PURE__*/React.createElement(InternalFooterBlock, _extends({}, getFooterBlockOptions(), {
31
+ actions: actions,
32
+ testId: "smart-block-card-footer"
33
+ })));
34
+ };
35
+ export default UnresolvedView;