@atlaskit/smart-card 26.50.14 → 26.51.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 (84) hide show
  1. package/CHANGELOG.md +17 -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 +17 -0
  5. package/dist/cjs/extractors/flexible/index.js +2 -2
  6. package/dist/cjs/state/flexible-ui-context/types.js +1 -3
  7. package/dist/cjs/utils/analytics/analytics.js +1 -1
  8. package/dist/cjs/view/BlockCard/index.js +7 -3
  9. package/dist/cjs/view/BlockCard/views/ForbiddenView.js +3 -2
  10. package/dist/cjs/view/FlexibleCard/components/actions/index.js +8 -12
  11. package/dist/cjs/view/FlexibleCard/components/actions/preview-action/index.js +83 -0
  12. package/dist/cjs/view/FlexibleCard/components/actions/types.js +5 -0
  13. package/dist/cjs/view/FlexibleCard/components/actions/utils.js +0 -13
  14. package/dist/cjs/view/FlexibleCard/components/blocks/action-group/action-group-item/index.js +8 -6
  15. package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +45 -11
  16. package/dist/cjs/view/FlexibleCard/components/elements/snippet-element/index.js +7 -3
  17. package/dist/cjs/view/FlexibleCard/utils.js +4 -4
  18. package/dist/cjs/view/LinkUrl/index.js +1 -1
  19. package/dist/cjs/view/common/ai-summary/index.js +5 -1
  20. package/dist/es2019/extractors/common/context/extractAccessContext.js +26 -68
  21. package/dist/es2019/extractors/common/context/index.js +1 -1
  22. package/dist/es2019/extractors/flexible/actions/index.js +9 -0
  23. package/dist/es2019/extractors/flexible/index.js +2 -2
  24. package/dist/es2019/state/flexible-ui-context/types.js +6 -1
  25. package/dist/es2019/utils/analytics/analytics.js +1 -1
  26. package/dist/es2019/view/BlockCard/index.js +9 -4
  27. package/dist/es2019/view/BlockCard/views/ForbiddenView.js +3 -2
  28. package/dist/es2019/view/FlexibleCard/components/actions/index.js +1 -11
  29. package/dist/es2019/view/FlexibleCard/components/actions/preview-action/index.js +52 -0
  30. package/dist/es2019/view/FlexibleCard/components/actions/utils.js +0 -14
  31. package/dist/es2019/view/FlexibleCard/components/blocks/action-group/action-group-item/index.js +8 -6
  32. package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +42 -33
  33. package/dist/es2019/view/FlexibleCard/components/elements/snippet-element/index.js +7 -4
  34. package/dist/es2019/view/FlexibleCard/utils.js +5 -5
  35. package/dist/es2019/view/LinkUrl/index.js +1 -1
  36. package/dist/es2019/view/common/ai-summary/index.js +5 -1
  37. package/dist/esm/extractors/common/context/extractAccessContext.js +27 -66
  38. package/dist/esm/extractors/common/context/index.js +1 -1
  39. package/dist/esm/extractors/flexible/actions/index.js +10 -0
  40. package/dist/esm/extractors/flexible/index.js +2 -2
  41. package/dist/esm/state/flexible-ui-context/types.js +6 -1
  42. package/dist/esm/utils/analytics/analytics.js +1 -1
  43. package/dist/esm/view/BlockCard/index.js +8 -4
  44. package/dist/esm/view/BlockCard/views/ForbiddenView.js +3 -2
  45. package/dist/esm/view/FlexibleCard/components/actions/index.js +1 -11
  46. package/dist/esm/view/FlexibleCard/components/actions/preview-action/index.js +73 -0
  47. package/dist/esm/view/FlexibleCard/components/actions/preview-action/types.js +1 -0
  48. package/dist/esm/view/FlexibleCard/components/actions/types.js +1 -0
  49. package/dist/esm/view/FlexibleCard/components/actions/utils.js +0 -13
  50. package/dist/esm/view/FlexibleCard/components/blocks/action-group/action-group-item/index.js +8 -6
  51. package/dist/esm/view/FlexibleCard/components/blocks/utils.js +45 -11
  52. package/dist/esm/view/FlexibleCard/components/elements/snippet-element/index.js +7 -3
  53. package/dist/esm/view/FlexibleCard/utils.js +5 -5
  54. package/dist/esm/view/LinkUrl/index.js +1 -1
  55. package/dist/esm/view/common/ai-summary/index.js +5 -1
  56. package/dist/types/extractors/common/context/extractAccessContext.d.ts +1 -6
  57. package/dist/types/extractors/common/context/index.d.ts +1 -1
  58. package/dist/types/extractors/flexible/actions/index.d.ts +5 -0
  59. package/dist/types/state/flexible-ui-context/types.d.ts +8 -7
  60. package/dist/types/view/FlexibleCard/components/actions/index.d.ts +1 -7
  61. package/dist/types/view/FlexibleCard/components/actions/preview-action/index.d.ts +4 -0
  62. package/dist/types/view/FlexibleCard/components/actions/preview-action/types.d.ts +2 -0
  63. package/dist/types/view/FlexibleCard/components/actions/types.d.ts +7 -0
  64. package/dist/types/view/FlexibleCard/types.d.ts +20 -2
  65. package/dist/types-ts4.5/extractors/common/context/extractAccessContext.d.ts +1 -6
  66. package/dist/types-ts4.5/extractors/common/context/index.d.ts +1 -1
  67. package/dist/types-ts4.5/extractors/flexible/actions/index.d.ts +5 -0
  68. package/dist/types-ts4.5/state/flexible-ui-context/types.d.ts +8 -7
  69. package/dist/types-ts4.5/view/FlexibleCard/components/actions/index.d.ts +1 -7
  70. package/dist/types-ts4.5/view/FlexibleCard/components/actions/preview-action/index.d.ts +4 -0
  71. package/dist/types-ts4.5/view/FlexibleCard/components/actions/preview-action/types.d.ts +2 -0
  72. package/dist/types-ts4.5/view/FlexibleCard/components/actions/types.d.ts +7 -0
  73. package/dist/types-ts4.5/view/FlexibleCard/types.d.ts +20 -2
  74. package/package.json +2 -2
  75. package/dist/cjs/view/FlexibleCard/components/actions/action/preview-action/index.js +0 -87
  76. package/dist/es2019/view/FlexibleCard/components/actions/action/preview-action/index.js +0 -63
  77. package/dist/esm/view/FlexibleCard/components/actions/action/preview-action/index.js +0 -80
  78. package/dist/types/view/FlexibleCard/components/actions/action/preview-action/index.d.ts +0 -4
  79. package/dist/types/view/FlexibleCard/components/actions/action/preview-action/types.d.ts +0 -12
  80. package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/preview-action/index.d.ts +0 -4
  81. package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/preview-action/types.d.ts +0 -12
  82. /package/dist/cjs/view/FlexibleCard/components/actions/{action/preview-action → preview-action}/types.js +0 -0
  83. /package/dist/es2019/view/FlexibleCard/components/actions/{action/preview-action → preview-action}/types.js +0 -0
  84. /package/dist/{esm/view/FlexibleCard/components/actions/action/preview-action → es2019/view/FlexibleCard/components/actions}/types.js +0 -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,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.14",
