@atlaskit/smart-card 27.3.0 → 27.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) 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/utils/analytics/analytics.js +1 -1
  4. package/dist/cjs/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/main.js +7 -3
  5. package/dist/cjs/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/menu-context/main.js +21 -5
  6. package/dist/cjs/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/body/main.js +2 -2
  7. package/dist/cjs/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/error-state/main.js +1 -1
  8. package/dist/cjs/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/execution-state-message/index.js +12 -0
  9. package/dist/cjs/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/execution-state-message/main.js +43 -0
  10. package/dist/cjs/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/footer/main.js +2 -2
  11. package/dist/cjs/view/FlexibleCard/components/actions/automation-action/index.js +14 -8
  12. package/dist/cjs/view/FlexibleCard/components/actions/automation-action/utils/index.js +19 -0
  13. package/dist/cjs/view/LinkUrl/index.js +1 -1
  14. package/dist/es2019/extractors/flexible/actions/extract-automation-action.js +13 -28
  15. package/dist/es2019/utils/analytics/analytics.js +1 -1
  16. package/dist/es2019/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/main.js +5 -3
  17. package/dist/es2019/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/menu-context/main.js +16 -4
  18. package/dist/es2019/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/body/main.js +2 -2
  19. package/dist/es2019/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/error-state/main.js +1 -1
  20. package/dist/es2019/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/execution-state-message/index.js +2 -0
  21. package/dist/es2019/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/execution-state-message/main.js +37 -0
  22. package/dist/es2019/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/footer/main.js +2 -2
  23. package/dist/es2019/view/FlexibleCard/components/actions/automation-action/index.js +16 -7
  24. package/dist/es2019/view/FlexibleCard/components/actions/automation-action/utils/index.js +13 -0
  25. package/dist/es2019/view/LinkUrl/index.js +1 -1
  26. package/dist/esm/extractors/flexible/actions/extract-automation-action.js +13 -30
  27. package/dist/esm/utils/analytics/analytics.js +1 -1
  28. package/dist/esm/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/main.js +7 -3
  29. package/dist/esm/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/menu-context/main.js +22 -6
  30. package/dist/esm/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/body/main.js +2 -2
  31. package/dist/esm/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/error-state/main.js +1 -1
  32. package/dist/esm/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/execution-state-message/index.js +2 -0
  33. package/dist/esm/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/execution-state-message/main.js +36 -0
  34. package/dist/esm/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/footer/main.js +2 -2
  35. package/dist/esm/view/FlexibleCard/components/actions/automation-action/index.js +14 -8
  36. package/dist/esm/view/FlexibleCard/components/actions/automation-action/utils/index.js +13 -0
  37. package/dist/esm/view/LinkUrl/index.js +1 -1
  38. package/dist/types/state/flexible-ui-context/types.d.ts +2 -3
  39. package/dist/types/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/menu-context/index.d.ts +1 -1
  40. package/dist/types/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/menu-context/main.d.ts +4 -1
  41. package/dist/types/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/execution-state-message/index.d.ts +2 -0
  42. package/dist/types/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/execution-state-message/main.d.ts +2 -0
  43. package/dist/types/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/header/main.d.ts +1 -1
  44. package/dist/types/view/FlexibleCard/components/actions/automation-action/utils/index.d.ts +7 -0
  45. package/dist/types-ts4.5/state/flexible-ui-context/types.d.ts +2 -3
  46. package/dist/types-ts4.5/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/menu-context/index.d.ts +1 -1
  47. package/dist/types-ts4.5/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/menu-context/main.d.ts +4 -1
  48. package/dist/types-ts4.5/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/execution-state-message/index.d.ts +2 -0
  49. package/dist/types-ts4.5/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/execution-state-message/main.d.ts +2 -0
  50. 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
  51. package/dist/types-ts4.5/view/FlexibleCard/components/actions/automation-action/utils/index.d.ts +7 -0
  52. package/package.json +2 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 27.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#105414](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/105414)
