@atlaskit/smart-card 27.4.0 → 27.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/extractors/flexible/actions/extract-automation-action.js +13 -31
  3. package/dist/cjs/state/hooks/use-resolve/index.js +15 -120
  4. package/dist/cjs/state/hooks/use-response/index.js +132 -0
  5. package/dist/cjs/utils/analytics/analytics.js +1 -1
  6. package/dist/cjs/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/main.js +1 -1
  7. package/dist/cjs/view/FlexibleCard/components/actions/automation-action/index.js +14 -8
  8. package/dist/cjs/view/FlexibleCard/components/actions/automation-action/utils/index.js +19 -0
  9. package/dist/cjs/view/LinkUrl/index.js +1 -1
  10. package/dist/es2019/extractors/flexible/actions/extract-automation-action.js +13 -28
  11. package/dist/es2019/state/hooks/use-resolve/index.js +9 -112
  12. package/dist/es2019/state/hooks/use-response/index.js +126 -0
  13. package/dist/es2019/utils/analytics/analytics.js +1 -1
  14. package/dist/es2019/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/main.js +1 -1
  15. package/dist/es2019/view/FlexibleCard/components/actions/automation-action/index.js +16 -7
  16. package/dist/es2019/view/FlexibleCard/components/actions/automation-action/utils/index.js +13 -0
  17. package/dist/es2019/view/LinkUrl/index.js +1 -1
  18. package/dist/esm/extractors/flexible/actions/extract-automation-action.js +13 -30
  19. package/dist/esm/state/hooks/use-resolve/index.js +13 -118
  20. package/dist/esm/state/hooks/use-response/index.js +126 -0
  21. package/dist/esm/utils/analytics/analytics.js +1 -1
  22. package/dist/esm/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/main.js +1 -1
  23. package/dist/esm/view/FlexibleCard/components/actions/automation-action/index.js +14 -8
  24. package/dist/esm/view/FlexibleCard/components/actions/automation-action/utils/index.js +13 -0
  25. package/dist/esm/view/LinkUrl/index.js +1 -1
  26. package/dist/types/state/flexible-ui-context/types.d.ts +2 -3
  27. package/dist/types/state/hooks/use-response/index.d.ts +7 -0
  28. package/dist/types/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/header/main.d.ts +1 -1
  29. package/dist/types/view/FlexibleCard/components/actions/automation-action/utils/index.d.ts +7 -0
  30. package/dist/types-ts4.5/state/flexible-ui-context/types.d.ts +2 -3
  31. package/dist/types-ts4.5/state/hooks/use-response/index.d.ts +7 -0
  32. package/dist/types-ts4.5/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/header/main.d.ts +1 -1
  33. package/dist/types-ts4.5/view/FlexibleCard/components/actions/automation-action/utils/index.d.ts +7 -0
  34. package/package.json +3 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 27.4.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#105240](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/105240)
8
+ [`d54017d7086f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d54017d7086f) -
9
+ EDM-9896: separate useResponse hook from useResolveHook.
10
+
11
+ ## 27.4.1
12
+
13
+ ### Patch Changes
14
+
15
+ - [#105414](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/105414)
16
+ [`23d96f7c2ad9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/23d96f7c2ad9) -
17
+ Remove product and resourceType logic from the FE.
18
+
3
19
  ## 27.4.0
4
20
 
5
21
  ### Minor Changes
