@atlaskit/smart-card 25.7.0 → 25.7.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 (27) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cjs/messages.js +20 -0
  3. package/dist/cjs/state/hooks/use-invoke/types.js +1 -17
  4. package/dist/cjs/version.json +1 -1
  5. package/dist/cjs/view/FlexibleCard/components/common/lozenge-action/index.js +38 -29
  6. package/dist/cjs/view/FlexibleCard/components/common/lozenge-action/lozenge-action-error/index.js +33 -12
  7. package/dist/cjs/view/FlexibleCard/components/common/lozenge-action/lozenge-action-error/styled.js +21 -0
  8. package/dist/cjs/view/FlexibleCard/components/common/lozenge-action/lozenge-action-error/types.js +15 -1
  9. package/dist/es2019/messages.js +20 -0
  10. package/dist/es2019/state/hooks/use-invoke/types.js +1 -15
  11. package/dist/es2019/version.json +1 -1
  12. package/dist/es2019/view/FlexibleCard/components/common/lozenge-action/index.js +18 -11
  13. package/dist/es2019/view/FlexibleCard/components/common/lozenge-action/lozenge-action-error/index.js +30 -7
  14. package/dist/es2019/view/FlexibleCard/components/common/lozenge-action/lozenge-action-error/styled.js +41 -0
  15. package/dist/es2019/view/FlexibleCard/components/common/lozenge-action/lozenge-action-error/types.js +12 -1
  16. package/dist/esm/messages.js +20 -0
  17. package/dist/esm/state/hooks/use-invoke/types.js +1 -15
  18. package/dist/esm/version.json +1 -1
  19. package/dist/esm/view/FlexibleCard/components/common/lozenge-action/index.js +38 -29
  20. package/dist/esm/view/FlexibleCard/components/common/lozenge-action/lozenge-action-error/index.js +30 -8
  21. package/dist/esm/view/FlexibleCard/components/common/lozenge-action/lozenge-action-error/styled.js +11 -0
  22. package/dist/esm/view/FlexibleCard/components/common/lozenge-action/lozenge-action-error/types.js +12 -1
  23. package/dist/types/messages.d.ts +1 -1
  24. package/dist/types/state/hooks/use-invoke/types.d.ts +0 -4
  25. package/dist/types/view/FlexibleCard/components/common/lozenge-action/lozenge-action-error/styled.d.ts +3 -0
  26. package/dist/types/view/FlexibleCard/components/common/lozenge-action/lozenge-action-error/types.d.ts +14 -2
  27. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 25.7.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`7a58d99e333`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7a58d99e333) - [ux] Added error handling for smart link action
8
+ - Updated dependencies
9
+
3
10
  ## 25.7.0
4
11
 
5
12
  ### Minor Changes
@@ -206,6 +206,11 @@ var messages = (0, _reactIntlNext.defineMessages)({
206
206
  defaultMessage: "Uh oh. We can't find this link!",
207
207
  description: 'Error case for when a provided link is not found'
208
208
  },
209
+ open_issue_in_jira: {
210
+ id: 'fabric.linking.open_issue_in_jira',
211
+ defaultMessage: 'Open issue in Jira',
212
+ description: 'Click to open link in Jira'
213
+ },
209
214
  open_link_in_a_new_tab: {
210
215
  id: 'fabric.linking.open_link_in_a_new_tab',
211
216
  defaultMessage: 'Open link in a new tab',
@@ -351,6 +356,21 @@ var messages = (0, _reactIntlNext.defineMessages)({
351
356
  defaultMessage: 'Save',
352
357
  description: 'Just the "save" word'
353
358
  },
359
+ status_change_load_error: {
360
+ id: 'fabric.linking.status_change_load_error',
361
+ defaultMessage: 'We couldn’t load the statuses and transitions',
362
+ description: 'Informs the user that the loading of status transitions failed'
363
+ },
364
+ status_change_permission_error: {
365
+ id: 'fabric.linking.status_change_permission_error',
366
+ defaultMessage: 'You don’t have permission to transition this issue. ',
367
+ description: 'Informs the user that they do not have enough permissions to update a status'
368
+ },
369
+ status_change_update_error: {
370
+ id: 'fabric.linking.status_change_update_error',
371
+ defaultMessage: 'We couldn’t update the status',
372
+ description: "Occurs when a user tries to update an issue's status but fails to do so"
373
+ },
354
374
  try_again: {
355
375
  id: 'fabric.linking.try_again',
356
376
  defaultMessage: 'Try again',
@@ -2,20 +2,4 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
- });
6
- exports.InvokeActionError = void 0;
7
- var InvokeActionError;
8
- /**
9
- * Additional details for invoke function that may be required for component
10
- */
11
- exports.InvokeActionError = InvokeActionError;
12
- (function (InvokeActionError) {
13
- InvokeActionError["NoData"] = "NoData";
14
- InvokeActionError["Unknown"] = "Unknown";
15
- })(InvokeActionError || (exports.InvokeActionError = InvokeActionError = {}));
16
- /**
17
- * Invoke request with additional details for the component
18
- */
19
- /**
20
- * CRUD invoke requests for the component that support server actions
21
- */
5
+ });
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "25.7.0",
3
+ "version": "25.7.1",
4
4
  "sideEffects": false
5
5
  }
@@ -18,10 +18,10 @@ var _lozengeActionError = _interopRequireDefault(require("./lozenge-action-error
18
18
  var _errorBoundary = _interopRequireDefault(require("./error-boundary"));
19
19
  var _styled = require("./styled");
20
20
  var _useInvoke = _interopRequireDefault(require("../../../../../state/hooks/use-invoke"));
21
- var _types = require("../../../../../state/hooks/use-invoke/types");
22
21
  var _extractLozengeActionItems = _interopRequireDefault(require("../../../../../extractors/action/extract-lozenge-action-items"));
23
22
  var _createStatusUpdateRequest = _interopRequireDefault(require("../../../../../utils/actions/create-status-update-request"));
24
23
  var _useResolve = _interopRequireDefault(require("../../../../../state/hooks/use-resolve"));
24
+ var _types = require("./lozenge-action-error/types");
25
25
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
26
26
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
27
27
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; } /** @jsx jsx */
@@ -32,6 +32,9 @@ var validateItems = function validateItems() {
32
32
  return item.text !== text;
33
33
  });
