@atlaskit/link-datasource 1.10.2 → 1.11.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.
Files changed (43) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/analytics/constants.js +1 -1
  3. package/dist/cjs/analytics/types.js +1 -0
  4. package/dist/cjs/hooks/useObjectSchemas.js +23 -13
  5. package/dist/cjs/ui/assets-modal/modal/index.js +109 -16
  6. package/dist/cjs/ui/assets-modal/modal/render-assets-content/index.js +5 -3
  7. package/dist/cjs/ui/assets-modal/search-container/index.js +4 -0
  8. package/dist/cjs/ui/assets-modal/search-container/object-schema-select/index.js +68 -23
  9. package/dist/cjs/ui/issue-like-table/render-type/link/index.js +5 -0
  10. package/dist/cjs/ui/jira-issues-modal/modal/index.js +2 -1
  11. package/dist/es2019/analytics/constants.js +1 -1
  12. package/dist/es2019/analytics/types.js +1 -0
  13. package/dist/es2019/hooks/useObjectSchemas.js +9 -1
  14. package/dist/es2019/ui/assets-modal/modal/index.js +112 -15
  15. package/dist/es2019/ui/assets-modal/modal/render-assets-content/index.js +5 -3
  16. package/dist/es2019/ui/assets-modal/search-container/index.js +5 -0
  17. package/dist/es2019/ui/assets-modal/search-container/object-schema-select/index.js +32 -5
  18. package/dist/es2019/ui/issue-like-table/render-type/link/index.js +13 -6
  19. package/dist/es2019/ui/jira-issues-modal/modal/index.js +2 -1
  20. package/dist/esm/analytics/constants.js +1 -1
  21. package/dist/esm/analytics/types.js +1 -0
  22. package/dist/esm/hooks/useObjectSchemas.js +23 -13
  23. package/dist/esm/ui/assets-modal/modal/index.js +112 -19
  24. package/dist/esm/ui/assets-modal/modal/render-assets-content/index.js +5 -3
  25. package/dist/esm/ui/assets-modal/search-container/index.js +4 -0
  26. package/dist/esm/ui/assets-modal/search-container/object-schema-select/index.js +65 -20
  27. package/dist/esm/ui/issue-like-table/render-type/link/index.js +5 -0
  28. package/dist/esm/ui/jira-issues-modal/modal/index.js +2 -1
  29. package/dist/types/analytics/generated/analytics.types.d.ts +7 -2
  30. package/dist/types/analytics/types.d.ts +2 -1
  31. package/dist/types/hooks/useObjectSchemas.d.ts +3 -1
  32. package/dist/types/ui/assets-modal/modal/render-assets-content/index.d.ts +1 -0
  33. package/dist/types/ui/assets-modal/search-container/index.d.ts +1 -2
  34. package/dist/types/ui/assets-modal/types.d.ts +2 -1
  35. package/dist/types-ts4.5/analytics/generated/analytics.types.d.ts +7 -2
  36. package/dist/types-ts4.5/analytics/types.d.ts +2 -1
  37. package/dist/types-ts4.5/hooks/useObjectSchemas.d.ts +3 -1
  38. package/dist/types-ts4.5/ui/assets-modal/modal/render-assets-content/index.d.ts +1 -0
  39. package/dist/types-ts4.5/ui/assets-modal/search-container/index.d.ts +1 -2
  40. package/dist/types-ts4.5/ui/assets-modal/types.d.ts +2 -1
  41. package/package.json +3 -3
  42. package/report.api.md +4 -1
  43. package/tmp/api-report-tmp.d.ts +1 -1
@@ -1,19 +1,25 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
1
  import _extends from "@babel/runtime/helpers/extends";
3
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
4
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
5
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
5
6
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
7
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
- import _regeneratorRuntime from "@babel/runtime/regenerator";
8
8
  /** @jsx jsx */
9
- import { useCallback, useEffect, useMemo, useState } from 'react';
9
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
10
10
  import { css, jsx } from '@emotion/react';
11
11
  import { FormattedMessage } from 'react-intl-next';
12
+ import { v4 as uuidv4 } from 'uuid';
12
13
  import { withAnalyticsContext } from '@atlaskit/analytics-next';
13
14
  import Button from '@atlaskit/button/standard-button';
14
15
  import { IntlMessagesProvider } from '@atlaskit/intl-messages-provider';
15
16
  import Modal, { ModalBody, ModalFooter, ModalHeader, ModalTitle, ModalTransition } from '@atlaskit/modal-dialog';
16
- import { useDatasourceAnalyticsEvents } from '../../../analytics';
17
+ import { EVENT_CHANNEL, useDatasourceAnalyticsEvents } from '../../../analytics';
18
+ import { packageMetaData } from '../../../analytics/constants';
19
+ import { DatasourceAction, DatasourceDisplay, DatasourceSearchMethod } from '../../../analytics/types';
20
+ import { startUfoExperience } from '../../../analytics/ufoExperiences';
21
+ import { useColumnPickerRenderedFailedUfoExperience } from '../../../analytics/ufoExperiences/hooks/useColumnPickerRenderedFailedUfoExperience';
22
+ import { useDataRenderedUfoExperience } from '../../../analytics/ufoExperiences/hooks/useDataRenderedUfoExperience';
17
23
  import { fetchMessagesForLocale } from '../../../common/utils/locale/fetch-messages-for-locale';