@@ -1,53 +1,35 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.extractAutomationAction = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
7
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
- var _messages = require("../../../messages");
11
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
12
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
13
- // This action will not be enabled by default for smart cards, which is opposite of the default behavior for actions.
14
- // The AutomationAction will only appear if product/resourceType combination is handled by this function.
15
- var getProductData = function getProductData(meta) {
16
- var _ProductData$product;
17
- var tenantId = meta.tenantId;
18
- var product = meta.product;
19
- var resourceType = meta.resourceType;
20
- var ProductData = {
21
- 'confluence': {
22
- 'page': {
23
- //TODO extract to server
24
- siteAri: "ari:cloud:confluence::site/".concat(tenantId),
25
- //TODO Move to AutomationAction
26
- modalTitle: _messages.messages.automation_action_confluence_page_modal_title,
27
- modalDescription: _messages.messages.automation_action_confluence_page_modal_description
28
- }
29
- }
30
- };
31
- return ProductData === null || ProductData === void 0 || (_ProductData$product = ProductData[product]) === null || _ProductData$product === void 0 ? void 0 : _ProductData$product[resourceType];
32
- };
8
+ var _constants = require("../../../constants");
33
9
  var extractAutomationAction = exports.extractAutomationAction = function extractAutomationAction(response) {
10
+ var _response$meta;
34
11
  if (!(0, _platformFeatureFlags.getBooleanFF)('platform.linking-platfom.smart-card.confluence.page.automation-action_xcdoi') || !response.data) {
35
12
  return undefined;
36
13
  }
14
+ if (!(response !== null && response !== void 0 && (_response$meta = response.meta) !== null && _response$meta !== void 0 && (_response$meta = _response$meta.supportedFeature) !== null && _response$meta !== void 0 && _response$meta.includes(_constants.ActionName.AutomationAction))) {
15
+ return undefined;
16
+ }
37
17
  var data = response.data;
38
18
  var meta = response.meta;
39
19
  var name = data.name,
40
20
  objectAri = data["atlassian:ari"];
41
- var productData = getProductData(meta);
42
- if (!productData) {
43
- return undefined;
44
- }
45
- return _objectSpread(_objectSpread({}, productData), {}, {
21
+ var product = meta.product,
22
+ tenantId = meta.tenantId,
23
+ resourceType = meta.resourceType;
24
+ return {
25
+ product: product,
26
+ resourceType: resourceType,
27
+ siteAri: "ari:cloud:".concat(product, "::site/").concat(tenantId),
46
28
  objectName: name,
47
29
  objectAri: objectAri,
48
30
  // TODO: The admin experience will be a follow up
49
31
  canManageAutomation: false,
50
32
  baseAutomationUrl: '',
51
33
  analyticsSource: 'smartCard'
52
- });
34
+ };
53
35
  };
@@ -8,133 +8,28 @@ exports.default = void 0;
8
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
9
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
10
  var _react = require("react");
11
- var _reactDom = require("react-dom");
12
11
  var _analytics = require("../../analytics");
13
- var _linkingCommon = require("@atlaskit/linking-common");
14
- var _constants = require("../../actions/constants");
15
- var _jsonld = require("../../../utils/jsonld");
16
- var _constants2 = require("../../../constants");
12
+ var _constants = require("../../../constants");
17
13
  var _linkProvider = require("@atlaskit/link-provider");
