@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,13 +1,19 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  /** @jsx jsx */
3
- import { useCallback, useEffect, useMemo, useState } from 'react';
3
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
4
4
  import { css, jsx } from '@emotion/react';
5
5
  import { FormattedMessage } from 'react-intl-next';
6
+ import { v4 as uuidv4 } from 'uuid';
6
7
  import { withAnalyticsContext } from '@atlaskit/analytics-next';
7
8
  import Button from '@atlaskit/button/standard-button';
8
9
  import { IntlMessagesProvider } from '@atlaskit/intl-messages-provider';
9
10
  import Modal, { ModalBody, ModalFooter, ModalHeader, ModalTitle, ModalTransition } from '@atlaskit/modal-dialog';
10
- import { useDatasourceAnalyticsEvents } from '../../../analytics';
11
+ import { EVENT_CHANNEL, useDatasourceAnalyticsEvents } from '../../../analytics';
12
+ import { packageMetaData } from '../../../analytics/constants';
13
+ import { DatasourceAction, DatasourceDisplay, DatasourceSearchMethod } from '../../../analytics/types';
14
+ import { startUfoExperience } from '../../../analytics/ufoExperiences';
15
+ import { useColumnPickerRenderedFailedUfoExperience } from '../../../analytics/ufoExperiences/hooks/useColumnPickerRenderedFailedUfoExperience';
16
+ import { useDataRenderedUfoExperience } from '../../../analytics/ufoExperiences/hooks/useDataRenderedUfoExperience';
11
17
  import { fetchMessagesForLocale } from '../../../common/utils/locale/fetch-messages-for-locale';
12
18
  import { useAssetsClient } from '../../../hooks/useAssetsClient';
13
19
  import { useDatasourceTableState } from '../../../hooks/useDatasourceTableState';
