@atlaskit/link-datasource 0.21.2 → 0.22.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 (39) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/hooks/useDatasourceTableState.js +14 -7
  3. package/dist/cjs/ui/common/error-state/loading-error-svg.js +87 -0
  4. package/dist/cjs/ui/common/error-state/loading-error.js +49 -0
  5. package/dist/cjs/ui/common/error-state/messages.js +45 -0
  6. package/dist/cjs/ui/common/error-state/modal-loading-error.js +54 -0
  7. package/dist/cjs/ui/common/error-state/no-results.js +168 -0
  8. package/dist/cjs/ui/datasource-table-view/datasourceTableView.js +12 -0
  9. package/dist/cjs/ui/jira-issues-modal/modal/index.js +46 -24
  10. package/dist/cjs/version.json +1 -1
  11. package/dist/es2019/hooks/useDatasourceTableState.js +24 -20
  12. package/dist/es2019/ui/common/error-state/loading-error-svg.js +77 -0
  13. package/dist/es2019/ui/common/error-state/loading-error.js +41 -0
  14. package/dist/es2019/ui/common/error-state/messages.js +38 -0
  15. package/dist/es2019/ui/common/error-state/modal-loading-error.js +44 -0
  16. package/dist/es2019/ui/common/error-state/no-results.js +160 -0
  17. package/dist/es2019/ui/datasource-table-view/datasourceTableView.js +12 -0
  18. package/dist/es2019/ui/jira-issues-modal/modal/index.js +43 -21
  19. package/dist/es2019/version.json +1 -1
  20. package/dist/esm/hooks/useDatasourceTableState.js +14 -7
  21. package/dist/esm/ui/common/error-state/loading-error-svg.js +79 -0
  22. package/dist/esm/ui/common/error-state/loading-error.js +40 -0
  23. package/dist/esm/ui/common/error-state/messages.js +38 -0
  24. package/dist/esm/ui/common/error-state/modal-loading-error.js +45 -0
  25. package/dist/esm/ui/common/error-state/no-results.js +159 -0
  26. package/dist/esm/ui/datasource-table-view/datasourceTableView.js +12 -0
  27. package/dist/esm/ui/jira-issues-modal/modal/index.js +46 -24
  28. package/dist/esm/version.json +1 -1
  29. package/dist/types/ui/common/error-state/loading-error-svg.d.ts +2 -0
  30. package/dist/types/ui/common/error-state/loading-error.d.ts +7 -0
  31. package/dist/types/ui/common/error-state/messages.d.ts +37 -0
  32. package/dist/types/ui/common/error-state/modal-loading-error.d.ts +7 -0
  33. package/dist/types/ui/common/error-state/no-results.d.ts +7 -0
  34. package/dist/types-ts4.5/ui/common/error-state/loading-error-svg.d.ts +2 -0
  35. package/dist/types-ts4.5/ui/common/error-state/loading-error.d.ts +7 -0
  36. package/dist/types-ts4.5/ui/common/error-state/messages.d.ts +37 -0
  37. package/dist/types-ts4.5/ui/common/error-state/modal-loading-error.d.ts +7 -0
  38. package/dist/types-ts4.5/ui/common/error-state/no-results.d.ts +7 -0
  39. package/package.json +1 -1