14
+ var _useResponse2 = _interopRequireDefault(require("../use-response"));
18
15
  var useResolve = function useResolve() {
19
16
  // Request JSON-LD data for the card from ORS, if it has extended
20
17
  // its cache lifespan OR there is no data for it currently. Once the data
21
- // has come back asynchronously, dispatch the resolved action for the card.
18
+ // has come back asynchronously, call the useResponse callback to
19
+ // dispatch the resolved action for the card.
22
20
  var _useSmartLinkContext = (0, _linkProvider.useSmartLinkContext)(),
23
21
  store = _useSmartLinkContext.store,
24
- connections = _useSmartLinkContext.connections,
25
- config = _useSmartLinkContext.config;
26
- var getState = store.getState,
27
- dispatch = store.dispatch;
28
- var hasAuthFlowSupported = config.authFlow !== 'disabled';
29
- var setMetadataStatus = (0, _react.useCallback)(function (url, metadataStatus) {
30
- dispatch((0, _linkingCommon.cardAction)(_linkingCommon.ACTION_UPDATE_METADATA_STATUS, {
31
- url: url
32
- }, undefined, undefined, metadataStatus));
33
- }, [dispatch]);
34
- var handleResolvedLinkError = (0, _react.useCallback)(function (url, error, response, isMetadataRequest) {
35
- var _ref = getState()[url] || {
36
- status: _constants2.SmartLinkStatus.Pending,
37
- details: undefined
38
- },
39
- details = _ref.details;
40
- var hasData = !!(details && details.data);
41
-
42
- // If metadata request then set metadata status, return and do not alter link status
43
- if (isMetadataRequest) {
44
- setMetadataStatus(url, 'errored');
45
- return;
46
- }
47
- if (error.kind === 'fatal') {
48
- // If there's no previous data in the store for this URL, then bail
49
- // out and let the editor handle fallbacks (returns to a blue link).
50
- if (!hasData && status !== 'resolved') {
51
- dispatch((0, _linkingCommon.cardAction)(_linkingCommon.ACTION_ERROR, {
52
- url: url
53
- }, details, error));
54
- throw error;
55
- }
56
- // If we already have resolved data for this URL in the store, then
57
- // simply fallback to the previous data.
58
- if (hasData) {
59
- dispatch((0, _linkingCommon.cardAction)(_linkingCommon.ACTION_RESOLVED, {
60
- url: url
61
- }, details));
62
- }
63
- // Handle AuthErrors (user did not have access to resource) -
64
- // Missing AAID in ASAP claims, or missing UserContext, or 403 from downstream
65
- } else if (error.kind === 'auth') {
66
- dispatch((0, _linkingCommon.cardAction)(_linkingCommon.ACTION_RESOLVED, {
67
- url: url
68
- }, (0, _jsonld.getUnauthorizedJsonLd)()));
69
- } else {
70
- if (error.kind === 'fallback') {
71
- // Fallback to blue link with smart link formatting. Not part of reliability.
72
- dispatch((0, _linkingCommon.cardAction)(_linkingCommon.ACTION_ERROR_FALLBACK, {
73
- url: url
74
- }, response, error));
75
- } else {
76
- // Fallback to blue link with smart link formatting. Part of reliability.
77
- dispatch((0, _linkingCommon.cardAction)(_linkingCommon.ACTION_ERROR, {
78
- url: url
79
- }, undefined, error));
80
- }
81
- }
82
- }, [getState, setMetadataStatus, dispatch]);
83
- var handleResolvedLinkSuccess = (0, _react.useCallback)(function (resourceUrl, response, isReloading, isMetadataRequest) {
84
- //if a link resolves normally, metadata will also always be resolved
85
- setMetadataStatus(resourceUrl, 'resolved');
86
- // Dispatch Analytics and resolved card action - including unauthorized states.
87
- if (isReloading) {
88
- dispatch((0, _linkingCommon.cardAction)(_linkingCommon.ACTION_RELOADING, {
89
- url: resourceUrl
90
- }, response));
91
- } else {
92
- dispatch((0, _linkingCommon.cardAction)(_linkingCommon.ACTION_RESOLVED, {
93
- url: resourceUrl
94
- }, response, undefined, undefined, isMetadataRequest));
95
- }
96
- }, [setMetadataStatus, dispatch]);
97
- var handleResolvedLinkResponse = (0, _react.useCallback)(function (resourceUrl, response) {
98
- var isReloading = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
99
- var isMetadataRequest = arguments.length > 3 ? arguments[3] : undefined;
100
- var hostname = new URL(resourceUrl).hostname;
101
- var nextStatus = response ? (0, _linkingCommon.getStatus)(response) : 'fatal';
102
-
103
- // If we require authorization & do not have an authFlow available,
104
- // throw an error and render as a normal blue link.
105
- if ((nextStatus === 'unauthorized' || nextStatus === 'forbidden') && !hasAuthFlowSupported) {
106
- handleResolvedLinkError(resourceUrl, new _linkingCommon.APIError('fallback', hostname, _constants.ERROR_MESSAGE_OAUTH), response, isMetadataRequest);
107
- return;
108
- }
109
-
110
- // Handle any other errors
111
- if (nextStatus === 'fatal') {
112
- handleResolvedLinkError(resourceUrl, new _linkingCommon.APIError('fatal', hostname, _constants.ERROR_MESSAGE_FATAL), undefined, isMetadataRequest);
113
- return;
114
- }
115
-
116
- // Handle errors of any other kind in the metadata request response
117
- if (isMetadataRequest && nextStatus !== 'resolved') {
118
- handleResolvedLinkError(resourceUrl, new _linkingCommon.APIError('error', hostname, _constants.ERROR_MESSAGE_METADATA), response, isMetadataRequest);
119
- return;
120
- }
121
-
122
- /**
123
- * Using unstable_batchedUpdates because this store update happens async and trigers a rerender
124
- * more info:
125
- * https://github.com/facebook/react/blob/v18.2.0/packages/use-sync-external-store/src/useSyncExternalStoreShimClient.js#L113
126
- * https://react-redux.js.org/api/batch
127
- */
128
- (0, _reactDom.unstable_batchedUpdates)(function () {
129
- handleResolvedLinkSuccess(resourceUrl, response, isReloading, isMetadataRequest);
130
- });
131
- }, [handleResolvedLinkError, handleResolvedLinkSuccess, hasAuthFlowSupported]);
22
+ connections = _useSmartLinkContext.connections;
23
+ var getState = store.getState;
24
+ var _useResponse = (0, _useResponse2.default)(),
25
+ handleResolvedLinkResponse = _useResponse.handleResolvedLinkResponse,
26
+ handleResolvedLinkError = _useResponse.handleResolvedLinkError;
132
27
  return (0, _react.useCallback)( /*#__PURE__*/function () {
133
- var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(url) {
28
+ var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(url) {
134
29
  var isReloading,
135
30
  isMetadataRequest,
136
31
  id,
137
- _ref3,
32
+ _ref2,
138
33
  details,
139
34
  hasData,
140
35
  _args = arguments;
@@ -144,10 +39,10 @@ var useResolve = function useResolve() {
144
39
  isReloading = _args.length > 1 && _args[1] !== undefined ? _args[1] : false;
145
40
  isMetadataRequest = _args.length > 2 && _args[2] !== undefined ? _args[2] : false;
146
41
  id = _args.length > 3 && _args[3] !== undefined ? _args[3] : '';
147
- _ref3 = getState()[url] || {
148
- status: _constants2.SmartLinkStatus.Pending,
42
+ _ref2 = getState()[url] || {
43
+ status: _constants.SmartLinkStatus.Pending,
149
44
  details: undefined
150
- }, details = _ref3.details;
45
+ }, details = _ref2.details;
151
46
  hasData = !!(details && details.data);
152
47
  if (!(isReloading || !hasData || isMetadataRequest)) {
153
48
  _context.next = 9;
@@ -169,7 +64,7 @@ var useResolve = function useResolve() {
169
64
  }, _callee);
170
65
  }));
171
66
  return function (_x) {
172
- return _ref2.apply(this, arguments);
67
+ return _ref.apply(this, arguments);
173
68
  };
174
69
  }(), [connections.client, getState, handleResolvedLinkError, handleResolvedLinkResponse]);
175
70
  };
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = require("react");
8
+ var _linkingCommon = require("@atlaskit/linking-common");
9
+ var _constants = require("../../../constants");
10
+ var _jsonld = require("../../../utils/jsonld");
11
+ var _constants2 = require("../../actions/constants");
12
+ var _reactDom = require("react-dom");
13
+ var _linkProvider = require("@atlaskit/link-provider");
14
+ var useResponse = function useResponse() {
15
+ // Takes in the JSON-LD response and dispatch the resolved action for the card.
16
+ // It will dispatch a successful or error action
17
+ var _useSmartLinkContext = (0, _linkProvider.useSmartLinkContext)(),
18
+ store = _useSmartLinkContext.store,
19
+ config = _useSmartLinkContext.config;
20
+ var getState = store.getState,
21
+ dispatch = store.dispatch;
22
+ var hasAuthFlowSupported = config.authFlow !== 'disabled';
23
+ var setMetadataStatus = (0, _react.useCallback)(function (url, metadataStatus) {
24
+ dispatch((0, _linkingCommon.cardAction)(_linkingCommon.ACTION_UPDATE_METADATA_STATUS, {
25
+ url: url
26
+ }, undefined, undefined, metadataStatus));
27
+ }, [dispatch]);
28
+ var handleResolvedLinkError = (0, _react.useCallback)(function (url, error, response, isMetadataRequest) {
29
+ var _ref = getState()[url] || {
30
+ status: _constants.SmartLinkStatus.Pending,
31
+ details: undefined
32
+ },
33
+ details = _ref.details;
34
+ var hasData = !!(details && details.data);
35
+ // If metadata request then set metadata status, return and do not alter link status
36
+ if (isMetadataRequest) {
37
+ setMetadataStatus(url, 'errored');
38
+ return;
39
+ }
40
+ if (error.kind === 'fatal') {
41
+ // If there's no previous data in the store for this URL, then bail
42
+ // out and let the editor handle fallbacks (returns to a blue link).
43
+ if (!hasData && status !== 'resolved') {
44
+ dispatch((0, _linkingCommon.cardAction)(_linkingCommon.ACTION_ERROR, {
45
+ url: url
46
+ }, details, error));
47
+ throw error;
48
+ }
49
+ // If we already have resolved data for this URL in the store, then
50
+ // simply fallback to the previous data.
51
+ if (hasData) {
52
+ dispatch((0, _linkingCommon.cardAction)(_linkingCommon.ACTION_RESOLVED, {
53
+ url: url
54
+ }, details));
55
+ }
56
+ // Handle AuthErrors (user did not have access to resource) -
57
+ // Missing AAID in ASAP claims, or missing UserContext, or 403 from downstream
58
+ } else if (error.kind === 'auth') {
59
+ dispatch((0, _linkingCommon.cardAction)(_linkingCommon.ACTION_RESOLVED, {
60
+ url: url
61
+ }, (0, _jsonld.getUnauthorizedJsonLd)()));
62
+ } else {
63
+ if (error.kind === 'fallback') {
64
+ // Fallback to blue link with smart link formatting. Not part of reliability.
65
+ dispatch((0, _linkingCommon.cardAction)(_linkingCommon.ACTION_ERROR_FALLBACK, {
66
+ url: url
67
+ }, response, error));
68
+ } else {
69
+ // Fallback to blue link with smart link formatting. Part of reliability.
70
+ dispatch((0, _linkingCommon.cardAction)(_linkingCommon.ACTION_ERROR, {
71
+ url: url
72
+ }, undefined, error));
73
+ }
74
+ }
75
+ }, [getState, setMetadataStatus, dispatch]);
76
+ var handleResolvedLinkSuccess = (0, _react.useCallback)(function (resourceUrl, response, isReloading, isMetadataRequest) {
77
+ //if a link resolves normally, metadata will also always be resolved
78
+ setMetadataStatus(resourceUrl, 'resolved');
79
+ // Dispatch Analytics and resolved card action - including unauthorized states.
80
+ if (isReloading) {
81
+ dispatch((0, _linkingCommon.cardAction)(_linkingCommon.ACTION_RELOADING, {
82
+ url: resourceUrl
83
+ }, response));
84
+ } else {
85
+ dispatch((0, _linkingCommon.cardAction)(_linkingCommon.ACTION_RESOLVED, {
86
+ url: resourceUrl
87
+ }, response, undefined, undefined, isMetadataRequest));
88
+ }
89
+ }, [setMetadataStatus, dispatch]);
90
+ var handleResolvedLinkResponse = (0, _react.useCallback)(function (resourceUrl, response) {
91
+ var isReloading = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
92
+ var isMetadataRequest = arguments.length > 3 ? arguments[3] : undefined;
93
+ var hostname = new URL(resourceUrl).hostname;
94
+ var nextStatus = response ? (0, _linkingCommon.getStatus)(response) : 'fatal';
95
+
96
+ // If we require authorization & do not have an authFlow available,
97
+ // throw an error and render as a normal blue link.
98
+ if ((nextStatus === 'unauthorized' || nextStatus === 'forbidden') && !hasAuthFlowSupported) {
99
+ handleResolvedLinkError(resourceUrl, new _linkingCommon.APIError('fallback', hostname, _constants2.ERROR_MESSAGE_OAUTH), response, isMetadataRequest);
100
+ return;
101
+ }
102
+
103
+ // Handle any other errors
104
+ if (nextStatus === 'fatal') {
105
+ handleResolvedLinkError(resourceUrl, new _linkingCommon.APIError('fatal', hostname, _constants2.ERROR_MESSAGE_FATAL), undefined, isMetadataRequest);
106
+ return;
107
+ }
108
+
109
+ // Handle errors of any other kind in the metadata request response
110
+ if (isMetadataRequest && nextStatus !== 'resolved') {
111
+ handleResolvedLinkError(resourceUrl, new _linkingCommon.APIError('error', hostname, _constants2.ERROR_MESSAGE_METADATA), response, isMetadataRequest);
112
+ return;
113
+ }
114
+
115
+ /**
116
+ * Using unstable_batchedUpdates because this store update happens async and triggers a rerender
117
+ * more info:
118
+ * https://github.com/facebook/react/blob/v18.2.0/packages/use-sync-external-store/src/useSyncExternalStoreShimClient.js#L113
119
+ * https://react-redux.js.org/api/batch
120
+ */
121
+ (0, _reactDom.unstable_batchedUpdates)(function () {
122
+ handleResolvedLinkSuccess(resourceUrl, response, isReloading, isMetadataRequest);
123
+ });
124
+ }, [handleResolvedLinkError, handleResolvedLinkSuccess, hasAuthFlowSupported]);
125
+ return (0, _react.useMemo)(function () {
126
+ return {
127
+ handleResolvedLinkError: handleResolvedLinkError,
128
+ handleResolvedLinkResponse: handleResolvedLinkResponse
129
+ };
130
+ }, [handleResolvedLinkError, handleResolvedLinkResponse]);
131
+ };
132
+ var _default = exports.default = useResponse;
@@ -22,7 +22,7 @@ var ANALYTICS_CHANNEL = exports.ANALYTICS_CHANNEL = 'media';
22
22
  var context = exports.context = {
23
23
  componentName: 'smart-cards',
24
24
  packageName: "@atlaskit/smart-card",
25
- packageVersion: "27.4.0"
25
+ packageVersion: "27.4.2"
26
26
  };
