@atlaskit/link-datasource 3.12.1 → 3.13.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 (53) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/cjs/hooks/useLoadOptions.js +100 -0
  3. package/dist/cjs/ui/common/error-state/loading-error.js +11 -12
  4. package/dist/cjs/ui/common/error-state/modal-loading-error.js +10 -17
  5. package/dist/cjs/ui/common/error-state/no-instances.js +11 -11
  6. package/dist/cjs/ui/common/error-state/no-results.js +15 -19
  7. package/dist/cjs/ui/common/modal/count-view-smart-link/index.js +19 -15
  8. package/dist/cjs/ui/issue-like-table/edit-type/icon/index.js +16 -106
  9. package/dist/cjs/ui/issue-like-table/edit-type/index.js +26 -9
  10. package/dist/cjs/ui/issue-like-table/edit-type/status/index.js +10 -112
  11. package/dist/cjs/ui/issue-like-table/edit-type/text/index.js +4 -6
  12. package/dist/cjs/ui/issue-like-table/edit-type/user/index.js +97 -0
  13. package/dist/cjs/ui/issue-like-table/table-cell-content/inline-edit.js +5 -2
  14. package/dist/es2019/hooks/useLoadOptions.js +63 -0
  15. package/dist/es2019/ui/common/error-state/loading-error.js +11 -12
  16. package/dist/es2019/ui/common/error-state/modal-loading-error.js +10 -17
  17. package/dist/es2019/ui/common/error-state/no-instances.js +13 -13
  18. package/dist/es2019/ui/common/error-state/no-results.js +16 -20
  19. package/dist/es2019/ui/common/modal/count-view-smart-link/index.js +20 -16
  20. package/dist/es2019/ui/issue-like-table/edit-type/icon/index.js +13 -74
  21. package/dist/es2019/ui/issue-like-table/edit-type/index.js +24 -5
  22. package/dist/es2019/ui/issue-like-table/edit-type/status/index.js +8 -76
  23. package/dist/es2019/ui/issue-like-table/edit-type/text/index.js +5 -5
  24. package/dist/es2019/ui/issue-like-table/edit-type/user/index.js +74 -0
  25. package/dist/es2019/ui/issue-like-table/table-cell-content/inline-edit.js +5 -2
  26. package/dist/esm/hooks/useLoadOptions.js +93 -0
  27. package/dist/esm/ui/common/error-state/loading-error.js +11 -12
  28. package/dist/esm/ui/common/error-state/modal-loading-error.js +10 -17
  29. package/dist/esm/ui/common/error-state/no-instances.js +13 -13
  30. package/dist/esm/ui/common/error-state/no-results.js +16 -20
  31. package/dist/esm/ui/common/modal/count-view-smart-link/index.js +20 -16
  32. package/dist/esm/ui/issue-like-table/edit-type/icon/index.js +18 -107
  33. package/dist/esm/ui/issue-like-table/edit-type/index.js +25 -5
  34. package/dist/esm/ui/issue-like-table/edit-type/status/index.js +11 -113
  35. package/dist/esm/ui/issue-like-table/edit-type/text/index.js +3 -5
  36. package/dist/esm/ui/issue-like-table/edit-type/user/index.js +87 -0
  37. package/dist/esm/ui/issue-like-table/table-cell-content/inline-edit.js +5 -2
  38. package/dist/types/hooks/useLoadOptions.d.ts +11 -0
  39. package/dist/types/ui/issue-like-table/edit-type/icon/index.d.ts +2 -2
  40. package/dist/types/ui/issue-like-table/edit-type/index.d.ts +1 -0
  41. package/dist/types/ui/issue-like-table/edit-type/status/index.d.ts +4 -4
  42. package/dist/types/ui/issue-like-table/edit-type/text/index.d.ts +2 -3
  43. package/dist/types/ui/issue-like-table/edit-type/user/index.d.ts +11 -0
  44. package/dist/types/ui/issue-like-table/types.d.ts +3 -0
  45. package/dist/types-ts4.5/hooks/useLoadOptions.d.ts +11 -0
  46. package/dist/types-ts4.5/ui/issue-like-table/edit-type/icon/index.d.ts +2 -2
  47. package/dist/types-ts4.5/ui/issue-like-table/edit-type/index.d.ts +1 -0
  48. package/dist/types-ts4.5/ui/issue-like-table/edit-type/status/index.d.ts +4 -4
  49. package/dist/types-ts4.5/ui/issue-like-table/edit-type/text/index.d.ts +2 -3
  50. package/dist/types-ts4.5/ui/issue-like-table/edit-type/user/index.d.ts +11 -0
  51. package/dist/types-ts4.5/ui/issue-like-table/types.d.ts +3 -0
  52. package/examples-helpers/buildIssueLikeTable.tsx +2 -1
  53. package/package.json +8 -5
