@atlaskit/link-datasource 3.9.0 → 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 +24 -0
- package/dist/cjs/hooks/useDatasourceTableFlag.js +12 -3
- package/dist/cjs/state/actions/index.js +7 -4
- 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 +34 -17
- 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/cjs/ui/table-footer/index.js +1 -2
- package/dist/es2019/hooks/useDatasourceTableFlag.js +12 -3
- package/dist/es2019/state/actions/index.js +6 -5
- 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 +18 -6
- 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/es2019/ui/table-footer/index.js +1 -2
- package/dist/esm/hooks/useDatasourceTableFlag.js +12 -3
- package/dist/esm/state/actions/index.js +7 -4
- 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 +34 -17
- 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/esm/ui/table-footer/index.js +1 -2
- 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 +5 -5
|
@@ -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;
|
|
@@ -16,7 +17,9 @@ const StatusEditType = props => {
|
|
|
16
17
|
options,
|
|
17
18
|
isLoading,
|
|
18
19
|
hasFailed
|
|
19
|
-
} = useStatusOptions(
|
|
20
|
+
} = useStatusOptions({
|
|
21
|
+
executeFetch
|
|
22
|
+
});
|
|
20
23
|
const experienceId = useDatasourceExperienceId();
|
|
21
24
|
useEffect(() => {
|
|
22
25
|
if (!experienceId) {
|
|
@@ -53,7 +56,10 @@ const StatusEditType = props => {
|
|
|
53
56
|
}));
|
|
54
57
|
};
|
|
55
58
|
const filterOption = (option, inputValue) => option.data.text.toLowerCase().includes(inputValue.toLowerCase());
|
|
56
|
-
const useStatusOptions = (
|
|
59
|
+
const useStatusOptions = ({
|
|
60
|
+
fetchInputs,
|
|
61
|
+
executeFetch
|
|
62
|
+
}) => {
|
|
57
63
|
const [{
|
|
58
64
|
options,
|
|
59
65
|
isLoading,
|
|
@@ -63,9 +69,14 @@ const useStatusOptions = (currentValue, executeFetch) => {
|
|
|
63
69
|
options: [],
|
|
64
70
|
hasFailed: false
|
|
65
71
|
});
|
|
72
|
+
const {
|
|
73
|
+
showErrorFlag
|
|
74
|
+
} = useDatasourceTableFlag({
|
|
75
|
+
isFetchAction: true
|
|
76
|
+
});
|
|
66
77
|
useEffect(() => {
|
|
67
78
|
let isMounted = true;
|
|
68
|
-
loadOptions(
|
|
79
|
+
loadOptions(fetchInputs, executeFetch).then(options => {
|
|
69
80
|
if (isMounted) {
|
|
70
81
|
setOptions({
|
|
71
82
|
isLoading: false,
|
|
@@ -74,6 +85,7 @@ const useStatusOptions = (currentValue, executeFetch) => {
|
|
|
74
85
|
});
|
|
75
86
|
}
|
|
76
87
|
}).catch(err => {
|
|
88
|
+
showErrorFlag();
|
|
77
89
|
setOptions({
|
|
78
90
|
isLoading: false,
|
|
79
91
|
options: [],
|
|
@@ -83,16 +95,16 @@ const useStatusOptions = (currentValue, executeFetch) => {
|
|
|
83
95
|
return () => {
|
|
84
96
|
isMounted = false;
|
|
85
97
|
};
|
|
86
|
-
}, [
|
|
98
|
+
}, [fetchInputs, executeFetch, showErrorFlag]);
|
|
87
99
|
return {
|
|
88
100
|
options,
|
|
89
101
|
isLoading,
|
|
90
102
|
hasFailed
|
|
91
103
|
};
|
|
92
104
|
};
|
|
93
|
-
const loadOptions = async (
|
|
105
|
+
const loadOptions = async (fetchInputs = {}, executeFetch) => {
|
|
94
106
|
if (executeFetch) {
|
|
95
|
-
const result = await executeFetch(
|
|
107
|
+
const result = await executeFetch(fetchInputs);
|
|
96
108
|
const {
|
|
97
109
|
operationStatus,
|
|
98
110
|
entities
|
|
@@ -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',
|
|
@@ -18,6 +18,11 @@ const textWrapperStyles = xcss({
|
|
|
18
18
|
});
|
|
19
19
|
export const ICON_TYPE_TEST_ID = 'link-datasource-render-type--icon';
|
|
20
20
|
export const ICON_TYPE_TEXT_TEST_ID = `${ICON_TYPE_TEST_ID}-text`;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated: To be cleaned up and replaced with new-icon after
|
|
24
|
+
* `platform-datasources-enable-two-way-sync-priority` rollout.
|
|
25
|
+
*/
|
|
21
26
|
const IconRenderType = ({
|
|
22
27
|
label,
|
|
23
28
|
text,
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
4
|
import BooleanRenderType from './boolean';
|
|
4
5
|
import DateTimeRenderType, { getFormattedDate } from './date-time';
|
|
5
6
|
import IconRenderType from './icon';
|
|
6
7
|
import LinkRenderType from './link';
|
|
8
|
+
import NewIconRenderType from './new-icon';
|
|
7
9
|
import NumberRenderType from './number';
|
|
8
10
|
import RichTextRenderType, { parseRichText } from './richtext';
|
|
9
11
|
import StatusRenderType from './status';
|
|
@@ -60,7 +62,7 @@ export const renderType = item => {
|
|
|
60
62
|
display: "datetime"
|
|
61
63
|
}));
|
|
62
64
|
case 'icon':
|
|
63
|
-
return item.values.map(iconValue => /*#__PURE__*/React.createElement(IconRenderType, iconValue));
|
|
65
|
+
return fg('platform-datasources-enable-two-way-sync-priority') ? item.values.map(iconValue => /*#__PURE__*/React.createElement(NewIconRenderType, iconValue)) : item.values.map(iconValue => /*#__PURE__*/React.createElement(IconRenderType, iconValue));
|
|
64
66
|
case 'link':
|
|
65
67
|
return item.values.map(linkValue => /*#__PURE__*/React.createElement(LinkRenderType, _extends({
|
|
66
68
|
key: linkValue === null || linkValue === void 0 ? void 0 : linkValue.url
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SharedIconComponent } from '../../shared-components/icon';
|
|
3
|
+
export const ICON_TYPE_TEST_ID = 'link-datasource-render-type--icon';
|
|
4
|
+
export const ICON_TYPE_TEXT_TEST_ID = `${ICON_TYPE_TEST_ID}-text`;
|
|
5
|
+
const IconRenderType = ({
|
|
6
|
+
label,
|
|
7
|
+
text,
|
|
8
|
+
source,
|
|
9
|
+
testId = ICON_TYPE_TEST_ID
|
|
10
|
+
}) => {
|
|
11
|
+
return /*#__PURE__*/React.createElement(SharedIconComponent, {
|
|
12
|
+
testId: testId,
|
|
13
|
+
iconUrl: source,
|
|
14
|
+
label: label,
|
|
15
|
+
text: text
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
export default IconRenderType;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Box, Flex, Inline, xcss } from '@atlaskit/primitives';
|
|
3
|
+
const labelStyles = xcss({
|
|
4
|
+
overflow: 'hidden',
|
|
5
|
+
textOverflow: 'ellipsis',
|
|
6
|
+
width: '100%'
|
|
7
|
+
});
|
|
8
|
+
/**
|
|
9
|
+
* Renders a icon and label.
|
|
10
|
+
* If the text is undefined, render the capitalised label.
|
|
11
|
+
*/
|
|
12
|
+
export function SharedIconComponent({
|
|
13
|
+
iconUrl,
|
|
14
|
+
label,
|
|
15
|
+
text,
|
|
16
|
+
testId
|
|
17
|
+
}) {
|
|
18
|
+
const displayText = text === undefined || text === '' ? label ? label.charAt(0).toUpperCase() + label.slice(1) : undefined : text;
|
|
19
|
+
return /*#__PURE__*/React.createElement(Flex, {
|
|
20
|
+
gap: "space.100",
|
|
21
|
+
alignItems: "center",
|
|
22
|
+
testId: testId
|
|
23
|
+
}, /*#__PURE__*/React.createElement(Inline, null, /*#__PURE__*/React.createElement("img", {
|
|
24
|
+
src: iconUrl,
|
|
25
|
+
alt: label
|
|
26
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
27
|
+
,
|
|
28
|
+
style: {
|
|
29
|
+
minWidth: '24px',
|
|
30
|
+
maxWidth: '24px'
|
|
31
|
+
} // having just width: '24px' shrinks it when table width is reduced
|
|
32
|
+
})), displayText && /*#__PURE__*/React.createElement(Box, {
|
|
33
|
+
xcss: labelStyles,
|
|
34
|
+
testId: `${testId}-text`
|
|
35
|
+
}, displayText));
|
|
36
|
+
}
|
|
@@ -11,7 +11,6 @@ import styled from '@emotion/styled';
|
|
|
11
11
|
import { FormattedMessage, useIntl } from 'react-intl-next';
|
|
12
12
|
import Button from '@atlaskit/button';
|
|
13
13
|
import RefreshIcon from '@atlaskit/icon/core/migration/refresh';
|
|
14
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
15
14
|
import { Flex } from '@atlaskit/primitives';
|
|
16
15
|
import { N0, N40, N90 } from '@atlaskit/theme/colors';
|
|
17
16
|
import { ASSETS_LIST_OF_LINKS_DATASOURCE_ID } from '../assets-modal';
|
|
@@ -70,7 +69,7 @@ export const TableFooter = ({
|
|
|
70
69
|
// ensure correct positioning since 'justify-content: space-between' is used).
|
|
71
70
|
return onRefresh || showItemCount ? jsx(FooterWrapper, {
|
|
72
71
|
"data-testid": "table-footer"
|
|
73
|
-
}, jsx(TopBorderWrapper, null, showItemCount && jsx(Flex, null, datasourceId === ASSETS_LIST_OF_LINKS_DATASOURCE_ID
|
|
72
|
+
}, jsx(TopBorderWrapper, null, showItemCount && jsx(Flex, null, datasourceId === ASSETS_LIST_OF_LINKS_DATASOURCE_ID ? jsx(AssetsItemCount, {
|
|
74
73
|
searchCount: itemCount,
|
|
75
74
|
url: url,
|
|
76
75
|
testId: "item-count"
|
|
@@ -16,7 +16,7 @@ var getErrorReason = function getErrorReason(status) {
|
|
|
16
16
|
return 'request_failed';
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
|
-
var
|
|
19
|
+
var getExecuteActionErrorMessage = function getExecuteActionErrorMessage(status) {
|
|
20
20
|
switch (status) {
|
|
21
21
|
case 403:
|
|
22
22
|
return {
|
|
@@ -30,6 +30,15 @@ var getGenericErrorMessage = function getGenericErrorMessage(status) {
|
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
|
+
var getFetchActionErrorMessage = function getFetchActionErrorMessage(status) {
|
|
34
|
+
switch (status) {
|
|
35
|
+
default:
|
|
36
|
+
return {
|
|
37
|
+
title: /*#__PURE__*/React.createElement(FormattedMessage, issueLikeTableMessages.fetchActionErrorGenericTitle),
|
|
38
|
+
description: /*#__PURE__*/React.createElement(FormattedMessage, issueLikeTableMessages.fetchActionErrorGenericDescription)
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
};
|
|
33
42
|
export var useDatasourceTableFlag = function useDatasourceTableFlag(options) {
|
|
34
43
|
var _useFlags = useFlags(),
|
|
35
44
|
showFlag = _useFlags.showFlag;
|
|
@@ -45,11 +54,11 @@ export var useDatasourceTableFlag = function useDatasourceTableFlag(options) {
|
|
|
45
54
|
}),
|
|
46
55
|
id: uuid(),
|
|
47
56
|
isAutoDismiss: true
|
|
48
|
-
},
|
|
57
|
+
}, 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));
|
|
49
58
|
fireEvent('ui.error.shown.inlineEdit', {
|
|
50
59
|
reason: getErrorReason(args === null || args === void 0 ? void 0 : args.status)
|
|
51
60
|
});
|
|
52
|
-
}, [fireEvent, showFlag]);
|
|
61
|
+
}, [fireEvent, options === null || options === void 0 ? void 0 : options.isFetchAction, showFlag]);
|
|
53
62
|
return {
|
|
54
63
|
showErrorFlag: showErrorFlag
|
|
55
64
|
};
|
|
@@ -200,12 +200,15 @@ export var useExecuteAtomicAction = function useExecuteAtomicAction(_ref5) {
|
|
|
200
200
|
var _useDatasourceClientE2 = useDatasourceClientExtension(),
|
|
201
201
|
executeAction = _useDatasourceClientE2.executeAtomicAction,
|
|
202
202
|
invalidateDatasourceDataCacheByAri = _useDatasourceClientE2.invalidateDatasourceDataCacheByAri;
|
|
203
|
-
var
|
|
204
|
-
|
|
205
|
-
var _useErrorLogger = useErrorLogger({
|
|
203
|
+
var loggerProps = useMemo(function () {
|
|
204
|
+
return {
|
|
206
205
|
integrationKey: integrationKey
|
|
207
|
-
}
|
|
206
|
+
};
|
|
207
|
+
}, [integrationKey]);
|
|
208
|
+
var _useErrorLogger = useErrorLogger(loggerProps),
|
|
208
209
|
captureError = _useErrorLogger.captureError;
|
|
210
|
+
var _useDatasourceAnalyti = useDatasourceAnalyticsEvents(),
|
|
211
|
+
fireEvent = _useDatasourceAnalyti.fireEvent;
|
|
209
212
|
var execute = useCallback(function (value) {
|
|
210
213
|
if (!schema) {
|
|
211
214
|
throw new Error('No action schema found.');
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
4
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
|
+
import React, { useEffect, useState } from 'react';
|
|
6
|
+
import { ActionOperationStatus } from '@atlaskit/linking-types';
|
|
7
|
+
// FilterOptionOption is used in the filterOption function which is part of the public API, but the type itself is not exported
|
|
8
|
+
// eslint-disable-next-line import/no-extraneous-dependencies,no-restricted-imports
|
|
9
|
+
|
|
10
|
+
import Select from '@atlaskit/select';
|
|
11
|
+
import { SharedIconComponent } from '../../shared-components/icon';
|
|
12
|
+
/**
|
|
13
|
+
* Should be gated by FF rollout of platform-datasources-enable-two-way-sync-priority
|
|
14
|
+
*/
|
|
15
|
+
var PriorityEditType = function PriorityEditType(props) {
|
|
16
|
+
var _currentValue$values;
|
|
17
|
+
var currentValue = props.currentValue,
|
|
18
|
+
executeFetch = props.executeFetch;
|
|
19
|
+
var _usePriorityOptions = usePriorityOptions(currentValue, executeFetch),
|
|
20
|
+
options = _usePriorityOptions.options,
|
|
21
|
+
isLoading = _usePriorityOptions.isLoading;
|
|
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: function getOptionValue(option) {
|
|
28
|
+
return option.label || '';
|
|
29
|
+
},
|
|
30
|
+
options: options,
|
|
31
|
+
isLoading: isLoading,
|
|
32
|
+
defaultValue: currentValue === null || currentValue === void 0 || (_currentValue$values = currentValue.values) === null || _currentValue$values === void 0 ? void 0 : _currentValue$values[0],
|
|
33
|
+
filterOption: filterOption,
|
|
34
|
+
formatOptionLabel: function formatOptionLabel(_ref) {
|
|
35
|
+
var source = _ref.source,
|
|
36
|
+
label = _ref.label,
|
|
37
|
+
text = _ref.text;
|
|
38
|
+
return /*#__PURE__*/React.createElement(SharedIconComponent, {
|
|
39
|
+
iconUrl: source,
|
|
40
|
+
text: text,
|
|
41
|
+
label: label,
|
|
42
|
+
testId: "inline-edit-priority-option-".concat(label)
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
onChange: function onChange(e) {
|
|
46
|
+
return props.setEditValues({
|
|
47
|
+
type: 'icon',
|
|
48
|
+
values: e ? [e] : []
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
})));
|
|
52
|
+
};
|
|
53
|
+
var filterOption = function filterOption(option, inputValue) {
|
|
54
|
+
return option.label.toLowerCase().includes(inputValue.toLowerCase());
|
|
55
|
+
};
|
|
56
|
+
var usePriorityOptions = function usePriorityOptions(currentValue, executeFetch) {
|
|
57
|
+
var _useState = useState({
|
|
58
|
+
isLoading: true,
|
|
59
|
+
options: []
|
|
60
|
+
}),
|
|
61
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
62
|
+
_useState2$ = _useState2[0],
|
|
63
|
+
options = _useState2$.options,
|
|
64
|
+
isLoading = _useState2$.isLoading,
|
|
65
|
+
setOptions = _useState2[1];
|
|
66
|
+
useEffect(function () {
|
|
67
|
+
var isMounted = true;
|
|
68
|
+
loadOptions(currentValue, executeFetch).then(function (options) {
|
|
69
|
+
if (isMounted) {
|
|
70
|
+
setOptions({
|
|
71
|
+
isLoading: false,
|
|
72
|
+
options: options
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
return function () {
|
|
77
|
+
isMounted = false;
|
|
78
|
+
};
|
|
79
|
+
}, [currentValue, executeFetch]);
|
|
80
|
+
return {
|
|
81
|
+
options: options,
|
|
82
|
+
isLoading: isLoading
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Load options for the select
|
|
88
|
+
*/
|
|
89
|
+
var loadOptions = /*#__PURE__*/function () {
|
|
90
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_currentValue, executeFetch) {
|
|
91
|
+
var _yield$executeFetch, operationStatus, entities;
|
|
92
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
93
|
+
while (1) switch (_context.prev = _context.next) {
|
|
94
|
+
case 0:
|
|
95
|
+
if (executeFetch) {
|
|
96
|
+
_context.next = 2;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
return _context.abrupt("return", []);
|
|
100
|
+
case 2:
|
|
101
|
+
_context.next = 4;
|
|
102
|
+
return executeFetch({});
|
|
103
|
+
case 4:
|
|
104
|
+
_yield$executeFetch = _context.sent;
|
|
105
|
+
operationStatus = _yield$executeFetch.operationStatus;
|
|
106
|
+
entities = _yield$executeFetch.entities;
|
|
107
|
+
if (!(operationStatus === ActionOperationStatus.SUCCESS && entities)) {
|
|
108
|
+
_context.next = 9;
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
return _context.abrupt("return", entities);
|
|
112
|
+
case 9:
|
|
113
|
+
return _context.abrupt("return", []);
|
|
114
|
+
case 10:
|
|
115
|
+
case "end":
|
|
116
|
+
return _context.stop();
|
|
117
|
+
}
|
|
118
|
+
}, _callee);
|
|
119
|
+
}));
|
|
120
|
+
return function loadOptions(_x, _x2) {
|
|
121
|
+
return _ref2.apply(this, arguments);
|
|
122
|
+
};
|
|
123
|
+
}();
|
|
124
|
+
export default PriorityEditType;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
1
3
|
import _objectDestructuringEmpty from "@babel/runtime/helpers/objectDestructuringEmpty";
|
|
2
4
|
import _extends from "@babel/runtime/helpers/extends";
|
|
5
|
+
var _excluded = ["value"];
|
|
3
6
|
import React from 'react';
|
|
4
7
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
|
+
import PriorityEditType from './icon';
|
|
5
9
|
import StatusEditType from './status';
|
|
6
10
|
import TextEditType, { toTextValue } from './text';
|
|
7
11
|
|
|
@@ -25,12 +29,13 @@ export var editType = function editType(_ref) {
|
|
|
25
29
|
}));
|
|
26
30
|
}
|
|
27
31
|
};
|
|
28
|
-
case '
|
|
32
|
+
case 'icon':
|
|
29
33
|
return {
|
|
30
34
|
defaultValue: toTextValue(defaultValue),
|
|
31
35
|
editView: function editView(_ref3) {
|
|
32
|
-
var
|
|
33
|
-
|
|
36
|
+
var value = _ref3.value,
|
|
37
|
+
fieldProps = _objectWithoutProperties(_ref3, _excluded);
|
|
38
|
+
return /*#__PURE__*/React.createElement(PriorityEditType, _extends({}, fieldProps, {
|
|
34
39
|
currentValue: currentValue,
|
|
35
40
|
setEditValues: setEditValues,
|
|
36
41
|
id: ACTIVE_INLINE_EDIT_ID,
|
|
@@ -38,17 +43,29 @@ export var editType = function editType(_ref) {
|
|
|
38
43
|
}));
|
|
39
44
|
}
|
|
40
45
|
};
|
|
41
|
-
|
|
46
|
+
case 'status':
|
|
42
47
|
return {
|
|
43
|
-
defaultValue:
|
|
44
|
-
editView: function editView() {
|
|
45
|
-
|
|
48
|
+
defaultValue: toTextValue(defaultValue),
|
|
49
|
+
editView: function editView(_ref4) {
|
|
50
|
+
var fieldProps = _extends({}, (_objectDestructuringEmpty(_ref4), _ref4));
|
|
51
|
+
return /*#__PURE__*/React.createElement(StatusEditType, _extends({}, fieldProps, {
|
|
52
|
+
currentValue: currentValue,
|
|
53
|
+
setEditValues: setEditValues,
|
|
54
|
+
id: ACTIVE_INLINE_EDIT_ID,
|
|
55
|
+
executeFetch: executeFetch
|
|
56
|
+
}));
|
|
46
57
|
}
|
|
47
58
|
};
|
|
48
59
|
}
|
|
60
|
+
return {
|
|
61
|
+
defaultValue: '',
|
|
62
|
+
editView: function editView() {
|
|
63
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
49
66
|
};
|
|
50
67
|
export var isEditTypeSupported = function isEditTypeSupported(type) {
|
|
51
|
-
var supportedEditType = fg('platform-datasources-enable-two-way-sync-statuses') ? ['
|
|
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'] : []));
|
|
52
69
|
return supportedEditType.includes(type);
|
|
53
70
|
};
|
|
54
71
|
export var isEditTypeSelectable = function isEditTypeSelectable(type) {
|