@atlaskit/smart-card 26.38.0 → 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 (76) hide show
  1. package/CHANGELOG.md +7 -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/LinkUrl/index.js +1 -1
  18. package/dist/es2019/utils/analytics/analytics.js +1 -1
  19. package/dist/es2019/view/BlockCard/actions/flexible/AuthorizeAction.js +1 -0
  20. package/dist/es2019/view/BlockCard/index.js +1 -15
  21. package/dist/es2019/view/BlockCard/views/flexible/FlexibleErroredView.js +8 -32
  22. package/dist/es2019/view/BlockCard/views/flexible/FlexibleForbiddenView.js +25 -52
  23. package/dist/es2019/view/BlockCard/views/flexible/FlexibleForbiddenViewOld.js +12 -31
  24. package/dist/es2019/view/BlockCard/views/flexible/FlexibleNotFoundView.js +15 -41
  25. package/dist/es2019/view/BlockCard/views/flexible/FlexibleResolvedView.js +10 -21
  26. package/dist/es2019/view/BlockCard/views/flexible/FlexibleUnauthorisedView.js +24 -43
  27. package/dist/es2019/view/BlockCard/views/flexible/styled.js +3 -4
  28. package/dist/es2019/view/BlockCard/views/flexible/unresolved-view/index.js +33 -0
  29. package/dist/es2019/view/BlockCard/views/flexible/utils/index.js +27 -2
  30. package/dist/es2019/view/FlexibleCard/components/blocks/footer-block/index.js +11 -54
  31. package/dist/es2019/view/FlexibleCard/components/blocks/footer-block/resolved/index.js +56 -0
  32. package/dist/es2019/view/FlexibleCard/components/blocks/index.js +4 -1
  33. package/dist/es2019/view/LinkUrl/index.js +1 -1
  34. package/dist/esm/utils/analytics/analytics.js +1 -1
  35. package/dist/esm/view/BlockCard/actions/flexible/AuthorizeAction.js +1 -0
  36. package/dist/esm/view/BlockCard/index.js +3 -18
  37. package/dist/esm/view/BlockCard/views/flexible/FlexibleErroredView.js +12 -34
  38. package/dist/esm/view/BlockCard/views/flexible/FlexibleForbiddenView.js +26 -52
  39. package/dist/esm/view/BlockCard/views/flexible/FlexibleForbiddenViewOld.js +13 -32
  40. package/dist/esm/view/BlockCard/views/flexible/FlexibleNotFoundView.js +9 -31
  41. package/dist/esm/view/BlockCard/views/flexible/FlexibleResolvedView.js +10 -21
  42. package/dist/esm/view/BlockCard/views/flexible/FlexibleUnauthorisedView.js +25 -45
  43. package/dist/esm/view/BlockCard/views/flexible/styled.js +4 -4
  44. package/dist/esm/view/BlockCard/views/flexible/unresolved-view/index.js +35 -0
  45. package/dist/esm/view/BlockCard/views/flexible/utils/index.js +30 -1
  46. package/dist/esm/view/FlexibleCard/components/blocks/footer-block/index.js +13 -54
  47. package/dist/esm/view/FlexibleCard/components/blocks/footer-block/resolved/index.js +55 -0
  48. package/dist/esm/view/FlexibleCard/components/blocks/index.js +4 -1
  49. package/dist/esm/view/LinkUrl/index.js +1 -1
  50. package/dist/types/view/BlockCard/views/flexible/FlexibleUnauthorisedView.d.ts +3 -1
  51. package/dist/types/view/BlockCard/views/flexible/styled.d.ts +0 -1
  52. package/dist/types/view/BlockCard/views/flexible/types.d.ts +2 -83
  53. package/dist/types/view/BlockCard/views/flexible/unresolved-view/index.d.ts +4 -0
  54. package/dist/types/view/BlockCard/views/flexible/unresolved-view/types.d.ts +7 -0
  55. package/dist/types/view/BlockCard/views/flexible/utils/index.d.ts +8 -0
  56. package/dist/types/view/FlexibleCard/components/blocks/footer-block/resolved/index.d.ts +4 -0
  57. package/dist/types/view/FlexibleCard/components/blocks/index.d.ts +1 -0
  58. package/dist/types-ts4.5/view/BlockCard/views/flexible/FlexibleUnauthorisedView.d.ts +3 -1
  59. package/dist/types-ts4.5/view/BlockCard/views/flexible/styled.d.ts +0 -1
  60. package/dist/types-ts4.5/view/BlockCard/views/flexible/types.d.ts +2 -83
  61. package/dist/types-ts4.5/view/BlockCard/views/flexible/unresolved-view/index.d.ts +4 -0
  62. package/dist/types-ts4.5/view/BlockCard/views/flexible/unresolved-view/types.d.ts +7 -0
  63. package/dist/types-ts4.5/view/BlockCard/views/flexible/utils/index.d.ts +8 -0
  64. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/footer-block/resolved/index.d.ts +4 -0
  65. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/index.d.ts +1 -0
  66. package/package.json +1 -1
  67. package/dist/cjs/view/BlockCard/components/flexible/footer/index.js +0 -56
  68. package/dist/es2019/view/BlockCard/components/flexible/footer/index.js +0 -52
  69. package/dist/esm/view/BlockCard/components/flexible/footer/index.js +0 -49
  70. package/dist/types/view/BlockCard/components/flexible/footer/index.d.ts +0 -12
  71. package/dist/types/view/BlockCard/components/flexible/footer/types.d.ts +0 -5
  72. package/dist/types-ts4.5/view/BlockCard/components/flexible/footer/index.d.ts +0 -12
  73. package/dist/types-ts4.5/view/BlockCard/components/flexible/footer/types.d.ts +0 -5
  74. /package/dist/cjs/view/BlockCard/{components/flexible/footer → views/flexible/unresolved-view}/types.js +0 -0
  75. /package/dist/es2019/view/BlockCard/{components/flexible/footer → views/flexible/unresolved-view}/types.js +0 -0
  76. /package/dist/esm/view/BlockCard/{components/flexible/footer → views/flexible/unresolved-view}/types.js +0 -0