@@ -6,17 +6,13 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.default = void 0;
9
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
10
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
12
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
10
  var _react = _interopRequireWildcard(require("react"));
14
- var _linkingTypes = require("@atlaskit/linking-types");
15
11
  var _lozenge = _interopRequireDefault(require("@atlaskit/lozenge"));
16
12
  var _select = _interopRequireDefault(require("@atlaskit/select"));
17
13
  var _ufoExperiences = require("../../../../analytics/ufoExperiences");
18
14
  var _datasourceExperienceId = require("../../../../contexts/datasource-experience-id");
19
- var _useDatasourceTableFlag = require("../../../../hooks/useDatasourceTableFlag");
15
+ var _useLoadOptions2 = require("../../../../hooks/useLoadOptions");
20
16
  var _inlineEdit = require("../../table-cell-content/inline-edit");
21
17
  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); }
22
18
  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 && {}.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; }
@@ -24,12 +20,12 @@ var StatusEditType = function StatusEditType(props) {
24
20
  var _currentValue$values;
25
21
  var currentValue = props.currentValue,
26
22
  executeFetch = props.executeFetch;
27
- var _useStatusOptions = useStatusOptions({
23
+ var _useLoadOptions = (0, _useLoadOptions2.useLoadOptions)({
28
24
  executeFetch: executeFetch
29
25
  }),
30
- options = _useStatusOptions.options,
31
- isLoading = _useStatusOptions.isLoading,
32
- hasFailed = _useStatusOptions.hasFailed;
26
+ options = _useLoadOptions.options,
27
+ isLoading = _useLoadOptions.isLoading,
28
+ hasFailed = _useLoadOptions.hasFailed;
33
29
  var experienceId = (0, _datasourceExperienceId.useDatasourceExperienceId)();
34
30
  (0, _react.useEffect)(function () {
35
31
  if (!experienceId) {
@@ -46,18 +42,18 @@ var StatusEditType = function StatusEditType(props) {
46
42
  }
47
43
  }, [experienceId, isLoading, hasFailed]);
48
44
  return /*#__PURE__*/_react.default.createElement(_select.default, (0, _extends2.default)({}, props, {
49
- testId: "inline-edit-status",
50
45
  autoFocus: true,
46
+ options: options,
51
47
  defaultMenuIsOpen: true,
52
48
  blurInputOnSelect: true,
49
+ menuPlacement: "auto",
50
+ isLoading: isLoading,
51
+ filterOption: filterOption,
52
+ testId: "inline-edit-status",
53
53
  getOptionValue: function getOptionValue(option) {
54
54
  return option.text;
55
55
  },
56
- options: options,
57
- isLoading: isLoading,
58
56
  defaultValue: currentValue === null || currentValue === void 0 || (_currentValue$values = currentValue.values) === null || _currentValue$values === void 0 ? void 0 : _currentValue$values[0],
59
- filterOption: filterOption,
60
- menuPlacement: "auto",
61
57
  formatOptionLabel: function formatOptionLabel(option) {
62
58
  return /*#__PURE__*/_react.default.createElement(_lozenge.default, (0, _extends2.default)({
63
59
  testId: "inline-edit-status-option-".concat(option.text)
@@ -74,102 +70,4 @@ var StatusEditType = function StatusEditType(props) {
74
70
  var filterOption = function filterOption(option, inputValue) {
75
71
  return option.data.text.toLowerCase().includes(inputValue.toLowerCase());
76
72
  };
77
- var useStatusOptions = function useStatusOptions(_ref) {
78
- var fetchInputs = _ref.fetchInputs,
79
- executeFetch = _ref.executeFetch;
80
- var _useState = (0, _react.useState)({
81
- isLoading: true,
82
- options: [],
83
- hasFailed: false
84
- }),
85
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
86
- _useState2$ = _useState2[0],
87
- options = _useState2$.options,
88
- isLoading = _useState2$.isLoading,
89
- hasFailed = _useState2$.hasFailed,
90
- setOptions = _useState2[1];
91
- var _useDatasourceTableFl = (0, _useDatasourceTableFlag.useDatasourceTableFlag)({
92
- isFetchAction: true
93
- }),
94
- showErrorFlag = _useDatasourceTableFl.showErrorFlag;
95
- (0, _react.useEffect)(function () {
96
- var isMounted = true;
97
- loadOptions(fetchInputs, executeFetch).then(function (options) {
98
- if (isMounted) {
99
- setOptions({
100
- isLoading: false,
101
- options: options,
102
- hasFailed: false
103
- });
104
- }
105
- }).catch(function (err) {
106
- showErrorFlag();
107
- setOptions({
108
- isLoading: false,
109
- options: [],
110
- hasFailed: true
111
- });
112
- });
113
- return function () {
114
- isMounted = false;
115
- };
116
- }, [fetchInputs, executeFetch, showErrorFlag]);
117
- return {
118
- options: options,
119
- isLoading: isLoading,
120
- hasFailed: hasFailed
121
- };
122
- };
123
- var loadOptions = /*#__PURE__*/function () {
124
- var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
125
- var fetchInputs,
126
- executeFetch,
127
- result,
128
- operationStatus,
129
- entities,
130
- _args = arguments;
131
- return _regenerator.default.wrap(function _callee$(_context) {
132
- while (1) switch (_context.prev = _context.next) {
133
- case 0:
134
- fetchInputs = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
135
- executeFetch = _args.length > 1 ? _args[1] : undefined;
136
- if (!executeFetch) {
137
- _context.next = 11;
138
- break;
139
- }
140
- _context.next = 5;
141
- return executeFetch(fetchInputs);
142
- case 5:
143
- result = _context.sent;
144
- operationStatus = result.operationStatus, entities = result.entities;
145
- if (!(operationStatus === _linkingTypes.ActionOperationStatus.FAILURE)) {
146
- _context.next = 9;
147
- break;
148
- }
149
- throw new Error('Failed to fetch status options');
150
- case 9:
151
- if (!entities) {
152
- _context.next = 11;
153
- break;
154
- }
155
- return _context.abrupt("return", entities.map(function (entity) {
156
- return {
157
- id: entity.id,
158
- text: entity.text,
159
- style: entity.style,
160
- transitionId: entity.transitionId
161
- };
162
- }));
163
- case 11:
164
- return _context.abrupt("return", []);
165
- case 12:
166
- case "end":
167
- return _context.stop();
168
- }
169
- }, _callee);
170
- }));
171
- return function loadOptions() {
172
- return _ref2.apply(this, arguments);
173
- };
174
- }();
175
73
  var _default = exports.default = StatusEditType;
@@ -5,7 +5,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.toTextValue = exports.default = void 0;
8
+ exports.default = void 0;
9
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
10
  var _react = _interopRequireWildcard(require("react"));
11
11
  var _layering = require("@atlaskit/layering");
@@ -14,12 +14,10 @@ var _ufoExperiences = require("../../../../analytics/ufoExperiences");
14
14
  var _datasourceExperienceId = require("../../../../contexts/datasource-experience-id");
15
15
  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); }
16
16
  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 && {}.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; }
17
- var toTextValue = exports.toTextValue = function toTextValue(typeWithValues) {
18
- var _ref, _typeWithValues$value;
19
- return (_ref = (_typeWithValues$value = typeWithValues.values) === null || _typeWithValues$value === void 0 ? void 0 : _typeWithValues$value[0]) !== null && _ref !== void 0 ? _ref : '';
20
- };
21
17
  var TextEditType = function TextEditType(props) {
18
+ var _currentValue$values$, _currentValue$values;
22
19
  var experienceId = (0, _datasourceExperienceId.useDatasourceExperienceId)();
20
+ var currentValue = props.currentValue;
23
21
  (0, _react.useEffect)(function () {
24
22
  if (experienceId) {
25
23
  (0, _ufoExperiences.succeedUfoExperience)({
@@ -37,7 +35,7 @@ var TextEditType = function TextEditType(props) {
37
35
  // We need 8px left padding to match read only version, but there is already 1px of border
38
36
  padding: "var(--ds-space-100, 8px)".concat(" calc(", "var(--ds-space-100, 8px)", " - 1px)")
39
37
  },
40
- value: toTextValue(props.currentValue),
38
+ value: (_currentValue$values$ = currentValue === null || currentValue === void 0 || (_currentValue$values = currentValue.values) === null || _currentValue$values === void 0 ? void 0 : _currentValue$values[0]) !== null && _currentValue$values$ !== void 0 ? _currentValue$values$ : '',
41
39
  onChange: function onChange(e) {
42
40
  return props.setEditValues({
43
41
  type: 'string',
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
+ var _react = _interopRequireWildcard(require("react"));
12
+ var _useDebounce = require("use-debounce");
13
+ var _avatar = _interopRequireWildcard(require("@atlaskit/avatar"));
14
+ var _select = _interopRequireDefault(require("@atlaskit/select"));
15
+ var _ufoExperiences = require("../../../../analytics/ufoExperiences");
16
+ var _datasourceExperienceId = require("../../../../contexts/datasource-experience-id");
17
+ var _useLoadOptions2 = require("../../../../hooks/useLoadOptions");
18
+ var _constants = require("../../../common/modal/popup-select/constants");
19
+ var _user = require("../../render-type/user");
20
+ var _inlineEdit = require("../../table-cell-content/inline-edit");
21
+ 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); }
22
+ 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 && {}.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; }
23
+ var UserEditType = function UserEditType(props) {
24
+ var _currentValue$values;
25
+ var currentValue = props.currentValue,
26
+ executeFetch = props.executeFetch;
27
+ var _useState = (0, _react.useState)({
28
+ query: ''
29
+ }),
30
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
31
+ fetchInputs = _useState2[0],
32
+ setFetchInputs = _useState2[1];
33
+ var _useDebouncedCallback = (0, _useDebounce.useDebouncedCallback)(function (query) {
34
+ return setFetchInputs({
35
+ query: query
36
+ });
37
+ }, _constants.SEARCH_DEBOUNCE_MS),
38
+ _useDebouncedCallback2 = (0, _slicedToArray2.default)(_useDebouncedCallback, 1),
39
+ handleUserInputDebounced = _useDebouncedCallback2[0];
40
+ var _useLoadOptions = (0, _useLoadOptions2.useLoadOptions)({
41
+ executeFetch: executeFetch,
42
+ fetchInputs: fetchInputs
43
+ }),
44
+ options = _useLoadOptions.options,
45
+ isLoading = _useLoadOptions.isLoading,
46
+ hasFailed = _useLoadOptions.hasFailed;
47
+ var experienceId = (0, _datasourceExperienceId.useDatasourceExperienceId)();
48
+ (0, _react.useEffect)(function () {
49
+ if (!experienceId) {
50
+ return;
51
+ }
52
+ if (hasFailed) {
53
+ (0, _ufoExperiences.failUfoExperience)({
54
+ name: _inlineEdit.InlineEditUFOExperience
55
+ }, experienceId);
56
+ } else if (!isLoading) {
57
+ (0, _ufoExperiences.succeedUfoExperience)({
58
+ name: _inlineEdit.InlineEditUFOExperience
59
+ }, experienceId);
60
+ }
61
+ }, [experienceId, isLoading, hasFailed]);
62
+ return /*#__PURE__*/_react.default.createElement(_select.default, (0, _extends2.default)({}, props, {
63
+ autoFocus: true,
64
+ defaultMenuIsOpen: true,
65
+ blurInputOnSelect: true,
66
+ options: options,
67
+ isLoading: isLoading,
68
+ testId: "inline-edit-user",
69
+ filterOption: function filterOption() {
70
+ return true;
71
+ } // necessary, otherwise by default all options will be filtered out on user input
72
+ ,
73
+ onInputChange: handleUserInputDebounced,
74
+ defaultValue: currentValue === null || currentValue === void 0 || (_currentValue$values = currentValue.values) === null || _currentValue$values === void 0 ? void 0 : _currentValue$values[0],
75
+ getOptionValue: function getOptionValue(option) {
76
+ return option.atlassianUserId;
77
+ },
78
+ formatOptionLabel: function formatOptionLabel(option) {
79
+ return /*#__PURE__*/_react.default.createElement(_avatar.AvatarItem, {
80
+ avatar: /*#__PURE__*/_react.default.createElement(_avatar.default, {
81
+ appearance: "circle",
82
+ size: 'small',
83
+ src: option.avatarSource,
84
+ testId: "".concat(_user.USER_TYPE_TEST_ID, "--avatar--").concat(option.atlassianUserId)
85
+ }),
86
+ primaryText: option.displayName
87
+ });
88
+ },
89
+ onChange: function onChange(e) {
90
+ return props.setEditValues({
91
+ type: 'user',
92
+ values: e ? [e] : []
93
+ });
94
+ }
95
+ }));
96
+ };
97
+ var _default = exports.default = UserEditType;
@@ -29,14 +29,16 @@ var editContainerStyles = (0, _primitives.xcss)({
29
29
  marginBlockStart: 'space.negative.100'
30
30
  });
31
31
  var getBackendUpdateValue = function getBackendUpdateValue(typedNewValue) {
32
- var _typedNewValue$values, _typedNewValue$values2;
32
+ var _typedNewValue$values, _typedNewValue$values2, _typedNewValue$values3;
33
33
  switch (typedNewValue.type) {
34
34
  case 'string':
35
35
  return typedNewValue.values[0] || '';
36
36
  case 'status':
37
37
  return ((_typedNewValue$values = typedNewValue.values[0]) === null || _typedNewValue$values === void 0 ? void 0 : _typedNewValue$values.transitionId) || '';
38
+ case 'user':
39
+ return ((_typedNewValue$values2 = typedNewValue.values[0]) === null || _typedNewValue$values2 === void 0 ? void 0 : _typedNewValue$values2.atlassianUserId) || '';
38
40
  case 'icon':
39
- return ((_typedNewValue$values2 = typedNewValue.values[0]) === null || _typedNewValue$values2 === void 0 ? void 0 : _typedNewValue$values2.id) || '';
41
+ return ((_typedNewValue$values3 = typedNewValue.values[0]) === null || _typedNewValue$values3 === void 0 ? void 0 : _typedNewValue$values3.id) || '';
40
42
  }
41
43
  throw new Error("Datasource 2 way sync Backend update value not implemented for type ".concat(typedNewValue.type));
42
44
  };
@@ -47,6 +49,7 @@ var mapUpdatedItem = function mapUpdatedItem(existingItem, columnKey, newValue)
47
49
  data: newValue.values[0] || ''
48
50
  }));
49
51
  case 'status':
52
+ case 'user':
50
53
  case 'icon':
51
54
  return newValue.values[0] ? _objectSpread(_objectSpread({}, existingItem), {}, (0, _defineProperty2.default)({}, columnKey, {
52
55
  data: newValue.values[0]
@@ -0,0 +1,63 @@
1
+ import { useEffect, useState } from 'react';
2
+ import { ActionOperationStatus } from '@atlaskit/linking-types';
3
+ import { useDatasourceTableFlag } from './useDatasourceTableFlag';
4
+ const loadOptions = async (fetchInputs = {}, executeFetch) => {
5
+ if (!executeFetch) {
6
+ return [];
7
+ }
8
+ const result = await executeFetch(fetchInputs);
9
+ const {
10
+ operationStatus,
11
+ entities
12
+ } = result;
13
+ if (operationStatus === ActionOperationStatus.FAILURE) {
14
+ throw new Error('Failed to fetch status options');
15
+ }
16
+ return entities !== null && entities !== void 0 ? entities : [];
17
+ };
18
+ export const useLoadOptions = ({
19
+ fetchInputs,
20
+ executeFetch
21
+ }) => {
22
+ const [{
23
+ options,
24
+ isLoading,
25
+ hasFailed
26
+ }, setOptions] = useState({
27
+ isLoading: true,
28
+ options: [],
29
+ hasFailed: false
30
+ });
31
+ const {
32
+ showErrorFlag
33
+ } = useDatasourceTableFlag({
34
+ isFetchAction: true
35
+ });
36
+ useEffect(() => {
37
+ let isMounted = true;
38
+ loadOptions(fetchInputs, executeFetch).then(options => {
39
+ if (isMounted) {
40
+ setOptions({
41
+ isLoading: false,
42
+ options,
43
+ hasFailed: false
44
+ });
45
+ }
46
+ }).catch(err => {
47
+ showErrorFlag();
48
+ setOptions({
49
+ isLoading: false,
50
+ options: [],
51
+ hasFailed: true
52
+ });
53
+ });
54
+ return () => {
55
+ isMounted = false;
56
+ };
57
+ }, [fetchInputs, executeFetch, showErrorFlag]);
58
+ return {
59
+ options,
60
+ isLoading,
61
+ hasFailed
62
+ };
63
+ };
@@ -8,6 +8,7 @@ import { useEffect } from 'react';
8
8
  import { css, jsx } from '@emotion/react';
9
9
  import { FormattedMessage } from 'react-intl-next';
10
10
  import Button from '@atlaskit/button/standard-button';
11
+ import { Box, Inline, Text } from '@atlaskit/primitives';
11
12
  import { fontFallback } from '@atlaskit/theme/typography';
12
13
  import { useDatasourceAnalyticsEvents } from '../../../analytics';
13
14
  import { LoadingErrorSVG } from './loading-error-svg';
@@ -27,9 +28,6 @@ const errorMessageStyles = css({
27
28
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
28
29
  font: `var(--ds-font-heading-small, ${fontFallback.heading.small})`
29
30
  });
30
- const errorDescriptionStyles = css({
31
- margin: 0
32
- });
33
31
  export const LoadingError = ({
34
32
  onRefresh
35
33
  }) => {
@@ -41,15 +39,16 @@ export const LoadingError = ({
41
39
  reason: 'network'
42
40
  });
43
41
  }, [fireEvent]);
44
- return jsx("div", {
45
- css: errorContainerStyles,
46
- "data-testid": "datasource--loading-error"
47
- }, jsx(LoadingErrorSVG, null), jsx("div", {
48
- css: errorMessageContainerStyles
49
- }, jsx("span", {
50
- css: errorMessageStyles
51
- }, jsx(FormattedMessage, loadingErrorMessages.unableToLoadItems)), jsx("p", {
52
- css: errorDescriptionStyles
42
+ return jsx(Box, {
43
+ xcss: errorContainerStyles,
44
+ testId: "datasource--loading-error"
45
+ }, jsx(LoadingErrorSVG, null), jsx(Box, {
46
+ xcss: errorMessageContainerStyles
47
+ }, jsx(Inline, {
48
+ as: "span",
49
+ xcss: errorMessageStyles
50
+ }, jsx(FormattedMessage, loadingErrorMessages.unableToLoadItems)), jsx(Text, {
51
+ as: "p"
53
52
  }, jsx(FormattedMessage, loadingErrorMessages.checkConnection)), onRefresh && jsx(Button, {
54
53
  appearance: "primary",
55
54
  onClick: onRefresh
@@ -7,7 +7,7 @@ import { useEffect } from 'react';
7
7
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
8
8
  import { css, jsx } from '@emotion/react';
9
9
  import { FormattedMessage } from 'react-intl-next';
10
- import { fontFallback } from '@atlaskit/theme/typography';
10
+ import { Box, Text } from '@atlaskit/primitives';
11
11
  import { useDatasourceAnalyticsEvents } from '../../../analytics';
12
12
  import { LoadingErrorSVG } from './loading-error-svg';
13
13
  import { loadingErrorMessages } from './messages';
@@ -22,13 +22,6 @@ const errorMessageContainerStyles = css({
22
22
  gap: "var(--ds-space-100, 8px)",
23
23
  placeItems: 'center'
24
24
  });
25
- const errorMessageStyles = css({
26
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
27
- font: `var(--ds-font-heading-small, ${fontFallback.heading.small})`
28
- });
29
- const errorDescriptionStyles = css({
30
- margin: 0
31
- });
32
25
  export const ModalLoadingError = ({
33
26
  errorMessage = jsx(FormattedMessage, loadingErrorMessages.checkConnection)
34
27
  }) => {
@@ -40,14 +33,14 @@ export const ModalLoadingError = ({
40
33
  reason: 'network'
41
34
  });
42
35
  }, [fireEvent]);
43
- return jsx("div", {
44
- css: errorContainerStyles,
45
- "data-testid": "datasource-modal--loading-error"
46
- }, jsx(LoadingErrorSVG, null), jsx("div", {
47
- css: errorMessageContainerStyles
48
- }, jsx("span", {
49
- css: errorMessageStyles
50
- }, jsx(FormattedMessage, loadingErrorMessages.unableToLoadResults)), jsx("p", {
51
- css: errorDescriptionStyles
36
+ return jsx(Box, {
37
+ xcss: errorContainerStyles,
38
+ testId: "datasource-modal--loading-error"
39
+ }, jsx(LoadingErrorSVG, null), jsx(Box, {
40
+ xcss: errorMessageContainerStyles
41
+ }, jsx(Text, {
42
+ size: "small"
43
+ }, jsx(FormattedMessage, loadingErrorMessages.unableToLoadResults)), jsx(Text, {
44
+ as: "p"
52
45
  }, errorMessage)));
53
46
  };
@@ -3,18 +3,16 @@
3
3
  * @jsx jsx
4
4
  */
5
5
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
6
- import { css, jsx } from '@emotion/react';
6
+ import { jsx } from '@emotion/react';
7
7
  import { useIntl } from 'react-intl-next';
8
- import { Flex, xcss } from '@atlaskit/primitives';
9
- import { fontFallback } from '@atlaskit/theme/typography';
8
+ import { Flex, Inline, xcss } from '@atlaskit/primitives';
10
9
  import { NoInstancesSvg } from './no-instances-svg';
11
- const titleStyles = css({
12
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
13
- font: `var(--ds-font-heading-small, ${fontFallback.heading.small})`,
14
- marginTop: "var(--ds-space-200, 16px)"
10
+ const titleStyles = xcss({
11
+ font: 'font.heading.small',
12
+ marginTop: 'space.200'
15
13
  });
16
- const descriptionStyles = css({
17
- marginTop: "var(--ds-space-100, 8px)"
14
+ const descriptionStyles = xcss({
15
+ marginTop: 'space.100'
18
16
  });
19
17
  const containerStyles = xcss({
20
18
  marginTop: 'space.800'
@@ -32,9 +30,11 @@ export const NoInstancesView = ({
32
30
  direction: "column",
33
31
  alignItems: "center",
34
32
  xcss: containerStyles
35
- }, jsx(NoInstancesSvg, null), jsx("span", {
36
- css: titleStyles
37
- }, formatMessage(title)), jsx("span", {
38
- css: descriptionStyles
33
+ }, jsx(NoInstancesSvg, null), jsx(Inline, {
34
+ as: "span",
35
+ xcss: titleStyles
36
+ }, formatMessage(title)), jsx(Inline, {
37
+ as: "span",
38
+ xcss: descriptionStyles
39
39
  }, formatMessage(description)));
40
40
  };
@@ -5,28 +5,22 @@
5
5
  import { useEffect } from 'react';
6
6
 
7
7
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
8
- import { css, jsx } from '@emotion/react';
8
+ import { jsx } from '@emotion/react';
9
9
  import { FormattedMessage } from 'react-intl-next';
10
10
  import Button from '@atlaskit/button/standard-button';
11
- import { fontFallback } from '@atlaskit/theme/typography';
11
+ import { Grid, Text, xcss } from '@atlaskit/primitives';
12
12
  import { useDatasourceAnalyticsEvents } from '../../../analytics';
13
13
  import { loadingErrorMessages } from './messages';
14
- const noResultsContainerStyles = css({
15
- margin: `${"var(--ds-space-500, 40px)"} auto`,
16
- display: 'grid',
17
- gap: "var(--ds-space-300, 24px)",
14
+ const noResultsContainerStyles = xcss({
15
+ margin: 'space.500',
16
+ gap: 'space.300',
18
17
  placeItems: 'center',
19
18
  placeSelf: 'center'
20
19
  });
21
- const noResultsMessageContainerStyles = css({
22
- display: 'grid',
23
- gap: "var(--ds-space-100, 8px)",
20
+ const noResultsMessageContainerStyles = xcss({
21
+ gap: 'space.100',
24
22
  placeItems: 'center'
25
23
  });
26
- const noResultsMessageStyles = css({
27
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
28
- font: `var(--ds-font-heading-small, ${fontFallback.heading.small})`
29
- });
30
24
  export const NoResults = ({
31
25
  onRefresh
32
26
  }) => {
@@ -36,9 +30,9 @@ export const NoResults = ({
36
30
  useEffect(() => {
37
31
  fireEvent('ui.emptyResult.shown.datasource', {});
38
32
  }, [fireEvent]);
39
- return jsx("div", {
40
- css: noResultsContainerStyles,
41
- "data-testid": "datasource-modal--no-results"
33
+ return jsx(Grid, {
34
+ xcss: noResultsContainerStyles,
35
+ testId: "datasource-modal--no-results"
42
36
  }, jsx("svg", {
43
37
  width: "131",
44
38
  height: "120",
@@ -164,10 +158,12 @@ export const NoResults = ({
164
158
  width: "130.927",
165
159
  height: "120",
166
160
  fill: "white"
167
- })))), jsx("div", {
168
- css: noResultsMessageContainerStyles
169
- }, jsx("span", {
170
- css: noResultsMessageStyles
161
+ })))), jsx(Grid, {
162
+ xcss: noResultsMessageContainerStyles
163
+ }, jsx(Text, {
164
+ as: "span",
165
+ size: "large",
166
+ weight: "bold"
171
167
  }, jsx(FormattedMessage, loadingErrorMessages.noResultsFound)), onRefresh && jsx(Button, {
172
168
  appearance: "primary",
173
169
  onClick: onRefresh
@@ -3,32 +3,36 @@
3
3
  * @jsx jsx
4
4
  */
5
5
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
6
- import { css, jsx } from '@emotion/react';
6
+ import { jsx } from '@emotion/react';
7
7
  import { FormattedMessage } from 'react-intl-next';
8
- import { B400, N0 } from '@atlaskit/theme/colors';
8
+ import { Box, xcss } from '@atlaskit/primitives';
9
9
  import LinkRenderType from '../../../issue-like-table/render-type/link';
10
- const placeholderSmartLinkStyles = css({
11
- backgroundColor: `var(--ds-surface-raised, ${N0})`,
10
+ const placeholderSmartLinkStyles = xcss({
11
+ backgroundColor: 'elevation.surface.raised',
12
12
  borderRadius: "var(--ds-border-radius-200, 3px)",
13
- boxShadow: '0px 1px 1px rgba(9, 30, 66, 0.25), 0px 0px 1px rgba(9, 30, 66, 0.31)',
14
- color: `var(--ds-text-brand, ${B400})`,
15
- padding: `${"var(--ds-space-0, 0px)"} ${"var(--ds-space-025, 2px)"}`
13
+ color: 'color.text.brand',
14
+ paddingTop: 'space.0',
15
+ paddingBottom: 'space.0',
16
+ paddingLeft: 'space.025',
17
+ paddingRight: 'space.025',
18
+ boxShadow: 'elevation.shadow.raised'
16
19
  });
17
- const smartLinkContainerStyles = css({
18
- paddingLeft: "var(--ds-space-025, 2px)"
20
+ const smartLinkContainerStyles = xcss({
21
+ paddingLeft: 'space.025'
19
22
  });
20
23
  export const SmartCardPlaceholder = ({
21
24
  placeholderText
22
- }) => jsx("div", {
23
- css: smartLinkContainerStyles
24
- }, jsx("span", {
25
- "data-testid": `datasource-modal--smart-card-placeholder`,
26
- css: placeholderSmartLinkStyles
25
+ }) => jsx(Box, {
26
+ xcss: smartLinkContainerStyles
27
+ }, jsx(Box, {
28
+ as: "span",
29
+ testId: "datasource-modal--smart-card-placeholder",
30
+ xcss: placeholderSmartLinkStyles
27
31
  }, jsx(FormattedMessage, placeholderText)));
28
32
  export const SmartLink = ({
29
33
  url
30
- }) => jsx("div", {
31
- css: smartLinkContainerStyles
34
+ }) => jsx(Box, {
35
+ xcss: smartLinkContainerStyles
32
36
  }, jsx(LinkRenderType, {
33
37
  url: url
34
38
  }));