@atlaskit/link-datasource 3.12.1 → 3.13.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 +15 -0
- package/dist/cjs/hooks/useLoadOptions.js +100 -0
- package/dist/cjs/ui/issue-like-table/edit-type/icon/index.js +16 -106
- package/dist/cjs/ui/issue-like-table/edit-type/index.js +26 -9
- package/dist/cjs/ui/issue-like-table/edit-type/status/index.js +10 -112
- package/dist/cjs/ui/issue-like-table/edit-type/text/index.js +4 -6
- package/dist/cjs/ui/issue-like-table/edit-type/user/index.js +97 -0
- package/dist/cjs/ui/issue-like-table/table-cell-content/inline-edit.js +5 -2
- package/dist/es2019/hooks/useLoadOptions.js +63 -0
- package/dist/es2019/ui/issue-like-table/edit-type/icon/index.js +13 -74
- package/dist/es2019/ui/issue-like-table/edit-type/index.js +24 -5
- package/dist/es2019/ui/issue-like-table/edit-type/status/index.js +8 -76
- package/dist/es2019/ui/issue-like-table/edit-type/text/index.js +5 -5
- package/dist/es2019/ui/issue-like-table/edit-type/user/index.js +74 -0
- package/dist/es2019/ui/issue-like-table/table-cell-content/inline-edit.js +5 -2
- package/dist/esm/hooks/useLoadOptions.js +93 -0
- package/dist/esm/ui/issue-like-table/edit-type/icon/index.js +18 -107
- package/dist/esm/ui/issue-like-table/edit-type/index.js +25 -5
- package/dist/esm/ui/issue-like-table/edit-type/status/index.js +11 -113
- package/dist/esm/ui/issue-like-table/edit-type/text/index.js +3 -5
- package/dist/esm/ui/issue-like-table/edit-type/user/index.js +87 -0
- package/dist/esm/ui/issue-like-table/table-cell-content/inline-edit.js +5 -2
- package/dist/types/hooks/useLoadOptions.d.ts +11 -0
- package/dist/types/ui/issue-like-table/edit-type/icon/index.d.ts +2 -2
- package/dist/types/ui/issue-like-table/edit-type/index.d.ts +1 -0
- package/dist/types/ui/issue-like-table/edit-type/status/index.d.ts +4 -4
- package/dist/types/ui/issue-like-table/edit-type/text/index.d.ts +2 -3
- package/dist/types/ui/issue-like-table/edit-type/user/index.d.ts +11 -0
- package/dist/types/ui/issue-like-table/types.d.ts +3 -0
- package/dist/types-ts4.5/hooks/useLoadOptions.d.ts +11 -0
- package/dist/types-ts4.5/ui/issue-like-table/edit-type/icon/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/issue-like-table/edit-type/index.d.ts +1 -0
- package/dist/types-ts4.5/ui/issue-like-table/edit-type/status/index.d.ts +4 -4
- package/dist/types-ts4.5/ui/issue-like-table/edit-type/text/index.d.ts +2 -3
- package/dist/types-ts4.5/ui/issue-like-table/edit-type/user/index.d.ts +11 -0
- package/dist/types-ts4.5/ui/issue-like-table/types.d.ts +3 -0
- package/package.json +7 -4
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
import { ActionOperationStatus } from '@atlaskit/linking-types';
|
|
2
|
+
import React, { useEffect } from 'react';
|
|
3
|
+
|
|
7
4
|
// FilterOptionOption is used in the filterOption function which is part of the public API, but the type itself is not exported
|
|
8
5
|
// eslint-disable-next-line import/no-extraneous-dependencies,no-restricted-imports
|
|
9
6
|
|
|
10
7
|
import Select from '@atlaskit/select';
|
|
11
8
|
import { failUfoExperience, succeedUfoExperience } from '../../../../analytics/ufoExperiences';
|
|
12
9
|
import { useDatasourceExperienceId } from '../../../../contexts/datasource-experience-id';
|
|
13
|
-
import {
|
|
10
|
+
import { useLoadOptions } from '../../../../hooks/useLoadOptions';
|
|
14
11
|
import { SharedIconComponent } from '../../shared-components/icon';
|
|
15
12
|
import { InlineEditUFOExperience } from '../../table-cell-content/inline-edit';
|
|
16
13
|
/**
|
|
@@ -20,10 +17,12 @@ var IconEditType = function IconEditType(props) {
|
|
|
20
17
|
var _currentValue$values;
|
|
21
18
|
var currentValue = props.currentValue,
|
|
22
19
|
executeFetch = props.executeFetch;
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
var _useLoadOptions = useLoadOptions({
|
|
21
|
+
executeFetch: executeFetch
|
|
22
|
+
}),
|
|
23
|
+
options = _useLoadOptions.options,
|
|
24
|
+
isLoading = _useLoadOptions.isLoading,
|
|
25
|
+
hasFailed = _useLoadOptions.hasFailed;
|
|
27
26
|
var experienceId = useDatasourceExperienceId();
|
|
28
27
|
useEffect(function () {
|
|
29
28
|
if (!experienceId) {
|
|
@@ -39,18 +38,19 @@ var IconEditType = function IconEditType(props) {
|
|
|
39
38
|
}, experienceId);
|
|
40
39
|
}
|
|
41
40
|
}, [experienceId, isLoading, hasFailed]);
|
|
42
|
-
return /*#__PURE__*/React.createElement(
|
|
43
|
-
testId: "inline-edit-priority",
|
|
41
|
+
return /*#__PURE__*/React.createElement(Select, _extends({}, props, {
|
|
44
42
|
autoFocus: true,
|
|
45
|
-
defaultMenuIsOpen: true,
|
|
46
43
|
blurInputOnSelect: true,
|
|
47
|
-
|
|
48
|
-
return option.text || '';
|
|
49
|
-
},
|
|
44
|
+
defaultMenuIsOpen: true,
|
|
50
45
|
options: options,
|
|
46
|
+
menuPlacement: "auto",
|
|
51
47
|
isLoading: isLoading,
|
|
52
|
-
defaultValue: currentValue === null || currentValue === void 0 || (_currentValue$values = currentValue.values) === null || _currentValue$values === void 0 ? void 0 : _currentValue$values[0],
|
|
53
48
|
filterOption: filterOption,
|
|
49
|
+
testId: "inline-edit-priority",
|
|
50
|
+
defaultValue: currentValue === null || currentValue === void 0 || (_currentValue$values = currentValue.values) === null || _currentValue$values === void 0 ? void 0 : _currentValue$values[0],
|
|
51
|
+
getOptionValue: function getOptionValue(option) {
|
|
52
|
+
return option.text || '';
|
|
53
|
+
},
|
|
54
54
|
formatOptionLabel: function formatOptionLabel(_ref) {
|
|
55
55
|
var source = _ref.source,
|
|
56
56
|
label = _ref.label,
|
|
@@ -68,98 +68,9 @@ var IconEditType = function IconEditType(props) {
|
|
|
68
68
|
values: e ? [e] : []
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
-
}))
|
|
71
|
+
}));
|
|
72
72
|
};
|
|
73
73
|
var filterOption = function filterOption(option, inputValue) {
|
|
74
74
|
return option.label.toLowerCase().includes(inputValue.toLowerCase());
|
|
75
75
|
};
|
|
76
|
-
var usePriorityOptions = function usePriorityOptions(currentValue, executeFetch) {
|
|
77
|
-
var _useState = useState({
|
|
78
|
-
isLoading: true,
|
|
79
|
-
options: [],
|
|
80
|
-
hasFailed: false
|
|
81
|
-
}),
|
|
82
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
83
|
-
_useState2$ = _useState2[0],
|
|
84
|
-
options = _useState2$.options,
|
|
85
|
-
isLoading = _useState2$.isLoading,
|
|
86
|
-
hasFailed = _useState2$.hasFailed,
|
|
87
|
-
setOptions = _useState2[1];
|
|
88
|
-
var _useDatasourceTableFl = useDatasourceTableFlag({
|
|
89
|
-
isFetchAction: true
|
|
90
|
-
}),
|
|
91
|
-
showErrorFlag = _useDatasourceTableFl.showErrorFlag;
|
|
92
|
-
useEffect(function () {
|
|
93
|
-
var isMounted = true;
|
|
94
|
-
loadOptions(currentValue, executeFetch).then(function (options) {
|
|
95
|
-
if (isMounted) {
|
|
96
|
-
setOptions({
|
|
97
|
-
isLoading: false,
|
|
98
|
-
options: options,
|
|
99
|
-
hasFailed: false
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
}).catch(function (err) {
|
|
103
|
-
showErrorFlag();
|
|
104
|
-
setOptions({
|
|
105
|
-
isLoading: false,
|
|
106
|
-
options: [],
|
|
107
|
-
hasFailed: true
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
return function () {
|
|
111
|
-
isMounted = false;
|
|
112
|
-
};
|
|
113
|
-
}, [currentValue, executeFetch, showErrorFlag]);
|
|
114
|
-
return {
|
|
115
|
-
options: options,
|
|
116
|
-
isLoading: isLoading,
|
|
117
|
-
hasFailed: hasFailed
|
|
118
|
-
};
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Load options for the select
|
|
123
|
-
*/
|
|
124
|
-
var loadOptions = /*#__PURE__*/function () {
|
|
125
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_currentValue, executeFetch) {
|
|
126
|
-
var _yield$executeFetch, operationStatus, entities;
|
|
127
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
128
|
-
while (1) switch (_context.prev = _context.next) {
|
|
129
|
-
case 0:
|
|
130
|
-
if (executeFetch) {
|
|
131
|
-
_context.next = 2;
|
|
132
|
-
break;
|
|
133
|
-
}
|
|
134
|
-
return _context.abrupt("return", []);
|
|
135
|
-
case 2:
|
|
136
|
-
_context.next = 4;
|
|
137
|
-
return executeFetch({});
|
|
138
|
-
case 4:
|
|
139
|
-
_yield$executeFetch = _context.sent;
|
|
140
|
-
operationStatus = _yield$executeFetch.operationStatus;
|
|
141
|
-
entities = _yield$executeFetch.entities;
|
|
142
|
-
if (!(operationStatus === ActionOperationStatus.FAILURE)) {
|
|
143
|
-
_context.next = 9;
|
|
144
|
-
break;
|
|
145
|
-
}
|
|
146
|
-
throw new Error('Failed to fetch icon options');
|
|
147
|
-
case 9:
|
|
148
|
-
if (!(operationStatus === ActionOperationStatus.SUCCESS && entities)) {
|
|
149
|
-
_context.next = 11;
|
|
150
|
-
break;
|
|
151
|
-
}
|
|
152
|
-
return _context.abrupt("return", entities);
|
|
153
|
-
case 11:
|
|
154
|
-
return _context.abrupt("return", []);
|
|
155
|
-
case 12:
|
|
156
|
-
case "end":
|
|
157
|
-
return _context.stop();
|
|
158
|
-
}
|
|
159
|
-
}, _callee);
|
|
160
|
-
}));
|
|
161
|
-
return function loadOptions(_x, _x2) {
|
|
162
|
-
return _ref2.apply(this, arguments);
|
|
163
|
-
};
|
|
164
|
-
}();
|
|
165
76
|
export default IconEditType;
|
|
@@ -7,11 +7,13 @@ import React from 'react';
|
|
|
7
7
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
8
|
import IconEditType from './icon';
|
|
9
9
|
import StatusEditType from './status';
|
|
10
|
-
import TextEditType
|
|
10
|
+
import TextEditType from './text';
|
|
11
|
+
import UserEditType from './user';
|
|
11
12
|
|
|
12
13
|
// This is used in editor-card-plugin to identify if any type of inline edit is active.
|
|
13
14
|
var ACTIVE_INLINE_EDIT_ID = 'sllv-active-inline-edit';
|
|
14
15
|
export var editType = function editType(_ref) {
|
|
16
|
+
var _toValueType, _value$atlassianUserI;
|
|
15
17
|
var defaultValue = _ref.defaultValue,
|
|
16
18
|
currentValue = _ref.currentValue,
|
|
17
19
|
setEditValues = _ref.setEditValues,
|
|
@@ -19,7 +21,7 @@ export var editType = function editType(_ref) {
|
|
|
19
21
|
switch (defaultValue.type) {
|
|
20
22
|
case 'string':
|
|
21
23
|
return {
|
|
22
|
-
defaultValue:
|
|
24
|
+
defaultValue: (_toValueType = toValueType(defaultValue)) !== null && _toValueType !== void 0 ? _toValueType : '',
|
|
23
25
|
editView: function editView(_ref2) {
|
|
24
26
|
var fieldProps = _extends({}, (_objectDestructuringEmpty(_ref2), _ref2));
|
|
25
27
|
return /*#__PURE__*/React.createElement(TextEditType, _extends({}, fieldProps, {
|
|
@@ -31,7 +33,7 @@ export var editType = function editType(_ref) {
|
|
|
31
33
|
};
|
|
32
34
|
case 'icon':
|
|
33
35
|
return {
|
|
34
|
-
defaultValue:
|
|
36
|
+
defaultValue: toValueType(defaultValue),
|
|
35
37
|
editView: function editView(_ref3) {
|
|
36
38
|
var value = _ref3.value,
|
|
37
39
|
fieldProps = _objectWithoutProperties(_ref3, _excluded);
|
|
@@ -45,7 +47,7 @@ export var editType = function editType(_ref) {
|
|
|
45
47
|
};
|
|
46
48
|
case 'status':
|
|
47
49
|
return {
|
|
48
|
-
defaultValue:
|
|
50
|
+
defaultValue: toValueType(defaultValue),
|
|
49
51
|
editView: function editView(_ref4) {
|
|
50
52
|
var fieldProps = _extends({}, (_objectDestructuringEmpty(_ref4), _ref4));
|
|
51
53
|
return /*#__PURE__*/React.createElement(StatusEditType, _extends({}, fieldProps, {
|
|
@@ -56,6 +58,20 @@ export var editType = function editType(_ref) {
|
|
|
56
58
|
}));
|
|
57
59
|
}
|
|
58
60
|
};
|
|
61
|
+
case 'user':
|
|
62
|
+
var value = toValueType(defaultValue);
|
|
63
|
+
return {
|
|
64
|
+
defaultValue: (_value$atlassianUserI = value === null || value === void 0 ? void 0 : value.atlassianUserId) !== null && _value$atlassianUserI !== void 0 ? _value$atlassianUserI : '',
|
|
65
|
+
editView: function editView(_ref5) {
|
|
66
|
+
var fieldProps = _extends({}, (_objectDestructuringEmpty(_ref5), _ref5));
|
|
67
|
+
return /*#__PURE__*/React.createElement(UserEditType, _extends({}, fieldProps, {
|
|
68
|
+
currentValue: currentValue,
|
|
69
|
+
setEditValues: setEditValues,
|
|
70
|
+
id: ACTIVE_INLINE_EDIT_ID,
|
|
71
|
+
executeFetch: executeFetch
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
};
|
|
59
75
|
}
|
|
60
76
|
return {
|
|
61
77
|
defaultValue: '',
|
|
@@ -65,10 +81,14 @@ export var editType = function editType(_ref) {
|
|
|
65
81
|
};
|
|
66
82
|
};
|
|
67
83
|
export var isEditTypeSupported = function isEditTypeSupported(type) {
|
|
68
|
-
var supportedEditType = ['string'].concat(_toConsumableArray(fg('platform-datasources-enable-two-way-sync-statuses') ? ['status'] : []), _toConsumableArray(fg('platform-datasources-enable-two-way-sync-priority') ? ['icon'] : []));
|
|
84
|
+
var supportedEditType = ['string'].concat(_toConsumableArray(fg('platform-datasources-enable-two-way-sync-statuses') ? ['status'] : []), _toConsumableArray(fg('platform-datasources-enable-two-way-sync-priority') ? ['icon'] : []), _toConsumableArray(fg('platform-datasources-enable-two-way-sync-assignee') ? ['user'] : []));
|
|
69
85
|
return supportedEditType.includes(type);
|
|
70
86
|
};
|
|
71
87
|
export var isEditTypeSelectable = function isEditTypeSelectable(type) {
|
|
72
88
|
var selectEditTypes = ['status', 'icon', 'user'];
|
|
73
89
|
return selectEditTypes.includes(type);
|
|
90
|
+
};
|
|
91
|
+
export var toValueType = function toValueType(typeWithValues) {
|
|
92
|
+
var _typeWithValues$value;
|
|
93
|
+
return (_typeWithValues$value = typeWithValues.values) === null || _typeWithValues$value === void 0 ? void 0 : _typeWithValues$value[0];
|
|
74
94
|
};
|
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
4
|
-
import
|
|
5
|
-
import React, { useEffect, useState } from 'react';
|
|
6
|
-
import { ActionOperationStatus } from '@atlaskit/linking-types';
|
|
2
|
+
import React, { useEffect } from 'react';
|
|
7
3
|
import Lozenge from '@atlaskit/lozenge';
|
|
8
4
|
import Select from '@atlaskit/select';
|
|
9
5
|
import { failUfoExperience, succeedUfoExperience } from '../../../../analytics/ufoExperiences';
|
|
10
6
|
import { useDatasourceExperienceId } from '../../../../contexts/datasource-experience-id';
|
|
11
|
-
import {
|
|
7
|
+
import { useLoadOptions } from '../../../../hooks/useLoadOptions';
|
|
12
8
|
import { InlineEditUFOExperience } from '../../table-cell-content/inline-edit';
|
|
13
9
|
var StatusEditType = function StatusEditType(props) {
|
|
14
10
|
var _currentValue$values;
|
|
15
11
|
var currentValue = props.currentValue,
|
|
16
12
|
executeFetch = props.executeFetch;
|
|
17
|
-
var
|
|
13
|
+
var _useLoadOptions = useLoadOptions({
|
|
18
14
|
executeFetch: executeFetch
|
|
19
15
|
}),
|
|
20
|
-
options =
|
|
21
|
-
isLoading =
|
|
22
|
-
hasFailed =
|
|
16
|
+
options = _useLoadOptions.options,
|
|
17
|
+
isLoading = _useLoadOptions.isLoading,
|
|
18
|
+
hasFailed = _useLoadOptions.hasFailed;
|
|
23
19
|
var experienceId = useDatasourceExperienceId();
|
|
24
20
|
useEffect(function () {
|
|
25
21
|
if (!experienceId) {
|
|
@@ -36,18 +32,18 @@ var StatusEditType = function StatusEditType(props) {
|
|
|
36
32
|
}
|
|
37
33
|
}, [experienceId, isLoading, hasFailed]);
|
|
38
34
|
return /*#__PURE__*/React.createElement(Select, _extends({}, props, {
|
|
39
|
-
testId: "inline-edit-status",
|
|
40
35
|
autoFocus: true,
|
|
36
|
+
options: options,
|
|
41
37
|
defaultMenuIsOpen: true,
|
|
42
38
|
blurInputOnSelect: true,
|
|
39
|
+
menuPlacement: "auto",
|
|
40
|
+
isLoading: isLoading,
|
|
41
|
+
filterOption: filterOption,
|
|
42
|
+
testId: "inline-edit-status",
|
|
43
43
|
getOptionValue: function getOptionValue(option) {
|
|
44
44
|
return option.text;
|
|
45
45
|
},
|
|
46
|
-
options: options,
|
|
47
|
-
isLoading: isLoading,
|
|
48
46
|
defaultValue: currentValue === null || currentValue === void 0 || (_currentValue$values = currentValue.values) === null || _currentValue$values === void 0 ? void 0 : _currentValue$values[0],
|
|
49
|
-
filterOption: filterOption,
|
|
50
|
-
menuPlacement: "auto",
|
|
51
47
|
formatOptionLabel: function formatOptionLabel(option) {
|
|
52
48
|
return /*#__PURE__*/React.createElement(Lozenge, _extends({
|
|
53
49
|
testId: "inline-edit-status-option-".concat(option.text)
|
|
@@ -64,102 +60,4 @@ var StatusEditType = function StatusEditType(props) {
|
|
|
64
60
|
var filterOption = function filterOption(option, inputValue) {
|
|
65
61
|
return option.data.text.toLowerCase().includes(inputValue.toLowerCase());
|
|
66
62
|
};
|
|
67
|
-
var useStatusOptions = function useStatusOptions(_ref) {
|
|
68
|
-
var fetchInputs = _ref.fetchInputs,
|
|
69
|
-
executeFetch = _ref.executeFetch;
|
|
70
|
-
var _useState = useState({
|
|
71
|
-
isLoading: true,
|
|
72
|
-
options: [],
|
|
73
|
-
hasFailed: false
|
|
74
|
-
}),
|
|
75
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
76
|
-
_useState2$ = _useState2[0],
|
|
77
|
-
options = _useState2$.options,
|
|
78
|
-
isLoading = _useState2$.isLoading,
|
|
79
|
-
hasFailed = _useState2$.hasFailed,
|
|
80
|
-
setOptions = _useState2[1];
|
|
81
|
-
var _useDatasourceTableFl = useDatasourceTableFlag({
|
|
82
|
-
isFetchAction: true
|
|
83
|
-
}),
|
|
84
|
-
showErrorFlag = _useDatasourceTableFl.showErrorFlag;
|
|
85
|
-
useEffect(function () {
|
|
86
|
-
var isMounted = true;
|
|
87
|
-
loadOptions(fetchInputs, executeFetch).then(function (options) {
|
|
88
|
-
if (isMounted) {
|
|
89
|
-
setOptions({
|
|
90
|
-
isLoading: false,
|
|
91
|
-
options: options,
|
|
92
|
-
hasFailed: false
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}).catch(function (err) {
|
|
96
|
-
showErrorFlag();
|
|
97
|
-
setOptions({
|
|
98
|
-
isLoading: false,
|
|
99
|
-
options: [],
|
|
100
|
-
hasFailed: true
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
return function () {
|
|
104
|
-
isMounted = false;
|
|
105
|
-
};
|
|
106
|
-
}, [fetchInputs, executeFetch, showErrorFlag]);
|
|
107
|
-
return {
|
|
108
|
-
options: options,
|
|
109
|
-
isLoading: isLoading,
|
|
110
|
-
hasFailed: hasFailed
|
|
111
|
-
};
|
|
112
|
-
};
|
|
113
|
-
var loadOptions = /*#__PURE__*/function () {
|
|
114
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
115
|
-
var fetchInputs,
|
|
116
|
-
executeFetch,
|
|
117
|
-
result,
|
|
118
|
-
operationStatus,
|
|
119
|
-
entities,
|
|
120
|
-
_args = arguments;
|
|
121
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
122
|
-
while (1) switch (_context.prev = _context.next) {
|
|
123
|
-
case 0:
|
|
124
|
-
fetchInputs = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
|
|
125
|
-
executeFetch = _args.length > 1 ? _args[1] : undefined;
|
|
126
|
-
if (!executeFetch) {
|
|
127
|
-
_context.next = 11;
|
|
128
|
-
break;
|
|
129
|
-
}
|
|
130
|
-
_context.next = 5;
|
|
131
|
-
return executeFetch(fetchInputs);
|
|
132
|
-
case 5:
|
|
133
|
-
result = _context.sent;
|
|
134
|
-
operationStatus = result.operationStatus, entities = result.entities;
|
|
135
|
-
if (!(operationStatus === ActionOperationStatus.FAILURE)) {
|
|
136
|
-
_context.next = 9;
|
|
137
|
-
break;
|
|
138
|
-
}
|
|
139
|
-
throw new Error('Failed to fetch status options');
|
|
140
|
-
case 9:
|
|
141
|
-
if (!entities) {
|
|
142
|
-
_context.next = 11;
|
|
143
|
-
break;
|
|
144
|
-
}
|
|
145
|
-
return _context.abrupt("return", entities.map(function (entity) {
|
|
146
|
-
return {
|
|
147
|
-
id: entity.id,
|
|
148
|
-
text: entity.text,
|
|
149
|
-
style: entity.style,
|
|
150
|
-
transitionId: entity.transitionId
|
|
151
|
-
};
|
|
152
|
-
}));
|
|
153
|
-
case 11:
|
|
154
|
-
return _context.abrupt("return", []);
|
|
155
|
-
case 12:
|
|
156
|
-
case "end":
|
|
157
|
-
return _context.stop();
|
|
158
|
-
}
|
|
159
|
-
}, _callee);
|
|
160
|
-
}));
|
|
161
|
-
return function loadOptions() {
|
|
162
|
-
return _ref2.apply(this, arguments);
|
|
163
|
-
};
|
|
164
|
-
}();
|
|
165
63
|
export default StatusEditType;
|
|
@@ -4,12 +4,10 @@ import { Layering } from '@atlaskit/layering';
|
|
|
4
4
|
import Textfield from '@atlaskit/textfield';
|
|
5
5
|
import { succeedUfoExperience } from '../../../../analytics/ufoExperiences';
|
|
6
6
|
import { useDatasourceExperienceId } from '../../../../contexts/datasource-experience-id';
|
|
7
|
-
export var toTextValue = function toTextValue(typeWithValues) {
|
|
8
|
-
var _ref, _typeWithValues$value;
|
|
9
|
-
return (_ref = (_typeWithValues$value = typeWithValues.values) === null || _typeWithValues$value === void 0 ? void 0 : _typeWithValues$value[0]) !== null && _ref !== void 0 ? _ref : '';
|
|
10
|
-
};
|
|
11
7
|
var TextEditType = function TextEditType(props) {
|
|
8
|
+
var _currentValue$values$, _currentValue$values;
|
|
12
9
|
var experienceId = useDatasourceExperienceId();
|
|
10
|
+
var currentValue = props.currentValue;
|
|
13
11
|
useEffect(function () {
|
|
14
12
|
if (experienceId) {
|
|
15
13
|
succeedUfoExperience({
|
|
@@ -27,7 +25,7 @@ var TextEditType = function TextEditType(props) {
|
|
|
27
25
|
// We need 8px left padding to match read only version, but there is already 1px of border
|
|
28
26
|
padding: "var(--ds-space-100, 8px)".concat(" calc(", "var(--ds-space-100, 8px)", " - 1px)")
|
|
29
27
|
},
|
|
30
|
-
value:
|
|
28
|
+
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$ : '',
|
|
31
29
|
onChange: function onChange(e) {
|
|
32
30
|
return props.setEditValues({
|
|
33
31
|
type: 'string',
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
import React, { useEffect, useState } from 'react';
|
|
4
|
+
import { useDebouncedCallback } from 'use-debounce';
|
|
5
|
+
import Avatar, { AvatarItem } from '@atlaskit/avatar';
|
|
6
|
+
import Select from '@atlaskit/select';
|
|
7
|
+
import { failUfoExperience, succeedUfoExperience } from '../../../../analytics/ufoExperiences';
|
|
8
|
+
import { useDatasourceExperienceId } from '../../../../contexts/datasource-experience-id';
|
|
9
|
+
import { useLoadOptions } from '../../../../hooks/useLoadOptions';
|
|
10
|
+
import { SEARCH_DEBOUNCE_MS } from '../../../common/modal/popup-select/constants';
|
|
11
|
+
import { USER_TYPE_TEST_ID } from '../../render-type/user';
|
|
12
|
+
import { InlineEditUFOExperience } from '../../table-cell-content/inline-edit';
|
|
13
|
+
var UserEditType = function UserEditType(props) {
|
|
14
|
+
var _currentValue$values;
|
|
15
|
+
var currentValue = props.currentValue,
|
|
16
|
+
executeFetch = props.executeFetch;
|
|
17
|
+
var _useState = useState({
|
|
18
|
+
query: ''
|
|
19
|
+
}),
|
|
20
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
21
|
+
fetchInputs = _useState2[0],
|
|
22
|
+
setFetchInputs = _useState2[1];
|
|
23
|
+
var _useDebouncedCallback = useDebouncedCallback(function (query) {
|
|
24
|
+
return setFetchInputs({
|
|
25
|
+
query: query
|
|
26
|
+
});
|
|
27
|
+
}, SEARCH_DEBOUNCE_MS),
|
|
28
|
+
_useDebouncedCallback2 = _slicedToArray(_useDebouncedCallback, 1),
|
|
29
|
+
handleUserInputDebounced = _useDebouncedCallback2[0];
|
|
30
|
+
var _useLoadOptions = useLoadOptions({
|
|
31
|
+
executeFetch: executeFetch,
|
|
32
|
+
fetchInputs: fetchInputs
|
|
33
|
+
}),
|
|
34
|
+
options = _useLoadOptions.options,
|
|
35
|
+
isLoading = _useLoadOptions.isLoading,
|
|
36
|
+
hasFailed = _useLoadOptions.hasFailed;
|
|
37
|
+
var experienceId = useDatasourceExperienceId();
|
|
38
|
+
useEffect(function () {
|
|
39
|
+
if (!experienceId) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (hasFailed) {
|
|
43
|
+
failUfoExperience({
|
|
44
|
+
name: InlineEditUFOExperience
|
|
45
|
+
}, experienceId);
|
|
46
|
+
} else if (!isLoading) {
|
|
47
|
+
succeedUfoExperience({
|
|
48
|
+
name: InlineEditUFOExperience
|
|
49
|
+
}, experienceId);
|
|
50
|
+
}
|
|
51
|
+
}, [experienceId, isLoading, hasFailed]);
|
|
52
|
+
return /*#__PURE__*/React.createElement(Select, _extends({}, props, {
|
|
53
|
+
autoFocus: true,
|
|
54
|
+
defaultMenuIsOpen: true,
|
|
55
|
+
blurInputOnSelect: true,
|
|
56
|
+
options: options,
|
|
57
|
+
isLoading: isLoading,
|
|
58
|
+
testId: "inline-edit-user",
|
|
59
|
+
filterOption: function filterOption() {
|
|
60
|
+
return true;
|
|
61
|
+
} // necessary, otherwise by default all options will be filtered out on user input
|
|
62
|
+
,
|
|
63
|
+
onInputChange: handleUserInputDebounced,
|
|
64
|
+
defaultValue: currentValue === null || currentValue === void 0 || (_currentValue$values = currentValue.values) === null || _currentValue$values === void 0 ? void 0 : _currentValue$values[0],
|
|
65
|
+
getOptionValue: function getOptionValue(option) {
|
|
66
|
+
return option.atlassianUserId;
|
|
67
|
+
},
|
|
68
|
+
formatOptionLabel: function formatOptionLabel(option) {
|
|
69
|
+
return /*#__PURE__*/React.createElement(AvatarItem, {
|
|
70
|
+
avatar: /*#__PURE__*/React.createElement(Avatar, {
|
|
71
|
+
appearance: "circle",
|
|
72
|
+
size: 'small',
|
|
73
|
+
src: option.avatarSource,
|
|
74
|
+
testId: "".concat(USER_TYPE_TEST_ID, "--avatar--").concat(option.atlassianUserId)
|
|
75
|
+
}),
|
|
76
|
+
primaryText: option.displayName
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
onChange: function onChange(e) {
|
|
80
|
+
return props.setEditValues({
|
|
81
|
+
type: 'user',
|
|
82
|
+
values: e ? [e] : []
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}));
|
|
86
|
+
};
|
|
87
|
+
export default UserEditType;
|
|
@@ -19,14 +19,16 @@ var editContainerStyles = xcss({
|
|
|
19
19
|
marginBlockStart: 'space.negative.100'
|
|
20
20
|
});
|
|
21
21
|
var getBackendUpdateValue = function getBackendUpdateValue(typedNewValue) {
|
|
22
|
-
var _typedNewValue$values, _typedNewValue$values2;
|
|
22
|
+
var _typedNewValue$values, _typedNewValue$values2, _typedNewValue$values3;
|
|
23
23
|
switch (typedNewValue.type) {
|
|
24
24
|
case 'string':
|
|
25
25
|
return typedNewValue.values[0] || '';
|
|
26
26
|
case 'status':
|
|
27
27
|
return ((_typedNewValue$values = typedNewValue.values[0]) === null || _typedNewValue$values === void 0 ? void 0 : _typedNewValue$values.transitionId) || '';
|
|
28
|
+
case 'user':
|
|
29
|
+
return ((_typedNewValue$values2 = typedNewValue.values[0]) === null || _typedNewValue$values2 === void 0 ? void 0 : _typedNewValue$values2.atlassianUserId) || '';
|
|
28
30
|
case 'icon':
|
|
29
|
-
return ((_typedNewValue$
|
|
31
|
+
return ((_typedNewValue$values3 = typedNewValue.values[0]) === null || _typedNewValue$values3 === void 0 ? void 0 : _typedNewValue$values3.id) || '';
|
|
30
32
|
}
|
|
31
33
|
throw new Error("Datasource 2 way sync Backend update value not implemented for type ".concat(typedNewValue.type));
|
|
32
34
|
};
|
|
@@ -37,6 +39,7 @@ var mapUpdatedItem = function mapUpdatedItem(existingItem, columnKey, newValue)
|
|
|
37
39
|
data: newValue.values[0] || ''
|
|
38
40
|
}));
|
|
39
41
|
case 'status':
|
|
42
|
+
case 'user':
|
|
40
43
|
case 'icon':
|
|
41
44
|
return newValue.values[0] ? _objectSpread(_objectSpread({}, existingItem), {}, _defineProperty({}, columnKey, {
|
|
42
45
|
data: newValue.values[0]
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type AtomicActionExecuteRequest } from '@atlaskit/linking-types';
|
|
2
|
+
import type { ExecuteFetch } from '../state/actions';
|
|
3
|
+
export type LoadOptionsProps = {
|
|
4
|
+
fetchInputs?: AtomicActionExecuteRequest['parameters']['inputs'];
|
|
5
|
+
executeFetch?: ExecuteFetch;
|
|
6
|
+
};
|
|
7
|
+
export declare const useLoadOptions: <T>({ fetchInputs, executeFetch }: LoadOptionsProps) => {
|
|
8
|
+
options: T[];
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
hasFailed: boolean;
|
|
11
|
+
};
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { type FieldProps } from '@atlaskit/form';
|
|
3
3
|
import { type ExecuteFetch } from '../../../../state/actions';
|
|
4
4
|
import type { DatasourceTypeWithOnlyTypeValues, DatasourceTypeWithOnlyValues } from '../../types';
|
|
5
|
-
interface
|
|
5
|
+
interface IconEditTypeProps extends Omit<FieldProps<string>, 'value'> {
|
|
6
6
|
currentValue: DatasourceTypeWithOnlyTypeValues<'icon'>;
|
|
7
7
|
setEditValues: React.Dispatch<React.SetStateAction<DatasourceTypeWithOnlyValues>>;
|
|
8
8
|
executeFetch?: ExecuteFetch;
|
|
@@ -10,5 +10,5 @@ interface Props extends Omit<FieldProps<string>, 'value'> {
|
|
|
10
10
|
/**
|
|
11
11
|
* Should be gated by FF rollout of platform-datasources-enable-two-way-sync-priority
|
|
12
12
|
*/
|
|
13
|
-
declare const IconEditType: (props:
|
|
13
|
+
declare const IconEditType: (props: IconEditTypeProps) => JSX.Element;
|
|
14
14
|
export default IconEditType;
|
|
@@ -11,3 +11,4 @@ export declare const editType: ({ defaultValue, currentValue, setEditValues, exe
|
|
|
11
11
|
}) => Pick<React.ComponentProps<typeof InlineEdit>, 'defaultValue' | 'editView'>;
|
|
12
12
|
export declare const isEditTypeSupported: (type: DatasourceType['type']) => boolean;
|
|
13
13
|
export declare const isEditTypeSelectable: (type: DatasourceType['type']) => boolean;
|
|
14
|
+
export declare const toValueType: <T>(typeWithValues: DatasourceTypeWithOnlyValues) => T;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type FieldProps } from '@atlaskit/form';
|
|
3
3
|
import type { ExecuteFetch } from '../../../../state/actions';
|
|
4
|
-
import type { DatasourceTypeWithOnlyValues } from '../../types';
|
|
5
|
-
interface
|
|
6
|
-
currentValue:
|
|
4
|
+
import type { DatasourceTypeWithOnlyTypeValues, DatasourceTypeWithOnlyValues } from '../../types';
|
|
5
|
+
interface StatusEditTypeProps extends Omit<FieldProps<string>, 'value'> {
|
|
6
|
+
currentValue: DatasourceTypeWithOnlyTypeValues<'status'>;
|
|
7
7
|
setEditValues: React.Dispatch<React.SetStateAction<DatasourceTypeWithOnlyValues>>;
|
|
8
8
|
executeFetch?: ExecuteFetch;
|
|
9
9
|
}
|
|
10
|
-
declare const StatusEditType: (props:
|
|
10
|
+
declare const StatusEditType: (props: StatusEditTypeProps) => JSX.Element;
|
|
11
11
|
export default StatusEditType;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type FieldProps } from '@atlaskit/form';
|
|
3
|
-
import type { DatasourceTypeWithOnlyValues } from '../../types';
|
|
3
|
+
import type { DatasourceTypeWithOnlyTypeValues, DatasourceTypeWithOnlyValues } from '../../types';
|
|
4
4
|
interface TextEditTypeProps extends Omit<FieldProps<string>, 'value'> {
|
|
5
|
-
currentValue:
|
|
5
|
+
currentValue: DatasourceTypeWithOnlyTypeValues<'string'>;
|
|
6
6
|
setEditValues: React.Dispatch<React.SetStateAction<DatasourceTypeWithOnlyValues>>;
|
|
7
7
|
}
|
|
8
|
-
export declare const toTextValue: (typeWithValues: DatasourceTypeWithOnlyValues) => string;
|
|
9
8
|
declare const TextEditType: (props: TextEditTypeProps) => JSX.Element;
|
|
10
9
|
export default TextEditType;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type FieldProps } from '@atlaskit/form';
|
|
3
|
+
import type { ExecuteFetch } from '../../../../state/actions';
|
|
4
|
+
import type { DatasourceTypeWithOnlyTypeValues, DatasourceTypeWithOnlyValues } from '../../types';
|
|
5
|
+
interface UserEditTypeProps extends Omit<FieldProps<string>, 'value'> {
|
|
6
|
+
currentValue: DatasourceTypeWithOnlyTypeValues<'user'>;
|
|
7
|
+
setEditValues: React.Dispatch<React.SetStateAction<DatasourceTypeWithOnlyValues>>;
|
|
8
|
+
executeFetch?: ExecuteFetch;
|
|
9
|
+
}
|
|
10
|
+
declare const UserEditType: (props: UserEditTypeProps) => JSX.Element;
|
|
11
|
+
export default UserEditType;
|
|
@@ -16,6 +16,9 @@ export type DatasourceTypeWithOnlyTypeValues<K> = {
|
|
|
16
16
|
type: K;
|
|
17
17
|
}>['value'][];
|
|
18
18
|
};
|
|
19
|
+
export type DatasourceTypeValueType<K> = Extract<DatasourceType, {
|
|
20
|
+
type: K;
|
|
21
|
+
}>['value'];
|
|
19
22
|
export type TableViewPropsRenderType = (item: DatasourceTypeWithOnlyValues) => React.ReactNode;
|
|
20
23
|
export interface ColumnSizesMap {
|
|
21
24
|
[key: string]: number;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type AtomicActionExecuteRequest } from '@atlaskit/linking-types';
|
|
2
|
+
import type { ExecuteFetch } from '../state/actions';
|
|
3
|
+
export type LoadOptionsProps = {
|
|
4
|
+
fetchInputs?: AtomicActionExecuteRequest['parameters']['inputs'];
|
|
5
|
+
executeFetch?: ExecuteFetch;
|
|
6
|
+
};
|
|
7
|
+
export declare const useLoadOptions: <T>({ fetchInputs, executeFetch }: LoadOptionsProps) => {
|
|
8
|
+
options: T[];
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
hasFailed: boolean;
|
|
11
|
+
};
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { type FieldProps } from '@atlaskit/form';
|
|
3
3
|
import { type ExecuteFetch } from '../../../../state/actions';
|
|
4
4
|
import type { DatasourceTypeWithOnlyTypeValues, DatasourceTypeWithOnlyValues } from '../../types';
|
|
5
|
-
interface
|
|
5
|
+
interface IconEditTypeProps extends Omit<FieldProps<string>, 'value'> {
|
|
6
6
|
currentValue: DatasourceTypeWithOnlyTypeValues<'icon'>;
|
|
7
7
|
setEditValues: React.Dispatch<React.SetStateAction<DatasourceTypeWithOnlyValues>>;
|
|
8
8
|
executeFetch?: ExecuteFetch;
|
|
@@ -10,5 +10,5 @@ interface Props extends Omit<FieldProps<string>, 'value'> {
|
|
|
10
10
|
/**
|
|
11
11
|
* Should be gated by FF rollout of platform-datasources-enable-two-way-sync-priority
|
|
12
12
|
*/
|
|
13
|
-
declare const IconEditType: (props:
|
|
13
|
+
declare const IconEditType: (props: IconEditTypeProps) => JSX.Element;
|
|
14
14
|
export default IconEditType;
|
|
@@ -11,3 +11,4 @@ export declare const editType: ({ defaultValue, currentValue, setEditValues, exe
|
|
|
11
11
|
}) => Pick<React.ComponentProps<typeof InlineEdit>, 'defaultValue' | 'editView'>;
|
|
12
12
|
export declare const isEditTypeSupported: (type: DatasourceType['type']) => boolean;
|
|
13
13
|
export declare const isEditTypeSelectable: (type: DatasourceType['type']) => boolean;
|
|
14
|
+
export declare const toValueType: <T>(typeWithValues: DatasourceTypeWithOnlyValues) => T;
|