34
34
  };
35
+ var isInvokeCustomError = function isInvokeCustomError(err) {
36
+ return err.message !== undefined && err.errorCode !== undefined;
37
+ };
35
38
  var LozengeAction = function LozengeAction(_ref) {
36
39
  var action = _ref.action,
37
40
  appearance = _ref.appearance,
@@ -57,8 +60,8 @@ var LozengeAction = function LozengeAction(_ref) {
57
60
  setItems = _useState8[1];
58
61
  var _useState9 = (0, _react2.useState)(),
59
62
  _useState10 = (0, _slicedToArray2.default)(_useState9, 2),
60
- errorCode = _useState10[0],
61
- setErrorCode = _useState10[1];
63
+ errorMessage = _useState10[0],
64
+ setErrorMessage = _useState10[1];
62
65
  var invoke = (0, _useInvoke.default)();
63
66
  var reload = (0, _useResolve.default)();
64
67
  var handleOpenChange = (0, _react2.useCallback)( /*#__PURE__*/function () {
@@ -70,7 +73,7 @@ var LozengeAction = function LozengeAction(_ref) {
70
73
  case 0:
71
74
  setIsOpen(args.isOpen);
72
75
  if (!(args.isOpen && !isLoaded && action !== null && action !== void 0 && action.read)) {
73
- _context.next = 19;
76
+ _context.next = 20;
74
77
  break;
75
78
  }
76
79
  _context.prev = 2;
@@ -83,29 +86,30 @@ var LozengeAction = function LozengeAction(_ref) {
83
86
  setItems(validItems);
84
87
  setIsLoaded(true);
85
88
  if ((validItems === null || validItems === void 0 ? void 0 : validItems.length) === 0) {
86
- setErrorCode(_types.InvokeActionError.NoData);
89
+ setErrorMessage(_types.LozengeActionErrorMessages.noData);
90
+ setIsLoaded(false);
87
91
  }
88
- _context.next = 16;
92
+ _context.next = 17;
89
93
  break;
90
94
  case 13:
91
95
  _context.prev = 13;
92
96
  _context.t0 = _context["catch"](2);
93
- // TODO: EDM-6261: Error state
94
- setErrorCode(_types.InvokeActionError.Unknown);
95
- case 16:
96
- _context.prev = 16;
97
+ setErrorMessage(_types.LozengeActionErrorMessages.unknown);
98
+ setIsLoaded(false);
99
+ case 17:
100
+ _context.prev = 17;
97
101
  setIsLoading(false);
98
- return _context.finish(16);
99
- case 19:
102
+ return _context.finish(17);
103
+ case 20:
100
104
  if (!args.isOpen) {
101
- setErrorCode(undefined);
105
+ setErrorMessage(undefined);
102
106
  }
103
- case 20:
107
+ case 21:
104
108
  case "end":
105
109
  return _context.stop();
106
110
  }
107
111
  }
108
- }, _callee, null, [[2, 13, 16, 19]]);
112
+ }, _callee, null, [[2, 13, 17, 20]]);
109
113
  }));
110
114
  return function (_x) {
111
115
  return _ref2.apply(this, arguments);
@@ -128,7 +132,7 @@ var LozengeAction = function LozengeAction(_ref) {
128
132
  _context2.prev = 0;
129
133
  updateAction = action === null || action === void 0 ? void 0 : action.update;
130
134
  if (!(updateAction && id)) {
131
- _context2.next = 13;
135
+ _context2.next = 15;
132
136
  break;
133
137
  }
134
138
  setIsLoading(true);
@@ -137,38 +141,43 @@ var LozengeAction = function LozengeAction(_ref) {
137
141
  return invoke(request);
138
142
  case 7:
139
143
  setIsLoading(false);
144
+ setIsLoaded(false);
140
145
  setIsOpen(false);
146
+ setItems([]);
141
147
  _ref4 = updateAction.details || {}, url = _ref4.url, linkId = _ref4.id;
142
148
  if (!url) {
143
- _context2.next = 13;
149
+ _context2.next = 15;
144
150
  break;
145
151
  }
146
- _context2.next = 13;
152
+ _context2.next = 15;
147
153
  return reload(url, true, undefined, linkId);
148
- case 13:
149
- _context2.next = 19;
150
- break;
151
154
  case 15:
152
- _context2.prev = 15;
155
+ _context2.next = 21;
156
+ break;
157
+ case 17:
158
+ _context2.prev = 17;
153
159
  _context2.t0 = _context2["catch"](0);
154
- // TODO: EDM-6261: Error state
155
160
  setIsLoading(false);
156
- setErrorCode(_types.InvokeActionError.Unknown);
157
- case 19:
161
+ if (isInvokeCustomError(_context2.t0)) {
162
+ setErrorMessage(_context2.t0.message);
163
+ } else {
164
+ setErrorMessage(_types.LozengeActionErrorMessages.updateFailed);
165
+ }
166
+ case 21:
158
167
  case "end":
159
168
  return _context2.stop();
160
169
  }
161
170
  }
162
- }, _callee2, null, [[0, 15]]);
171
+ }, _callee2, null, [[0, 17]]);
163
172
  }));
164
173
  return function (_x2) {
165
174
  return _ref3.apply(this, arguments);
166
175
  };
167
176
  }(), [action === null || action === void 0 ? void 0 : action.update, invoke, reload]);
168
177
  var dropdownItemGroup = (0, _react2.useMemo)(function () {
169
- if (errorCode) {
178
+ if (errorMessage) {
170
179
  return (0, _react.jsx)(_lozengeActionError.default, {
171
- errorCode: errorCode,
180
+ errorMessage: errorMessage,
172
181
  testId: testId
173
182
  });
174
183
  }
@@ -184,7 +193,7 @@ var LozengeAction = function LozengeAction(_ref) {
184
193
  }));
185
194
  })));