20
+ packageVersion: "26.51.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';
@@ -0,0 +1,9 @@
1
+ import { ActionName } from '../../../constants';
2
+ import { extractPreviewAction } from './extract-preview-action';
3
+ const extractActions = (response, actionOptions) => {
4
+ const action = {
5
+ [ActionName.PreviewAction]: extractPreviewAction(response, actionOptions)
6
+ };
7
+ return Object.values(action).some(value => Boolean(value)) ? action : undefined;
8
+ };
9
+ export default extractActions;
@@ -1,4 +1,5 @@
1
1
  import { extractSummary } from '../common/primitives';
2
+ import extractActions from './actions';
2
3
  import extractFollowAction from './actions/extract-follow-action';
3
4
  import { extractLinkIcon } from './icon';
4
5
  import { extractAttachmentCount, extractChecklistProgress, extractCommentCount, extractCreatedBy, extractModifiedBy, extractProgrammingLanguage, extractSubscriberCount, extractViewCount, extractReactCount, extractVoteCount, extractSourceBranch, extractTargetBranch, extractDueOn, extractLocation, extractOwnedBy, extractAssignedTo, extractSubTasksProgress, extractStoryPoints, extractReadTime, extractSentOn, extractPersonAssignedToAsArray } from './utils';
@@ -9,7 +10,6 @@ import extractProviderIcon from './icon/extract-provider-icon';
9
10
  import extractPreview from './extract-preview';