8
+ [`23d96f7c2ad9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/23d96f7c2ad9) -
9
+ Remove product and resourceType logic from the FE.
10
+
11
+ ## 27.4.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [#104944](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/104944)
16
+ [`2254e1b73d47`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/2254e1b73d47) -
17
+ [ux] Error message for failed automation rule invocation.
18
+
3
19
  ## 27.3.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
  };
@@ -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.3.0"
25
+ packageVersion: "27.4.1"
26
26
  };
27
27
  var TrackQuickActionType = exports.TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
28
28
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -11,9 +11,10 @@ var _react = _interopRequireWildcard(require("react"));
11
11
  var _analyticsNext = require("@atlaskit/analytics-next");
12
12
  var _modalDialog = _interopRequireWildcard(require("@atlaskit/modal-dialog"));
13
13
  var _menuContext = require("./menu-context");
14
+ var _header = require("./sub-components/header");
14
15
  var _body = require("./sub-components/body");
16
+ var _executionStateMessage = require("./sub-components/execution-state-message");
15
17
  var _footer = require("./sub-components/footer");
16
- var _header = require("./sub-components/header");
17
18
  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); }
18
19
  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; }
19
20
  var AutomationModal = exports.AutomationModal = function AutomationModal(_ref) {
@@ -50,7 +51,10 @@ var AutomationModal = exports.AutomationModal = function AutomationModal(_ref) {
50
51
  analyticsSource: analyticsSource,
51
52
  emptyStateDescription: emptyStateDescription,
52
53
  emptyStateAdminDescription: emptyStateAdminDescription,
53
- onRuleInvocationLifecycleDone: onClose
54
+ onRuleInvocationSuccess: onClose,
55
+ onRuleInvocationFailure: function onRuleInvocationFailure() {
56
+ return setSelectedRule(undefined);
57
+ }
54
58
  }, function () {
55
59
  return /*#__PURE__*/_react.default.createElement(_modalDialog.default, {
56
60
  onClose: onClose,
@@ -64,7 +68,7 @@ var AutomationModal = exports.AutomationModal = function AutomationModal(_ref) {
64
68
  }), /*#__PURE__*/_react.default.createElement(_modalDialog.ModalBody, null, /*#__PURE__*/_react.default.createElement(_body.AutomationModalBody, {
65
69
  selectedRule: selectedRule,
66
70
  setSelectedRule: setSelectedRule
67
- })), /*#__PURE__*/_react.default.createElement(_modalDialog.ModalFooter, null, /*#__PURE__*/_react.default.createElement(_footer.AutomationModalFooter, {
71
+ })), /*#__PURE__*/_react.default.createElement(_executionStateMessage.AutomationModalExecutionState, null), /*#__PURE__*/_react.default.createElement(_modalDialog.ModalFooter, null, /*#__PURE__*/_react.default.createElement(_footer.AutomationModalFooter, {
68
72
  selectedRule: selectedRule,
69
73
  onClose: onClose
70
74
  })));
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.useAutomationMenu = exports.AutomationMenuContextContainer = void 0;
9
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
11
  var _react = _interopRequireWildcard(require("react"));
11
12
  var _manualTriggersContainer = require("../../manual-triggers-container");
12
13
  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); }
@@ -41,25 +42,40 @@ var AutomationMenuContextContainer = exports.AutomationMenuContextContainer = fu
41
42
  children = _ref2.children,
42
43
  emptyStateDescription = _ref2.emptyStateDescription,
43
44
  emptyStateAdminDescription = _ref2.emptyStateAdminDescription,
44
- onRuleInvocationSuccess = _ref2.onRuleInvocationSuccess,
45
- onRuleInvocationFailure = _ref2.onRuleInvocationFailure,
45
+ _onRuleInvocationSuccess = _ref2.onRuleInvocationSuccess,
46
+ _onRuleInvocationFailure = _ref2.onRuleInvocationFailure,
46
47
  onRuleInvocationLifecycleDone = _ref2.onRuleInvocationLifecycleDone;
48
+ var _useState = (0, _react.useState)('NONE'),
49
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
50
+ ruleExecutionState = _useState2[0],
51
+ setRuleExecutionState = _useState2[1];
47
52
  return /*#__PURE__*/_react.default.createElement(_manualTriggersContainer.ManualRulesContainer, {
48
53
  site: siteAri,
49
54
  query: {
50
55
  objects: [objectAri]
51
56
  },
57
+ onRuleInvocationLifecycleStarted: function onRuleInvocationLifecycleStarted() {
58
+ setRuleExecutionState('NONE');
59
+ },
52
60
  onRuleInvocationLifecycleDone: onRuleInvocationLifecycleDone,
53
- onRuleInvocationSuccess: onRuleInvocationSuccess,
54
- onRuleInvocationFailure: onRuleInvocationFailure
61
+ onRuleInvocationSuccess: function onRuleInvocationSuccess() {
62
+ setRuleExecutionState('SUCCEED');
63
+ _onRuleInvocationSuccess === null || _onRuleInvocationSuccess === void 0 || _onRuleInvocationSuccess();
64
+ },
65
+ onRuleInvocationFailure: function onRuleInvocationFailure() {
66
+ setRuleExecutionState('FAILURE');
67
+ _onRuleInvocationFailure === null || _onRuleInvocationFailure === void 0 || _onRuleInvocationFailure();
68
+ }
55
69
  }, function (props) {
56
70
  var contextValue = _objectSpread(_objectSpread({}, props), {}, {
71
+ fetchError: props.error,
57
72
  analyticsSource: analyticsSource,
58
73
  objectAri: objectAri,
59
74
  baseAutomationUrl: baseAutomationUrl,
60
75
  canManageAutomation: canManageAutomation,
61
76
  emptyStateDescription: emptyStateDescription,
62
- emptyStateAdminDescription: emptyStateAdminDescription
77
+ emptyStateAdminDescription: emptyStateAdminDescription,
78
+ ruleExecutionState: ruleExecutionState
63
79
  });
64
80
  return /*#__PURE__*/_react.default.createElement(AutomationMenuProvider, {
65
81
  value: contextValue
@@ -19,7 +19,7 @@ var AutomationModalBody = exports.AutomationModalBody = function AutomationModal
19
19
  triggerFetch = _useAutomationMenu.triggerFetch,
20
20
  initialised = _useAutomationMenu.initialised,
21
21
  rules = _useAutomationMenu.rules,
22
- error = _useAutomationMenu.error;
22
+ fetchError = _useAutomationMenu.fetchError;
23
23
  (0, _react.useEffect)(function () {
24
24
  void triggerFetch();
25
25
  // Want to ensure that triggerFetch is only called once when the component is mounted.
@@ -29,7 +29,7 @@ var AutomationModalBody = exports.AutomationModalBody = function AutomationModal
29
29
  return /*#__PURE__*/_react.default.createElement(_skeleton.Skeleton, {
30
30
  lineCount: 10
31
31
  });
32
- } else if (error && rules.length === 0) {
32
+ } else if (fetchError && rules.length === 0) {
33
33
  return /*#__PURE__*/_react.default.createElement(_errorState.AutomationModalErrorState, null);
34
34
  }
35
35
  return /*#__PURE__*/_react.default.createElement(_ruleList.AutomationModalRuleList, {
@@ -29,7 +29,7 @@ var imageContainerStyles = (0, _primitives.xcss)({
29
29
  display: 'block',
30
30
  maxWidth: '116px',
31
31
  maxHeight: '156px',
32
- marginBottom: "var(--ds-space-300, 24px)",
32
+ marginBottom: 'space.300',
33
33
  marginTop: 'space.050'
34
34
  });
35
35
  var descriptionStyles = (0, _primitives.xcss)({
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "AutomationModalExecutionState", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _main.AutomationModalExecutionState;
10
+ }
11
+ });
12
+ var _main = require("./main");
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.AutomationModalExecutionState = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _reactIntlNext = require("react-intl-next");
10
+ var _primitives = require("@atlaskit/primitives");
11
+ var _sectionMessage = _interopRequireDefault(require("@atlaskit/section-message"));
12
+ var _menuContext = require("../../menu-context");
13
+ var i18n = (0, _reactIntlNext.defineMessages)({
14
+ ruleExecutionSuccessMessage: {
15
+ id: 'automation-menu.success-state.message',
16
+ defaultMessage: 'Your automation is in progress',
17
+ description: 'Message that is displayed when a users automation rule has been successfully queued.'
18
+ },
19
+ ruleExecutionErrorMessage: {
20
+ id: 'automation-menu.modal.error.description',
21
+ defaultMessage: 'Oops we ran into a problem',
22
+ description: "Description for the error section shown when rules can't be executed"
23
+ }
24
+ });
25
+ var messageStyling = (0, _primitives.xcss)({
26
+ marginInline: 'space.300',
27
+ marginTop: 'space.100',
28
+ // The ModalFooter comes with a lot of built in margin, want to nudge the error message in to the footer a bit
29
+ marginBottom: 'space.negative.100'
30
+ });
31
+ var AutomationModalExecutionState = exports.AutomationModalExecutionState = function AutomationModalExecutionState() {
32
+ var _useAutomationMenu = (0, _menuContext.useAutomationMenu)(),
33
+ ruleExecutionState = _useAutomationMenu.ruleExecutionState;
34
+ if (ruleExecutionState === 'FAILURE') {
35
+ return /*#__PURE__*/_react.default.createElement(_primitives.Box, {
36
+ xcss: messageStyling
37
+ }, /*#__PURE__*/_react.default.createElement(_sectionMessage.default, {
38
+ appearance: "error"
39
+ }, /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, i18n.ruleExecutionErrorMessage)));
40
+ } else {
41
+ return null;
42
+ }
43
+ };
@@ -44,7 +44,7 @@ var AutomationModalFooter = exports.AutomationModalFooter = function AutomationM
44
44
  invokeRuleOrShowDialog = _useAutomationMenu.invokeRuleOrShowDialog,
45
45
  invokingRuleId = _useAutomationMenu.invokingRuleId,
46
46
  rules = _useAutomationMenu.rules,
47
- error = _useAutomationMenu.error,
47
+ fetchError = _useAutomationMenu.fetchError,
48
48
  baseAutomationUrl = _useAutomationMenu.baseAutomationUrl,
49
49
  analyticsSource = _useAutomationMenu.analyticsSource;
50
50
  var sendFooterAnalyticsEvent = function sendFooterAnalyticsEvent(actionSubjectId, ruleId) {
@@ -109,7 +109,7 @@ var AutomationModalFooter = exports.AutomationModalFooter = function AutomationM
109
109
  // Empty admin scenario -> cancel and Create Automation buttons
110
110
  // Empty end user and error scenario -> Ok button
111
111
  if (rules.length < 1) {
112
- if (error || !canManageAutomation) {
112
+ if (fetchError || !canManageAutomation) {
113
113
  modalButtons.push(okButton);
114
114
  } else {
115
115
  modalButtons.push(cancelButton, createAutomationButton);
@@ -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.3.0",
20
+ packageVersion: "27.4.1",
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
@@ -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: "27.3.0"
7
+ packageVersion: "27.4.1"
8
8
  };
9
9
  export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
10
10
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -2,9 +2,10 @@ import React, { useEffect, useState } from 'react';
2
2
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
3
3
  import Modal, { ModalBody, ModalFooter } from '@atlaskit/modal-dialog';
4
4
  import { AutomationMenuContextContainer } from './menu-context';
5
+ import { AutomationModalHeader } from './sub-components/header';
5
6
  import { AutomationModalBody } from './sub-components/body';
7
+ import { AutomationModalExecutionState } from './sub-components/execution-state-message';
6
8
  import { AutomationModalFooter } from './sub-components/footer';
7
- import { AutomationModalHeader } from './sub-components/header';
8
9
  export const AutomationModal = ({
9
10
  baseAutomationUrl,
10
11
  siteAri,
@@ -38,7 +39,8 @@ export const AutomationModal = ({
38
39
  analyticsSource: analyticsSource,
39
40
  emptyStateDescription: emptyStateDescription,
40
41
  emptyStateAdminDescription: emptyStateAdminDescription,
41
- onRuleInvocationLifecycleDone: onClose
42
+ onRuleInvocationSuccess: onClose,
43
+ onRuleInvocationFailure: () => setSelectedRule(undefined)
42
44
  }, () => {
43
45
  return /*#__PURE__*/React.createElement(Modal, {
44
46
  onClose: onClose,
@@ -52,7 +54,7 @@ export const AutomationModal = ({
52
54
  }), /*#__PURE__*/React.createElement(ModalBody, null, /*#__PURE__*/React.createElement(AutomationModalBody, {
53
55
  selectedRule: selectedRule,
54
56
  setSelectedRule: setSelectedRule
55
- })), /*#__PURE__*/React.createElement(ModalFooter, null, /*#__PURE__*/React.createElement(AutomationModalFooter, {
57
+ })), /*#__PURE__*/React.createElement(AutomationModalExecutionState, null), /*#__PURE__*/React.createElement(ModalFooter, null, /*#__PURE__*/React.createElement(AutomationModalFooter, {
56
58
  selectedRule: selectedRule,
57
59
  onClose: onClose
58
60
  })));
@@ -1,7 +1,7 @@
1
1
  // This is another layer on top of the AFE ManualRulesContainer.
2
2
  // It is necessary that this container wraps the entire "automation" component and not nested. Else the user input form will not render correctly.
3
3
  // This container provides an automation context to all children components through the useAutomationMenu hook.
4
- import React, { createContext, useContext } from 'react';
4
+ import React, { createContext, useContext, useState } from 'react';
5
5
  import { ManualRulesContainer } from '../../manual-triggers-container';
6
6
  const AutomationMenuContext = /*#__PURE__*/createContext(undefined);
7
7
  const AutomationMenuProvider = ({
@@ -34,23 +34,35 @@ export const AutomationMenuContextContainer = ({
34
34
  onRuleInvocationFailure,
35
35
  onRuleInvocationLifecycleDone
36
36
  }) => {
37
+ const [ruleExecutionState, setRuleExecutionState] = useState('NONE');
37
38
  return /*#__PURE__*/React.createElement(ManualRulesContainer, {
38
39
  site: siteAri,
39
40
  query: {
40
41
  objects: [objectAri]
41
42
  },
43
+ onRuleInvocationLifecycleStarted: () => {
44
+ setRuleExecutionState('NONE');
45
+ },
42
46
  onRuleInvocationLifecycleDone: onRuleInvocationLifecycleDone,
43
- onRuleInvocationSuccess: onRuleInvocationSuccess,
44
- onRuleInvocationFailure: onRuleInvocationFailure
47
+ onRuleInvocationSuccess: () => {
48
+ setRuleExecutionState('SUCCEED');
49
+ onRuleInvocationSuccess === null || onRuleInvocationSuccess === void 0 ? void 0 : onRuleInvocationSuccess();
50
+ },
51
+ onRuleInvocationFailure: () => {
52
+ setRuleExecutionState('FAILURE');
53
+ onRuleInvocationFailure === null || onRuleInvocationFailure === void 0 ? void 0 : onRuleInvocationFailure();
54
+ }
45
55
  }, props => {
46
56
  const contextValue = {
47
57
  ...props,
58
+ fetchError: props.error,
48
59
  analyticsSource,
49
60
  objectAri,
50
61
  baseAutomationUrl,
51
62
  canManageAutomation,
52
63
  emptyStateDescription,
53
- emptyStateAdminDescription
64
+ emptyStateAdminDescription,
65
+ ruleExecutionState
54
66
  };
55
67
  return /*#__PURE__*/React.createElement(AutomationMenuProvider, {
56
68
  value: contextValue
@@ -11,7 +11,7 @@ export const AutomationModalBody = ({
11
11
  triggerFetch,
12
12
  initialised,
13
13
  rules,
14
- error
14
+ fetchError
15
15
  } = useAutomationMenu();
16
16
  useEffect(() => {
17
17
  void triggerFetch();
@@ -22,7 +22,7 @@ export const AutomationModalBody = ({
22
22
  return /*#__PURE__*/React.createElement(Skeleton, {
23
23
  lineCount: 10
24
24
  });
25
- } else if (error && rules.length === 0) {
25
+ } else if (fetchError && rules.length === 0) {
26
26
  return /*#__PURE__*/React.createElement(AutomationModalErrorState, null);
27
27
  }
28
28
  return /*#__PURE__*/React.createElement(AutomationModalRuleList, {
@@ -22,7 +22,7 @@ const imageContainerStyles = xcss({
22
22
  display: 'block',
23
23
  maxWidth: '116px',
24
24
  maxHeight: '156px',
25
- marginBottom: "var(--ds-space-300, 24px)",
25
+ marginBottom: 'space.300',
26
26
  marginTop: 'space.050'
27
27
  });
28
28
  const descriptionStyles = xcss({
@@ -0,0 +1,2 @@
1
+ import { AutomationModalExecutionState } from './main';
2
+ export { AutomationModalExecutionState };
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import { defineMessages, FormattedMessage } from 'react-intl-next';
3
+ import { Box, xcss } from '@atlaskit/primitives';
4
+ import SectionMessage from '@atlaskit/section-message';
5
+ import { useAutomationMenu } from '../../menu-context';
6
+ const i18n = defineMessages({
7
+ ruleExecutionSuccessMessage: {
8
+ id: 'automation-menu.success-state.message',
9
+ defaultMessage: 'Your automation is in progress',
10
+ description: 'Message that is displayed when a users automation rule has been successfully queued.'
11
+ },
12
+ ruleExecutionErrorMessage: {
13
+ id: 'automation-menu.modal.error.description',
14
+ defaultMessage: 'Oops we ran into a problem',
15
+ description: "Description for the error section shown when rules can't be executed"
16
+ }
17
+ });
18
+ const messageStyling = xcss({
19
+ marginInline: 'space.300',
20
+ marginTop: 'space.100',
21
+ // The ModalFooter comes with a lot of built in margin, want to nudge the error message in to the footer a bit
22
+ marginBottom: 'space.negative.100'
23
+ });
24
+ export const AutomationModalExecutionState = () => {
25
+ const {
26
+ ruleExecutionState
27
+ } = useAutomationMenu();
28
+ if (ruleExecutionState === 'FAILURE') {
29
+ return /*#__PURE__*/React.createElement(Box, {
30
+ xcss: messageStyling
31
+ }, /*#__PURE__*/React.createElement(SectionMessage, {
32
+ appearance: "error"
33
+ }, /*#__PURE__*/React.createElement(FormattedMessage, i18n.ruleExecutionErrorMessage)));
34
+ } else {
35
+ return null;
36
+ }
37
+ };
@@ -39,7 +39,7 @@ export const AutomationModalFooter = ({
39
39
  invokeRuleOrShowDialog,
40
40
  invokingRuleId,
41
41
  rules,
42
- error,
42
+ fetchError,
43
43
  baseAutomationUrl,
44
44
  analyticsSource
45
45
  } = useAutomationMenu();
@@ -105,7 +105,7 @@ export const AutomationModalFooter = ({
105
105
  // Empty admin scenario -> cancel and Create Automation buttons
106
106
  // Empty end user and error scenario -> Ok button
107
107
  if (rules.length < 1) {
108
- if (error || !canManageAutomation) {
108
+ if (fetchError || !canManageAutomation) {
109
109
  modalButtons.push(okButton);
110
110
  } else {
111
111
  modalButtons.push(cancelButton, createAutomationButton);