186
195
  }
187
- }, [errorCode, handleItemClick, items, testId]);
196
+ }, [errorMessage, handleItemClick, items, testId]);
188
197
  return (0, _react.jsx)(_dropdownMenu.default, {
189
198
  isLoading: isLoading,
190
199
  isOpen: isOpen,
@@ -1,24 +1,45 @@
1
1
  "use strict";
2
2
 
3
- var _typeof = require("@babel/runtime/helpers/typeof");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _react = _interopRequireWildcard(require("react"));
8
+ var _react = require("@emotion/react");
9
+ var _react2 = require("react");
9
10
  var _dropdownMenu = require("@atlaskit/dropdown-menu");
10
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
11
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
11
+ var _colors = require("@atlaskit/theme/colors");
12
+ var _error = _interopRequireDefault(require("@atlaskit/icon/glyph/error"));
13
+ var _styled = require("./styled");
14
+ var _utils = require("../../../utils");
15
+ /** @jsx jsx */
16
+
17
+ var MAX_LINE_NUMBER = 8;
12
18
  var LozengeActionError = function LozengeActionError(_ref) {
13
- var errorCode = _ref.errorCode,
14
- testId = _ref.testId;
15
- // TODO: EDM-5746 and EDM-5782
16
- var content = (0, _react.useMemo)(function () {
17
- return errorCode;
18
- }, [errorCode]);
19
- return /*#__PURE__*/_react.default.createElement(_dropdownMenu.DropdownItemGroup, null, /*#__PURE__*/_react.default.createElement(_dropdownMenu.DropdownItem, {
19
+ var errorMessage = _ref.errorMessage,
20
+ testId = _ref.testId,
21
+ _ref$maxLineNumber = _ref.maxLineNumber,
22
+ maxLineNumber = _ref$maxLineNumber === void 0 ? MAX_LINE_NUMBER : _ref$maxLineNumber;
23
+ var content = (0, _react2.useMemo)(function () {
24
+ return (0, _react.jsx)(_react2.Fragment, null, (0, _react.jsx)("div", {
25
+ css: _styled.contentStyles
26
+ }, (0, _react.jsx)(_error.default, {
27
+ testId: "".concat(testId, "-icon"),
28
+ size: "medium",
29
+ primaryColor: "var(--ds-icon-danger, ".concat(_colors.R500, ")"),
30
+ secondaryColor: "var(--ds-background-danger, ".concat(_colors.R50, ")"),
31
+ label: 'error'
32
+ }), (0, _react.jsx)("span", {
33
+ css: (0, _styled.textStyles)(maxLineNumber),
34
+ "data-testid": "".concat(testId, "-error-message")
35
+ }, typeof errorMessage === 'string' ? errorMessage : (0, _utils.getFormattedMessage)(errorMessage))));
36
+ }, [errorMessage, maxLineNumber, testId]);
37
+ return (0, _react.jsx)("span", {
38
+ css: _styled.dropdownItemGroupStyles,
39
+ "data-testid": "".concat(testId, "-error-item-group")
40
+ }, (0, _react.jsx)(_dropdownMenu.DropdownItemGroup, null, (0, _react.jsx)(_dropdownMenu.DropdownItem, {
20
41
  testId: "".concat(testId, "-error")
21
- }, content));
42
+ }, content)));
22
43
  };
23
44
  var _default = LozengeActionError;
24
45
  exports.default = _default;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.textStyles = exports.dropdownItemGroupStyles = exports.contentStyles = void 0;
8
+ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
9
+ var _react = require("@emotion/react");
10
+ var _colors = require("@atlaskit/theme/colors");
11
+ var _utils = require("../../../utils");
12
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4;
13
+ var dropdownItemGroupStyles = (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n button {\n width: 220px;\n\n &:hover {\n background-color: inherit;\n cursor: default;\n }\n }\n"])));
14
+ exports.dropdownItemGroupStyles = dropdownItemGroupStyles;
15
+ var sharedBlockStyles = (0, _react.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n gap: 0.5rem;\n line-height: 1rem;\n min-width: 0;\n overflow: hidden;\n flex-direction: row;\n align-items: center;\n"])));
16
+ var contentStyles = (0, _react.css)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n ", ";\n\n margin-top: 2px;\n align-items: flex-start;\n\n > span,\n > div {\n &[data-smart-element-text] {\n font-size: 0.875rem;\n color: ", ";\n }\n }\n"])), sharedBlockStyles, "var(--ds-text, ".concat(_colors.N800, ")"));
17
+ exports.contentStyles = contentStyles;
18
+ var textStyles = function textStyles(maxLines) {
19
+ return (0, _react.css)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n line-height: 1rem;\n white-space: normal;\n ", ";\n"])), (0, _utils.getTruncateStyles)(maxLines));
20
+ };
21
+ exports.textStyles = textStyles;
@@ -2,4 +2,18 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
- });
5
+ });
6
+ exports.LozengeActionErrorMessages = void 0;
7
+ var _messages = require("../../../../../../messages");
8
+ var LozengeActionErrorMessages = {
9
+ noData: {
10
+ descriptor: _messages.messages['status_change_permission_error']
11
+ },
12
+ unknown: {
13
+ descriptor: _messages.messages['status_change_load_error']
14
+ },
15
+ updateFailed: {
16
+ descriptor: _messages.messages['status_change_update_error']
17
+ }
18
+ };
19
+ exports.LozengeActionErrorMessages = LozengeActionErrorMessages;
@@ -200,6 +200,11 @@ export const messages = defineMessages({
200
200
  defaultMessage: "Uh oh. We can't find this link!",
201
201
  description: 'Error case for when a provided link is not found'
202
202
  },
203
+ open_issue_in_jira: {
204
+ id: 'fabric.linking.open_issue_in_jira',
205
+ defaultMessage: 'Open issue in Jira',
206
+ description: 'Click to open link in Jira'
207
+ },
203
208
  open_link_in_a_new_tab: {
204
209
  id: 'fabric.linking.open_link_in_a_new_tab',
205
210
  defaultMessage: 'Open link in a new tab',
@@ -345,6 +350,21 @@ export const messages = defineMessages({
345
350
  defaultMessage: 'Save',
346
351
  description: 'Just the "save" word'
347
352
  },
353
+ status_change_load_error: {
354
+ id: 'fabric.linking.status_change_load_error',
355
+ defaultMessage: 'We couldn’t load the statuses and transitions',
356
+ description: 'Informs the user that the loading of status transitions failed'
357
+ },
358
+ status_change_permission_error: {
359
+ id: 'fabric.linking.status_change_permission_error',
360
+ defaultMessage: 'You don’t have permission to transition this issue. ',
361
+ description: 'Informs the user that they do not have enough permissions to update a status'
362
+ },
363
+ status_change_update_error: {
364
+ id: 'fabric.linking.status_change_update_error',
365
+ defaultMessage: 'We couldn’t update the status',
366
+ description: "Occurs when a user tries to update an issue's status but fails to do so"
367
+ },
348
368
  try_again: {
349
369
  id: 'fabric.linking.try_again',
350
370
  defaultMessage: 'Try again',
@@ -1,15 +1 @@
1
- export let InvokeActionError;
2
-
3
- /**
4
- * Additional details for invoke function that may be required for component
5
- */
6
- (function (InvokeActionError) {
7
- InvokeActionError["NoData"] = "NoData";
8
- InvokeActionError["Unknown"] = "Unknown";
9
- })(InvokeActionError || (InvokeActionError = {}));
10
- /**
11
- * Invoke request with additional details for the component
12
- */
13
- /**
14
- * CRUD invoke requests for the component that support server actions
15
- */
1
+ export {};
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "25.7.0",
3
+ "version": "25.7.1",
4
4
  "sideEffects": false
5
5
  }
@@ -9,13 +9,14 @@ import LozengeActionError from './lozenge-action-error';
9
9
  import withErrorBoundary from './error-boundary';
10
10
  import { dropdownItemGroupStyles } from './styled';
11
11
  import useInvoke from '../../../../../state/hooks/use-invoke';
12
- import { InvokeActionError } from '../../../../../state/hooks/use-invoke/types';
13
12
  import extractLozengeActionItems from '../../../../../extractors/action/extract-lozenge-action-items';
14
13
  import createStatusUpdateRequest from '../../../../../utils/actions/create-status-update-request';
15
14
  import useResolve from '../../../../../state/hooks/use-resolve';
15
+ import { LozengeActionErrorMessages } from './lozenge-action-error/types';
16
16
  const validateItems = (items = [], text) => {
17
17
  return items.filter(item => item.text !== text);
18
18
  };
19
+ const isInvokeCustomError = err => err.message !== undefined && err.errorCode !== undefined;
19
20
  const LozengeAction = ({
20
21
  action,
21
22
  appearance,
@@ -27,7 +28,7 @@ const LozengeAction = ({
27
28
  const [isLoading, setIsLoading] = useState(false);
28
29
  const [isOpen, setIsOpen] = useState(false);
29
30
  const [items, setItems] = useState();
30
- const [errorCode, setErrorCode] = useState();
31
+ const [errorMessage, setErrorMessage] = useState();
31
32
  const invoke = useInvoke();
32
33
  const reload = useResolve();
33
34
  const handleOpenChange = useCallback(async args => {
@@ -40,17 +41,18 @@ const LozengeAction = ({
40
41
  setItems(validItems);
41
42
  setIsLoaded(true);
42
43
  if ((validItems === null || validItems === void 0 ? void 0 : validItems.length) === 0) {
43
- setErrorCode(InvokeActionError.NoData);
44
+ setErrorMessage(LozengeActionErrorMessages.noData);
45
+ setIsLoaded(false);
44
46
  }
45
47
  } catch (err) {
46
- // TODO: EDM-6261: Error state
47
- setErrorCode(InvokeActionError.Unknown);
48
+ setErrorMessage(LozengeActionErrorMessages.unknown);
49
+ setIsLoaded(false);
48
50
  } finally {
49
51
  setIsLoading(false);
50
52
  }
51
53
  }
52
54
  if (!args.isOpen) {
53
- setErrorCode(undefined);
55
+ setErrorMessage(undefined);
54
56
  }
55
57
  }, [action === null || action === void 0 ? void 0 : action.read, invoke, isLoaded, text]);
56
58
  const trigger = useCallback(props => jsx(LozengeActionTrigger, _extends({}, props, {
@@ -66,7 +68,9 @@ const LozengeAction = ({
66
68
  const request = createStatusUpdateRequest(updateAction, id);
67
69
  await invoke(request);
68
70
  setIsLoading(false);
71
+ setIsLoaded(false);
69
72
  setIsOpen(false);
73
+ setItems([]);
70
74
  const {
71
75
  url,
72
76
  id: linkId
@@ -76,15 +80,18 @@ const LozengeAction = ({
76
80
  }
77
81
  }
78
82
  } catch (err) {
79
- // TODO: EDM-6261: Error state
80
83
  setIsLoading(false);
81
- setErrorCode(InvokeActionError.Unknown);
84
+ if (isInvokeCustomError(err)) {
85
+ setErrorMessage(err.message);
86
+ } else {
87
+ setErrorMessage(LozengeActionErrorMessages.updateFailed);
88
+ }
82
89
  }
83
90
  }, [action === null || action === void 0 ? void 0 : action.update, invoke, reload]);
84
91
  const dropdownItemGroup = useMemo(() => {
85
- if (errorCode) {
92
+ if (errorMessage) {
86
93
  return jsx(LozengeActionError, {
87
- errorCode: errorCode,
94
+ errorMessage: errorMessage,
88
95
  testId: testId
89
96
  });
90
97
  }
@@ -98,7 +105,7 @@ const LozengeAction = ({
98
105
  testId: `${testId}-item-${idx}`
99
106
  })))));
100
107
  }
101
- }, [errorCode, handleItemClick, items, testId]);
108
+ }, [errorMessage, handleItemClick, items, testId]);
102
109
  return jsx(DropdownMenu, {
103
110
  isLoading: isLoading,
104
111
  isOpen: isOpen,
@@ -1,13 +1,36 @@
1
- import React, { useMemo } from 'react';
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
3
+ import { Fragment, useMemo } from 'react';
2
4
  import { DropdownItem, DropdownItemGroup } from '@atlaskit/dropdown-menu';
5
+ import { R50, R500 } from '@atlaskit/theme/colors';
6
+ import ErrorIcon from '@atlaskit/icon/glyph/error';
7
+ import { dropdownItemGroupStyles, contentStyles, textStyles } from './styled';
8
+ import { getFormattedMessage } from '../../../utils';
9
+ const MAX_LINE_NUMBER = 8;
3
10
  const LozengeActionError = ({
4
- errorCode,
5
- testId
11
+ errorMessage,
12
+ testId,
13
+ maxLineNumber = MAX_LINE_NUMBER
6
14
  }) => {
7
- // TODO: EDM-5746 and EDM-5782
8
- const content = useMemo(() => errorCode, [errorCode]);
9
- return /*#__PURE__*/React.createElement(DropdownItemGroup, null, /*#__PURE__*/React.createElement(DropdownItem, {
15
+ const content = useMemo(() => {
16
+ return jsx(Fragment, null, jsx("div", {
17
+ css: contentStyles
18
+ }, jsx(ErrorIcon, {
19
+ testId: `${testId}-icon`,
20
+ size: "medium",
21
+ primaryColor: `var(--ds-icon-danger, ${R500})`,
22
+ secondaryColor: `var(--ds-background-danger, ${R50})`,
23
+ label: 'error'
24
+ }), jsx("span", {
25
+ css: textStyles(maxLineNumber),
26
+ "data-testid": `${testId}-error-message`
27
+ }, typeof errorMessage === 'string' ? errorMessage : getFormattedMessage(errorMessage))));
28
+ }, [errorMessage, maxLineNumber, testId]);
29
+ return jsx("span", {
30
+ css: dropdownItemGroupStyles,
31
+ "data-testid": `${testId}-error-item-group`
32
+ }, jsx(DropdownItemGroup, null, jsx(DropdownItem, {
10
33
  testId: `${testId}-error`
11
- }, content));
34
+ }, content)));
12
35
  };
13
36
  export default LozengeActionError;
@@ -0,0 +1,41 @@
1
+ import { css } from '@emotion/react';
2
+ import { N800 } from '@atlaskit/theme/colors';
3
+ import { getTruncateStyles } from '../../../utils';
4
+ export const dropdownItemGroupStyles = css`
5
+ button {
6
+ width: 220px;
7
+
8
+ &:hover {
9
+ background-color: inherit;
10
+ cursor: default;
11
+ }
12
+ }
13
+ `;
14
+ const sharedBlockStyles = css`
15
+ display: flex;
16
+ gap: 0.5rem;
17
+ line-height: 1rem;
18
+ min-width: 0;
19
+ overflow: hidden;
20
+ flex-direction: row;
21
+ align-items: center;
22
+ `;
23
+ export const contentStyles = css`
24
+ ${sharedBlockStyles};
25
+
26
+ margin-top: 2px;
27
+ align-items: flex-start;
28
+
29
+ > span,
30
+ > div {
31
+ &[data-smart-element-text] {
32
+ font-size: 0.875rem;
33
+ color: ${`var(--ds-text, ${N800})`};
34
+ }
35
+ }
36
+ `;
37
+ export const textStyles = maxLines => css`
38
+ line-height: 1rem;
39
+ white-space: normal;
40
+ ${getTruncateStyles(maxLines)};
41
+ `;
@@ -1 +1,12 @@
1
- export {};
1
+ import { messages } from '../../../../../../messages';
2
+ export const LozengeActionErrorMessages = {
3
+ noData: {
4
+ descriptor: messages['status_change_permission_error']
5
+ },
6
+ unknown: {
7
+ descriptor: messages['status_change_load_error']
8
+ },
9
+ updateFailed: {
10
+ descriptor: messages['status_change_update_error']
11
+ }
12
+ };
@@ -200,6 +200,11 @@ export var messages = defineMessages({
200
200
  defaultMessage: "Uh oh. We can't find this link!",
201
201
  description: 'Error case for when a provided link is not found'
202
202
  },
203
+ open_issue_in_jira: {
204
+ id: 'fabric.linking.open_issue_in_jira',
205
+ defaultMessage: 'Open issue in Jira',
206
+ description: 'Click to open link in Jira'
207
+ },
203
208
  open_link_in_a_new_tab: {
204
209
  id: 'fabric.linking.open_link_in_a_new_tab',
205
210
  defaultMessage: 'Open link in a new tab',
@@ -345,6 +350,21 @@ export var messages = defineMessages({
345
350
  defaultMessage: 'Save',
346
351
  description: 'Just the "save" word'
347
352
  },
353
+ status_change_load_error: {
354
+ id: 'fabric.linking.status_change_load_error',
355
+ defaultMessage: 'We couldn’t load the statuses and transitions',
356
+ description: 'Informs the user that the loading of status transitions failed'
357
+ },
358
+ status_change_permission_error: {
359
+ id: 'fabric.linking.status_change_permission_error',
360
+ defaultMessage: 'You don’t have permission to transition this issue. ',
361
+ description: 'Informs the user that they do not have enough permissions to update a status'
362
+ },
363
+ status_change_update_error: {
364
+ id: 'fabric.linking.status_change_update_error',
365
+ defaultMessage: 'We couldn’t update the status',
366
+ description: "Occurs when a user tries to update an issue's status but fails to do so"
367
+ },
348
368
  try_again: {
349
369
  id: 'fabric.linking.try_again',
350
370
  defaultMessage: 'Try again',
@@ -1,15 +1 @@
1
- export var InvokeActionError;
2
-
3
- /**
4
- * Additional details for invoke function that may be required for component
5
- */
6
- (function (InvokeActionError) {
7
- InvokeActionError["NoData"] = "NoData";
8
- InvokeActionError["Unknown"] = "Unknown";
9
- })(InvokeActionError || (InvokeActionError = {}));
10
- /**
11
- * Invoke request with additional details for the component
12
- */
13
- /**
14
- * CRUD invoke requests for the component that support server actions
15
- */
1
+ export {};
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "25.7.0",
3
+ "version": "25.7.1",
4
4
  "sideEffects": false
5
5
  }
@@ -13,10 +13,10 @@ import LozengeActionError from './lozenge-action-error';
13
13
  import withErrorBoundary from './error-boundary';
14
14
  import { dropdownItemGroupStyles } from './styled';
15
15
  import useInvoke from '../../../../../state/hooks/use-invoke';
16
- import { InvokeActionError } from '../../../../../state/hooks/use-invoke/types';
17
16
  import extractLozengeActionItems from '../../../../../extractors/action/extract-lozenge-action-items';
18
17
  import createStatusUpdateRequest from '../../../../../utils/actions/create-status-update-request';
19
18
  import useResolve from '../../../../../state/hooks/use-resolve';
19
+ import { LozengeActionErrorMessages } from './lozenge-action-error/types';
20
20
  var validateItems = function validateItems() {
21
21
  var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
22
22
  var text = arguments.length > 1 ? arguments[1] : undefined;
@@ -24,6 +24,9 @@ var validateItems = function validateItems() {
24
24
  return item.text !== text;
25
25
  });
26
26
  };
27
+ var isInvokeCustomError = function isInvokeCustomError(err) {
28
+ return err.message !== undefined && err.errorCode !== undefined;
29
+ };
27
30
  var LozengeAction = function LozengeAction(_ref) {
28
31
  var action = _ref.action,
29
32
  appearance = _ref.appearance,
@@ -49,8 +52,8 @@ var LozengeAction = function LozengeAction(_ref) {
49
52
  setItems = _useState8[1];
50
53
  var _useState9 = useState(),
51
54
  _useState10 = _slicedToArray(_useState9, 2),
52
- errorCode = _useState10[0],
53
- setErrorCode = _useState10[1];
55
+ errorMessage = _useState10[0],
56
+ setErrorMessage = _useState10[1];
54
57
  var invoke = useInvoke();
55
58
  var reload = useResolve();
56
59
  var handleOpenChange = useCallback( /*#__PURE__*/function () {
@@ -62,7 +65,7 @@ var LozengeAction = function LozengeAction(_ref) {
62
65
  case 0:
63
66
  setIsOpen(args.isOpen);
64
67
  if (!(args.isOpen && !isLoaded && action !== null && action !== void 0 && action.read)) {
65
- _context.next = 19;
68
+ _context.next = 20;
66
69
  break;
67
70
  }
68
71
  _context.prev = 2;
@@ -75,29 +78,30 @@ var LozengeAction = function LozengeAction(_ref) {
75
78
  setItems(validItems);
76
79
  setIsLoaded(true);
77
80
  if ((validItems === null || validItems === void 0 ? void 0 : validItems.length) === 0) {
78
- setErrorCode(InvokeActionError.NoData);
81
+ setErrorMessage(LozengeActionErrorMessages.noData);
82
+ setIsLoaded(false);
79
83
  }
80
- _context.next = 16;
84
+ _context.next = 17;
81
85
  break;
82
86
  case 13:
83
87
  _context.prev = 13;
84
88
  _context.t0 = _context["catch"](2);
85
- // TODO: EDM-6261: Error state
86
- setErrorCode(InvokeActionError.Unknown);
87
- case 16:
88
- _context.prev = 16;
89
+ setErrorMessage(LozengeActionErrorMessages.unknown);
90
+ setIsLoaded(false);
91
+ case 17:
92
+ _context.prev = 17;
89
93
  setIsLoading(false);
90
- return _context.finish(16);
91
- case 19:
94
+ return _context.finish(17);
95
+ case 20:
92
96
  if (!args.isOpen) {
93
- setErrorCode(undefined);
97
+ setErrorMessage(undefined);
94
98
  }
95
- case 20:
99
+ case 21:
96
100
  case "end":
97
101
  return _context.stop();
98
102
  }
99
103
  }
100
- }, _callee, null, [[2, 13, 16, 19]]);
104
+ }, _callee, null, [[2, 13, 17, 20]]);
101
105
  }));
102
106
  return function (_x) {
103
107
  return _ref2.apply(this, arguments);
@@ -120,7 +124,7 @@ var LozengeAction = function LozengeAction(_ref) {
120
124
  _context2.prev = 0;
121
125
  updateAction = action === null || action === void 0 ? void 0 : action.update;
122
126
  if (!(updateAction && id)) {
123
- _context2.next = 13;
127
+ _context2.next = 15;
124
128
  break;
125
129
  }
126
130
  setIsLoading(true);
@@ -129,38 +133,43 @@ var LozengeAction = function LozengeAction(_ref) {
129
133
  return invoke(request);
130
134
  case 7:
131
135
  setIsLoading(false);
136
+ setIsLoaded(false);
132
137
  setIsOpen(false);
138
+ setItems([]);
133
139
  _ref4 = updateAction.details || {}, url = _ref4.url, linkId = _ref4.id;
134
140
  if (!url) {
135
- _context2.next = 13;
141
+ _context2.next = 15;
136
142
  break;
137
143
  }
138
- _context2.next = 13;
144
+ _context2.next = 15;
139
145
  return reload(url, true, undefined, linkId);
140
- case 13:
141
- _context2.next = 19;
142
- break;
143
146
  case 15:
144
- _context2.prev = 15;
147
+ _context2.next = 21;
148
+ break;
149
+ case 17:
150
+ _context2.prev = 17;
145
151
  _context2.t0 = _context2["catch"](0);
146
- // TODO: EDM-6261: Error state
147
152
  setIsLoading(false);
148
- setErrorCode(InvokeActionError.Unknown);
149
- case 19:
153
+ if (isInvokeCustomError(_context2.t0)) {
154
+ setErrorMessage(_context2.t0.message);
155
+ } else {
156
+ setErrorMessage(LozengeActionErrorMessages.updateFailed);
157
+ }
158
+ case 21:
150
159
  case "end":
151
160
  return _context2.stop();
152
161
  }
153
162
  }
154
- }, _callee2, null, [[0, 15]]);
163
+ }, _callee2, null, [[0, 17]]);
155
164
  }));
