@atlaskit/smart-card 26.50.15 → 26.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/cjs/extractors/common/context/extractAccessContext.js +28 -67
  3. package/dist/cjs/extractors/common/context/index.js +2 -2
  4. package/dist/cjs/extractors/flexible/actions/index.js +5 -2
  5. package/dist/cjs/extractors/flexible/index.js +1 -5
  6. package/dist/cjs/utils/analytics/analytics.js +1 -1
  7. package/dist/cjs/view/BlockCard/index.js +7 -3
  8. package/dist/cjs/view/BlockCard/views/ForbiddenView.js +3 -2
  9. package/dist/cjs/view/BlockCard/views/flexible/FlexibleNotFoundView.js +0 -1
  10. package/dist/cjs/view/FlexibleCard/components/actions/download-action/index.js +76 -0
  11. package/dist/cjs/view/FlexibleCard/components/actions/follow-action/index.js +8 -9
  12. package/dist/cjs/view/FlexibleCard/components/actions/follow-action/types.js +5 -0
  13. package/dist/cjs/view/FlexibleCard/components/actions/index.js +9 -8
  14. package/dist/cjs/view/FlexibleCard/components/actions/utils.js +0 -13
  15. package/dist/cjs/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +41 -26
  16. package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +0 -8
  17. package/dist/cjs/view/FlexibleCard/components/elements/snippet-element/index.js +7 -3
  18. package/dist/cjs/view/FlexibleCard/utils.js +4 -4
  19. package/dist/cjs/view/HoverCard/components/ContentContainer.js +1 -0
  20. package/dist/cjs/view/HoverCard/components/views/resolved/index.js +1 -0
  21. package/dist/cjs/view/LinkUrl/index.js +1 -1
  22. package/dist/cjs/view/common/ai-summary/index.js +5 -1
  23. package/dist/es2019/extractors/common/context/extractAccessContext.js +26 -68
  24. package/dist/es2019/extractors/common/context/index.js +1 -1
  25. package/dist/es2019/extractors/flexible/actions/index.js +6 -2
  26. package/dist/es2019/extractors/flexible/index.js +1 -5
  27. package/dist/es2019/utils/analytics/analytics.js +1 -1
  28. package/dist/es2019/view/BlockCard/index.js +9 -4
  29. package/dist/es2019/view/BlockCard/views/ForbiddenView.js +3 -2
  30. package/dist/es2019/view/BlockCard/views/flexible/FlexibleNotFoundView.js +0 -1
  31. package/dist/es2019/view/FlexibleCard/components/actions/download-action/index.js +47 -0
  32. package/dist/es2019/view/FlexibleCard/components/actions/follow-action/index.js +7 -5
  33. package/dist/es2019/view/FlexibleCard/components/actions/index.js +1 -7
  34. package/dist/es2019/view/FlexibleCard/components/actions/utils.js +0 -14
  35. package/dist/es2019/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +43 -22
  36. package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +0 -8
  37. package/dist/es2019/view/FlexibleCard/components/elements/snippet-element/index.js +7 -4
  38. package/dist/es2019/view/FlexibleCard/utils.js +5 -5
  39. package/dist/es2019/view/HoverCard/components/ContentContainer.js +1 -0
  40. package/dist/es2019/view/HoverCard/components/views/resolved/index.js +1 -0
  41. package/dist/es2019/view/LinkUrl/index.js +1 -1
  42. package/dist/es2019/view/common/ai-summary/index.js +5 -1
  43. package/dist/esm/extractors/common/context/extractAccessContext.js +27 -66
  44. package/dist/esm/extractors/common/context/index.js +1 -1
  45. package/dist/esm/extractors/flexible/actions/index.js +5 -2
  46. package/dist/esm/extractors/flexible/index.js +1 -5
  47. package/dist/esm/utils/analytics/analytics.js +1 -1
  48. package/dist/esm/view/BlockCard/index.js +8 -4
  49. package/dist/esm/view/BlockCard/views/ForbiddenView.js +3 -2
  50. package/dist/esm/view/BlockCard/views/flexible/FlexibleNotFoundView.js +0 -1
  51. package/dist/esm/view/FlexibleCard/components/actions/download-action/index.js +66 -0
  52. package/dist/esm/view/FlexibleCard/components/actions/download-action/types.js +1 -0
  53. package/dist/esm/view/FlexibleCard/components/actions/follow-action/index.js +9 -7
  54. package/dist/esm/view/FlexibleCard/components/actions/follow-action/types.js +1 -0
  55. package/dist/esm/view/FlexibleCard/components/actions/index.js +1 -7
  56. package/dist/esm/view/FlexibleCard/components/actions/utils.js +0 -13
  57. package/dist/esm/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +41 -26
  58. package/dist/esm/view/FlexibleCard/components/blocks/utils.js +0 -8
  59. package/dist/esm/view/FlexibleCard/components/elements/snippet-element/index.js +7 -3
  60. package/dist/esm/view/FlexibleCard/utils.js +5 -5
  61. package/dist/esm/view/HoverCard/components/ContentContainer.js +1 -0
  62. package/dist/esm/view/HoverCard/components/views/resolved/index.js +1 -0
  63. package/dist/esm/view/LinkUrl/index.js +1 -1
  64. package/dist/esm/view/common/ai-summary/index.js +5 -1
  65. package/dist/types/__fixtures__/dropbox-file.d.ts +3 -0
  66. package/dist/types/extractors/common/context/extractAccessContext.d.ts +1 -6
  67. package/dist/types/extractors/common/context/index.d.ts +1 -1
  68. package/dist/types/extractors/flexible/actions/index.d.ts +1 -1
  69. package/dist/types/state/flexible-ui-context/types.d.ts +2 -12
  70. package/dist/types/view/FlexibleCard/components/actions/download-action/index.d.ts +4 -0
  71. package/dist/types/view/FlexibleCard/components/actions/download-action/types.d.ts +2 -0
  72. package/dist/types/view/FlexibleCard/components/actions/follow-action/index.d.ts +2 -2
  73. package/dist/types/view/FlexibleCard/components/actions/follow-action/types.d.ts +2 -0
  74. package/dist/types/view/FlexibleCard/components/actions/index.d.ts +1 -7
  75. package/dist/types/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.d.ts +11 -2
  76. package/dist/types-ts4.5/__fixtures__/dropbox-file.d.ts +3 -0
  77. package/dist/types-ts4.5/extractors/common/context/extractAccessContext.d.ts +1 -6
  78. package/dist/types-ts4.5/extractors/common/context/index.d.ts +1 -1
  79. package/dist/types-ts4.5/extractors/flexible/actions/index.d.ts +1 -1
  80. package/dist/types-ts4.5/state/flexible-ui-context/types.d.ts +2 -12
  81. package/dist/types-ts4.5/view/FlexibleCard/components/actions/download-action/index.d.ts +4 -0
  82. package/dist/types-ts4.5/view/FlexibleCard/components/actions/download-action/types.d.ts +2 -0
  83. package/dist/types-ts4.5/view/FlexibleCard/components/actions/follow-action/index.d.ts +2 -2
  84. package/dist/types-ts4.5/view/FlexibleCard/components/actions/follow-action/types.d.ts +2 -0
  85. package/dist/types-ts4.5/view/FlexibleCard/components/actions/index.d.ts +1 -7
  86. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.d.ts +11 -2
  87. package/package.json +4 -4
  88. package/dist/cjs/view/FlexibleCard/components/actions/action/download-action/index.js +0 -72
  89. package/dist/es2019/view/FlexibleCard/components/actions/action/download-action/index.js +0 -47
  90. package/dist/esm/view/FlexibleCard/components/actions/action/download-action/index.js +0 -65
  91. package/dist/types/view/FlexibleCard/components/actions/action/download-action/index.d.ts +0 -4
  92. package/dist/types/view/FlexibleCard/components/actions/action/download-action/types.d.ts +0 -5
  93. package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/download-action/index.d.ts +0 -4
  94. package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/download-action/types.d.ts +0 -5
  95. /package/dist/cjs/view/FlexibleCard/components/actions/{action/download-action → download-action}/types.js +0 -0
  96. /package/dist/es2019/view/FlexibleCard/components/actions/{action/download-action → download-action}/types.js +0 -0
  97. /package/dist/{esm/view/FlexibleCard/components/actions/action/download-action → es2019/view/FlexibleCard/components/actions/follow-action}/types.js +0 -0
