@atlaskit/link-datasource 2.9.3 → 2.9.5
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 +19 -0
- package/dist/cjs/hooks/useDatasourceTableState.js +43 -17
- package/dist/cjs/state/actions/index.js +183 -0
- package/dist/cjs/state/index.js +8 -4
- package/dist/cjs/ui/issue-like-table/index.js +87 -70
- package/dist/cjs/ui/issue-like-table/styled.js +22 -3
- package/dist/cjs/ui/issue-like-table/table-cell-content/index.js +98 -23
- package/dist/es2019/hooks/useDatasourceTableState.js +26 -2
- package/dist/es2019/state/actions/index.js +166 -0
- package/dist/es2019/state/index.js +11 -5
- package/dist/es2019/ui/issue-like-table/index.js +27 -11
- package/dist/es2019/ui/issue-like-table/styled.js +28 -0
- package/dist/es2019/ui/issue-like-table/table-cell-content/index.js +96 -18
- package/dist/esm/hooks/useDatasourceTableState.js +43 -17
- package/dist/esm/state/actions/index.js +177 -0
- package/dist/esm/state/index.js +8 -4
- package/dist/esm/ui/issue-like-table/index.js +88 -71
- package/dist/esm/ui/issue-like-table/styled.js +21 -2
- package/dist/esm/ui/issue-like-table/table-cell-content/index.js +98 -23
- package/dist/types/state/actions/index.d.ts +87 -0
- package/dist/types/state/index.d.ts +10 -5
- package/dist/types/ui/issue-like-table/styled.d.ts +4 -0
- package/dist/types/ui/issue-like-table/table-cell-content/index.d.ts +3 -2
- package/dist/types-ts4.5/state/actions/index.d.ts +87 -0
- package/dist/types-ts4.5/state/index.d.ts +10 -5
- package/dist/types-ts4.5/ui/issue-like-table/styled.d.ts +4 -0
- package/dist/types-ts4.5/ui/issue-like-table/table-cell-content/index.d.ts +3 -2
- package/package.json +7 -4
|
@@ -7,35 +7,28 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.TableCellContent = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _reactIntlNext = require("react-intl-next");
|
|
10
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
|
+
var _primitives = require("@atlaskit/primitives");
|
|
10
12
|
var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
|
|
11
13
|
var _state = require("../../../state");
|
|
12
14
|
var _renderType = require("../render-type");
|
|
13
15
|
var _truncateTextTag = require("../truncate-text-tag");
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
+
var truncateTextStyles = (0, _primitives.xcss)({
|
|
17
|
+
textOverflow: 'ellipsis',
|
|
18
|
+
overflow: 'hidden',
|
|
19
|
+
width: '100%'
|
|
20
|
+
});
|
|
21
|
+
var TooltipWrapper = function TooltipWrapper(_ref) {
|
|
16
22
|
var columnKey = _ref.columnKey,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
wrappedColumnKeys = _ref.wrappedColumnKeys
|
|
23
|
+
_ref$datasourceTypeWi = _ref.datasourceTypeWithValues,
|
|
24
|
+
type = _ref$datasourceTypeWi.type,
|
|
25
|
+
values = _ref$datasourceTypeWi.values,
|
|
26
|
+
wrappedColumnKeys = _ref.wrappedColumnKeys,
|
|
27
|
+
children = _ref.children;
|
|
21
28
|
var intl = (0, _reactIntlNext.useIntl)();
|
|
22
|
-
var rowData = (0, _state.useDatasourceItem)({
|
|
23
|
-
id: id
|
|
24
|
-
});
|
|
25
|
-
if (!rowData || !columnKey || !rowData[columnKey]) {
|
|
26
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Need to make sure we keep falsy values like 0 and '', as well as the boolean false.
|
|
30
|
-
var value = (_rowData$columnKey = rowData[columnKey]) === null || _rowData$columnKey === void 0 ? void 0 : _rowData$columnKey.data;
|
|
31
|
-
var values = Array.isArray(value) ? value : [value];
|
|
32
|
-
var renderedValues = renderItem({
|
|
33
|
-
type: columnType,
|
|
34
|
-
values: values
|
|
35
|
-
});
|
|
36
29
|
var stringifiedContent = values.map(function (value) {
|
|
37
30
|
return (0, _renderType.stringifyType)({
|
|
38
|
-
type:
|
|
31
|
+
type: type,
|
|
39
32
|
value: value
|
|
40
33
|
}, intl.formatMessage, intl.formatDate);
|
|
41
34
|
}).filter(function (value) {
|
|
@@ -48,7 +41,89 @@ var TableCellContent = exports.TableCellContent = function TableCellContent(_ref
|
|
|
48
41
|
tag: _truncateTextTag.TruncateTextTag,
|
|
49
42
|
content: stringifiedContent,
|
|
50
43
|
testId: "issues-table-cell-tooltip"
|
|
51
|
-
},
|
|
44
|
+
}, children);
|
|
45
|
+
}
|
|
46
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children);
|
|
47
|
+
};
|
|
48
|
+
var ReadOnlyCell = function ReadOnlyCell(_ref2) {
|
|
49
|
+
var _rowData$columnKey;
|
|
50
|
+
var id = _ref2.id,
|
|
51
|
+
columnType = _ref2.columnType,
|
|
52
|
+
_ref2$wrappedColumnKe = _ref2.wrappedColumnKeys,
|
|
53
|
+
wrappedColumnKeys = _ref2$wrappedColumnKe === void 0 ? [] : _ref2$wrappedColumnKe,
|
|
54
|
+
renderItem = _ref2.renderItem,
|
|
55
|
+
columnKey = _ref2.columnKey;
|
|
56
|
+
var rowData = (0, _state.useDatasourceItem)({
|
|
57
|
+
id: id
|
|
58
|
+
});
|
|
59
|
+
if (!rowData || !columnKey || !rowData[columnKey]) {
|
|
60
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Need to make sure we keep falsy values like 0 and '', as well as the boolean false.
|
|
64
|
+
var value = (_rowData$columnKey = rowData[columnKey]) === null || _rowData$columnKey === void 0 ? void 0 : _rowData$columnKey.data;
|
|
65
|
+
var values = Array.isArray(value) ? value : [value];
|
|
66
|
+
var datasourceTypeWithValues = {
|
|
67
|
+
type: columnType,
|
|
68
|
+
values: values
|
|
69
|
+
};
|
|
70
|
+
return /*#__PURE__*/_react.default.createElement(TooltipWrapper, {
|
|
71
|
+
columnKey: columnKey,
|
|
72
|
+
datasourceTypeWithValues: datasourceTypeWithValues,
|
|
73
|
+
wrappedColumnKeys: wrappedColumnKeys
|
|
74
|
+
}, renderItem(datasourceTypeWithValues));
|
|
75
|
+
};
|
|
76
|
+
var InlineEditableCell = function InlineEditableCell(_ref3) {
|
|
77
|
+
var _rowData$columnKey2;
|
|
78
|
+
var id = _ref3.id,
|
|
79
|
+
columnKey = _ref3.columnKey,
|
|
80
|
+
columnType = _ref3.columnType,
|
|
81
|
+
renderItem = _ref3.renderItem,
|
|
82
|
+
wrappedColumnKeys = _ref3.wrappedColumnKeys;
|
|
83
|
+
var rowData = (0, _state.useDatasourceItem)({
|
|
84
|
+
id: id
|
|
85
|
+
});
|
|
86
|
+
if (!rowData || !columnKey || !rowData[columnKey]) {
|
|
87
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
|
|
52
88
|
}
|
|
53
|
-
|
|
89
|
+
|
|
90
|
+
// Need to make sure we keep falsy values like 0 and '', as well as the boolean false.
|
|
91
|
+
var value = (_rowData$columnKey2 = rowData[columnKey]) === null || _rowData$columnKey2 === void 0 ? void 0 : _rowData$columnKey2.data;
|
|
92
|
+
var values = Array.isArray(value) ? value : [value];
|
|
93
|
+
var datasourceTypeWithValues = {
|
|
94
|
+
type: columnType,
|
|
95
|
+
values: values
|
|
96
|
+
};
|
|
97
|
+
return /*#__PURE__*/_react.default.createElement(TooltipWrapper, {
|
|
98
|
+
columnKey: columnKey,
|
|
99
|
+
datasourceTypeWithValues: datasourceTypeWithValues,
|
|
100
|
+
wrappedColumnKeys: wrappedColumnKeys
|
|
101
|
+
}, /*#__PURE__*/_react.default.createElement(_primitives.Box, {
|
|
102
|
+
testId: 'inline-edit-read-view',
|
|
103
|
+
paddingInline: 'space.100',
|
|
104
|
+
paddingBlock: 'space.050',
|
|
105
|
+
xcss: truncateTextStyles
|
|
106
|
+
}, renderItem(datasourceTypeWithValues)));
|
|
107
|
+
};
|
|
108
|
+
var TableCellContent = exports.TableCellContent = function TableCellContent(_ref4) {
|
|
109
|
+
var columnKey = _ref4.columnKey,
|
|
110
|
+
columnType = _ref4.columnType,
|
|
111
|
+
id = _ref4.id,
|
|
112
|
+
renderItem = _ref4.renderItem,
|
|
113
|
+
wrappedColumnKeys = _ref4.wrappedColumnKeys;
|
|
114
|
+
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
115
|
+
var renderedContent = (0, _platformFeatureFlags.fg)('platform-datasources-enable-two-way-sync') ? /*#__PURE__*/_react.default.createElement(InlineEditableCell, {
|
|
116
|
+
id: id,
|
|
117
|
+
columnKey: columnKey,
|
|
118
|
+
columnType: columnType,
|
|
119
|
+
renderItem: renderItem,
|
|
120
|
+
wrappedColumnKeys: wrappedColumnKeys
|
|
121
|
+
}) : /*#__PURE__*/_react.default.createElement(ReadOnlyCell, {
|
|
122
|
+
id: id,
|
|
123
|
+
columnKey: columnKey,
|
|
124
|
+
columnType: columnType,
|
|
125
|
+
wrappedColumnKeys: wrappedColumnKeys,
|
|
126
|
+
renderItem: renderItem
|
|
127
|
+
});
|
|
128
|
+
return renderedContent;
|
|
54
129
|
};
|
|
@@ -4,6 +4,7 @@ import { DEFAULT_GET_DATASOURCE_DATA_PAGE_SIZE, useDatasourceClientExtension } f
|
|
|
4
4
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
5
|
import { useDatasourceAnalyticsEvents } from '../analytics';
|
|
6
6
|
import { useDatasourceActions } from '../state';
|
|
7
|
+
import { useDiscoverActions } from '../state/actions';
|
|
7
8
|
import useErrorLogger from './useErrorLogger';
|
|
8
9
|
export const useDatasourceTableState = ({
|
|
9
10
|
datasourceId,
|
|
@@ -21,6 +22,9 @@ export const useDatasourceTableState = ({
|
|
|
21
22
|
const {
|
|
22
23
|
onAddItems
|
|
23
24
|
} = useDatasourceActions();
|
|
25
|
+
const {
|
|
26
|
+
discoverActions
|
|
27
|
+
} = useDiscoverActions();
|
|
24
28
|
const idFieldCount = 1;
|
|
25
29
|
const keyFieldCount = 1;
|
|
26
30
|
const [initialEmptyArray] = useState([]);
|
|
@@ -152,6 +156,7 @@ export const useDatasourceTableState = ({
|
|
|
152
156
|
meta: {
|
|
153
157
|
access,
|
|
154
158
|
destinationObjectTypes,
|
|
159
|
+
product,
|
|
155
160
|
extensionKey,
|
|
156
161
|
auth,
|
|
157
162
|
providerName
|
|
@@ -186,8 +191,27 @@ export const useDatasourceTableState = ({
|
|
|
186
191
|
return [...currentResponseItems, ...items];
|
|
187
192
|
});
|
|
188
193
|
if (fg('enable_datasource_react_sweet_state')) {
|
|
189
|
-
|
|
194
|
+
/**
|
|
195
|
+
* Product is typed as any.
|
|
196
|
+
*/
|
|
197
|
+
const integrationKey = product;
|
|
198
|
+
const newIds = onAddItems(items, typeof integrationKey === 'string' ? integrationKey : undefined);
|
|
190
199
|
setResponseItemIds(currentIds => [...currentIds, ...newIds]);
|
|
200
|
+
if (fg('platform-datasources-enable-two-way-sync')) {
|
|
201
|
+
if (typeof integrationKey === 'string') {
|
|
202
|
+
const aris = items.reduce((acc, item) => {
|
|
203
|
+
var _item$ari;
|
|
204
|
+
return typeof ((_item$ari = item.ari) === null || _item$ari === void 0 ? void 0 : _item$ari.data) === 'string' ? [...acc, item.ari.data] : acc;
|
|
205
|
+
}, []);
|
|
206
|
+
if (aris.length) {
|
|
207
|
+
discoverActions({
|
|
208
|
+
aris,
|
|
209
|
+
integrationKey,
|
|
210
|
+
fieldKeys
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
191
215
|
}
|
|
192
216
|
setHasNextPage(Boolean(nextPageCursor));
|
|
193
217
|
if (fieldKeys.length > 0) {
|
|
@@ -228,7 +252,7 @@ export const useDatasourceTableState = ({
|
|
|
228
252
|
}
|
|
229
253
|
setStatus('rejected');
|
|
230
254
|
}
|
|
231
|
-
}, [captureError, parameters, fieldKeys, nextCursor, responseItems, setResponseItemIds, onAddItems, getDatasourceData, datasourceId, applySchemaProperties, fireEvent, fullSchema, initialEmptyArray]);
|
|
255
|
+
}, [captureError, parameters, fieldKeys, nextCursor, responseItems, setResponseItemIds, onAddItems, getDatasourceData, datasourceId, applySchemaProperties, fireEvent, fullSchema, initialEmptyArray, discoverActions]);
|
|
232
256
|
const reset = useCallback(options => {
|
|
233
257
|
setResponseItems(initialEmptyArray);
|
|
234
258
|
setResponseItemIds(initialEmptyArray);
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { useCallback, useMemo } from 'react';
|
|
2
|
+
import { createActionsHook, createHook, createStore } from 'react-sweet-state';
|
|
3
|
+
import { useDatasourceClientExtension } from '@atlaskit/link-client-extension';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Atomic actions available for an integration (by field)
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* {
|
|
10
|
+
* jira: {
|
|
11
|
+
* summary: {
|
|
12
|
+
* actionKey: 'atlassian:issue:update:summary',
|
|
13
|
+
* type: 'string',
|
|
14
|
+
* description: 'Update issue summary',
|
|
15
|
+
* }
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Permissions available for a target
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* User permissions for actions on target (ARI) properties
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* {
|
|
30
|
+
* 'ari:cloud:jira:63cecfe3-16fa-4ee1-8e8d-047cc4b18980:issue/1': {
|
|
31
|
+
* summary: {
|
|
32
|
+
* isEditable: true
|
|
33
|
+
* }
|
|
34
|
+
* }
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
const getInitialState = () => ({
|
|
40
|
+
actionsByIntegration: {},
|
|
41
|
+
permissions: {}
|
|
42
|
+
});
|
|
43
|
+
export const actions = {
|
|
44
|
+
discoverActions: (api, request) => async ({
|
|
45
|
+
setState,
|
|
46
|
+
getState
|
|
47
|
+
}) => {
|
|
48
|
+
const response = await api.getDatasourceActionsAndPermissions(request);
|
|
49
|
+
if ('permissions' in response) {
|
|
50
|
+
const {
|
|
51
|
+
actionsByIntegration: currentActions,
|
|
52
|
+
permissions: currentPermissions
|
|
53
|
+
} = getState();
|
|
54
|
+
const actionsByIntegration = response.actions.reduce((acc, action) => ({
|
|
55
|
+
...acc,
|
|
56
|
+
[action.integrationKey]: {
|
|
57
|
+
...acc[action.integrationKey],
|
|
58
|
+
[action.fieldKey]: {
|
|
59
|
+
actionKey: action.actionKey,
|
|
60
|
+
type: action.type
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}), currentActions);
|
|
64
|
+
const permissions = response.permissions.data.reduce((acc, permission) => ({
|
|
65
|
+
...acc,
|
|
66
|
+
[permission.ari]: {
|
|
67
|
+
...acc[permission.ari],
|
|
68
|
+
[permission.fieldKey]: {
|
|
69
|
+
isEditable: permission.isEditable
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}), currentPermissions);
|
|
73
|
+
setState({
|
|
74
|
+
actionsByIntegration,
|
|
75
|
+
permissions
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
export const ActionsStore = createStore({
|
|
81
|
+
name: 'actions-store',
|
|
82
|
+
initialState: getInitialState(),
|
|
83
|
+
actions
|
|
84
|
+
});
|
|
85
|
+
const useActionStoreActions = createActionsHook(ActionsStore);
|
|
86
|
+
export const useDiscoverActions = () => {
|
|
87
|
+
const {
|
|
88
|
+
getDatasourceActionsAndPermissions
|
|
89
|
+
} = useDatasourceClientExtension();
|
|
90
|
+
const {
|
|
91
|
+
discoverActions
|
|
92
|
+
} = useActionStoreActions();
|
|
93
|
+
return {
|
|
94
|
+
discoverActions: useMemo(() => discoverActions.bind(null, {
|
|
95
|
+
getDatasourceActionsAndPermissions
|
|
96
|
+
}), [discoverActions, getDatasourceActionsAndPermissions])
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
const getFieldUpdateActionByAri = (state, {
|
|
100
|
+
ari,
|
|
101
|
+
fieldKey,
|
|
102
|
+
integrationKey
|
|
103
|
+
}) => {
|
|
104
|
+
var _state$permissions$ar, _state$permissions$ar2, _state$actionsByInteg;
|
|
105
|
+
const isEditable = (_state$permissions$ar = state.permissions[ari]) === null || _state$permissions$ar === void 0 ? void 0 : (_state$permissions$ar2 = _state$permissions$ar[fieldKey]) === null || _state$permissions$ar2 === void 0 ? void 0 : _state$permissions$ar2.isEditable;
|
|
106
|
+
if (isEditable === false) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
return (_state$actionsByInteg = state.actionsByIntegration[integrationKey]) === null || _state$actionsByInteg === void 0 ? void 0 : _state$actionsByInteg[fieldKey];
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Retrieves the action schema for a given ARI + fieldKey + integrationKey
|
|
114
|
+
*/
|
|
115
|
+
export const useAtomicUpdateActionSchema = createHook(ActionsStore, {
|
|
116
|
+
selector: getFieldUpdateActionByAri
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Given an ARI + fieldKey + integrationKey
|
|
121
|
+
* Returns an executable action that updates a field on the entity if the user has permissions to do so
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```tsx
|
|
125
|
+
* const { execute } = useExecuteAtomicAction({ ari, fieldKey: 'summary', integrationKey: 'jira' });
|
|
126
|
+
*
|
|
127
|
+
* return <button onClick={() => execute('New summary')}>Update summary</button>;
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
export const useExecuteAtomicAction = ({
|
|
131
|
+
ari,
|
|
132
|
+
fieldKey,
|
|
133
|
+
integrationKey
|
|
134
|
+
}) => {
|
|
135
|
+
const [schema] = useAtomicUpdateActionSchema({
|
|
136
|
+
ari,
|
|
137
|
+
fieldKey,
|
|
138
|
+
integrationKey
|
|
139
|
+
});
|
|
140
|
+
const {
|
|
141
|
+
executeAtomicAction: executeAction
|
|
142
|
+
} = useDatasourceClientExtension();
|
|
143
|
+
const execute = useCallback(value => {
|
|
144
|
+
if (!schema) {
|
|
145
|
+
throw new Error('No action schema found.');
|
|
146
|
+
}
|
|
147
|
+
executeAction({
|
|
148
|
+
integrationKey,
|
|
149
|
+
actionKey: schema.actionKey,
|
|
150
|
+
parameters: {
|
|
151
|
+
inputs: {
|
|
152
|
+
[fieldKey]: value
|
|
153
|
+
},
|
|
154
|
+
target: {
|
|
155
|
+
ari
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}, [executeAction, integrationKey, schema, fieldKey, ari]);
|
|
160
|
+
if (!schema) {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
return {
|
|
164
|
+
execute
|
|
165
|
+
};
|
|
166
|
+
};
|
|
@@ -6,7 +6,7 @@ const getInitialState = () => ({
|
|
|
6
6
|
items: {}
|
|
7
7
|
});
|
|
8
8
|
export const actions = {
|
|
9
|
-
onAddItems: items => ({
|
|
9
|
+
onAddItems: (items, integrationKey) => ({
|
|
10
10
|
setState,
|
|
11
11
|
getState
|
|
12
12
|
}) => {
|
|
@@ -14,14 +14,17 @@ export const actions = {
|
|
|
14
14
|
...getState().items
|
|
15
15
|
};
|
|
16
16
|
const [newItemIds, newItems] = items.reduce(([ids, itemMap], item) => {
|
|
17
|
-
var _item$ari;
|
|
17
|
+
var _item$ari, _oldItems$id;
|
|
18
18
|
const ari = typeof ((_item$ari = item['ari']) === null || _item$ari === void 0 ? void 0 : _item$ari.data) === 'string' ? item['ari'].data : undefined;
|
|
19
19
|
const id = ari !== null && ari !== void 0 ? ari : uuidv4();
|
|
20
20
|
return [[...ids, id], {
|
|
21
21
|
...itemMap,
|
|
22
22
|
[id]: {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
integrationKey,
|
|
24
|
+
data: {
|
|
25
|
+
...((_oldItems$id = oldItems[id]) === null || _oldItems$id === void 0 ? void 0 : _oldItems$id.data),
|
|
26
|
+
...item
|
|
27
|
+
}
|
|
25
28
|
}
|
|
26
29
|
}];
|
|
27
30
|
}, [[], oldItems]);
|
|
@@ -39,7 +42,10 @@ export const Store = createStore({
|
|
|
39
42
|
export const useDatasourceItem = createStateHook(Store, {
|
|
40
43
|
selector: (state, {
|
|
41
44
|
id
|
|
42
|
-
}) =>
|
|
45
|
+
}) => {
|
|
46
|
+
var _state$items$id;
|
|
47
|
+
return (_state$items$id = state.items[id]) === null || _state$items$id === void 0 ? void 0 : _state$items$id.data;
|
|
48
|
+
}
|
|
43
49
|
});
|
|
44
50
|
export const useDatasourceActions = createActionsHook(Store);
|
|
45
51
|
const Container = createContainer(Store);
|
|
@@ -30,7 +30,7 @@ import { DragColumnPreview } from './drag-column-preview';
|
|
|
30
30
|
import { DraggableTableHeading } from './draggable-table-heading';
|
|
31
31
|
import TableEmptyState from './empty-state';
|
|
32
32
|
import { renderType, stringifyType } from './render-type';
|
|
33
|
-
import { Table, TableCell, TableHeading, withTablePluginHeaderPrefix } from './styled';
|
|
33
|
+
import { InlineEditableTableCell, Table, TableCell, TableHeading, withTablePluginHeaderPrefix } from './styled';
|
|
34
34
|
import { TableCellContent } from './table-cell-content';
|
|
35
35
|
import { TruncateTextTag } from './truncate-text-tag';
|
|
36
36
|
import { useIsOnScreen } from './useIsOnScreen';
|
|
@@ -457,7 +457,9 @@ export const IssueLikeDataTableView = ({
|
|
|
457
457
|
}
|
|
458
458
|
}));
|
|
459
459
|
}, [visibleColumnKeys, onVisibleColumnKeysChange, tableId, hasData]);
|
|
460
|
-
const tableRows = useMemo(() =>
|
|
460
|
+
const tableRows = useMemo(() =>
|
|
461
|
+
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
462
|
+
fg('enable_datasource_react_sweet_state') ? itemIds.map((id, rowIndex) => {
|
|
461
463
|
return {
|
|
462
464
|
key: id,
|
|
463
465
|
cells: visibleSortedColumns.map(({
|
|
@@ -678,15 +680,29 @@ export const IssueLikeDataTableView = ({
|
|
|
678
680
|
paddingBlock: "var(--ds-space-100, 8px)"
|
|
679
681
|
};
|
|
680
682
|
}
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
683
|
+
|
|
684
|
+
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
685
|
+
if (fg('platform-datasources-enable-two-way-sync')) {
|
|
686
|
+
return jsx(InlineEditableTableCell, {
|
|
687
|
+
key: cellKey,
|
|
688
|
+
"data-testid": testId && `${testId}--cell-${cellIndex}`,
|
|
689
|
+
colSpan: isEditable && isLastCell ? 2 : undefined
|
|
690
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
691
|
+
,
|
|
692
|
+
style: loadingRowStyle,
|
|
693
|
+
css: [wrappedColumnKeys !== null && wrappedColumnKeys !== void 0 && wrappedColumnKeys.includes(cellKey) ? null : truncateStyles]
|
|
694
|
+
}, content);
|
|
695
|
+
} else {
|
|
696
|
+
return jsx(TableCell, {
|
|
697
|
+
key: cellKey,
|
|
698
|
+
"data-testid": testId && `${testId}--cell-${cellIndex}`,
|
|
699
|
+
colSpan: isEditable && isLastCell ? 2 : undefined
|
|
700
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
701
|
+
,
|
|
702
|
+
style: loadingRowStyle,
|
|
703
|
+
css: [wrappedColumnKeys !== null && wrappedColumnKeys !== void 0 && wrappedColumnKeys.includes(cellKey) ? null : truncateStyles]
|
|
704
|
+
}, content);
|
|
705
|
+
}
|
|
690
706
|
}))))));
|
|
691
707
|
};
|
|
692
708
|
export const EmptyState = TableEmptyState;
|
|
@@ -108,4 +108,32 @@ export const TableCell = styled.td({
|
|
|
108
108
|
["& [data-testid='inline-card-icon-and-title'], " + "& [data-testid='button-connect-account'] > span"]: {
|
|
109
109
|
whiteSpace: 'unset'
|
|
110
110
|
}
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-styled, @atlaskit/ui-styling-standard/no-exported-styles -- To migrate as part of go/ui-styling-standard
|
|
114
|
+
export const InlineEditableTableCell = styled.td({
|
|
115
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
116
|
+
[`${withTablePluginBodyPrefix()}`]: {
|
|
117
|
+
/* First section here is to override things editor table plugin css defines */
|
|
118
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
119
|
+
font: fieldTextFontSize,
|
|
120
|
+
padding: `${"var(--ds-space-0, 0)"} ${"var(--ds-space-0, 0)"}`,
|
|
121
|
+
border: 0,
|
|
122
|
+
minWidth: 'auto',
|
|
123
|
+
verticalAlign: 'inherit',
|
|
124
|
+
boxSizing: 'border-box',
|
|
125
|
+
borderRight: `0.5px solid ${`var(--ds-border, ${N40})`}`,
|
|
126
|
+
borderBottom: `0.5px solid ${`var(--ds-border, ${N40})`}`,
|
|
127
|
+
overflow: 'hidden'
|
|
128
|
+
},
|
|
129
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
130
|
+
[`${withTablePluginBodyPrefix('&:last-child')}`]: {
|
|
131
|
+
borderRight: 0
|
|
132
|
+
},
|
|
133
|
+
// Inline smart links are pretty opinionated about word-wrapping.
|
|
134
|
+
// We want it to be controlled by user, so we make it overflow and truncate by default.
|
|
135
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
136
|
+
["& [data-testid='inline-card-icon-and-title'], " + "& [data-testid='button-connect-account'] > span"]: {
|
|
137
|
+
whiteSpace: 'unset'
|
|
138
|
+
}
|
|
111
139
|
});
|
|
@@ -1,18 +1,49 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl-next';
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
|
+
import { Box, xcss } from '@atlaskit/primitives';
|
|
3
5
|
import Tooltip from '@atlaskit/tooltip';
|
|
4
6
|
import { useDatasourceItem } from '../../../state';
|
|
5
7
|
import { stringifyType } from '../render-type';
|
|
6
8
|
import { TruncateTextTag } from '../truncate-text-tag';
|
|
7
|
-
|
|
9
|
+
const truncateTextStyles = xcss({
|
|
10
|
+
textOverflow: 'ellipsis',
|
|
11
|
+
overflow: 'hidden',
|
|
12
|
+
width: '100%'
|
|
13
|
+
});
|
|
14
|
+
const TooltipWrapper = ({
|
|
8
15
|
columnKey,
|
|
9
|
-
|
|
16
|
+
datasourceTypeWithValues: {
|
|
17
|
+
type,
|
|
18
|
+
values
|
|
19
|
+
},
|
|
20
|
+
wrappedColumnKeys,
|
|
21
|
+
children
|
|
22
|
+
}) => {
|
|
23
|
+
const intl = useIntl();
|
|
24
|
+
const stringifiedContent = values.map(value => stringifyType({
|
|
25
|
+
type,
|
|
26
|
+
value
|
|
27
|
+
}, intl.formatMessage, intl.formatDate)).filter(value => value !== '').join(', ');
|
|
28
|
+
if (stringifiedContent && !(wrappedColumnKeys !== null && wrappedColumnKeys !== void 0 && wrappedColumnKeys.includes(columnKey))) {
|
|
29
|
+
return /*#__PURE__*/React.createElement(Tooltip
|
|
30
|
+
// @ts-ignore: [PIT-1685] Fails in post-office due to backwards incompatibility issue with React 18
|
|
31
|
+
, {
|
|
32
|
+
tag: TruncateTextTag,
|
|
33
|
+
content: stringifiedContent,
|
|
34
|
+
testId: "issues-table-cell-tooltip"
|
|
35
|
+
}, children);
|
|
36
|
+
}
|
|
37
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
38
|
+
};
|
|
39
|
+
const ReadOnlyCell = ({
|
|
10
40
|
id,
|
|
41
|
+
columnType,
|
|
42
|
+
wrappedColumnKeys = [],
|
|
11
43
|
renderItem,
|
|
12
|
-
|
|
44
|
+
columnKey
|
|
13
45
|
}) => {
|
|
14
46
|
var _rowData$columnKey;
|
|
15
|
-
const intl = useIntl();
|
|
16
47
|
const rowData = useDatasourceItem({
|
|
17
48
|
id
|
|
18
49
|
});
|
|
@@ -23,22 +54,69 @@ export const TableCellContent = ({
|
|
|
23
54
|
// Need to make sure we keep falsy values like 0 and '', as well as the boolean false.
|
|
24
55
|
const value = (_rowData$columnKey = rowData[columnKey]) === null || _rowData$columnKey === void 0 ? void 0 : _rowData$columnKey.data;
|
|
25
56
|
const values = Array.isArray(value) ? value : [value];
|
|
26
|
-
const
|
|
57
|
+
const datasourceTypeWithValues = {
|
|
27
58
|
type: columnType,
|
|
28
59
|
values
|
|
60
|
+
};
|
|
61
|
+
return /*#__PURE__*/React.createElement(TooltipWrapper, {
|
|
62
|
+
columnKey: columnKey,
|
|
63
|
+
datasourceTypeWithValues: datasourceTypeWithValues,
|
|
64
|
+
wrappedColumnKeys: wrappedColumnKeys
|
|
65
|
+
}, renderItem(datasourceTypeWithValues));
|
|
66
|
+
};
|
|
67
|
+
const InlineEditableCell = ({
|
|
68
|
+
id,
|
|
69
|
+
columnKey,
|
|
70
|
+
columnType,
|
|
71
|
+
renderItem,
|
|
72
|
+
wrappedColumnKeys
|
|
73
|
+
}) => {
|
|
74
|
+
var _rowData$columnKey2;
|
|
75
|
+
const rowData = useDatasourceItem({
|
|
76
|
+
id
|
|
29
77
|
});
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
value
|
|
33
|
-
}, intl.formatMessage, intl.formatDate)).filter(value => value !== '').join(', ');
|
|
34
|
-
if (stringifiedContent && !(wrappedColumnKeys !== null && wrappedColumnKeys !== void 0 && wrappedColumnKeys.includes(columnKey))) {
|
|
35
|
-
return /*#__PURE__*/React.createElement(Tooltip
|
|
36
|
-
// @ts-ignore: [PIT-1685] Fails in post-office due to backwards incompatibility issue with React 18
|
|
37
|
-
, {
|
|
38
|
-
tag: TruncateTextTag,
|
|
39
|
-
content: stringifiedContent,
|
|
40
|
-
testId: "issues-table-cell-tooltip"
|
|
41
|
-
}, renderedValues);
|
|
78
|
+
if (!rowData || !columnKey || !rowData[columnKey]) {
|
|
79
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
42
80
|
}
|
|
43
|
-
|
|
81
|
+
|
|
82
|
+
// Need to make sure we keep falsy values like 0 and '', as well as the boolean false.
|
|
83
|
+
const value = (_rowData$columnKey2 = rowData[columnKey]) === null || _rowData$columnKey2 === void 0 ? void 0 : _rowData$columnKey2.data;
|
|
84
|
+
const values = Array.isArray(value) ? value : [value];
|
|
85
|
+
const datasourceTypeWithValues = {
|
|
86
|
+
type: columnType,
|
|
87
|
+
values
|
|
88
|
+
};
|
|
89
|
+
return /*#__PURE__*/React.createElement(TooltipWrapper, {
|
|
90
|
+
columnKey: columnKey,
|
|
91
|
+
datasourceTypeWithValues: datasourceTypeWithValues,
|
|
92
|
+
wrappedColumnKeys: wrappedColumnKeys
|
|
93
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
94
|
+
testId: 'inline-edit-read-view',
|
|
95
|
+
paddingInline: 'space.100',
|
|
96
|
+
paddingBlock: 'space.050',
|
|
97
|
+
xcss: truncateTextStyles
|
|
98
|
+
}, renderItem(datasourceTypeWithValues)));
|
|
99
|
+
};
|
|
100
|
+
export const TableCellContent = ({
|
|
101
|
+
columnKey,
|
|
102
|
+
columnType,
|
|
103
|
+
id,
|
|
104
|
+
renderItem,
|
|
105
|
+
wrappedColumnKeys
|
|
106
|
+
}) => {
|
|
107
|
+
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
108
|
+
const renderedContent = fg('platform-datasources-enable-two-way-sync') ? /*#__PURE__*/React.createElement(InlineEditableCell, {
|
|
109
|
+
id: id,
|
|
110
|
+
columnKey: columnKey,
|
|
111
|
+
columnType: columnType,
|
|
112
|
+
renderItem: renderItem,
|
|
113
|
+
wrappedColumnKeys: wrappedColumnKeys
|
|
114
|
+
}) : /*#__PURE__*/React.createElement(ReadOnlyCell, {
|
|
115
|
+
id: id,
|
|
116
|
+
columnKey: columnKey,
|
|
117
|
+
columnType: columnType,
|
|
118
|
+
wrappedColumnKeys: wrappedColumnKeys,
|
|
119
|
+
renderItem: renderItem
|
|
120
|
+
});
|
|
121
|
+
return renderedContent;
|
|
44
122
|
};
|