@@ -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;
@@ -1,6 +1,8 @@
1
- import { ElementName } from '../../../../../constants';
1
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
2
+ import { ElementName, MediaPlacement, SmartLinkPosition, SmartLinkSize } from '../../../../../constants';
2
3
  import { extractOwnedBy } from '../../../../../extractors/flexible/utils';
3
4
  import { getExtensionKey } from '../../../../../state/helpers';
5
+ import { footerBlockCss, titleBlockCss } from '../styled';
4
6
  var baseTopMetadata = [{
5
7
  name: ElementName.ModifiedOn
6
8
  }, {
@@ -134,4 +136,31 @@ export var getSimulatedMetadata = function getSimulatedMetadata(cardDetails) {
134
136
  titleMetadata: titleMetadata,
135
137
  topMetadata: topMetadata
136
138
  };
139
+ };
140
+ export var FlexibleCardUiOptions = {
141
+ hideElevation: true
142
+ };
143
+
144
+ // Due to the use of getBooleanFF(), this has to be a function.
145
+ // Make this a const object after ff cleanup.
146
+ export var getTitleBlockOptions = function getTitleBlockOptions() {
147
+ return {
148
+ anchorTarget: getBooleanFF('platform.linking-platform.smart-card.enable-block-card-clicks-opening-in-same-tab') ? '_self' : undefined,
149
+ position: SmartLinkPosition.Center,
150
+ overrideCss: titleBlockCss,
151
+ hideRetry: true,
152
+ size: getBooleanFF('platform.linking-platform.smart-card.enable-better-metadata_iojwg') ? SmartLinkSize.Large : undefined
153
+ };
154
+ };
155
+ export var PreviewBlockOptions = {
156
+ placement: MediaPlacement.Right,
157
+ ignoreContainerPadding: true
158
+ };
159
+
160
+ // Due to the use of getBooleanFF(), this has to be a function.
161
+ // Make this a const object after ff cleanup.
162
+ export var getFooterBlockOptions = function getFooterBlockOptions() {
163
+ return {
164
+ overrideCss: getBooleanFF('platform.linking-platform.smart-card.enable-better-metadata_iojwg') ? footerBlockCss : undefined
165
+ };
137
166
  };
@@ -1,23 +1,9 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
3
- var _templateObject;
4
- import React, { useCallback, useMemo } from 'react';
5
- import { css } from '@emotion/react';
6
- import { SmartLinkAlignment, SmartLinkDirection, SmartLinkSize, SmartLinkStatus, SmartLinkWidth } from '../../../../../constants';
7
- import Block from '../block';
8
- import ElementGroup from '../element-group';
9
- import { Provider } from '../../elements';
10
- import ActionGroup from '../action-group';
11
- import { filterActionItems } from '../utils';
12
- import { useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
13
- var getActionGroupStyles = function getActionGroupStyles(size) {
14
- if (size === SmartLinkSize.XLarge) {
15
- // The biggest height of the action button exceeds the max line-height
16
- // of the elements causing the action on the block with x-large size to
17
- // get cut at the bottom.
18
- return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n max-height: 2rem;\n "])));
19
- }
20
- };
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["status", "testId"];
4
+ import React from 'react';
5
+ import FooterBlockResolvedView from './resolved';
6
+ import { SmartLinkStatus } from '../../../../../constants';
21
7
 
22
8
  /**
23
9
  * Represents a FooterBlock, designed to contain elements and actions that should appear
@@ -26,43 +12,16 @@ var getActionGroupStyles = function getActionGroupStyles(size) {
26
12
  * @param {FooterBlockProps} FooterBlockProps
27
13
  * @see Block
28
14
  */
29
- var FooterBlock = function FooterBlock(props) {
30
- var status = props.status,
31
- actions = props.actions,
32
- _props$size = props.size,
33
- size = _props$size === void 0 ? SmartLinkSize.Medium : _props$size,
34
- _props$testId = props.testId,
35
- testId = _props$testId === void 0 ? 'smart-footer-block' : _props$testId,
36
- onActionMenuOpenChange = props.onActionMenuOpenChange;
37
- var context = useFlexibleUiContext();
38
- var hasActions = useMemo(function () {
39
- var _filterActionItems;
40
- return ((_filterActionItems = filterActionItems(actions, context)) === null || _filterActionItems === void 0 ? void 0 : _filterActionItems.length) > 0;
41
- }, [actions, context]);
42
- var onDropdownOpenChange = useCallback(function (isOpen) {
43
- if (onActionMenuOpenChange) {
44
- onActionMenuOpenChange({
45
- isOpen: isOpen
46
- });
47
- }
48
- }, [onActionMenuOpenChange]);
15
+ var FooterBlock = function FooterBlock(_ref) {
16
+ var status = _ref.status,
17
+ _ref$testId = _ref.testId,
18
+ testId = _ref$testId === void 0 ? 'smart-footer-block' : _ref$testId,
19
+ props = _objectWithoutProperties(_ref, _excluded);
49
20
  if (status !== SmartLinkStatus.Resolved) {
50
21
  return null;
51
22
  }
52
- return /*#__PURE__*/React.createElement(Block, _extends({}, props, {
53
- testId: "".concat(testId, "-resolved-view")
54
- }), /*#__PURE__*/React.createElement(Provider, {
55
- testId: "".concat(testId, "-provider")
56
- }), actions && hasActions ? /*#__PURE__*/React.createElement(ElementGroup, {
57
- testId: "smart-element-group-actions",
58
- align: SmartLinkAlignment.Right,
59
- direction: SmartLinkDirection.Horizontal,
60
- overrideCss: getActionGroupStyles(size),
61
- width: SmartLinkWidth.Flexible
62
- }, /*#__PURE__*/React.createElement(ActionGroup, {
63
- onDropdownOpenChange: onDropdownOpenChange,
64
- items: actions,
65
- appearance: "default"
66
- })) : null);
23
+ return /*#__PURE__*/React.createElement(FooterBlockResolvedView, _extends({}, props, {
24
+ testId: testId
25
+ }));
67
26
  };
68
27
  export default FooterBlock;