10
11
  import extractState from './extract-state';
11
12
  import { extractLatestCommit } from './latest-commit';
12
- import { extractPreviewAction } from './actions/extract-preview-action';
13
13
  import { extractDownloadAction } from './actions/extract-download-action';
14
14
  import { extractViewAction } from './actions/extract-view-action';
15
15
  const extractFlexibleUiContext = ({
@@ -24,6 +24,7 @@ const extractFlexibleUiContext = ({
24
24
  const data = response.data;
25
25
  const url = extractLink(data);
26
26
  return {
27
+ actions: extractActions(response, actionOptions),
27
28
  assignedToGroup: extractPersonAssignedToAsArray(data),
28
29
  attachmentCount: extractAttachmentCount(data),
29
30
  authorGroup: extractPersonCreatedBy(data),
@@ -40,7 +41,6 @@ const extractFlexibleUiContext = ({
40
41
  createdOn: extractDateCreated(data),
41
42
  dueOn: extractDueOn(data),
42
43
  followAction: extractFollowAction(response, actionOptions, id),
43
- previewAction: extractPreviewAction(response, actionOptions),
44
44
  viewAction: extractViewAction(data, actionOptions),
45
45
  downloadAction: extractDownloadAction(data, actionOptions),
46
46
  latestCommit: extractLatestCommit(data),
@@ -1 +1,6 @@
1
- export {};
1
+ import { ActionName } from '../../constants';
2
+
3
+ /**
4
+ * This provides the data that will be used by Smart Links Flexible UI to populate it's
5
+ * underlying elements.
6
+ */
@@ -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.14"
7
+ packageVersion: "26.51.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,
@@ -1,10 +1,7 @@
1
1
  import { ActionName } from '../../../../constants';
2
2
  import { createDataAction, createUIAction } from './utils';
3
3
  export { default as FollowAction } from './follow-action';
4
-
5
- // Attention: Keep the export name and action name the same.
6
- // This will help reducing the code for mapping action inside
7
- // createAction and renderActionItems
4
+ export { default as PreviewAction } from './preview-action';
8
5
 
9
6
  /**
10
7
  * Creates a DeleteAction component. Accepts default ActionProps, but defaults
@@ -19,13 +16,6 @@ export const DeleteAction = createUIAction(ActionName.DeleteAction);
19
16
  */
20
17
  export const EditAction = createUIAction(ActionName.EditAction);
21
18
 
22
- /**
23
- * Creates a PreviewAction component. Accepts default PreviewActionProps, and defaults
24
- * to the text 'Preview' inside the button.
25
- * @see Action
26
- */
27
- export const PreviewAction = createDataAction(ActionName.PreviewAction);
28
-
29
19
  /**
30
20
  * Creates a ViewAction component. Accepts default ViewActionProps, and defaults
31
21
  * to the text 'View' inside the button.
@@ -0,0 +1,52 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import VidFullScreenOnIcon from '@atlaskit/icon/glyph/vid-full-screen-on';
3
+ import React, { useCallback } from 'react';
4
+ import { FormattedMessage } from 'react-intl-next';
5
+ import { ActionName } from '../../../../../constants';
6
+ import { messages } from '../../../../../messages';
7
+ import { useFlexibleUiAnalyticsContext, useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
8
+ import useInvokeClientAction from '../../../../../state/hooks/use-invoke-client-action';
9
+ import { openEmbedModalWithFlexibleUiIcon } from '../../utils';
10
+ import Action from '../action';
11
+ const PreviewAction = ({
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.PreviewAction];
22
+ const onClick = useCallback(() => {
23
+ if (data) {
24
+ invoke({
25
+ actionType: ActionName.PreviewAction,
26
+ actionFn: async () => openEmbedModalWithFlexibleUiIcon({
27
+ download: data === null || data === void 0 ? void 0 : data.downloadUrl,
28
+ extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey,
29
+ analytics,
30
+ ...data
31
+ }),
32
+ // These values have already been set in analytics context.
33
+ // We only pass these here for ufo experience.
34
+ display: analytics === null || analytics === void 0 ? void 0 : analytics.display,
35
+ extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey
36
+ });
37
+ }
38
+ if (onClickCallback) {
39
+ onClickCallback();
40
+ }
41
+ }, [analytics, data, invoke, onClickCallback]);
42
+ return data ? /*#__PURE__*/React.createElement(Action, _extends({
43
+ content: /*#__PURE__*/React.createElement(FormattedMessage, messages.preview_improved),
44
+ icon: /*#__PURE__*/React.createElement(VidFullScreenOnIcon, {
45
+ label: "Open preview"
46
+ }),
47
+ onClick: onClick,
48
+ testId: "smart-action-preview-action",
49
+ tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.preview_improved)
50
+ }, data, props)) : null;
51
+ };
52
+ export default PreviewAction;
@@ -7,8 +7,6 @@ import { FormattedMessage } from 'react-intl-next';
7
7
  import { messages } from '../../../../messages';
8
8
  import CrossIcon from '@atlaskit/icon/glyph/cross';
9
9
  import EditIcon from '@atlaskit/icon/glyph/edit';
10
- import PreviewAction from './action/preview-action';
11
- import VidFullScreenOnIcon from '@atlaskit/icon/glyph/vid-full-screen-on';
12
10
  import ViewAction from './action/view-action';
13
11
  import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
14
12
  import DownloadAction from './action/download-action';
@@ -40,17 +38,6 @@ const actionMappings = {
40
38
  tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.edit)
41
39
  }
42
40
  },
43
- [ActionName.PreviewAction]: {
44
- component: PreviewAction,
45
- props: {
46
- testId: 'smart-action-preview-action',
47
- content: /*#__PURE__*/React.createElement(FormattedMessage, messages.preview_improved),
48
- icon: /*#__PURE__*/React.createElement(VidFullScreenOnIcon, {
49
- label: "Open preview"
50
- }),
51
- tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.preview_improved)
52
- }
53
- },
54
41
  [ActionName.ViewAction]: {
55
42
  component: ViewAction,
56
43
  props: {
@@ -85,7 +72,6 @@ const getActionData = (actionName, contextKey, context) => {
85
72
  }
86
73
  const data = context[contextKey];
87
74
  switch (actionName) {
88
- case ActionName.PreviewAction:
89
75
  case ActionName.ViewAction:
90
76
  case ActionName.DownloadAction:
91
77
  return data;
@@ -3,7 +3,6 @@ import _extends from "@babel/runtime/helpers/extends";
3
3
  import { jsx } from '@emotion/react';
4
4
  import React, { useCallback } from 'react';
5
5
  import * as Actions from '../../../actions';
6
- import { isJSXElementNull } from '../../utils';
7
6
  const ActionGroupItem = ({
8
7
  item,
9
8
  size,
@@ -40,7 +39,14 @@ const ActionGroupItem = ({
40
39
  if (hideIcon) {
41
40
  actionProps.icon = undefined;
42
41
  }
43
- const action = jsx(Action, _extends({
42
+ return jsx(Action
43
+ // Remove url once ViewAction is retired.
44
+ // This seems to be a typescript workaround
45
+ // because ViewAction marks it as required,
46
+ // which does not reflect actual implementation as the url
47
+ // came from data context and not all actions require url.
48
+ // https://product-fabric.atlassian.net/browse/EDM-9547
49
+ , _extends({
44
50
  url: "",
45
51
  asDropDownItem: asDropDownItems,
46
52
  size: size,
@@ -48,9 +54,5 @@ const ActionGroupItem = ({
48
54
  onClick: handleOnClick,
49
55
  isDisabled: isDisabled
50
56
  }, actionProps));
51
- if (!isJSXElementNull(action)) {
52
- return action;
53
- }
54
- return null;
55
57
  };
56
58
  export default ActionGroupItem;
@@ -48,16 +48,16 @@ export const ElementDisplaySchema = {
48
48
  const getDirectionStyles = direction => {
49
49
  switch (direction) {
50
50
  case SmartLinkDirection.Vertical:
51
- return css`
52
- flex-direction: column;
53
- align-items: flex-start;
54
- `;
51
+ return css({
52
+ flexDirection: 'column',
53
+ alignItems: 'flex-start'
54
+ });
55
55
  case SmartLinkDirection.Horizontal:
56
56
  default:
57
- return css`
58
- flex-direction: row;
59
- align-items: center;
60
- `;
57
+ return css({
58
+ flexDirection: 'row',
59
+ alignItems: 'center'
60
+ });
61
61
  }
62
62
  };
63
63
  export const getGapSize = size => {
@@ -73,24 +73,24 @@ export const getGapSize = size => {
73
73
  return 0.25;
74
74
  }
75
75
  };
76
- export const getBaseStyles = (direction, size) => css`
77
- align-items: center;
78
- display: flex;
79
- gap: ${getGapSize(size)}rem;
80
- line-height: 1rem;
81
- min-width: 0;
82
- overflow: hidden;
83
- ${getDirectionStyles(direction)};
84
- &:empty {
85
- display: none;
76
+ export const getBaseStyles = (direction, size) => css({
77
+ alignItems: 'center',
78
+ display: 'flex',
79
+ gap: `${getGapSize(size)}rem`,
80
+ lineHeight: '1rem',
81
+ minWidth: 0,
82
+ overflow: 'hidden'
83
+ }, getDirectionStyles(direction), {
84
+ '&:empty': {
85
+ display: 'none'
86
+ },
87
+ '& > *': {
88
+ minWidth: 0
89
+ },
90
+ '& > [data-fit-to-content]': {
91
+ minWidth: 'fit-content'
86
92
  }
87
- & > * {
88
- min-width: 0;
89
- }
90
- & > [data-fit-to-content] {
91
- min-width: fit-content;
92
- }
93
- `;
93
+ });
94
94
  export const highlightRemoveStyles = css`
95
95
  outline: none !important;
96
96
  outline-color: inherit;
@@ -116,26 +116,35 @@ export const getActionGroupStyles = size => {
116
116
  // The biggest height of the action button exceeds the max line-height
117
117
  // of the elements causing the action on the block with x-large size to
118
118
  // get cut at the bottom.
119
- return css`
120
- max-height: 2rem;
121
- `;
119
+ return css({
120
+ maxHeight: '2rem'
121
+ });
122
122
  }
123
123
  };
124
124
  export const filterActionItems = (items = [], context) => {
125
125
  return items.filter(item => {
126
+ var _context$actions;
126
127
  switch (item.name) {
127
- // Action that require data from the data context to render.
128
+ case ActionName.DeleteAction:
129
+ case ActionName.EditAction:
130
+ case ActionName.CustomAction:
131
+ // Named and custom actions that user defines.
132
+ return Boolean(ActionName[item.name]);
128
133
  case ActionName.DownloadAction:
134
+ // Remove once DownloadAction is refactored to context.action
135
+ // https://product-fabric.atlassian.net/browse/EDM-9545
129
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
130
139
  case ActionName.FollowAction:
131
140
  return Boolean(context === null || context === void 0 ? void 0 : context.followAction);
132
- case ActionName.PreviewAction:
133
- return Boolean(context === null || context === void 0 ? void 0 : context.previewAction);
141
+ // Remove once ViewAction is retired
142
+ // https://product-fabric.atlassian.net/browse/EDM-9547
134
143
  case ActionName.ViewAction:
135
144
  return Boolean(context === null || context === void 0 ? void 0 : context.viewAction);
136
145
  default:
137
- // Named and custom actions that user defines.
138
- return Boolean(ActionName[item.name]);
146
+ // Action that require data from the data context to render.
147
+ return Boolean(context === null || context === void 0 ? void 0 : (_context$actions = context.actions) === null || _context$actions === void 0 ? void 0 : _context$actions[item.name]);
139
148
  }
140
149
  });
141
150
  };
@@ -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,
@@ -1,6 +1,6 @@
1
1
  import { SmartLinkStatus } from '../../constants';
2
2
  import { getEmptyJsonLd, getForbiddenJsonLd } from '../../utils/jsonld';
3
- import { extractRequestAccessContext } from '../../extractors/common/context';
3
+ import { extractRequestAccessContextImproved } from '../../extractors/common/context';
4
4
  import { messages } from '../../messages';
5
5
  import extractFlexibleUiContext from '../../extractors/flexible';
6
6
  import { extractErrorIcon } from '../../extractors/flexible/icon';
@@ -60,7 +60,7 @@ const getForbiddenMessageKey = meta => {
60
60
  }
61
61
  };
62
62
  export const getRetryOptions = (url, status, response, onAuthorize) => {
63
- var _response$meta, _access$action;
63
+ var _response$meta, _access$action, _access$buttonDisable;
64
64
  const data = response && response.data || getEmptyJsonLd();
65
65
  const provider = extractProvider(data);
66
66
  const context = provider === null || provider === void 0 ? void 0 : provider.text;
@@ -70,15 +70,15 @@ export const getRetryOptions = (url, status, response, onAuthorize) => {
70
70
  switch (status) {
71
71
  case SmartLinkStatus.Forbidden:
72
72
  const meta = (_response$meta = response === null || response === void 0 ? void 0 : response.meta) !== null && _response$meta !== void 0 ? _response$meta : getForbiddenJsonLd().meta;
73
- const access = extractRequestAccessContext({
73
+ const access = extractRequestAccessContextImproved({
74
74
  jsonLd: meta,
75
75
  url,
76
- product: context
76
+ product: context !== null && context !== void 0 ? context : ''
77
77
  });
78
78
  const messageKey = getForbiddenMessageKey(meta);
79
79
  const descriptor = messages[messageKey];
80
80
  const retry = onAuthorize || (access === null || access === void 0 ? void 0 : (_access$action = access.action) === null || _access$action === void 0 ? void 0 : _access$action.promise);
81
- const onClick = retry ? handleOnClick(retry) : undefined;
81
+ const onClick = retry && !((_access$buttonDisable = access === null || access === void 0 ? void 0 : access.buttonDisabled) !== null && _access$buttonDisable !== void 0 ? _access$buttonDisable : false) ? handleOnClick(retry) : undefined;
82
82
  return {
83
83
  descriptor,
84
84
  onClick,
@@ -7,7 +7,7 @@ import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-m
7
7
  import LinkWarningModal from './LinkWarningModal';
8
8
  const PACKAGE_DATA = {
9
9
  packageName: "@atlaskit/smart-card",
10
- packageVersion: "26.50.14",
10
+ packageVersion: "26.51.0",
11
11
  componentName: 'linkUrl'
12
12
  };
13
13
  const Link = withLinkClickedEvent('a');
@@ -13,7 +13,11 @@ const AISummaryCSSStyles = css({
13
13
  fontSize: '0.75rem',
14
14
  lineHeight: '1rem',
15
15
  wordWrap: 'break-word',
16
- whiteSpace: 'normal'
16
+ whiteSpace: 'normal',
17
+ WebkitUserSelect: 'text',
18
+ MozUserSelect: 'text',
19
+ MsUserSelect: 'text',
20
+ userSelect: 'text'
17
21
  });
18
22
  /**
19
23
  * A component to render a response from AI in markdown text.