@atlaskit/link-datasource 3.22.1 → 3.22.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @atlaskit/link-datasource
2
2
 
3
+ ## 3.22.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#122399](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/122399)
8
+ [`cbaab3690564b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/cbaab3690564b) -
9
+ Behind FF: `enable_datasource_fetch_action_inputs` introduce logic to find fetchAction inputs from
10
+ the fetchSchema and its value from datasource item data
11
+ - Updated dependencies
12
+
3
13
  ## 3.22.1
4
14
 
5
15
  ### Patch Changes
@@ -15,6 +15,7 @@ var _linkClientExtension = require("@atlaskit/link-client-extension");
15
15
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
16
16
  var _analytics = require("../../analytics");
17
17
  var _useErrorLogger2 = _interopRequireDefault(require("../../hooks/useErrorLogger"));
18
+ var _index = require("../index");
18
19
  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; }
19
20
  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; }
20
21
  /**
@@ -203,6 +204,11 @@ var useExecuteAtomicAction = exports.useExecuteAtomicAction = function useExecut
203
204
  _useAtomicUpdateActio3 = _useAtomicUpdateActio2[0],
204
205
  schema = _useAtomicUpdateActio3.schema,
205
206
  fetchSchema = _useAtomicUpdateActio3.fetchSchema;
207
+ var item = (0, _platformFeatureFlags.fg)('enable_datasource_fetch_action_inputs') ?
208
+ // eslint-disable-next-line react-hooks/rules-of-hooks
209
+ (0, _index.useDatasourceItem)({
210
+ id: ari
211
+ }) : undefined;
206
212
  var _useDatasourceClientE2 = (0, _linkClientExtension.useDatasourceClientExtension)(),
207
213
  executeAction = _useDatasourceClientE2.executeAtomicAction,
208
214
  invalidateDatasourceDataCacheByAri = _useDatasourceClientE2.invalidateDatasourceDataCacheByAri;
@@ -242,11 +248,37 @@ var useExecuteAtomicAction = exports.useExecuteAtomicAction = function useExecut
242
248
  throw error;
243
249
  });
244
250
  }, [schema, executeAction, integrationKey, fieldKey, ari, invalidateDatasourceDataCacheByAri, fireEvent, captureError]);
245
- var executeFetch = (0, _react.useCallback)(function (inputs) {
251
+ var executeFetch = (0, _react.useCallback)(function (controlledInputs) {
246
252
  if (!fetchSchema) {
247
253
  throw new Error('No supporting action schema found.');
248
254
  }
249
255
 
256
+ /**
257
+ * controlled inputs are useful for search fields, where a variable query is passed to the fetchAction
258
+ */
259
+ var inputs = controlledInputs;
260
+ /**
261
+ * When FF is on and `controlledInputs` are not provided we look for required inputs in the fetchSchema
262
+ */
263
+ if (!Object.keys(inputs).length && fetchSchema.inputs && !!Object.keys(fetchSchema.inputs).length && (0, _platformFeatureFlags.fg)('enable_datasource_fetch_action_inputs')) {
264
+ var inputKeys = Object.keys(fetchSchema.inputs);
265
+ /**
266
+ * If present return the input value from the datasource item
267
+ * e.g. this could be the issueKey or projectId of a Jira issue
268
+ */
269
+ inputs = inputKeys.reduce(function (acc, key) {
270
+ var _item$data;
271
+ var value = item === null || item === void 0 || (_item$data = item.data) === null || _item$data === void 0 || (_item$data = _item$data[key]) === null || _item$data === void 0 ? void 0 : _item$data.data;
272
+ if (typeof value === 'string' || typeof value === 'number') {
273
+ acc[key] = value;
274
+ }
275
+ /**
276
+ * This allows for the schema and data from the BE to dynamically set the action inputs
277
+ */
278
+ return acc;
279
+ }, {});
280
+ }
281
+
250
282
  // A generic type can allow us here to define the inputs and outputs
251
283
  return executeAction({
252
284
  integrationKey: integrationKey,
@@ -268,7 +300,7 @@ var useExecuteAtomicAction = exports.useExecuteAtomicAction = function useExecut
268
300
  // Rethrow up to component for flags and other handling
269
301
  throw error;
270
302
  });
271
- }, [fetchSchema, executeAction, integrationKey, ari, fireEvent, captureError]);
303
+ }, [fetchSchema, executeAction, integrationKey, ari, item, fireEvent, captureError]);
272
304
  return _objectSpread(_objectSpread({}, schema && {
273
305
  execute: execute
274
306
  }), fetchSchema && {
@@ -55,7 +55,7 @@ var IconEditType = function IconEditType(props) {
55
55
  autoFocus: true,
56
56
  blurInputOnSelect: true,
57
57
  defaultMenuIsOpen: true
58
- // We can't update the status if we don't have an ID - however the ID
58
+ // We can't update this field if we don't have an ID - however the ID
59
59
  // is typed optional.
60
60
  ,
61
61
  options: (0, _platformFeatureFlags.fg)('platform-datasources-inline-edit-id-checks') ? options.filter(function (option) {
@@ -4,6 +4,7 @@ import { useDatasourceClientExtension } from '@atlaskit/link-client-extension';
4
4
  import { fg } from '@atlaskit/platform-feature-flags';
5
5
  import { useDatasourceAnalyticsEvents } from '../../analytics';
6
6
  import useErrorLogger from '../../hooks/useErrorLogger';
7
+ import { useDatasourceItem } from '../index';
7
8
 
8
9
  /**
9
10
  * Atomic actions available for an integration (by field)
@@ -185,6 +186,11 @@ export const useExecuteAtomicAction = ({
185
186
  fieldKey,
186
187
  integrationKey
187
188
  });
189
+ const item = fg('enable_datasource_fetch_action_inputs') ?
190
+ // eslint-disable-next-line react-hooks/rules-of-hooks
191
+ useDatasourceItem({
192
+ id: ari
193
+ }) : undefined;
188
194
  const {
189
195
  executeAtomicAction: executeAction,
190
196
  invalidateDatasourceDataCacheByAri
@@ -227,11 +233,37 @@ export const useExecuteAtomicAction = ({
227
233
  throw error;
228
234
  });
229
235
  }, [schema, executeAction, integrationKey, fieldKey, ari, invalidateDatasourceDataCacheByAri, fireEvent, captureError]);
230
- const executeFetch = useCallback(inputs => {
236
+ const executeFetch = useCallback(controlledInputs => {
231
237
  if (!fetchSchema) {
232
238
  throw new Error('No supporting action schema found.');
233
239
  }
234
240
 
241
+ /**
242
+ * controlled inputs are useful for search fields, where a variable query is passed to the fetchAction
243
+ */
244
+ let inputs = controlledInputs;
245
+ /**
246
+ * When FF is on and `controlledInputs` are not provided we look for required inputs in the fetchSchema
247
+ */
248
+ if (!Object.keys(inputs).length && fetchSchema.inputs && !!Object.keys(fetchSchema.inputs).length && fg('enable_datasource_fetch_action_inputs')) {
249
+ const inputKeys = Object.keys(fetchSchema.inputs);
250
+ /**
251
+ * If present return the input value from the datasource item
252
+ * e.g. this could be the issueKey or projectId of a Jira issue
253
+ */
254
+ inputs = inputKeys.reduce((acc, key) => {
255
+ var _item$data, _item$data$key;
256
+ const value = item === null || item === void 0 ? void 0 : (_item$data = item.data) === null || _item$data === void 0 ? void 0 : (_item$data$key = _item$data[key]) === null || _item$data$key === void 0 ? void 0 : _item$data$key.data;
257
+ if (typeof value === 'string' || typeof value === 'number') {
258
+ acc[key] = value;
259
+ }
260
+ /**
261
+ * This allows for the schema and data from the BE to dynamically set the action inputs
262
+ */
263
+ return acc;
264
+ }, {});
265
+ }
266
+
235
267
  // A generic type can allow us here to define the inputs and outputs
236
268
  return executeAction({
237
269
  integrationKey,
@@ -253,7 +285,7 @@ export const useExecuteAtomicAction = ({
253
285
  // Rethrow up to component for flags and other handling
254
286
  throw error;
255
287
  });
256
- }, [fetchSchema, executeAction, integrationKey, ari, fireEvent, captureError]);
288
+ }, [fetchSchema, executeAction, integrationKey, ari, item, fireEvent, captureError]);
257
289
  return {
258
290
  ...(schema && {
259
291
  execute
@@ -48,7 +48,7 @@ const IconEditType = props => {
48
48
  autoFocus: true,
49
49
  blurInputOnSelect: true,
50
50
  defaultMenuIsOpen: true
51
- // We can't update the status if we don't have an ID - however the ID
51
+ // We can't update this field if we don't have an ID - however the ID
52
52
  // is typed optional.
53
53
  ,
54
54
  options: fg('platform-datasources-inline-edit-id-checks') ? options.filter(option => option.id) : options,
@@ -10,6 +10,7 @@ import { useDatasourceClientExtension } from '@atlaskit/link-client-extension';
10
10
  import { fg } from '@atlaskit/platform-feature-flags';
11
11
  import { useDatasourceAnalyticsEvents } from '../../analytics';
12
12
  import useErrorLogger from '../../hooks/useErrorLogger';
13
+ import { useDatasourceItem } from '../index';
13
14
 
14
15
  /**
15
16
  * Atomic actions available for an integration (by field)
@@ -197,6 +198,11 @@ export var useExecuteAtomicAction = function useExecuteAtomicAction(_ref5) {
197
198
  _useAtomicUpdateActio3 = _useAtomicUpdateActio2[0],
198
199
  schema = _useAtomicUpdateActio3.schema,
199
200
  fetchSchema = _useAtomicUpdateActio3.fetchSchema;
201
+ var item = fg('enable_datasource_fetch_action_inputs') ?
202
+ // eslint-disable-next-line react-hooks/rules-of-hooks
203
+ useDatasourceItem({
204
+ id: ari
205
+ }) : undefined;
200
206
  var _useDatasourceClientE2 = useDatasourceClientExtension(),
201
207
  executeAction = _useDatasourceClientE2.executeAtomicAction,
202
208
  invalidateDatasourceDataCacheByAri = _useDatasourceClientE2.invalidateDatasourceDataCacheByAri;
@@ -236,11 +242,37 @@ export var useExecuteAtomicAction = function useExecuteAtomicAction(_ref5) {
236
242
  throw error;
237
243
  });
238
244
  }, [schema, executeAction, integrationKey, fieldKey, ari, invalidateDatasourceDataCacheByAri, fireEvent, captureError]);
239
- var executeFetch = useCallback(function (inputs) {
245
+ var executeFetch = useCallback(function (controlledInputs) {
240
246
  if (!fetchSchema) {
241
247
  throw new Error('No supporting action schema found.');
242
248
  }
243
249
 
250
+ /**
251
+ * controlled inputs are useful for search fields, where a variable query is passed to the fetchAction
252
+ */
253
+ var inputs = controlledInputs;
254
+ /**
255
+ * When FF is on and `controlledInputs` are not provided we look for required inputs in the fetchSchema
256
+ */
257
+ if (!Object.keys(inputs).length && fetchSchema.inputs && !!Object.keys(fetchSchema.inputs).length && fg('enable_datasource_fetch_action_inputs')) {
258
+ var inputKeys = Object.keys(fetchSchema.inputs);
259
+ /**
260
+ * If present return the input value from the datasource item
261
+ * e.g. this could be the issueKey or projectId of a Jira issue
262
+ */
263
+ inputs = inputKeys.reduce(function (acc, key) {
264
+ var _item$data;
265
+ var value = item === null || item === void 0 || (_item$data = item.data) === null || _item$data === void 0 || (_item$data = _item$data[key]) === null || _item$data === void 0 ? void 0 : _item$data.data;
266
+ if (typeof value === 'string' || typeof value === 'number') {
267
+ acc[key] = value;
268
+ }
269
+ /**
270
+ * This allows for the schema and data from the BE to dynamically set the action inputs
271
+ */
272
+ return acc;
273
+ }, {});
274
+ }
275
+
244
276
  // A generic type can allow us here to define the inputs and outputs
245
277
  return executeAction({
246
278
  integrationKey: integrationKey,
@@ -262,7 +294,7 @@ export var useExecuteAtomicAction = function useExecuteAtomicAction(_ref5) {
262
294
  // Rethrow up to component for flags and other handling
263
295
  throw error;
264
296
  });
265
- }, [fetchSchema, executeAction, integrationKey, ari, fireEvent, captureError]);
297
+ }, [fetchSchema, executeAction, integrationKey, ari, item, fireEvent, captureError]);
266
298
  return _objectSpread(_objectSpread({}, schema && {
267
299
  execute: execute
268
300
  }), fetchSchema && {
@@ -45,7 +45,7 @@ var IconEditType = function IconEditType(props) {
45
45
  autoFocus: true,
46
46
  blurInputOnSelect: true,
47
47
  defaultMenuIsOpen: true
48
- // We can't update the status if we don't have an ID - however the ID
48
+ // We can't update this field if we don't have an ID - however the ID
49
49
  // is typed optional.
50
50
  ,
51
51
  options: fg('platform-datasources-inline-edit-id-checks') ? options.filter(function (option) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/link-datasource",
3
- "version": "3.22.1",
3
+ "version": "3.22.2",
4
4
  "description": "UI Components to support linking platform dataset feature",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -45,17 +45,17 @@
45
45
  "@atlaskit/badge": "^18.1.0",
46
46
  "@atlaskit/button": "^21.1.0",
47
47
  "@atlaskit/css": "^0.10.0",
48
- "@atlaskit/datetime-picker": "^16.0.0",
48
+ "@atlaskit/datetime-picker": "^16.1.0",
49
49
  "@atlaskit/dropdown-menu": "^13.0.0",
50
50
  "@atlaskit/editor-prosemirror": "7.0.0",
51
51
  "@atlaskit/empty-state": "^9.0.0",
52
- "@atlaskit/flag": "^16.1.0",
52
+ "@atlaskit/flag": "^16.2.0",
53
53
  "@atlaskit/form": "^12.0.0",
54
54
  "@atlaskit/heading": "^5.1.0",
55
55
  "@atlaskit/icon": "^24.1.0",
56
56
  "@atlaskit/icon-object": "^7.0.0",
57
57
  "@atlaskit/image": "^2.0.0",
58
- "@atlaskit/inline-edit": "^15.0.0",
58
+ "@atlaskit/inline-edit": "^15.1.0",
59
59
  "@atlaskit/intl-messages-provider": "^2.0.0",
60
60
  "@atlaskit/jql-ast": "^3.3.0",
61
61
  "@atlaskit/jql-editor": "^5.0.0",
@@ -165,6 +165,9 @@
165
165
  "enable_datasource_supporting_actions": {
166
166
  "type": "boolean"
167
167
  },
168
+ "enable_datasource_fetch_action_inputs": {
169
+ "type": "boolean"
170
+ },
168
171
  "platform-datasources-enable-two-way-sync-statuses": {
169
172
  "type": "boolean"
170
173
  },