@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
|
@@ -8,6 +8,7 @@ import { DEFAULT_GET_DATASOURCE_DATA_PAGE_SIZE, useDatasourceClientExtension } f
|
|
|
8
8
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
9
|
import { useDatasourceAnalyticsEvents } from '../analytics';
|
|
10
10
|
import { useDatasourceActions } from '../state';
|
|
11
|
+
import { useDiscoverActions } from '../state/actions';
|
|
11
12
|
import useErrorLogger from './useErrorLogger';
|
|
12
13
|
export var useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
13
14
|
var datasourceId = _ref.datasourceId,
|
|
@@ -22,6 +23,8 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
|
22
23
|
captureError = _useErrorLogger.captureError;
|
|
23
24
|
var _useDatasourceActions = useDatasourceActions(),
|
|
24
25
|
onAddItems = _useDatasourceActions.onAddItems;
|
|
26
|
+
var _useDiscoverActions = useDiscoverActions(),
|
|
27
|
+
discoverActions = _useDiscoverActions.discoverActions;
|
|
25
28
|
var idFieldCount = 1;
|
|
26
29
|
var keyFieldCount = 1;
|
|
27
30
|
var _useState = useState([]),
|
|
@@ -208,6 +211,7 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
|
208
211
|
_yield$getDatasourceD4,
|
|
209
212
|
access,
|
|
210
213
|
_destinationObjectTypes,
|
|
214
|
+
product,
|
|
211
215
|
_extensionKey,
|
|
212
216
|
auth,
|
|
213
217
|
_providerName,
|
|
@@ -216,7 +220,9 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
|
216
220
|
nextPageCursor,
|
|
217
221
|
_totalCount,
|
|
218
222
|
schema,
|
|
223
|
+
integrationKey,
|
|
219
224
|
newIds,
|
|
225
|
+
aris,
|
|
220
226
|
isUserLoadingNextPage,
|
|
221
227
|
currentLoadedItemCount,
|
|
222
228
|
newlyLoadedItemCount,
|
|
@@ -258,6 +264,7 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
|
258
264
|
_yield$getDatasourceD4 = _yield$getDatasourceD3.meta;
|
|
259
265
|
access = _yield$getDatasourceD4.access;
|
|
260
266
|
_destinationObjectTypes = _yield$getDatasourceD4.destinationObjectTypes;
|
|
267
|
+
product = _yield$getDatasourceD4.product;
|
|
261
268
|
_extensionKey = _yield$getDatasourceD4.extensionKey;
|
|
262
269
|
auth = _yield$getDatasourceD4.auth;
|
|
263
270
|
_providerName = _yield$getDatasourceD4.providerName;
|
|
@@ -267,21 +274,21 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
|
267
274
|
_totalCount = _yield$getDatasourceD5.totalCount;
|
|
268
275
|
schema = _yield$getDatasourceD5.schema;
|
|
269
276
|
if (!((_currentAbortControll = currentAbortController) !== null && _currentAbortControll !== void 0 && _currentAbortControll.signal.aborted)) {
|
|
270
|
-
_context2.next =
|
|
277
|
+
_context2.next = 28;
|
|
271
278
|
break;
|
|
272
279
|
}
|
|
273
280
|
throw new Error('Aborted');
|
|
274
|
-
case
|
|
281
|
+
case 28:
|
|
275
282
|
setExtensionKey(_extensionKey);
|
|
276
283
|
setProviderName(_providerName);
|
|
277
284
|
if (!(access === 'unauthorized' || access === 'forbidden')) {
|
|
278
|
-
_context2.next =
|
|
285
|
+
_context2.next = 34;
|
|
279
286
|
break;
|
|
280
287
|
}
|
|
281
288
|
setStatus(access);
|
|
282
289
|
setAuthDetails(auth || initialEmptyArray);
|
|
283
290
|
return _context2.abrupt("return");
|
|
284
|
-
case
|
|
291
|
+
case 34:
|
|
285
292
|
setDestinationObjectTypes(_destinationObjectTypes);
|
|
286
293
|
setTotalCount(_totalCount);
|
|
287
294
|
setNextCursor(nextPageCursor);
|
|
@@ -292,10 +299,29 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
|
292
299
|
return [].concat(_toConsumableArray(currentResponseItems), _toConsumableArray(items));
|
|
293
300
|
});
|
|
294
301
|
if (fg('enable_datasource_react_sweet_state')) {
|
|
295
|
-
|
|
302
|
+
/**
|
|
303
|
+
* Product is typed as any.
|
|
304
|
+
*/
|
|
305
|
+
integrationKey = product;
|
|
306
|
+
newIds = onAddItems(items, typeof integrationKey === 'string' ? integrationKey : undefined);
|
|
296
307
|
setResponseItemIds(function (currentIds) {
|
|
297
308
|
return [].concat(_toConsumableArray(currentIds), _toConsumableArray(newIds));
|
|
298
309
|
});
|
|
310
|
+
if (fg('platform-datasources-enable-two-way-sync')) {
|
|
311
|
+
if (typeof integrationKey === 'string') {
|
|
312
|
+
aris = items.reduce(function (acc, item) {
|
|
313
|
+
var _item$ari;
|
|
314
|
+
return typeof ((_item$ari = item.ari) === null || _item$ari === void 0 ? void 0 : _item$ari.data) === 'string' ? [].concat(_toConsumableArray(acc), [item.ari.data]) : acc;
|
|
315
|
+
}, []);
|
|
316
|
+
if (aris.length) {
|
|
317
|
+
discoverActions({
|
|
318
|
+
aris: aris,
|
|
319
|
+
integrationKey: integrationKey,
|
|
320
|
+
fieldKeys: fieldKeys
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
299
325
|
}
|
|
300
326
|
setHasNextPage(Boolean(nextPageCursor));
|
|
301
327
|
if (fieldKeys.length > 0) {
|
|
@@ -315,39 +341,39 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
|
315
341
|
});
|
|
316
342
|
}
|
|
317
343
|
setStatus('resolved');
|
|
318
|
-
_context2.next =
|
|
344
|
+
_context2.next = 59;
|
|
319
345
|
break;
|
|
320
|
-
case
|
|
321
|
-
_context2.prev =
|
|
346
|
+
case 47:
|
|
347
|
+
_context2.prev = 47;
|
|
322
348
|
_context2.t0 = _context2["catch"](10);
|
|
323
349
|
if (!(_context2.t0.message === 'Aborted')) {
|
|
324
|
-
_context2.next =
|
|
350
|
+
_context2.next = 51;
|
|
325
351
|
break;
|
|
326
352
|
}
|
|
327
353
|
return _context2.abrupt("return");
|
|
328
|
-
case
|
|
354
|
+
case 51:
|
|
329
355
|
captureError('onNextPage', _context2.t0);
|
|
330
356
|
if (!(_context2.t0 instanceof Response && _context2.t0.status === 401)) {
|
|
331
|
-
_context2.next =
|
|
357
|
+
_context2.next = 55;
|
|
332
358
|
break;
|
|
333
359
|
}
|
|
334
360
|
setStatus('unauthorized');
|
|
335
361
|
return _context2.abrupt("return");
|
|
336
|
-
case
|
|
362
|
+
case 55:
|
|
337
363
|
if (!(_context2.t0 instanceof Response && _context2.t0.status === 403)) {
|
|
338
|
-
_context2.next =
|
|
364
|
+
_context2.next = 58;
|
|
339
365
|
break;
|
|
340
366
|
}
|
|
341
367
|
setStatus('forbidden');
|
|
342
368
|
return _context2.abrupt("return");
|
|
343
|
-
case 57:
|
|
344
|
-
setStatus('rejected');
|
|
345
369
|
case 58:
|
|
370
|
+
setStatus('rejected');
|
|
371
|
+
case 59:
|
|
346
372
|
case "end":
|
|
347
373
|
return _context2.stop();
|
|
348
374
|
}
|
|
349
|
-
}, _callee2, null, [[10,
|
|
350
|
-
})), [captureError, parameters, fieldKeys, nextCursor, responseItems, setResponseItemIds, onAddItems, getDatasourceData, datasourceId, applySchemaProperties, fireEvent, fullSchema, initialEmptyArray]);
|
|
375
|
+
}, _callee2, null, [[10, 47]]);
|
|
376
|
+
})), [captureError, parameters, fieldKeys, nextCursor, responseItems, setResponseItemIds, onAddItems, getDatasourceData, datasourceId, applySchemaProperties, fireEvent, fullSchema, initialEmptyArray, discoverActions]);
|
|
351
377
|
var reset = useCallback(function (options) {
|
|
352
378
|
setResponseItems(initialEmptyArray);
|
|
353
379
|
setResponseItemIds(initialEmptyArray);
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
4
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
|
+
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; }
|
|
6
|
+
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; }
|
|
7
|
+
import { useCallback, useMemo } from 'react';
|
|
8
|
+
import { createActionsHook, createHook, createStore } from 'react-sweet-state';
|
|
9
|
+
import { useDatasourceClientExtension } from '@atlaskit/link-client-extension';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Atomic actions available for an integration (by field)
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* {
|
|
16
|
+
* jira: {
|
|
17
|
+
* summary: {
|
|
18
|
+
* actionKey: 'atlassian:issue:update:summary',
|
|
19
|
+
* type: 'string',
|
|
20
|
+
* description: 'Update issue summary',
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Permissions available for a target
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* User permissions for actions on target (ARI) properties
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* {
|
|
36
|
+
* 'ari:cloud:jira:63cecfe3-16fa-4ee1-8e8d-047cc4b18980:issue/1': {
|
|
37
|
+
* summary: {
|
|
38
|
+
* isEditable: true
|
|
39
|
+
* }
|
|
40
|
+
* }
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
var getInitialState = function getInitialState() {
|
|
46
|
+
return {
|
|
47
|
+
actionsByIntegration: {},
|
|
48
|
+
permissions: {}
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export var actions = {
|
|
52
|
+
discoverActions: function discoverActions(api, request) {
|
|
53
|
+
return /*#__PURE__*/function () {
|
|
54
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
55
|
+
var setState, getState, response, _getState, currentActions, currentPermissions, actionsByIntegration, permissions;
|
|
56
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
57
|
+
while (1) switch (_context.prev = _context.next) {
|
|
58
|
+
case 0:
|
|
59
|
+
setState = _ref.setState, getState = _ref.getState;
|
|
60
|
+
_context.next = 3;
|
|
61
|
+
return api.getDatasourceActionsAndPermissions(request);
|
|
62
|
+
case 3:
|
|
63
|
+
response = _context.sent;
|
|
64
|
+
if ('permissions' in response) {
|
|
65
|
+
_getState = getState(), currentActions = _getState.actionsByIntegration, currentPermissions = _getState.permissions;
|
|
66
|
+
actionsByIntegration = response.actions.reduce(function (acc, action) {
|
|
67
|
+
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, action.integrationKey, _objectSpread(_objectSpread({}, acc[action.integrationKey]), {}, _defineProperty({}, action.fieldKey, {
|
|
68
|
+
actionKey: action.actionKey,
|
|
69
|
+
type: action.type
|
|
70
|
+
}))));
|
|
71
|
+
}, currentActions);
|
|
72
|
+
permissions = response.permissions.data.reduce(function (acc, permission) {
|
|
73
|
+
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, permission.ari, _objectSpread(_objectSpread({}, acc[permission.ari]), {}, _defineProperty({}, permission.fieldKey, {
|
|
74
|
+
isEditable: permission.isEditable
|
|
75
|
+
}))));
|
|
76
|
+
}, currentPermissions);
|
|
77
|
+
setState({
|
|
78
|
+
actionsByIntegration: actionsByIntegration,
|
|
79
|
+
permissions: permissions
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
case 5:
|
|
83
|
+
case "end":
|
|
84
|
+
return _context.stop();
|
|
85
|
+
}
|
|
86
|
+
}, _callee);
|
|
87
|
+
}));
|
|
88
|
+
return function (_x) {
|
|
89
|
+
return _ref2.apply(this, arguments);
|
|
90
|
+
};
|
|
91
|
+
}();
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
export var ActionsStore = createStore({
|
|
95
|
+
name: 'actions-store',
|
|
96
|
+
initialState: getInitialState(),
|
|
97
|
+
actions: actions
|
|
98
|
+
});
|
|
99
|
+
var useActionStoreActions = createActionsHook(ActionsStore);
|
|
100
|
+
export var useDiscoverActions = function useDiscoverActions() {
|
|
101
|
+
var _useDatasourceClientE = useDatasourceClientExtension(),
|
|
102
|
+
getDatasourceActionsAndPermissions = _useDatasourceClientE.getDatasourceActionsAndPermissions;
|
|
103
|
+
var _useActionStoreAction = useActionStoreActions(),
|
|
104
|
+
discoverActions = _useActionStoreAction.discoverActions;
|
|
105
|
+
return {
|
|
106
|
+
discoverActions: useMemo(function () {
|
|
107
|
+
return discoverActions.bind(null, {
|
|
108
|
+
getDatasourceActionsAndPermissions: getDatasourceActionsAndPermissions
|
|
109
|
+
});
|
|
110
|
+
}, [discoverActions, getDatasourceActionsAndPermissions])
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
var getFieldUpdateActionByAri = function getFieldUpdateActionByAri(state, _ref3) {
|
|
114
|
+
var _state$permissions$ar, _state$actionsByInteg;
|
|
115
|
+
var ari = _ref3.ari,
|
|
116
|
+
fieldKey = _ref3.fieldKey,
|
|
117
|
+
integrationKey = _ref3.integrationKey;
|
|
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 === false) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
return (_state$actionsByInteg = state.actionsByIntegration[integrationKey]) === null || _state$actionsByInteg === void 0 ? void 0 : _state$actionsByInteg[fieldKey];
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Retrieves the action schema for a given ARI + fieldKey + integrationKey
|
|
127
|
+
*/
|
|
128
|
+
export var useAtomicUpdateActionSchema = createHook(ActionsStore, {
|
|
129
|
+
selector: getFieldUpdateActionByAri
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Given an ARI + fieldKey + integrationKey
|
|
134
|
+
* Returns an executable action that updates a field on the entity if the user has permissions to do so
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```tsx
|
|
138
|
+
* const { execute } = useExecuteAtomicAction({ ari, fieldKey: 'summary', integrationKey: 'jira' });
|
|
139
|
+
*
|
|
140
|
+
* return <button onClick={() => execute('New summary')}>Update summary</button>;
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
export var useExecuteAtomicAction = function useExecuteAtomicAction(_ref4) {
|
|
144
|
+
var ari = _ref4.ari,
|
|
145
|
+
fieldKey = _ref4.fieldKey,
|
|
146
|
+
integrationKey = _ref4.integrationKey;
|
|
147
|
+
var _useAtomicUpdateActio = useAtomicUpdateActionSchema({
|
|
148
|
+
ari: ari,
|
|
149
|
+
fieldKey: fieldKey,
|
|
150
|
+
integrationKey: integrationKey
|
|
151
|
+
}),
|
|
152
|
+
_useAtomicUpdateActio2 = _slicedToArray(_useAtomicUpdateActio, 1),
|
|
153
|
+
schema = _useAtomicUpdateActio2[0];
|
|
154
|
+
var _useDatasourceClientE2 = useDatasourceClientExtension(),
|
|
155
|
+
executeAction = _useDatasourceClientE2.executeAtomicAction;
|
|
156
|
+
var execute = useCallback(function (value) {
|
|
157
|
+
if (!schema) {
|
|
158
|
+
throw new Error('No action schema found.');
|
|
159
|
+
}
|
|
160
|
+
executeAction({
|
|
161
|
+
integrationKey: integrationKey,
|
|
162
|
+
actionKey: schema.actionKey,
|
|
163
|
+
parameters: {
|
|
164
|
+
inputs: _defineProperty({}, fieldKey, value),
|
|
165
|
+
target: {
|
|
166
|
+
ari: ari
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}, [executeAction, integrationKey, schema, fieldKey, ari]);
|
|
171
|
+
if (!schema) {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
execute: execute
|
|
176
|
+
};
|
|
177
|
+
};
|
package/dist/esm/state/index.js
CHANGED
|
@@ -13,19 +13,22 @@ var getInitialState = function getInitialState() {
|
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
15
|
export var actions = {
|
|
16
|
-
onAddItems: function onAddItems(items) {
|
|
16
|
+
onAddItems: function onAddItems(items, integrationKey) {
|
|
17
17
|
return function (_ref) {
|
|
18
18
|
var setState = _ref.setState,
|
|
19
19
|
getState = _ref.getState;
|
|
20
20
|
var oldItems = _objectSpread({}, getState().items);
|
|
21
21
|
var _items$reduce = items.reduce(function (_ref2, item) {
|
|
22
|
-
var _item$ari;
|
|
22
|
+
var _item$ari, _oldItems$id;
|
|
23
23
|
var _ref3 = _slicedToArray(_ref2, 2),
|
|
24
24
|
ids = _ref3[0],
|
|
25
25
|
itemMap = _ref3[1];
|
|
26
26
|
var ari = typeof ((_item$ari = item['ari']) === null || _item$ari === void 0 ? void 0 : _item$ari.data) === 'string' ? item['ari'].data : undefined;
|
|
27
27
|
var id = ari !== null && ari !== void 0 ? ari : uuidv4();
|
|
28
|
-
return [[].concat(_toConsumableArray(ids), [id]), _objectSpread(_objectSpread({}, itemMap), {}, _defineProperty({}, id,
|
|
28
|
+
return [[].concat(_toConsumableArray(ids), [id]), _objectSpread(_objectSpread({}, itemMap), {}, _defineProperty({}, id, {
|
|
29
|
+
integrationKey: integrationKey,
|
|
30
|
+
data: _objectSpread(_objectSpread({}, (_oldItems$id = oldItems[id]) === null || _oldItems$id === void 0 ? void 0 : _oldItems$id.data), item)
|
|
31
|
+
}))];
|
|
29
32
|
}, [[], oldItems]),
|
|
30
33
|
_items$reduce2 = _slicedToArray(_items$reduce, 2),
|
|
31
34
|
newItemIds = _items$reduce2[0],
|
|
@@ -44,8 +47,9 @@ export var Store = createStore({
|
|
|
44
47
|
});
|
|
45
48
|
export var useDatasourceItem = createStateHook(Store, {
|
|
46
49
|
selector: function selector(state, _ref4) {
|
|
50
|
+
var _state$items$id;
|
|
47
51
|
var id = _ref4.id;
|
|
48
|
-
return state.items[id];
|
|
52
|
+
return (_state$items$id = state.items[id]) === null || _state$items$id === void 0 ? void 0 : _state$items$id.data;
|
|
49
53
|
}
|
|
50
54
|
});
|
|
51
55
|
export var useDatasourceActions = createActionsHook(Store);
|
|
@@ -37,7 +37,7 @@ import { DragColumnPreview } from './drag-column-preview';
|
|
|
37
37
|
import { DraggableTableHeading } from './draggable-table-heading';
|
|
38
38
|
import TableEmptyState from './empty-state';
|
|
39
39
|
import { renderType, stringifyType } from './render-type';
|
|
40
|
-
import { Table, TableCell, TableHeading, withTablePluginHeaderPrefix } from './styled';
|
|
40
|
+
import { InlineEditableTableCell, Table, TableCell, TableHeading, withTablePluginHeaderPrefix } from './styled';
|
|
41
41
|
import { TableCellContent } from './table-cell-content';
|
|
42
42
|
import { TruncateTextTag } from './truncate-text-tag';
|
|
43
43
|
import { useIsOnScreen } from './useIsOnScreen';
|
|
@@ -456,69 +456,72 @@ export var IssueLikeDataTableView = function IssueLikeDataTableView(_ref5) {
|
|
|
456
456
|
}));
|
|
457
457
|
}, [visibleColumnKeys, onVisibleColumnKeysChange, tableId, hasData]);
|
|
458
458
|
var tableRows = useMemo(function () {
|
|
459
|
-
return
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
id: id,
|
|
459
|
+
return (
|
|
460
|
+
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
461
|
+
fg('enable_datasource_react_sweet_state') ? itemIds.map(function (id, rowIndex) {
|
|
462
|
+
return {
|
|
463
|
+
key: id,
|
|
464
|
+
cells: visibleSortedColumns.map(function (_ref12, cellIndex) {
|
|
465
|
+
var key = _ref12.key,
|
|
466
|
+
type = _ref12.type;
|
|
467
|
+
return {
|
|
468
|
+
key: key,
|
|
470
469
|
columnKey: key,
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
values:
|
|
495
|
-
|
|
496
|
-
var stringifiedContent = values.map(function (value) {
|
|
497
|
-
return stringifyType({
|
|
470
|
+
content: jsx(TableCellContent, {
|
|
471
|
+
id: id,
|
|
472
|
+
columnKey: key,
|
|
473
|
+
columnType: type,
|
|
474
|
+
wrappedColumnKeys: wrappedColumnKeys,
|
|
475
|
+
renderItem: renderItem
|
|
476
|
+
}),
|
|
477
|
+
width: getColumnWidth(key, type, cellIndex === visibleSortedColumns.length - 1)
|
|
478
|
+
};
|
|
479
|
+
}),
|
|
480
|
+
ref: rowIndex === items.length - 1 ? function (el) {
|
|
481
|
+
return setLastRowElement(el);
|
|
482
|
+
} : undefined
|
|
483
|
+
};
|
|
484
|
+
}) : items.map(function (newRowData, rowIndex) {
|
|
485
|
+
return {
|
|
486
|
+
key: "".concat(identityColumnKey && newRowData[identityColumnKey] && newRowData[identityColumnKey].data || rowIndex),
|
|
487
|
+
cells: visibleSortedColumns.map(function (_ref13, cellIndex) {
|
|
488
|
+
var _newRowData$key;
|
|
489
|
+
var key = _ref13.key,
|
|
490
|
+
type = _ref13.type;
|
|
491
|
+
// Need to make sure we keep falsy values like 0 and '', as well as the boolean false.
|
|
492
|
+
var value = (_newRowData$key = newRowData[key]) === null || _newRowData$key === void 0 ? void 0 : _newRowData$key.data;
|
|
493
|
+
var values = Array.isArray(value) ? value : [value];
|
|
494
|
+
var renderedValues = renderItem({
|
|
498
495
|
type: type,
|
|
499
|
-
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
496
|
+
values: values
|
|
497
|
+
});
|
|
498
|
+
var stringifiedContent = values.map(function (value) {
|
|
499
|
+
return stringifyType({
|
|
500
|
+
type: type,
|
|
501
|
+
value: value
|
|
502
|
+
}, intl.formatMessage, intl.formatDate);
|
|
503
|
+
}).filter(function (value) {
|
|
504
|
+
return value !== '';
|
|
505
|
+
}).join(', ');
|
|
506
|
+
var contentComponent = stringifiedContent && !(wrappedColumnKeys !== null && wrappedColumnKeys !== void 0 && wrappedColumnKeys.includes(key)) ? jsx(Tooltip
|
|
507
|
+
// @ts-ignore: [PIT-1685] Fails in post-office due to backwards incompatibility issue with React 18
|
|
508
|
+
, {
|
|
509
|
+
tag: TruncateTextTag,
|
|
510
|
+
content: stringifiedContent,
|
|
511
|
+
testId: "issues-table-cell-tooltip"
|
|
512
|
+
}, renderedValues) : renderedValues;
|
|
513
|
+
return {
|
|
514
|
+
key: key,
|
|
515
|
+
content: contentComponent,
|
|
516
|
+
width: getColumnWidth(key, type, cellIndex === visibleSortedColumns.length - 1)
|
|
517
|
+
};
|
|
518
|
+
}),
|
|
519
|
+
ref: rowIndex === items.length - 1 ? function (el) {
|
|
520
|
+
return setLastRowElement(el);
|
|
521
|
+
} : undefined
|
|
522
|
+
};
|
|
523
|
+
})
|
|
524
|
+
);
|
|
522
525
|
}, [items, itemIds, renderItem, wrappedColumnKeys, visibleSortedColumns, getColumnWidth, intl.formatMessage, intl.formatDate]);
|
|
523
526
|
var rows = useMemo(function () {
|
|
524
527
|
if (status !== 'loading') {
|
|
@@ -699,15 +702,29 @@ export var IssueLikeDataTableView = function IssueLikeDataTableView(_ref5) {
|
|
|
699
702
|
paddingBlock: "var(--ds-space-100, 8px)"
|
|
700
703
|
});
|
|
701
704
|
}
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
705
|
+
|
|
706
|
+
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
707
|
+
if (fg('platform-datasources-enable-two-way-sync')) {
|
|
708
|
+
return jsx(InlineEditableTableCell, {
|
|
709
|
+
key: cellKey,
|
|
710
|
+
"data-testid": testId && "".concat(testId, "--cell-").concat(cellIndex),
|
|
711
|
+
colSpan: isEditable && isLastCell ? 2 : undefined
|
|
712
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
713
|
+
,
|
|
714
|
+
style: loadingRowStyle,
|
|
715
|
+
css: [wrappedColumnKeys !== null && wrappedColumnKeys !== void 0 && wrappedColumnKeys.includes(cellKey) ? null : truncateStyles]
|
|
716
|
+
}, content);
|
|
717
|
+
} else {
|
|
718
|
+
return jsx(TableCell, {
|
|
719
|
+
key: cellKey,
|
|
720
|
+
"data-testid": testId && "".concat(testId, "--cell-").concat(cellIndex),
|
|
721
|
+
colSpan: isEditable && isLastCell ? 2 : undefined
|
|
722
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
723
|
+
,
|
|
724
|
+
style: loadingRowStyle,
|
|
725
|
+
css: [wrappedColumnKeys !== null && wrappedColumnKeys !== void 0 && wrappedColumnKeys.includes(cellKey) ? null : truncateStyles]
|
|
726
|
+
}, content);
|
|
727
|
+
}
|
|
711
728
|
}));
|
|
712
729
|
}))));
|
|
713
730
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
var _styled$th, _styled$td;
|
|
2
|
+
var _styled$th, _styled$td, _styled$td2;
|
|
3
3
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
4
4
|
import styled from '@emotion/styled';
|
|
5
5
|
import { N40 } from '@atlaskit/theme/colors';
|
|
@@ -87,4 +87,23 @@ export var TableCell = styled.td((_styled$td = {}, _defineProperty(_styled$td, "
|
|
|
87
87
|
paddingRight: "var(--ds-space-100, 8px)"
|
|
88
88
|
}), _defineProperty(_styled$td, "& [data-testid='inline-card-icon-and-title'], " + "& [data-testid='button-connect-account'] > span", {
|
|
89
89
|
whiteSpace: 'unset'
|
|
90
|
-
}), _styled$td));
|
|
90
|
+
}), _styled$td));
|
|
91
|
+
|
|
92
|
+
// 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
|
|
93
|
+
export var InlineEditableTableCell = styled.td((_styled$td2 = {}, _defineProperty(_styled$td2, "".concat(withTablePluginBodyPrefix()), {
|
|
94
|
+
/* First section here is to override things editor table plugin css defines */
|
|
95
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
96
|
+
font: fieldTextFontSize,
|
|
97
|
+
padding: "var(--ds-space-0, 0)".concat(" ", "var(--ds-space-0, 0)"),
|
|
98
|
+
border: 0,
|
|
99
|
+
minWidth: 'auto',
|
|
100
|
+
verticalAlign: 'inherit',
|
|
101
|
+
boxSizing: 'border-box',
|
|
102
|
+
borderRight: "0.5px solid ".concat("var(--ds-border, ".concat(N40, ")")),
|
|
103
|
+
borderBottom: "0.5px solid ".concat("var(--ds-border, ".concat(N40, ")")),
|
|
104
|
+
overflow: 'hidden'
|
|
105
|
+
}), _defineProperty(_styled$td2, "".concat(withTablePluginBodyPrefix('&:last-child')), {
|
|
106
|
+
borderRight: 0
|
|
107
|
+
}), _defineProperty(_styled$td2, "& [data-testid='inline-card-icon-and-title'], " + "& [data-testid='button-connect-account'] > span", {
|
|
108
|
+
whiteSpace: 'unset'
|
|
109
|
+
}), _styled$td2));
|