156
165
  return function (_x2) {
157
166
  return _ref3.apply(this, arguments);
158
167
  };
159
168
  }(), [action === null || action === void 0 ? void 0 : action.update, invoke, reload]);
160
169
  var dropdownItemGroup = useMemo(function () {
161
- if (errorCode) {
170
+ if (errorMessage) {
162
171
  return jsx(LozengeActionError, {
163
- errorCode: errorCode,
172
+ errorMessage: errorMessage,
164
173
  testId: testId
165
174
  });
166
175
  }
@@ -176,7 +185,7 @@ var LozengeAction = function LozengeAction(_ref) {
176
185
  }));
177
186
  })));
178
187
  }
179
- }, [errorCode, handleItemClick, items, testId]);
188
+ }, [errorMessage, handleItemClick, items, testId]);
180
189
  return jsx(DropdownMenu, {
181
190
  isLoading: isLoading,
182
191
  isOpen: isOpen,
@@ -1,14 +1,36 @@
1
- import React, { useMemo } from 'react';
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
3
+ import { Fragment, useMemo } from 'react';
2
4
  import { DropdownItem, DropdownItemGroup } from '@atlaskit/dropdown-menu';
5
+ import { R50, R500 } from '@atlaskit/theme/colors';
6
+ import ErrorIcon from '@atlaskit/icon/glyph/error';
7
+ import { dropdownItemGroupStyles, contentStyles, textStyles } from './styled';
8
+ import { getFormattedMessage } from '../../../utils';
9
+ var MAX_LINE_NUMBER = 8;
3
10
  var LozengeActionError = function LozengeActionError(_ref) {
4
- var errorCode = _ref.errorCode,
5
- testId = _ref.testId;
6
- // TODO: EDM-5746 and EDM-5782
11
+ var errorMessage = _ref.errorMessage,
12
+ testId = _ref.testId,
13
+ _ref$maxLineNumber = _ref.maxLineNumber,
14
+ maxLineNumber = _ref$maxLineNumber === void 0 ? MAX_LINE_NUMBER : _ref$maxLineNumber;
7
15
  var content = useMemo(function () {
8
- return errorCode;
9
- }, [errorCode]);
10
- return /*#__PURE__*/React.createElement(DropdownItemGroup, null, /*#__PURE__*/React.createElement(DropdownItem, {
16
+ return jsx(Fragment, null, jsx("div", {
17
+ css: contentStyles
18
+ }, jsx(ErrorIcon, {
19
+ testId: "".concat(testId, "-icon"),
20
+ size: "medium",
21
+ primaryColor: "var(--ds-icon-danger, ".concat(R500, ")"),
22
+ secondaryColor: "var(--ds-background-danger, ".concat(R50, ")"),
23
+ label: 'error'
24
+ }), jsx("span", {
25
+ css: textStyles(maxLineNumber),
26
+ "data-testid": "".concat(testId, "-error-message")
27
+ }, typeof errorMessage === 'string' ? errorMessage : getFormattedMessage(errorMessage))));
28
+ }, [errorMessage, maxLineNumber, testId]);
29
+ return jsx("span", {
30
+ css: dropdownItemGroupStyles,
31
+ "data-testid": "".concat(testId, "-error-item-group")
32
+ }, jsx(DropdownItemGroup, null, jsx(DropdownItem, {
11
33
  testId: "".concat(testId, "-error")
12
- }, content));
34
+ }, content)));
13
35
  };
