@atlaskit/link-datasource 1.23.6 → 1.23.8

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/link-datasource
2
2
 
3
+ ## 1.23.8
4
+
5
+ ### Patch Changes
6
+
7
+ - [#80679](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/80679) [`104eb9443b7e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/104eb9443b7e) - ED-22553 Updating adf-schema version to 35.6.0
8
+
9
+ ## 1.23.7
10
+
11
+ ### Patch Changes
12
+
13
+ - [#79004](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/79004) [`5438920b88ce`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5438920b88ce) - Fixes race conditions/concurrent requests when parameters changing on datasource, behind ff `platform.linking-platform.datasource.enable-abort-controller`.
14
+
3
15
  ## 1.23.6
4
16
 
5
17
  ### Patch Changes
@@ -1,5 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
1
+ "use strict";
@@ -1,5 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
1
+ "use strict";
@@ -1,5 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
1
+ "use strict";
@@ -12,6 +12,7 @@ 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");
16
17
  var _useErrorLogger2 = _interopRequireDefault(require("./useErrorLogger"));
17
18
  var useDatasourceTableState = exports.useDatasourceTableState = function useDatasourceTableState(_ref) {
@@ -88,6 +89,7 @@ var useDatasourceTableState = exports.useDatasourceTableState = function useData
88
89
  _useState30 = (0, _slicedToArray2.default)(_useState29, 2),
89
90
  providerName = _useState30[0],
90
91
  setProviderName = _useState30[1];
92
+ var abortController = (0, _react.useRef)(new AbortController());
91
93
  var _useDatasourceClientE = (0, _linkClientExtension.useDatasourceClientExtension)(),
92
94
  getDatasourceData = _useDatasourceClientE.getDatasourceData,
93
95
  getDatasourceDetails = _useDatasourceClientE.getDatasourceDetails;
@@ -170,7 +172,7 @@ var useDatasourceTableState = exports.useDatasourceTableState = function useData
170
172
 
171
173
  /*Jira adds identifier fields like id and key to all data responses
172
174
  Since defaultProperties already send back the keyField, we are accounting only
173
- for the idField when we are using defaulProperties
175
+ for the idField when we are using defaultProperties
174
176
  */
175
177
  if (properties.length > fieldKeys.length + idFieldCount + keyFieldCount && properties.length > defaultProperties.length + idFieldCount) {
176
178
  setFullSchema(schema);
@@ -193,6 +195,7 @@ var useDatasourceTableState = exports.useDatasourceTableState = function useData
193
195
  }, [columns, defaultVisibleColumnKeys, lastRequestedFieldKeys]);
194
196
  var onNextPage = (0, _react.useCallback)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
195
197
  var requestInfo,
198
+ currentAbortController,
196
199
  _requestInfo$isSchema,
197
200
  isSchemaFromData,
198
201
  shouldRequestFirstPage,
@@ -212,6 +215,7 @@ var useDatasourceTableState = exports.useDatasourceTableState = function useData
212
215
  nextPageCursor,
213
216
  _totalCount,
214
217
  schema,
218
+ _currentAbortControll,
215
219
  isUserLoadingNextPage,
216
220
  currentLoadedItemCount,
217
221
  newlyLoadedItemCount,
@@ -220,12 +224,23 @@ var useDatasourceTableState = exports.useDatasourceTableState = function useData
220
224
  while (1) switch (_context2.prev = _context2.next) {
221
225
  case 0:
222
226
  requestInfo = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
227
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.datasource.enable-abort-controller')) {
228
+ /**
229
+ * Abort whichever request was made before this one.
230
+ */
231
+ abortController.current.abort();
232
+ /**
233
+ * Setup new abort controller for this request.
234
+ */
235
+ abortController.current = new AbortController();
236
+ currentAbortController = abortController.current;
237
+ }
223
238
  if (parameters) {
224
- _context2.next = 3;
239
+ _context2.next = 4;
225
240
  break;
226
241
  }
227
242
  return _context2.abrupt("return");
228
- case 3:
243
+ case 4:
229
244
  _requestInfo$isSchema = requestInfo.isSchemaFromData, isSchemaFromData = _requestInfo$isSchema === void 0 ? true : _requestInfo$isSchema, shouldRequestFirstPage = requestInfo.shouldRequestFirstPage, _requestInfo$shouldFo = requestInfo.shouldForceRequest, shouldForceRequest = _requestInfo$shouldFo === void 0 ? false : _requestInfo$shouldFo;
230
245
  isFullSchemaLoaded = fullSchema.properties.length > 0;
231
246
  datasourceDataRequest = {
@@ -236,10 +251,10 @@ var useDatasourceTableState = exports.useDatasourceTableState = function useData
236
251
  includeSchema: isFullSchemaLoaded ? false : isSchemaFromData
237
252
  };
238
253
  setStatus('loading');
239
- _context2.prev = 7;
240
- _context2.next = 10;
254
+ _context2.prev = 8;
255
+ _context2.next = 11;
241
256
  return getDatasourceData(datasourceId, datasourceDataRequest, shouldForceRequest);
242
- case 10:
257
+ case 11:
243
258
  _yield$getDatasourceD3 = _context2.sent;
244
259
  _yield$getDatasourceD4 = _yield$getDatasourceD3.meta;
245
260
  access = _yield$getDatasourceD4.access;
@@ -252,25 +267,38 @@ var useDatasourceTableState = exports.useDatasourceTableState = function useData
252
267
  nextPageCursor = _yield$getDatasourceD5.nextPageCursor;
253
268
  _totalCount = _yield$getDatasourceD5.totalCount;
254
269
  schema = _yield$getDatasourceD5.schema;
270
+ if (!(0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.datasource.enable-abort-controller')) {
271
+ _context2.next = 26;
272
+ break;
273
+ }
274
+ if (!((_currentAbortControll = currentAbortController) !== null && _currentAbortControll !== void 0 && _currentAbortControll.signal.aborted)) {
275
+ _context2.next = 26;
276
+ break;
277
+ }
278
+ throw new Error('Aborted');
279
+ case 26:
255
280
  setExtensionKey(_extensionKey);
256
281
  setProviderName(_providerName);
257
282
  if (!(access === 'unauthorized' || access === 'forbidden')) {
258
- _context2.next = 28;
283
+ _context2.next = 32;
259
284
  break;
260
285
  }
261
286
  setStatus(access);
262
287
  setAuthDetails(auth || initialEmptyArray);
263
288
  return _context2.abrupt("return");
264
- case 28:
289
+ case 32:
265
290
  setDestinationObjectTypes(_destinationObjectTypes);
266
291
  setTotalCount(_totalCount);
267
292
  setNextCursor(nextPageCursor);
268
293
  setResponseItems(function (currentResponseItems) {
269
- // FIXME EDM-8977 (https://product-fabric.atlassian.net/browse/EDM-8977)
270
- // once the onNextPage and reset loop issue has been thoroughly investigated
271
- // in the above card, remove this isEqual check, ensure onNextPage isn't called twice
272
- var hasIdenticalResponseItems = (0, _isEqual.default)(currentResponseItems, items);
273
- if (hasIdenticalResponseItems || shouldRequestFirstPage) {
294
+ if (!(0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.datasource.enable-abort-controller')) {
295
+ var hasIdenticalResponseItems = (0, _isEqual.default)(currentResponseItems, items);
296
+ if (hasIdenticalResponseItems || shouldRequestFirstPage) {
297
+ return items;
298
+ }
299
+ return [].concat((0, _toConsumableArray2.default)(currentResponseItems), (0, _toConsumableArray2.default)(items));
300
+ }
301
+ if (shouldRequestFirstPage) {
274
302
  return items;
275
303
  }
276
304
  return [].concat((0, _toConsumableArray2.default)(currentResponseItems), (0, _toConsumableArray2.default)(items));
@@ -293,32 +321,42 @@ var useDatasourceTableState = exports.useDatasourceTableState = function useData
293
321
  });
294
322
  }
295
323
  setStatus('resolved');
296
- _context2.next = 50;
324
+ _context2.next = 57;
297
325
  break;
298
- case 40:
299
- _context2.prev = 40;
300
- _context2.t0 = _context2["catch"](7);
326
+ case 44:
327
+ _context2.prev = 44;
328
+ _context2.t0 = _context2["catch"](8);
329
+ if (!(0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.datasource.enable-abort-controller')) {
330
+ _context2.next = 49;
331
+ break;
332
+ }
333
+ if (!(_context2.t0.message === 'Aborted')) {
334
+ _context2.next = 49;
335
+ break;
336
+ }
337
+ return _context2.abrupt("return");
338
+ case 49:
301
339
  captureError('onNextPage', _context2.t0);
302
340
  if (!(_context2.t0 instanceof Response && _context2.t0.status === 401)) {
303
- _context2.next = 46;
341
+ _context2.next = 53;
304
342
  break;
305
343
  }
306
344
  setStatus('unauthorized');
307
345
  return _context2.abrupt("return");
308
- case 46:
346
+ case 53:
309
347
  if (!(_context2.t0 instanceof Response && _context2.t0.status === 403)) {
310
- _context2.next = 49;
348
+ _context2.next = 56;
311
349
  break;
312
350
  }
313
351
  setStatus('forbidden');
314
352
  return _context2.abrupt("return");
315
- case 49:
353
+ case 56:
316
354
  setStatus('rejected');
317
- case 50:
355
+ case 57:
318
356
  case "end":
319
357
  return _context2.stop();
320
358
  }
321
- }, _callee2, null, [[7, 40]]);
359
+ }, _callee2, null, [[8, 44]]);
322
360
  })), [captureError, parameters, fieldKeys, nextCursor, getDatasourceData, datasourceId, responseItems, applySchemaProperties, fireEvent, fullSchema, initialEmptyArray]);