27
27
  var TrackQuickActionType = exports.TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
28
28
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -52,7 +52,7 @@ var AutomationModal = exports.AutomationModal = function AutomationModal(_ref) {
52
52
  emptyStateDescription: emptyStateDescription,
53
53
  emptyStateAdminDescription: emptyStateAdminDescription,
54
54
  onRuleInvocationSuccess: onClose,
55
- onRuleInvocationLifecycleDone: function onRuleInvocationLifecycleDone() {
55
+ onRuleInvocationFailure: function onRuleInvocationFailure() {
56
56
  return setSelectedRule(undefined);
57
57
  }
58
58
  }, function () {
@@ -15,6 +15,7 @@ var _flexibleUiContext = require("../../../../../state/flexible-ui-context");
15
15
  var _modal = require("../../../../../state/modal");
16
16
  var _constants = require("../../../../../constants");
17
17
  var _messages = require("../../../../../messages");
18
+ var _utils = require("./utils");
18
19
  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); }
19
20
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != (0, _typeof2.default)(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; }
20
21
  var AutomationModal = /*#__PURE__*/(0, _react.lazy)(function () {
@@ -27,19 +28,23 @@ var AutomationAction = function AutomationAction(props) {
27
28
  var _useIntl = (0, _reactIntlNext.useIntl)(),
28
29
  formatMessage = _useIntl.formatMessage;
29
30
  var modal = (0, _modal.useSmartLinkModal)();
31
+ var onClickCallback = props.onClick;
30
32
  var context = (0, _flexibleUiContext.useFlexibleUiContext)();
31
33
  var automationActionData = context === null || context === void 0 || (_context$actions = context.actions) === null || _context$actions === void 0 ? void 0 : _context$actions[_constants.ActionName.AutomationAction];
32
34
  var automationActionOnClick = (0, _react.useCallback)(function (automationActionData) {
33
- var baseAutomationUrl = automationActionData.baseAutomationUrl,
35
+ var product = automationActionData.product,
36
+ resourceType = automationActionData.resourceType,
37
+ baseAutomationUrl = automationActionData.baseAutomationUrl,
34
38
  objectAri = automationActionData.objectAri,
35
39
  siteAri = automationActionData.siteAri,
36
40
  canManageAutomation = automationActionData.canManageAutomation,
37
41
  analyticsSource = automationActionData.analyticsSource,
38
- modalTitle = automationActionData.modalTitle,
39
- modalDescription = automationActionData.modalDescription,
40
42
  objectName = automationActionData.objectName;
41
- var automationModalTitle = /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, modalTitle);
42
- var automationModalDescription = /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, (0, _extends2.default)({}, modalDescription, {
43
+ var _ref = (0, _utils.getModalContent)(product, resourceType) || {},
44
+ modalTitle = _ref.modalTitle,
45
+ modalDescription = _ref.modalDescription;
46
+ var automationModalTitle = modalTitle ? /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, modalTitle) : undefined;
47
+ var automationModalDescription = modalDescription ? /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, (0, _extends2.default)({}, modalDescription, {
43
48
  values: {
44
49
  name: objectName,
45
50
  b: function b(chunks) {
@@ -47,7 +52,7 @@ var AutomationAction = function AutomationAction(props) {
47
52
  },
48
53
  br: /*#__PURE__*/_react.default.createElement("br", null)
49
54
  }
50
- }));
55
+ })) : undefined;
51
56
  modal.open( /*#__PURE__*/_react.default.createElement(AutomationModal, {
52
57
  baseAutomationUrl: baseAutomationUrl,
53
58
  objectAri: objectAri,
@@ -60,7 +65,8 @@ var AutomationAction = function AutomationAction(props) {
60
65
  return modal.close();
61
66
  }
62
67
  }));
63
- }, [modal]);
68
+ onClickCallback === null || onClickCallback === void 0 || onClickCallback();
69
+ }, [modal, onClickCallback]);
64
70
  if (!automationActionData) {
65
71
  return null;
66
72
  }