@@ -38,6 +44,9 @@ const PlainAssetsConfigModal = props => {
38
44
  const {
39
45
  fireEvent
40
46
  } = useDatasourceAnalyticsEvents();
47
+ const {
48
+ current: modalRenderInstanceId
49
+ } = useRef(uuidv4());
41
50
 
42
51
  // If a workspaceError occurs this is a critical error
43
52
  const {
@@ -60,18 +69,74 @@ const PlainAssetsConfigModal = props => {
60
69
  loadDatasourceDetails,
61
70
  hasNextPage,
62
71
  columns,
63
- defaultVisibleColumnKeys
72
+ defaultVisibleColumnKeys,
73
+ extensionKey = null,
74
+ destinationObjectTypes,
75
+ totalCount
64
76
  } = useDatasourceTableState({
65
77
  datasourceId,
66
78
  parameters: isParametersSet ? parameters : undefined,
67
79
  fieldKeys: isNewSearch ? [] : visibleColumnKeys
68
80
  });
81
+
82
+ /* ------------------------------ OBSERVABILITY ------------------------------ */
83
+ const searchCount = useRef(0);
84
+ const userInteractionActions = useRef(new Set());
85
+ const visibleColumnCount = useRef((visibleColumnKeys === null || visibleColumnKeys === void 0 ? void 0 : visibleColumnKeys.length) || 0);
86
+ const isDataReady = (visibleColumnKeys || []).length > 0;
87
+ const analyticsPayload = useMemo(() => {
88
+ return {
89
+ extensionKey: extensionKey,
90
+ destinationObjectTypes: destinationObjectTypes
91
+ };
92
+ }, [destinationObjectTypes, extensionKey]);
93
+ useEffect(() => {
94
+ fireEvent('screen.datasourceModalDialog.viewed', {});
95
+ }, [fireEvent]);
96
+ const fireTableViewedEvent = useCallback(() => {
97
+ if (isDataReady) {
98
+ fireEvent('ui.table.viewed.datasourceConfigModal', {
99
+ ...analyticsPayload,
100
+ totalItemCount: totalCount || 0,
101
+ searchMethod: DatasourceSearchMethod.DATASOURCE_SEARCH_QUERY,
102
+ displayedColumnCount: visibleColumnCount.current
103
+ });
104
+ }
105
+ }, [analyticsPayload, fireEvent, totalCount, isDataReady]);
106
+ useEffect(() => {
107
+ const isResolved = status === 'resolved';
108
+ if (!isResolved || !totalCount) {
109
+ return;
110
+ }
111
+ if (totalCount > 1) {
112
+ fireTableViewedEvent();
113
+ }
114
+ }, [fireTableViewedEvent, status, totalCount]);
115
+ useEffect(() => {
116
+ const shouldStartUfoExperience = status === 'loading';
117
+ if (shouldStartUfoExperience) {
118
+ startUfoExperience({
119
+ name: 'datasource-rendered'
120
+ }, modalRenderInstanceId);
121
+ }
122
+ }, [modalRenderInstanceId, status]);
123
+ useDataRenderedUfoExperience({
124
+ status,
125
+ experienceId: modalRenderInstanceId,
126
+ itemCount: responseItems.length,
127
+ canBeLink: false,
128
+ extensionKey
129
+ });
130
+ useColumnPickerRenderedFailedUfoExperience(status, modalRenderInstanceId);
131
+ /* ------------------------------ END OBSERVABILITY ------------------------------ */
132
+
69
133
  const onVisibleColumnKeysChange = useCallback(visibleColumnKeys => {
70
134
  setVisibleColumnKeys(visibleColumnKeys);
71
135
  setIsNewSearch(false);
72
136
  }, []);
73
137
  useEffect(() => {
74
138
  const newVisibleColumnKeys = !initialVisibleColumnKeys || (initialVisibleColumnKeys || []).length === 0 ? defaultVisibleColumnKeys : initialVisibleColumnKeys;
139
+ visibleColumnCount.current = newVisibleColumnKeys.length;
75
140
  setVisibleColumnKeys(newVisibleColumnKeys);
76
141
  }, [initialVisibleColumnKeys, defaultVisibleColumnKeys]);
77
142
  useEffect(() => {
@@ -79,20 +144,33 @@ const PlainAssetsConfigModal = props => {
79
144
  setVisibleColumnKeys(defaultVisibleColumnKeys);
80
145
  }
81
146
  }, [defaultVisibleColumnKeys, isNewSearch]);
82
- useEffect(() => {
83
- fireEvent('screen.datasourceModalDialog.viewed', {});
84
- }, [fireEvent]);
85
- const isDisabled = !!workspaceError || status === 'rejected' || status === 'loading' || status === 'empty' || !!workspaceError || assetsClientLoading || !aql || !schemaId;
147
+ const isDisabled = !!workspaceError || status === 'rejected' || status === 'loading' || status === 'empty' || assetsClientLoading || !aql || !schemaId;
86
148
  const retrieveUrlForSmartCardRender = useCallback(() => {
87
149
  var _data$key, _data$key$data;
88
150
  const [data] = responseItems;
89
151
  // agreement with BE that we will use `key` for rendering smartlink
90
152
  return data === null || data === void 0 ? void 0 : (_data$key = data.key) === null || _data$key === void 0 ? void 0 : (_data$key$data = _data$key.data) === null || _data$key$data === void 0 ? void 0 : _data$key$data.url;
91
153
  }, [responseItems]);
92
- const onInsertPressed = useCallback(() => {
154
+ const onInsertPressed = useCallback((e, analyticsEvent) => {
155
+ var _insertButtonClickedE;
93
156
  if (!aql || !schemaId || !workspaceId) {
94
157
  return;
95
158
  }
159
+ const insertButtonClickedEvent = analyticsEvent.update({
160
+ actionSubjectId: 'insert',
161
+ attributes: {
162
+ ...analyticsPayload,
163
+ totalItemCount: totalCount || 0,
164
+ displayedColumnCount: visibleColumnCount.current,
165
+ display: DatasourceDisplay.DATASOURCE_TABLE,
166
+ searchCount: searchCount.current,
167
+ searchMethod: DatasourceSearchMethod.DATASOURCE_SEARCH_QUERY,
168
+ actions: Array.from(userInteractionActions.current)
169
+ },
170
+ eventType: 'ui'
171
+ });
172
+ const consumerEvent = (_insertButtonClickedE = insertButtonClickedEvent.clone()) !== null && _insertButtonClickedE !== void 0 ? _insertButtonClickedE : undefined;
173
+ insertButtonClickedEvent.fire(EVENT_CHANNEL);
96
174
  const firstAssetUrl = retrieveUrlForSmartCardRender();
97
175
  if (responseItems.length === 1 && firstAssetUrl) {
98
176
  onInsert({
@@ -100,7 +178,7 @@ const PlainAssetsConfigModal = props => {
100
178
  attrs: {
101
179
  url: firstAssetUrl
102
180
  }
103
- });
181
+ }, consumerEvent);
104
182
  } else {
105
183
  onInsert({
106
184
  type: 'blockCard',
@@ -122,11 +200,30 @@ const PlainAssetsConfigModal = props => {
122
200
  }]
123
201
  }
124
202
  }
125
- });
203
+ }, consumerEvent);
126
204
  }