14
36
  export default LozengeActionError;
@@ -0,0 +1,11 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4;
3
+ import { css } from '@emotion/react';
4
+ import { N800 } from '@atlaskit/theme/colors';
5
+ import { getTruncateStyles } from '../../../utils';
6
+ export var dropdownItemGroupStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n button {\n width: 220px;\n\n &:hover {\n background-color: inherit;\n cursor: default;\n }\n }\n"])));
7
+ var sharedBlockStyles = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: flex;\n gap: 0.5rem;\n line-height: 1rem;\n min-width: 0;\n overflow: hidden;\n flex-direction: row;\n align-items: center;\n"])));
8
+ export var contentStyles = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n ", ";\n\n margin-top: 2px;\n align-items: flex-start;\n\n > span,\n > div {\n &[data-smart-element-text] {\n font-size: 0.875rem;\n color: ", ";\n }\n }\n"])), sharedBlockStyles, "var(--ds-text, ".concat(N800, ")"));
9
+ export var textStyles = function textStyles(maxLines) {
10
+ return css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n line-height: 1rem;\n white-space: normal;\n ", ";\n"])), getTruncateStyles(maxLines));
11
+ };
@@ -1 +1,12 @@
1
- export {};
1
+ import { messages } from '../../../../../../messages';
2
+ export var LozengeActionErrorMessages = {
3
+ noData: {
4
+ descriptor: messages['status_change_permission_error']
5
+ },
6
+ unknown: {
7
+ descriptor: messages['status_change_load_error']
8
+ },
9
+ updateFailed: {
10
+ descriptor: messages['status_change_update_error']
11
+ }
12
+ };
@@ -1,6 +1,6 @@
1
1
  import { MessageDescriptor } from 'react-intl-next';