@@ -74,7 +80,7 @@ var AutomationAction = function AutomationAction(props) {
74
80
  }),
75
81
  testId: "smart-action-automation-action",
76
82
  tooltipMessage: automationActionTooltip
77
- }, automationActionData, props, {
83
+ }, props, {
78
84
  onClick: function onClick() {
79
85
  return automationActionOnClick(automationActionData);
80
86
  }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getModalContent = void 0;
7
+ var _messages = require("../../../../../../messages");
8
+ var getModalContent = exports.getModalContent = function getModalContent(product, resourceType) {
9
+ var _modalContentMap$prod;
10
+ var modalContentMap = {
11
+ 'confluence': {
12
+ 'page': {
13
+ modalTitle: _messages.messages.automation_action_confluence_page_modal_title,
14
+ modalDescription: _messages.messages.automation_action_confluence_page_modal_description
15
+ }
16
+ }
17
+ };
18
+ return modalContentMap === null || modalContentMap === void 0 || (_modalContentMap$prod = modalContentMap[product]) === null || _modalContentMap$prod === void 0 ? void 0 : _modalContentMap$prod[resourceType];
19
+ };
@@ -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: "27.4.0",
20
+ packageVersion: "27.4.2",
21
21
  componentName: 'linkUrl'
22
22
  };