323
361
  var reset = (0, _react.useCallback)(function (options) {
324
362
  setResponseItems(initialEmptyArray);
@@ -349,7 +387,7 @@ var useDatasourceTableState = exports.useDatasourceTableState = function useData
349
387
  });
350
388
  setShouldForceRequest(false);
351
389
  }
352
- }, [lastRequestedFieldKeys, loadDatasourceDetails, onNextPage, parameters, shouldForceRequest, status]);
390
+ }, [lastRequestedFieldKeys, onNextPage, parameters, shouldForceRequest, status]);
353
391
 
354
392
  // this takes care of requesting /data when user selects/unselects a column
355
393
  (0, _react.useEffect)(function () {
@@ -378,6 +416,13 @@ var useDatasourceTableState = exports.useDatasourceTableState = function useData
378
416
  }
379
417
  }
380
418
  }, [fieldKeys, lastRequestedFieldKeys, responseItems, reset, onNextPage]);
419
+ (0, _react.useEffect)(function () {
420
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.datasource.enable-abort-controller')) {
421
+ return function () {
422
+ return abortController.current.abort();
423
+ };
424
+ }
425
+ }, []);
381
426
  return {
382
427
  status: status,
383
428
  onNextPage: onNextPage,
@@ -1,5 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
1
+ "use strict";
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,6 +1,7 @@
1
- import { useCallback, useEffect, useState } from 'react';
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 { getBooleanFF } from '@atlaskit/platform-feature-flags';
4
5
  import { useDatasourceAnalyticsEvents } from '../analytics';
5
6
  import useErrorLogger from './useErrorLogger';
6
7
  export const useDatasourceTableState = ({
@@ -35,6 +36,7 @@ export const useDatasourceTableState = ({
35
36
  const [destinationObjectTypes, setDestinationObjectTypes] = useState([]);
36
37
  const [extensionKey, setExtensionKey] = useState();
37
38
  const [providerName, setProviderName] = useState(undefined);
39
+ const abortController = useRef(new AbortController());
38
40
  const {
39
41
  getDatasourceData,
40
42
  getDatasourceDetails
@@ -92,7 +94,7 @@ export const useDatasourceTableState = ({
92
94
 
93
95
  /*Jira adds identifier fields like id and key to all data responses
94
96
  Since defaultProperties already send back the keyField, we are accounting only
95
- for the idField when we are using defaulProperties
97
+ for the idField when we are using defaultProperties
96
98
  */
97
99
  if (properties.length > fieldKeys.length + idFieldCount + keyFieldCount && properties.length > defaultProperties.length + idFieldCount) {
98
100
  setFullSchema(schema);
@@ -112,6 +114,18 @@ export const useDatasourceTableState = ({
112
114
  }
113
115
  }, [columns, defaultVisibleColumnKeys, lastRequestedFieldKeys]);
114
116
  const onNextPage = useCallback(async (requestInfo = {}) => {
117
+ let currentAbortController;
118
+ if (getBooleanFF('platform.linking-platform.datasource.enable-abort-controller')) {
119
+ /**
120
+ * Abort whichever request was made before this one.
121
+ */
122
+ abortController.current.abort();
123
+ /**
124
+ * Setup new abort controller for this request.
125
+ */
126
+ abortController.current = new AbortController();
127
+ currentAbortController = abortController.current;
128
+ }
115
129
  if (!parameters) {
116
130
  return;
117
131
  }
@@ -145,6 +159,15 @@ export const useDatasourceTableState = ({
145
159
  schema
146
160
  }
147
161
  } = await getDatasourceData(datasourceId, datasourceDataRequest, shouldForceRequest);
162
+ if (getBooleanFF('platform.linking-platform.datasource.enable-abort-controller')) {
163
+ var _currentAbortControll;
164
+ /**
165
+ * Let the response finish and store in cache, but throw error if signal is aborted
166
+ */
167
+ if ((_currentAbortControll = currentAbortController) !== null && _currentAbortControll !== void 0 && _currentAbortControll.signal.aborted) {
168
+ throw new Error('Aborted');
169
+ }
170
+ }
148
171
  setExtensionKey(extensionKey);
149
172
  setProviderName(providerName);
150
173
  if (access === 'unauthorized' || access === 'forbidden') {
@@ -156,11 +179,14 @@ export const useDatasourceTableState = ({
156
179
  setTotalCount(totalCount);
157
180
  setNextCursor(nextPageCursor);
158
181
  setResponseItems(currentResponseItems => {
159
- // FIXME EDM-8977 (https://product-fabric.atlassian.net/browse/EDM-8977)
160
- // once the onNextPage and reset loop issue has been thoroughly investigated
161
- // in the above card, remove this isEqual check, ensure onNextPage isn't called twice
162
- const hasIdenticalResponseItems = isEqual(currentResponseItems, items);
163
- if (hasIdenticalResponseItems || shouldRequestFirstPage) {
182
+ if (!getBooleanFF('platform.linking-platform.datasource.enable-abort-controller')) {
183
+ const hasIdenticalResponseItems = isEqual(currentResponseItems, items);
184
+ if (hasIdenticalResponseItems || shouldRequestFirstPage) {
185
+ return items;
186
+ }
187
+ return [...currentResponseItems, ...items];
188
+ }
189
+ if (shouldRequestFirstPage) {
164
190
  return items;
165
191
  }
166
192
  return [...currentResponseItems, ...items];
@@ -184,6 +210,17 @@ export const useDatasourceTableState = ({
184
210
  }
185
211
  setStatus('resolved');
186
212
  } catch (e) {
213
+ if (getBooleanFF('platform.linking-platform.datasource.enable-abort-controller')) {
214
+ if (e.message === 'Aborted') {
215
+ /**
216
+ * If the request was aborted, we don't want to change the status of the table
217
+ * as we are already loading the next request attempt
218
+ *
219
+ * Is not an exceptional state, do not need to captureError
220
+ */
221
+ return;
222
+ }
223
+ }
187
224
  captureError('onNextPage', e);
188
225
  if (e instanceof Response && e.status === 401) {
189
226
  setStatus('unauthorized');
@@ -225,7 +262,7 @@ export const useDatasourceTableState = ({
225
262
  });
226
263
  setShouldForceRequest(false);
227
264
  }
228
- }, [lastRequestedFieldKeys, loadDatasourceDetails, onNextPage, parameters, shouldForceRequest, status]);
265
+ }, [lastRequestedFieldKeys, onNextPage, parameters, shouldForceRequest, status]);
229
266
 
230
267
  // this takes care of requesting /data when user selects/unselects a column
231
268
  useEffect(() => {
@@ -250,6 +287,11 @@ export const useDatasourceTableState = ({
250
287
  }
251
288
  }
252
289
  }, [fieldKeys, lastRequestedFieldKeys, responseItems, reset, onNextPage]);
290
+ useEffect(() => {
291
+ if (getBooleanFF('platform.linking-platform.datasource.enable-abort-controller')) {
292
+ return () => abortController.current.abort();
293
+ }
294
+ }, []);
253
295
  return {
254
296
  status,
255
297
  onNextPage,
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -2,9 +2,10 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import _regeneratorRuntime from "@babel/runtime/regenerator";
5
- import { useCallback, useEffect, useState } from 'react';
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 { getBooleanFF } from '@atlaskit/platform-feature-flags';
8
9
  import { useDatasourceAnalyticsEvents } from '../analytics';
9
10
  import useErrorLogger from './useErrorLogger';
10
11
  export var useDatasourceTableState = function useDatasourceTableState(_ref) {
@@ -81,6 +82,7 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
81
82
  _useState30 = _slicedToArray(_useState29, 2),
82
83
  providerName = _useState30[0],
83
84
  setProviderName = _useState30[1];
85
+ var abortController = useRef(new AbortController());
84
86
  var _useDatasourceClientE = useDatasourceClientExtension(),
85
87
  getDatasourceData = _useDatasourceClientE.getDatasourceData,
86
88
  getDatasourceDetails = _useDatasourceClientE.getDatasourceDetails;
@@ -163,7 +165,7 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
163
165
 
164
166
  /*Jira adds identifier fields like id and key to all data responses
165
167
  Since defaultProperties already send back the keyField, we are accounting only
166
- for the idField when we are using defaulProperties
168
+ for the idField when we are using defaultProperties
167
169
  */
168
170
  if (properties.length > fieldKeys.length + idFieldCount + keyFieldCount && properties.length > defaultProperties.length + idFieldCount) {
169
171
  setFullSchema(schema);
@@ -186,6 +188,7 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
186
188
  }, [columns, defaultVisibleColumnKeys, lastRequestedFieldKeys]);
187
189
  var onNextPage = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
188
190
  var requestInfo,
191
+ currentAbortController,
189
192
  _requestInfo$isSchema,
190
193
  isSchemaFromData,
191
194
  shouldRequestFirstPage,
@@ -205,6 +208,7 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
205
208
  nextPageCursor,
206
209
  _totalCount,
207
210
  schema,
211
+ _currentAbortControll,
208
212
  isUserLoadingNextPage,
209
213
  currentLoadedItemCount,
210
214
  newlyLoadedItemCount,
@@ -213,12 +217,23 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
213
217
  while (1) switch (_context2.prev = _context2.next) {
214
218
  case 0:
215
219
  requestInfo = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
220
+ if (getBooleanFF('platform.linking-platform.datasource.enable-abort-controller')) {
221
+ /**
222
+ * Abort whichever request was made before this one.
223
+ */
224
+ abortController.current.abort();
225
+ /**
226
+ * Setup new abort controller for this request.
227
+ */
228
+ abortController.current = new AbortController();
229
+ currentAbortController = abortController.current;
230
+ }
216
231
  if (parameters) {
217
- _context2.next = 3;
232
+ _context2.next = 4;
218
233
  break;
219
234
  }
220
235
  return _context2.abrupt("return");
221
- case 3:
236
+ case 4:
222
237
  _requestInfo$isSchema = requestInfo.isSchemaFromData, isSchemaFromData = _requestInfo$isSchema === void 0 ? true : _requestInfo$isSchema, shouldRequestFirstPage = requestInfo.shouldRequestFirstPage, _requestInfo$shouldFo = requestInfo.shouldForceRequest, shouldForceRequest = _requestInfo$shouldFo === void 0 ? false : _requestInfo$shouldFo;
223
238
  isFullSchemaLoaded = fullSchema.properties.length > 0;
224
239
  datasourceDataRequest = {
@@ -229,10 +244,10 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
229
244
  includeSchema: isFullSchemaLoaded ? false : isSchemaFromData
230
245
  };
231
246
  setStatus('loading');
232
- _context2.prev = 7;
233
- _context2.next = 10;
247
+ _context2.prev = 8;
248
+ _context2.next = 11;
234
249
  return getDatasourceData(datasourceId, datasourceDataRequest, shouldForceRequest);
235
- case 10:
250
+ case 11:
236
251
  _yield$getDatasourceD3 = _context2.sent;
237
252
  _yield$getDatasourceD4 = _yield$getDatasourceD3.meta;
238
253
  access = _yield$getDatasourceD4.access;
@@ -245,25 +260,38 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
245
260
  nextPageCursor = _yield$getDatasourceD5.nextPageCursor;
246
261
  _totalCount = _yield$getDatasourceD5.totalCount;
247
262
  schema = _yield$getDatasourceD5.schema;
263
+ if (!getBooleanFF('platform.linking-platform.datasource.enable-abort-controller')) {
264
+ _context2.next = 26;
265
+ break;
266
+ }
267
+ if (!((_currentAbortControll = currentAbortController) !== null && _currentAbortControll !== void 0 && _currentAbortControll.signal.aborted)) {
268
+ _context2.next = 26;
269
+ break;
270
+ }
271
+ throw new Error('Aborted');
272
+ case 26:
248
273
  setExtensionKey(_extensionKey);
249
274
  setProviderName(_providerName);
250
275
  if (!(access === 'unauthorized' || access === 'forbidden')) {
251
- _context2.next = 28;
276
+ _context2.next = 32;
252
277
  break;
253
278
  }
254
279
  setStatus(access);
255
280
  setAuthDetails(auth || initialEmptyArray);
256
281
  return _context2.abrupt("return");
257
- case 28:
282
+ case 32:
258
283
  setDestinationObjectTypes(_destinationObjectTypes);
259
284
  setTotalCount(_totalCount);
260
285
  setNextCursor(nextPageCursor);
261
286
  setResponseItems(function (currentResponseItems) {
262
- // FIXME EDM-8977 (https://product-fabric.atlassian.net/browse/EDM-8977)
263
- // once the onNextPage and reset loop issue has been thoroughly investigated
264
- // in the above card, remove this isEqual check, ensure onNextPage isn't called twice
265
- var hasIdenticalResponseItems = isEqual(currentResponseItems, items);
266
- if (hasIdenticalResponseItems || shouldRequestFirstPage) {
287
+ if (!getBooleanFF('platform.linking-platform.datasource.enable-abort-controller')) {
288
+ var hasIdenticalResponseItems = isEqual(currentResponseItems, items);
289
+ if (hasIdenticalResponseItems || shouldRequestFirstPage) {
290
+ return items;
291
+ }
292
+ return [].concat(_toConsumableArray(currentResponseItems), _toConsumableArray(items));
293
+ }
294
+ if (shouldRequestFirstPage) {
267
295
  return items;
268
296
  }
269
297
  return [].concat(_toConsumableArray(currentResponseItems), _toConsumableArray(items));
@@ -286,32 +314,42 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
286
314
  });
287
315
  }
288
316
  setStatus('resolved');
289
- _context2.next = 50;
317
+ _context2.next = 57;
290
318
  break;
291
- case 40:
292
- _context2.prev = 40;
293
- _context2.t0 = _context2["catch"](7);
319
+ case 44:
320
+ _context2.prev = 44;
321
+ _context2.t0 = _context2["catch"](8);
322
+ if (!getBooleanFF('platform.linking-platform.datasource.enable-abort-controller')) {
323
+ _context2.next = 49;
324
+ break;
325
+ }
326
+ if (!(_context2.t0.message === 'Aborted')) {
327
+ _context2.next = 49;
328
+ break;
329
+ }
330
+ return _context2.abrupt("return");
331
+ case 49:
294
332
  captureError('onNextPage', _context2.t0);
295
333
  if (!(_context2.t0 instanceof Response && _context2.t0.status === 401)) {
296
- _context2.next = 46;
334
+ _context2.next = 53;
297
335
  break;
298
336
  }
299
337
  setStatus('unauthorized');
300
338
  return _context2.abrupt("return");
301
- case 46:
339
+ case 53:
302
340
  if (!(_context2.t0 instanceof Response && _context2.t0.status === 403)) {
303
- _context2.next = 49;
341
+ _context2.next = 56;
304
342
  break;
305
343
  }
306
344
  setStatus('forbidden');
307
345
  return _context2.abrupt("return");
308
- case 49:
346
+ case 56:
309
347
  setStatus('rejected');
310
- case 50:
348
+ case 57:
311
349
  case "end":
312
350
  return _context2.stop();
313
351
  }
314
- }, _callee2, null, [[7, 40]]);
352
+ }, _callee2, null, [[8, 44]]);
315
353
  })), [captureError, parameters, fieldKeys, nextCursor, getDatasourceData, datasourceId, responseItems, applySchemaProperties, fireEvent, fullSchema, initialEmptyArray]);
316
354
  var reset = useCallback(function (options) {
317
355
  setResponseItems(initialEmptyArray);
@@ -342,7 +380,7 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
342
380
  });
343
381
  setShouldForceRequest(false);
344
382
  }
345
- }, [lastRequestedFieldKeys, loadDatasourceDetails, onNextPage, parameters, shouldForceRequest, status]);
383
+ }, [lastRequestedFieldKeys, onNextPage, parameters, shouldForceRequest, status]);
346
384
 
347
385
  // this takes care of requesting /data when user selects/unselects a column
348
386
  useEffect(function () {
@@ -371,6 +409,13 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
371
409
  }
372
410
  }
373
411
  }, [fieldKeys, lastRequestedFieldKeys, responseItems, reset, onNextPage]);
