@atlaskit/link-datasource 2.8.0 → 2.9.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 +9 -0
- package/dist/cjs/hooks/useDatasourceTableState.js +54 -39
- package/dist/cjs/state/index.js +68 -0
- package/dist/cjs/ui/assets-modal/modal/index.js +8 -5
- package/dist/cjs/ui/confluence-search-modal/modal/index.js +3 -2
- package/dist/cjs/ui/datasource-table-view/datasourceTableView.js +3 -2
- package/dist/cjs/ui/jira-issues-modal/modal/index.js +3 -2
- package/dist/es2019/hooks/useDatasourceTableState.js +15 -5
- package/dist/es2019/state/index.js +55 -0
- package/dist/es2019/ui/assets-modal/modal/index.js +9 -6
- package/dist/es2019/ui/confluence-search-modal/modal/index.js +3 -2
- package/dist/es2019/ui/datasource-table-view/datasourceTableView.js +4 -3
- package/dist/es2019/ui/jira-issues-modal/modal/index.js +3 -2
- package/dist/esm/hooks/useDatasourceTableState.js +54 -39
- package/dist/esm/state/index.js +61 -0
- package/dist/esm/ui/assets-modal/modal/index.js +9 -6
- package/dist/esm/ui/confluence-search-modal/modal/index.js +3 -2
- package/dist/esm/ui/datasource-table-view/datasourceTableView.js +4 -3
- package/dist/esm/ui/jira-issues-modal/modal/index.js +3 -2
- package/dist/types/state/index.d.ts +21 -0
- package/dist/types/ui/confluence-search-modal/basic-filters/filters/date-range-picker/PopupComponent.d.ts +1 -1
- package/dist/types-ts4.5/state/index.d.ts +21 -0
- package/dist/types-ts4.5/ui/confluence-search-modal/basic-filters/filters/date-range-picker/PopupComponent.d.ts +1 -1
- package/package.json +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/link-datasource
|
|
2
2
|
|
|
3
|
+
## 2.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#123321](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/123321)
|
|
8
|
+
[`f932f3070f30d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f932f3070f30d) -
|
|
9
|
+
Added `react-sweet-state` which will be fully integrated in issue like table in the next
|
|
10
|
+
changeset.
|
|
11
|
+
|
|
3
12
|
## 2.8.0
|
|
4
13
|
|
|
5
14
|
### Minor Changes
|
|
@@ -12,7 +12,9 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
12
12
|
var _react = require("react");
|
|
13
13
|
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
14
14
|
var _linkClientExtension = require("@atlaskit/link-client-extension");
|
|
15
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
16
|
var _analytics = require("../analytics");
|
|
17
|
+
var _state = require("../state");
|
|
16
18
|
var _useErrorLogger2 = _interopRequireDefault(require("./useErrorLogger"));
|
|
17
19
|
var useDatasourceTableState = exports.useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
18
20
|
var datasourceId = _ref.datasourceId,
|
|
@@ -25,6 +27,8 @@ var useDatasourceTableState = exports.useDatasourceTableState = function useData
|
|
|
25
27
|
datasourceId: datasourceId
|
|
26
28
|
}),
|
|
27
29
|
captureError = _useErrorLogger.captureError;
|
|
30
|
+
var _useDatasourceActions = (0, _state.useDatasourceActions)(),
|
|
31
|
+
onAddItems = _useDatasourceActions.onAddItems;
|
|
28
32
|
var idFieldCount = 1;
|
|
29
33
|
var keyFieldCount = 1;
|
|
30
34
|
var _useState = (0, _react.useState)([]),
|
|
@@ -52,42 +56,45 @@ var useDatasourceTableState = exports.useDatasourceTableState = function useData
|
|
|
52
56
|
_useState12 = (0, _slicedToArray2.default)(_useState11, 2),
|
|
53
57
|
authDetails = _useState12[0],
|
|
54
58
|
setAuthDetails = _useState12[1];
|
|
55
|
-
var _useState13 = (0, _react.useState)(
|
|
59
|
+
var _useState13 = (0, _react.useState)(initialEmptyArray),
|
|
56
60
|
_useState14 = (0, _slicedToArray2.default)(_useState13, 2),
|
|
57
61
|
responseItems = _useState14[0],
|
|
58
62
|
setResponseItems = _useState14[1];
|
|
59
|
-
var _useState15 = (0, _react.useState)(
|
|
63
|
+
var _useState15 = (0, _react.useState)(initialEmptyArray),
|
|
60
64
|
_useState16 = (0, _slicedToArray2.default)(_useState15, 2),
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
var _useState17 = (0, _react.useState)(undefined),
|
|
65
|
+
setResponseItemIds = _useState16[1];
|
|
66
|
+
var _useState17 = (0, _react.useState)(true),
|
|
64
67
|
_useState18 = (0, _slicedToArray2.default)(_useState17, 2),
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
var _useState19 = (0, _react.useState)(
|
|
68
|
+
hasNextPage = _useState18[0],
|
|
69
|
+
setHasNextPage = _useState18[1];
|
|
70
|
+
var _useState19 = (0, _react.useState)(undefined),
|
|
68
71
|
_useState20 = (0, _slicedToArray2.default)(_useState19, 2),
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
var _useState21 = (0, _react.useState)(
|
|
72
|
+
nextCursor = _useState20[0],
|
|
73
|
+
setNextCursor = _useState20[1];
|
|
74
|
+
var _useState21 = (0, _react.useState)([]),
|
|
72
75
|
_useState22 = (0, _slicedToArray2.default)(_useState21, 2),
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
var _useState23 = (0, _react.useState)(
|
|
76
|
+
columns = _useState22[0],
|
|
77
|
+
setColumns = _useState22[1];
|
|
78
|
+
var _useState23 = (0, _react.useState)(undefined),
|
|
76
79
|
_useState24 = (0, _slicedToArray2.default)(_useState23, 2),
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
var _useState25 = (0, _react.useState)(
|
|
80
|
+
totalCount = _useState24[0],
|
|
81
|
+
setTotalCount = _useState24[1];
|
|
82
|
+
var _useState25 = (0, _react.useState)(false),
|
|
80
83
|
_useState26 = (0, _slicedToArray2.default)(_useState25, 2),
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
var _useState27 = (0, _react.useState)(),
|
|
84
|
+
shouldForceRequest = _useState26[0],
|
|
85
|
+
setShouldForceRequest = _useState26[1];
|
|
86
|
+
var _useState27 = (0, _react.useState)([]),
|
|
84
87
|
_useState28 = (0, _slicedToArray2.default)(_useState27, 2),
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
var _useState29 = (0, _react.useState)(
|
|
88
|
+
destinationObjectTypes = _useState28[0],
|
|
89
|
+
setDestinationObjectTypes = _useState28[1];
|
|
90
|
+
var _useState29 = (0, _react.useState)(),
|
|
88
91
|
_useState30 = (0, _slicedToArray2.default)(_useState29, 2),
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
extensionKey = _useState30[0],
|
|
93
|
+
setExtensionKey = _useState30[1];
|
|
94
|
+
var _useState31 = (0, _react.useState)(undefined),
|
|
95
|
+
_useState32 = (0, _slicedToArray2.default)(_useState31, 2),
|
|
96
|
+
providerName = _useState32[0],
|
|
97
|
+
setProviderName = _useState32[1];
|
|
91
98
|
var abortController = (0, _react.useRef)(new AbortController());
|
|
92
99
|
var _useDatasourceClientE = (0, _linkClientExtension.useDatasourceClientExtension)(),
|
|
93
100
|
getDatasourceData = _useDatasourceClientE.getDatasourceData,
|
|
@@ -215,6 +222,7 @@ var useDatasourceTableState = exports.useDatasourceTableState = function useData
|
|
|
215
222
|
nextPageCursor,
|
|
216
223
|
_totalCount,
|
|
217
224
|
schema,
|
|
225
|
+
newIds,
|
|
218
226
|
isUserLoadingNextPage,
|
|
219
227
|
currentLoadedItemCount,
|
|
220
228
|
newlyLoadedItemCount,
|
|
@@ -289,6 +297,12 @@ var useDatasourceTableState = exports.useDatasourceTableState = function useData
|
|
|
289
297
|
}
|
|
290
298
|
return [].concat((0, _toConsumableArray2.default)(currentResponseItems), (0, _toConsumableArray2.default)(items));
|
|
291
299
|
});
|
|
300
|
+
if ((0, _platformFeatureFlags.fg)('enable_datasource_react_sweet_state')) {
|
|
301
|
+
newIds = onAddItems(items);
|
|
302
|
+
setResponseItemIds(function (currentIds) {
|
|
303
|
+
return [].concat((0, _toConsumableArray2.default)(currentIds), (0, _toConsumableArray2.default)(newIds));
|
|
304
|
+
});
|
|
305
|
+
}
|
|
292
306
|
setHasNextPage(Boolean(nextPageCursor));
|
|
293
307
|
if (fieldKeys.length > 0) {
|
|
294
308
|
setLastRequestedFieldKeys(fieldKeys);
|
|
@@ -296,9 +310,9 @@ var useDatasourceTableState = exports.useDatasourceTableState = function useData
|
|
|
296
310
|
if ((isSchemaFromData && schema || fullSchema.properties.length > 0) && items.length > 0) {
|
|
297
311
|
applySchemaProperties(schema || fullSchema, fieldKeys);
|
|
298
312
|
}
|
|
299
|
-
isUserLoadingNextPage =
|
|
313
|
+
isUserLoadingNextPage = responseItems.length !== 0 && !shouldRequestFirstPage;
|
|
300
314
|
if (isUserLoadingNextPage) {
|
|
301
|
-
currentLoadedItemCount =
|
|
315
|
+
currentLoadedItemCount = responseItems.length;
|
|
302
316
|
newlyLoadedItemCount = (items === null || items === void 0 ? void 0 : items.length) || 0;
|
|
303
317
|
fireEvent('track.nextItem.loaded', {
|
|
304
318
|
extensionKey: _extensionKey,
|
|
@@ -307,41 +321,42 @@ var useDatasourceTableState = exports.useDatasourceTableState = function useData
|
|
|
307
321
|
});
|
|
308
322
|
}
|
|
309
323
|
setStatus('resolved');
|
|
310
|
-
_context2.next =
|
|
324
|
+
_context2.next = 58;
|
|
311
325
|
break;
|
|
312
|
-
case
|
|
313
|
-
_context2.prev =
|
|
326
|
+
case 46:
|
|
327
|
+
_context2.prev = 46;
|
|
314
328
|
_context2.t0 = _context2["catch"](10);
|
|
315
329
|
if (!(_context2.t0.message === 'Aborted')) {
|
|
316
|
-
_context2.next =
|
|
330
|
+
_context2.next = 50;
|
|
317
331
|
break;
|
|
318
332
|
}
|
|
319
333
|
return _context2.abrupt("return");
|
|
320
|
-
case
|
|
334
|
+
case 50:
|
|
321
335
|
captureError('onNextPage', _context2.t0);
|
|
322
336
|
if (!(_context2.t0 instanceof Response && _context2.t0.status === 401)) {
|
|
323
|
-
_context2.next =
|
|
337
|
+
_context2.next = 54;
|
|
324
338
|
break;
|
|
325
339
|
}
|
|
326
340
|
setStatus('unauthorized');
|
|
327
341
|
return _context2.abrupt("return");
|
|
328
|
-
case
|
|
342
|
+
case 54:
|
|
329
343
|
if (!(_context2.t0 instanceof Response && _context2.t0.status === 403)) {
|
|
330
|
-
_context2.next =
|
|
344
|
+
_context2.next = 57;
|
|
331
345
|
break;
|
|
332
346
|
}
|
|
333
347
|
setStatus('forbidden');
|
|
334
348
|
return _context2.abrupt("return");
|
|
335
|
-
case 56:
|
|
336
|
-
setStatus('rejected');
|
|
337
349
|
case 57:
|
|
350
|
+
setStatus('rejected');
|
|
351
|
+
case 58:
|
|
338
352
|
case "end":
|
|
339
353
|
return _context2.stop();
|
|
340
354
|
}
|
|
341
|
-
}, _callee2, null, [[10,
|
|
342
|
-
})), [captureError, parameters, fieldKeys, nextCursor, getDatasourceData, datasourceId,
|
|
355
|
+
}, _callee2, null, [[10, 46]]);
|
|
356
|
+
})), [captureError, parameters, fieldKeys, nextCursor, responseItems, setResponseItemIds, onAddItems, getDatasourceData, datasourceId, applySchemaProperties, fireEvent, fullSchema, initialEmptyArray]);
|
|
343
357
|
var reset = (0, _react.useCallback)(function (options) {
|
|
344
358
|
setResponseItems(initialEmptyArray);
|
|
359
|
+
setResponseItemIds(initialEmptyArray);
|
|
345
360
|
setHasNextPage(true);
|
|
346
361
|
setNextCursor(undefined);
|
|
347
362
|
setTotalCount(undefined);
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useDatasourceItem = exports.useDatasourceActions = exports.actions = exports.StoreContainer = exports.Store = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
var _react = _interopRequireDefault(require("react"));
|
|
12
|
+
var _reactSweetState = require("react-sweet-state");
|
|
13
|
+
var _uuid = require("uuid");
|
|
14
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
|
+
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; }
|
|
16
|
+
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) { (0, _defineProperty2.default)(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; }
|
|
17
|
+
var getInitialState = function getInitialState() {
|
|
18
|
+
return {
|
|
19
|
+
items: {}
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
var actions = exports.actions = {
|
|
23
|
+
onAddItems: function onAddItems(items) {
|
|
24
|
+
return function (_ref) {
|
|
25
|
+
var setState = _ref.setState,
|
|
26
|
+
getState = _ref.getState;
|
|
27
|
+
var oldItems = _objectSpread({}, getState().items);
|
|
28
|
+
var _items$reduce = items.reduce(function (_ref2, item) {
|
|
29
|
+
var _item$ari;
|
|
30
|
+
var _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
|
|
31
|
+
ids = _ref3[0],
|
|
32
|
+
itemMap = _ref3[1];
|
|
33
|
+
var ari = typeof ((_item$ari = item['ari']) === null || _item$ari === void 0 ? void 0 : _item$ari.data) === 'string' ? item['ari'].data : undefined;
|
|
34
|
+
var id = ari !== null && ari !== void 0 ? ari : (0, _uuid.v4)();
|
|
35
|
+
return [[].concat((0, _toConsumableArray2.default)(ids), [id]), _objectSpread(_objectSpread({}, itemMap), {}, (0, _defineProperty2.default)({}, id, _objectSpread(_objectSpread({}, oldItems[id]), item)))];
|
|
36
|
+
}, [[], oldItems]),
|
|
37
|
+
_items$reduce2 = (0, _slicedToArray2.default)(_items$reduce, 2),
|
|
38
|
+
newItemIds = _items$reduce2[0],
|
|
39
|
+
newItems = _items$reduce2[1];
|
|
40
|
+
setState({
|
|
41
|
+
items: newItems
|
|
42
|
+
});
|
|
43
|
+
return newItemIds;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
var Store = exports.Store = (0, _reactSweetState.createStore)({
|
|
48
|
+
name: 'datasource-store',
|
|
49
|
+
initialState: getInitialState(),
|
|
50
|
+
actions: actions
|
|
51
|
+
});
|
|
52
|
+
var useDatasourceItem = exports.useDatasourceItem = (0, _reactSweetState.createStateHook)(Store, {
|
|
53
|
+
selector: function selector(state, _ref4) {
|
|
54
|
+
var id = _ref4.id;
|
|
55
|
+
return state.items[id];
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
var useDatasourceActions = exports.useDatasourceActions = (0, _reactSweetState.createActionsHook)(Store);
|
|
59
|
+
var Container = (0, _reactSweetState.createContainer)(Store);
|
|
60
|
+
var StoreContainer = exports.StoreContainer = function StoreContainer(_ref5) {
|
|
61
|
+
var children = _ref5.children;
|
|
62
|
+
if ((0, _platformFeatureFlags.fg)('enable_datasource_react_sweet_state')) {
|
|
63
|
+
return /*#__PURE__*/_react.default.createElement(Container, {
|
|
64
|
+
scope: "datasource"
|
|
65
|
+
}, children);
|
|
66
|
+
}
|
|
67
|
+
return children;
|
|
68
|
+
};
|
|
@@ -30,6 +30,7 @@ var _useAssetsClient2 = require("../../../hooks/useAssetsClient");
|
|
|
30
30
|
var _useDatasourceTableState = require("../../../hooks/useDatasourceTableState");
|
|
31
31
|
var _en = _interopRequireDefault(require("../../../i18n/en"));
|
|
32
32
|
var _cmdbService = require("../../../services/cmdbService.utils");
|
|
33
|
+
var _state = require("../../../state");
|
|
33
34
|
var _accessRequired = require("../../../ui/common/error-state/access-required");
|
|
34
35
|
var _modalLoadingError = require("../../common/error-state/modal-loading-error");
|
|
35
36
|
var _cancelButton = require("../../common/modal/cancel-button");
|
|
@@ -66,7 +67,9 @@ var PlainAssetsConfigModal = function PlainAssetsConfigModal(props) {
|
|
|
66
67
|
schemaId = _useState4[0],
|
|
67
68
|
setSchemaId = _useState4[1];
|
|
68
69
|
var apiVersion = initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.version;
|
|
69
|
-
var _useState5 = (0, _react.useState)(
|
|
70
|
+
var _useState5 = (0, _react.useState)(
|
|
71
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
72
|
+
(0, _platformFeatureFlags.fg)('platform.linking-platform.datasource-assets_add_version_parameter') && apiVersion !== VERSION_TWO ? [] : initialVisibleColumnKeys),
|
|
70
73
|
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
71
74
|
visibleColumnKeys = _useState6[0],
|
|
72
75
|
setVisibleColumnKeys = _useState6[1];
|
|
@@ -125,7 +128,7 @@ var PlainAssetsConfigModal = function PlainAssetsConfigModal(props) {
|
|
|
125
128
|
aql: aql || '',
|
|
126
129
|
schemaId: schemaId || '',
|
|
127
130
|
workspaceId: workspaceId || ''
|
|
128
|
-
}, (0, _platformFeatureFlags.
|
|
131
|
+
}, (0, _platformFeatureFlags.fg)('platform.linking-platform.datasource-assets_add_version_parameter') ? {
|
|
129
132
|
version: VERSION_TWO
|
|
130
133
|
} : {});
|
|
131
134
|
}, [aql, schemaId, workspaceId]);
|
|
@@ -209,7 +212,7 @@ var PlainAssetsConfigModal = function PlainAssetsConfigModal(props) {
|
|
|
209
212
|
setIsNewSearch(false);
|
|
210
213
|
}, []);
|
|
211
214
|
(0, _react.useEffect)(function () {
|
|
212
|
-
if ((0, _platformFeatureFlags.
|
|
215
|
+
if ((0, _platformFeatureFlags.fg)('platform.linking-platform.datasource-assets_add_version_parameter')) {
|
|
213
216
|
var newVisibleColumnKeys = initialVisibleColumnKeys && initialVisibleColumnKeys.length > 0 && apiVersion === VERSION_TWO ? initialVisibleColumnKeys : defaultVisibleColumnKeys;
|
|
214
217
|
setVisibleColumnKeys(newVisibleColumnKeys);
|
|
215
218
|
} else {
|
|
@@ -268,7 +271,7 @@ var PlainAssetsConfigModal = function PlainAssetsConfigModal(props) {
|
|
|
268
271
|
workspaceId: workspaceId,
|
|
269
272
|
aql: aql,
|
|
270
273
|
schemaId: schemaId
|
|
271
|
-
}, (0, _platformFeatureFlags.
|
|
274
|
+
}, (0, _platformFeatureFlags.fg)('platform.linking-platform.datasource-assets_add_version_parameter') ? {
|
|
272
275
|
version: VERSION_TWO
|
|
273
276
|
} : {}),
|
|
274
277
|
views: [{
|
|
@@ -390,5 +393,5 @@ var contextData = _objectSpread(_objectSpread({}, analyticsContextData), {}, {
|
|
|
390
393
|
attributes: _objectSpread({}, analyticsContextAttributes)
|
|
391
394
|
});
|
|
392
395
|
var AssetsConfigModal = exports.AssetsConfigModal = (0, _analyticsNext.withAnalyticsContext)(contextData)(function (props) {
|
|
393
|
-
return (0, _react2.jsx)(_datasourceExperienceId.DatasourceExperienceIdProvider, null, (0, _react2.jsx)(_userInteractions.UserInteractionsProvider, null, (0, _react2.jsx)(PlainAssetsConfigModal, props)));
|
|
396
|
+
return (0, _react2.jsx)(_state.StoreContainer, null, (0, _react2.jsx)(_datasourceExperienceId.DatasourceExperienceIdProvider, null, (0, _react2.jsx)(_userInteractions.UserInteractionsProvider, null, (0, _react2.jsx)(PlainAssetsConfigModal, props))));
|
|
394
397
|
});
|
|
@@ -23,6 +23,7 @@ var _datasourceExperienceId = require("../../../contexts/datasource-experience-i
|
|
|
23
23
|
var _userInteractions = require("../../../contexts/user-interactions");
|
|
24
24
|
var _en = _interopRequireDefault(require("../../../i18n/en"));
|
|
25
25
|
var _useAvailableSites2 = require("../../../services/useAvailableSites");
|
|
26
|
+
var _state = require("../../../state");
|
|
26
27
|
var _accessRequired = require("../../common/error-state/access-required");
|
|
27
28
|
var _modalLoadingError = require("../../common/error-state/modal-loading-error");
|
|
28
29
|
var _noInstances = require("../../common/error-state/no-instances");
|
|
@@ -351,7 +352,7 @@ var contextData = _objectSpread(_objectSpread({}, analyticsContextData), {}, {
|
|
|
351
352
|
});
|
|
352
353
|
var ConfluenceSearchConfigModal = exports.ConfluenceSearchConfigModal = (0, _analyticsNext.withAnalyticsContext)(contextData)(function (props) {
|
|
353
354
|
var _props$viewMode;
|
|
354
|
-
return (0, _react2.jsx)(_datasourceExperienceId.DatasourceExperienceIdProvider, null, (0, _react2.jsx)(_userInteractions.UserInteractionsProvider, null, (0, _platformFeatureFlags.fg)('platform-datasources-use-refactored-config-modal') ? (0, _react2.jsx)(_datasourceContext.DatasourceContextProvider, {
|
|
355
|
+
return (0, _react2.jsx)(_state.StoreContainer, null, (0, _react2.jsx)(_datasourceExperienceId.DatasourceExperienceIdProvider, null, (0, _react2.jsx)(_userInteractions.UserInteractionsProvider, null, (0, _platformFeatureFlags.fg)('platform-datasources-use-refactored-config-modal') ? (0, _react2.jsx)(_datasourceContext.DatasourceContextProvider, {
|
|
355
356
|
datasourceId: props.datasourceId,
|
|
356
357
|
initialVisibleColumnKeys: props.visibleColumnKeys,
|
|
357
358
|
initialColumnCustomSizes: props.columnCustomSizes,
|
|
@@ -363,5 +364,5 @@ var ConfluenceSearchConfigModal = exports.ConfluenceSearchConfigModal = (0, _ana
|
|
|
363
364
|
viewMode: (_props$viewMode = props.viewMode) !== null && _props$viewMode !== void 0 ? _props$viewMode : DEFAULT_VIEW_MODE
|
|
364
365
|
}, (0, _react2.jsx)(PlainConfluenceSearchConfigModal, props))) :
|
|
365
366
|
// TODO on cleanup 'use-refactored-config-modal' ff, delete `ModalOld.tsx` as well
|
|
366
|
-
(0, _react2.jsx)(_ModalOld.PlainConfluenceSearchConfigModal, props)));
|
|
367
|
+
(0, _react2.jsx)(_ModalOld.PlainConfluenceSearchConfigModal, props))));
|
|
367
368
|
});
|
|
@@ -19,6 +19,7 @@ var _fetchMessagesForLocale = require("../../common/utils/locale/fetch-messages-
|
|
|
19
19
|
var _datasourceExperienceId = require("../../contexts/datasource-experience-id");
|
|
20
20
|
var _useDatasourceTableState = require("../../hooks/useDatasourceTableState");
|
|
21
21
|
var _en = _interopRequireDefault(require("../../i18n/en"));
|
|
22
|
+
var _state = require("../../state");
|
|
22
23
|
var _styled = require("../../ui/issue-like-table/styled");
|
|
23
24
|
var _assetsModal = require("../assets-modal");
|
|
24
25
|
var _accessRequired = require("../common/error-state/access-required");
|
|
@@ -121,7 +122,7 @@ var DatasourceTableViewWithoutAnalytics = function DatasourceTableViewWithoutAna
|
|
|
121
122
|
var forcedReset = (0, _react.useCallback)(function () {
|
|
122
123
|
reset({
|
|
123
124
|
shouldForceRequest: true,
|
|
124
|
-
shouldResetColumns: (0, _platformFeatureFlags.
|
|
125
|
+
shouldResetColumns: (0, _platformFeatureFlags.fg)('platform.linking-platform.datasource-assets_update_refresh_button_dt3qk') && datasourceId === _assetsModal.ASSETS_LIST_OF_LINKS_DATASOURCE_ID
|
|
125
126
|
});
|
|
126
127
|
}, [reset, datasourceId]);
|
|
127
128
|
var onRefresh = (0, _react.useCallback)(function () {
|
|
@@ -192,5 +193,5 @@ var DatasourceTableViewWithoutAnalytics = function DatasourceTableViewWithoutAna
|
|
|
192
193
|
})));
|
|
193
194
|
};
|
|
194
195
|
var DatasourceTableView = exports.DatasourceTableView = (0, _analyticsNext.withAnalyticsContext)(_constants.componentMetadata.tableView)(function (props) {
|
|
195
|
-
return (0, _react2.jsx)(_datasourceExperienceId.DatasourceExperienceIdProvider, null, (0, _react2.jsx)(DatasourceTableViewWithoutAnalytics, props));
|
|
196
|
+
return (0, _react2.jsx)(_state.StoreContainer, null, (0, _react2.jsx)(_datasourceExperienceId.DatasourceExperienceIdProvider, null, (0, _react2.jsx)(DatasourceTableViewWithoutAnalytics, props)));
|
|
196
197
|
});
|
|
@@ -30,6 +30,7 @@ var _userInteractions = require("../../../contexts/user-interactions");
|
|
|
30
30
|
var _useDatasourceTableState = require("../../../hooks/useDatasourceTableState");
|
|
31
31
|
var _en = _interopRequireDefault(require("../../../i18n/en"));
|
|
32
32
|
var _useAvailableSites2 = require("../../../services/useAvailableSites");
|
|
33
|
+
var _state = require("../../../state");
|
|
33
34
|
var _accessRequired = require("../../common/error-state/access-required");
|
|
34
35
|
var _messages = require("../../common/error-state/messages");
|
|
35
36
|
var _modalLoadingError = require("../../common/error-state/modal-loading-error");
|
|
@@ -500,7 +501,7 @@ var contextData = _objectSpread(_objectSpread({}, analyticsContextData), {}, {
|
|
|
500
501
|
});
|
|
501
502
|
var JiraIssuesConfigModal = exports.JiraIssuesConfigModal = (0, _analyticsNext.withAnalyticsContext)(contextData)(function (props) {
|
|
502
503
|
var _props$viewMode;
|
|
503
|
-
return (0, _react2.jsx)(_datasourceExperienceId.DatasourceExperienceIdProvider, null, (0, _react2.jsx)(_userInteractions.UserInteractionsProvider, null, (0, _platformFeatureFlags.fg)('platform-datasources-use-refactored-config-modal') ? (0, _react2.jsx)(_useViewModeContext2.DatasourceViewModeProvider, {
|
|
504
|
+
return (0, _react2.jsx)(_state.StoreContainer, null, (0, _react2.jsx)(_datasourceExperienceId.DatasourceExperienceIdProvider, null, (0, _react2.jsx)(_userInteractions.UserInteractionsProvider, null, (0, _platformFeatureFlags.fg)('platform-datasources-use-refactored-config-modal') ? (0, _react2.jsx)(_useViewModeContext2.DatasourceViewModeProvider, {
|
|
504
505
|
viewMode: (_props$viewMode = props.viewMode) !== null && _props$viewMode !== void 0 ? _props$viewMode : DEFAULT_VIEW_MODE
|
|
505
|
-
}, (0, _react2.jsx)(PlainJiraIssuesConfigModal, props)) : (0, _react2.jsx)(_ModalOld.PlainJiraIssuesConfigModalOld, props)));
|
|
506
|
+
}, (0, _react2.jsx)(PlainJiraIssuesConfigModal, props)) : (0, _react2.jsx)(_ModalOld.PlainJiraIssuesConfigModalOld, props))));
|
|
506
507
|
});
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import isEqual from 'lodash/isEqual';
|
|
3
3
|
import { DEFAULT_GET_DATASOURCE_DATA_PAGE_SIZE, useDatasourceClientExtension } from '@atlaskit/link-client-extension';
|
|
4
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
5
|
import { useDatasourceAnalyticsEvents } from '../analytics';
|
|
6
|
+
import { useDatasourceActions } from '../state';
|
|
5
7
|
import useErrorLogger from './useErrorLogger';
|
|
6
8
|
export const useDatasourceTableState = ({
|
|
7
9
|
datasourceId,
|
|
@@ -16,6 +18,9 @@ export const useDatasourceTableState = ({
|
|
|
16
18
|
} = useErrorLogger({
|
|
17
19
|
datasourceId
|
|
18
20
|
});
|
|
21
|
+
const {
|
|
22
|
+
onAddItems
|
|
23
|
+
} = useDatasourceActions();
|
|
19
24
|
const idFieldCount = 1;
|
|
20
25
|
const keyFieldCount = 1;
|
|
21
26
|
const [initialEmptyArray] = useState([]);
|
|
@@ -26,7 +31,8 @@ export const useDatasourceTableState = ({
|
|
|
26
31
|
});
|
|
27
32
|
const [status, setStatus] = useState('empty');
|
|
28
33
|
const [authDetails, setAuthDetails] = useState([]);
|
|
29
|
-
const [responseItems, setResponseItems] = useState(
|
|
34
|
+
const [responseItems, setResponseItems] = useState(initialEmptyArray);
|
|
35
|
+
const [, setResponseItemIds] = useState(initialEmptyArray);
|
|
30
36
|
const [hasNextPage, setHasNextPage] = useState(true);
|
|
31
37
|
const [nextCursor, setNextCursor] = useState(undefined);
|
|
32
38
|
const [columns, setColumns] = useState([]);
|
|
@@ -157,7 +163,6 @@ export const useDatasourceTableState = ({
|
|
|
157
163
|
schema
|
|
158
164
|
}
|
|
159
165
|
} = await getDatasourceData(datasourceId, datasourceDataRequest, shouldForceRequest);
|
|
160
|
-
|
|
161
166
|
/**
|
|
162
167
|
* Let the response finish and store in cache, but throw error if signal is aborted
|
|
163
168
|
*/
|
|
@@ -180,6 +185,10 @@ export const useDatasourceTableState = ({
|
|
|
180
185
|
}
|
|
181
186
|
return [...currentResponseItems, ...items];
|
|
182
187
|
});
|
|
188
|
+
if (fg('enable_datasource_react_sweet_state')) {
|
|
189
|
+
const newIds = onAddItems(items);
|
|
190
|
+
setResponseItemIds(currentIds => [...currentIds, ...newIds]);
|
|
191
|
+
}
|
|
183
192
|
setHasNextPage(Boolean(nextPageCursor));
|
|
184
193
|
if (fieldKeys.length > 0) {
|
|
185
194
|
setLastRequestedFieldKeys(fieldKeys);
|
|
@@ -187,9 +196,9 @@ export const useDatasourceTableState = ({
|
|
|
187
196
|
if ((isSchemaFromData && schema || fullSchema.properties.length > 0) && items.length > 0) {
|
|
188
197
|
applySchemaProperties(schema || fullSchema, fieldKeys);
|
|
189
198
|
}
|
|
190
|
-
const isUserLoadingNextPage =
|
|
199
|
+
const isUserLoadingNextPage = responseItems.length !== 0 && !shouldRequestFirstPage;
|
|
191
200
|
if (isUserLoadingNextPage) {
|
|
192
|
-
const currentLoadedItemCount =
|
|
201
|
+
const currentLoadedItemCount = responseItems.length;
|
|
193
202
|
const newlyLoadedItemCount = (items === null || items === void 0 ? void 0 : items.length) || 0;
|
|
194
203
|
fireEvent('track.nextItem.loaded', {
|
|
195
204
|
extensionKey,
|
|
@@ -219,9 +228,10 @@ export const useDatasourceTableState = ({
|
|
|
219
228
|
}
|
|
220
229
|
setStatus('rejected');
|
|
221
230
|
}
|
|
222
|
-
}, [captureError, parameters, fieldKeys, nextCursor, getDatasourceData, datasourceId,
|
|
231
|
+
}, [captureError, parameters, fieldKeys, nextCursor, responseItems, setResponseItemIds, onAddItems, getDatasourceData, datasourceId, applySchemaProperties, fireEvent, fullSchema, initialEmptyArray]);
|
|
223
232
|
const reset = useCallback(options => {
|
|
224
233
|
setResponseItems(initialEmptyArray);
|
|
234
|
+
setResponseItemIds(initialEmptyArray);
|
|
225
235
|
setHasNextPage(true);
|
|
226
236
|
setNextCursor(undefined);
|
|
227
237
|
setTotalCount(undefined);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { createActionsHook, createContainer, createStateHook, createStore } from 'react-sweet-state';
|
|
3
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
4
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
|
+
const getInitialState = () => ({
|
|
6
|
+
items: {}
|
|
7
|
+
});
|
|
8
|
+
export const actions = {
|
|
9
|
+
onAddItems: items => ({
|
|
10
|
+
setState,
|
|
11
|
+
getState
|
|
12
|
+
}) => {
|
|
13
|
+
const oldItems = {
|
|
14
|
+
...getState().items
|
|
15
|
+
};
|
|
16
|
+
const [newItemIds, newItems] = items.reduce(([ids, itemMap], item) => {
|
|
17
|
+
var _item$ari;
|
|
18
|
+
const ari = typeof ((_item$ari = item['ari']) === null || _item$ari === void 0 ? void 0 : _item$ari.data) === 'string' ? item['ari'].data : undefined;
|
|
19
|
+
const id = ari !== null && ari !== void 0 ? ari : uuidv4();
|
|
20
|
+
return [[...ids, id], {
|
|
21
|
+
...itemMap,
|
|
22
|
+
[id]: {
|
|
23
|
+
...oldItems[id],
|
|
24
|
+
...item
|
|
25
|
+
}
|
|
26
|
+
}];
|
|
27
|
+
}, [[], oldItems]);
|
|
28
|
+
setState({
|
|
29
|
+
items: newItems
|
|
30
|
+
});
|
|
31
|
+
return newItemIds;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
export const Store = createStore({
|
|
35
|
+
name: 'datasource-store',
|
|
36
|
+
initialState: getInitialState(),
|
|
37
|
+
actions
|
|
38
|
+
});
|
|
39
|
+
export const useDatasourceItem = createStateHook(Store, {
|
|
40
|
+
selector: (state, {
|
|
41
|
+
id
|
|
42
|
+
}) => state.items[id]
|
|
43
|
+
});
|
|
44
|
+
export const useDatasourceActions = createActionsHook(Store);
|
|
45
|
+
const Container = createContainer(Store);
|
|
46
|
+
export const StoreContainer = ({
|
|
47
|
+
children
|
|
48
|
+
}) => {
|
|
49
|
+
if (fg('enable_datasource_react_sweet_state')) {
|
|
50
|
+
return /*#__PURE__*/React.createElement(Container, {
|
|
51
|
+
scope: "datasource"
|
|
52
|
+
}, children);
|
|
53
|
+
}
|
|
54
|
+
return children;
|
|
55
|
+
};
|
|
@@ -12,7 +12,7 @@ import { withAnalyticsContext } from '@atlaskit/analytics-next';
|
|
|
12
12
|
import Button from '@atlaskit/button/standard-button';
|
|
13
13
|
import { IntlMessagesProvider } from '@atlaskit/intl-messages-provider';
|
|
14
14
|
import { ModalBody, ModalFooter, ModalHeader, ModalTitle, ModalTransition } from '@atlaskit/modal-dialog';
|
|
15
|
-
import {
|
|
15
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
16
16
|
import { EVENT_CHANNEL, useDatasourceAnalyticsEvents } from '../../../analytics';
|
|
17
17
|
import { componentMetadata } from '../../../analytics/constants';
|
|
18
18
|
import { DatasourceAction, DatasourceDisplay, DatasourceSearchMethod } from '../../../analytics/types';
|
|
@@ -27,6 +27,7 @@ import { useAssetsClient } from '../../../hooks/useAssetsClient';
|
|
|
27
27
|
import { useDatasourceTableState } from '../../../hooks/useDatasourceTableState';
|
|
28
28
|
import i18nEN from '../../../i18n/en';
|
|
29
29
|
import { PermissionError } from '../../../services/cmdbService.utils';
|
|
30
|
+
import { StoreContainer } from '../../../state';
|
|
30
31
|
import { AccessRequired } from '../../../ui/common/error-state/access-required';
|
|
31
32
|
import { ModalLoadingError } from '../../common/error-state/modal-loading-error';
|
|
32
33
|
import { CancelButton } from '../../common/modal/cancel-button';
|
|
@@ -54,7 +55,9 @@ const PlainAssetsConfigModal = props => {
|
|
|
54
55
|
const [aql, setAql] = useState(initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.aql);
|
|
55
56
|
const [schemaId, setSchemaId] = useState(initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.schemaId);
|
|
56
57
|
const apiVersion = initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.version;
|
|
57
|
-
const [visibleColumnKeys, setVisibleColumnKeys] = useState(
|
|
58
|
+
const [visibleColumnKeys, setVisibleColumnKeys] = useState(
|
|
59
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
60
|
+
fg('platform.linking-platform.datasource-assets_add_version_parameter') && apiVersion !== VERSION_TWO ? [] : initialVisibleColumnKeys);
|
|
58
61
|
const [isNewSearch, setIsNewSearch] = useState(false);
|
|
59
62
|
const [errorState, setErrorState] = useState();
|
|
60
63
|
const {
|
|
@@ -105,7 +108,7 @@ const PlainAssetsConfigModal = props => {
|
|
|
105
108
|
aql: aql || '',
|
|
106
109
|
schemaId: schemaId || '',
|
|
107
110
|
workspaceId: workspaceId || '',
|
|
108
|
-
...(
|
|
111
|
+
...(fg('platform.linking-platform.datasource-assets_add_version_parameter') ? {
|
|
109
112
|
version: VERSION_TWO
|
|
110
113
|
} : {})
|
|
111
114
|
}), [aql, schemaId, workspaceId]);
|
|
@@ -190,7 +193,7 @@ const PlainAssetsConfigModal = props => {
|
|
|
190
193
|
setIsNewSearch(false);
|
|
191
194
|
}, []);
|
|
192
195
|
useEffect(() => {
|
|
193
|
-
if (
|
|
196
|
+
if (fg('platform.linking-platform.datasource-assets_add_version_parameter')) {
|
|
194
197
|
const newVisibleColumnKeys = initialVisibleColumnKeys && initialVisibleColumnKeys.length > 0 && apiVersion === VERSION_TWO ? initialVisibleColumnKeys : defaultVisibleColumnKeys;
|
|
195
198
|
setVisibleColumnKeys(newVisibleColumnKeys);
|
|
196
199
|
} else {
|
|
@@ -249,7 +252,7 @@ const PlainAssetsConfigModal = props => {
|
|
|
249
252
|
workspaceId,
|
|
250
253
|
aql,
|
|
251
254
|
schemaId,
|
|
252
|
-
...(
|
|
255
|
+
...(fg('platform.linking-platform.datasource-assets_add_version_parameter') ? {
|
|
253
256
|
version: VERSION_TWO
|
|
254
257
|
} : {})
|
|
255
258
|
},
|
|
@@ -374,4 +377,4 @@ const contextData = {
|
|
|
374
377
|
...analyticsContextAttributes
|
|
375
378
|
}
|
|
376
379
|
};
|
|
377
|
-
export const AssetsConfigModal = withAnalyticsContext(contextData)(props => jsx(DatasourceExperienceIdProvider, null, jsx(UserInteractionsProvider, null, jsx(PlainAssetsConfigModal, props))));
|
|
380
|
+
export const AssetsConfigModal = withAnalyticsContext(contextData)(props => jsx(StoreContainer, null, jsx(DatasourceExperienceIdProvider, null, jsx(UserInteractionsProvider, null, jsx(PlainAssetsConfigModal, props)))));
|
|
@@ -21,6 +21,7 @@ import { DatasourceExperienceIdProvider } from '../../../contexts/datasource-exp
|
|
|
21
21
|
import { UserInteractionsProvider, useUserInteractions } from '../../../contexts/user-interactions';
|
|
22
22
|
import i18nEN from '../../../i18n/en';
|
|
23
23
|
import { useAvailableSites } from '../../../services/useAvailableSites';
|
|
24
|
+
import { StoreContainer } from '../../../state';
|
|
24
25
|
import { AccessRequired } from '../../common/error-state/access-required';
|
|
25
26
|
import { ModalLoadingError } from '../../common/error-state/modal-loading-error';
|
|
26
27
|
import { NoInstancesView } from '../../common/error-state/no-instances';
|
|
@@ -342,7 +343,7 @@ const contextData = {
|
|
|
342
343
|
};
|
|
343
344
|
export const ConfluenceSearchConfigModal = withAnalyticsContext(contextData)(props => {
|
|
344
345
|
var _props$viewMode;
|
|
345
|
-
return jsx(DatasourceExperienceIdProvider, null, jsx(UserInteractionsProvider, null, fg('platform-datasources-use-refactored-config-modal') ? jsx(DatasourceContextProvider, {
|
|
346
|
+
return jsx(StoreContainer, null, jsx(DatasourceExperienceIdProvider, null, jsx(UserInteractionsProvider, null, fg('platform-datasources-use-refactored-config-modal') ? jsx(DatasourceContextProvider, {
|
|
346
347
|
datasourceId: props.datasourceId,
|
|
347
348
|
initialVisibleColumnKeys: props.visibleColumnKeys,
|
|
348
349
|
initialColumnCustomSizes: props.columnCustomSizes,
|
|
@@ -354,5 +355,5 @@ export const ConfluenceSearchConfigModal = withAnalyticsContext(contextData)(pro
|
|
|
354
355
|
viewMode: (_props$viewMode = props.viewMode) !== null && _props$viewMode !== void 0 ? _props$viewMode : DEFAULT_VIEW_MODE
|
|
355
356
|
}, jsx(PlainConfluenceSearchConfigModal, props))) :
|
|
356
357
|
// TODO on cleanup 'use-refactored-config-modal' ff, delete `ModalOld.tsx` as well
|
|
357
|
-
jsx(PlainConfluenceSearchConfigModalOld, props)));
|
|
358
|
+
jsx(PlainConfluenceSearchConfigModalOld, props))));
|
|
358
359
|
});
|
|
@@ -8,7 +8,7 @@ import { useCallback, useEffect, useRef } from 'react';
|
|
|
8
8
|
import { css, jsx } from '@emotion/react';
|
|
9
9
|
import { withAnalyticsContext } from '@atlaskit/analytics-next';
|
|
10
10
|
import { IntlMessagesProvider } from '@atlaskit/intl-messages-provider';
|
|
11
|
-
import {
|
|
11
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
12
|
import { useDatasourceAnalyticsEvents } from '../../analytics';
|
|
13
13
|
import { componentMetadata } from '../../analytics/constants';
|
|
14
14
|
import { startUfoExperience } from '../../analytics/ufoExperiences';
|
|
@@ -18,6 +18,7 @@ import { fetchMessagesForLocale } from '../../common/utils/locale/fetch-messages
|
|
|
18
18
|
import { DatasourceExperienceIdProvider, useDatasourceExperienceId } from '../../contexts/datasource-experience-id';
|
|
19
19
|
import { useDatasourceTableState } from '../../hooks/useDatasourceTableState';
|
|
20
20
|
import i18nEN from '../../i18n/en';
|
|
21
|
+
import { StoreContainer } from '../../state';
|
|
21
22
|
import { ScrollableContainerHeight } from '../../ui/issue-like-table/styled';
|
|
22
23
|
import { ASSETS_LIST_OF_LINKS_DATASOURCE_ID } from '../assets-modal';
|
|
23
24
|
import { AccessRequired } from '../common/error-state/access-required';
|
|
@@ -115,7 +116,7 @@ const DatasourceTableViewWithoutAnalytics = ({
|
|
|
115
116
|
const forcedReset = useCallback(() => {
|
|
116
117
|
reset({
|
|
117
118
|
shouldForceRequest: true,
|
|
118
|
-
shouldResetColumns:
|
|
119
|
+
shouldResetColumns: fg('platform.linking-platform.datasource-assets_update_refresh_button_dt3qk') && datasourceId === ASSETS_LIST_OF_LINKS_DATASOURCE_ID
|
|
119
120
|
});
|
|
120
121
|
}, [reset, datasourceId]);
|
|
121
122
|
const onRefresh = useCallback(() => {
|
|
@@ -185,4 +186,4 @@ const DatasourceTableViewWithoutAnalytics = ({
|
|
|
185
186
|
url: url
|
|
186
187
|
})));
|
|
187
188
|
};
|
|
188
|
-
export const DatasourceTableView = withAnalyticsContext(componentMetadata.tableView)(props => jsx(DatasourceExperienceIdProvider, null, jsx(DatasourceTableViewWithoutAnalytics, props)));
|
|
189
|
+
export const DatasourceTableView = withAnalyticsContext(componentMetadata.tableView)(props => jsx(StoreContainer, null, jsx(DatasourceExperienceIdProvider, null, jsx(DatasourceTableViewWithoutAnalytics, props))));
|
|
@@ -29,6 +29,7 @@ import { UserInteractionsProvider, useUserInteractions } from '../../../contexts
|
|
|
29
29
|
import { useDatasourceTableState } from '../../../hooks/useDatasourceTableState';
|
|
30
30
|
import i18nEN from '../../../i18n/en';
|
|
31
31
|
import { useAvailableSites } from '../../../services/useAvailableSites';
|
|
32
|
+
import { StoreContainer } from '../../../state';
|
|
32
33
|
import { AccessRequired } from '../../common/error-state/access-required';
|
|
33
34
|
import { loadingErrorMessages } from '../../common/error-state/messages';
|
|
34
35
|
import { ModalLoadingError } from '../../common/error-state/modal-loading-error';
|
|
@@ -494,7 +495,7 @@ const contextData = {
|
|
|
494
495
|
};
|
|
495
496
|
export const JiraIssuesConfigModal = withAnalyticsContext(contextData)(props => {
|
|
496
497
|
var _props$viewMode;
|
|
497
|
-
return jsx(DatasourceExperienceIdProvider, null, jsx(UserInteractionsProvider, null, fg('platform-datasources-use-refactored-config-modal') ? jsx(DatasourceViewModeProvider, {
|
|
498
|
+
return jsx(StoreContainer, null, jsx(DatasourceExperienceIdProvider, null, jsx(UserInteractionsProvider, null, fg('platform-datasources-use-refactored-config-modal') ? jsx(DatasourceViewModeProvider, {
|
|
498
499
|
viewMode: (_props$viewMode = props.viewMode) !== null && _props$viewMode !== void 0 ? _props$viewMode : DEFAULT_VIEW_MODE
|
|
499
|
-
}, jsx(PlainJiraIssuesConfigModal, props)) : jsx(PlainJiraIssuesConfigModalOld, props)));
|
|
500
|
+
}, jsx(PlainJiraIssuesConfigModal, props)) : jsx(PlainJiraIssuesConfigModalOld, props))));
|
|
500
501
|
});
|
|
@@ -5,7 +5,9 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
5
5
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
6
6
|
import isEqual from 'lodash/isEqual';
|
|
7
7
|
import { DEFAULT_GET_DATASOURCE_DATA_PAGE_SIZE, useDatasourceClientExtension } from '@atlaskit/link-client-extension';
|
|
8
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
9
|
import { useDatasourceAnalyticsEvents } from '../analytics';
|
|
10
|
+
import { useDatasourceActions } from '../state';
|
|
9
11
|
import useErrorLogger from './useErrorLogger';
|
|
10
12
|
export var useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
11
13
|
var datasourceId = _ref.datasourceId,
|
|
@@ -18,6 +20,8 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
|
18
20
|
datasourceId: datasourceId
|
|
19
21
|
}),
|
|
20
22
|
captureError = _useErrorLogger.captureError;
|
|
23
|
+
var _useDatasourceActions = useDatasourceActions(),
|
|
24
|
+
onAddItems = _useDatasourceActions.onAddItems;
|
|
21
25
|
var idFieldCount = 1;
|
|
22
26
|
var keyFieldCount = 1;
|
|
23
27
|
var _useState = useState([]),
|
|
@@ -45,42 +49,45 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
|
45
49
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
46
50
|
authDetails = _useState12[0],
|
|
47
51
|
setAuthDetails = _useState12[1];
|
|
48
|
-
var _useState13 = useState(
|
|
52
|
+
var _useState13 = useState(initialEmptyArray),
|
|
49
53
|
_useState14 = _slicedToArray(_useState13, 2),
|
|
50
54
|
responseItems = _useState14[0],
|
|
51
55
|
setResponseItems = _useState14[1];
|
|
52
|
-
var _useState15 = useState(
|
|
56
|
+
var _useState15 = useState(initialEmptyArray),
|
|
53
57
|
_useState16 = _slicedToArray(_useState15, 2),
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
var _useState17 = useState(undefined),
|
|
58
|
+
setResponseItemIds = _useState16[1];
|
|
59
|
+
var _useState17 = useState(true),
|
|
57
60
|
_useState18 = _slicedToArray(_useState17, 2),
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
var _useState19 = useState(
|
|
61
|
+
hasNextPage = _useState18[0],
|
|
62
|
+
setHasNextPage = _useState18[1];
|
|
63
|
+
var _useState19 = useState(undefined),
|
|
61
64
|
_useState20 = _slicedToArray(_useState19, 2),
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
var _useState21 = useState(
|
|
65
|
+
nextCursor = _useState20[0],
|
|
66
|
+
setNextCursor = _useState20[1];
|
|
67
|
+
var _useState21 = useState([]),
|
|
65
68
|
_useState22 = _slicedToArray(_useState21, 2),
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
var _useState23 = useState(
|
|
69
|
+
columns = _useState22[0],
|
|
70
|
+
setColumns = _useState22[1];
|
|
71
|
+
var _useState23 = useState(undefined),
|
|
69
72
|
_useState24 = _slicedToArray(_useState23, 2),
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
var _useState25 = useState(
|
|
73
|
+
totalCount = _useState24[0],
|
|
74
|
+
setTotalCount = _useState24[1];
|
|
75
|
+
var _useState25 = useState(false),
|
|
73
76
|
_useState26 = _slicedToArray(_useState25, 2),
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
var _useState27 = useState(),
|
|
77
|
+
shouldForceRequest = _useState26[0],
|
|
78
|
+
setShouldForceRequest = _useState26[1];
|
|
79
|
+
var _useState27 = useState([]),
|
|
77
80
|
_useState28 = _slicedToArray(_useState27, 2),
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
var _useState29 = useState(
|
|
81
|
+
destinationObjectTypes = _useState28[0],
|
|
82
|
+
setDestinationObjectTypes = _useState28[1];
|
|
83
|
+
var _useState29 = useState(),
|
|
81
84
|
_useState30 = _slicedToArray(_useState29, 2),
|
|
82
|
-
|
|
83
|
-
|
|
85
|
+
extensionKey = _useState30[0],
|
|
86
|
+
setExtensionKey = _useState30[1];
|
|
87
|
+
var _useState31 = useState(undefined),
|
|
88
|
+
_useState32 = _slicedToArray(_useState31, 2),
|
|
89
|
+
providerName = _useState32[0],
|
|
90
|
+
setProviderName = _useState32[1];
|
|
84
91
|
var abortController = useRef(new AbortController());
|
|
85
92
|
var _useDatasourceClientE = useDatasourceClientExtension(),
|
|
86
93
|
getDatasourceData = _useDatasourceClientE.getDatasourceData,
|
|
@@ -208,6 +215,7 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
|
208
215
|
nextPageCursor,
|
|
209
216
|
_totalCount,
|
|
210
217
|
schema,
|
|
218
|
+
newIds,
|
|
211
219
|
isUserLoadingNextPage,
|
|
212
220
|
currentLoadedItemCount,
|
|
213
221
|
newlyLoadedItemCount,
|
|
@@ -282,6 +290,12 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
|
282
290
|
}
|
|
283
291
|
return [].concat(_toConsumableArray(currentResponseItems), _toConsumableArray(items));
|
|
284
292
|
});
|
|
293
|
+
if (fg('enable_datasource_react_sweet_state')) {
|
|
294
|
+
newIds = onAddItems(items);
|
|
295
|
+
setResponseItemIds(function (currentIds) {
|
|
296
|
+
return [].concat(_toConsumableArray(currentIds), _toConsumableArray(newIds));
|
|
297
|
+
});
|
|
298
|
+
}
|
|
285
299
|
setHasNextPage(Boolean(nextPageCursor));
|
|
286
300
|
if (fieldKeys.length > 0) {
|
|
287
301
|
setLastRequestedFieldKeys(fieldKeys);
|
|
@@ -289,9 +303,9 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
|
289
303
|
if ((isSchemaFromData && schema || fullSchema.properties.length > 0) && items.length > 0) {
|
|
290
304
|
applySchemaProperties(schema || fullSchema, fieldKeys);
|
|
291
305
|
}
|
|
292
|
-
isUserLoadingNextPage =
|
|
306
|
+
isUserLoadingNextPage = responseItems.length !== 0 && !shouldRequestFirstPage;
|
|
293
307
|
if (isUserLoadingNextPage) {
|
|
294
|
-
currentLoadedItemCount =
|
|
308
|
+
currentLoadedItemCount = responseItems.length;
|
|
295
309
|
newlyLoadedItemCount = (items === null || items === void 0 ? void 0 : items.length) || 0;
|
|
296
310
|
fireEvent('track.nextItem.loaded', {
|
|
297
311
|
extensionKey: _extensionKey,
|
|
@@ -300,41 +314,42 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
|
300
314
|
});
|
|
301
315
|
}
|
|
302
316
|
setStatus('resolved');
|
|
303
|
-
_context2.next =
|
|
317
|
+
_context2.next = 58;
|
|
304
318
|
break;
|
|
305
|
-
case
|
|
306
|
-
_context2.prev =
|
|
319
|
+
case 46:
|
|
320
|
+
_context2.prev = 46;
|
|
307
321
|
_context2.t0 = _context2["catch"](10);
|
|
308
322
|
if (!(_context2.t0.message === 'Aborted')) {
|
|
309
|
-
_context2.next =
|
|
323
|
+
_context2.next = 50;
|
|
310
324
|
break;
|
|
311
325
|
}
|
|
312
326
|
return _context2.abrupt("return");
|
|
313
|
-
case
|
|
327
|
+
case 50:
|
|
314
328
|
captureError('onNextPage', _context2.t0);
|
|
315
329
|
if (!(_context2.t0 instanceof Response && _context2.t0.status === 401)) {
|
|
316
|
-
_context2.next =
|
|
330
|
+
_context2.next = 54;
|
|
317
331
|
break;
|
|
318
332
|
}
|
|
319
333
|
setStatus('unauthorized');
|
|
320
334
|
return _context2.abrupt("return");
|
|
321
|
-
case
|
|
335
|
+
case 54:
|
|
322
336
|
if (!(_context2.t0 instanceof Response && _context2.t0.status === 403)) {
|
|
323
|
-
_context2.next =
|
|
337
|
+
_context2.next = 57;
|
|
324
338
|
break;
|
|
325
339
|
}
|
|
326
340
|
setStatus('forbidden');
|
|
327
341
|
return _context2.abrupt("return");
|
|
328
|
-
case 56:
|
|
329
|
-
setStatus('rejected');
|
|
330
342
|
case 57:
|
|
343
|
+
setStatus('rejected');
|
|
344
|
+
case 58:
|
|
331
345
|
case "end":
|
|
332
346
|
return _context2.stop();
|
|
333
347
|
}
|
|
334
|
-
}, _callee2, null, [[10,
|
|
335
|
-
})), [captureError, parameters, fieldKeys, nextCursor, getDatasourceData, datasourceId,
|
|
348
|
+
}, _callee2, null, [[10, 46]]);
|
|
349
|
+
})), [captureError, parameters, fieldKeys, nextCursor, responseItems, setResponseItemIds, onAddItems, getDatasourceData, datasourceId, applySchemaProperties, fireEvent, fullSchema, initialEmptyArray]);
|
|
336
350
|
var reset = useCallback(function (options) {
|
|
337
351
|
setResponseItems(initialEmptyArray);
|
|
352
|
+
setResponseItemIds(initialEmptyArray);
|
|
338
353
|
setHasNextPage(true);
|
|
339
354
|
setNextCursor(undefined);
|
|
340
355
|
setTotalCount(undefined);
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
+
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; }
|
|
5
|
+
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; }
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { createActionsHook, createContainer, createStateHook, createStore } from 'react-sweet-state';
|
|
8
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
9
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
|
+
var getInitialState = function getInitialState() {
|
|
11
|
+
return {
|
|
12
|
+
items: {}
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export var actions = {
|
|
16
|
+
onAddItems: function onAddItems(items) {
|
|
17
|
+
return function (_ref) {
|
|
18
|
+
var setState = _ref.setState,
|
|
19
|
+
getState = _ref.getState;
|
|
20
|
+
var oldItems = _objectSpread({}, getState().items);
|
|
21
|
+
var _items$reduce = items.reduce(function (_ref2, item) {
|
|
22
|
+
var _item$ari;
|
|
23
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
24
|
+
ids = _ref3[0],
|
|
25
|
+
itemMap = _ref3[1];
|
|
26
|
+
var ari = typeof ((_item$ari = item['ari']) === null || _item$ari === void 0 ? void 0 : _item$ari.data) === 'string' ? item['ari'].data : undefined;
|
|
27
|
+
var id = ari !== null && ari !== void 0 ? ari : uuidv4();
|
|
28
|
+
return [[].concat(_toConsumableArray(ids), [id]), _objectSpread(_objectSpread({}, itemMap), {}, _defineProperty({}, id, _objectSpread(_objectSpread({}, oldItems[id]), item)))];
|
|
29
|
+
}, [[], oldItems]),
|
|
30
|
+
_items$reduce2 = _slicedToArray(_items$reduce, 2),
|
|
31
|
+
newItemIds = _items$reduce2[0],
|
|
32
|
+
newItems = _items$reduce2[1];
|
|
33
|
+
setState({
|
|
34
|
+
items: newItems
|
|
35
|
+
});
|
|
36
|
+
return newItemIds;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
export var Store = createStore({
|
|
41
|
+
name: 'datasource-store',
|
|
42
|
+
initialState: getInitialState(),
|
|
43
|
+
actions: actions
|
|
44
|
+
});
|
|
45
|
+
export var useDatasourceItem = createStateHook(Store, {
|
|
46
|
+
selector: function selector(state, _ref4) {
|
|
47
|
+
var id = _ref4.id;
|
|
48
|
+
return state.items[id];
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
export var useDatasourceActions = createActionsHook(Store);
|
|
52
|
+
var Container = createContainer(Store);
|
|
53
|
+
export var StoreContainer = function StoreContainer(_ref5) {
|
|
54
|
+
var children = _ref5.children;
|
|
55
|
+
if (fg('enable_datasource_react_sweet_state')) {
|
|
56
|
+
return /*#__PURE__*/React.createElement(Container, {
|
|
57
|
+
scope: "datasource"
|
|
58
|
+
}, children);
|
|
59
|
+
}
|
|
60
|
+
return children;
|
|
61
|
+
};
|
|
@@ -16,7 +16,7 @@ import { withAnalyticsContext } from '@atlaskit/analytics-next';
|
|
|
16
16
|
import Button from '@atlaskit/button/standard-button';
|
|
17
17
|
import { IntlMessagesProvider } from '@atlaskit/intl-messages-provider';
|
|
18
18
|
import { ModalBody, ModalFooter, ModalHeader, ModalTitle, ModalTransition } from '@atlaskit/modal-dialog';
|
|
19
|
-
import {
|
|
19
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
20
20
|
import { EVENT_CHANNEL, useDatasourceAnalyticsEvents } from '../../../analytics';
|
|
21
21
|
import { componentMetadata } from '../../../analytics/constants';
|
|
22
22
|
import { DatasourceAction, DatasourceDisplay, DatasourceSearchMethod } from '../../../analytics/types';
|
|
@@ -31,6 +31,7 @@ import { useAssetsClient } from '../../../hooks/useAssetsClient';
|
|
|
31
31
|
import { useDatasourceTableState } from '../../../hooks/useDatasourceTableState';
|
|
32
32
|
import i18nEN from '../../../i18n/en';
|
|
33
33
|
import { PermissionError } from '../../../services/cmdbService.utils';
|
|
34
|
+
import { StoreContainer } from '../../../state';
|
|
34
35
|
import { AccessRequired } from '../../../ui/common/error-state/access-required';
|
|
35
36
|
import { ModalLoadingError } from '../../common/error-state/modal-loading-error';
|
|
36
37
|
import { CancelButton } from '../../common/modal/cancel-button';
|
|
@@ -62,7 +63,9 @@ var PlainAssetsConfigModal = function PlainAssetsConfigModal(props) {
|
|
|
62
63
|
schemaId = _useState4[0],
|
|
63
64
|
setSchemaId = _useState4[1];
|
|
64
65
|
var apiVersion = initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.version;
|
|
65
|
-
var _useState5 = useState(
|
|
66
|
+
var _useState5 = useState(
|
|
67
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
68
|
+
fg('platform.linking-platform.datasource-assets_add_version_parameter') && apiVersion !== VERSION_TWO ? [] : initialVisibleColumnKeys),
|
|
66
69
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
67
70
|
visibleColumnKeys = _useState6[0],
|
|
68
71
|
setVisibleColumnKeys = _useState6[1];
|
|
@@ -121,7 +124,7 @@ var PlainAssetsConfigModal = function PlainAssetsConfigModal(props) {
|
|
|
121
124
|
aql: aql || '',
|
|
122
125
|
schemaId: schemaId || '',
|
|
123
126
|
workspaceId: workspaceId || ''
|
|
124
|
-
},
|
|
127
|
+
}, fg('platform.linking-platform.datasource-assets_add_version_parameter') ? {
|
|
125
128
|
version: VERSION_TWO
|
|
126
129
|
} : {});
|
|
127
130
|
}, [aql, schemaId, workspaceId]);
|
|
@@ -205,7 +208,7 @@ var PlainAssetsConfigModal = function PlainAssetsConfigModal(props) {
|
|
|
205
208
|
setIsNewSearch(false);
|
|
206
209
|
}, []);
|
|
207
210
|
useEffect(function () {
|
|
208
|
-
if (
|
|
211
|
+
if (fg('platform.linking-platform.datasource-assets_add_version_parameter')) {
|
|
209
212
|
var newVisibleColumnKeys = initialVisibleColumnKeys && initialVisibleColumnKeys.length > 0 && apiVersion === VERSION_TWO ? initialVisibleColumnKeys : defaultVisibleColumnKeys;
|
|
210
213
|
setVisibleColumnKeys(newVisibleColumnKeys);
|
|
211
214
|
} else {
|
|
@@ -264,7 +267,7 @@ var PlainAssetsConfigModal = function PlainAssetsConfigModal(props) {
|
|
|
264
267
|
workspaceId: workspaceId,
|
|
265
268
|
aql: aql,
|
|
266
269
|
schemaId: schemaId
|
|
267
|
-
},
|
|
270
|
+
}, fg('platform.linking-platform.datasource-assets_add_version_parameter') ? {
|
|
268
271
|
version: VERSION_TWO
|
|
269
272
|
} : {}),
|
|
270
273
|
views: [{
|
|
@@ -386,5 +389,5 @@ var contextData = _objectSpread(_objectSpread({}, analyticsContextData), {}, {
|
|
|
386
389
|
attributes: _objectSpread({}, analyticsContextAttributes)
|
|
387
390
|
});
|
|
388
391
|
export var AssetsConfigModal = withAnalyticsContext(contextData)(function (props) {
|
|
389
|
-
return jsx(DatasourceExperienceIdProvider, null, jsx(UserInteractionsProvider, null, jsx(PlainAssetsConfigModal, props)));
|
|
392
|
+
return jsx(StoreContainer, null, jsx(DatasourceExperienceIdProvider, null, jsx(UserInteractionsProvider, null, jsx(PlainAssetsConfigModal, props))));
|
|
390
393
|
});
|
|
@@ -25,6 +25,7 @@ import { DatasourceExperienceIdProvider } from '../../../contexts/datasource-exp
|
|
|
25
25
|
import { UserInteractionsProvider, useUserInteractions } from '../../../contexts/user-interactions';
|
|
26
26
|
import i18nEN from '../../../i18n/en';
|
|
27
27
|
import { useAvailableSites } from '../../../services/useAvailableSites';
|
|
28
|
+
import { StoreContainer } from '../../../state';
|
|
28
29
|
import { AccessRequired } from '../../common/error-state/access-required';
|
|
29
30
|
import { ModalLoadingError } from '../../common/error-state/modal-loading-error';
|
|
30
31
|
import { NoInstancesView } from '../../common/error-state/no-instances';
|
|
@@ -348,7 +349,7 @@ var contextData = _objectSpread(_objectSpread({}, analyticsContextData), {}, {
|
|
|
348
349
|
});
|
|
349
350
|
export var ConfluenceSearchConfigModal = withAnalyticsContext(contextData)(function (props) {
|
|
350
351
|
var _props$viewMode;
|
|
351
|
-
return jsx(DatasourceExperienceIdProvider, null, jsx(UserInteractionsProvider, null, fg('platform-datasources-use-refactored-config-modal') ? jsx(DatasourceContextProvider, {
|
|
352
|
+
return jsx(StoreContainer, null, jsx(DatasourceExperienceIdProvider, null, jsx(UserInteractionsProvider, null, fg('platform-datasources-use-refactored-config-modal') ? jsx(DatasourceContextProvider, {
|
|
352
353
|
datasourceId: props.datasourceId,
|
|
353
354
|
initialVisibleColumnKeys: props.visibleColumnKeys,
|
|
354
355
|
initialColumnCustomSizes: props.columnCustomSizes,
|
|
@@ -360,5 +361,5 @@ export var ConfluenceSearchConfigModal = withAnalyticsContext(contextData)(funct
|
|
|
360
361
|
viewMode: (_props$viewMode = props.viewMode) !== null && _props$viewMode !== void 0 ? _props$viewMode : DEFAULT_VIEW_MODE
|
|
361
362
|
}, jsx(PlainConfluenceSearchConfigModal, props))) :
|
|
362
363
|
// TODO on cleanup 'use-refactored-config-modal' ff, delete `ModalOld.tsx` as well
|
|
363
|
-
jsx(PlainConfluenceSearchConfigModalOld, props)));
|
|
364
|
+
jsx(PlainConfluenceSearchConfigModalOld, props))));
|
|
364
365
|
});
|
|
@@ -8,7 +8,7 @@ import { useCallback, useEffect, useRef } from 'react';
|
|
|
8
8
|
import { css, jsx } from '@emotion/react';
|
|
9
9
|
import { withAnalyticsContext } from '@atlaskit/analytics-next';
|
|
10
10
|
import { IntlMessagesProvider } from '@atlaskit/intl-messages-provider';
|
|
11
|
-
import {
|
|
11
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
12
|
import { useDatasourceAnalyticsEvents } from '../../analytics';
|
|
13
13
|
import { componentMetadata } from '../../analytics/constants';
|
|
14
14
|
import { startUfoExperience } from '../../analytics/ufoExperiences';
|
|
@@ -18,6 +18,7 @@ import { fetchMessagesForLocale } from '../../common/utils/locale/fetch-messages
|
|
|
18
18
|
import { DatasourceExperienceIdProvider, useDatasourceExperienceId } from '../../contexts/datasource-experience-id';
|
|
19
19
|
import { useDatasourceTableState } from '../../hooks/useDatasourceTableState';
|
|
20
20
|
import i18nEN from '../../i18n/en';
|
|
21
|
+
import { StoreContainer } from '../../state';
|
|
21
22
|
import { ScrollableContainerHeight } from '../../ui/issue-like-table/styled';
|
|
22
23
|
import { ASSETS_LIST_OF_LINKS_DATASOURCE_ID } from '../assets-modal';
|
|
23
24
|
import { AccessRequired } from '../common/error-state/access-required';
|
|
@@ -113,7 +114,7 @@ var DatasourceTableViewWithoutAnalytics = function DatasourceTableViewWithoutAna
|
|
|
113
114
|
var forcedReset = useCallback(function () {
|
|
114
115
|
reset({
|
|
115
116
|
shouldForceRequest: true,
|
|
116
|
-
shouldResetColumns:
|
|
117
|
+
shouldResetColumns: fg('platform.linking-platform.datasource-assets_update_refresh_button_dt3qk') && datasourceId === ASSETS_LIST_OF_LINKS_DATASOURCE_ID
|
|
117
118
|
});
|
|
118
119
|
}, [reset, datasourceId]);
|
|
119
120
|
var onRefresh = useCallback(function () {
|
|
@@ -184,5 +185,5 @@ var DatasourceTableViewWithoutAnalytics = function DatasourceTableViewWithoutAna
|
|
|
184
185
|
})));
|
|
185
186
|
};
|
|
186
187
|
export var DatasourceTableView = withAnalyticsContext(componentMetadata.tableView)(function (props) {
|
|
187
|
-
return jsx(DatasourceExperienceIdProvider, null, jsx(DatasourceTableViewWithoutAnalytics, props));
|
|
188
|
+
return jsx(StoreContainer, null, jsx(DatasourceExperienceIdProvider, null, jsx(DatasourceTableViewWithoutAnalytics, props)));
|
|
188
189
|
});
|
|
@@ -33,6 +33,7 @@ import { UserInteractionsProvider, useUserInteractions } from '../../../contexts
|
|
|
33
33
|
import { useDatasourceTableState } from '../../../hooks/useDatasourceTableState';
|
|
34
34
|
import i18nEN from '../../../i18n/en';
|
|
35
35
|
import { useAvailableSites } from '../../../services/useAvailableSites';
|
|
36
|
+
import { StoreContainer } from '../../../state';
|
|
36
37
|
import { AccessRequired } from '../../common/error-state/access-required';
|
|
37
38
|
import { loadingErrorMessages } from '../../common/error-state/messages';
|
|
38
39
|
import { ModalLoadingError } from '../../common/error-state/modal-loading-error';
|
|
@@ -498,7 +499,7 @@ var contextData = _objectSpread(_objectSpread({}, analyticsContextData), {}, {
|
|
|
498
499
|
});
|
|
499
500
|
export var JiraIssuesConfigModal = withAnalyticsContext(contextData)(function (props) {
|
|
500
501
|
var _props$viewMode;
|
|
501
|
-
return jsx(DatasourceExperienceIdProvider, null, jsx(UserInteractionsProvider, null, fg('platform-datasources-use-refactored-config-modal') ? jsx(DatasourceViewModeProvider, {
|
|
502
|
+
return jsx(StoreContainer, null, jsx(DatasourceExperienceIdProvider, null, jsx(UserInteractionsProvider, null, fg('platform-datasources-use-refactored-config-modal') ? jsx(DatasourceViewModeProvider, {
|
|
502
503
|
viewMode: (_props$viewMode = props.viewMode) !== null && _props$viewMode !== void 0 ? _props$viewMode : DEFAULT_VIEW_MODE
|
|
503
|
-
}, jsx(PlainJiraIssuesConfigModal, props)) : jsx(PlainJiraIssuesConfigModalOld, props)));
|
|
504
|
+
}, jsx(PlainJiraIssuesConfigModal, props)) : jsx(PlainJiraIssuesConfigModalOld, props))));
|
|
504
505
|
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type Action } from 'react-sweet-state';
|
|
3
|
+
import { type DatasourceDataResponseItem } from '@atlaskit/linking-types';
|
|
4
|
+
export interface State {
|
|
5
|
+
items: Record<string, DatasourceDataResponseItem>;
|
|
6
|
+
}
|
|
7
|
+
export declare const actions: {
|
|
8
|
+
onAddItems: (items: DatasourceDataResponseItem[]) => Action<State, void, string[]>;
|
|
9
|
+
};
|
|
10
|
+
export declare const Store: import("react-sweet-state").Store<State, {
|
|
11
|
+
onAddItems: (items: DatasourceDataResponseItem[]) => Action<State, void, string[]>;
|
|
12
|
+
}>;
|
|
13
|
+
export declare const useDatasourceItem: import("react-sweet-state").HookStateFunction<DatasourceDataResponseItem | undefined, {
|
|
14
|
+
id: string;
|
|
15
|
+
}>;
|
|
16
|
+
export declare const useDatasourceActions: import("react-sweet-state").HookActionsFunction<import("react-sweet-state").BoundActions<State, {
|
|
17
|
+
onAddItems: (items: DatasourceDataResponseItem[]) => Action<State, void, string[]>;
|
|
18
|
+
}>>;
|
|
19
|
+
export declare const StoreContainer: ({ children }: {
|
|
20
|
+
children: JSX.Element;
|
|
21
|
+
}) => JSX.Element;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { PopupComponentProps } from '@atlaskit/popup';
|
|
3
|
-
export declare const PopupComponent: React.ForwardRefExoticComponent<Pick<PopupComponentProps, "
|
|
3
|
+
export declare const PopupComponent: React.ForwardRefExoticComponent<Pick<PopupComponentProps, "id" | "children" | "style" | "data-testid" | "tabIndex" | "role" | "shouldFitContainer" | "shouldRenderToParent" | "data-placement"> & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type Action } from 'react-sweet-state';
|
|
3
|
+
import { type DatasourceDataResponseItem } from '@atlaskit/linking-types';
|
|
4
|
+
export interface State {
|
|
5
|
+
items: Record<string, DatasourceDataResponseItem>;
|
|
6
|
+
}
|
|
7
|
+
export declare const actions: {
|
|
8
|
+
onAddItems: (items: DatasourceDataResponseItem[]) => Action<State, void, string[]>;
|
|
9
|
+
};
|
|
10
|
+
export declare const Store: import("react-sweet-state").Store<State, {
|
|
11
|
+
onAddItems: (items: DatasourceDataResponseItem[]) => Action<State, void, string[]>;
|
|
12
|
+
}>;
|
|
13
|
+
export declare const useDatasourceItem: import("react-sweet-state").HookStateFunction<DatasourceDataResponseItem | undefined, {
|
|
14
|
+
id: string;
|
|
15
|
+
}>;
|
|
16
|
+
export declare const useDatasourceActions: import("react-sweet-state").HookActionsFunction<import("react-sweet-state").BoundActions<State, {
|
|
17
|
+
onAddItems: (items: DatasourceDataResponseItem[]) => Action<State, void, string[]>;
|
|
18
|
+
}>>;
|
|
19
|
+
export declare const StoreContainer: ({ children }: {
|
|
20
|
+
children: JSX.Element;
|
|
21
|
+
}) => JSX.Element;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { PopupComponentProps } from '@atlaskit/popup';
|
|
3
|
-
export declare const PopupComponent: React.ForwardRefExoticComponent<Pick<PopupComponentProps, "
|
|
3
|
+
export declare const PopupComponent: React.ForwardRefExoticComponent<Pick<PopupComponentProps, "id" | "children" | "style" | "data-testid" | "tabIndex" | "role" | "shouldFitContainer" | "shouldRenderToParent" | "data-placement"> & React.RefAttributes<HTMLDivElement>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/link-datasource",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"description": "UI Components to support linking platform dataset feature",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -85,6 +85,7 @@
|
|
|
85
85
|
"debounce-promise": "^3.1.2",
|
|
86
86
|
"lodash": "^4.17.21",
|
|
87
87
|
"react-dom": "^16.8.0",
|
|
88
|
+
"react-sweet-state": "^2.6.5",
|
|
88
89
|
"tiny-invariant": "^1.2.0",
|
|
89
90
|
"use-debounce": "^3.4.0",
|
|
90
91
|
"uuid": "^3.1.0"
|
|
@@ -151,6 +152,9 @@
|
|
|
151
152
|
"./elements": "./src/elements.ts"
|
|
152
153
|
},
|
|
153
154
|
"platform-feature-flags": {
|
|
155
|
+
"enable_datasource_react_sweet_state": {
|
|
156
|
+
"type": "boolean"
|
|
157
|
+
},
|
|
154
158
|
"platform.linking-platform.datasource.add-timezone-header": {
|
|
155
159
|
"type": "boolean",
|
|
156
160
|
"referenceOnly": "true"
|