2
2
  export declare type RequestAccessMessageKey = 'click_to_join' | 'click_to_join_description' | 'forbidden_description' | 'request_access' | 'request_access_description' | 'request_access_pending' | 'request_access_pending_description' | 'request_denied_description';
3
- export declare type MessageKey = 'cannot_find_link' | 'connect_link_account_card' | 'connect_link_account_card_name' | 'connect_link_account_card_description' | 'connect_unauthorised_account_action' | 'connect_unauthorised_account_description' | 'connect_unauthorised_account_description_no_provider' | 'continue' | 'copy_url_to_clipboard' | 'could_not_load_link' | 'download' | 'go_back' | 'invalid_permissions' | 'invalid_permissions_description' | 'join_to_view' | 'connect_link_account' | 'created_by' | 'created_on_relative' | 'created_on_absolute' | 'check_this_link' | 'delete' | 'edit' | 'learn_more_about_smart_links' | 'loading' | 'link_safety_warning_message' | 'modified_by' | 'modified_on_relative' | 'modified_on_absolute' | 'more_actions' | 'not_found_title' | 'not_found_description' | 'open_link_in_a_new_tab' | 'owned_by' | 'preview' | 'preview_close' | 'preview_max_size' | 'preview_min_size' | 'priority_blocker' | 'priority_critical' | 'priority_high' | 'priority_highest' | 'priority_low' | 'priority_lowest' | 'priority_major' | 'priority_medium' | 'priority_minor' | 'priority_trivial' | 'priority_undefined' | 'forbidden_access' | 'pending_request' | 'restricted_link' | 'request_access_to_view' | 'request_denied' | 'try_again' | 'try_another_account' | 'view' | 'viewIn' | 'viewOriginal' | 'actions' | 'add_account' | 'cancel' | 'close' | 'connect_to' | 'connect_account_description' | 'retry' | 'save' | 'unlink_account' | RequestAccessMessageKey;
3
+ export declare type MessageKey = 'cannot_find_link' | 'connect_link_account_card' | 'connect_link_account_card_name' | 'connect_link_account_card_description' | 'connect_unauthorised_account_action' | 'connect_unauthorised_account_description' | 'connect_unauthorised_account_description_no_provider' | 'continue' | 'copy_url_to_clipboard' | 'could_not_load_link' | 'download' | 'go_back' | 'invalid_permissions' | 'invalid_permissions_description' | 'join_to_view' | 'connect_link_account' | 'created_by' | 'created_on_relative' | 'created_on_absolute' | 'check_this_link' | 'delete' | 'edit' | 'learn_more_about_smart_links' | 'loading' | 'link_safety_warning_message' | 'modified_by' | 'modified_on_relative' | 'modified_on_absolute' | 'more_actions' | 'not_found_title' | 'not_found_description' | 'open_issue_in_jira' | 'open_link_in_a_new_tab' | 'owned_by' | 'preview' | 'preview_close' | 'preview_max_size' | 'preview_min_size' | 'priority_blocker' | 'priority_critical' | 'priority_high' | 'priority_highest' | 'priority_low' | 'priority_lowest' | 'priority_major' | 'priority_medium' | 'priority_minor' | 'priority_trivial' | 'priority_undefined' | 'forbidden_access' | 'pending_request' | 'restricted_link' | 'request_access_to_view' | 'request_denied' | 'status_change_load_error' | 'status_change_permission_error' | 'status_change_update_error' | 'try_again' | 'try_another_account' | 'view' | 'viewIn' | 'viewOriginal' | 'actions' | 'add_account' | 'cancel' | 'close' | 'connect_to' | 'connect_account_description' | 'retry' | 'save' | 'unlink_account' | RequestAccessMessageKey;
4
4
  declare type Messages = {
5
5
  [K in MessageKey]: MessageDescriptor;
6
6
  };
