@atlaskit/link-datasource 2.8.0 → 2.9.1
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 +17 -0
- package/dist/cjs/hooks/useDatasourceTableState.js +54 -39
- package/dist/cjs/state/index.js +68 -0
- package/dist/cjs/ui/assets-modal/modal/index.js +8 -5
- package/dist/cjs/ui/common/modal/datasource-modal/createDatasourceModal.js +55 -0
- package/dist/cjs/ui/common/modal/datasources-table-in-modal-preview/index.js +13 -2
- package/dist/cjs/ui/common/modal/insert-button/index.js +5 -4
- package/dist/cjs/ui/confluence-search-modal/modal/index.js +36 -39
- package/dist/cjs/ui/datasource-table-view/datasourceTableView.js +3 -2
- package/dist/cjs/ui/jira-issues-modal/modal/index.js +142 -211
- package/dist/es2019/hooks/useDatasourceTableState.js +15 -5
- package/dist/es2019/state/index.js +55 -0
- package/dist/es2019/ui/assets-modal/modal/index.js +9 -6
- package/dist/es2019/ui/common/modal/datasource-context/index.js +1 -1
- package/dist/es2019/ui/common/modal/datasource-modal/createDatasourceModal.js +51 -0
- package/dist/es2019/ui/common/modal/datasources-table-in-modal-preview/index.js +9 -2
- package/dist/es2019/ui/common/modal/insert-button/index.js +5 -4
- package/dist/es2019/ui/confluence-search-modal/modal/index.js +36 -39
- package/dist/es2019/ui/datasource-table-view/datasourceTableView.js +4 -3
- package/dist/es2019/ui/jira-issues-modal/modal/index.js +134 -202
- package/dist/esm/hooks/useDatasourceTableState.js +54 -39
- package/dist/esm/state/index.js +61 -0
- package/dist/esm/ui/assets-modal/modal/index.js +9 -6
- package/dist/esm/ui/common/modal/datasource-modal/createDatasourceModal.js +48 -0
- package/dist/esm/ui/common/modal/datasources-table-in-modal-preview/index.js +10 -2
- package/dist/esm/ui/common/modal/insert-button/index.js +5 -4
- package/dist/esm/ui/confluence-search-modal/modal/index.js +39 -42
- package/dist/esm/ui/datasource-table-view/datasourceTableView.js +4 -3
- package/dist/esm/ui/jira-issues-modal/modal/index.js +147 -216
- package/dist/types/common/types.d.ts +2 -1
- package/dist/types/state/index.d.ts +21 -0
- package/dist/types/ui/common/modal/datasource-context/index.d.ts +9 -12
- package/dist/types/ui/common/modal/datasource-modal/createDatasourceModal.d.ts +15 -0
- package/dist/types/ui/common/modal/insert-button/index.d.ts +4 -2
- package/dist/types/ui/confluence-search-modal/basic-filters/filters/date-range-picker/PopupComponent.d.ts +1 -1
- package/dist/types/ui/confluence-search-modal/modal/index.d.ts +3 -4
- package/dist/types/ui/confluence-search-modal/types.d.ts +6 -1
- package/dist/types/ui/jira-issues-modal/modal/index.d.ts +3 -3
- package/dist/types/ui/jira-issues-modal/types.d.ts +3 -0
- package/dist/types-ts4.5/common/types.d.ts +2 -1
- package/dist/types-ts4.5/state/index.d.ts +21 -0
- package/dist/types-ts4.5/ui/common/modal/datasource-context/index.d.ts +9 -12
- package/dist/types-ts4.5/ui/common/modal/datasource-modal/createDatasourceModal.d.ts +15 -0
- package/dist/types-ts4.5/ui/common/modal/insert-button/index.d.ts +4 -2
- package/dist/types-ts4.5/ui/confluence-search-modal/basic-filters/filters/date-range-picker/PopupComponent.d.ts +1 -1
- package/dist/types-ts4.5/ui/confluence-search-modal/modal/index.d.ts +3 -4
- package/dist/types-ts4.5/ui/confluence-search-modal/types.d.ts +6 -1
- package/dist/types-ts4.5/ui/jira-issues-modal/modal/index.d.ts +3 -3
- package/dist/types-ts4.5/ui/jira-issues-modal/types.d.ts +3 -0
- package/package.json +5 -1
|
@@ -10,25 +10,23 @@ import { Fragment, useCallback, useEffect, useMemo, useRef, useState } from 'rea
|
|
|
10
10
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
11
11
|
import { jsx } from '@emotion/react';
|
|
12
12
|
import { FormattedMessage } from 'react-intl-next';
|
|
13
|
-
import {
|
|
14
|
-
import Button from '@atlaskit/button/standard-button';
|
|
13
|
+
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
15
14
|
import { IntlMessagesProvider } from '@atlaskit/intl-messages-provider';
|
|
16
15
|
import { ModalBody, ModalFooter, ModalHeader, ModalTitle, ModalTransition } from '@atlaskit/modal-dialog';
|
|
17
16
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
18
|
-
import {
|
|
19
|
-
import { componentMetadata } from '../../../analytics/constants';
|
|
17
|
+
import { useDatasourceAnalyticsEvents } from '../../../analytics';
|
|
18
|
+
import { componentMetadata, EVENT_CHANNEL } from '../../../analytics/constants';
|
|
20
19
|
import { DatasourceAction, DatasourceDisplay } from '../../../analytics/types';
|
|
21
20
|
import { startUfoExperience } from '../../../analytics/ufoExperiences';
|
|
22
21
|
import { useColumnPickerRenderedFailedUfoExperience } from '../../../analytics/ufoExperiences/hooks/useColumnPickerRenderedFailedUfoExperience';
|
|
23
22
|
import { useDataRenderedUfoExperience } from '../../../analytics/ufoExperiences/hooks/useDataRenderedUfoExperience';
|
|
24
23
|
import { mapSearchMethod } from '../../../analytics/utils';
|
|
25
|
-
import { buildDatasourceAdf } from '../../../common/utils/adf';
|
|
26
24
|
import { fetchMessagesForLocale } from '../../../common/utils/locale/fetch-messages-for-locale';
|
|
27
25
|
import { DatasourceExperienceIdProvider, useDatasourceExperienceId } from '../../../contexts/datasource-experience-id';
|
|
28
26
|
import { UserInteractionsProvider, useUserInteractions } from '../../../contexts/user-interactions';
|
|
29
|
-
import { useDatasourceTableState } from '../../../hooks/useDatasourceTableState';
|
|
30
27
|
import i18nEN from '../../../i18n/en';
|
|
31
28
|
import { useAvailableSites } from '../../../services/useAvailableSites';
|
|
29
|
+
import { StoreContainer } from '../../../state';
|
|
32
30
|
import { AccessRequired } from '../../common/error-state/access-required';
|
|
33
31
|
import { loadingErrorMessages } from '../../common/error-state/messages';
|
|
34
32
|
import { ModalLoadingError } from '../../common/error-state/modal-loading-error';
|
|
@@ -39,22 +37,22 @@ import { initialStateViewMessages } from '../../common/initial-state-view/messag
|
|
|
39
37
|
import { CancelButton } from '../../common/modal/cancel-button';
|
|
40
38
|
import { ContentContainer } from '../../common/modal/content-container';
|
|
41
39
|
import { SmartCardPlaceholder, SmartLink } from '../../common/modal/count-view-smart-link';
|
|
40
|
+
import { useDatasourceContext } from '../../common/modal/datasource-context';
|
|
42
41
|
import { DatasourceModal } from '../../common/modal/datasource-modal';
|
|
43
|
-
import {
|
|
44
|
-
import
|
|
42
|
+
import { createDatasourceModal } from '../../common/modal/datasource-modal/createDatasourceModal';
|
|
43
|
+
import DatasourcesTableInModalPreview from '../../common/modal/datasources-table-in-modal-preview';
|
|
44
|
+
import { InsertButton } from '../../common/modal/insert-button';
|
|
45
45
|
import { DatasourceViewModeDropDown } from '../../common/modal/mode-switcher';
|
|
46
|
-
import {
|
|
46
|
+
import { useViewModeContext } from '../../common/modal/mode-switcher/useViewModeContext';
|
|
47
47
|
import TableSearchCount from '../../common/modal/search-count';
|
|
48
48
|
import { SiteSelector } from '../../common/modal/site-selector';
|
|
49
|
-
import { EmptyState
|
|
50
|
-
import { getColumnAction } from '../../issue-like-table/utils';
|
|
49
|
+
import { EmptyState } from '../../issue-like-table';
|
|
51
50
|
import { availableBasicFilterTypes } from '../basic-filters/ui';
|
|
52
51
|
import { isQueryTooComplex } from '../basic-filters/utils/isQueryTooComplex';
|
|
53
52
|
import { JiraSearchContainer } from '../jira-search-container';
|
|
54
53
|
import { JiraInitialStateSVG } from './jira-issues-initial-state-svg';
|
|
55
54
|
import { modalMessages } from './messages';
|
|
56
55
|
import { PlainJiraIssuesConfigModalOld } from './ModalOld';
|
|
57
|
-
const DEFAULT_VIEW_MODE = 'table';
|
|
58
56
|
const getDisplayValue = (currentViewMode, itemCount) => {
|
|
59
57
|
if (currentViewMode === 'table') {
|
|
60
58
|
return DatasourceDisplay.DATASOURCE_TABLE;
|
|
@@ -62,70 +60,52 @@ const getDisplayValue = (currentViewMode, itemCount) => {
|
|
|
62
60
|
return itemCount === 1 ? DatasourceDisplay.INLINE : DatasourceDisplay.DATASOURCE_INLINE;
|
|
63
61
|
};
|
|
64
62
|
const jqlSupportDocumentLink = 'https://support.atlassian.com/jira-service-management-cloud/docs/use-advanced-search-with-jira-query-language-jql/';
|
|
63
|
+
const isValidParameters = parameters => typeof (parameters === null || parameters === void 0 ? void 0 : parameters.jql) === 'string' && parameters.jql.length > 0 && typeof (parameters === null || parameters === void 0 ? void 0 : parameters.cloudId) === 'string' && parameters.cloudId.length > 0;
|
|
65
64
|
const PlainJiraIssuesConfigModal = props => {
|
|
66
65
|
const {
|
|
67
|
-
datasourceId,
|
|
68
|
-
columnCustomSizes: initialColumnCustomSizes,
|
|
69
|
-
wrappedColumnKeys: initialWrappedColumnKeys,
|
|
70
66
|
onCancel,
|
|
71
|
-
|
|
72
|
-
parameters: initialParameters,
|
|
73
|
-
url: urlBeingEdited,
|
|
74
|
-
visibleColumnKeys: initialVisibleColumnKeys
|
|
67
|
+
url: urlBeingEdited
|
|
75
68
|
} = props;
|
|
69
|
+
const {
|
|
70
|
+
visibleColumnCount,
|
|
71
|
+
visibleColumnKeys,
|
|
72
|
+
parameters,
|
|
73
|
+
setParameters,
|
|
74
|
+
tableState
|
|
75
|
+
} = useDatasourceContext();
|
|
76
|
+
const {
|
|
77
|
+
reset,
|
|
78
|
+
status,
|
|
79
|
+
responseItems,
|
|
80
|
+
columns,
|
|
81
|
+
totalCount,
|
|
82
|
+
extensionKey = null,
|
|
83
|
+
destinationObjectTypes
|
|
84
|
+
} = tableState;
|
|
85
|
+
const {
|
|
86
|
+
cloudId,
|
|
87
|
+
jql
|
|
88
|
+
} = parameters !== null && parameters !== void 0 ? parameters : {};
|
|
89
|
+
const [initialJql] = useState(jql);
|
|
76
90
|
const {
|
|
77
91
|
currentViewMode
|
|
78
92
|
} = useViewModeContext();
|
|
79
|
-
const [cloudId, setCloudId] = useState(initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.cloudId);
|
|
80
93
|
const {
|
|
81
94
|
availableSites,
|
|
82
95
|
selectedSite: selectedJiraSite
|
|
83
96
|
} = useAvailableSites('jira', cloudId);
|
|
84
|
-
const [
|
|
85
|
-
const [searchBarJql, setSearchBarJql] = useState(initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.jql);
|
|
86
|
-
const [visibleColumnKeys, setVisibleColumnKeys] = useState(initialVisibleColumnKeys);
|
|
97
|
+
const [searchBarJql, setSearchBarJql] = useState(jql);
|
|
87
98
|
|
|
88
99
|
// analytics related parameters
|
|
89
100
|
const searchCount = useRef(0);
|
|
90
101
|
const userInteractions = useUserInteractions();
|
|
91
102
|
const initialSearchMethod =
|
|
92
103
|
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
93
|
-
fg('platform.linking-platform.datasource.show-jlol-basic-filters') && !isQueryTooComplex(
|
|
104
|
+
fg('platform.linking-platform.datasource.show-jlol-basic-filters') && !isQueryTooComplex(initialJql || '') ? 'basic' : 'jql';
|
|
94
105
|
const [currentSearchMethod, setCurrentSearchMethod] = useState(initialSearchMethod);
|
|
95
106
|
const searchMethodSearchedWith = useRef(null);
|
|
96
|
-
const visibleColumnCount = useRef((visibleColumnKeys === null || visibleColumnKeys === void 0 ? void 0 : visibleColumnKeys.length) || 0);
|
|
97
107
|
const basicFilterSelectionsSearchedWith = useRef({});
|
|
98
108
|
const isSearchedWithComplexQuery = useRef(false);
|
|
99
|
-
const parameters = useMemo(() => !!cloudId ? {
|
|
100
|
-
cloudId,
|
|
101
|
-
jql: jql || ''
|
|
102
|
-
} : undefined, [cloudId, jql]);
|
|
103
|
-
const isParametersSet = !!(jql && cloudId);
|
|
104
|
-
const {
|
|
105
|
-
columnCustomSizes,
|
|
106
|
-
onColumnResize
|
|
107
|
-
} = useColumnResize(initialColumnCustomSizes);
|
|
108
|
-
const {
|
|
109
|
-
wrappedColumnKeys,
|
|
110
|
-
onWrappedColumnChange
|
|
111
|
-
} = useColumnWrapping(initialWrappedColumnKeys);
|
|
112
|
-
const {
|
|
113
|
-
reset,
|
|
114
|
-
status,
|
|
115
|
-
onNextPage,
|
|
116
|
-
responseItems,
|
|
117
|
-
hasNextPage,
|
|
118
|
-
columns,
|
|
119
|
-
defaultVisibleColumnKeys,
|
|
120
|
-
loadDatasourceDetails,
|
|
121
|
-
totalCount,
|
|
122
|
-
extensionKey = null,
|
|
123
|
-
destinationObjectTypes
|
|
124
|
-
} = useDatasourceTableState({
|
|
125
|
-
datasourceId,
|
|
126
|
-
parameters: isParametersSet ? parameters : undefined,
|
|
127
|
-
fieldKeys: visibleColumnKeys
|
|
128
|
-
});
|
|
129
109
|
const {
|
|
130
110
|
fireEvent
|
|
131
111
|
} = useDatasourceAnalyticsEvents();
|
|
@@ -136,7 +116,6 @@ const PlainJiraIssuesConfigModal = props => {
|
|
|
136
116
|
}), [destinationObjectTypes, extensionKey]);
|
|
137
117
|
const resolvedWithNoResults = status === 'resolved' && !responseItems.length;
|
|
138
118
|
const jqlUrl = selectedJiraSite && jql && `${selectedJiraSite.url}/issues/?jql=${encodeURI(jql)}`;
|
|
139
|
-
const isInsertDisabled = !isParametersSet || status === 'rejected' || status === 'unauthorized' || status === 'loading';
|
|
140
119
|
const shouldShowIssueCount = !!totalCount && totalCount !== 1 && currentViewMode === 'table';
|
|
141
120
|
const isDataReady = (visibleColumnKeys || []).length > 0;
|
|
142
121
|
const hasNoJiraSites = availableSites && availableSites.length === 0;
|
|
@@ -163,16 +142,19 @@ const PlainJiraIssuesConfigModal = props => {
|
|
|
163
142
|
canBeLink: currentViewMode === 'inline',
|
|
164
143
|
extensionKey
|
|
165
144
|
});
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* If the selected Jira site changes, update the cloudId in the parameters
|
|
148
|
+
* This is mainly useful for setting the initial cloudId after the site selection loads
|
|
149
|
+
*/
|
|
171
150
|
useEffect(() => {
|
|
172
151
|
if (selectedJiraSite && (!cloudId || cloudId !== selectedJiraSite.cloudId)) {
|
|
173
|
-
|
|
152
|
+
setParameters(() => ({
|
|
153
|
+
jql: '',
|
|
154
|
+
cloudId: selectedJiraSite.cloudId
|
|
155
|
+
}));
|
|
174
156
|
}
|
|
175
|
-
}, [cloudId, selectedJiraSite]);
|
|
157
|
+
}, [cloudId, selectedJiraSite, setParameters]);
|
|
176
158
|
const fireSingleItemViewedEvent = useCallback(() => {
|
|
177
159
|
fireEvent('ui.link.viewed.singleItem', {
|
|
178
160
|
...analyticsPayload,
|
|
@@ -195,7 +177,7 @@ const PlainJiraIssuesConfigModal = props => {
|
|
|
195
177
|
displayedColumnCount: visibleColumnCount.current
|
|
196
178
|
});
|
|
197
179
|
}
|
|
198
|
-
}, [
|
|
180
|
+
}, [isDataReady, fireEvent, analyticsPayload, totalCount, visibleColumnCount]);
|
|
199
181
|
const fireIssueViewAnalytics = useCallback(() => {
|
|
200
182
|
if (!totalCount) {
|
|
201
183
|
return;
|
|
@@ -232,145 +214,30 @@ const PlainJiraIssuesConfigModal = props => {
|
|
|
232
214
|
if (jql !== newParameters.jql) {
|
|
233
215
|
userInteractions.add(DatasourceAction.QUERY_UPDATED);
|
|
234
216
|
}
|
|
235
|
-
|
|
217
|
+
setParameters(state => state && newParameters.jql ? {
|
|
218
|
+
cloudId: state.cloudId,
|
|
219
|
+
jql: newParameters.jql
|
|
220
|
+
} : undefined);
|
|
236
221
|
reset({
|
|
237
222
|
shouldForceRequest: true
|
|
238
223
|
});
|
|
239
|
-
}, [jql, reset, userInteractions]);
|
|
224
|
+
}, [jql, reset, userInteractions, setParameters]);
|
|
240
225
|
const onSiteSelection = useCallback(site => {
|
|
241
226
|
userInteractions.add(DatasourceAction.INSTANCE_UPDATED);
|
|
242
|
-
|
|
243
|
-
|
|
227
|
+
setParameters({
|
|
228
|
+
jql: '',
|
|
229
|
+
cloudId: site.cloudId
|
|
230
|
+
});
|
|
244
231
|
reset({
|
|
245
232
|
shouldForceRequest: true
|
|
246
233
|
});
|
|
247
|
-
}, [reset, userInteractions]);
|
|
234
|
+
}, [reset, userInteractions, setParameters]);
|
|
248
235
|
const retrieveUrlForSmartCardRender = useCallback(() => {
|
|
249
236
|
var _data$key, _data$key$data;
|
|
250
237
|
const [data] = responseItems;
|
|
251
238
|
// agreement with BE that we will use `key` for rendering smartlink
|
|
252
239
|
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;
|
|
253
240
|
}, [responseItems]);
|
|
254
|
-
const onInsertPressed = useCallback((e, analyticsEvent) => {
|
|
255
|
-
var _insertButtonClickedE;
|
|
256
|
-
if (!isParametersSet || !jql || !selectedJiraSite) {
|
|
257
|
-
return;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
// During insertion, we want the JQL of the datasource to be whatever is in the search bar,
|
|
261
|
-
// even if the user didn't previously click search
|
|
262
|
-
const upToDateJql = searchBarJql !== null && searchBarJql !== void 0 ? searchBarJql : jql;
|
|
263
|
-
const upToDateJqlUrl = selectedJiraSite && jql && `${selectedJiraSite.url}/issues/?jql=${encodeURIComponent(upToDateJql)}`;
|
|
264
|
-
const filterSelectionCount = availableBasicFilterTypes.reduce((current, filter) => {
|
|
265
|
-
var _basicFilterSelection;
|
|
266
|
-
return {
|
|
267
|
-
...current,
|
|
268
|
-
[`${filter}BasicFilterSelectionCount`]: ((_basicFilterSelection = basicFilterSelectionsSearchedWith.current[filter]) === null || _basicFilterSelection === void 0 ? void 0 : _basicFilterSelection.length) || 0
|
|
269
|
-
};
|
|
270
|
-
}, {});
|
|
271
|
-
const insertButtonClickedEvent = analyticsEvent.update({
|
|
272
|
-
actionSubjectId: 'insert',
|
|
273
|
-
attributes: {
|
|
274
|
-
...analyticsPayload,
|
|
275
|
-
totalItemCount: totalCount || 0,
|
|
276
|
-
displayedColumnCount: visibleColumnCount.current,
|
|
277
|
-
display: getDisplayValue(currentViewMode, totalCount || 0),
|
|
278
|
-
searchCount: searchCount.current,
|
|
279
|
-
searchMethod: mapSearchMethod(searchMethodSearchedWith.current),
|
|
280
|
-
actions: userInteractions.get(),
|
|
281
|
-
isQueryComplex: isSearchedWithComplexQuery.current,
|
|
282
|
-
...(searchMethodSearchedWith.current === 'basic' ? {
|
|
283
|
-
...filterSelectionCount
|
|
284
|
-
} : {})
|
|
285
|
-
},
|
|
286
|
-
eventType: 'ui'
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
// additional event for tracking in confluence against JIM
|
|
290
|
-
const macroInsertedEvent = analyticsEvent.clone();
|
|
291
|
-
macroInsertedEvent === null || macroInsertedEvent === void 0 ? void 0 : macroInsertedEvent.update({
|
|
292
|
-
eventType: 'track',
|
|
293
|
-
action: 'inserted',
|
|
294
|
-
actionSubject: 'macro',
|
|
295
|
-
actionSubjectId: 'jlol',
|
|
296
|
-
attributes: {
|
|
297
|
-
...analyticsPayload,
|
|
298
|
-
totalItemCount: totalCount || 0,
|
|
299
|
-
displayedColumnCount: visibleColumnCount.current,
|
|
300
|
-
display: getDisplayValue(currentViewMode, totalCount || 0),
|
|
301
|
-
searchCount: searchCount.current,
|
|
302
|
-
searchMethod: mapSearchMethod(searchMethodSearchedWith.current),
|
|
303
|
-
actions: userInteractions.get()
|
|
304
|
-
}
|
|
305
|
-
});
|
|
306
|
-
const consumerEvent = (_insertButtonClickedE = insertButtonClickedEvent.clone()) !== null && _insertButtonClickedE !== void 0 ? _insertButtonClickedE : undefined;
|
|
307
|
-
insertButtonClickedEvent.fire(EVENT_CHANNEL);
|
|
308
|
-
const firstIssueUrl = retrieveUrlForSmartCardRender();
|
|
309
|
-
if (currentViewMode === 'inline') {
|
|
310
|
-
macroInsertedEvent === null || macroInsertedEvent === void 0 ? void 0 : macroInsertedEvent.fire(EVENT_CHANNEL);
|
|
311
|
-
const url = responseItems.length === 1 ? firstIssueUrl : upToDateJqlUrl;
|
|
312
|
-
onInsert({
|
|
313
|
-
type: 'inlineCard',
|
|
314
|
-
attrs: {
|
|
315
|
-
url
|
|
316
|
-
}
|
|
317
|
-
}, consumerEvent);
|
|
318
|
-
} else {
|
|
319
|
-
onInsert(buildDatasourceAdf({
|
|
320
|
-
id: datasourceId,
|
|
321
|
-
parameters: {
|
|
322
|
-
cloudId,
|
|
323
|
-
jql: upToDateJql // TODO support non JQL type
|
|
324
|
-
},
|
|
325
|
-
views: [{
|
|
326
|
-
type: 'table',
|
|
327
|
-
properties: {
|
|
328
|
-
columns: (visibleColumnKeys || []).map(key => {
|
|
329
|
-
const width = columnCustomSizes === null || columnCustomSizes === void 0 ? void 0 : columnCustomSizes[key];
|
|
330
|
-
const isWrapped = wrappedColumnKeys === null || wrappedColumnKeys === void 0 ? void 0 : wrappedColumnKeys.includes(key);
|
|
331
|
-
return {
|
|
332
|
-
key,
|
|
333
|
-
...(width ? {
|
|
334
|
-
width
|
|
335
|
-
} : {}),
|
|
336
|
-
...(isWrapped ? {
|
|
337
|
-
isWrapped
|
|
338
|
-
} : {})
|
|
339
|
-
};
|
|
340
|
-
})
|
|
341
|
-
}
|
|
342
|
-
}]
|
|
343
|
-
}, upToDateJqlUrl), consumerEvent);
|
|
344
|
-
}
|
|
345
|
-
}, [isParametersSet, jql, selectedJiraSite, searchBarJql, analyticsPayload, totalCount, currentViewMode, retrieveUrlForSmartCardRender, responseItems.length, onInsert, datasourceId, cloudId, visibleColumnKeys, columnCustomSizes, wrappedColumnKeys, userInteractions]);
|
|
346
|
-
const handleOnNextPage = useCallback((onNextPageProps = {}) => {
|
|
347
|
-
userInteractions.add(DatasourceAction.NEXT_PAGE_SCROLLED);
|
|
348
|
-
onNextPage(onNextPageProps);
|
|
349
|
-
}, [onNextPage, userInteractions]);
|
|
350
|
-
const handleVisibleColumnKeysChange = useCallback((newVisibleColumnKeys = []) => {
|
|
351
|
-
const columnAction = getColumnAction(visibleColumnKeys || [], newVisibleColumnKeys);
|
|
352
|
-
userInteractions.add(columnAction);
|
|
353
|
-
visibleColumnCount.current = newVisibleColumnKeys.length;
|
|
354
|
-
setVisibleColumnKeys(newVisibleColumnKeys);
|
|
355
|
-
}, [visibleColumnKeys, userInteractions]);
|
|
356
|
-
const issueLikeDataTableView = useMemo(() => jsx(ContentContainer, {
|
|
357
|
-
withTableBorder: true
|
|
358
|
-
}, jsx(IssueLikeDataTableView, {
|
|
359
|
-
testId: "jira-datasource-table",
|
|
360
|
-
status: status,
|
|
361
|
-
columns: columns,
|
|
362
|
-
items: responseItems,
|
|
363
|
-
hasNextPage: hasNextPage,
|
|
364
|
-
visibleColumnKeys: visibleColumnKeys || defaultVisibleColumnKeys,
|
|
365
|
-
onNextPage: handleOnNextPage,
|
|
366
|
-
onLoadDatasourceDetails: loadDatasourceDetails,
|
|
367
|
-
onVisibleColumnKeysChange: handleVisibleColumnKeysChange,
|
|
368
|
-
extensionKey: extensionKey,
|
|
369
|
-
columnCustomSizes: columnCustomSizes,
|
|
370
|
-
onColumnResize: onColumnResize,
|
|
371
|
-
wrappedColumnKeys: wrappedColumnKeys,
|
|
372
|
-
onWrappedColumnChange: fg('platform.linking-platform.datasource-word_wrap') ? onWrappedColumnChange : undefined
|
|
373
|
-
})), [status, columns, responseItems, hasNextPage, visibleColumnKeys, defaultVisibleColumnKeys, handleOnNextPage, loadDatasourceDetails, handleVisibleColumnKeysChange, extensionKey, columnCustomSizes, onColumnResize, wrappedColumnKeys, onWrappedColumnChange]);
|
|
374
241
|
const renderCountModeContent = useCallback(() => {
|
|
375
242
|
const selectedJiraSiteUrl = selectedJiraSite === null || selectedJiraSite === void 0 ? void 0 : selectedJiraSite.url;
|
|
376
243
|
if (status === 'unauthorized') {
|
|
@@ -428,8 +295,12 @@ const PlainJiraIssuesConfigModal = props => {
|
|
|
428
295
|
} : undefined
|
|
429
296
|
}));
|
|
430
297
|
}
|
|
431
|
-
return
|
|
432
|
-
|
|
298
|
+
return jsx(ContentContainer, {
|
|
299
|
+
withTableBorder: true
|
|
300
|
+
}, jsx(DatasourcesTableInModalPreview, {
|
|
301
|
+
testId: "jira-datasource-table"
|
|
302
|
+
}));
|
|
303
|
+
}, [columns.length, currentSearchMethod, jql, jqlUrl, resolvedWithNoResults, selectedJiraSite === null || selectedJiraSite === void 0 ? void 0 : selectedJiraSite.url, status, urlBeingEdited]);
|
|
433
304
|
const siteSelectorLabel = availableSites && availableSites.length > 1 ? modalMessages.insertIssuesTitleManySites : modalMessages.insertIssuesTitle;
|
|
434
305
|
const getCancelButtonAnalyticsPayload = useCallback(() => {
|
|
435
306
|
return {
|
|
@@ -438,6 +309,41 @@ const PlainJiraIssuesConfigModal = props => {
|
|
|
438
309
|
actions: userInteractions.get()
|
|
439
310
|
};
|
|
440
311
|
}, [analyticsPayload, userInteractions]);
|
|
312
|
+
const filterSelectionCount = availableBasicFilterTypes.reduce((current, filter) => {
|
|
313
|
+
var _basicFilterSelection;
|
|
314
|
+
return {
|
|
315
|
+
...current,
|
|
316
|
+
[`${filter}BasicFilterSelectionCount`]: ((_basicFilterSelection = basicFilterSelectionsSearchedWith.current[filter]) === null || _basicFilterSelection === void 0 ? void 0 : _basicFilterSelection.length) || 0
|
|
317
|
+
};
|
|
318
|
+
}, {});
|
|
319
|
+
const getInsertButtonAnalyticsPayload = useCallback(() => ({
|
|
320
|
+
...analyticsPayload,
|
|
321
|
+
display: getDisplayValue(currentViewMode, totalCount || 0),
|
|
322
|
+
isQueryComplex: isSearchedWithComplexQuery.current,
|
|
323
|
+
searchMethod: mapSearchMethod(searchMethodSearchedWith.current),
|
|
324
|
+
searchCount: searchCount.current,
|
|
325
|
+
actions: userInteractions.get(),
|
|
326
|
+
...(searchMethodSearchedWith.current === 'basic' ? {
|
|
327
|
+
...filterSelectionCount
|
|
328
|
+
} : {})
|
|
329
|
+
}), [analyticsPayload, currentViewMode, filterSelectionCount, totalCount, userInteractions]);
|
|
330
|
+
const urlToInsert = useMemo(() => {
|
|
331
|
+
const jql = parameters === null || parameters === void 0 ? void 0 : parameters.jql;
|
|
332
|
+
if (!jql || !(selectedJiraSite !== null && selectedJiraSite !== void 0 && selectedJiraSite.url)) {
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
// During insertion, we want the JQL of the datasource to be whatever is in the search bar,
|
|
336
|
+
// even if the user didn't previously click search
|
|
337
|
+
const upToDateJql = searchBarJql !== null && searchBarJql !== void 0 ? searchBarJql : jql;
|
|
338
|
+
const upToDateJqlUrl = `${selectedJiraSite.url}/issues/?jql=${encodeURIComponent(upToDateJql)}`;
|
|
339
|
+
return currentViewMode === 'inline' && responseItems.length === 1 ? retrieveUrlForSmartCardRender() : upToDateJqlUrl;
|
|
340
|
+
}, [currentViewMode, parameters === null || parameters === void 0 ? void 0 : parameters.jql, responseItems, retrieveUrlForSmartCardRender, searchBarJql, selectedJiraSite === null || selectedJiraSite === void 0 ? void 0 : selectedJiraSite.url]);
|
|
341
|
+
const updateParametersBeforeInsert = parameters => ({
|
|
342
|
+
cloudId: parameters.cloudId,
|
|
343
|
+
// searchBarJql will not be null at this point, since this function is only called when user press insert button
|
|
344
|
+
//
|
|
345
|
+
jql: searchBarJql || ''
|
|
346
|
+
});
|
|
441
347
|
return jsx(IntlMessagesProvider, {
|
|
442
348
|
defaultMessages: i18nEN,
|
|
443
349
|
loaderFn: fetchMessagesForLocale
|
|
@@ -472,11 +378,11 @@ const PlainJiraIssuesConfigModal = props => {
|
|
|
472
378
|
onCancel: onCancel,
|
|
473
379
|
getAnalyticsPayload: getCancelButtonAnalyticsPayload,
|
|
474
380
|
testId: "jira-datasource-modal--cancel-button"
|
|
475
|
-
}), !hasNoJiraSites && jsx(
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
381
|
+
}), !hasNoJiraSites && jsx(InsertButton, {
|
|
382
|
+
testId: "jira-datasource-modal--insert-button",
|
|
383
|
+
url: urlToInsert,
|
|
384
|
+
overwriteParameters: updateParametersBeforeInsert,
|
|
385
|
+
getAnalyticsPayload: getInsertButtonAnalyticsPayload
|
|
480
386
|
}, jsx(FormattedMessage, modalMessages.insertIssuesButtonText))))));
|
|
481
387
|
};
|
|
482
388
|
const analyticsContextAttributes = {
|
|
@@ -492,9 +398,35 @@ const contextData = {
|
|
|
492
398
|
...analyticsContextAttributes
|
|
493
399
|
}
|
|
494
400
|
};
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
401
|
+
const ConnectedJiraIssueConfigModal = createDatasourceModal({
|
|
402
|
+
isValidParameters,
|
|
403
|
+
dataProvider: 'jira-issues',
|
|
404
|
+
component: PlainJiraIssuesConfigModal
|
|
405
|
+
});
|
|
406
|
+
const JiraIssuesConfigModalWithExtraAnalyticsOnInsert = props => {
|
|
407
|
+
const onInsert = props.onInsert;
|
|
408
|
+
const onInsertWithMacroAnalytics = useCallback((adf, analyticsEvent) => {
|
|
409
|
+
if (analyticsEvent && adf.type === 'inlineCard') {
|
|
410
|
+
const macroInsertedEvent = analyticsEvent.clone();
|
|
411
|
+
macroInsertedEvent === null || macroInsertedEvent === void 0 ? void 0 : macroInsertedEvent.update({
|
|
412
|
+
eventType: 'track',
|
|
413
|
+
action: 'inserted',
|
|
414
|
+
actionSubject: 'macro',
|
|
415
|
+
actionSubjectId: 'jlol'
|
|
416
|
+
});
|
|
417
|
+
macroInsertedEvent === null || macroInsertedEvent === void 0 ? void 0 : macroInsertedEvent.fire(EVENT_CHANNEL);
|
|
418
|
+
}
|
|
419
|
+
onInsert(adf, analyticsEvent);
|
|
420
|
+
}, [onInsert]);
|
|
421
|
+
return jsx(StoreContainer, null, jsx(ConnectedJiraIssueConfigModal, _extends({}, props, {
|
|
422
|
+
onInsert: onInsertWithMacroAnalytics
|
|
423
|
+
})));
|
|
424
|
+
};
|
|
425
|
+
export const JiraIssuesConfigModal = props => {
|
|
426
|
+
if (fg('platform-datasources-use-refactored-config-modal')) {
|
|
427
|
+
return jsx(JiraIssuesConfigModalWithExtraAnalyticsOnInsert, props);
|
|
428
|
+
}
|
|
429
|
+
return jsx(StoreContainer, null, jsx(AnalyticsContext, {
|
|
430
|
+
data: contextData
|
|
431
|
+
}, jsx(DatasourceExperienceIdProvider, null, jsx(UserInteractionsProvider, null, jsx(PlainJiraIssuesConfigModalOld, props)))));
|
|
432
|
+
};
|
|
@@ -5,7 +5,9 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
5
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 { fg } from '@atlaskit/platform-feature-flags';
|
|
8
9
|
import { useDatasourceAnalyticsEvents } from '../analytics';
|
|
10
|
+
import { useDatasourceActions } from '../state';
|
|
9
11
|
import useErrorLogger from './useErrorLogger';
|
|
10
12
|
export var useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
11
13
|
var datasourceId = _ref.datasourceId,
|
|
@@ -18,6 +20,8 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
|
18
20
|
datasourceId: datasourceId
|
|
19
21
|
}),
|
|
20
22
|
captureError = _useErrorLogger.captureError;
|
|
23
|
+
var _useDatasourceActions = useDatasourceActions(),
|
|
24
|
+
onAddItems = _useDatasourceActions.onAddItems;
|
|
21
25
|
var idFieldCount = 1;
|
|
22
26
|
var keyFieldCount = 1;
|
|
23
27
|
var _useState = useState([]),
|
|
@@ -45,42 +49,45 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
|
45
49
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
46
50
|
authDetails = _useState12[0],
|
|
47
51
|
setAuthDetails = _useState12[1];
|
|
48
|
-
var _useState13 = useState(
|
|
52
|
+
var _useState13 = useState(initialEmptyArray),
|
|
49
53
|
_useState14 = _slicedToArray(_useState13, 2),
|
|
50
54
|
responseItems = _useState14[0],
|
|
51
55
|
setResponseItems = _useState14[1];
|
|
52
|
-
var _useState15 = useState(
|
|
56
|
+
var _useState15 = useState(initialEmptyArray),
|
|
53
57
|
_useState16 = _slicedToArray(_useState15, 2),
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
var _useState17 = useState(undefined),
|
|
58
|
+
setResponseItemIds = _useState16[1];
|
|
59
|
+
var _useState17 = useState(true),
|
|
57
60
|
_useState18 = _slicedToArray(_useState17, 2),
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
var _useState19 = useState(
|
|
61
|
+
hasNextPage = _useState18[0],
|
|
62
|
+
setHasNextPage = _useState18[1];
|
|
63
|
+
var _useState19 = useState(undefined),
|
|
61
64
|
_useState20 = _slicedToArray(_useState19, 2),
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
var _useState21 = useState(
|
|
65
|
+
nextCursor = _useState20[0],
|
|
66
|
+
setNextCursor = _useState20[1];
|
|
67
|
+
var _useState21 = useState([]),
|
|
65
68
|
_useState22 = _slicedToArray(_useState21, 2),
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
var _useState23 = useState(
|
|
69
|
+
columns = _useState22[0],
|
|
70
|
+
setColumns = _useState22[1];
|
|
71
|
+
var _useState23 = useState(undefined),
|
|
69
72
|
_useState24 = _slicedToArray(_useState23, 2),
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
var _useState25 = useState(
|
|
73
|
+
totalCount = _useState24[0],
|
|
74
|
+
setTotalCount = _useState24[1];
|
|
75
|
+
var _useState25 = useState(false),
|
|
73
76
|
_useState26 = _slicedToArray(_useState25, 2),
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
var _useState27 = useState(),
|
|
77
|
+
shouldForceRequest = _useState26[0],
|
|
78
|
+
setShouldForceRequest = _useState26[1];
|
|
79
|
+
var _useState27 = useState([]),
|
|
77
80
|
_useState28 = _slicedToArray(_useState27, 2),
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
var _useState29 = useState(
|
|
81
|
+
destinationObjectTypes = _useState28[0],
|
|
82
|
+
setDestinationObjectTypes = _useState28[1];
|
|
83
|
+
var _useState29 = useState(),
|
|
81
84
|
_useState30 = _slicedToArray(_useState29, 2),
|
|
82
|
-
|
|
83
|
-
|
|
85
|
+
extensionKey = _useState30[0],
|
|
86
|
+
setExtensionKey = _useState30[1];
|
|
87
|
+
var _useState31 = useState(undefined),
|
|
88
|
+
_useState32 = _slicedToArray(_useState31, 2),
|
|
89
|
+
providerName = _useState32[0],
|
|
90
|
+
setProviderName = _useState32[1];
|
|
84
91
|
var abortController = useRef(new AbortController());
|
|
85
92
|
var _useDatasourceClientE = useDatasourceClientExtension(),
|
|
86
93
|
getDatasourceData = _useDatasourceClientE.getDatasourceData,
|
|
@@ -208,6 +215,7 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
|
208
215
|
nextPageCursor,
|
|
209
216
|
_totalCount,
|
|
210
217
|
schema,
|
|
218
|
+
newIds,
|
|
211
219
|
isUserLoadingNextPage,
|
|
212
220
|
currentLoadedItemCount,
|
|
213
221
|
newlyLoadedItemCount,
|
|
@@ -282,6 +290,12 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
|
282
290
|
}
|
|
283
291
|
return [].concat(_toConsumableArray(currentResponseItems), _toConsumableArray(items));
|
|
284
292
|
});
|
|
293
|
+
if (fg('enable_datasource_react_sweet_state')) {
|
|
294
|
+
newIds = onAddItems(items);
|
|
295
|
+
setResponseItemIds(function (currentIds) {
|
|
296
|
+
return [].concat(_toConsumableArray(currentIds), _toConsumableArray(newIds));
|
|
297
|
+
});
|
|
298
|
+
}
|
|
285
299
|
setHasNextPage(Boolean(nextPageCursor));
|
|
286
300
|
if (fieldKeys.length > 0) {
|
|
287
301
|
setLastRequestedFieldKeys(fieldKeys);
|
|
@@ -289,9 +303,9 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
|
289
303
|
if ((isSchemaFromData && schema || fullSchema.properties.length > 0) && items.length > 0) {
|
|
290
304
|
applySchemaProperties(schema || fullSchema, fieldKeys);
|
|
291
305
|
}
|
|
292
|
-
isUserLoadingNextPage =
|
|
306
|
+
isUserLoadingNextPage = responseItems.length !== 0 && !shouldRequestFirstPage;
|
|
293
307
|
if (isUserLoadingNextPage) {
|
|
294
|
-
currentLoadedItemCount =
|
|
308
|
+
currentLoadedItemCount = responseItems.length;
|
|
295
309
|
newlyLoadedItemCount = (items === null || items === void 0 ? void 0 : items.length) || 0;
|
|
296
310
|
fireEvent('track.nextItem.loaded', {
|
|
297
311
|
extensionKey: _extensionKey,
|
|
@@ -300,41 +314,42 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
|
300
314
|
});
|
|
301
315
|
}
|
|
302
316
|
setStatus('resolved');
|
|
303
|
-
_context2.next =
|
|
317
|
+
_context2.next = 58;
|
|
304
318
|
break;
|
|
305
|
-
case
|
|
306
|
-
_context2.prev =
|
|
319
|
+
case 46:
|
|
320
|
+
_context2.prev = 46;
|
|
307
321
|
_context2.t0 = _context2["catch"](10);
|
|
308
322
|
if (!(_context2.t0.message === 'Aborted')) {
|
|
309
|
-
_context2.next =
|
|
323
|
+
_context2.next = 50;
|
|
310
324
|
break;
|
|
311
325
|
}
|
|
312
326
|
return _context2.abrupt("return");
|
|
313
|
-
case
|
|
327
|
+
case 50:
|
|
314
328
|
captureError('onNextPage', _context2.t0);
|
|
315
329
|
if (!(_context2.t0 instanceof Response && _context2.t0.status === 401)) {
|
|
316
|
-
_context2.next =
|
|
330
|
+
_context2.next = 54;
|
|
317
331
|
break;
|
|
318
332
|
}
|
|
319
333
|
setStatus('unauthorized');
|
|
320
334
|
return _context2.abrupt("return");
|
|
321
|
-
case
|
|
335
|
+
case 54:
|
|
322
336
|
if (!(_context2.t0 instanceof Response && _context2.t0.status === 403)) {
|
|
323
|
-
_context2.next =
|
|
337
|
+
_context2.next = 57;
|
|
324
338
|
break;
|
|
325
339
|
}
|
|
326
340
|
setStatus('forbidden');
|
|
327
341
|
return _context2.abrupt("return");
|
|
328
|
-
case 56:
|
|
329
|
-
setStatus('rejected');
|
|
330
342
|
case 57:
|
|
343
|
+
setStatus('rejected');
|
|
344
|
+
case 58:
|
|
331
345
|
case "end":
|
|
332
346
|
return _context2.stop();
|
|
333
347
|
}
|
|
334
|
-
}, _callee2, null, [[10,
|
|
335
|
-
})), [captureError, parameters, fieldKeys, nextCursor, getDatasourceData, datasourceId,
|
|
348
|
+
}, _callee2, null, [[10, 46]]);
|
|
349
|
+
})), [captureError, parameters, fieldKeys, nextCursor, responseItems, setResponseItemIds, onAddItems, getDatasourceData, datasourceId, applySchemaProperties, fireEvent, fullSchema, initialEmptyArray]);
|
|
336
350
|
var reset = useCallback(function (options) {
|
|
337
351
|
setResponseItems(initialEmptyArray);
|
|
352
|
+
setResponseItemIds(initialEmptyArray);
|
|
338
353
|
setHasNextPage(true);
|
|
339
354
|
setNextCursor(undefined);
|
|
340
355
|
setTotalCount(undefined);
|