@atlaskit/link-datasource 3.9.1 → 3.10.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.
- package/CHANGELOG.md +11 -0
- package/dist/cjs/hooks/useDatasourceTableFlag.js +12 -3
- package/dist/cjs/ui/issue-like-table/edit-type/icon/index.js +134 -0
- package/dist/cjs/ui/issue-like-table/edit-type/index.js +25 -8
- package/dist/cjs/ui/issue-like-table/edit-type/status/index.js +7 -1
- package/dist/cjs/ui/issue-like-table/messages.js +10 -0
- package/dist/cjs/ui/issue-like-table/render-type/icon/index.js +5 -0
- package/dist/cjs/ui/issue-like-table/render-type/index.js +5 -1
- package/dist/cjs/ui/issue-like-table/render-type/new-icon/index.js +25 -0
- package/dist/cjs/ui/issue-like-table/shared-components/icon/index.js +42 -0
- package/dist/es2019/hooks/useDatasourceTableFlag.js +12 -3
- package/dist/es2019/ui/issue-like-table/edit-type/icon/index.js +94 -0
- package/dist/es2019/ui/issue-like-table/edit-type/index.js +19 -6
- package/dist/es2019/ui/issue-like-table/edit-type/status/index.js +8 -1
- package/dist/es2019/ui/issue-like-table/messages.js +10 -0
- package/dist/es2019/ui/issue-like-table/render-type/icon/index.js +5 -0
- package/dist/es2019/ui/issue-like-table/render-type/index.js +3 -1
- package/dist/es2019/ui/issue-like-table/render-type/new-icon/index.js +18 -0
- package/dist/es2019/ui/issue-like-table/shared-components/icon/index.js +36 -0
- package/dist/esm/hooks/useDatasourceTableFlag.js +12 -3
- package/dist/esm/ui/issue-like-table/edit-type/icon/index.js +124 -0
- package/dist/esm/ui/issue-like-table/edit-type/index.js +25 -8
- package/dist/esm/ui/issue-like-table/edit-type/status/index.js +7 -1
- package/dist/esm/ui/issue-like-table/messages.js +10 -0
- package/dist/esm/ui/issue-like-table/render-type/icon/index.js +5 -0
- package/dist/esm/ui/issue-like-table/render-type/index.js +5 -1
- package/dist/esm/ui/issue-like-table/render-type/new-icon/index.js +18 -0
- package/dist/esm/ui/issue-like-table/shared-components/icon/index.js +35 -0
- package/dist/types/hooks/useDatasourceTableFlag.d.ts +1 -0
- package/dist/types/ui/issue-like-table/edit-type/icon/index.d.ts +14 -0
- package/dist/types/ui/issue-like-table/edit-type/index.d.ts +2 -1
- package/dist/types/ui/issue-like-table/messages.d.ts +10 -0
- package/dist/types/ui/issue-like-table/render-type/icon/index.d.ts +4 -0
- package/dist/types/ui/issue-like-table/render-type/new-icon/index.d.ts +9 -0
- package/dist/types/ui/issue-like-table/shared-components/icon/index.d.ts +23 -0
- package/dist/types/ui/issue-like-table/types.d.ts +7 -0
- package/dist/types-ts4.5/hooks/useDatasourceTableFlag.d.ts +1 -0
- package/dist/types-ts4.5/ui/issue-like-table/edit-type/icon/index.d.ts +14 -0
- package/dist/types-ts4.5/ui/issue-like-table/edit-type/index.d.ts +2 -1
- package/dist/types-ts4.5/ui/issue-like-table/messages.d.ts +10 -0
- package/dist/types-ts4.5/ui/issue-like-table/render-type/icon/index.d.ts +4 -0
- package/dist/types-ts4.5/ui/issue-like-table/render-type/new-icon/index.d.ts +9 -0
- package/dist/types-ts4.5/ui/issue-like-table/shared-components/icon/index.d.ts +23 -0
- package/dist/types-ts4.5/ui/issue-like-table/types.d.ts +7 -0
- package/package.json +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @atlaskit/link-datasource
|
|
2
2
|
|
|
3
|
+
## 3.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#161781](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/161781)
|
|
8
|
+
[`86ee3866560f2`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/86ee3866560f2) -
|
|
9
|
+
[ux] EDM-10114 Add support for priority dropdown in datasources
|
|
10
|
+
- [#163853](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/163853)
|
|
11
|
+
[`726e9811f22b4`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/726e9811f22b4) -
|
|
12
|
+
[ux] Adding error flag when `executeFetch` request fails
|
|
13
|
+
|
|
3
14
|
## 3.9.1
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -26,7 +26,7 @@ var getErrorReason = function getErrorReason(status) {
|
|
|
26
26
|
return 'request_failed';
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
|
-
var
|
|
29
|
+
var getExecuteActionErrorMessage = function getExecuteActionErrorMessage(status) {
|
|
30
30
|
switch (status) {
|
|
31
31
|
case 403:
|
|
32
32
|
return {
|
|
@@ -40,6 +40,15 @@ var getGenericErrorMessage = function getGenericErrorMessage(status) {
|
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
|
+
var getFetchActionErrorMessage = function getFetchActionErrorMessage(status) {
|
|
44
|
+
switch (status) {
|
|
45
|
+
default:
|
|
46
|
+
return {
|
|
47
|
+
title: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, _messages.issueLikeTableMessages.fetchActionErrorGenericTitle),
|
|
48
|
+
description: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, _messages.issueLikeTableMessages.fetchActionErrorGenericDescription)
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
};
|
|
43
52
|
var useDatasourceTableFlag = exports.useDatasourceTableFlag = function useDatasourceTableFlag(options) {
|
|
44
53
|
var _useFlags = (0, _flag.useFlags)(),
|
|
45
54
|
showFlag = _useFlags.showFlag;
|
|
@@ -55,11 +64,11 @@ var useDatasourceTableFlag = exports.useDatasourceTableFlag = function useDataso
|
|
|
55
64
|
}),
|
|
56
65
|
id: (0, _uuid.default)(),
|
|
57
66
|
isAutoDismiss: true
|
|
58
|
-
},
|
|
67
|
+
}, options !== null && options !== void 0 && options.isFetchAction ? getFetchActionErrorMessage(args === null || args === void 0 ? void 0 : args.status) : getExecuteActionErrorMessage(args === null || args === void 0 ? void 0 : args.status)), args));
|
|
59
68
|
fireEvent('ui.error.shown.inlineEdit', {
|
|
60
69
|
reason: getErrorReason(args === null || args === void 0 ? void 0 : args.status)
|
|
61
70
|
});
|
|
62
|
-
}, [fireEvent, showFlag]);
|
|
71
|
+
}, [fireEvent, options === null || options === void 0 ? void 0 : options.isFetchAction, showFlag]);
|
|
63
72
|
return {
|
|
64
73
|
showErrorFlag: showErrorFlag
|
|
65
74
|
};
|
|
@@ -0,0 +1,134 @@
|
|
|
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 _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
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
14
|
+
var _linkingTypes = require("@atlaskit/linking-types");
|
|
15
|
+
var _select = _interopRequireDefault(require("@atlaskit/select"));
|
|
16
|
+
var _icon = require("../../shared-components/icon");
|
|
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); }
|
|
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; }
|
|
19
|
+
// FilterOptionOption is used in the filterOption function which is part of the public API, but the type itself is not exported
|
|
20
|
+
// eslint-disable-next-line import/no-extraneous-dependencies,no-restricted-imports
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Should be gated by FF rollout of platform-datasources-enable-two-way-sync-priority
|
|
24
|
+
*/
|
|
25
|
+
var PriorityEditType = function PriorityEditType(props) {
|
|
26
|
+
var _currentValue$values;
|
|
27
|
+
var currentValue = props.currentValue,
|
|
28
|
+
executeFetch = props.executeFetch;
|
|
29
|
+
var _usePriorityOptions = usePriorityOptions(currentValue, executeFetch),
|
|
30
|
+
options = _usePriorityOptions.options,
|
|
31
|
+
isLoading = _usePriorityOptions.isLoading;
|
|
32
|
+
return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_select.default, (0, _extends2.default)({}, props, {
|
|
33
|
+
testId: "inline-edit-priority",
|
|
34
|
+
autoFocus: true,
|
|
35
|
+
defaultMenuIsOpen: true,
|
|
36
|
+
blurInputOnSelect: true,
|
|
37
|
+
getOptionValue: function getOptionValue(option) {
|
|
38
|
+
return option.label || '';
|
|
39
|
+
},
|
|
40
|
+
options: options,
|
|
41
|
+
isLoading: isLoading,
|
|
42
|
+
defaultValue: currentValue === null || currentValue === void 0 || (_currentValue$values = currentValue.values) === null || _currentValue$values === void 0 ? void 0 : _currentValue$values[0],
|
|
43
|
+
filterOption: filterOption,
|
|
44
|
+
formatOptionLabel: function formatOptionLabel(_ref) {
|
|
45
|
+
var source = _ref.source,
|
|
46
|
+
label = _ref.label,
|
|
47
|
+
text = _ref.text;
|
|
48
|
+
return /*#__PURE__*/_react.default.createElement(_icon.SharedIconComponent, {
|
|
49
|
+
iconUrl: source,
|
|
50
|
+
text: text,
|
|
51
|
+
label: label,
|
|
52
|
+
testId: "inline-edit-priority-option-".concat(label)
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
onChange: function onChange(e) {
|
|
56
|
+
return props.setEditValues({
|
|
57
|
+
type: 'icon',
|
|
58
|
+
values: e ? [e] : []
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
})));
|
|
62
|
+
};
|
|
63
|
+
var filterOption = function filterOption(option, inputValue) {
|
|
64
|
+
return option.label.toLowerCase().includes(inputValue.toLowerCase());
|
|
65
|
+
};
|
|
66
|
+
var usePriorityOptions = function usePriorityOptions(currentValue, executeFetch) {
|
|
67
|
+
var _useState = (0, _react.useState)({
|
|
68
|
+
isLoading: true,
|
|
69
|
+
options: []
|
|
70
|
+
}),
|
|
71
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
72
|
+
_useState2$ = _useState2[0],
|
|
73
|
+
options = _useState2$.options,
|
|
74
|
+
isLoading = _useState2$.isLoading,
|
|
75
|
+
setOptions = _useState2[1];
|
|
76
|
+
(0, _react.useEffect)(function () {
|
|
77
|
+
var isMounted = true;
|
|
78
|
+
loadOptions(currentValue, executeFetch).then(function (options) {
|
|
79
|
+
if (isMounted) {
|
|
80
|
+
setOptions({
|
|
81
|
+
isLoading: false,
|
|
82
|
+
options: options
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
return function () {
|
|
87
|
+
isMounted = false;
|
|
88
|
+
};
|
|
89
|
+
}, [currentValue, executeFetch]);
|
|
90
|
+
return {
|
|
91
|
+
options: options,
|
|
92
|
+
isLoading: isLoading
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Load options for the select
|
|
98
|
+
*/
|
|
99
|
+
var loadOptions = /*#__PURE__*/function () {
|
|
100
|
+
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_currentValue, executeFetch) {
|
|
101
|
+
var _yield$executeFetch, operationStatus, entities;
|
|
102
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
103
|
+
while (1) switch (_context.prev = _context.next) {
|
|
104
|
+
case 0:
|
|
105
|
+
if (executeFetch) {
|
|
106
|
+
_context.next = 2;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
return _context.abrupt("return", []);
|
|
110
|
+
case 2:
|
|
111
|
+
_context.next = 4;
|
|
112
|
+
return executeFetch({});
|
|
113
|
+
case 4:
|
|
114
|
+
_yield$executeFetch = _context.sent;
|
|
115
|
+
operationStatus = _yield$executeFetch.operationStatus;
|
|
116
|
+
entities = _yield$executeFetch.entities;
|
|
117
|
+
if (!(operationStatus === _linkingTypes.ActionOperationStatus.SUCCESS && entities)) {
|
|
118
|
+
_context.next = 9;
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
return _context.abrupt("return", entities);
|
|
122
|
+
case 9:
|
|
123
|
+
return _context.abrupt("return", []);
|
|
124
|
+
case 10:
|
|
125
|
+
case "end":
|
|
126
|
+
return _context.stop();
|
|
127
|
+
}
|
|
128
|
+
}, _callee);
|
|
129
|
+
}));
|
|
130
|
+
return function loadOptions(_x, _x2) {
|
|
131
|
+
return _ref2.apply(this, arguments);
|
|
132
|
+
};
|
|
133
|
+
}();
|
|
134
|
+
var _default = exports.default = PriorityEditType;
|
|
@@ -6,12 +6,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.isEditTypeSupported = exports.isEditTypeSelectable = exports.editType = void 0;
|
|
9
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
9
11
|
var _objectDestructuringEmpty2 = _interopRequireDefault(require("@babel/runtime/helpers/objectDestructuringEmpty"));
|
|
10
12
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
13
|
var _react = _interopRequireDefault(require("react"));
|
|
12
14
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
|
+
var _icon = _interopRequireDefault(require("./icon"));
|
|
13
16
|
var _status = _interopRequireDefault(require("./status"));
|
|
14
17
|
var _text = _interopRequireWildcard(require("./text"));
|
|
18
|
+
var _excluded = ["value"];
|
|
15
19
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
16
20
|
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
21
|
// This is used in editor-card-plugin to identify if any type of inline edit is active.
|
|
@@ -34,12 +38,13 @@ var editType = exports.editType = function editType(_ref) {
|
|
|
34
38
|
}));
|
|
35
39
|
}
|
|
36
40
|
};
|
|
37
|
-
case '
|
|
41
|
+
case 'icon':
|
|
38
42
|
return {
|
|
39
43
|
defaultValue: (0, _text.toTextValue)(defaultValue),
|
|
40
44
|
editView: function editView(_ref3) {
|
|
41
|
-
var
|
|
42
|
-
|
|
45
|
+
var value = _ref3.value,
|
|
46
|
+
fieldProps = (0, _objectWithoutProperties2.default)(_ref3, _excluded);
|
|
47
|
+
return /*#__PURE__*/_react.default.createElement(_icon.default, (0, _extends2.default)({}, fieldProps, {
|
|
43
48
|
currentValue: currentValue,
|
|
44
49
|
setEditValues: setEditValues,
|
|
45
50
|
id: ACTIVE_INLINE_EDIT_ID,
|
|
@@ -47,17 +52,29 @@ var editType = exports.editType = function editType(_ref) {
|
|
|
47
52
|
}));
|
|
48
53
|
}
|
|
49
54
|
};
|
|
50
|
-
|
|
55
|
+
case 'status':
|
|
51
56
|
return {
|
|
52
|
-
defaultValue:
|
|
53
|
-
editView: function editView() {
|
|
54
|
-
|
|
57
|
+
defaultValue: (0, _text.toTextValue)(defaultValue),
|
|
58
|
+
editView: function editView(_ref4) {
|
|
59
|
+
var fieldProps = (0, _extends2.default)({}, ((0, _objectDestructuringEmpty2.default)(_ref4), _ref4));
|
|
60
|
+
return /*#__PURE__*/_react.default.createElement(_status.default, (0, _extends2.default)({}, fieldProps, {
|
|
61
|
+
currentValue: currentValue,
|
|
62
|
+
setEditValues: setEditValues,
|
|
63
|
+
id: ACTIVE_INLINE_EDIT_ID,
|
|
64
|
+
executeFetch: executeFetch
|
|
65
|
+
}));
|
|
55
66
|
}
|
|
56
67
|
};
|
|
57
68
|
}
|
|
69
|
+
return {
|
|
70
|
+
defaultValue: '',
|
|
71
|
+
editView: function editView() {
|
|
72
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
58
75
|
};
|
|
59
76
|
var isEditTypeSupported = exports.isEditTypeSupported = function isEditTypeSupported(type) {
|
|
60
|
-
var supportedEditType = (0, _platformFeatureFlags.fg)('platform-datasources-enable-two-way-sync-statuses') ? ['
|
|
77
|
+
var supportedEditType = ['string'].concat((0, _toConsumableArray2.default)((0, _platformFeatureFlags.fg)('platform-datasources-enable-two-way-sync-statuses') ? ['status'] : []), (0, _toConsumableArray2.default)((0, _platformFeatureFlags.fg)('platform-datasources-enable-two-way-sync-priority') ? ['icon'] : []));
|
|
61
78
|
return supportedEditType.includes(type);
|
|
62
79
|
};
|
|
63
80
|
var isEditTypeSelectable = exports.isEditTypeSelectable = function isEditTypeSelectable(type) {
|
|
@@ -16,6 +16,7 @@ var _lozenge = _interopRequireDefault(require("@atlaskit/lozenge"));
|
|
|
16
16
|
var _select = _interopRequireDefault(require("@atlaskit/select"));
|
|
17
17
|
var _ufoExperiences = require("../../../../analytics/ufoExperiences");
|
|
18
18
|
var _datasourceExperienceId = require("../../../../contexts/datasource-experience-id");
|
|
19
|
+
var _useDatasourceTableFlag = require("../../../../hooks/useDatasourceTableFlag");
|
|
19
20
|
var _inlineEdit = require("../../table-cell-content/inline-edit");
|
|
20
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); }
|
|
21
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; }
|
|
@@ -87,6 +88,10 @@ var useStatusOptions = function useStatusOptions(_ref) {
|
|
|
87
88
|
isLoading = _useState2$.isLoading,
|
|
88
89
|
hasFailed = _useState2$.hasFailed,
|
|
89
90
|
setOptions = _useState2[1];
|
|
91
|
+
var _useDatasourceTableFl = (0, _useDatasourceTableFlag.useDatasourceTableFlag)({
|
|
92
|
+
isFetchAction: true
|
|
93
|
+
}),
|
|
94
|
+
showErrorFlag = _useDatasourceTableFl.showErrorFlag;
|
|
90
95
|
(0, _react.useEffect)(function () {
|
|
91
96
|
var isMounted = true;
|
|
92
97
|
loadOptions(fetchInputs, executeFetch).then(function (options) {
|
|
@@ -98,6 +103,7 @@ var useStatusOptions = function useStatusOptions(_ref) {
|
|
|
98
103
|
});
|
|
99
104
|
}
|
|
100
105
|
}).catch(function (err) {
|
|
106
|
+
showErrorFlag();
|
|
101
107
|
setOptions({
|
|
102
108
|
isLoading: false,
|
|
103
109
|
options: [],
|
|
@@ -107,7 +113,7 @@ var useStatusOptions = function useStatusOptions(_ref) {
|
|
|
107
113
|
return function () {
|
|
108
114
|
isMounted = false;
|
|
109
115
|
};
|
|
110
|
-
}, [fetchInputs, executeFetch]);
|
|
116
|
+
}, [fetchInputs, executeFetch, showErrorFlag]);
|
|
111
117
|
return {
|
|
112
118
|
options: options,
|
|
113
119
|
isLoading: isLoading,
|
|
@@ -26,6 +26,16 @@ var issueLikeTableMessages = exports.issueLikeTableMessages = (0, _reactIntlNext
|
|
|
26
26
|
description: 'Generic error message title shown when updating issue field fails',
|
|
27
27
|
defaultMessage: 'Something went wrong'
|
|
28
28
|
},
|
|
29
|
+
fetchActionErrorGenericDescription: {
|
|
30
|
+
id: 'linkDataSource.issue-line-table.fetch-action-error-generic-description',
|
|
31
|
+
description: 'Generic error message description shown when fetching inline edit dropdown field fails',
|
|
32
|
+
defaultMessage: 'Wait a few minutes, then try again. Check your project settings or contact support if this keeps happening.'
|
|
33
|
+
},
|
|
34
|
+
fetchActionErrorGenericTitle: {
|
|
35
|
+
id: 'linkDataSource.issue-line-table.fetch-action-error-generic-title',
|
|
36
|
+
description: 'Generic error message title shown when fetching inline edit dropdown field fails',
|
|
37
|
+
defaultMessage: 'We’re having trouble fetching options'
|
|
38
|
+
},
|
|
29
39
|
wrapText: {
|
|
30
40
|
id: 'linkDataSource.issue-line-table.wrap-text',
|
|
31
41
|
description: 'Table header Dropdown item for making whole column to wrap text',
|
|
@@ -25,6 +25,11 @@ var textWrapperStyles = (0, _primitives.xcss)({
|
|
|
25
25
|
});
|
|
26
26
|
var ICON_TYPE_TEST_ID = exports.ICON_TYPE_TEST_ID = 'link-datasource-render-type--icon';
|
|
27
27
|
var ICON_TYPE_TEXT_TEST_ID = exports.ICON_TYPE_TEXT_TEST_ID = "".concat(ICON_TYPE_TEST_ID, "-text");
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @deprecated: To be cleaned up and replaced with new-icon after
|
|
31
|
+
* `platform-datasources-enable-two-way-sync-priority` rollout.
|
|
32
|
+
*/
|
|
28
33
|
var IconRenderType = function IconRenderType(_ref) {
|
|
29
34
|
var label = _ref.label,
|
|
30
35
|
text = _ref.text,
|
|
@@ -8,10 +8,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.stringifyType = exports.renderType = void 0;
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
12
|
var _boolean = _interopRequireDefault(require("./boolean"));
|
|
12
13
|
var _dateTime = _interopRequireWildcard(require("./date-time"));
|
|
13
14
|
var _icon = _interopRequireDefault(require("./icon"));
|
|
14
15
|
var _link = _interopRequireDefault(require("./link"));
|
|
16
|
+
var _newIcon = _interopRequireDefault(require("./new-icon"));
|
|
15
17
|
var _number = _interopRequireDefault(require("./number"));
|
|
16
18
|
var _richtext = _interopRequireWildcard(require("./richtext"));
|
|
17
19
|
var _status = _interopRequireDefault(require("./status"));
|
|
@@ -75,7 +77,9 @@ var renderType = exports.renderType = function renderType(item) {
|
|
|
75
77
|
});
|
|
76
78
|
});
|
|
77
79
|
case 'icon':
|
|
78
|
-
return item.values.map(function (iconValue) {
|
|
80
|
+
return (0, _platformFeatureFlags.fg)('platform-datasources-enable-two-way-sync-priority') ? item.values.map(function (iconValue) {
|
|
81
|
+
return /*#__PURE__*/_react.default.createElement(_newIcon.default, iconValue);
|
|
82
|
+
}) : item.values.map(function (iconValue) {
|
|
79
83
|
return /*#__PURE__*/_react.default.createElement(_icon.default, iconValue);
|
|
80
84
|
});
|
|
81
85
|
case 'link':
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = exports.ICON_TYPE_TEXT_TEST_ID = exports.ICON_TYPE_TEST_ID = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _icon = require("../../shared-components/icon");
|
|
10
|
+
var ICON_TYPE_TEST_ID = exports.ICON_TYPE_TEST_ID = 'link-datasource-render-type--icon';
|
|
11
|
+
var ICON_TYPE_TEXT_TEST_ID = exports.ICON_TYPE_TEXT_TEST_ID = "".concat(ICON_TYPE_TEST_ID, "-text");
|
|
12
|
+
var IconRenderType = function IconRenderType(_ref) {
|
|
13
|
+
var label = _ref.label,
|
|
14
|
+
text = _ref.text,
|
|
15
|
+
source = _ref.source,
|
|
16
|
+
_ref$testId = _ref.testId,
|
|
17
|
+
testId = _ref$testId === void 0 ? ICON_TYPE_TEST_ID : _ref$testId;
|
|
18
|
+
return /*#__PURE__*/_react.default.createElement(_icon.SharedIconComponent, {
|
|
19
|
+
testId: testId,
|
|
20
|
+
iconUrl: source,
|
|
21
|
+
label: label,
|
|
22
|
+
text: text
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
var _default = exports.default = IconRenderType;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.SharedIconComponent = SharedIconComponent;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _primitives = require("@atlaskit/primitives");
|
|
10
|
+
var labelStyles = (0, _primitives.xcss)({
|
|
11
|
+
overflow: 'hidden',
|
|
12
|
+
textOverflow: 'ellipsis',
|
|
13
|
+
width: '100%'
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
* Renders a icon and label.
|
|
17
|
+
* If the text is undefined, render the capitalised label.
|
|
18
|
+
*/
|
|
19
|
+
function SharedIconComponent(_ref) {
|
|
20
|
+
var iconUrl = _ref.iconUrl,
|
|
21
|
+
label = _ref.label,
|
|
22
|
+
text = _ref.text,
|
|
23
|
+
testId = _ref.testId;
|
|
24
|
+
var displayText = text === undefined || text === '' ? label ? label.charAt(0).toUpperCase() + label.slice(1) : undefined : text;
|
|
25
|
+
return /*#__PURE__*/_react.default.createElement(_primitives.Flex, {
|
|
26
|
+
gap: "space.100",
|
|
27
|
+
alignItems: "center",
|
|
28
|
+
testId: testId
|
|
29
|
+
}, /*#__PURE__*/_react.default.createElement(_primitives.Inline, null, /*#__PURE__*/_react.default.createElement("img", {
|
|
30
|
+
src: iconUrl,
|
|
31
|
+
alt: label
|
|
32
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
33
|
+
,
|
|
34
|
+
style: {
|
|
35
|
+
minWidth: '24px',
|
|
36
|
+
maxWidth: '24px'
|
|
37
|
+
} // having just width: '24px' shrinks it when table width is reduced
|
|
38
|
+
})), displayText && /*#__PURE__*/_react.default.createElement(_primitives.Box, {
|
|
39
|
+
xcss: labelStyles,
|
|
40
|
+
testId: "".concat(testId, "-text")
|
|
41
|
+
}, displayText));
|
|
42
|
+
}
|
|
@@ -13,7 +13,7 @@ const getErrorReason = status => {
|
|
|
13
13
|
return 'request_failed';
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
|
-
const
|
|
16
|
+
const getExecuteActionErrorMessage = status => {
|
|
17
17
|
switch (status) {
|
|
18
18
|
case 403:
|
|
19
19
|
return {
|
|
@@ -27,6 +27,15 @@ const getGenericErrorMessage = status => {
|
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
|
+
const getFetchActionErrorMessage = status => {
|
|
31
|
+
switch (status) {
|
|
32
|
+
default:
|
|
33
|
+
return {
|
|
34
|
+
title: /*#__PURE__*/React.createElement(FormattedMessage, issueLikeTableMessages.fetchActionErrorGenericTitle),
|
|
35
|
+
description: /*#__PURE__*/React.createElement(FormattedMessage, issueLikeTableMessages.fetchActionErrorGenericDescription)
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
};
|
|
30
39
|
export const useDatasourceTableFlag = options => {
|
|
31
40
|
const {
|
|
32
41
|
showFlag
|
|
@@ -44,13 +53,13 @@ export const useDatasourceTableFlag = options => {
|
|
|
44
53
|
}),
|
|
45
54
|
id: uuid(),
|
|
46
55
|
isAutoDismiss: true,
|
|
47
|
-
...
|
|
56
|
+
...(options !== null && options !== void 0 && options.isFetchAction ? getFetchActionErrorMessage(args === null || args === void 0 ? void 0 : args.status) : getExecuteActionErrorMessage(args === null || args === void 0 ? void 0 : args.status)),
|
|
48
57
|
...args
|
|
49
58
|
});
|
|
50
59
|
fireEvent('ui.error.shown.inlineEdit', {
|
|
51
60
|
reason: getErrorReason(args === null || args === void 0 ? void 0 : args.status)
|
|
52
61
|
});
|
|
53
|
-
}, [fireEvent, showFlag]);
|
|
62
|
+
}, [fireEvent, options === null || options === void 0 ? void 0 : options.isFetchAction, showFlag]);
|
|
54
63
|
return {
|
|
55
64
|
showErrorFlag
|
|
56
65
|
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React, { useEffect, useState } from 'react';
|
|
3
|
+
import { ActionOperationStatus } from '@atlaskit/linking-types';
|
|
4
|
+
// FilterOptionOption is used in the filterOption function which is part of the public API, but the type itself is not exported
|
|
5
|
+
// eslint-disable-next-line import/no-extraneous-dependencies,no-restricted-imports
|
|
6
|
+
|
|
7
|
+
import Select from '@atlaskit/select';
|
|
8
|
+
import { SharedIconComponent } from '../../shared-components/icon';
|
|
9
|
+
/**
|
|
10
|
+
* Should be gated by FF rollout of platform-datasources-enable-two-way-sync-priority
|
|
11
|
+
*/
|
|
12
|
+
const PriorityEditType = props => {
|
|
13
|
+
var _currentValue$values;
|
|
14
|
+
const {
|
|
15
|
+
currentValue,
|
|
16
|
+
executeFetch
|
|
17
|
+
} = props;
|
|
18
|
+
const {
|
|
19
|
+
options,
|
|
20
|
+
isLoading
|
|
21
|
+
} = usePriorityOptions(currentValue, executeFetch);
|
|
22
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Select, _extends({}, props, {
|
|
23
|
+
testId: "inline-edit-priority",
|
|
24
|
+
autoFocus: true,
|
|
25
|
+
defaultMenuIsOpen: true,
|
|
26
|
+
blurInputOnSelect: true,
|
|
27
|
+
getOptionValue: option => option.label || '',
|
|
28
|
+
options: options,
|
|
29
|
+
isLoading: isLoading,
|
|
30
|
+
defaultValue: currentValue === null || currentValue === void 0 ? void 0 : (_currentValue$values = currentValue.values) === null || _currentValue$values === void 0 ? void 0 : _currentValue$values[0],
|
|
31
|
+
filterOption: filterOption,
|
|
32
|
+
formatOptionLabel: ({
|
|
33
|
+
source,
|
|
34
|
+
label,
|
|
35
|
+
text
|
|
36
|
+
}) => /*#__PURE__*/React.createElement(SharedIconComponent, {
|
|
37
|
+
iconUrl: source,
|
|
38
|
+
text: text,
|
|
39
|
+
label: label,
|
|
40
|
+
testId: `inline-edit-priority-option-${label}`
|
|
41
|
+
}),
|
|
42
|
+
onChange: e => props.setEditValues({
|
|
43
|
+
type: 'icon',
|
|
44
|
+
values: e ? [e] : []
|
|
45
|
+
})
|
|
46
|
+
})));
|
|
47
|
+
};
|
|
48
|
+
const filterOption = (option, inputValue) => option.label.toLowerCase().includes(inputValue.toLowerCase());
|
|
49
|
+
const usePriorityOptions = (currentValue, executeFetch) => {
|
|
50
|
+
const [{
|
|
51
|
+
options,
|
|
52
|
+
isLoading
|
|
53
|
+
}, setOptions] = useState({
|
|
54
|
+
isLoading: true,
|
|
55
|
+
options: []
|
|
56
|
+
});
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
let isMounted = true;
|
|
59
|
+
loadOptions(currentValue, executeFetch).then(options => {
|
|
60
|
+
if (isMounted) {
|
|
61
|
+
setOptions({
|
|
62
|
+
isLoading: false,
|
|
63
|
+
options
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
return () => {
|
|
68
|
+
isMounted = false;
|
|
69
|
+
};
|
|
70
|
+
}, [currentValue, executeFetch]);
|
|
71
|
+
return {
|
|
72
|
+
options,
|
|
73
|
+
isLoading
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Load options for the select
|
|
79
|
+
*/
|
|
80
|
+
const loadOptions = async (_currentValue, executeFetch) => {
|
|
81
|
+
if (!executeFetch) {
|
|
82
|
+
return [];
|
|
83
|
+
}
|
|
84
|
+
const {
|
|
85
|
+
operationStatus,
|
|
86
|
+
entities
|
|
87
|
+
} = await executeFetch({});
|
|
88
|
+
if (operationStatus === ActionOperationStatus.SUCCESS && entities) {
|
|
89
|
+
// Map entities here if the backend type is different from the type required by the select
|
|
90
|
+
return entities;
|
|
91
|
+
}
|
|
92
|
+
return [];
|
|
93
|
+
};
|
|
94
|
+
export default PriorityEditType;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
|
+
import PriorityEditType from './icon';
|
|
4
5
|
import StatusEditType from './status';
|
|
5
6
|
import TextEditType, { toTextValue } from './text';
|
|
6
7
|
|
|
@@ -24,27 +25,39 @@ export const editType = ({
|
|
|
24
25
|
id: ACTIVE_INLINE_EDIT_ID
|
|
25
26
|
}))
|
|
26
27
|
};
|
|
27
|
-
case '
|
|
28
|
+
case 'icon':
|
|
28
29
|
return {
|
|
29
30
|
defaultValue: toTextValue(defaultValue),
|
|
30
31
|
editView: ({
|
|
32
|
+
value,
|
|
31
33
|
...fieldProps
|
|
32
|
-
}) => /*#__PURE__*/React.createElement(
|
|
34
|
+
}) => /*#__PURE__*/React.createElement(PriorityEditType, _extends({}, fieldProps, {
|
|
33
35
|
currentValue: currentValue,
|
|
34
36
|
setEditValues: setEditValues,
|
|
35
37
|
id: ACTIVE_INLINE_EDIT_ID,
|
|
36
38
|
executeFetch: executeFetch
|
|
37
39
|
}))
|
|
38
40
|
};
|
|
39
|
-
|
|
41
|
+
case 'status':
|
|
40
42
|
return {
|
|
41
|
-
defaultValue:
|
|
42
|
-
editView: (
|
|
43
|
+
defaultValue: toTextValue(defaultValue),
|
|
44
|
+
editView: ({
|
|
45
|
+
...fieldProps
|
|
46
|
+
}) => /*#__PURE__*/React.createElement(StatusEditType, _extends({}, fieldProps, {
|
|
47
|
+
currentValue: currentValue,
|
|
48
|
+
setEditValues: setEditValues,
|
|
49
|
+
id: ACTIVE_INLINE_EDIT_ID,
|
|
50
|
+
executeFetch: executeFetch
|
|
51
|
+
}))
|
|
43
52
|
};
|
|
44
53
|
}
|
|
54
|
+
return {
|
|
55
|
+
defaultValue: '',
|
|
56
|
+
editView: () => /*#__PURE__*/React.createElement(React.Fragment, null)
|
|
57
|
+
};
|
|
45
58
|
};
|
|
46
59
|
export const isEditTypeSupported = type => {
|
|
47
|
-
const supportedEditType = fg('platform-datasources-enable-two-way-sync-statuses') ? ['
|
|
60
|
+
const supportedEditType = ['string', ...(fg('platform-datasources-enable-two-way-sync-statuses') ? ['status'] : []), ...(fg('platform-datasources-enable-two-way-sync-priority') ? ['icon'] : [])];
|
|
48
61
|
return supportedEditType.includes(type);
|
|
49
62
|
};
|
|
50
63
|
export const isEditTypeSelectable = type => {
|
|
@@ -5,6 +5,7 @@ import Lozenge from '@atlaskit/lozenge';
|
|
|
5
5
|
import Select from '@atlaskit/select';
|
|
6
6
|
import { failUfoExperience, succeedUfoExperience } from '../../../../analytics/ufoExperiences';
|
|
7
7
|
import { useDatasourceExperienceId } from '../../../../contexts/datasource-experience-id';
|
|
8
|
+
import { useDatasourceTableFlag } from '../../../../hooks/useDatasourceTableFlag';
|
|
8
9
|
import { InlineEditUFOExperience } from '../../table-cell-content/inline-edit';
|
|
9
10
|
const StatusEditType = props => {
|
|
10
11
|
var _currentValue$values;
|
|
@@ -68,6 +69,11 @@ const useStatusOptions = ({
|
|
|
68
69
|
options: [],
|
|
69
70
|
hasFailed: false
|
|
70
71
|
});
|
|
72
|
+
const {
|
|
73
|
+
showErrorFlag
|
|
74
|
+
} = useDatasourceTableFlag({
|
|
75
|
+
isFetchAction: true
|
|
76
|
+
});
|
|
71
77
|
useEffect(() => {
|
|
72
78
|
let isMounted = true;
|
|
73
79
|
loadOptions(fetchInputs, executeFetch).then(options => {
|
|
@@ -79,6 +85,7 @@ const useStatusOptions = ({
|
|
|
79
85
|
});
|
|
80
86
|
}
|
|
81
87
|
}).catch(err => {
|
|
88
|
+
showErrorFlag();
|
|
82
89
|
setOptions({
|
|
83
90
|
isLoading: false,
|
|
84
91
|
options: [],
|
|
@@ -88,7 +95,7 @@ const useStatusOptions = ({
|
|
|
88
95
|
return () => {
|
|
89
96
|
isMounted = false;
|
|
90
97
|
};
|
|
91
|
-
}, [fetchInputs, executeFetch]);
|
|
98
|
+
}, [fetchInputs, executeFetch, showErrorFlag]);
|
|
92
99
|
return {
|
|
93
100
|
options,
|
|
94
101
|
isLoading,
|
|
@@ -20,6 +20,16 @@ export const issueLikeTableMessages = defineMessages({
|
|
|
20
20
|
description: 'Generic error message title shown when updating issue field fails',
|
|
21
21
|
defaultMessage: 'Something went wrong'
|
|
22
22
|
},
|
|
23
|
+
fetchActionErrorGenericDescription: {
|
|
24
|
+
id: 'linkDataSource.issue-line-table.fetch-action-error-generic-description',
|
|
25
|
+
description: 'Generic error message description shown when fetching inline edit dropdown field fails',
|
|
26
|
+
defaultMessage: 'Wait a few minutes, then try again. Check your project settings or contact support if this keeps happening.'
|
|
27
|
+
},
|
|
28
|
+
fetchActionErrorGenericTitle: {
|
|
29
|
+
id: 'linkDataSource.issue-line-table.fetch-action-error-generic-title',
|
|
30
|
+
description: 'Generic error message title shown when fetching inline edit dropdown field fails',
|
|
31
|
+
defaultMessage: 'We’re having trouble fetching options'
|
|
32
|
+
},
|
|
23
33
|
wrapText: {
|
|
24
34
|
id: 'linkDataSource.issue-line-table.wrap-text',
|
|
25
35
|
description: 'Table header Dropdown item for making whole column to wrap text',
|