127
- }, [aql, schemaId, workspaceId, retrieveUrlForSmartCardRender, responseItems.length, onInsert, datasourceId, visibleColumnKeys]);
205
+ }, [aql, schemaId, workspaceId, analyticsPayload, totalCount, retrieveUrlForSmartCardRender, responseItems.length, onInsert, datasourceId, visibleColumnKeys]);
206
+ const onCancelClick = useCallback((e, analyticEvent) => {
207
+ analyticEvent.update({
208
+ eventType: 'ui',
209
+ actionSubjectId: 'cancel',
210
+ attributes: {
211
+ ...analyticsPayload,
212
+ searchCount: searchCount.current,
213
+ actions: Array.from(userInteractionActions.current)
214
+ }
215
+ }).fire(EVENT_CHANNEL);
216
+ onCancel();
217
+ }, [analyticsPayload, onCancel]);
128
218
  const handleOnSearch = useCallback(async (searchAql, searchSchemaId) => {
129
219
  if (schemaId !== searchSchemaId || aql !== searchAql) {
220
+ searchCount.current++;
221
+ if (schemaId !== searchSchemaId) {
222
+ userInteractionActions.current.add(DatasourceAction.SCHEMA_UPDATED);
223
+ }
224
+ if (aql !== searchAql) {
225
+ userInteractionActions.current.add(DatasourceAction.QUERY_UPDATED);
226
+ }
130
227
  reset({
131
228
  shouldResetColumns: true
132
229
  });
@@ -179,10 +276,11 @@ const PlainAssetsConfigModal = props => {
179
276
  hasNextPage: hasNextPage,
180
277
  loadDatasourceDetails: loadDatasourceDetails,
181
278
  columns: columns,
182
- defaultVisibleColumnKeys: defaultVisibleColumnKeys
279
+ defaultVisibleColumnKeys: defaultVisibleColumnKeys,
280
+ modalRenderInstanceId: modalRenderInstanceId
183
281
  }))), jsx(ModalFooter, null, jsx(Button, {
184
282
  appearance: "default",
185
- onClick: onCancel,
283
+ onClick: onCancelClick,
186
284
  testId: 'asset-datasource-modal--cancel-button'
187
285
  }, jsx(FormattedMessage, modalMessages.cancelButtonText)), jsx(Button, {
188
286
  appearance: "primary",
@@ -199,8 +297,7 @@ const analyticsContextAttributes = {
199
297
  dataProvider: 'jsm-assets'
200
298
  };
201
299
  const analyticsContextData = {
202
- packageName: "@atlaskit/link-datasource",
203
- packageVersion: "1.10.2",
300
+ ...packageMetaData,
204
301
  source: 'datasourceConfigModal'
205
302
  };
206
303
  const contextData = {
@@ -13,7 +13,8 @@ export const RenderAssetsContent = props => {
13
13
  loadDatasourceDetails,
14
14
  columns,
15
15
  defaultVisibleColumnKeys,
16
- onVisibleColumnKeysChange
16
+ onVisibleColumnKeysChange,
17
+ modalRenderInstanceId
17
18
  } = props;
18
19
  const resolvedWithNoResults = status === 'resolved' && !responseItems.length;
19
20
  const issueLikeDataTableView = useMemo(() => /*#__PURE__*/React.createElement(IssueLikeDataTableView, {
@@ -25,8 +26,9 @@ export const RenderAssetsContent = props => {
25
26
  visibleColumnKeys: visibleColumnKeys || defaultVisibleColumnKeys,
26
27
  onNextPage: onNextPage,
27
28
  onLoadDatasourceDetails: loadDatasourceDetails,
28
- onVisibleColumnKeysChange: onVisibleColumnKeysChange
29
- }), [columns, defaultVisibleColumnKeys, hasNextPage, loadDatasourceDetails, onNextPage, onVisibleColumnKeysChange, responseItems, status, visibleColumnKeys]);
29
+ onVisibleColumnKeysChange: onVisibleColumnKeysChange,
30
+ parentContainerRenderInstanceId: modalRenderInstanceId
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';
@@ -15,12 +16,16 @@ export const AssetsSearchContainer = props => {
15
16
  modalTitle,
16
17
  isSearching
17
18
  } = props;
19
+ const {
20
+ fireEvent
21
+ } = useDatasourceAnalyticsEvents();
18
22
  const onFormSubmit = searchFormValues => {
19
23
  const {
20
24
  aql,
21
25
  objectSchema
22
26
  } = searchFormValues;
23
27
  if (objectSchema) {
28
+ fireEvent('ui.aqlEditor.searched', {});
24
29
  // Pass the validated aql and object schema back to modal
25
30
  onSearch(aql, objectSchema.value);
26
31
  }
@@ -1,18 +1,23 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  /** @jsx jsx */
3
3
 
4
+ import { useEffect, useState } from 'react';
4
5
  import { jsx } from '@emotion/react';
5
6
  import debounce from 'debounce-promise';
6
7
  import { useIntl } from 'react-intl-next';
7
8
  import { Field } from '@atlaskit/form';
8
9
  import { AsyncSelect } from '@atlaskit/select';
9
10
  import { layers } from '@atlaskit/theme/constants';
11
+ import { useDatasourceAnalyticsEvents } from '../../../../analytics';
10
12
  import { useObjectSchemas } from '../../../../hooks/useObjectSchemas';
11
13
  import { objectSchemaKey } from '../../../../types/assets/types';
12
14
  import { FieldContainer } from '../styled';
13
15
  import { objectSchemaSelectMessages } from './messages';
14
16
  import { objectSchemaToSelectOption } from './utils';
15
17
  export const SEARCH_DEBOUNCE_MS = 350;
18
+ const mapObjectSchemasToOptions = objectSchemas => {
19
+ return objectSchemas ? objectSchemas.map(objectSchema => objectSchemaToSelectOption(objectSchema)) : [];
20
+ };
16
21
 
17
22
  /**
18
23
  * Rendering a `<Select>` in a `<Modal>` results in the select options getting cut off by the bottom of the modal and
@@ -32,6 +37,10 @@ export const AssetsObjectSchemaSelect = ({
32
37
  workspaceId,
33
38
  classNamePrefix = 'assets-datasource-modal--object-schema-select'
34
39
  }) => {
40
+ const [defaultOptions, setDefaultOptions] = useState(null);
41
+ const {
42
+ fireEvent
43
+ } = useDatasourceAnalyticsEvents();
35
44
  const {
36
45
  formatMessage
37
46
  } = useIntl();
@@ -40,10 +49,29 @@ export const AssetsObjectSchemaSelect = ({
40
49
  objectSchemasLoading
41
50
  } = useObjectSchemas(workspaceId);
42
51
  const selectedObjectSchema = value ? objectSchemaToSelectOption(value) : undefined;
52
+ useEffect(() => {
53
+ const fetchInitialData = async () => {
54
+ const {
55
+ objectSchemas,
56
+ totalObjectSchemas
57
+ } = await fetchObjectSchemas('');
58
+ // We only want to send modal ready event once after we've fetched the schema count
59
+ fireEvent('ui.modal.ready.datasource', {
60
+ schemasCount: totalObjectSchemas !== null && totalObjectSchemas !== void 0 ? totalObjectSchemas : 0,
61
+ instancesCount: null
62
+ });
63
+ setDefaultOptions(mapObjectSchemasToOptions(objectSchemas));
64
+ };
65
+ if (defaultOptions === null) {
66
+ fetchInitialData();
67
+ }
68
+ // eslint-disable-next-line react-hooks/exhaustive-deps
69
+ }, []);
43
70
  const loadOptions = async inputValue => {
44
- const objectSchemas = await fetchObjectSchemas(inputValue);
45
- const options = objectSchemas ? objectSchemas.map(objectSchema => objectSchemaToSelectOption(objectSchema)) : [];
46
- return options;
71
+ const {
72
+ objectSchemas
73
+ } = await fetchObjectSchemas(inputValue);
74
+ return mapObjectSchemasToOptions(objectSchemas);
47
75
  };
48
76
  const debouncedLoadOptions = debounce(loadOptions, SEARCH_DEBOUNCE_MS);
49
77
  const validateSchema = value => {
@@ -66,8 +94,7 @@ export const AssetsObjectSchemaSelect = ({
66
94
  autoFocus: true,
67
95
  classNamePrefix: classNamePrefix,
68
96
  isLoading: objectSchemasLoading,
69
- defaultOptions: true // setting to true causes the loadOptions to be called on mount
70
- ,
97
+ defaultOptions: defaultOptions !== null && defaultOptions !== void 0 ? defaultOptions : [],
71
98
  isSearchable: true,
72
99
  loadOptions: debouncedLoadOptions,
73
100
  placeholder: formatMessage(objectSchemaSelectMessages.placeholder),
@@ -35,12 +35,19 @@ const LinkRenderType = ({
35
35
  "data-testid": testId,
36
36
  target: "_blank"
37
37
  }, text || url)), [linkStyle, url, text, testId]);
38
- const SmartCard = () => /*#__PURE__*/React.createElement(Card, {
39
- appearance: "inline",
40
- url: url,
41
- testId: testId,
42
- fallbackComponent: () => anchor
43
- });
38
+ const SmartCard = () => {
39
+ const handleClick = e => {
40
+ e.preventDefault();
41
+ window.open(url, '_blank', 'noopener, noreferrer');
42
+ };
43
+ return /*#__PURE__*/React.createElement(Card, {
44
+ appearance: "inline",
45
+ onClick: handleClick,
46
+ url: url,
47
+ testId: testId,
48
+ fallbackComponent: () => anchor
49
+ });
50
+ };
44
51
 
45
52
  // url can be undefined before data is fetched whilst adding new link column to display
46
53
  if (!url) {
@@ -179,7 +179,8 @@ export const PlainJiraIssuesConfigModal = props => {
179
179
  const sortedAvailableSites = [...jiraSites].sort((a, b) => a.displayName.localeCompare(b.displayName));
180
180
  setAvailableSites(sortedAvailableSites);
181
181
  fireEvent('ui.modal.ready.datasource', {
182
- instancesCount: sortedAvailableSites.length
182
+ instancesCount: sortedAvailableSites.length,
183
+ schemasCount: null
183
184
  });
184
185
  };
185
186
  void fetchSiteDisplayNames();
@@ -1,5 +1,5 @@
1
1
  export var EVENT_CHANNEL = 'media';
2
2
  export var packageMetaData = {
3
3
  packageName: "@atlaskit/link-datasource",
4
- packageVersion: "1.10.2"
4
+ packageVersion: "1.11.0"
5
5
  };
@@ -6,6 +6,7 @@ export var DatasourceAction = /*#__PURE__*/function (DatasourceAction) {
6
6
  DatasourceAction["QUERY_UPDATED"] = "query updated";
7
7
  DatasourceAction["DISPLAY_VIEW_CHANGED"] = "display view changed";
8
8
  DatasourceAction["NEXT_PAGE_SCROLLED"] = "next page scrolled";
9
+ DatasourceAction["SCHEMA_UPDATED"] = "schema updated";
9
10
  return DatasourceAction;
10
11
  }({});
11
12
  export var DatasourceDisplay = /*#__PURE__*/function (DatasourceDisplay) {
@@ -14,11 +14,15 @@ export var useObjectSchemas = function useObjectSchemas(workspaceId) {
14
14
  setObjectSchemas = _useState4[1];
15
15
  var _useState5 = useState(),
16
16
  _useState6 = _slicedToArray(_useState5, 2),
17
- error = _useState6[0],
18
- setError = _useState6[1];
17
+ totalObjectSchemas = _useState6[0],
18
+ setTotalObjectSchemas = _useState6[1];
19
+ var _useState7 = useState(),
20
+ _useState8 = _slicedToArray(_useState7, 2),
21
+ error = _useState8[0],
22
+ setError = _useState8[1];
19
23
  var request = useCallback( /*#__PURE__*/function () {
20
24
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(query) {
21
- var fetchedObjectSchemas, fetchedObjectSchemasResponse;
25
+ var fetchedObjectSchemas, fetchTotalObjectSchemas, fetchedObjectSchemasResponse;
22
26
  return _regeneratorRuntime.wrap(function _callee$(_context) {
23
27
  while (1) switch (_context.prev = _context.next) {
24
28
  case 0:
@@ -30,28 +34,33 @@ export var useObjectSchemas = function useObjectSchemas(workspaceId) {
30
34
  case 5:
31
35
  fetchedObjectSchemasResponse = _context.sent;
32
36
  setObjectSchemas(fetchedObjectSchemasResponse.values);
37
+ setTotalObjectSchemas(fetchedObjectSchemasResponse.total);
33
38
  fetchedObjectSchemas = fetchedObjectSchemasResponse.values;
34
- _context.next = 13;
39
+ fetchTotalObjectSchemas = fetchedObjectSchemasResponse.total;
40
+ _context.next = 15;
35
41
  break;
36
- case 10:
37
- _context.prev = 10;
42
+ case 12:
43
+ _context.prev = 12;
38
44
  _context.t0 = _context["catch"](2);
39
45
  if (_context.t0 instanceof Error) {
40
46
  setError(_context.t0);
41
47
  } else {
42
48
  setError(new Error('Unexpected error occured'));
43
49
  }
44
- case 13:
45
- _context.prev = 13;
50
+ case 15:
51
+ _context.prev = 15;
46
52
  setLoading(false);
47
- return _context.finish(13);
48
- case 16:
49
- return _context.abrupt("return", fetchedObjectSchemas);
50
- case 17:
53
+ return _context.finish(15);
54
+ case 18:
55
+ return _context.abrupt("return", {
56
+ objectSchemas: fetchedObjectSchemas,
57
+ totalObjectSchemas: fetchTotalObjectSchemas
58
+ });
59
+ case 19:
51
60
  case "end":
52
61
  return _context.stop();
53
62
  }
54
- }, _callee, null, [[2, 10, 13, 16]]);
63
+ }, _callee, null, [[2, 12, 15, 18]]);
55
64
  }));
56
65
  return function (_x) {
57
66
  return _ref.apply(this, arguments);
@@ -61,6 +70,7 @@ export var useObjectSchemas = function useObjectSchemas(workspaceId) {
61
70
  objectSchemasLoading: loading,
62
71
  objectSchemasError: error,
63
72
  objectSchemas: objectSchemas,
73
+ totalObjectSchemas: totalObjectSchemas,
64
74
  fetchObjectSchemas: request
65
75
  };
66
76
  };