@atlaskit/link-datasource 2.9.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 +8 -0
- 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 +35 -39
- package/dist/cjs/ui/jira-issues-modal/modal/index.js +141 -211
- 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 +35 -39
- package/dist/es2019/ui/jira-issues-modal/modal/index.js +133 -202
- 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 +38 -42
- package/dist/esm/ui/jira-issues-modal/modal/index.js +146 -216
- package/dist/types/common/types.d.ts +2 -1
- 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/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/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/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 +1 -1
|
@@ -8,7 +8,7 @@ import { Fragment, useCallback, useEffect, useMemo, useRef, useState } from 'rea
|
|
|
8
8
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
9
9
|
import { jsx } from '@emotion/react';
|
|
10
10
|
import { FormattedMessage } from 'react-intl-next';
|
|
11
|
-
import {
|
|
11
|
+
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
12
12
|
import { IntlMessagesProvider } from '@atlaskit/intl-messages-provider';
|
|
13
13
|
import { ModalBody, ModalFooter, ModalHeader, ModalTitle } from '@atlaskit/modal-dialog';
|
|
14
14
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -30,12 +30,13 @@ import { InitialStateView } from '../../common/initial-state-view';
|
|
|
30
30
|
import { CancelButton } from '../../common/modal/cancel-button';
|
|
31
31
|
import { ContentContainer } from '../../common/modal/content-container';
|
|
32
32
|
import { SmartCardPlaceholder, SmartLink } from '../../common/modal/count-view-smart-link';
|
|
33
|
-
import {
|
|
33
|
+
import { useDatasourceContext } from '../../common/modal/datasource-context';
|
|
34
34
|
import { DatasourceModal } from '../../common/modal/datasource-modal';
|
|
35
|
+
import { createDatasourceModal } from '../../common/modal/datasource-modal/createDatasourceModal';
|
|
35
36
|
import DatasourcesTableInModalPreview from '../../common/modal/datasources-table-in-modal-preview';
|
|
36
37
|
import { InsertButton } from '../../common/modal/insert-button';
|
|
37
38
|
import { DatasourceViewModeDropDown } from '../../common/modal/mode-switcher';
|
|
38
|
-
import {
|
|
39
|
+
import { useViewModeContext } from '../../common/modal/mode-switcher/useViewModeContext';
|
|
39
40
|
import TableSearchCount from '../../common/modal/search-count';
|
|
40
41
|
import { SiteSelector } from '../../common/modal/site-selector';
|
|
41
42
|
import { EmptyState } from '../../issue-like-table';
|
|
@@ -43,7 +44,6 @@ import ConfluenceSearchContainer from '../confluence-search-container';
|
|
|
43
44
|
import { ConfluenceSearchInitialStateSVG } from './confluence-search-initial-state-svg';
|
|
44
45
|
import { confluenceSearchModalMessages } from './messages';
|
|
45
46
|
import { PlainConfluenceSearchConfigModal as PlainConfluenceSearchConfigModalOld } from './ModalOld';
|
|
46
|
-
const DEFAULT_VIEW_MODE = 'table';
|
|
47
47
|
const inputContainerStyles = xcss({
|
|
48
48
|
alignItems: 'baseline',
|
|
49
49
|
display: 'flex',
|
|
@@ -75,7 +75,6 @@ const useUpdateParametersOnFormUpdate = (cloudId, searchString, lastModified, co
|
|
|
75
75
|
export const PlainConfluenceSearchConfigModal = props => {
|
|
76
76
|
const {
|
|
77
77
|
onCancel,
|
|
78
|
-
parameters: initialParameters,
|
|
79
78
|
url: urlBeingEdited,
|
|
80
79
|
disableDisplayDropdown = false,
|
|
81
80
|
overrideParameters
|
|
@@ -83,23 +82,6 @@ export const PlainConfluenceSearchConfigModal = props => {
|
|
|
83
82
|
const {
|
|
84
83
|
currentViewMode
|
|
85
84
|
} = useViewModeContext();
|
|
86
|
-
const [cloudId, setCloudId] = useState(initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.cloudId);
|
|
87
|
-
const {
|
|
88
|
-
availableSites,
|
|
89
|
-
selectedSite: selectedConfluenceSite
|
|
90
|
-
} = useAvailableSites('confluence', cloudId);
|
|
91
|
-
const [searchString, setSearchString] = useState(initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.searchString);
|
|
92
|
-
const [contributorAccountIds, setContributorAccountIds] = useState((initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.contributorAccountIds) || []);
|
|
93
|
-
const [lastModified, setLastModified] = useState(initialParameters !== null && initialParameters !== void 0 && initialParameters.lastModified ? {
|
|
94
|
-
value: initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.lastModified,
|
|
95
|
-
from: initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.lastModifiedFrom,
|
|
96
|
-
to: initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.lastModifiedTo
|
|
97
|
-
} : undefined);
|
|
98
|
-
|
|
99
|
-
// analytics related parameters
|
|
100
|
-
const searchCount = useRef(0);
|
|
101
|
-
const userInteractions = useUserInteractions();
|
|
102
|
-
useUpdateParametersOnFormUpdate(cloudId, searchString, lastModified, contributorAccountIds, overrideParameters);
|
|
103
85
|
const {
|
|
104
86
|
visibleColumnKeys,
|
|
105
87
|
tableState: {
|
|
@@ -114,6 +96,23 @@ export const PlainConfluenceSearchConfigModal = props => {
|
|
|
114
96
|
visibleColumnCount,
|
|
115
97
|
parameters
|
|
116
98
|
} = useDatasourceContext();
|
|
99
|
+
const [cloudId, setCloudId] = useState(parameters === null || parameters === void 0 ? void 0 : parameters.cloudId);
|
|
100
|
+
const {
|
|
101
|
+
availableSites,
|
|
102
|
+
selectedSite: selectedConfluenceSite
|
|
103
|
+
} = useAvailableSites('confluence', cloudId);
|
|
104
|
+
const [searchString, setSearchString] = useState(parameters === null || parameters === void 0 ? void 0 : parameters.searchString);
|
|
105
|
+
const [contributorAccountIds, setContributorAccountIds] = useState((parameters === null || parameters === void 0 ? void 0 : parameters.contributorAccountIds) || []);
|
|
106
|
+
const [lastModified, setLastModified] = useState(parameters !== null && parameters !== void 0 && parameters.lastModified ? {
|
|
107
|
+
value: parameters === null || parameters === void 0 ? void 0 : parameters.lastModified,
|
|
108
|
+
from: parameters === null || parameters === void 0 ? void 0 : parameters.lastModifiedFrom,
|
|
109
|
+
to: parameters === null || parameters === void 0 ? void 0 : parameters.lastModifiedTo
|
|
110
|
+
} : undefined);
|
|
111
|
+
|
|
112
|
+
// analytics related parameters
|
|
113
|
+
const searchCount = useRef(0);
|
|
114
|
+
const userInteractions = useUserInteractions();
|
|
115
|
+
useUpdateParametersOnFormUpdate(cloudId, searchString, lastModified, contributorAccountIds, overrideParameters);
|
|
117
116
|
const {
|
|
118
117
|
fireEvent
|
|
119
118
|
} = useDatasourceAnalyticsEvents();
|
|
@@ -306,7 +305,7 @@ export const PlainConfluenceSearchConfigModal = props => {
|
|
|
306
305
|
}, jsx(ConfluenceSearchContainer, {
|
|
307
306
|
isSearching: status === 'loading',
|
|
308
307
|
onSearch: onSearch,
|
|
309
|
-
parameters: isValidParameters(parameters) ? parameters : {
|
|
308
|
+
parameters: parameters && isValidParameters(parameters) ? parameters : {
|
|
310
309
|
cloudId: ''
|
|
311
310
|
}
|
|
312
311
|
})), currentViewMode === 'inline' ? renderInlineLinkModalContent() : renderTableModalContent()) : jsx(NoInstancesView, {
|
|
@@ -341,19 +340,16 @@ const contextData = {
|
|
|
341
340
|
...analyticsContextAttributes
|
|
342
341
|
}
|
|
343
342
|
};
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
// TODO on cleanup 'use-refactored-config-modal' ff, delete `ModalOld.tsx` as well
|
|
358
|
-
jsx(PlainConfluenceSearchConfigModalOld, props))));
|
|
359
|
-
});
|
|
343
|
+
const ConnectedConfluenceSearchConfigModal = createDatasourceModal({
|
|
344
|
+
isValidParameters,
|
|
345
|
+
dataProvider: 'confluence-search',
|
|
346
|
+
component: PlainConfluenceSearchConfigModal
|
|
347
|
+
});
|
|
348
|
+
export const ConfluenceSearchConfigModal = props => {
|
|
349
|
+
if (fg('platform-datasources-use-refactored-config-modal')) {
|
|
350
|
+
return jsx(StoreContainer, null, jsx(ConnectedConfluenceSearchConfigModal, props));
|
|
351
|
+
}
|
|
352
|
+
return jsx(StoreContainer, null, jsx(AnalyticsContext, {
|
|
353
|
+
data: contextData
|
|
354
|
+
}, jsx(DatasourceExperienceIdProvider, null, jsx(UserInteractionsProvider, null, jsx(PlainConfluenceSearchConfigModalOld, props)))));
|
|
355
|
+
};
|
|
@@ -10,23 +10,20 @@ 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';
|
|
32
29
|
import { StoreContainer } from '../../../state';
|
|
@@ -40,22 +37,22 @@ import { initialStateViewMessages } from '../../common/initial-state-view/messag
|
|
|
40
37
|
import { CancelButton } from '../../common/modal/cancel-button';
|
|
41
38
|
import { ContentContainer } from '../../common/modal/content-container';
|
|
42
39
|
import { SmartCardPlaceholder, SmartLink } from '../../common/modal/count-view-smart-link';
|
|
40
|
+
import { useDatasourceContext } from '../../common/modal/datasource-context';
|
|
43
41
|
import { DatasourceModal } from '../../common/modal/datasource-modal';
|
|
44
|
-
import {
|
|
45
|
-
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';
|
|
46
45
|
import { DatasourceViewModeDropDown } from '../../common/modal/mode-switcher';
|
|
47
|
-
import {
|
|
46
|
+
import { useViewModeContext } from '../../common/modal/mode-switcher/useViewModeContext';
|
|
48
47
|
import TableSearchCount from '../../common/modal/search-count';
|
|
49
48
|
import { SiteSelector } from '../../common/modal/site-selector';
|
|
50
|
-
import { EmptyState
|
|
51
|
-
import { getColumnAction } from '../../issue-like-table/utils';
|
|
49
|
+
import { EmptyState } from '../../issue-like-table';
|
|
52
50
|
import { availableBasicFilterTypes } from '../basic-filters/ui';
|
|
53
51
|
import { isQueryTooComplex } from '../basic-filters/utils/isQueryTooComplex';
|
|
54
52
|
import { JiraSearchContainer } from '../jira-search-container';
|
|
55
53
|
import { JiraInitialStateSVG } from './jira-issues-initial-state-svg';
|
|
56
54
|
import { modalMessages } from './messages';
|
|
57
55
|
import { PlainJiraIssuesConfigModalOld } from './ModalOld';
|
|
58
|
-
const DEFAULT_VIEW_MODE = 'table';
|
|
59
56
|
const getDisplayValue = (currentViewMode, itemCount) => {
|
|
60
57
|
if (currentViewMode === 'table') {
|
|
61
58
|
return DatasourceDisplay.DATASOURCE_TABLE;
|
|
@@ -63,70 +60,52 @@ const getDisplayValue = (currentViewMode, itemCount) => {
|
|
|
63
60
|
return itemCount === 1 ? DatasourceDisplay.INLINE : DatasourceDisplay.DATASOURCE_INLINE;
|
|
64
61
|
};
|
|
65
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;
|
|
66
64
|
const PlainJiraIssuesConfigModal = props => {
|
|
67
65
|
const {
|
|
68
|
-
datasourceId,
|
|
69
|
-
columnCustomSizes: initialColumnCustomSizes,
|
|
70
|
-
wrappedColumnKeys: initialWrappedColumnKeys,
|
|
71
66
|
onCancel,
|
|
72
|
-
|
|
73
|
-
parameters: initialParameters,
|
|
74
|
-
url: urlBeingEdited,
|
|
75
|
-
visibleColumnKeys: initialVisibleColumnKeys
|
|
67
|
+
url: urlBeingEdited
|
|
76
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);
|
|
77
90
|
const {
|
|
78
91
|
currentViewMode
|
|
79
92
|
} = useViewModeContext();
|
|
80
|
-
const [cloudId, setCloudId] = useState(initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.cloudId);
|
|
81
93
|
const {
|
|
82
94
|
availableSites,
|
|
83
95
|
selectedSite: selectedJiraSite
|
|
84
96
|
} = useAvailableSites('jira', cloudId);
|
|
85
|
-
const [
|
|
86
|
-
const [searchBarJql, setSearchBarJql] = useState(initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.jql);
|
|
87
|
-
const [visibleColumnKeys, setVisibleColumnKeys] = useState(initialVisibleColumnKeys);
|
|
97
|
+
const [searchBarJql, setSearchBarJql] = useState(jql);
|
|
88
98
|
|
|
89
99
|
// analytics related parameters
|
|
90
100
|
const searchCount = useRef(0);
|
|
91
101
|
const userInteractions = useUserInteractions();
|
|
92
102
|
const initialSearchMethod =
|
|
93
103
|
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
94
|
-
fg('platform.linking-platform.datasource.show-jlol-basic-filters') && !isQueryTooComplex(
|
|
104
|
+
fg('platform.linking-platform.datasource.show-jlol-basic-filters') && !isQueryTooComplex(initialJql || '') ? 'basic' : 'jql';
|
|
95
105
|
const [currentSearchMethod, setCurrentSearchMethod] = useState(initialSearchMethod);
|
|
96
106
|
const searchMethodSearchedWith = useRef(null);
|
|
97
|
-
const visibleColumnCount = useRef((visibleColumnKeys === null || visibleColumnKeys === void 0 ? void 0 : visibleColumnKeys.length) || 0);
|
|
98
107
|
const basicFilterSelectionsSearchedWith = useRef({});
|
|
99
108
|
const isSearchedWithComplexQuery = useRef(false);
|
|
100
|
-
const parameters = useMemo(() => !!cloudId ? {
|
|
101
|
-
cloudId,
|
|
102
|
-
jql: jql || ''
|
|
103
|
-
} : undefined, [cloudId, jql]);
|
|
104
|
-
const isParametersSet = !!(jql && cloudId);
|
|
105
|
-
const {
|
|
106
|
-
columnCustomSizes,
|
|
107
|
-
onColumnResize
|
|
108
|
-
} = useColumnResize(initialColumnCustomSizes);
|
|
109
|
-
const {
|
|
110
|
-
wrappedColumnKeys,
|
|
111
|
-
onWrappedColumnChange
|
|
112
|
-
} = useColumnWrapping(initialWrappedColumnKeys);
|
|
113
|
-
const {
|
|
114
|
-
reset,
|
|
115
|
-
status,
|
|
116
|
-
onNextPage,
|
|
117
|
-
responseItems,
|
|
118
|
-
hasNextPage,
|
|
119
|
-
columns,
|
|
120
|
-
defaultVisibleColumnKeys,
|
|
121
|
-
loadDatasourceDetails,
|
|
122
|
-
totalCount,
|
|
123
|
-
extensionKey = null,
|
|
124
|
-
destinationObjectTypes
|
|
125
|
-
} = useDatasourceTableState({
|
|
126
|
-
datasourceId,
|
|
127
|
-
parameters: isParametersSet ? parameters : undefined,
|
|
128
|
-
fieldKeys: visibleColumnKeys
|
|
129
|
-
});
|
|
130
109
|
const {
|
|
131
110
|
fireEvent
|
|
132
111
|
} = useDatasourceAnalyticsEvents();
|
|
@@ -137,7 +116,6 @@ const PlainJiraIssuesConfigModal = props => {
|
|
|
137
116
|
}), [destinationObjectTypes, extensionKey]);
|
|
138
117
|
const resolvedWithNoResults = status === 'resolved' && !responseItems.length;
|
|
139
118
|
const jqlUrl = selectedJiraSite && jql && `${selectedJiraSite.url}/issues/?jql=${encodeURI(jql)}`;
|
|
140
|
-
const isInsertDisabled = !isParametersSet || status === 'rejected' || status === 'unauthorized' || status === 'loading';
|
|
141
119
|
const shouldShowIssueCount = !!totalCount && totalCount !== 1 && currentViewMode === 'table';
|
|
142
120
|
const isDataReady = (visibleColumnKeys || []).length > 0;
|
|
143
121
|
const hasNoJiraSites = availableSites && availableSites.length === 0;
|
|
@@ -164,16 +142,19 @@ const PlainJiraIssuesConfigModal = props => {
|
|
|
164
142
|
canBeLink: currentViewMode === 'inline',
|
|
165
143
|
extensionKey
|
|
166
144
|
});
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
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
|
+
*/
|
|
172
150
|
useEffect(() => {
|
|
173
151
|
if (selectedJiraSite && (!cloudId || cloudId !== selectedJiraSite.cloudId)) {
|
|
174
|
-
|
|
152
|
+
setParameters(() => ({
|
|
153
|
+
jql: '',
|
|
154
|
+
cloudId: selectedJiraSite.cloudId
|
|
155
|
+
}));
|
|
175
156
|
}
|
|
176
|
-
}, [cloudId, selectedJiraSite]);
|
|
157
|
+
}, [cloudId, selectedJiraSite, setParameters]);
|
|
177
158
|
const fireSingleItemViewedEvent = useCallback(() => {
|
|
178
159
|
fireEvent('ui.link.viewed.singleItem', {
|
|
179
160
|
...analyticsPayload,
|
|
@@ -196,7 +177,7 @@ const PlainJiraIssuesConfigModal = props => {
|
|
|
196
177
|
displayedColumnCount: visibleColumnCount.current
|
|
197
178
|
});
|
|
198
179
|
}
|
|
199
|
-
}, [
|
|
180
|
+
}, [isDataReady, fireEvent, analyticsPayload, totalCount, visibleColumnCount]);
|
|
200
181
|
const fireIssueViewAnalytics = useCallback(() => {
|
|
201
182
|
if (!totalCount) {
|
|
202
183
|
return;
|
|
@@ -233,145 +214,30 @@ const PlainJiraIssuesConfigModal = props => {
|
|
|
233
214
|
if (jql !== newParameters.jql) {
|
|
234
215
|
userInteractions.add(DatasourceAction.QUERY_UPDATED);
|
|
235
216
|
}
|
|
236
|
-
|
|
217
|
+
setParameters(state => state && newParameters.jql ? {
|
|
218
|
+
cloudId: state.cloudId,
|
|
219
|
+
jql: newParameters.jql
|
|
220
|
+
} : undefined);
|
|
237
221
|
reset({
|
|
238
222
|
shouldForceRequest: true
|
|
239
223
|
});
|
|
240
|
-
}, [jql, reset, userInteractions]);
|
|
224
|
+
}, [jql, reset, userInteractions, setParameters]);
|
|
241
225
|
const onSiteSelection = useCallback(site => {
|
|
242
226
|
userInteractions.add(DatasourceAction.INSTANCE_UPDATED);
|
|
243
|
-
|
|
244
|
-
|
|
227
|
+
setParameters({
|
|
228
|
+
jql: '',
|
|
229
|
+
cloudId: site.cloudId
|
|
230
|
+
});
|
|
245
231
|
reset({
|
|
246
232
|
shouldForceRequest: true
|
|
247
233
|
});
|
|
248
|
-
}, [reset, userInteractions]);
|
|
234
|
+
}, [reset, userInteractions, setParameters]);
|
|
249
235
|
const retrieveUrlForSmartCardRender = useCallback(() => {
|
|
250
236
|
var _data$key, _data$key$data;
|
|
251
237
|
const [data] = responseItems;
|
|
252
238
|
// agreement with BE that we will use `key` for rendering smartlink
|
|
253
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;
|
|
254
240
|
}, [responseItems]);
|
|
255
|
-
const onInsertPressed = useCallback((e, analyticsEvent) => {
|
|
256
|
-
var _insertButtonClickedE;
|
|
257
|
-
if (!isParametersSet || !jql || !selectedJiraSite) {
|
|
258
|
-
return;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
// During insertion, we want the JQL of the datasource to be whatever is in the search bar,
|
|
262
|
-
// even if the user didn't previously click search
|
|
263
|
-
const upToDateJql = searchBarJql !== null && searchBarJql !== void 0 ? searchBarJql : jql;
|
|
264
|
-
const upToDateJqlUrl = selectedJiraSite && jql && `${selectedJiraSite.url}/issues/?jql=${encodeURIComponent(upToDateJql)}`;
|
|
265
|
-
const filterSelectionCount = availableBasicFilterTypes.reduce((current, filter) => {
|
|
266
|
-
var _basicFilterSelection;
|
|
267
|
-
return {
|
|
268
|
-
...current,
|
|
269
|
-
[`${filter}BasicFilterSelectionCount`]: ((_basicFilterSelection = basicFilterSelectionsSearchedWith.current[filter]) === null || _basicFilterSelection === void 0 ? void 0 : _basicFilterSelection.length) || 0
|
|
270
|
-
};
|
|
271
|
-
}, {});
|
|
272
|
-
const insertButtonClickedEvent = analyticsEvent.update({
|
|
273
|
-
actionSubjectId: 'insert',
|
|
274
|
-
attributes: {
|
|
275
|
-
...analyticsPayload,
|
|
276
|
-
totalItemCount: totalCount || 0,
|
|
277
|
-
displayedColumnCount: visibleColumnCount.current,
|
|
278
|
-
display: getDisplayValue(currentViewMode, totalCount || 0),
|
|
279
|
-
searchCount: searchCount.current,
|
|
280
|
-
searchMethod: mapSearchMethod(searchMethodSearchedWith.current),
|
|
281
|
-
actions: userInteractions.get(),
|
|
282
|
-
isQueryComplex: isSearchedWithComplexQuery.current,
|
|
283
|
-
...(searchMethodSearchedWith.current === 'basic' ? {
|
|
284
|
-
...filterSelectionCount
|
|
285
|
-
} : {})
|
|
286
|
-
},
|
|
287
|
-
eventType: 'ui'
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
// additional event for tracking in confluence against JIM
|
|
291
|
-
const macroInsertedEvent = analyticsEvent.clone();
|
|
292
|
-
macroInsertedEvent === null || macroInsertedEvent === void 0 ? void 0 : macroInsertedEvent.update({
|
|
293
|
-
eventType: 'track',
|
|
294
|
-
action: 'inserted',
|
|
295
|
-
actionSubject: 'macro',
|
|
296
|
-
actionSubjectId: 'jlol',
|
|
297
|
-
attributes: {
|
|
298
|
-
...analyticsPayload,
|
|
299
|
-
totalItemCount: totalCount || 0,
|
|
300
|
-
displayedColumnCount: visibleColumnCount.current,
|
|
301
|
-
display: getDisplayValue(currentViewMode, totalCount || 0),
|
|
302
|
-
searchCount: searchCount.current,
|
|
303
|
-
searchMethod: mapSearchMethod(searchMethodSearchedWith.current),
|
|
304
|
-
actions: userInteractions.get()
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
const consumerEvent = (_insertButtonClickedE = insertButtonClickedEvent.clone()) !== null && _insertButtonClickedE !== void 0 ? _insertButtonClickedE : undefined;
|
|
308
|
-
insertButtonClickedEvent.fire(EVENT_CHANNEL);
|
|
309
|
-
const firstIssueUrl = retrieveUrlForSmartCardRender();
|
|
310
|
-
if (currentViewMode === 'inline') {
|
|
311
|
-
macroInsertedEvent === null || macroInsertedEvent === void 0 ? void 0 : macroInsertedEvent.fire(EVENT_CHANNEL);
|
|
312
|
-
const url = responseItems.length === 1 ? firstIssueUrl : upToDateJqlUrl;
|
|
313
|
-
onInsert({
|
|
314
|
-
type: 'inlineCard',
|
|
315
|
-
attrs: {
|
|
316
|
-
url
|
|
317
|
-
}
|
|
318
|
-
}, consumerEvent);
|
|
319
|
-
} else {
|
|
320
|
-
onInsert(buildDatasourceAdf({
|
|
321
|
-
id: datasourceId,
|
|
322
|
-
parameters: {
|
|
323
|
-
cloudId,
|
|
324
|
-
jql: upToDateJql // TODO support non JQL type
|
|
325
|
-
},
|
|
326
|
-
views: [{
|
|
327
|
-
type: 'table',
|
|
328
|
-
properties: {
|
|
329
|
-
columns: (visibleColumnKeys || []).map(key => {
|
|
330
|
-
const width = columnCustomSizes === null || columnCustomSizes === void 0 ? void 0 : columnCustomSizes[key];
|
|
331
|
-
const isWrapped = wrappedColumnKeys === null || wrappedColumnKeys === void 0 ? void 0 : wrappedColumnKeys.includes(key);
|
|
332
|
-
return {
|
|
333
|
-
key,
|
|
334
|
-
...(width ? {
|
|
335
|
-
width
|
|
336
|
-
} : {}),
|
|
337
|
-
...(isWrapped ? {
|
|
338
|
-
isWrapped
|
|
339
|
-
} : {})
|
|
340
|
-
};
|
|
341
|
-
})
|
|
342
|
-
}
|
|
343
|
-
}]
|
|
344
|
-
}, upToDateJqlUrl), consumerEvent);
|
|
345
|
-
}
|
|
346
|
-
}, [isParametersSet, jql, selectedJiraSite, searchBarJql, analyticsPayload, totalCount, currentViewMode, retrieveUrlForSmartCardRender, responseItems.length, onInsert, datasourceId, cloudId, visibleColumnKeys, columnCustomSizes, wrappedColumnKeys, userInteractions]);
|
|
347
|
-
const handleOnNextPage = useCallback((onNextPageProps = {}) => {
|
|
348
|
-
userInteractions.add(DatasourceAction.NEXT_PAGE_SCROLLED);
|
|
349
|
-
onNextPage(onNextPageProps);
|
|
350
|
-
}, [onNextPage, userInteractions]);
|
|
351
|
-
const handleVisibleColumnKeysChange = useCallback((newVisibleColumnKeys = []) => {
|
|
352
|
-
const columnAction = getColumnAction(visibleColumnKeys || [], newVisibleColumnKeys);
|
|
353
|
-
userInteractions.add(columnAction);
|
|
354
|
-
visibleColumnCount.current = newVisibleColumnKeys.length;
|
|
355
|
-
setVisibleColumnKeys(newVisibleColumnKeys);
|
|
356
|
-
}, [visibleColumnKeys, userInteractions]);
|
|
357
|
-
const issueLikeDataTableView = useMemo(() => jsx(ContentContainer, {
|
|
358
|
-
withTableBorder: true
|
|
359
|
-
}, jsx(IssueLikeDataTableView, {
|
|
360
|
-
testId: "jira-datasource-table",
|
|
361
|
-
status: status,
|
|
362
|
-
columns: columns,
|
|
363
|
-
items: responseItems,
|
|
364
|
-
hasNextPage: hasNextPage,
|
|
365
|
-
visibleColumnKeys: visibleColumnKeys || defaultVisibleColumnKeys,
|
|
366
|
-
onNextPage: handleOnNextPage,
|
|
367
|
-
onLoadDatasourceDetails: loadDatasourceDetails,
|
|
368
|
-
onVisibleColumnKeysChange: handleVisibleColumnKeysChange,
|
|
369
|
-
extensionKey: extensionKey,
|
|
370
|
-
columnCustomSizes: columnCustomSizes,
|
|
371
|
-
onColumnResize: onColumnResize,
|
|
372
|
-
wrappedColumnKeys: wrappedColumnKeys,
|
|
373
|
-
onWrappedColumnChange: fg('platform.linking-platform.datasource-word_wrap') ? onWrappedColumnChange : undefined
|
|
374
|
-
})), [status, columns, responseItems, hasNextPage, visibleColumnKeys, defaultVisibleColumnKeys, handleOnNextPage, loadDatasourceDetails, handleVisibleColumnKeysChange, extensionKey, columnCustomSizes, onColumnResize, wrappedColumnKeys, onWrappedColumnChange]);
|
|
375
241
|
const renderCountModeContent = useCallback(() => {
|
|
376
242
|
const selectedJiraSiteUrl = selectedJiraSite === null || selectedJiraSite === void 0 ? void 0 : selectedJiraSite.url;
|
|
377
243
|
if (status === 'unauthorized') {
|
|
@@ -429,8 +295,12 @@ const PlainJiraIssuesConfigModal = props => {
|
|
|
429
295
|
} : undefined
|
|
430
296
|
}));
|
|
431
297
|
}
|
|
432
|
-
return
|
|
433
|
-
|
|
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]);
|
|
434
304
|
const siteSelectorLabel = availableSites && availableSites.length > 1 ? modalMessages.insertIssuesTitleManySites : modalMessages.insertIssuesTitle;
|
|
435
305
|
const getCancelButtonAnalyticsPayload = useCallback(() => {
|
|
436
306
|
return {
|
|
@@ -439,6 +309,41 @@ const PlainJiraIssuesConfigModal = props => {
|
|
|
439
309
|
actions: userInteractions.get()
|
|
440
310
|
};
|
|
441
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
|
+
});
|
|
442
347
|
return jsx(IntlMessagesProvider, {
|
|
443
348
|
defaultMessages: i18nEN,
|
|
444
349
|
loaderFn: fetchMessagesForLocale
|
|
@@ -473,11 +378,11 @@ const PlainJiraIssuesConfigModal = props => {
|
|
|
473
378
|
onCancel: onCancel,
|
|
474
379
|
getAnalyticsPayload: getCancelButtonAnalyticsPayload,
|
|
475
380
|
testId: "jira-datasource-modal--cancel-button"
|
|
476
|
-
}), !hasNoJiraSites && jsx(
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
381
|
+
}), !hasNoJiraSites && jsx(InsertButton, {
|
|
382
|
+
testId: "jira-datasource-modal--insert-button",
|
|
383
|
+
url: urlToInsert,
|
|
384
|
+
overwriteParameters: updateParametersBeforeInsert,
|
|
385
|
+
getAnalyticsPayload: getInsertButtonAnalyticsPayload
|
|
481
386
|
}, jsx(FormattedMessage, modalMessages.insertIssuesButtonText))))));
|
|
482
387
|
};
|
|
483
388
|
const analyticsContextAttributes = {
|
|
@@ -493,9 +398,35 @@ const contextData = {
|
|
|
493
398
|
...analyticsContextAttributes
|
|
494
399
|
}
|
|
495
400
|
};
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
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
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
8
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
9
|
+
import { jsx } from '@emotion/react';
|
|
10
|
+
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
11
|
+
import { DatasourceExperienceIdProvider } from '../../../../contexts/datasource-experience-id';
|
|
12
|
+
import { UserInteractionsProvider } from '../../../../contexts/user-interactions';
|
|
13
|
+
import { DatasourceContextProvider } from '../datasource-context';
|
|
14
|
+
import { DatasourceViewModeProvider } from '../mode-switcher/useViewModeContext';
|
|
15
|
+
var DEFAULT_VIEW_MODE = 'table';
|
|
16
|
+
export var createDatasourceModal = function createDatasourceModal(_ref) {
|
|
17
|
+
var isValidParameters = _ref.isValidParameters,
|
|
18
|
+
dataProvider = _ref.dataProvider,
|
|
19
|
+
ModalContent = _ref.component;
|
|
20
|
+
return function (props) {
|
|
21
|
+
var datasourceId = props.datasourceId,
|
|
22
|
+
visibleColumnKeys = props.visibleColumnKeys,
|
|
23
|
+
columnCustomSizes = props.columnCustomSizes,
|
|
24
|
+
wrappedColumnKeys = props.wrappedColumnKeys,
|
|
25
|
+
parameters = props.parameters,
|
|
26
|
+
onInsert = props.onInsert,
|
|
27
|
+
viewMode = props.viewMode;
|
|
28
|
+
return jsx(AnalyticsContext, {
|
|
29
|
+
data: {
|
|
30
|
+
source: 'datasourceConfigModal',
|
|
31
|
+
component: 'datasourceConfigModal',
|
|
32
|
+
attributes: {
|
|
33
|
+
dataProvider: dataProvider
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}, jsx(DatasourceExperienceIdProvider, null, jsx(UserInteractionsProvider, null, jsx(DatasourceContextProvider, {
|
|
37
|
+
datasourceId: datasourceId,
|
|
38
|
+
initialVisibleColumnKeys: visibleColumnKeys,
|
|
39
|
+
initialColumnCustomSizes: columnCustomSizes,
|
|
40
|
+
initialWrappedColumnKeys: wrappedColumnKeys,
|
|
41
|
+
initialParameters: parameters,
|
|
42
|
+
isValidParameters: isValidParameters,
|
|
43
|
+
onInsert: onInsert
|
|
44
|
+
}, jsx(DatasourceViewModeProvider, {
|
|
45
|
+
viewMode: viewMode !== null && viewMode !== void 0 ? viewMode : DEFAULT_VIEW_MODE
|
|
46
|
+
}, jsx(ModalContent, props))))));
|
|
47
|
+
};
|
|
48
|
+
};
|