@@ -8,19 +8,23 @@ Object.defineProperty(exports, "__esModule", {
8
8
  exports.default = void 0;
9
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
10
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
- var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
12
11
  var _react = require("@emotion/react");
13
12
  var _react2 = _interopRequireWildcard(require("react"));
14
13
  var _flexibleUiContext = require("../../../../../state/flexible-ui-context");
15
14
  var _text = _interopRequireDefault(require("../text"));
16
15
  var _excluded = ["content", "maxLines", "overrideCss"];
17
- var _templateObject;
18
16
  /** @jsx jsx */
19
17
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
20
18
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
21
19
  var SNIPPET_DEFAULT_MAX_LINES = 3;
22
20
  var getSnippetStyles = function getSnippetStyles(overrideCss) {
23
- return (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n color: ", ";\n ", ";\n"])), "var(--ds-text, #172B4D)", overrideCss);
21
+ return (0, _react.css)({
22
+ color: "var(--ds-text, #172B4D)",
23
+ WebkitUserSelect: 'text',
24
+ MozUserSelect: 'text',
25
+ MsUserSelect: 'text',
26
+ userSelect: 'text'
27
+ }, overrideCss);
24
28
  };
25
29
  var SnippetElement = function SnippetElement() {
26
30
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -66,7 +66,7 @@ var getForbiddenMessageKey = function getForbiddenMessageKey(meta) {
66
66
  }
67
67
  };
68
68
  var getRetryOptions = exports.getRetryOptions = function getRetryOptions(url, status, response, onAuthorize) {
69
- var _response$meta, _access$action;
69
+ var _response$meta, _access$action, _access$buttonDisable;
70
70
  var data = response && response.data || (0, _jsonld.getEmptyJsonLd)();
71
71
  var provider = (0, _linkExtractors.extractProvider)(data);
72
72
  var context = provider === null || provider === void 0 ? void 0 : provider.text;
@@ -76,15 +76,15 @@ var getRetryOptions = exports.getRetryOptions = function getRetryOptions(url, st
76
76
  switch (status) {
77
77
  case _constants.SmartLinkStatus.Forbidden:
78
78
  var meta = (_response$meta = response === null || response === void 0 ? void 0 : response.meta) !== null && _response$meta !== void 0 ? _response$meta : (0, _jsonld.getForbiddenJsonLd)().meta;
79
- var access = (0, _context.extractRequestAccessContext)({
79
+ var access = (0, _context.extractRequestAccessContextImproved)({
80
80
  jsonLd: meta,
81
81
  url: url,
82
- product: context
82
+ product: context !== null && context !== void 0 ? context : ''
83
83
  });
84
84
  var messageKey = getForbiddenMessageKey(meta);
85
85
  var descriptor = _messages.messages[messageKey];
86
86
  var retry = onAuthorize || (access === null || access === void 0 || (_access$action = access.action) === null || _access$action === void 0 ? void 0 : _access$action.promise);
87
- var onClick = retry ? (0, _utils.handleOnClick)(retry) : undefined;
87
+ var onClick = retry && !((_access$buttonDisable = access === null || access === void 0 ? void 0 : access.buttonDisabled) !== null && _access$buttonDisable !== void 0 ? _access$buttonDisable : false) ? (0, _utils.handleOnClick)(retry) : undefined;
88
88
  return {
89
89
  descriptor: descriptor,
90
90
  onClick: onClick,
@@ -17,6 +17,7 @@ var _HoverCardContent = require("./HoverCardContent");
17
17
  var _useAiSummary = require("../../../state/hooks/use-ai-summary");
18
18
  var _store = require("../../../state/store");
19
19
  var _linkExtractors = require("@atlaskit/link-extractors");
20
+ var _reactMagneticDi = require("react-magnetic-di");
20
21
  var _excluded = ["children", "isAIEnabled", "testId", "url"],
21
22
  _excluded2 = ["children", "isAIEnabled", "testId", "url"];
22
23
  /** @jsx jsx */
@@ -22,6 +22,7 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
22
22
  var _helpers = require("../../../../../state/helpers");
23
23
  var _useAiSummary = require("../../../../../state/hooks/use-ai-summary");
24
24
  var _linkExtractors = require("@atlaskit/link-extractors");
25
+ var _reactMagneticDi = require("react-magnetic-di");
25
26
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
26
27
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
27
28
  var toFooterActions = exports.toFooterActions = function toFooterActions(cardActions, onActionClick) {
@@ -17,7 +17,7 @@ var _excluded = ["href", "children", "checkSafety", "onClick", "testId"],
17
17
  _excluded2 = ["isLinkSafe", "showSafetyWarningModal"];
18
18
  var PACKAGE_DATA = {
19
19
  packageName: "@atlaskit/smart-card",
20
- packageVersion: "26.50.15",
20
+ packageVersion: "26.52.0",
21
21
  componentName: 'linkUrl'
22
22
  };
23
23
  var Link = (0, _click.withLinkClickedEvent)('a');
@@ -23,7 +23,11 @@ var AISummaryCSSStyles = (0, _react2.css)({
23
23
  fontSize: '0.75rem',
24
24
  lineHeight: '1rem',
25
25
  wordWrap: 'break-word',
26
- whiteSpace: 'normal'
26
+ whiteSpace: 'normal',
27
+ WebkitUserSelect: 'text',
28
+ MozUserSelect: 'text',
29
+ MsUserSelect: 'text',
30
+ userSelect: 'text'
27
31
  });
28
32
  /**
29
33
  * A component to render a response from AI in markdown text.
@@ -2,66 +2,18 @@ import { messages } from '../../../messages';
2
2
  import { ForbiddenAction } from '../../../view/BlockCard/actions/ForbiddenAction';
3
3
  import extractHostname from '../hostname/extractHostname';
4
4
  import { ANALYTICS_CHANNEL } from '../../../utils/analytics';
5
- export const extractRequestAccessContext = ({
6
- jsonLd,
7
- url,
8
- product
9
- }) => {
10
- var _jsonLd$requestAccess;
11
- const requestAccess = jsonLd !== null && jsonLd !== void 0 && jsonLd.requestAccess ? {
12
- ...(jsonLd === null || jsonLd === void 0 ? void 0 : jsonLd.requestAccess),
13
- hostname: extractHostname(url)
14
- } : undefined;
15
- switch (jsonLd === null || jsonLd === void 0 ? void 0 : (_jsonLd$requestAccess = jsonLd.requestAccess) === null || _jsonLd$requestAccess === void 0 ? void 0 : _jsonLd$requestAccess.accessType) {
16
- case 'DIRECT_ACCESS':
17
- return {
18
- ...requestAccess,
19
- callToActionMessageKey: 'click_to_join',
20
- descriptiveMessageKey: 'click_to_join_description',
21
- action: ForbiddenAction(() => window.open(url), 'click_to_join', messages.click_to_join, {
22
- context: product
23
- })
24
- };
25
- case 'REQUEST_ACCESS':
26
- return {
27
- ...requestAccess,
28
- callToActionMessageKey: 'request_access',
29
- descriptiveMessageKey: 'request_access_description',
30
- action: ForbiddenAction(() => window.open(url), 'request_access', messages.request_access, {
31
- product
32
- })
33
- };
34
- case 'PENDING_REQUEST_EXISTS':
35
- return {
36
- ...requestAccess,
37
- descriptiveMessageKey: 'request_access_pending_description'
38
- };
39
- case 'FORBIDDEN':
40
- return {
41
- ...requestAccess,
42
- descriptiveMessageKey: 'forbidden_description'
43
- };
44
- case 'DENIED_REQUEST_EXISTS':
45
- return {
46
- ...requestAccess,
47
- descriptiveMessageKey: 'request_denied_description'
48
- };
49
- default:
50
- return requestAccess;
51
- }
52
- };
53
5
  export const extractRequestAccessContextImproved = ({
54
6
  jsonLd,
55
7
  url,
56
8
  product,
57
9
  createAnalyticsEvent
58
10
  }) => {
59
- var _jsonLd$requestAccess2;
11
+ var _jsonLd$requestAccess;
60
12
  const requestAccess = jsonLd !== null && jsonLd !== void 0 && jsonLd.requestAccess ? {
61
13
  ...(jsonLd === null || jsonLd === void 0 ? void 0 : jsonLd.requestAccess),
62
14
  hostname: extractHostname(url)
63
15
  } : undefined;
64
- switch (jsonLd === null || jsonLd === void 0 ? void 0 : (_jsonLd$requestAccess2 = jsonLd.requestAccess) === null || _jsonLd$requestAccess2 === void 0 ? void 0 : _jsonLd$requestAccess2.accessType) {
16
+ switch (jsonLd === null || jsonLd === void 0 ? void 0 : (_jsonLd$requestAccess = jsonLd.requestAccess) === null || _jsonLd$requestAccess === void 0 ? void 0 : _jsonLd$requestAccess.accessType) {
65
17
  case 'DIRECT_ACCESS':
66
18
  return {
67
19
  ...requestAccess,
@@ -69,12 +21,14 @@ export const extractRequestAccessContextImproved = ({
69
21
  descriptiveMessageKey: 'direct_access_description',
70
22
  callToActionMessageKey: 'direct_access',
71
23
  action: ForbiddenAction(() => {
72
- createAnalyticsEvent({
73
- action: 'clicked',
74
- actionSubject: 'button',
75
- actionSubjectId: 'crossJoin',
76
- eventType: 'ui'
77
- }).fire(ANALYTICS_CHANNEL);
24
+ if (createAnalyticsEvent !== undefined) {
25
+ createAnalyticsEvent({
26
+ action: 'clicked',
27
+ actionSubject: 'button',
28
+ actionSubjectId: 'crossJoin',
29
+ eventType: 'ui'
30
+ }).fire(ANALYTICS_CHANNEL);
31
+ }
78
32
  window.open(url);
79
33
  }, 'direct_access', messages.direct_access, {
80
34
  product
@@ -87,12 +41,14 @@ export const extractRequestAccessContextImproved = ({
87
41
  descriptiveMessageKey: 'request_access_description',
88
42
  callToActionMessageKey: 'request_access',
89
43
  action: ForbiddenAction(() => {
90
- createAnalyticsEvent({
91
- action: 'clicked',
92
- actionSubject: 'button',
93
- actionSubjectId: 'requestAccess',
94
- eventType: 'ui'
95
- }).fire(ANALYTICS_CHANNEL);
44
+ if (createAnalyticsEvent !== undefined) {
45
+ createAnalyticsEvent({
46
+ action: 'clicked',
47
+ actionSubject: 'button',
48
+ actionSubjectId: 'requestAccess',
49
+ eventType: 'ui'
50
+ }).fire(ANALYTICS_CHANNEL);
51
+ }
96
52
  window.open(url);
97
53
  }, 'request_access', messages.request_access)
98
54
  };
@@ -125,12 +81,14 @@ export const extractRequestAccessContextImproved = ({
125
81
  descriptiveMessageKey: 'access_exists_description',
126
82
  callToActionMessageKey: 'request_access',
127
83
  action: ForbiddenAction(() => {
128
- createAnalyticsEvent({
129
- action: 'clicked',
130
- actionSubject: 'button',
131
- actionSubjectId: 'requestAccess',
132
- eventType: 'ui'
133
- }).fire(ANALYTICS_CHANNEL);
84
+ if (createAnalyticsEvent !== undefined) {
85
+ createAnalyticsEvent({
86
+ action: 'clicked',
87
+ actionSubject: 'button',
88
+ actionSubjectId: 'requestAccess',
89
+ eventType: 'ui'
90
+ }).fire(ANALYTICS_CHANNEL);
91
+ }
134
92
  window.open(url);
135
93
  }, 'access_exists', messages.request_access)
136
94
  };
@@ -1 +1 @@
1
- export { extractRequestAccessContext } from './extractAccessContext';
1
+ export { extractRequestAccessContextImproved } from './extractAccessContext';
@@ -1,8 +1,12 @@
1
1
  import { ActionName } from '../../../constants';
2
+ import { extractDownloadAction } from './extract-download-action';
2
3
  import { extractPreviewAction } from './extract-preview-action';
3
- const extractActions = (response, actionOptions) => {
4
+ import extractFollowAction from './extract-follow-action';
5
+ const extractActions = (response, data, actionOptions, id) => {
4
6
  const action = {
5
- [ActionName.PreviewAction]: extractPreviewAction(response, actionOptions)
7
+ [ActionName.PreviewAction]: extractPreviewAction(response, actionOptions),
8
+ [ActionName.DownloadAction]: extractDownloadAction(data, actionOptions),
9
+ [ActionName.FollowAction]: extractFollowAction(response, actionOptions, id)
6
10
  };
7
11
  return Object.values(action).some(value => Boolean(value)) ? action : undefined;
8
12
  };
@@ -1,6 +1,5 @@
1
1
  import { extractSummary } from '../common/primitives';
2
2
  import extractActions from './actions';
3
- import extractFollowAction from './actions/extract-follow-action';
4
3
  import { extractLinkIcon } from './icon';
5
4
  import { extractAttachmentCount, extractChecklistProgress, extractCommentCount, extractCreatedBy, extractModifiedBy, extractProgrammingLanguage, extractSubscriberCount, extractViewCount, extractReactCount, extractVoteCount, extractSourceBranch, extractTargetBranch, extractDueOn, extractLocation, extractOwnedBy, extractAssignedTo, extractSubTasksProgress, extractStoryPoints, extractReadTime, extractSentOn, extractPersonAssignedToAsArray } from './utils';
6
5
  import { extractPersonsUpdatedBy } from './collaboratorGroup';
@@ -10,7 +9,6 @@ import extractProviderIcon from './icon/extract-provider-icon';
10
9
  import extractPreview from './extract-preview';
11
10
  import extractState from './extract-state';
12
11
  import { extractLatestCommit } from './latest-commit';
13
- import { extractDownloadAction } from './actions/extract-download-action';
14
12
  import { extractViewAction } from './actions/extract-view-action';
15
13
  const extractFlexibleUiContext = ({
16
14
  id,
@@ -24,7 +22,7 @@ const extractFlexibleUiContext = ({
24
22
  const data = response.data;
25
23
  const url = extractLink(data);
26
24
  return {
27
- actions: extractActions(response, actionOptions),
25
+ actions: extractActions(response, data, actionOptions, id),
28
26
  assignedToGroup: extractPersonAssignedToAsArray(data),
29
27
  attachmentCount: extractAttachmentCount(data),
30
28
  authorGroup: extractPersonCreatedBy(data),
@@ -40,9 +38,7 @@ const extractFlexibleUiContext = ({
40
38
  assignedTo: extractAssignedTo(data),
41
39
  createdOn: extractDateCreated(data),
42
40
  dueOn: extractDueOn(data),
43
- followAction: extractFollowAction(response, actionOptions, id),
44
41
  viewAction: extractViewAction(data, actionOptions),
45
- downloadAction: extractDownloadAction(data, actionOptions),
46
42
  latestCommit: extractLatestCommit(data),
47
43
  linkIcon: extractLinkIcon(response, renderers),
48
44
  location: extractLocation(data),
@@ -4,7 +4,7 @@ export const ANALYTICS_CHANNEL = 'media';
4
4
  export const context = {
5
5
  componentName: 'smart-cards',
6
6
  packageName: "@atlaskit/smart-card",
7
- packageVersion: "26.50.15"
7
+ packageVersion: "26.52.0"
8
8
  };
9
9
  export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
10
10
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -1,10 +1,11 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  /** @jsx jsx */
3
3
 
4
+ import { useAnalyticsEvents } from '@atlaskit/analytics-next';
4
5
  import { getExtensionKey } from '../../state/helpers';
5
6
  import { extractBlockProps } from '../../extractors/block';
6
7
  import { getEmptyJsonLd, getForbiddenJsonLd } from '../../utils/jsonld';
7
- import { extractRequestAccessContext } from '../../extractors/common/context';
8
+ import { extractRequestAccessContextImproved } from '../../extractors/common/context';
8
9
  import { CardLinkView } from '../LinkView';
9
10
  import { AuthorizeAction } from './actions/AuthorizeAction';
10
11
  import { ForbiddenAction } from './actions/ForbiddenAction';
@@ -42,7 +43,10 @@ export const BlockCard = ({
42
43
  enableFlexibleBlockCard,
43
44
  actionOptions
44
45
  }) => {
45
- var _details$meta, _forbiddenViewProps$c;
46
+ var _details$meta, _forbiddenViewProps$c, _forbiddenViewProps$c2;
47
+ const {
48
+ createAnalyticsEvent
49
+ } = useAnalyticsEvents();
46
50
  const {
47
51
  status,
48
52
  details
@@ -156,10 +160,11 @@ export const BlockCard = ({
156
160
  }
157
161
  const forbiddenViewProps = extractBlockProps(data, meta, extractorOpts);
158
162
  const cardMetadata = (_details$meta = details === null || details === void 0 ? void 0 : details.meta) !== null && _details$meta !== void 0 ? _details$meta : getForbiddenJsonLd().meta;
159
- const requestAccessContext = extractRequestAccessContext({
163
+ const requestAccessContext = extractRequestAccessContextImproved({
160
164
  jsonLd: cardMetadata,
161
165
  url,
162
- product: (_forbiddenViewProps$c = forbiddenViewProps.context) === null || _forbiddenViewProps$c === void 0 ? void 0 : _forbiddenViewProps$c.text
166
+ product: (_forbiddenViewProps$c = (_forbiddenViewProps$c2 = forbiddenViewProps.context) === null || _forbiddenViewProps$c2 === void 0 ? void 0 : _forbiddenViewProps$c2.text) !== null && _forbiddenViewProps$c !== void 0 ? _forbiddenViewProps$c : '',
167
+ createAnalyticsEvent
163
168
  });
164
169
  return jsx(BlockCardForbiddenView, _extends({}, forbiddenViewProps, {
165
170
  isSelected: isSelected,
@@ -46,9 +46,10 @@ export const ForbiddenView = ({
46
46
  const {
47
47
  action,
48
48
  descriptiveMessageKey = 'invalid_permissions_description',
49
- hostname = ''
49
+ hostname = '',
50
+ buttonDisabled
50
51
  } = requestAccessContext;
51
- const items = action ? [...actions, action] : actions;
52
+ const items = action !== undefined && !(buttonDisabled !== null && buttonDisabled !== void 0 ? buttonDisabled : false) ? [...actions, action] : actions;
52
53
  return jsx(Frame, {
53
54
  isSelected: isSelected,
54
55
  testId: testId,
@@ -36,7 +36,6 @@ const FlexibleNotFoundView = ({
36
36
  descriptor: messages.not_found_description
37
37
  }), []);
38
38
  return /*#__PURE__*/React.createElement(UnresolvedView, _extends({}, props, {
39
- showPreview: true,
40
39
  testId: testId,
41
40
  title: title
42
41
  }), /*#__PURE__*/React.createElement(LockIcon, {
@@ -0,0 +1,47 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React, { useCallback } from 'react';
3
+ import { downloadUrl as download } from '../../../../../utils';
4
+ import { FormattedMessage } from 'react-intl-next';
5
+ import { ActionName } from '../../../../../constants';
6
+ import { messages } from '../../../../../messages';
7
+ import Action from '../action';
8
+ import { useFlexibleUiAnalyticsContext, useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
9
+ import useInvokeClientAction from '../../../../../state/hooks/use-invoke-client-action';
10
+ import DownloadIcon from '@atlaskit/icon/glyph/download';
11
+ const DownloadAction = ({
12
+ onClick: onClickCallback,
13
+ ...props
14
+ }) => {
15
+ var _context$actions;
16
+ const context = useFlexibleUiContext();
17
+ const analytics = useFlexibleUiAnalyticsContext();
18
+ const invoke = useInvokeClientAction({
19
+ analytics
20
+ });
21
+ const data = context === null || context === void 0 ? void 0 : (_context$actions = context.actions) === null || _context$actions === void 0 ? void 0 : _context$actions[ActionName.DownloadAction];
22
+ const onClick = useCallback(() => {
23
+ if (data !== null && data !== void 0 && data.downloadUrl) {
24
+ invoke({
25
+ actionType: ActionName.DownloadAction,
26
+ actionFn: async () => download(data === null || data === void 0 ? void 0 : data.downloadUrl),
27
+ // These values have already been set in analytics context.
28
+ // We only pass these here for ufo experience.
29
+ display: analytics === null || analytics === void 0 ? void 0 : analytics.display,
30
+ extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey
31
+ });
32
+ if (onClickCallback) {
33
+ onClickCallback();
34
+ }
35
+ }
36
+ }, [analytics, data === null || data === void 0 ? void 0 : data.downloadUrl, invoke, onClickCallback]);
37
+ return data ? /*#__PURE__*/React.createElement(Action, _extends({
38
+ content: /*#__PURE__*/React.createElement(FormattedMessage, messages.download),
39
+ icon: /*#__PURE__*/React.createElement(DownloadIcon, {
40
+ label: "Download"
41
+ }),
42
+ onClick: onClick,
43
+ testId: "smart-action-download-action",
44
+ tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.download)
45
+ }, data, props)) : null;
46
+ };
47
+ export default DownloadAction;
@@ -1,20 +1,22 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import InviteTeamIcon from '@atlaskit/icon/glyph/invite-team';
3
- import React, { useContext } from 'react';
3
+ import React from 'react';
4
4
  import { FormattedMessage } from 'react-intl-next';
5
+ import { ActionName } from '../../../../../constants';
5
6
  import { messages } from '../../../../../messages';
6
- import { FlexibleUiContext } from '../../../../../state/flexible-ui-context';
7
+ import { useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
7
8
  import ServerAction from '../action/server-action';
8
9
  import UnfollowIcon from './unfollow-icon';
9
10
  const FollowAction = props => {
10
- const context = useContext(FlexibleUiContext);
11
- if (!context || !context.followAction) {
11
+ var _context$actions, _context$actions2;
12
+ const context = useFlexibleUiContext();
13
+ if (!context || !(context !== null && context !== void 0 && (_context$actions = context.actions) !== null && _context$actions !== void 0 && _context$actions[ActionName.FollowAction])) {
12
14
  return null;
13
15
  }
14
16
  const {
15
17
  value,
16
18
  ...data
17
- } = context.followAction;
19
+ } = context === null || context === void 0 ? void 0 : (_context$actions2 = context.actions) === null || _context$actions2 === void 0 ? void 0 : _context$actions2[ActionName.FollowAction];
18
20
  const message = value ? messages.follow : messages.unfollow;
19
21
  const icon = value ? /*#__PURE__*/React.createElement(InviteTeamIcon, {
20
22
  label: "Follow"
@@ -2,6 +2,7 @@ import { ActionName } from '../../../../constants';
2
2
  import { createDataAction, createUIAction } from './utils';
3
3
  export { default as FollowAction } from './follow-action';
4
4
  export { default as PreviewAction } from './preview-action';
5
+ export { default as DownloadAction } from './download-action';
5
6
 
6
7
  /**
7
8
  * Creates a DeleteAction component. Accepts default ActionProps, but defaults
@@ -23,13 +24,6 @@ export const EditAction = createUIAction(ActionName.EditAction);
23
24
  */
24
25
  export const ViewAction = createDataAction(ActionName.ViewAction);
25
26
 
26
- /**
27
- * Creates a DownloadAction component. Accepts default DownloadActionProps, and defaults
28
- * to the text 'Download' inside the button.
29
- * @see Action
30
- */
31
- export const DownloadAction = createDataAction(ActionName.DownloadAction);
32
-
33
27
  /**
34
28
  * Creates a CustomAction component. Accepts default ActionProps. Required to provide
35
29
  * your own icon or text.
@@ -9,8 +9,6 @@ import CrossIcon from '@atlaskit/icon/glyph/cross';
9
9
  import EditIcon from '@atlaskit/icon/glyph/edit';
10
10
  import ViewAction from './action/view-action';
11
11
  import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
12
- import DownloadAction from './action/download-action';
13
- import DownloadIcon from '@atlaskit/icon/glyph/download';
14
12
  const actionMappings = {
15
13
  [ActionName.CustomAction]: {
16
14
  component: Action,
@@ -48,17 +46,6 @@ const actionMappings = {
48
46
  }),
49
47
  tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.view)
50
48
  }
51
- },
52
- [ActionName.DownloadAction]: {
53
- component: DownloadAction,
54
- props: {
55
- testId: 'smart-action-download-action',
56
- content: /*#__PURE__*/React.createElement(FormattedMessage, messages.download),
57
- icon: /*#__PURE__*/React.createElement(DownloadIcon, {
58
- label: "Download"
59
- }),
60
- tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.download)
61
- }
62
49
  }
63
50
  };
64
51
  const getContextKey = name => {
@@ -73,7 +60,6 @@ const getActionData = (actionName, contextKey, context) => {
73
60
  const data = context[contextKey];
74
61
  switch (actionName) {
75
62
  case ActionName.ViewAction:
76
- case ActionName.DownloadAction:
77
63
  return data;
78
64
  default:
79
65
  return undefined;
@@ -1,5 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import React, { useCallback, useMemo, useRef, useState, useEffect } from 'react';
2
+ import React, { useCallback, useMemo, useRef, useEffect } from 'react';
3
3
  import { FormattedMessage } from 'react-intl-next';
4
4
  import { Box, Inline } from '@atlaskit/primitives';
5
5
  import { ActionName, SmartLinkDirection, SmartLinkSize, SmartLinkWidth } from '../../../../../../constants';
@@ -16,16 +16,46 @@ import AISummary from '../../../../../common/ai-summary';
16
16
  import { useAnalyticsEvents } from '../../../../../../common/analytics/generated/use-analytics-events';
17
17
  import AIEventSummaryViewed from '../ai-event-summary-viewed';
18
18
  import AIEventErrorViewed from '../ai-event-error-viewed';
19
+ import { di } from 'react-magnetic-di';
20
+ export const AISummaryBlockErrorIndicator = ({
21
+ showErrorIndicator,
22
+ error,
23
+ testId
24
+ }) => {
25
+ return showErrorIndicator ? /*#__PURE__*/React.createElement(Inline, {
26
+ grow: "fill"
27
+ }, /*#__PURE__*/React.createElement(AIEventErrorViewed, {
28
+ reason: error
29
+ }), /*#__PURE__*/React.createElement(AIStateIndicator, {
30
+ error: error,
31
+ state: 'error',
32
+ testId: testId
33
+ })) : null;
34
+ };
35
+ export const AISummaryBlockStatusIndicator = ({
36
+ showStatusIndicator,
37
+ metadata,
38
+ status,
39
+ testId
40
+ }) => {
41
+ const metadataElements = renderElementItems(metadata);
42
+ return showStatusIndicator ? /*#__PURE__*/React.createElement(AIStateIndicator, {
43
+ state: status,
44
+ testId: `${testId}-state-indicator`
45
+ }) : /*#__PURE__*/React.createElement(ElementGroup, {
46
+ width: SmartLinkWidth.FitToContent,
47
+ testId: `${testId}-metadata-group`
48
+ }, metadataElements);
49
+ };
19
50
  const AISummaryBlockResolvedView = props => {
20
51
  const {
21
52
  actions = [],
22
- metadata,
23
53
  onActionMenuOpenChange,
24
54
  size = SmartLinkSize.Medium,
25
55
  testId,
26
- aiSummaryMinHeight
56
+ aiSummaryMinHeight,
57
+ metadata
27
58
  } = props;
28
- const metadataElements = renderElementItems(metadata);
29
59
  const {
30
60
  fireEvent
31
61
  } = useAnalyticsEvents();
@@ -48,15 +78,11 @@ const AISummaryBlockResolvedView = props => {
48
78
  status === 'loading' && !!content;
49
79
  const isSummarisedOnMountRef = useRef(status === 'done');
50
80
  const isErroredOnMountRef = useRef(status === 'error');
51
- const [showAISummaryErrorMessage, setShowAISummaryErrorMessage] = useState(false);
52
81
  useEffect(() => {
53
82
  // if the error was apparent on mount and the status is changed to loading we can
54
83
  // clear the initial error on mount state
55
84
  if (isErroredOnMountRef.current && status === 'loading') {
56
85
  isErroredOnMountRef.current = false;
57
- } else {
58
- // if a new error occurs and it was not an apparent error on mount, we can show the error message
59
- setShowAISummaryErrorMessage(!isErroredOnMountRef.current && status === 'error');
60
86
  }
61
87
  }, [status]);
62
88
  const combinedActions = useMemo(() => {
@@ -99,25 +125,20 @@ const AISummaryBlockResolvedView = props => {
99
125
  alignInline: "end",
100
126
  grow: "fill",
101
127
  spread: "space-between"
102
- }, /*#__PURE__*/React.createElement(Box, null, !isSummarisedOnMountRef.current && (status === 'loading' || status === 'done') ? /*#__PURE__*/React.createElement(AIStateIndicator, {
103
- state: status,
104
- testId: `${testId}-state-indicator`
105
- }) : /*#__PURE__*/React.createElement(ElementGroup, {
106
- width: SmartLinkWidth.FitToContent,
107
- testId: `${testId}-metadata-group`
108
- }, metadataElements)), /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(ActionGroup, {
128
+ }, /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(AISummaryBlockStatusIndicator, {
129
+ metadata: metadata,
130
+ showStatusIndicator: !isSummarisedOnMountRef.current && (status === 'loading' || status === 'done'),
131
+ status: status,
132
+ testId: testId
133
+ })), /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(ActionGroup, {
109
134
  onDropdownOpenChange: onDropdownOpenChange,
110
135
  items: combinedActions,
111
136
  appearance: "default",
112
137
  size: size
113
- }))), showAISummaryErrorMessage && /*#__PURE__*/React.createElement(Inline, {
114
- grow: "fill"
115
- }, /*#__PURE__*/React.createElement(AIEventErrorViewed, {
116
- reason: error
117
- }), /*#__PURE__*/React.createElement(AIStateIndicator, {
138
+ }))), /*#__PURE__*/React.createElement(AISummaryBlockErrorIndicator, {
139
+ showErrorIndicator: !isErroredOnMountRef.current && status === 'error',
118
140
  error: error,
119
- state: status,
120
141
  testId: testId
121
- })));
142
+ }));
122
143
  };
123
144
  export default AISummaryBlockResolvedView;
@@ -130,14 +130,6 @@ export const filterActionItems = (items = [], context) => {
130
130
  case ActionName.CustomAction:
131
131
  // Named and custom actions that user defines.
132
132
  return Boolean(ActionName[item.name]);
133
- case ActionName.DownloadAction:
134
- // Remove once DownloadAction is refactored to context.action
135
- // https://product-fabric.atlassian.net/browse/EDM-9545
136
- return Boolean(context === null || context === void 0 ? void 0 : context.downloadAction);
137
- // Remove once FollowAction is refactored to context.action
138
- // https://product-fabric.atlassian.net/browse/EDM-9559
139
- case ActionName.FollowAction:
140
- return Boolean(context === null || context === void 0 ? void 0 : context.followAction);
141
133
  // Remove once ViewAction is retired
142
134
  // https://product-fabric.atlassian.net/browse/EDM-9547
143
135
  case ActionName.ViewAction:
@@ -5,10 +5,13 @@ import React, { useContext } from 'react';
5
5
  import { FlexibleUiContext } from '../../../../../state/flexible-ui-context';
6
6
  import Text from '../text';
7
7
  const SNIPPET_DEFAULT_MAX_LINES = 3;
8
- const getSnippetStyles = overrideCss => css`
9
- color: ${"var(--ds-text, #172B4D)"};
10
- ${overrideCss};
11
- `;
8
+ const getSnippetStyles = overrideCss => css({
9
+ color: "var(--ds-text, #172B4D)",
10
+ WebkitUserSelect: 'text',
11
+ MozUserSelect: 'text',
12
+ MsUserSelect: 'text',
13
+ userSelect: 'text'
14
+ }, overrideCss);
12
15
  const SnippetElement = ({
13
16
  content: overrideContent,
14
17
  maxLines = SNIPPET_DEFAULT_MAX_LINES,