@atlaskit/smart-card 27.3.0 → 27.4.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 (37) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/cjs/utils/analytics/analytics.js +1 -1
  3. package/dist/cjs/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/main.js +7 -3
  4. package/dist/cjs/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/menu-context/main.js +21 -5
  5. package/dist/cjs/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/body/main.js +2 -2
  6. package/dist/cjs/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/error-state/main.js +1 -1
  7. package/dist/cjs/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/execution-state-message/index.js +12 -0
  8. package/dist/cjs/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/execution-state-message/main.js +43 -0
  9. package/dist/cjs/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/footer/main.js +2 -2
  10. package/dist/cjs/view/LinkUrl/index.js +1 -1
  11. package/dist/es2019/utils/analytics/analytics.js +1 -1
  12. package/dist/es2019/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/main.js +5 -3
  13. package/dist/es2019/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/menu-context/main.js +16 -4
  14. package/dist/es2019/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/body/main.js +2 -2
  15. package/dist/es2019/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/error-state/main.js +1 -1
  16. package/dist/es2019/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/execution-state-message/index.js +2 -0
  17. package/dist/es2019/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/execution-state-message/main.js +37 -0
  18. package/dist/es2019/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/footer/main.js +2 -2
  19. package/dist/es2019/view/LinkUrl/index.js +1 -1
  20. package/dist/esm/utils/analytics/analytics.js +1 -1
  21. package/dist/esm/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/main.js +7 -3
  22. package/dist/esm/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/menu-context/main.js +22 -6
  23. package/dist/esm/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/body/main.js +2 -2
  24. package/dist/esm/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/error-state/main.js +1 -1
  25. package/dist/esm/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/execution-state-message/index.js +2 -0
  26. package/dist/esm/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/execution-state-message/main.js +36 -0
  27. package/dist/esm/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/footer/main.js +2 -2
  28. package/dist/esm/view/LinkUrl/index.js +1 -1
  29. package/dist/types/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/menu-context/index.d.ts +1 -1
  30. package/dist/types/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/menu-context/main.d.ts +4 -1
  31. 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
  32. 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
  33. package/dist/types-ts4.5/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/menu-context/index.d.ts +1 -1
  34. package/dist/types-ts4.5/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/menu-context/main.d.ts +4 -1
  35. 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
  36. 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
  37. package/package.json +2 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 27.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#104944](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/104944)
8
+ [`2254e1b73d47`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/2254e1b73d47) -
9
+ [ux] Error message for failed automation rule invocation.
10
+
3
11
  ## 27.3.0
4
12
 
5
13
  ### Minor Changes
@@ -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.0"
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
+ onRuleInvocationLifecycleDone: function onRuleInvocationLifecycleDone() {
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);
@@ -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.0",
21
21
  componentName: 'linkUrl'
22
22
  };
23
23
  var Link = (0, _click.withLinkClickedEvent)('a');
@@ -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.0"
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
+ onRuleInvocationLifecycleDone: () => 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);
@@ -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: "27.3.0",
10
+ packageVersion: "27.4.0",
11
11
  componentName: 'linkUrl'
12
12
  };
13
13
  const Link = withLinkClickedEvent('a');
@@ -15,7 +15,7 @@ export var ANALYTICS_CHANNEL = 'media';
15
15
  export var context = {
16
16
  componentName: 'smart-cards',
17
17
  packageName: "@atlaskit/smart-card",
18
- packageVersion: "27.3.0"
18
+ packageVersion: "27.4.0"
19
19
  };
20
20
  export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
21
21
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -3,9 +3,10 @@ import React, { useEffect, useState } from 'react';
3
3
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
4
4
  import Modal, { ModalBody, ModalFooter } from '@atlaskit/modal-dialog';
5
5
  import { AutomationMenuContextContainer } from './menu-context';
6
+ import { AutomationModalHeader } from './sub-components/header';
6
7
  import { AutomationModalBody } from './sub-components/body';
8
+ import { AutomationModalExecutionState } from './sub-components/execution-state-message';
7
9
  import { AutomationModalFooter } from './sub-components/footer';