18
24
  import { useAssetsClient } from '../../../hooks/useAssetsClient';
19
25
  import { useDatasourceTableState } from '../../../hooks/useDatasourceTableState';
@@ -53,6 +59,8 @@ var PlainAssetsConfigModal = function PlainAssetsConfigModal(props) {
53
59
  setIsNewSearch = _useState8[1];
54
60
  var _useDatasourceAnalyti = useDatasourceAnalyticsEvents(),
55
61
  fireEvent = _useDatasourceAnalyti.fireEvent;
62
+ var _useRef = useRef(uuidv4()),
63
+ modalRenderInstanceId = _useRef.current;
56
64
 
57
65
  // If a workspaceError occurs this is a critical error
58
66
  var _useAssetsClient = useAssetsClient(initialParameters),
@@ -80,13 +88,69 @@ var PlainAssetsConfigModal = function PlainAssetsConfigModal(props) {
80
88
  loadDatasourceDetails = _useDatasourceTableSt.loadDatasourceDetails,
81
89
  hasNextPage = _useDatasourceTableSt.hasNextPage,
82
90
  columns = _useDatasourceTableSt.columns,
83
- defaultVisibleColumnKeys = _useDatasourceTableSt.defaultVisibleColumnKeys;
91
+ defaultVisibleColumnKeys = _useDatasourceTableSt.defaultVisibleColumnKeys,
92
+ _useDatasourceTableSt2 = _useDatasourceTableSt.extensionKey,
93
+ extensionKey = _useDatasourceTableSt2 === void 0 ? null : _useDatasourceTableSt2,
94
+ destinationObjectTypes = _useDatasourceTableSt.destinationObjectTypes,
95
+ totalCount = _useDatasourceTableSt.totalCount;
96
+
97
+ /* ------------------------------ OBSERVABILITY ------------------------------ */
98
+ var searchCount = useRef(0);
99
+ var userInteractionActions = useRef(new Set());
100
+ var visibleColumnCount = useRef((visibleColumnKeys === null || visibleColumnKeys === void 0 ? void 0 : visibleColumnKeys.length) || 0);
101
+ var isDataReady = (visibleColumnKeys || []).length > 0;
102
+ var analyticsPayload = useMemo(function () {
103
+ return {
104
+ extensionKey: extensionKey,
105
+ destinationObjectTypes: destinationObjectTypes
106
+ };
107
+ }, [destinationObjectTypes, extensionKey]);
108
+ useEffect(function () {
109
+ fireEvent('screen.datasourceModalDialog.viewed', {});
110
+ }, [fireEvent]);
111
+ var fireTableViewedEvent = useCallback(function () {
112
+ if (isDataReady) {
113
+ fireEvent('ui.table.viewed.datasourceConfigModal', _objectSpread(_objectSpread({}, analyticsPayload), {}, {
114
+ totalItemCount: totalCount || 0,
115
+ searchMethod: DatasourceSearchMethod.DATASOURCE_SEARCH_QUERY,
116
+ displayedColumnCount: visibleColumnCount.current
117
+ }));
118
+ }
119
+ }, [analyticsPayload, fireEvent, totalCount, isDataReady]);
120
+ useEffect(function () {
121
+ var isResolved = status === 'resolved';
122
+ if (!isResolved || !totalCount) {
123
+ return;
124
+ }
125
+ if (totalCount > 1) {
126
+ fireTableViewedEvent();
127
+ }
128
+ }, [fireTableViewedEvent, status, totalCount]);
129
+ useEffect(function () {
130
+ var shouldStartUfoExperience = status === 'loading';
131
+ if (shouldStartUfoExperience) {
132
+ startUfoExperience({
133
+ name: 'datasource-rendered'
134
+ }, modalRenderInstanceId);
135
+ }
136
+ }, [modalRenderInstanceId, status]);
137
+ useDataRenderedUfoExperience({
138
+ status: status,
139
+ experienceId: modalRenderInstanceId,
140
+ itemCount: responseItems.length,
141
+ canBeLink: false,
142
+ extensionKey: extensionKey
143
+ });
144
+ useColumnPickerRenderedFailedUfoExperience(status, modalRenderInstanceId);
145
+ /* ------------------------------ END OBSERVABILITY ------------------------------ */
146
+
84
147
  var onVisibleColumnKeysChange = useCallback(function (visibleColumnKeys) {
85
148
  setVisibleColumnKeys(visibleColumnKeys);
86
149
  setIsNewSearch(false);
87
150
  }, []);
88
151
  useEffect(function () {
89
152
  var newVisibleColumnKeys = !initialVisibleColumnKeys || (initialVisibleColumnKeys || []).length === 0 ? defaultVisibleColumnKeys : initialVisibleColumnKeys;
153
+ visibleColumnCount.current = newVisibleColumnKeys.length;
90
154
  setVisibleColumnKeys(newVisibleColumnKeys);
91
155
  }, [initialVisibleColumnKeys, defaultVisibleColumnKeys]);
92
156
  useEffect(function () {
@@ -94,10 +158,7 @@ var PlainAssetsConfigModal = function PlainAssetsConfigModal(props) {
94
158
  setVisibleColumnKeys(defaultVisibleColumnKeys);
95
159
  }
96
160
  }, [defaultVisibleColumnKeys, isNewSearch]);
97
- useEffect(function () {
98
- fireEvent('screen.datasourceModalDialog.viewed', {});
99
- }, [fireEvent]);
100
- var isDisabled = !!workspaceError || status === 'rejected' || status === 'loading' || status === 'empty' || !!workspaceError || assetsClientLoading || !aql || !schemaId;
161
+ var isDisabled = !!workspaceError || status === 'rejected' || status === 'loading' || status === 'empty' || assetsClientLoading || !aql || !schemaId;
101
162
  var retrieveUrlForSmartCardRender = useCallback(function () {
102
163
  var _data$key;
103
164
  var _responseItems = _slicedToArray(responseItems, 1),
@@ -105,10 +166,25 @@ var PlainAssetsConfigModal = function PlainAssetsConfigModal(props) {
105
166
  // agreement with BE that we will use `key` for rendering smartlink
106
167
  return data === null || data === void 0 || (_data$key = data.key) === null || _data$key === void 0 || (_data$key = _data$key.data) === null || _data$key === void 0 ? void 0 : _data$key.url;
107
168
  }, [responseItems]);
108
- var onInsertPressed = useCallback(function () {
169
+ var onInsertPressed = useCallback(function (e, analyticsEvent) {
170
+ var _insertButtonClickedE;
109
171
  if (!aql || !schemaId || !workspaceId) {
110
172
  return;
111
173
  }
174
+ var insertButtonClickedEvent = analyticsEvent.update({
175
+ actionSubjectId: 'insert',
176
+ attributes: _objectSpread(_objectSpread({}, analyticsPayload), {}, {
177
+ totalItemCount: totalCount || 0,
178
+ displayedColumnCount: visibleColumnCount.current,
179
+ display: DatasourceDisplay.DATASOURCE_TABLE,
180
+ searchCount: searchCount.current,
181
+ searchMethod: DatasourceSearchMethod.DATASOURCE_SEARCH_QUERY,
182
+ actions: Array.from(userInteractionActions.current)
183
+ }),
184
+ eventType: 'ui'
185
+ });
186
+ var consumerEvent = (_insertButtonClickedE = insertButtonClickedEvent.clone()) !== null && _insertButtonClickedE !== void 0 ? _insertButtonClickedE : undefined;
187
+ insertButtonClickedEvent.fire(EVENT_CHANNEL);
112
188
  var firstAssetUrl = retrieveUrlForSmartCardRender();
113
189
  if (responseItems.length === 1 && firstAssetUrl) {
114
190
  onInsert({
@@ -116,7 +192,7 @@ var PlainAssetsConfigModal = function PlainAssetsConfigModal(props) {
116
192
  attrs: {
117
193
  url: firstAssetUrl
118
194
  }
119
- });
195
+ }, consumerEvent);
120
196
  } else {
121
197
  onInsert({
122
198
  type: 'blockCard',
@@ -140,15 +216,33 @@ var PlainAssetsConfigModal = function PlainAssetsConfigModal(props) {
140
216
  }]
141
217
  }
142
218
  }
143
- });
219
+ }, consumerEvent);
144
220
  }
145
- }, [aql, schemaId, workspaceId, retrieveUrlForSmartCardRender, responseItems.length, onInsert, datasourceId, visibleColumnKeys]);
221
+ }, [aql, schemaId, workspaceId, analyticsPayload, totalCount, retrieveUrlForSmartCardRender, responseItems.length, onInsert, datasourceId, visibleColumnKeys]);
222
+ var onCancelClick = useCallback(function (e, analyticEvent) {
223
+ analyticEvent.update({
224
+ eventType: 'ui',
225
+ actionSubjectId: 'cancel',
226
+ attributes: _objectSpread(_objectSpread({}, analyticsPayload), {}, {
227
+ searchCount: searchCount.current,
228
+ actions: Array.from(userInteractionActions.current)
229
+ })
230
+ }).fire(EVENT_CHANNEL);
231
+ onCancel();
232
+ }, [analyticsPayload, onCancel]);
146
233
  var handleOnSearch = useCallback( /*#__PURE__*/function () {
147
234
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(searchAql, searchSchemaId) {
148
235
  return _regeneratorRuntime.wrap(function _callee$(_context) {
149
236
  while (1) switch (_context.prev = _context.next) {
150
237
  case 0:
151
238
  if (schemaId !== searchSchemaId || aql !== searchAql) {
239
+ searchCount.current++;
240
+ if (schemaId !== searchSchemaId) {
241
+ userInteractionActions.current.add(DatasourceAction.SCHEMA_UPDATED);
242
+ }
243
+ if (aql !== searchAql) {
244
+ userInteractionActions.current.add(DatasourceAction.QUERY_UPDATED);
245
+ }
152
246
  reset({
153
247
  shouldResetColumns: true
154
248
  });
@@ -210,10 +304,11 @@ var PlainAssetsConfigModal = function PlainAssetsConfigModal(props) {
210
304
  hasNextPage: hasNextPage,
211
305
  loadDatasourceDetails: loadDatasourceDetails,
212
306
  columns: columns,
213
- defaultVisibleColumnKeys: defaultVisibleColumnKeys
307
+ defaultVisibleColumnKeys: defaultVisibleColumnKeys,
308
+ modalRenderInstanceId: modalRenderInstanceId
214
309
  }))), jsx(ModalFooter, null, jsx(Button, {
215
310
  appearance: "default",
216
- onClick: onCancel,
311
+ onClick: onCancelClick,
217
312
  testId: 'asset-datasource-modal--cancel-button'
218
313
  }, jsx(FormattedMessage, modalMessages.cancelButtonText)), jsx(Button, {
219
314
  appearance: "primary",
@@ -229,11 +324,9 @@ var PlainAssetsConfigModal = function PlainAssetsConfigModal(props) {
229
324
  var analyticsContextAttributes = {
230
325
  dataProvider: 'jsm-assets'
231
326
  };
232
- var analyticsContextData = {
233
- packageName: "@atlaskit/link-datasource",
234
- packageVersion: "1.10.2",
327
+ var analyticsContextData = _objectSpread(_objectSpread({}, packageMetaData), {}, {
235
328
  source: 'datasourceConfigModal'
236
- };
329
+ });
237
330
  var contextData = _objectSpread(_objectSpread({}, analyticsContextData), {}, {
238
331
  attributes: _objectSpread({}, analyticsContextAttributes)
239
332
  });
@@ -12,7 +12,8 @@ export var RenderAssetsContent = function RenderAssetsContent(props) {
12
12
  loadDatasourceDetails = props.loadDatasourceDetails,
13
13
  columns = props.columns,
14
14
  defaultVisibleColumnKeys = props.defaultVisibleColumnKeys,
15
- onVisibleColumnKeysChange = props.onVisibleColumnKeysChange;
15
+ onVisibleColumnKeysChange = props.onVisibleColumnKeysChange,
16
+ modalRenderInstanceId = props.modalRenderInstanceId;
16
17
  var resolvedWithNoResults = status === 'resolved' && !responseItems.length;
17
18
  var issueLikeDataTableView = useMemo(function () {
18
19
  return /*#__PURE__*/React.createElement(IssueLikeDataTableView, {
@@ -24,9 +25,10 @@ export var RenderAssetsContent = function RenderAssetsContent(props) {
24
25
  visibleColumnKeys: visibleColumnKeys || defaultVisibleColumnKeys,
25
26
  onNextPage: onNextPage,
26
27
  onLoadDatasourceDetails: loadDatasourceDetails,
27
- onVisibleColumnKeysChange: onVisibleColumnKeysChange
28
+ onVisibleColumnKeysChange: onVisibleColumnKeysChange,
29
+ parentContainerRenderInstanceId: modalRenderInstanceId
28
30
  });
29
- }, [columns, defaultVisibleColumnKeys, hasNextPage, loadDatasourceDetails, onNextPage, onVisibleColumnKeysChange, responseItems, status, visibleColumnKeys]);
31
+ }, [columns, defaultVisibleColumnKeys, hasNextPage, loadDatasourceDetails, onNextPage, onVisibleColumnKeysChange, responseItems, status, visibleColumnKeys, modalRenderInstanceId]);
30
32
  if (status === 'rejected') {
31
33
  return /*#__PURE__*/React.createElement(ModalLoadingError, null);
32
34
  } else if (status === 'empty') {
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  /** @jsx jsx */
3
3
  import { jsx } from '@emotion/react';
4
4
  import Form from '@atlaskit/form';
5
+ import { useDatasourceAnalyticsEvents } from '../../../analytics';
5
6
  import { AqlSearchInput } from './aql-search-input';
6
7
  import { AssetsObjectSchemaSelect } from './object-schema-select';
7
8
  import { FormContainer, FormRowContainer, SchemaSelectContainer } from './styled';
@@ -13,10 +14,13 @@ export var AssetsSearchContainer = function AssetsSearchContainer(props) {
13
14
  initialSearchData = props.initialSearchData,
14
15
  modalTitle = props.modalTitle,
15
16
  isSearching = props.isSearching;
17
+ var _useDatasourceAnalyti = useDatasourceAnalyticsEvents(),
18
+ fireEvent = _useDatasourceAnalyti.fireEvent;
16
19
  var onFormSubmit = function onFormSubmit(searchFormValues) {
17
20
  var aql = searchFormValues.aql,
18
21
  objectSchema = searchFormValues.objectSchema;
19
22
  if (objectSchema) {
23
+ fireEvent('ui.aqlEditor.searched', {});
20
24
  // Pass the validated aql and object schema back to modal
21
25
  onSearch(aql, objectSchema.value);
22
26
  }
@@ -1,6 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
4
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
5
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
6
  var _excluded = ["onChange", "onFocus"];
6
7
  import _regeneratorRuntime from "@babel/runtime/regenerator";
@@ -8,18 +9,25 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
8
9
  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; }
9
10
  /** @jsx jsx */
10
11
 
12
+ import { useEffect, useState } from 'react';
11
13
  import { jsx } from '@emotion/react';
12
14
  import debounce from 'debounce-promise';
13
15
  import { useIntl } from 'react-intl-next';
14
16
  import { Field } from '@atlaskit/form';
15
17
  import { AsyncSelect } from '@atlaskit/select';
16
18
  import { layers } from '@atlaskit/theme/constants';
19
+ import { useDatasourceAnalyticsEvents } from '../../../../analytics';
17
20
  import { useObjectSchemas } from '../../../../hooks/useObjectSchemas';
18
21
  import { objectSchemaKey } from '../../../../types/assets/types';
19
22
  import { FieldContainer } from '../styled';
20
23
  import { objectSchemaSelectMessages } from './messages';
21
24
  import { objectSchemaToSelectOption } from './utils';
22
25
  export var SEARCH_DEBOUNCE_MS = 350;
26
+ var mapObjectSchemasToOptions = function mapObjectSchemasToOptions(objectSchemas) {
27
+ return objectSchemas ? objectSchemas.map(function (objectSchema) {
28
+ return objectSchemaToSelectOption(objectSchema);
29
+ }) : [];
30
+ };
23
31
 
24
32
  /**
25
33
  * Rendering a `<Select>` in a `<Modal>` results in the select options getting cut off by the bottom of the modal and
@@ -40,34 +48,72 @@ export var AssetsObjectSchemaSelect = function AssetsObjectSchemaSelect(_ref) {
40
48
  workspaceId = _ref.workspaceId,
41
49
  _ref$classNamePrefix = _ref.classNamePrefix,
42
50
  classNamePrefix = _ref$classNamePrefix === void 0 ? 'assets-datasource-modal--object-schema-select' : _ref$classNamePrefix;
51
+ var _useState = useState(null),
52
+ _useState2 = _slicedToArray(_useState, 2),
53
+ defaultOptions = _useState2[0],
54
+ setDefaultOptions = _useState2[1];
55
+ var _useDatasourceAnalyti = useDatasourceAnalyticsEvents(),
56
+ fireEvent = _useDatasourceAnalyti.fireEvent;
43
57
  var _useIntl = useIntl(),
44
58
  formatMessage = _useIntl.formatMessage;
45
59
  var _useObjectSchemas = useObjectSchemas(workspaceId),
46
60
  fetchObjectSchemas = _useObjectSchemas.fetchObjectSchemas,
47
61
  objectSchemasLoading = _useObjectSchemas.objectSchemasLoading;
48
62
  var selectedObjectSchema = value ? objectSchemaToSelectOption(value) : undefined;
63
+ useEffect(function () {
64
+ var fetchInitialData = /*#__PURE__*/function () {
65
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
66
+ var _yield$fetchObjectSch, objectSchemas, totalObjectSchemas;
67
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
68
+ while (1) switch (_context.prev = _context.next) {
69
+ case 0:
70
+ _context.next = 2;
71
+ return fetchObjectSchemas('');
72
+ case 2:
73
+ _yield$fetchObjectSch = _context.sent;
74
+ objectSchemas = _yield$fetchObjectSch.objectSchemas;
75
+ totalObjectSchemas = _yield$fetchObjectSch.totalObjectSchemas;
76
+ // We only want to send modal ready event once after we've fetched the schema count
77
+ fireEvent('ui.modal.ready.datasource', {
78
+ schemasCount: totalObjectSchemas !== null && totalObjectSchemas !== void 0 ? totalObjectSchemas : 0,
79
+ instancesCount: null
80
+ });
81
+ setDefaultOptions(mapObjectSchemasToOptions(objectSchemas));
82
+ case 7:
83
+ case "end":
84
+ return _context.stop();
85
+ }
86
+ }, _callee);
87
+ }));
88
+ return function fetchInitialData() {
89
+ return _ref2.apply(this, arguments);
90
+ };
91
+ }();
92
+ if (defaultOptions === null) {
93
+ fetchInitialData();
94
+ }
95
+ // eslint-disable-next-line react-hooks/exhaustive-deps
96
+ }, []);
49
97
  var loadOptions = /*#__PURE__*/function () {
50
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(inputValue) {
51
- var objectSchemas, options;
52
- return _regeneratorRuntime.wrap(function _callee$(_context) {
53
- while (1) switch (_context.prev = _context.next) {
98
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(inputValue) {
99
+ var _yield$fetchObjectSch2, objectSchemas;
100
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
101
+ while (1) switch (_context2.prev = _context2.next) {
54
102
  case 0:
55
- _context.next = 2;
103
+ _context2.next = 2;
56
104
  return fetchObjectSchemas(inputValue);
57
105
  case 2:
58
- objectSchemas = _context.sent;
59
- options = objectSchemas ? objectSchemas.map(function (objectSchema) {
60
- return objectSchemaToSelectOption(objectSchema);
61
- }) : [];
62
- return _context.abrupt("return", options);
106
+ _yield$fetchObjectSch2 = _context2.sent;
107
+ objectSchemas = _yield$fetchObjectSch2.objectSchemas;
108
+ return _context2.abrupt("return", mapObjectSchemasToOptions(objectSchemas));
63
109
  case 5:
64
110
  case "end":
65
- return _context.stop();
111
+ return _context2.stop();
66
112
  }
67
- }, _callee);
113
+ }, _callee2);
68
114
  }));
69
115
  return function loadOptions(_x) {
70
- return _ref2.apply(this, arguments);
116
+ return _ref3.apply(this, arguments);
71
117
  };
72
118
  }();
73
119
  var debouncedLoadOptions = debounce(loadOptions, SEARCH_DEBOUNCE_MS);
@@ -83,17 +129,16 @@ export var AssetsObjectSchemaSelect = function AssetsObjectSchemaSelect(_ref) {
83
129
  validate: function validate(value) {
84
130
  return validateSchema(value);
85
131
  }
86
- }, function (_ref3) {
87
- var _ref3$fieldProps = _ref3.fieldProps,
88
- _onChange = _ref3$fieldProps.onChange,
89
- onFocus = _ref3$fieldProps.onFocus,
90
- restFieldProps = _objectWithoutProperties(_ref3$fieldProps, _excluded);
132
+ }, function (_ref4) {
133
+ var _ref4$fieldProps = _ref4.fieldProps,
134
+ _onChange = _ref4$fieldProps.onChange,
135
+ onFocus = _ref4$fieldProps.onFocus,
136
+ restFieldProps = _objectWithoutProperties(_ref4$fieldProps, _excluded);
91
137
  return jsx(AsyncSelect, _extends({
92
138
  autoFocus: true,
93
139
  classNamePrefix: classNamePrefix,
94
140
  isLoading: objectSchemasLoading,
95
- defaultOptions: true // setting to true causes the loadOptions to be called on mount
96
- ,
141
+ defaultOptions: defaultOptions !== null && defaultOptions !== void 0 ? defaultOptions : [],
97
142
  isSearchable: true,
98
143
  loadOptions: debouncedLoadOptions,
99
144
  placeholder: formatMessage(objectSchemaSelectMessages.placeholder),
@@ -39,8 +39,13 @@ var LinkRenderType = function LinkRenderType(_ref) {
39
39
  }, text || url));
40
40
  }, [linkStyle, url, text, testId]);
41
41
  var SmartCard = function SmartCard() {
42
+ var handleClick = function handleClick(e) {
43
+ e.preventDefault();
44
+ window.open(url, '_blank', 'noopener, noreferrer');
45
+ };
42
46
  return /*#__PURE__*/React.createElement(Card, {
43
47
  appearance: "inline",
48
+ onClick: handleClick,
44
49
  url: url,
45
50
  testId: testId,
46
51
  fallbackComponent: function fallbackComponent() {
@@ -216,7 +216,8 @@ export var PlainJiraIssuesConfigModal = function PlainJiraIssuesConfigModal(prop
216
216
  });
217
217
  setAvailableSites(sortedAvailableSites);
218
218
  fireEvent('ui.modal.ready.datasource', {
219
- instancesCount: sortedAvailableSites.length
219
+ instancesCount: sortedAvailableSites.length,
220
+ schemasCount: null
220
221
  });
221
222
  case 6:
222
223
  case "end":
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Generates Typescript types for analytics events from analytics.spec.yaml
5
5
  *
6
- * @codegen <<SignedSource::24da75a4acd4c592c9cfed50e9897853>>
6
+ * @codegen <<SignedSource::7e783b41141644b6a0df41de5ab456df>>
7
7
  * @codegenCommand yarn workspace @atlassian/analytics-tooling run analytics:codegen link-datasource
8
8
  */
9
9
  export type PackageMetaDataType = {
@@ -18,7 +18,8 @@ export type AnalyticsContextAttributesType = {
18
18
  };
19
19
  export type DatasourceModalDialogViewedAttributesType = {};
20
20
  export type ModalReadyDatasourceAttributesType = {
21
- instancesCount: number;
21
+ instancesCount: number | null;
22
+ schemasCount: number | null;
22
23
  };
23
24
  export type JqlEditorSearchedAttributesType = {};
24
25
  export type FormSubmittedBasicSearchAttributesType = {};
@@ -81,6 +82,7 @@ export type LinkViewedCountAttributesType = {
81
82
  totalItemCount: number;
82
83
  extensionKey: string | null;
83
84
  };
85
+ export type AqlEditorSearchedAttributesType = {};
84
86
  export type AnalyticsEventAttributes = {
85
87
  /**
86
88
  * Fires when user sees modal dialog. */
@@ -130,5 +132,8 @@ export type AnalyticsEventAttributes = {
130
132
  /**
131
133
  * Fired when the datasource results are displayed as link( smart-link) in count mode. */
132
134
  'ui.link.viewed.count': LinkViewedCountAttributesType;
135
+ /**
136
+ * Fired when search is initiated via the search icon or enter key press for aql editor input field. */
137
+ 'ui.aqlEditor.searched': AqlEditorSearchedAttributesType;
133
138
  };
134
139
  export type EventKey = keyof AnalyticsEventAttributes;
@@ -5,7 +5,8 @@ export declare enum DatasourceAction {
5
5
  INSTANCE_UPDATED = "instance updated",
6
6
  QUERY_UPDATED = "query updated",
7
7
  DISPLAY_VIEW_CHANGED = "display view changed",
8
- NEXT_PAGE_SCROLLED = "next page scrolled"
8
+ NEXT_PAGE_SCROLLED = "next page scrolled",
9
+ SCHEMA_UPDATED = "schema updated"
9
10
  }
10
11
  export declare enum DatasourceDisplay {
11
12
  DATASOURCE_TABLE = "datasource_table",
@@ -1,8 +1,10 @@
1
1
  import { ObjectSchema } from '../types/assets/types';
2
+ export type FetchObjectSchemasDetails = Pick<UseObjectSchemasState, 'objectSchemas' | 'totalObjectSchemas'>;
2
3
  export type UseObjectSchemasState = {
3
4
  objectSchemasLoading: boolean;
4
5
  objectSchemasError: Error | undefined;
5
6
  objectSchemas: ObjectSchema[] | undefined;
6
- fetchObjectSchemas: (query: string) => Promise<ObjectSchema[] | undefined>;
7
+ totalObjectSchemas: number | undefined;
8
+ fetchObjectSchemas: (query: string) => Promise<FetchObjectSchemasDetails>;
7
9
  };
8
10
  export declare const useObjectSchemas: (workspaceId: string) => UseObjectSchemasState;
@@ -13,5 +13,6 @@ export interface RenderAssetsContentProps {
13
13
  columns: DatasourceResponseSchemaProperty[];
14
14
  defaultVisibleColumnKeys: string[];
15
15
  onVisibleColumnKeysChange: (visibleColumnKeys: string[]) => void;
16
+ modalRenderInstanceId: string;
16
17
  }
17
18
  export declare const RenderAssetsContent: (props: RenderAssetsContentProps) => JSX.Element;
@@ -2,7 +2,7 @@
2
2
  /** @jsx jsx */
3
3
  import { jsx } from '@emotion/react';
4
4
  import type { ObjectSchema } from '../../../types/assets/types';
5
- type InitialSearchData = {
5
+ export type InitialSearchData = {
6
6
  objectSchema?: ObjectSchema;
7
7
  aql?: string;
8
8
  };
@@ -14,4 +14,3 @@ export interface SearchContainerProps {
14
14
  isSearching: boolean;
15
15
  }
16
16
  export declare const AssetsSearchContainer: (props: SearchContainerProps) => jsx.JSX.Element;
17
- export {};
@@ -1,3 +1,4 @@
1
+ import type { UIAnalyticsEvent } from '@atlaskit/analytics-next';
1
2
  import { DatasourceAdf, DatasourceAdfView, InlineCardAdf } from '@atlaskit/linking-common/types';
2
3
  export interface AssetsDatasourceParameters {
3
4
  workspaceId: string;
@@ -19,5 +20,5 @@ export interface AssetsConfigModalProps {
19
20
  visibleColumnKeys?: string[];
20
21
  parameters?: AssetsDatasourceParameters;
21
22
  onCancel: () => void;
22
- onInsert: (adf: InlineCardAdf | AssetsDatasourceAdf) => void;
23
+ onInsert: (adf: InlineCardAdf | AssetsDatasourceAdf, analyticsEvent?: UIAnalyticsEvent) => void;
23
24
  }
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Generates Typescript types for analytics events from analytics.spec.yaml
5
5
  *
6
- * @codegen <<SignedSource::24da75a4acd4c592c9cfed50e9897853>>
6
+ * @codegen <<SignedSource::7e783b41141644b6a0df41de5ab456df>>
7
7
  * @codegenCommand yarn workspace @atlassian/analytics-tooling run analytics:codegen link-datasource
8
8
  */
9
9
  export type PackageMetaDataType = {
@@ -18,7 +18,8 @@ export type AnalyticsContextAttributesType = {
18
18
  };
19
19
  export type DatasourceModalDialogViewedAttributesType = {};
20
20
  export type ModalReadyDatasourceAttributesType = {
21
- instancesCount: number;
21
+ instancesCount: number | null;
22
+ schemasCount: number | null;
22
23
  };
23
24
  export type JqlEditorSearchedAttributesType = {};
24
25
  export type FormSubmittedBasicSearchAttributesType = {};
@@ -81,6 +82,7 @@ export type LinkViewedCountAttributesType = {
81
82
  totalItemCount: number;
82
83
  extensionKey: string | null;
83
84
  };
85
+ export type AqlEditorSearchedAttributesType = {};
84
86
  export type AnalyticsEventAttributes = {
85
87
  /**
86
88
  * Fires when user sees modal dialog. */
@@ -130,5 +132,8 @@ export type AnalyticsEventAttributes = {
130
132
  /**
131
133
  * Fired when the datasource results are displayed as link( smart-link) in count mode. */
132
134
  'ui.link.viewed.count': LinkViewedCountAttributesType;
135
+ /**
136
+ * Fired when search is initiated via the search icon or enter key press for aql editor input field. */
137
+ 'ui.aqlEditor.searched': AqlEditorSearchedAttributesType;
133
138
  };
134
139
  export type EventKey = keyof AnalyticsEventAttributes;
@@ -5,7 +5,8 @@ export declare enum DatasourceAction {
5
5
  INSTANCE_UPDATED = "instance updated",
6
6
  QUERY_UPDATED = "query updated",
7
7
  DISPLAY_VIEW_CHANGED = "display view changed",
8
- NEXT_PAGE_SCROLLED = "next page scrolled"
8
+ NEXT_PAGE_SCROLLED = "next page scrolled",
9
+ SCHEMA_UPDATED = "schema updated"
9
10
  }
10
11
  export declare enum DatasourceDisplay {
11
12
  DATASOURCE_TABLE = "datasource_table",
@@ -1,8 +1,10 @@
1
1
  import { ObjectSchema } from '../types/assets/types';
2
+ export type FetchObjectSchemasDetails = Pick<UseObjectSchemasState, 'objectSchemas' | 'totalObjectSchemas'>;
2
3
  export type UseObjectSchemasState = {
3
4
  objectSchemasLoading: boolean;
4
5
  objectSchemasError: Error | undefined;
5
6
  objectSchemas: ObjectSchema[] | undefined;
6
- fetchObjectSchemas: (query: string) => Promise<ObjectSchema[] | undefined>;
7
+ totalObjectSchemas: number | undefined;
8
+ fetchObjectSchemas: (query: string) => Promise<FetchObjectSchemasDetails>;
7
9
  };
8
10
  export declare const useObjectSchemas: (workspaceId: string) => UseObjectSchemasState;
@@ -13,5 +13,6 @@ export interface RenderAssetsContentProps {
13
13
  columns: DatasourceResponseSchemaProperty[];
14
14
  defaultVisibleColumnKeys: string[];
15
15
  onVisibleColumnKeysChange: (visibleColumnKeys: string[]) => void;
16
+ modalRenderInstanceId: string;
16
17
  }
17
18
  export declare const RenderAssetsContent: (props: RenderAssetsContentProps) => JSX.Element;
@@ -2,7 +2,7 @@
2
2
  /** @jsx jsx */
3
3
  import { jsx } from '@emotion/react';
4
4
  import type { ObjectSchema } from '../../../types/assets/types';
5
- type InitialSearchData = {
5
+ export type InitialSearchData = {
6
6
  objectSchema?: ObjectSchema;
7
7
  aql?: string;
8
8
  };
@@ -14,4 +14,3 @@ export interface SearchContainerProps {
14
14
  isSearching: boolean;
15
15
  }
16
16
  export declare const AssetsSearchContainer: (props: SearchContainerProps) => jsx.JSX.Element;
17
- export {};
@@ -1,3 +1,4 @@
1
+ import type { UIAnalyticsEvent } from '@atlaskit/analytics-next';
1
2
  import { DatasourceAdf, DatasourceAdfView, InlineCardAdf } from '@atlaskit/linking-common/types';
2
3
  export interface AssetsDatasourceParameters {
3
4
  workspaceId: string;
@@ -19,5 +20,5 @@ export interface AssetsConfigModalProps {
19
20
  visibleColumnKeys?: string[];
20
21
  parameters?: AssetsDatasourceParameters;
21
22
  onCancel: () => void;
22
- onInsert: (adf: InlineCardAdf | AssetsDatasourceAdf) => void;
23
+ onInsert: (adf: InlineCardAdf | AssetsDatasourceAdf, analyticsEvent?: UIAnalyticsEvent) => void;
23
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/link-datasource",
3
- "version": "1.10.2",
3
+ "version": "1.11.0",
4
4
  "description": "UI Components to support linking platform dataset feature",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -45,7 +45,7 @@
45
45
  "@atlaskit/jql-ast": "^3.0.0",
46
46
  "@atlaskit/jql-editor-autocomplete-rest": "^2.0.0",
47
47
  "@atlaskit/link-client-extension": "^1.8.0",
48
- "@atlaskit/linking-common": "^4.12.0",
48
+ "@atlaskit/linking-common": "^4.13.0",
49
49
  "@atlaskit/linking-types": "^8.4.0",
50
50
  "@atlaskit/lozenge": "^11.4.0",
51
51
  "@atlaskit/modal-dialog": "^12.8.0",
@@ -56,7 +56,7 @@
56
56
  "@atlaskit/pragmatic-drag-and-drop-react-indicator": "^0.16.0",
57
57
  "@atlaskit/primitives": "^1.8.0",
58
58
  "@atlaskit/select": "^16.7.0",
59
- "@atlaskit/smart-card": "^26.40.0",
59
+ "@atlaskit/smart-card": "^26.41.0",
60
60
  "@atlaskit/spinner": "^15.6.0",
61
61
  "@atlaskit/tag": "^11.6.0",
62
62
  "@atlaskit/textfield": "5.6.8",