@@ -1,8 +1,4 @@
1
1
  import type { InvokeRequest } from '@atlaskit/linking-types/smart-link-actions';
2
- export declare enum InvokeActionError {
3
- NoData = "NoData",
4
- Unknown = "Unknown"
5
- }
6
2
  /**
7
3
  * Additional details for invoke function that may be required for component
8
4
  */
@@ -0,0 +1,3 @@
1
+ export declare const dropdownItemGroupStyles: import("@emotion/react").SerializedStyles;
2
+ export declare const contentStyles: import("@emotion/react").SerializedStyles;
3
+ export declare const textStyles: (maxLines: number) => import("@emotion/react").SerializedStyles;
@@ -1,5 +1,17 @@
1
- import type { InvokeActionError } from '../../../../../../state/hooks/use-invoke/types';
1
+ import { MessageProps } from '../../../types';
2
2
  export declare type LozengeActionErrorProps = {
3
- errorCode: InvokeActionError;
3
+ errorMessage: string | MessageProps;
4
4
  testId?: string;
5
+ maxLineNumber?: number;
6
+ };
7
+ export declare const LozengeActionErrorMessages: {
8
+ noData: {
9
+ descriptor: import("react-intl-next").MessageDescriptor;
10
+ };
11
+ unknown: {
12
+ descriptor: import("react-intl-next").MessageDescriptor;
13
+ };
14
+ updateFailed: {
15
+ descriptor: import("react-intl-next").MessageDescriptor;
16
+ };
5
17
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "25.7.0",
3
+ "version": "25.7.1",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -35,7 +35,7 @@
35
35
  "@atlaskit/in-product-testing": "^0.1.0",
36
36
  "@atlaskit/link-client-extension": "^0.4.0",
37
37
  "@atlaskit/linking-common": "^2.6.0",
38
- "@atlaskit/linking-types": "^1.1.0",
38
+ "@atlaskit/linking-types": "^1.2.0",
39
39
  "@atlaskit/logo": "^13.13.0",
40
40
  "@atlaskit/lozenge": "^11.3.0",
41
41
  "@atlaskit/media-common": "^4.0.0",