@@ -11,6 +11,8 @@ import Modal, { ModalBody, ModalFooter, ModalHeader, ModalTitle, ModalTransition
11
11
  import { B400, N0, N800 } from '@atlaskit/theme/colors';
12
12
  import { useDatasourceTableState } from '../../../hooks/useDatasourceTableState';
13
13
  import { getAvailableJiraSites } from '../../../services/getAvailableJiraSites';
14
+ import { ModalLoadingError } from '../../common/error-state/modal-loading-error';
15
+ import { NoResults } from '../../common/error-state/no-results';
14
16
  import { EmptyState, IssueLikeDataTableView } from '../../issue-like-table';
15
17
  import LinkRenderType from '../../issue-like-table/render-type/link';
16
18
  import { JiraSearchContainer } from '../jira-search-container';
@@ -22,6 +24,7 @@ var dropdownContainerStyles = css({
22
24
  gap: "var(--ds-space-100, 0.5rem)"
23
25
  });
24
26
  var contentContainerStyles = css({
27
+ display: 'grid',
25
28
  height: '420px',
26
29
  overflow: 'auto'
27
30
  });
@@ -37,6 +40,9 @@ var issueCountStyles = css({
37
40
  flex: 1,
38
41
  fontWeight: 600
39
42
  });
43
+ var smartLinkContainerStyles = css({
44
+ paddingLeft: '1px'
45
+ });
40
46
  export var JiraIssuesConfigModal = function JiraIssuesConfigModal(props) {
41
47
  var datasourceId = props.datasourceId,
42
48
  initialParameters = props.parameters,
@@ -84,12 +90,21 @@ export var JiraIssuesConfigModal = function JiraIssuesConfigModal(props) {
84
90
  defaultVisibleColumnKeys = _useDatasourceTableSt.defaultVisibleColumnKeys,
85
91
  loadDatasourceDetails = _useDatasourceTableSt.loadDatasourceDetails,
86
92
  totalCount = _useDatasourceTableSt.totalCount;
93
+ var _useIntl = useIntl(),
94
+ formatMessage = _useIntl.formatMessage;
95
+ var selectedJiraSite = useMemo(function () {
96
+ return availableSites.find(function (jiraSite) {
97
+ return jiraSite.cloudId === cloudId;
98
+ }) || availableSites[0];
99
+ }, [availableSites, cloudId]);
100
+ var resolvedWithNoResults = status === 'resolved' && !responseItems.length;
101
+ var jqlUrl = selectedJiraSite && jql && "".concat(selectedJiraSite.url, "/issues/?jql=").concat(encodeURI(jql));
102
+ var isDisabled = !isParametersSet || status === 'rejected' || status === 'loading' || resolvedWithNoResults;
103
+ var shouldShowIssueCount = !!totalCount && totalCount !== 1 && currentViewMode === 'issue';
87
104
  useEffect(function () {
88
105
  var newVisibleColumnKeys = !initialVisibleColumnKeys || (initialVisibleColumnKeys || []).length === 0 ? defaultVisibleColumnKeys : initialVisibleColumnKeys;
89
106
  setVisibleColumnKeys(newVisibleColumnKeys);
90
107
  }, [initialVisibleColumnKeys, defaultVisibleColumnKeys]);
91
- var _useIntl = useIntl(),
92
- formatMessage = _useIntl.formatMessage;
93
108
  useEffect(function () {
94
109
  var fetchSiteDisplayNames = /*#__PURE__*/function () {
95
110
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
@@ -114,6 +129,11 @@ export var JiraIssuesConfigModal = function JiraIssuesConfigModal(props) {
114
129
  }();
115
130
  void fetchSiteDisplayNames();
116
131
  }, []);
132
+ useEffect(function () {
133
+ if (!cloudId && selectedJiraSite) {
134
+ setCloudId(selectedJiraSite.cloudId);
135
+ }
136
+ }, [cloudId, selectedJiraSite]);
117
137
  var onSearch = useCallback(function (newParameters) {
118
138
  setJql(newParameters.jql);
119
139
  reset();
@@ -122,16 +142,6 @@ export var JiraIssuesConfigModal = function JiraIssuesConfigModal(props) {
122
142
  setCloudId(site.cloudId);
123
143
  reset();
124
144
  }, [reset]);
125
- var selectedJiraSite = useMemo(function () {
126
- return availableSites.find(function (jiraSite) {
127
- return jiraSite.cloudId === cloudId;
128
- }) || availableSites[0];
129
- }, [availableSites, cloudId]);
130
- useEffect(function () {
131
- if (!cloudId && selectedJiraSite) {
132
- setCloudId(selectedJiraSite.cloudId);
133
- }
134
- }, [cloudId, selectedJiraSite]);
135
145
  var retrieveUrlForSmartCardRender = useCallback(function () {
136
146
  var _data$key, _data$key$data;
137
147
  var _responseItems = _slicedToArray(responseItems, 1),
@@ -148,7 +158,7 @@ export var JiraIssuesConfigModal = function JiraIssuesConfigModal(props) {
148
158
  onInsert({
149
159
  type: 'inlineCard',
150
160
  attrs: {
151
- url: "".concat(selectedJiraSite.url, "/issues/?jql=").concat(encodeURI(jql))
161
+ url: jqlUrl
152
162
  }
153
163
  });
154
164
  } else if (responseItems.length === 1 && firstIssueUrl) {
@@ -179,7 +189,7 @@ export var JiraIssuesConfigModal = function JiraIssuesConfigModal(props) {
179
189
  }
180
190
  });
181
191
  }
182
- }, [isParametersSet, jql, selectedJiraSite, retrieveUrlForSmartCardRender, currentViewMode, responseItems.length, onInsert, datasourceId, cloudId, visibleColumnKeys]);
192
+ }, [isParametersSet, jql, jqlUrl, selectedJiraSite, retrieveUrlForSmartCardRender, currentViewMode, responseItems.length, onInsert, datasourceId, cloudId, visibleColumnKeys]);
183
193
  var handleViewModeChange = function handleViewModeChange(selectedMode) {
184
194
  setCurrentViewMode(selectedMode);
185
195
  };
@@ -199,31 +209,43 @@ export var JiraIssuesConfigModal = function JiraIssuesConfigModal(props) {
199
209
  var renderCountModeContent = useCallback(function () {
200
210
  var url = selectedJiraSite === null || selectedJiraSite === void 0 ? void 0 : selectedJiraSite.url;
201
211
  if (status === 'empty' || !jql || !url) {
202
- return jsx("span", {
212
+ return jsx("div", {
213
+ css: smartLinkContainerStyles
214
+ }, jsx("span", {
203
215
  "data-testid": "jira-jql-datasource-modal--smart-card-placeholder",
204
216
  css: placeholderSmartLinkStyles
205
- }, jsx(FormattedMessage, modalMessages.issuesCountSmartCardPlaceholderText));
217
+ }, jsx(FormattedMessage, modalMessages.issuesCountSmartCardPlaceholderText)));
206
218
  } else {
207
219
  var urlWithEncodedJql = "".concat(url, "/issues/?jql=").concat(encodeURI(jql));
208
- return jsx(LinkRenderType, {
220
+ return jsx("div", {
221
+ css: smartLinkContainerStyles
222
+ }, jsx(LinkRenderType, {
209
223
  url: urlWithEncodedJql
210
- });
224
+ }));
211
225
  }
212
226
  }, [jql, selectedJiraSite === null || selectedJiraSite === void 0 ? void 0 : selectedJiraSite.url, status]);
213
227
  var renderIssuesModeContent = useCallback(function () {
214
- if (status === 'empty' || columns.length === 0) {
228
+ if (status === 'empty') {
215
229
  return jsx(EmptyState, {
216
230
  testId: "jira-jql-datasource-modal--empty-state"
217
231
  });
232
+ } else if (resolvedWithNoResults) {
233
+ return jsx(NoResults, null);
234
+ } else if (status === 'rejected' && jqlUrl) {
235
+ return jsx(ModalLoadingError, {
236
+ url: jqlUrl
237
+ });
218
238
  }
219
239
  var firstIssueUrl = retrieveUrlForSmartCardRender();
220
240
  if (responseItems.length === 1 && firstIssueUrl) {
221
- return jsx(LinkRenderType, {
241
+ return jsx("div", {
242
+ css: smartLinkContainerStyles
243
+ }, jsx(LinkRenderType, {
222
244
  url: firstIssueUrl
223
- });
245
+ }));
224
246
  }
225
247
  return issueLikeDataTableView;
226
- }, [columns.length, issueLikeDataTableView, responseItems.length, retrieveUrlForSmartCardRender, status]);
248
+ }, [issueLikeDataTableView, jqlUrl, responseItems.length, resolvedWithNoResults, retrieveUrlForSmartCardRender, status]);
227
249
  return jsx(IntlProvider, {
228
250
  locale: "en"
229
251
  }, jsx(ModalTransition, null, jsx(Modal, {
@@ -258,7 +280,7 @@ export var JiraIssuesConfigModal = function JiraIssuesConfigModal(props) {
258
280
  onSearch: onSearch
259
281
  }), jsx("div", {
260
282
  css: contentContainerStyles
261
- }, currentViewMode === 'count' ? renderCountModeContent() : renderIssuesModeContent())), jsx(ModalFooter, null, !!totalCount && currentViewMode === 'issue' && jsx("div", {
283
+ }, currentViewMode === 'count' ? renderCountModeContent() : renderIssuesModeContent())), jsx(ModalFooter, null, shouldShowIssueCount && jsx("div", {
262
284
  "data-testid": "jira-jql-datasource-modal-total-issues-count",
263
285
  css: issueCountStyles
264
286
  }, jsx(FormattedNumber, {
@@ -273,7 +295,7 @@ export var JiraIssuesConfigModal = function JiraIssuesConfigModal(props) {
273
295
  }, jsx(FormattedMessage, modalMessages.cancelButtonText)), jsx(Button, {
274
296
  appearance: "primary",
275
297
  onClick: onInsertPressed,
276
- isDisabled: !isParametersSet || status === 'loading',
298
+ isDisabled: isDisabled,
277
299
  testId: 'jira-jql-datasource-modal--insert-button'
278
300
  }, jsx(FormattedMessage, modalMessages.insertIssuesButtonText))))));
279
301
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/link-datasource",
3
- "version": "0.21.2",
3
+ "version": "0.22.0",
4
4
  "sideEffects": false
5
5
  }
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const LoadingErrorSVG: () => JSX.Element;
@@ -0,0 +1,7 @@
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
3
+ interface LoadingErrorProps {
4
+ onRefresh?: () => void;
5
+ }
6
+ export declare const LoadingError: ({ onRefresh }: LoadingErrorProps) => jsx.JSX.Element;
7
+ export {};
@@ -0,0 +1,37 @@
1
+ export declare const loadingErrorMessages: {
2
+ checkConnection: {
3
+ id: string;
4
+ description: string;
5
+ defaultMessage: string;
6
+ };
7
+ checkConnectionWithSource: {
8
+ id: string;
9
+ description: string;
10
+ defaultMessage: string;
11
+ };
12
+ noResultsFound: {
13
+ id: string;
14
+ description: string;
15
+ defaultMessage: string;
16
+ };
17
+ openInProject: {
18
+ id: string;
19
+ description: string;
20
+ defaultMessage: string;
21
+ };
22
+ refresh: {
23
+ id: string;
24
+ description: string;
25
+ defaultMessage: string;
26
+ };
27
+ unableToLoadIssues: {
28
+ id: string;
29
+ description: string;
30
+ defaultMessage: string;
31
+ };
32
+ unableToLoadResults: {
33
+ id: string;
34
+ description: string;
35
+ defaultMessage: string;
36
+ };
37
+ };
@@ -0,0 +1,7 @@
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
3
+ interface ModalLoadingErrorProps {
4
+ url: string;
5
+ }
6
+ export declare const ModalLoadingError: ({ url }: ModalLoadingErrorProps) => jsx.JSX.Element;
7
+ export {};
@@ -0,0 +1,7 @@
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
3
+ interface NoResultsProps {
4
+ onRefresh?: () => void;
5
+ }
6
+ export declare const NoResults: ({ onRefresh }: NoResultsProps) => jsx.JSX.Element;
7
+ export {};
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const LoadingErrorSVG: () => JSX.Element;
@@ -0,0 +1,7 @@
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
3
+ interface LoadingErrorProps {
4
+ onRefresh?: () => void;
5
+ }
6
+ export declare const LoadingError: ({ onRefresh }: LoadingErrorProps) => jsx.JSX.Element;
7
+ export {};
@@ -0,0 +1,37 @@
1
+ export declare const loadingErrorMessages: {
2
+ checkConnection: {
3
+ id: string;
4
+ description: string;
5
+ defaultMessage: string;
6
+ };
7
+ checkConnectionWithSource: {
8
+ id: string;
9
+ description: string;
10
+ defaultMessage: string;
11
+ };
12
+ noResultsFound: {
13
+ id: string;
14
+ description: string;
15
+ defaultMessage: string;
16
+ };
17
+ openInProject: {
18
+ id: string;
19
+ description: string;
20
+ defaultMessage: string;
21
+ };
22
+ refresh: {
23
+ id: string;
24
+ description: string;
25
+ defaultMessage: string;
26
+ };
27
+ unableToLoadIssues: {
28
+ id: string;
29
+ description: string;
30
+ defaultMessage: string;
31
+ };
32
+ unableToLoadResults: {
33
+ id: string;
34
+ description: string;
35
+ defaultMessage: string;
36
+ };
37
+ };
@@ -0,0 +1,7 @@
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
3
+ interface ModalLoadingErrorProps {
4
+ url: string;
5
+ }
6
+ export declare const ModalLoadingError: ({ url }: ModalLoadingErrorProps) => jsx.JSX.Element;
7
+ export {};
@@ -0,0 +1,7 @@
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
3
+ interface NoResultsProps {
4
+ onRefresh?: () => void;
5
+ }
6
+ export declare const NoResults: ({ onRefresh }: NoResultsProps) => jsx.JSX.Element;
7
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/link-datasource",
3
- "version": "0.21.2",
3
+ "version": "0.22.0",
4
4
  "description": "UI Components to support linking platform dataset feature",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"