8
- import { AutomationModalHeader } from './sub-components/header';
9
10
  export var AutomationModal = function AutomationModal(_ref) {
10
11
  var baseAutomationUrl = _ref.baseAutomationUrl,
11
12
  siteAri = _ref.siteAri,
@@ -40,7 +41,10 @@ export var AutomationModal = function AutomationModal(_ref) {
40
41
  analyticsSource: analyticsSource,
41
42
  emptyStateDescription: emptyStateDescription,
42
43
  emptyStateAdminDescription: emptyStateAdminDescription,
43
- onRuleInvocationLifecycleDone: onClose
44
+ onRuleInvocationSuccess: onClose,
45
+ onRuleInvocationLifecycleDone: function onRuleInvocationLifecycleDone() {
46
+ return setSelectedRule(undefined);
47
+ }
44
48
  }, function () {
45
49
  return /*#__PURE__*/React.createElement(Modal, {
46
50
  onClose: onClose,
@@ -54,7 +58,7 @@ export var AutomationModal = function AutomationModal(_ref) {
54
58
  }), /*#__PURE__*/React.createElement(ModalBody, null, /*#__PURE__*/React.createElement(AutomationModalBody, {
55
59
  selectedRule: selectedRule,
56
60
  setSelectedRule: setSelectedRule
57
- })), /*#__PURE__*/React.createElement(ModalFooter, null, /*#__PURE__*/React.createElement(AutomationModalFooter, {
61
+ })), /*#__PURE__*/React.createElement(AutomationModalExecutionState, null), /*#__PURE__*/React.createElement(ModalFooter, null, /*#__PURE__*/React.createElement(AutomationModalFooter, {
58
62
  selectedRule: selectedRule,
59
63
  onClose: onClose
60
64
  })));
@@ -1,10 +1,11 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
3
  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; }
3
4
  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) { _defineProperty(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; }
4
5
  // This is another layer on top of the AFE ManualRulesContainer.
5
6
  // It is necessary that this container wraps the entire "automation" component and not nested. Else the user input form will not render correctly.
6
7
  // This container provides an automation context to all children components through the useAutomationMenu hook.
7
- import React, { createContext, useContext } from 'react';
8
+ import React, { createContext, useContext, useState } from 'react';
8
9
  import { ManualRulesContainer } from '../../manual-triggers-container';
9
10
  var AutomationMenuContext = /*#__PURE__*/createContext(undefined);
10
11
  var AutomationMenuProvider = function AutomationMenuProvider(_ref) {
@@ -32,25 +33,40 @@ export var AutomationMenuContextContainer = function AutomationMenuContextContai
32
33
  children = _ref2.children,
33
34
  emptyStateDescription = _ref2.emptyStateDescription,
34
35
  emptyStateAdminDescription = _ref2.emptyStateAdminDescription,
35
- onRuleInvocationSuccess = _ref2.onRuleInvocationSuccess,
36
- onRuleInvocationFailure = _ref2.onRuleInvocationFailure,
36
+ _onRuleInvocationSuccess = _ref2.onRuleInvocationSuccess,
37
+ _onRuleInvocationFailure = _ref2.onRuleInvocationFailure,
37
38
  onRuleInvocationLifecycleDone = _ref2.onRuleInvocationLifecycleDone;
39
+ var _useState = useState('NONE'),
40
+ _useState2 = _slicedToArray(_useState, 2),
41
+ ruleExecutionState = _useState2[0],
42
+ setRuleExecutionState = _useState2[1];
38
43
  return /*#__PURE__*/React.createElement(ManualRulesContainer, {
39
44
  site: siteAri,
40
45
  query: {
41
46
  objects: [objectAri]
42
47
  },
48
+ onRuleInvocationLifecycleStarted: function onRuleInvocationLifecycleStarted() {
49
+ setRuleExecutionState('NONE');
50
+ },
43
51
  onRuleInvocationLifecycleDone: onRuleInvocationLifecycleDone,
44
- onRuleInvocationSuccess: onRuleInvocationSuccess,
45
- onRuleInvocationFailure: onRuleInvocationFailure
52
+ onRuleInvocationSuccess: function onRuleInvocationSuccess() {
53
+ setRuleExecutionState('SUCCEED');
54
+ _onRuleInvocationSuccess === null || _onRuleInvocationSuccess === void 0 || _onRuleInvocationSuccess();
55
+ },
56
+ onRuleInvocationFailure: function onRuleInvocationFailure() {
57
+ setRuleExecutionState('FAILURE');
58
+ _onRuleInvocationFailure === null || _onRuleInvocationFailure === void 0 || _onRuleInvocationFailure();
59
+ }
46
60
  }, function (props) {
47
61
  var contextValue = _objectSpread(_objectSpread({}, props), {}, {
62
+ fetchError: props.error,
48
63
  analyticsSource: analyticsSource,
49
64
  objectAri: objectAri,
50
65
  baseAutomationUrl: baseAutomationUrl,
51
66
  canManageAutomation: canManageAutomation,
52
67
  emptyStateDescription: emptyStateDescription,
53
- emptyStateAdminDescription: emptyStateAdminDescription
68
+ emptyStateAdminDescription: emptyStateAdminDescription,
69
+ ruleExecutionState: ruleExecutionState
54
70
  });
55
71
  return /*#__PURE__*/React.createElement(AutomationMenuProvider, {
56
72
  value: contextValue
@@ -10,7 +10,7 @@ export var AutomationModalBody = function AutomationModalBody(_ref) {
10
10
  triggerFetch = _useAutomationMenu.triggerFetch,
11
11
  initialised = _useAutomationMenu.initialised,
12
12
  rules = _useAutomationMenu.rules,
13
- error = _useAutomationMenu.error;
13
+ fetchError = _useAutomationMenu.fetchError;
14
14
  useEffect(function () {
15
15
  void triggerFetch();
16
16
  // Want to ensure that triggerFetch is only called once when the component is mounted.
@@ -20,7 +20,7 @@ export var AutomationModalBody = function AutomationModalBody(_ref) {
20
20
  return /*#__PURE__*/React.createElement(Skeleton, {
21
21
  lineCount: 10
22
22
  });
23
- } else if (error && rules.length === 0) {
23
+ } else if (fetchError && rules.length === 0) {
24
24
  return /*#__PURE__*/React.createElement(AutomationModalErrorState, null);
25
25
  }
26
26
  return /*#__PURE__*/React.createElement(AutomationModalRuleList, {
@@ -22,7 +22,7 @@ var 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
  var descriptionStyles = xcss({
@@ -0,0 +1,2 @@
1
+ import { AutomationModalExecutionState } from './main';
2
+ export { AutomationModalExecutionState };
@@ -0,0 +1,36 @@
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
+ var 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
+ var 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 var AutomationModalExecutionState = function AutomationModalExecutionState() {
25
+ var _useAutomationMenu = useAutomationMenu(),
26
+ ruleExecutionState = _useAutomationMenu.ruleExecutionState;
27
+ if (ruleExecutionState === 'FAILURE') {
28
+ return /*#__PURE__*/React.createElement(Box, {
29
+ xcss: messageStyling
30
+ }, /*#__PURE__*/React.createElement(SectionMessage, {
31
+ appearance: "error"
32
+ }, /*#__PURE__*/React.createElement(FormattedMessage, i18n.ruleExecutionErrorMessage)));
33
+ } else {
34
+ return null;
35
+ }
36
+ };
@@ -37,7 +37,7 @@ export var AutomationModalFooter = function AutomationModalFooter(_ref) {
37
37
  invokeRuleOrShowDialog = _useAutomationMenu.invokeRuleOrShowDialog,
38
38
  invokingRuleId = _useAutomationMenu.invokingRuleId,
39
39
  rules = _useAutomationMenu.rules,
40
- error = _useAutomationMenu.error,
40
+ fetchError = _useAutomationMenu.fetchError,
41
41
  baseAutomationUrl = _useAutomationMenu.baseAutomationUrl,
42
42
  analyticsSource = _useAutomationMenu.analyticsSource;
43
43
  var sendFooterAnalyticsEvent = function sendFooterAnalyticsEvent(actionSubjectId, ruleId) {
@@ -102,7 +102,7 @@ export var AutomationModalFooter = function AutomationModalFooter(_ref) {
102
102
  // Empty admin scenario -> cancel and Create Automation buttons
103
103
  // Empty end user and error scenario -> Ok button
104
104
  if (rules.length < 1) {
105
- if (error || !canManageAutomation) {
105
+ if (fetchError || !canManageAutomation) {
106
106
  modalButtons.push(okButton);
107
107
  } else {
108
108
  modalButtons.push(cancelButton, createAutomationButton);
@@ -10,7 +10,7 @@ import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-m
10
10
  import LinkWarningModal from './LinkWarningModal';
11
11
  var PACKAGE_DATA = {
12
12
  packageName: "@atlaskit/smart-card",
13
- packageVersion: "27.3.0",
13
+ packageVersion: "27.4.0",
14
14
  componentName: 'linkUrl'
15
15
  };
16
16
  var Link = withLinkClickedEvent('a');
@@ -1 +1 @@
1
- export { AutomationMenuContextContainer, useAutomationMenu, } from './main';
1
+ export { AutomationMenuContextContainer, useAutomationMenu, type RuleExecutionState, } from './main';
@@ -13,13 +13,16 @@ type AutomationMenuContextContainerProps = {
13
13
  onRuleInvocationFailure?: () => void;
14
14
  onRuleInvocationLifecycleDone?: () => void;
15
15
  };
16
- export type MenuContext = ManualRulesData & {
16
+ export type RuleExecutionState = 'SUCCEED' | 'FAILURE' | 'NONE';
17
+ export type MenuContext = Omit<ManualRulesData, 'error'> & {
18
+ fetchError: any;
17
19
  analyticsSource: string;
18
20
  objectAri: string;
19
21
  baseAutomationUrl: string;
20
22
  canManageAutomation: boolean;
21
23
  emptyStateDescription?: React.ReactNode;
22
24
  emptyStateAdminDescription?: React.ReactNode;
25
+ ruleExecutionState: RuleExecutionState;
23
26
  };
24
27
  export declare const useAutomationMenu: () => MenuContext;
25
28
  export declare const AutomationMenuContextContainer: ({ baseAutomationUrl, analyticsSource, objectAri, siteAri, canManageAutomation, children, emptyStateDescription, emptyStateAdminDescription, onRuleInvocationSuccess, onRuleInvocationFailure, onRuleInvocationLifecycleDone, }: AutomationMenuContextContainerProps) => JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { AutomationModalExecutionState } from './main';
2
+ export { AutomationModalExecutionState };
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const AutomationModalExecutionState: () => JSX.Element | null;
@@ -1 +1 @@
1
- export { AutomationMenuContextContainer, useAutomationMenu, } from './main';
1
+ export { AutomationMenuContextContainer, useAutomationMenu, type RuleExecutionState, } from './main';
@@ -13,13 +13,16 @@ type AutomationMenuContextContainerProps = {
13
13
  onRuleInvocationFailure?: () => void;
14
14
  onRuleInvocationLifecycleDone?: () => void;
15
15
  };
16
- export type MenuContext = ManualRulesData & {
16
+ export type RuleExecutionState = 'SUCCEED' | 'FAILURE' | 'NONE';
17
+ export type MenuContext = Omit<ManualRulesData, 'error'> & {
18
+ fetchError: any;
17
19
  analyticsSource: string;
18
20
  objectAri: string;
19
21
  baseAutomationUrl: string;
20
22
  canManageAutomation: boolean;
21
23
  emptyStateDescription?: React.ReactNode;
22
24
  emptyStateAdminDescription?: React.ReactNode;
25
+ ruleExecutionState: RuleExecutionState;
23
26
  };
24
27
  export declare const useAutomationMenu: () => MenuContext;
25
28
  export declare const AutomationMenuContextContainer: ({ baseAutomationUrl, analyticsSource, objectAri, siteAri, canManageAutomation, children, emptyStateDescription, emptyStateAdminDescription, onRuleInvocationSuccess, onRuleInvocationFailure, onRuleInvocationLifecycleDone, }: AutomationMenuContextContainerProps) => JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { AutomationModalExecutionState } from './main';
2
+ export { AutomationModalExecutionState };
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const AutomationModalExecutionState: () => JSX.Element | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "27.3.0",
3
+ "version": "27.4.0",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -56,6 +56,7 @@
56
56
  "@atlaskit/platform-feature-flags": "^0.2.1",
57
57
  "@atlaskit/popup": "^1.17.0",
58
58
  "@atlaskit/primitives": "^6.3.0",
59
+ "@atlaskit/section-message": "^6.5.0",
59
60
  "@atlaskit/select": "^17.10.0",
60
61
  "@atlaskit/spinner": "^16.1.0",
61
62
  "@atlaskit/textarea": "^5.4.0",