@atlaskit/link-datasource 2.11.0 → 2.11.2
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 +16 -0
- package/dist/cjs/common/utils/response-item.js +18 -0
- package/dist/cjs/hooks/useDatasourceTableFlag.js +49 -0
- package/dist/cjs/state/actions/index.js +1 -1
- package/dist/cjs/ui/issue-like-table/index.js +11 -2
- package/dist/cjs/ui/issue-like-table/messages.js +15 -0
- package/dist/cjs/ui/issue-like-table/table-cell-content/index.js +61 -48
- package/dist/cjs/ui/issue-like-table/table-cell-content/inline-edit.js +13 -14
- package/dist/es2019/common/utils/response-item.js +6 -0
- package/dist/es2019/hooks/useDatasourceTableFlag.js +38 -0
- package/dist/es2019/state/actions/index.js +1 -1
- package/dist/es2019/ui/issue-like-table/index.js +12 -3
- package/dist/es2019/ui/issue-like-table/messages.js +15 -0
- package/dist/es2019/ui/issue-like-table/table-cell-content/index.js +61 -47
- package/dist/es2019/ui/issue-like-table/table-cell-content/inline-edit.js +14 -15
- package/dist/esm/common/utils/response-item.js +11 -0
- package/dist/esm/hooks/useDatasourceTableFlag.js +39 -0
- package/dist/esm/state/actions/index.js +1 -1
- package/dist/esm/ui/issue-like-table/index.js +12 -3
- package/dist/esm/ui/issue-like-table/messages.js +15 -0
- package/dist/esm/ui/issue-like-table/table-cell-content/index.js +60 -47
- package/dist/esm/ui/issue-like-table/table-cell-content/inline-edit.js +13 -14
- package/dist/types/common/utils/response-item.d.ts +2 -0
- package/dist/types/hooks/useDatasourceTableFlag.d.ts +8 -0
- package/dist/types/ui/common/modal/cancel-button/index.d.ts +1 -1
- package/dist/types/ui/common/modal/insert-button/index.d.ts +1 -1
- package/dist/types/ui/issue-like-table/messages.d.ts +15 -0
- package/dist/types/ui/issue-like-table/table-cell-content/index.d.ts +2 -1
- package/dist/types/ui/issue-like-table/table-cell-content/inline-edit.d.ts +4 -2
- package/dist/types-ts4.5/common/utils/response-item.d.ts +2 -0
- package/dist/types-ts4.5/hooks/useDatasourceTableFlag.d.ts +8 -0
- package/dist/types-ts4.5/ui/common/modal/cancel-button/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/common/modal/insert-button/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/issue-like-table/messages.d.ts +15 -0
- package/dist/types-ts4.5/ui/issue-like-table/table-cell-content/index.d.ts +2 -1
- package/dist/types-ts4.5/ui/issue-like-table/table-cell-content/inline-edit.d.ts +4 -2
- package/package.json +4 -3
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl-next';
|
|
3
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
3
|
import { Box, xcss } from '@atlaskit/primitives';
|
|
5
4
|
import Tooltip from '@atlaskit/tooltip';
|
|
6
5
|
import { useDatasourceItem } from '../../../state';
|
|
6
|
+
import { useExecuteAtomicAction } from '../../../state/actions';
|
|
7
7
|
import { isEditTypeSupported } from '../edit-type';
|
|
8
8
|
import { stringifyType } from '../render-type';
|
|
9
9
|
import { TruncateTextTag } from '../truncate-text-tag';
|
|
@@ -38,7 +38,7 @@ const TooltipWrapper = ({
|
|
|
38
38
|
}
|
|
39
39
|
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
40
40
|
};
|
|
41
|
-
const ReadOnlyCell = ({
|
|
41
|
+
export const ReadOnlyCell = ({
|
|
42
42
|
id,
|
|
43
43
|
columnType,
|
|
44
44
|
wrappedColumnKeys = [],
|
|
@@ -50,7 +50,7 @@ const ReadOnlyCell = ({
|
|
|
50
50
|
id
|
|
51
51
|
})) === null || _useDatasourceItem === void 0 ? void 0 : _useDatasourceItem.data;
|
|
52
52
|
if (!rowData || !columnKey || !rowData[columnKey]) {
|
|
53
|
-
return
|
|
53
|
+
return null;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
// Need to make sure we keep falsy values like 0 and '', as well as the boolean false.
|
|
@@ -67,75 +67,89 @@ const ReadOnlyCell = ({
|
|
|
67
67
|
}, renderItem(datasourceTypeWithValues));
|
|
68
68
|
};
|
|
69
69
|
const InlineEditableCell = ({
|
|
70
|
-
|
|
70
|
+
ari,
|
|
71
|
+
values,
|
|
71
72
|
columnKey,
|
|
72
|
-
columnType,
|
|
73
73
|
renderItem,
|
|
74
|
+
integrationKey,
|
|
74
75
|
wrappedColumnKeys
|
|
75
76
|
}) => {
|
|
76
|
-
|
|
77
|
-
const item = useDatasourceItem({
|
|
78
|
-
id
|
|
79
|
-
});
|
|
80
|
-
if (!item) {
|
|
81
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
82
|
-
}
|
|
77
|
+
// Execute fn is only returned when the field is editable and the action schema exists
|
|
83
78
|
const {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
ari
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
// Check if field is editable
|
|
93
|
-
const isEditable = !!ari && !!integrationKey && isEditTypeSupported(columnType);
|
|
94
|
-
|
|
95
|
-
// Need to make sure we keep falsy values like 0 and '', as well as the boolean false.
|
|
96
|
-
const value = (_rowData$columnKey2 = rowData[columnKey]) === null || _rowData$columnKey2 === void 0 ? void 0 : _rowData$columnKey2.data;
|
|
97
|
-
const values = Array.isArray(value) ? value : [value];
|
|
98
|
-
const datasourceTypeWithValues = {
|
|
99
|
-
type: columnType,
|
|
100
|
-
values
|
|
101
|
-
};
|
|
79
|
+
execute
|
|
80
|
+
} = useExecuteAtomicAction({
|
|
81
|
+
ari,
|
|
82
|
+
fieldKey: columnKey,
|
|
83
|
+
integrationKey
|
|
84
|
+
});
|
|
85
|
+
const isEditable = !!execute;
|
|
102
86
|
const readView = /*#__PURE__*/React.createElement(TooltipWrapper, {
|
|
103
87
|
columnKey: columnKey,
|
|
104
|
-
datasourceTypeWithValues:
|
|
88
|
+
datasourceTypeWithValues: values,
|
|
105
89
|
wrappedColumnKeys: wrappedColumnKeys
|
|
106
90
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
107
91
|
testId: "inline-edit-read-view",
|
|
108
92
|
paddingInline: isEditable ? 'space.075' : 'space.100',
|
|
109
93
|
paddingBlock: "space.050",
|
|
110
94
|
xcss: truncateTextStyles
|
|
111
|
-
}, renderItem(
|
|
112
|
-
|
|
95
|
+
}, renderItem(values)));
|
|
96
|
+
if (!isEditable) {
|
|
97
|
+
return readView;
|
|
98
|
+
}
|
|
99
|
+
return /*#__PURE__*/React.createElement(InlineEdit, {
|
|
113
100
|
ari: ari,
|
|
101
|
+
execute: execute,
|
|
102
|
+
readView: readView,
|
|
114
103
|
columnKey: columnKey,
|
|
115
|
-
datasourceTypeWithValues:
|
|
116
|
-
|
|
117
|
-
}) : readView;
|
|
104
|
+
datasourceTypeWithValues: values
|
|
105
|
+
});
|
|
118
106
|
};
|
|
119
107
|
export const TableCellContent = ({
|
|
108
|
+
id,
|
|
120
109
|
columnKey,
|
|
121
110
|
columnType,
|
|
122
|
-
id,
|
|
123
111
|
renderItem,
|
|
124
112
|
wrappedColumnKeys
|
|
125
113
|
}) => {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
114
|
+
const item = useDatasourceItem({
|
|
115
|
+
id
|
|
116
|
+
});
|
|
117
|
+
if (item) {
|
|
118
|
+
const {
|
|
119
|
+
integrationKey,
|
|
120
|
+
ari,
|
|
121
|
+
data: rowData
|
|
122
|
+
} = item;
|
|
123
|
+
const isEditType = !!ari && !!integrationKey && rowData[columnKey] && isEditTypeSupported(columnType);
|
|
124
|
+
if (isEditType) {
|
|
125
|
+
var _rowData$columnKey2;
|
|
126
|
+
// Need to make sure we keep falsy values like 0 and '', as well as the boolean false.
|
|
127
|
+
const value = (_rowData$columnKey2 = rowData[columnKey]) === null || _rowData$columnKey2 === void 0 ? void 0 : _rowData$columnKey2.data;
|
|
128
|
+
const values = Array.isArray(value) ? value : [value];
|
|
129
|
+
const datasourceTypeWithValues = {
|
|
130
|
+
type: columnType,
|
|
131
|
+
values
|
|
132
|
+
};
|
|
133
|
+
return /*#__PURE__*/React.createElement(InlineEditableCell, {
|
|
134
|
+
ari: ari,
|
|
135
|
+
columnKey: columnKey,
|
|
136
|
+
renderItem: renderItem,
|
|
137
|
+
integrationKey: integrationKey,
|
|
138
|
+
values: datasourceTypeWithValues,
|
|
139
|
+
wrappedColumnKeys: wrappedColumnKeys
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
144
|
+
testId: "inline-edit-read-view",
|
|
145
|
+
paddingInline: "space.100",
|
|
146
|
+
paddingBlock: "space.050",
|
|
147
|
+
xcss: truncateTextStyles
|
|
148
|
+
}, /*#__PURE__*/React.createElement(ReadOnlyCell, {
|
|
134
149
|
id: id,
|
|
135
150
|
columnKey: columnKey,
|
|
136
151
|
columnType: columnType,
|
|
137
152
|
wrappedColumnKeys: wrappedColumnKeys,
|
|
138
153
|
renderItem: renderItem
|
|
139
|
-
});
|
|
140
|
-
return renderedContent;
|
|
154
|
+
}));
|
|
141
155
|
};
|
|
@@ -2,8 +2,9 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import React, { useCallback, useState } from 'react';
|
|
3
3
|
import AKInlineEdit from '@atlaskit/inline-edit';
|
|
4
4
|
import { Box, xcss } from '@atlaskit/primitives';
|
|
5
|
+
import { getResourceUrl } from '../../../common/utils/response-item';
|
|
6
|
+
import { useDatasourceTableFlag } from '../../../hooks/useDatasourceTableFlag';
|
|
5
7
|
import { useDatasourceActions, useDatasourceItem } from '../../../state';
|
|
6
|
-
import { useExecuteAtomicAction } from '../../../state/actions';
|
|
7
8
|
import { editType } from '../edit-type';
|
|
8
9
|
const containerStyles = xcss({
|
|
9
10
|
marginBlockStart: 'space.negative.100'
|
|
@@ -23,27 +24,26 @@ const mapUpdatedItem = (type, existingItem, columnKey, newValue) => {
|
|
|
23
24
|
};
|
|
24
25
|
export const InlineEdit = ({
|
|
25
26
|
ari,
|
|
27
|
+
execute,
|
|
28
|
+
readView,
|
|
26
29
|
columnKey,
|
|
27
|
-
datasourceTypeWithValues
|
|
28
|
-
readView
|
|
30
|
+
datasourceTypeWithValues
|
|
29
31
|
}) => {
|
|
30
|
-
var _item$integrationKey;
|
|
31
32
|
const [isEditing, setIsEditing] = useState(false);
|
|
32
33
|
const item = useDatasourceItem({
|
|
33
34
|
id: ari
|
|
34
35
|
});
|
|
36
|
+
const url = getResourceUrl(item === null || item === void 0 ? void 0 : item.data);
|
|
37
|
+
const {
|
|
38
|
+
showErrorFlag
|
|
39
|
+
} = useDatasourceTableFlag({
|
|
40
|
+
url
|
|
41
|
+
});
|
|
35
42
|
const {
|
|
36
43
|
onUpdateItem
|
|
37
44
|
} = useDatasourceActions();
|
|
38
|
-
const {
|
|
39
|
-
execute
|
|
40
|
-
} = useExecuteAtomicAction({
|
|
41
|
-
ari,
|
|
42
|
-
fieldKey: columnKey,
|
|
43
|
-
integrationKey: (_item$integrationKey = item === null || item === void 0 ? void 0 : item.integrationKey) !== null && _item$integrationKey !== void 0 ? _item$integrationKey : ''
|
|
44
|
-
});
|
|
45
45
|
const onCommitUpdate = useCallback(value => {
|
|
46
|
-
if (!
|
|
46
|
+
if (!item) {
|
|
47
47
|
setIsEditing(false);
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
@@ -55,12 +55,11 @@ export const InlineEdit = ({
|
|
|
55
55
|
}
|
|
56
56
|
onUpdateItem(ari, newItem);
|
|
57
57
|
execute(value).catch(error => {
|
|
58
|
-
|
|
59
|
-
console.error(error);
|
|
58
|
+
showErrorFlag();
|
|
60
59
|
onUpdateItem(ari, existingData);
|
|
61
60
|
});
|
|
62
61
|
setIsEditing(false);
|
|
63
|
-
}, [ari, execute, datasourceTypeWithValues, item, columnKey, onUpdateItem]);
|
|
62
|
+
}, [ari, execute, datasourceTypeWithValues, item, columnKey, onUpdateItem, showErrorFlag]);
|
|
64
63
|
return /*#__PURE__*/React.createElement(Box, {
|
|
65
64
|
xcss: containerStyles
|
|
66
65
|
}, /*#__PURE__*/React.createElement(AKInlineEdit, _extends({}, editType(datasourceTypeWithValues), {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
|
+
var isLink = function isLink(data) {
|
|
3
|
+
return _typeof(data) === 'object' && 'url' in data;
|
|
4
|
+
};
|
|
5
|
+
var getLinkTypeUrl = function getLinkTypeUrl(data) {
|
|
6
|
+
return isLink(data) ? data.url : undefined;
|
|
7
|
+
};
|
|
8
|
+
export var getResourceUrl = function getResourceUrl(data) {
|
|
9
|
+
var _data$key, _data$title;
|
|
10
|
+
return getLinkTypeUrl(data === null || data === void 0 || (_data$key = data['key']) === null || _data$key === void 0 ? void 0 : _data$key.data) || getLinkTypeUrl(data === null || data === void 0 || (_data$title = data['title']) === null || _data$title === void 0 ? void 0 : _data$title.data);
|
|
11
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
import React, { useCallback, useMemo } from 'react';
|
|
5
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
6
|
+
import uuid from 'uuid';
|
|
7
|
+
import { useFlags } from '@atlaskit/flag';
|
|
8
|
+
import CrossCircleIcon from '@atlaskit/icon/glyph/cross-circle';
|
|
9
|
+
import { issueLikeTableMessages } from '../ui/issue-like-table/messages';
|
|
10
|
+
export var useDatasourceTableFlag = function useDatasourceTableFlag(options) {
|
|
11
|
+
var _useFlags = useFlags(),
|
|
12
|
+
showFlag = _useFlags.showFlag;
|
|
13
|
+
var actions = useMemo(function () {
|
|
14
|
+
var resourceLink = (options === null || options === void 0 ? void 0 : options.url) && {
|
|
15
|
+
content: /*#__PURE__*/React.createElement(FormattedMessage, issueLikeTableMessages.goToResourceLink),
|
|
16
|
+
href: options === null || options === void 0 ? void 0 : options.url,
|
|
17
|
+
target: '_blank'
|
|
18
|
+
};
|
|
19
|
+
return resourceLink ? [resourceLink] : undefined;
|
|
20
|
+
}, [options === null || options === void 0 ? void 0 : options.url]);
|
|
21
|
+
var showErrorFlag = useCallback(function (args) {
|
|
22
|
+
showFlag(_objectSpread({
|
|
23
|
+
actions: actions,
|
|
24
|
+
description: /*#__PURE__*/React.createElement(FormattedMessage, issueLikeTableMessages.updateErrorGenericDescription),
|
|
25
|
+
// We need IconTile (currently in beta) in order to scale the new icon to 24px
|
|
26
|
+
// eslint-disable-next-line @atlaskit/design-system/no-legacy-icons
|
|
27
|
+
icon: /*#__PURE__*/React.createElement(CrossCircleIcon, {
|
|
28
|
+
label: "Error",
|
|
29
|
+
primaryColor: "var(--ds-icon-danger, #C9372C)"
|
|
30
|
+
}),
|
|
31
|
+
id: uuid(),
|
|
32
|
+
isAutoDismiss: true,
|
|
33
|
+
title: /*#__PURE__*/React.createElement(FormattedMessage, issueLikeTableMessages.updateErrorGenericTitle)
|
|
34
|
+
}, args));
|
|
35
|
+
}, [actions, showFlag]);
|
|
36
|
+
return {
|
|
37
|
+
showErrorFlag: showErrorFlag
|
|
38
|
+
};
|
|
39
|
+
};
|
|
@@ -116,7 +116,7 @@ var getFieldUpdateActionByAri = function getFieldUpdateActionByAri(state, _ref3)
|
|
|
116
116
|
fieldKey = _ref3.fieldKey,
|
|
117
117
|
integrationKey = _ref3.integrationKey;
|
|
118
118
|
var isEditable = (_state$permissions$ar = state.permissions[ari]) === null || _state$permissions$ar === void 0 || (_state$permissions$ar = _state$permissions$ar[fieldKey]) === null || _state$permissions$ar === void 0 ? void 0 : _state$permissions$ar.isEditable;
|
|
119
|
-
if (isEditable
|
|
119
|
+
if (!isEditable) {
|
|
120
120
|
return;
|
|
121
121
|
}
|
|
122
122
|
return (_state$actionsByInteg = state.actionsByIntegration[integrationKey]) === null || _state$actionsByInteg === void 0 ? void 0 : _state$actionsByInteg[fieldKey];
|
|
@@ -18,6 +18,7 @@ import styled from '@emotion/styled';
|
|
|
18
18
|
import debounce from 'lodash/debounce';
|
|
19
19
|
import { useIntl } from 'react-intl-next';
|
|
20
20
|
import invariant from 'tiny-invariant';
|
|
21
|
+
import { FlagsProvider } from '@atlaskit/flag';
|
|
21
22
|
import { Skeleton } from '@atlaskit/linking-common';
|
|
22
23
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
23
24
|
import { extractClosestEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';
|
|
@@ -38,7 +39,7 @@ import { DraggableTableHeading } from './draggable-table-heading';
|
|
|
38
39
|
import TableEmptyState from './empty-state';
|
|
39
40
|
import { renderType, stringifyType } from './render-type';
|
|
40
41
|
import { InlineEditableTableCell, Table, TableCell, TableHeading, withTablePluginHeaderPrefix } from './styled';
|
|
41
|
-
import { TableCellContent } from './table-cell-content';
|
|
42
|
+
import { ReadOnlyCell, TableCellContent } from './table-cell-content';
|
|
42
43
|
import { TruncateTextTag } from './truncate-text-tag';
|
|
43
44
|
import { useIsOnScreen } from './useIsOnScreen';
|
|
44
45
|
import { COLUMN_BASE_WIDTH, getWidthCss } from './utils';
|
|
@@ -467,7 +468,14 @@ export var IssueLikeDataTableView = function IssueLikeDataTableView(_ref5) {
|
|
|
467
468
|
return {
|
|
468
469
|
key: key,
|
|
469
470
|
columnKey: key,
|
|
470
|
-
|
|
471
|
+
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
472
|
+
content: fg('platform-datasources-enable-two-way-sync') ? jsx(TableCellContent, {
|
|
473
|
+
id: id,
|
|
474
|
+
columnKey: key,
|
|
475
|
+
columnType: type,
|
|
476
|
+
wrappedColumnKeys: wrappedColumnKeys,
|
|
477
|
+
renderItem: renderItem
|
|
478
|
+
}) : jsx(ReadOnlyCell, {
|
|
471
479
|
id: id,
|
|
472
480
|
columnKey: key,
|
|
473
481
|
columnType: type,
|
|
@@ -581,7 +589,7 @@ export var IssueLikeDataTableView = function IssueLikeDataTableView(_ref5) {
|
|
|
581
589
|
}, _callee, null, [[3, 9]]);
|
|
582
590
|
})), [experienceId, extensionKey, hasFullSchema, onLoadDatasourceDetails]);
|
|
583
591
|
var isEditable = onVisibleColumnKeysChange && hasData;
|
|
584
|
-
|
|
592
|
+
var view = jsx("div", {
|
|
585
593
|
/* There is required contentEditable={true} in editor-card-plugin
|
|
586
594
|
* But this brakes how DND works. We set contentEditable={false} to allow DND to work
|
|
587
595
|
* when dragging is initiated on top of a column label.
|
|
@@ -727,5 +735,6 @@ export var IssueLikeDataTableView = function IssueLikeDataTableView(_ref5) {
|
|
|
727
735
|
}
|
|
728
736
|
}));
|
|
729
737
|
}))));
|
|
738
|
+
return fg('platform-datasources-enable-two-way-sync') ? jsx(FlagsProvider, null, view) : view;
|
|
730
739
|
};
|
|
731
740
|
export var EmptyState = TableEmptyState;
|
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
import { defineMessages } from 'react-intl-next';
|
|
2
2
|
export var issueLikeTableMessages = defineMessages({
|
|
3
|
+
goToResourceLink: {
|
|
4
|
+
id: 'linkDataSource.issue-line-table.go-to-resource.nonfinal',
|
|
5
|
+
description: 'Link to navigate to the resource page',
|
|
6
|
+
defaultMessage: 'Go to item'
|
|
7
|
+
},
|
|
8
|
+
updateErrorGenericDescription: {
|
|
9
|
+
id: 'linkDataSource.issue-line-table.error-generic-description.nonfinal',
|
|
10
|
+
description: 'Generic error message description shown when updating issue field fails',
|
|
11
|
+
defaultMessage: 'We had an issue trying to complete the update. Refresh the page and try again.'
|
|
12
|
+
},
|
|
13
|
+
updateErrorGenericTitle: {
|
|
14
|
+
id: 'linkDataSource.issue-line-table.error-generic-title.nonfinal',
|
|
15
|
+
description: 'Generic error message title shown when updating issue field fails',
|
|
16
|
+
defaultMessage: 'Something went wrong'
|
|
17
|
+
},
|
|
3
18
|
wrapText: {
|
|
4
19
|
id: 'linkDataSource.issue-line-table.wrap-text',
|
|
5
20
|
description: 'Table header Dropdown item for making whole column to wrap text',
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl-next';
|
|
3
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
3
|
import { Box, xcss } from '@atlaskit/primitives';
|
|
5
4
|
import Tooltip from '@atlaskit/tooltip';
|
|
6
5
|
import { useDatasourceItem } from '../../../state';
|
|
6
|
+
import { useExecuteAtomicAction } from '../../../state/actions';
|
|
7
7
|
import { isEditTypeSupported } from '../edit-type';
|
|
8
8
|
import { stringifyType } from '../render-type';
|
|
9
9
|
import { TruncateTextTag } from '../truncate-text-tag';
|
|
@@ -40,7 +40,7 @@ var TooltipWrapper = function TooltipWrapper(_ref) {
|
|
|
40
40
|
}
|
|
41
41
|
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
42
42
|
};
|
|
43
|
-
var ReadOnlyCell = function ReadOnlyCell(_ref2) {
|
|
43
|
+
export var ReadOnlyCell = function ReadOnlyCell(_ref2) {
|
|
44
44
|
var _useDatasourceItem, _rowData$columnKey;
|
|
45
45
|
var id = _ref2.id,
|
|
46
46
|
columnType = _ref2.columnType,
|
|
@@ -52,7 +52,7 @@ var ReadOnlyCell = function ReadOnlyCell(_ref2) {
|
|
|
52
52
|
id: id
|
|
53
53
|
})) === null || _useDatasourceItem === void 0 ? void 0 : _useDatasourceItem.data;
|
|
54
54
|
if (!rowData || !columnKey || !rowData[columnKey]) {
|
|
55
|
-
return
|
|
55
|
+
return null;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
// Need to make sure we keep falsy values like 0 and '', as well as the boolean false.
|
|
@@ -69,71 +69,84 @@ var ReadOnlyCell = function ReadOnlyCell(_ref2) {
|
|
|
69
69
|
}, renderItem(datasourceTypeWithValues));
|
|
70
70
|
};
|
|
71
71
|
var InlineEditableCell = function InlineEditableCell(_ref3) {
|
|
72
|
-
var
|
|
73
|
-
|
|
72
|
+
var ari = _ref3.ari,
|
|
73
|
+
values = _ref3.values,
|
|
74
74
|
columnKey = _ref3.columnKey,
|
|
75
|
-
columnType = _ref3.columnType,
|
|
76
75
|
renderItem = _ref3.renderItem,
|
|
76
|
+
integrationKey = _ref3.integrationKey,
|
|
77
77
|
wrappedColumnKeys = _ref3.wrappedColumnKeys;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
ari = item.ari;
|
|
87
|
-
if (!rowData || !columnKey || !rowData[columnKey]) {
|
|
88
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// Check if field is editable
|
|
92
|
-
var isEditable = !!ari && !!integrationKey && isEditTypeSupported(columnType);
|
|
93
|
-
|
|
94
|
-
// Need to make sure we keep falsy values like 0 and '', as well as the boolean false.
|
|
95
|
-
var value = (_rowData$columnKey2 = rowData[columnKey]) === null || _rowData$columnKey2 === void 0 ? void 0 : _rowData$columnKey2.data;
|
|
96
|
-
var values = Array.isArray(value) ? value : [value];
|
|
97
|
-
var datasourceTypeWithValues = {
|
|
98
|
-
type: columnType,
|
|
99
|
-
values: values
|
|
100
|
-
};
|
|
78
|
+
// Execute fn is only returned when the field is editable and the action schema exists
|
|
79
|
+
var _useExecuteAtomicActi = useExecuteAtomicAction({
|
|
80
|
+
ari: ari,
|
|
81
|
+
fieldKey: columnKey,
|
|
82
|
+
integrationKey: integrationKey
|
|
83
|
+
}),
|
|
84
|
+
execute = _useExecuteAtomicActi.execute;
|
|
85
|
+
var isEditable = !!execute;
|
|
101
86
|
var readView = /*#__PURE__*/React.createElement(TooltipWrapper, {
|
|
102
87
|
columnKey: columnKey,
|
|
103
|
-
datasourceTypeWithValues:
|
|
88
|
+
datasourceTypeWithValues: values,
|
|
104
89
|
wrappedColumnKeys: wrappedColumnKeys
|
|
105
90
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
106
91
|
testId: "inline-edit-read-view",
|
|
107
92
|
paddingInline: isEditable ? 'space.075' : 'space.100',
|
|
108
93
|
paddingBlock: "space.050",
|
|
109
94
|
xcss: truncateTextStyles
|
|
110
|
-
}, renderItem(
|
|
111
|
-
|
|
95
|
+
}, renderItem(values)));
|
|
96
|
+
if (!isEditable) {
|
|
97
|
+
return readView;
|
|
98
|
+
}
|
|
99
|
+
return /*#__PURE__*/React.createElement(InlineEdit, {
|
|
112
100
|
ari: ari,
|
|
101
|
+
execute: execute,
|
|
102
|
+
readView: readView,
|
|
113
103
|
columnKey: columnKey,
|
|
114
|
-
datasourceTypeWithValues:
|
|
115
|
-
|
|
116
|
-
}) : readView;
|
|
104
|
+
datasourceTypeWithValues: values
|
|
105
|
+
});
|
|
117
106
|
};
|
|
118
107
|
export var TableCellContent = function TableCellContent(_ref4) {
|
|
119
|
-
var
|
|
108
|
+
var id = _ref4.id,
|
|
109
|
+
columnKey = _ref4.columnKey,
|
|
120
110
|
columnType = _ref4.columnType,
|
|
121
|
-
id = _ref4.id,
|
|
122
111
|
renderItem = _ref4.renderItem,
|
|
123
112
|
wrappedColumnKeys = _ref4.wrappedColumnKeys;
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
113
|
+
var item = useDatasourceItem({
|
|
114
|
+
id: id
|
|
115
|
+
});
|
|
116
|
+
if (item) {
|
|
117
|
+
var integrationKey = item.integrationKey,
|
|
118
|
+
ari = item.ari,
|
|
119
|
+
rowData = item.data;
|
|
120
|
+
var isEditType = !!ari && !!integrationKey && rowData[columnKey] && isEditTypeSupported(columnType);
|
|
121
|
+
if (isEditType) {
|
|
122
|
+
var _rowData$columnKey2;
|
|
123
|
+
// Need to make sure we keep falsy values like 0 and '', as well as the boolean false.
|
|
124
|
+
var value = (_rowData$columnKey2 = rowData[columnKey]) === null || _rowData$columnKey2 === void 0 ? void 0 : _rowData$columnKey2.data;
|
|
125
|
+
var values = Array.isArray(value) ? value : [value];
|
|
126
|
+
var datasourceTypeWithValues = {
|
|
127
|
+
type: columnType,
|
|
128
|
+
values: values
|
|
129
|
+
};
|
|
130
|
+
return /*#__PURE__*/React.createElement(InlineEditableCell, {
|
|
131
|
+
ari: ari,
|
|
132
|
+
columnKey: columnKey,
|
|
133
|
+
renderItem: renderItem,
|
|
134
|
+
integrationKey: integrationKey,
|
|
135
|
+
values: datasourceTypeWithValues,
|
|
136
|
+
wrappedColumnKeys: wrappedColumnKeys
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
141
|
+
testId: "inline-edit-read-view",
|
|
142
|
+
paddingInline: "space.100",
|
|
143
|
+
paddingBlock: "space.050",
|
|
144
|
+
xcss: truncateTextStyles
|
|
145
|
+
}, /*#__PURE__*/React.createElement(ReadOnlyCell, {
|
|
132
146
|
id: id,
|
|
133
147
|
columnKey: columnKey,
|
|
134
148
|
columnType: columnType,
|
|
135
149
|
wrappedColumnKeys: wrappedColumnKeys,
|
|
136
150
|
renderItem: renderItem
|
|
137
|
-
});
|
|
138
|
-
return renderedContent;
|
|
151
|
+
}));
|
|
139
152
|
};
|
|
@@ -6,8 +6,9 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
6
6
|
import React, { useCallback, useState } from 'react';
|
|
7
7
|
import AKInlineEdit from '@atlaskit/inline-edit';
|
|
8
8
|
import { Box, xcss } from '@atlaskit/primitives';
|
|
9
|
+
import { getResourceUrl } from '../../../common/utils/response-item';
|
|
10
|
+
import { useDatasourceTableFlag } from '../../../hooks/useDatasourceTableFlag';
|
|
9
11
|
import { useDatasourceActions, useDatasourceItem } from '../../../state';
|
|
10
|
-
import { useExecuteAtomicAction } from '../../../state/actions';
|
|
11
12
|
import { editType } from '../edit-type';
|
|
12
13
|
var containerStyles = xcss({
|
|
13
14
|
marginBlockStart: 'space.negative.100'
|
|
@@ -23,11 +24,11 @@ var mapUpdatedItem = function mapUpdatedItem(type, existingItem, columnKey, newV
|
|
|
23
24
|
return null;
|
|
24
25
|
};
|
|
25
26
|
export var InlineEdit = function InlineEdit(_ref) {
|
|
26
|
-
var _item$integrationKey;
|
|
27
27
|
var ari = _ref.ari,
|
|
28
|
+
execute = _ref.execute,
|
|
29
|
+
_readView = _ref.readView,
|
|
28
30
|
columnKey = _ref.columnKey,
|
|
29
|
-
datasourceTypeWithValues = _ref.datasourceTypeWithValues
|
|
30
|
-
_readView = _ref.readView;
|
|
31
|
+
datasourceTypeWithValues = _ref.datasourceTypeWithValues;
|
|
31
32
|
var _useState = useState(false),
|
|
32
33
|
_useState2 = _slicedToArray(_useState, 2),
|
|
33
34
|
isEditing = _useState2[0],
|
|
@@ -35,16 +36,15 @@ export var InlineEdit = function InlineEdit(_ref) {
|
|
|
35
36
|
var item = useDatasourceItem({
|
|
36
37
|
id: ari
|
|
37
38
|
});
|
|
39
|
+
var url = getResourceUrl(item === null || item === void 0 ? void 0 : item.data);
|
|
40
|
+
var _useDatasourceTableFl = useDatasourceTableFlag({
|
|
41
|
+
url: url
|
|
42
|
+
}),
|
|
43
|
+
showErrorFlag = _useDatasourceTableFl.showErrorFlag;
|
|
38
44
|
var _useDatasourceActions = useDatasourceActions(),
|
|
39
45
|
onUpdateItem = _useDatasourceActions.onUpdateItem;
|
|
40
|
-
var _useExecuteAtomicActi = useExecuteAtomicAction({
|
|
41
|
-
ari: ari,
|
|
42
|
-
fieldKey: columnKey,
|
|
43
|
-
integrationKey: (_item$integrationKey = item === null || item === void 0 ? void 0 : item.integrationKey) !== null && _item$integrationKey !== void 0 ? _item$integrationKey : ''
|
|
44
|
-
}),
|
|
45
|
-
execute = _useExecuteAtomicActi.execute;
|
|
46
46
|
var onCommitUpdate = useCallback(function (value) {
|
|
47
|
-
if (!
|
|
47
|
+
if (!item) {
|
|
48
48
|
setIsEditing(false);
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
@@ -56,12 +56,11 @@ export var InlineEdit = function InlineEdit(_ref) {
|
|
|
56
56
|
}
|
|
57
57
|
onUpdateItem(ari, newItem);
|
|
58
58
|
execute(value).catch(function (error) {
|
|
59
|
-
|
|
60
|
-
console.error(error);
|
|
59
|
+
showErrorFlag();
|
|
61
60
|
onUpdateItem(ari, existingData);
|
|
62
61
|
});
|
|
63
62
|
setIsEditing(false);
|
|
64
|
-
}, [ari, execute, datasourceTypeWithValues, item, columnKey, onUpdateItem]);
|
|
63
|
+
}, [ari, execute, datasourceTypeWithValues, item, columnKey, onUpdateItem, showErrorFlag]);
|
|
65
64
|
return /*#__PURE__*/React.createElement(Box, {
|
|
66
65
|
xcss: containerStyles
|
|
67
66
|
}, /*#__PURE__*/React.createElement(AKInlineEdit, _extends({}, editType(datasourceTypeWithValues), {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type CreateFlagArgs } from '@atlaskit/flag';
|
|
2
|
+
interface DatasourceTableFlagOptions {
|
|
3
|
+
url?: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const useDatasourceTableFlag: (options?: DatasourceTableFlagOptions) => {
|
|
6
|
+
showErrorFlag: (args?: Partial<CreateFlagArgs>) => void;
|
|
7
|
+
};
|
|
8
|
+
export {};
|
|
@@ -3,6 +3,6 @@ import { type ButtonClickedCancelAttributesType } from '../../../../analytics/ge
|
|
|
3
3
|
export interface CancelButtonProps {
|
|
4
4
|
getAnalyticsPayload: () => ButtonClickedCancelAttributesType;
|
|
5
5
|
onCancel: () => void;
|
|
6
|
-
testId
|
|
6
|
+
testId?: string;
|
|
7
7
|
}
|
|
8
8
|
export declare const CancelButton: ({ getAnalyticsPayload, onCancel, testId }: CancelButtonProps) => jsx.JSX.Element;
|
|
@@ -6,7 +6,7 @@ import { type PropsWithChildren } from 'react';
|
|
|
6
6
|
import { jsx } from '@emotion/react';
|
|
7
7
|
import { type DatasourceParameters } from '@atlaskit/linking-types';
|
|
8
8
|
export type InsertButtonProps<Parameters extends DatasourceParameters> = PropsWithChildren<{
|
|
9
|
-
testId
|
|
9
|
+
testId?: string;
|
|
10
10
|
url: string | undefined;
|
|
11
11
|
getAnalyticsPayload: () => Record<string, any>;
|
|
12
12
|
overwriteParameters?: (parameters: Parameters) => Parameters;
|
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
export declare const issueLikeTableMessages: {
|
|
2
|
+
goToResourceLink: {
|
|
3
|
+
id: string;
|
|
4
|
+
description: string;
|
|
5
|
+
defaultMessage: string;
|
|
6
|
+
};
|
|
7
|
+
updateErrorGenericDescription: {
|
|
8
|
+
id: string;
|
|
9
|
+
description: string;
|
|
10
|
+
defaultMessage: string;
|
|
11
|
+
};
|
|
12
|
+
updateErrorGenericTitle: {
|
|
13
|
+
id: string;
|
|
14
|
+
description: string;
|
|
15
|
+
defaultMessage: string;
|
|
16
|
+
};
|
|
2
17
|
wrapText: {
|
|
3
18
|
id: string;
|
|
4
19
|
description: string;
|
|
@@ -9,5 +9,6 @@ interface TableCellContentProps {
|
|
|
9
9
|
renderItem: TableViewPropsRenderType;
|
|
10
10
|
wrappedColumnKeys: string[] | undefined;
|
|
11
11
|
}
|
|
12
|
-
export declare const
|
|
12
|
+
export declare const ReadOnlyCell: ({ id, columnType, wrappedColumnKeys, renderItem, columnKey, }: TableCellContentProps) => JSX.Element | null;
|
|
13
|
+
export declare const TableCellContent: ({ id, columnKey, columnType, renderItem, wrappedColumnKeys, }: TableCellContentProps) => JSX.Element;
|
|
13
14
|
export {};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { type AtomicActionExecuteResponse } from '@atlaskit/linking-types';
|
|
2
3
|
import type { DatasourceTypeWithOnlyValues } from '../types';
|
|
3
4
|
interface InlineEditProps {
|
|
4
5
|
ari: string;
|
|
5
6
|
columnKey: string;
|
|
6
|
-
datasourceTypeWithValues: DatasourceTypeWithOnlyValues;
|
|
7
7
|
readView: React.ReactNode;
|
|
8
|
+
datasourceTypeWithValues: DatasourceTypeWithOnlyValues;
|
|
9
|
+
execute: (value: string | number) => Promise<AtomicActionExecuteResponse>;
|
|
8
10
|
}
|
|
9
|
-
export declare const InlineEdit: ({ ari, columnKey, datasourceTypeWithValues,
|
|
11
|
+
export declare const InlineEdit: ({ ari, execute, readView, columnKey, datasourceTypeWithValues, }: InlineEditProps) => JSX.Element;
|
|
10
12
|
export {};
|