412
+ useEffect(function () {
413
+ if (getBooleanFF('platform.linking-platform.datasource.enable-abort-controller')) {
414
+ return function () {
415
+ return abortController.current.abort();
416
+ };
417
+ }
418
+ }, []);
374
419
  return {
375
420
  status: status,
376
421
  onNextPage: onNextPage,
@@ -1 +0,0 @@
1
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/link-datasource",
3
- "version": "1.23.6",
3
+ "version": "1.23.8",
4
4
  "description": "UI Components to support linking platform dataset feature",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -31,7 +31,7 @@
31
31
  "analytics:codegen": "yarn workspace @atlassian/analytics-tooling run analytics:codegen link-datasource --output ./src/analytics/generated"
32
32
  },
33
33
  "dependencies": {
34
- "@atlaskit/adf-schema": "^35.5.2",
34
+ "@atlaskit/adf-schema": "^35.6.0",
35
35
  "@atlaskit/analytics-next": "^9.2.0",
36
36
  "@atlaskit/avatar": "^21.5.0",
37
37
  "@atlaskit/avatar-group": "^9.5.0",
@@ -41,7 +41,7 @@
41
41
  "@atlaskit/editor-prosemirror": "3.0.0",
42
42
  "@atlaskit/empty-state": "^7.7.0",
43
43
  "@atlaskit/form": "^9.0.3",
44
- "@atlaskit/heading": "^1.7.0",
44
+ "@atlaskit/heading": "^1.8.0",
45
45
  "@atlaskit/icon": "^22.1.0",
46
46
  "@atlaskit/icon-object": "^6.3.0",
47
47
  "@atlaskit/image": "^1.1.0",
@@ -60,7 +60,7 @@
60
60
  "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.0",
61
61
  "@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-autoscroll": "^1.0.0",
62
62
  "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^1.0.0",
63
- "@atlaskit/primitives": "^4.0.0",
63
+ "@atlaskit/primitives": "^4.1.0",
64
64
  "@atlaskit/select": "^17.3.0",
65
65
  "@atlaskit/smart-card": "^26.49.0",
66
66
  "@atlaskit/spinner": "^16.0.0",
@@ -146,6 +146,9 @@
146
146
  },
147
147
  "platform.linking-platform.datasources.enable-sentry-client": {
148
148
  "type": "boolean"
149
+ },
150
+ "platform.linking-platform.datasource.enable-abort-controller": {
151
+ "type": "boolean"
149
152
  }
150
153
  }
151
154
  }