23
23
  var Link = (0, _click.withLinkClickedEvent)('a');
@@ -1,43 +1,28 @@
1
1
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
2
- import { messages } from '../../../messages';
3
- // This action will not be enabled by default for smart cards, which is opposite of the default behavior for actions.
4
- // The AutomationAction will only appear if product/resourceType combination is handled by this function.
5
- const getProductData = meta => {
6
- var _ProductData$product;
7
- const {
8
- tenantId
9
- } = meta;
10
- const product = meta.product;
11
- const resourceType = meta.resourceType;
12
- const ProductData = {
13
- 'confluence': {
14
- 'page': {
15
- //TODO extract to server
16
- siteAri: `ari:cloud:confluence::site/${tenantId}`,
17
- //TODO Move to AutomationAction
18
- modalTitle: messages.automation_action_confluence_page_modal_title,
19
- modalDescription: messages.automation_action_confluence_page_modal_description
20
- }
21
- }
22
- };
23
- return ProductData === null || ProductData === void 0 ? void 0 : (_ProductData$product = ProductData[product]) === null || _ProductData$product === void 0 ? void 0 : _ProductData$product[resourceType];
24
- };
2
+ import { ActionName } from '../../../constants';
25
3
  export const extractAutomationAction = response => {
4
+ var _response$meta, _response$meta$suppor;
26
5
  if (!getBooleanFF('platform.linking-platfom.smart-card.confluence.page.automation-action_xcdoi') || !response.data) {
27
6
  return undefined;
28
7
  }
8
+ if (!(response !== null && response !== void 0 && (_response$meta = response.meta) !== null && _response$meta !== void 0 && (_response$meta$suppor = _response$meta.supportedFeature) !== null && _response$meta$suppor !== void 0 && _response$meta$suppor.includes(ActionName.AutomationAction))) {
9
+ return undefined;
10
+ }
29
11
  const data = response.data;
30
12
  const meta = response.meta;
31
13
  const {
32
14
  name,
33
15
  "atlassian:ari": objectAri
34
16
  } = data;
35
- const productData = getProductData(meta);
36
- if (!productData) {
37
- return undefined;
38
- }
17
+ const {
18
+ product,
19
+ tenantId,
20
+ resourceType
21
+ } = meta;
39
22
  return {
40
- ...productData,
23
+ product: product,
24
+ resourceType: resourceType,
25
+ siteAri: `ari:cloud:${product}::site/${tenantId}`,
41
26
  objectName: name,
42
27
  objectAri: objectAri,
43
28
  // TODO: The admin experience will be a follow up