@atlaskit/link-datasource 1.26.3 → 1.27.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.
- package/CHANGELOG.md +10 -0
- package/dist/cjs/ui/common/modal/count-view-smart-link/index.js +40 -0
- package/dist/cjs/ui/{jira-issues-modal/modal/jira-display-view-dropdown/jira-display-view-drop-down.js → common/modal/display-view-dropdown/display-view-drop-down.js} +29 -13
- package/dist/cjs/ui/common/modal/display-view-dropdown/messages.js +58 -0
- package/dist/cjs/ui/confluence-search-modal/modal/index.js +114 -45
- package/dist/cjs/ui/confluence-search-modal/modal/messages.js +5 -0
- package/dist/cjs/ui/jira-issues-modal/modal/index.js +8 -23
- package/dist/cjs/ui/jira-issues-modal/modal/messages.js +0 -20
- package/dist/es2019/ui/common/modal/count-view-smart-link/index.js +30 -0
- package/dist/es2019/ui/common/modal/display-view-dropdown/display-view-drop-down.js +71 -0
- package/dist/es2019/ui/common/modal/display-view-dropdown/messages.js +52 -0
- package/dist/es2019/ui/confluence-search-modal/modal/index.js +98 -31
- package/dist/es2019/ui/confluence-search-modal/modal/messages.js +5 -0
- package/dist/es2019/ui/jira-issues-modal/modal/index.js +9 -24
- package/dist/es2019/ui/jira-issues-modal/modal/messages.js +0 -20
- package/dist/esm/ui/common/modal/count-view-smart-link/index.js +32 -0
- package/dist/esm/ui/common/modal/display-view-dropdown/display-view-drop-down.js +73 -0
- package/dist/esm/ui/common/modal/display-view-dropdown/messages.js +52 -0
- package/dist/esm/ui/confluence-search-modal/modal/index.js +114 -45
- package/dist/esm/ui/confluence-search-modal/modal/messages.js +5 -0
- package/dist/esm/ui/jira-issues-modal/modal/index.js +9 -24
- package/dist/esm/ui/jira-issues-modal/modal/messages.js +0 -20
- package/dist/types/common/types.d.ts +5 -5
- package/dist/types/ui/common/modal/count-view-smart-link/index.d.ts +9 -0
- package/dist/types/ui/common/modal/display-view-dropdown/display-view-drop-down.d.ts +8 -0
- package/dist/types/ui/common/modal/display-view-dropdown/messages.d.ts +42 -0
- package/dist/types/ui/confluence-search-modal/modal/messages.d.ts +5 -0
- package/dist/types/ui/confluence-search-modal/types.d.ts +2 -2
- package/dist/types/ui/jira-issues-modal/modal/messages.d.ts +0 -20
- package/dist/types-ts4.5/common/types.d.ts +5 -5
- package/dist/types-ts4.5/ui/common/modal/count-view-smart-link/index.d.ts +9 -0
- package/dist/types-ts4.5/ui/common/modal/display-view-dropdown/display-view-drop-down.d.ts +8 -0
- package/dist/types-ts4.5/ui/common/modal/display-view-dropdown/messages.d.ts +42 -0
- package/dist/types-ts4.5/ui/confluence-search-modal/modal/messages.d.ts +5 -0
- package/dist/types-ts4.5/ui/confluence-search-modal/types.d.ts +2 -2
- package/dist/types-ts4.5/ui/jira-issues-modal/modal/messages.d.ts +0 -20
- package/examples-helpers/mockSmartLinkData.ts +49 -0
- package/examples-helpers/smartLinkCustomClient.ts +8 -3
- package/package.json +1 -1
- package/dist/es2019/ui/jira-issues-modal/modal/jira-display-view-dropdown/jira-display-view-drop-down.js +0 -55
- package/dist/esm/ui/jira-issues-modal/modal/jira-display-view-dropdown/jira-display-view-drop-down.js +0 -57
- package/dist/types/ui/jira-issues-modal/modal/jira-display-view-dropdown/jira-display-view-drop-down.d.ts +0 -8
- package/dist/types-ts4.5/ui/jira-issues-modal/modal/jira-display-view-dropdown/jira-display-view-drop-down.d.ts +0 -8
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
3
|
+
import { FormattedMessage, useIntl } from 'react-intl-next';
|
|
4
|
+
import DropdownMenu, { DropdownItem, DropdownItemGroup } from '@atlaskit/dropdown-menu';
|
|
5
|
+
import TableIcon from '@atlaskit/icon/glyph/table';
|
|
6
|
+
import { Box, xcss } from '@atlaskit/primitives';
|
|
7
|
+
import { displayViewDropDownMessages } from './messages';
|
|
8
|
+
const dropDownItemGroupStyles = xcss({
|
|
9
|
+
width: '320px',
|
|
10
|
+
height: '140px',
|
|
11
|
+
paddingTop: 'space.050',
|
|
12
|
+
paddingBottom: 'space.050',
|
|
13
|
+
borderRadius: 'border.radius'
|
|
14
|
+
});
|
|
15
|
+
const InlineIcon = jsx("svg", {
|
|
16
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
17
|
+
width: "24",
|
|
18
|
+
height: "24",
|
|
19
|
+
viewBox: "0 0 24 24",
|
|
20
|
+
fill: "none"
|
|
21
|
+
}, jsx("path", {
|
|
22
|
+
fillRule: "evenodd",
|
|
23
|
+
clipRule: "evenodd",
|
|
24
|
+
d: "M4 9C2.89543 9 2 9.67155 2 10.5V13.5C2 14.3285 2.89543 15 4 15H20C21.1046 15 22 14.3285 22 13.5V10.5C22 9.67155 21.1046 9 20 9H4ZM4.22222 11.25C4.22222 10.5 4.22222 10.5 5 10.5H7C7.55556 10.5 7.55556 10.5 7.55556 11.25V13C7.55556 13.5 7.55556 13.5 7 13.5H5C4.22222 13.5 4.22222 13.5 4.22222 13V11.25ZM9 12C9 11.7929 9.2239 11.625 9.5 11.625H19.5C19.7761 11.625 20 11.7929 20 12C20 12.2071 19.7761 12.375 19.5 12.375H9.5C9.2239 12.375 9 12.2071 9 12Z",
|
|
25
|
+
fill: 'currentColor'
|
|
26
|
+
}));
|
|
27
|
+
export const DisplayViewDropDown = ({
|
|
28
|
+
onViewModeChange,
|
|
29
|
+
viewMode
|
|
30
|
+
}) => {
|
|
31
|
+
const {
|
|
32
|
+
formatMessage
|
|
33
|
+
} = useIntl();
|
|
34
|
+
// TODO: further refactoring in EDM-9573
|
|
35
|
+
// temporary fix. transition 'count' to 'inline', 'issue' to 'table'
|
|
36
|
+
const isJira = viewMode === 'issue' || viewMode === 'count';
|
|
37
|
+
const isTable = viewMode === 'table' || viewMode === 'issue';
|
|
38
|
+
const triggerText = isTable ? formatMessage(
|
|
39
|
+
// TODO EDM-9573, remove once EDM-9431 is merged
|
|
40
|
+
isJira ? displayViewDropDownMessages.tableViewModeLabel : displayViewDropDownMessages.tableViewModeLabelDuplicate) : formatMessage(
|
|
41
|
+
// TODO EDM-9573, remove once EDM-9431 is merged
|
|
42
|
+
isJira ? displayViewDropDownMessages.inlineLinkViewModeLabel : displayViewDropDownMessages.inlineLinkViewModeLabelDuplicate);
|
|
43
|
+
return jsx(DropdownMenu, {
|
|
44
|
+
trigger: triggerText,
|
|
45
|
+
testId: "datasource-modal--view-drop-down"
|
|
46
|
+
}, jsx(Box, {
|
|
47
|
+
xcss: dropDownItemGroupStyles
|
|
48
|
+
}, jsx(DropdownItemGroup, null, jsx(DropdownItem, {
|
|
49
|
+
testId: "dropdown-item-table",
|
|
50
|
+
onClick: () => onViewModeChange(isJira ? 'issue' : 'table'),
|
|
51
|
+
isSelected: isTable,
|
|
52
|
+
description: formatMessage(
|
|
53
|
+
// TODO EDM-9573, remove once EDM-9431 is merged
|
|
54
|
+
isJira ? displayViewDropDownMessages.tableViewModeDescription : displayViewDropDownMessages.tableViewModeDescriptionDuplicate),
|
|
55
|
+
elemBefore: jsx(TableIcon, {
|
|
56
|
+
label: "table icon"
|
|
57
|
+
})
|
|
58
|
+
}, jsx(FormattedMessage
|
|
59
|
+
// TODO EDM-9573, remove once EDM-9431 is merged
|
|
60
|
+
, isJira ? displayViewDropDownMessages.tableViewModeLabel : displayViewDropDownMessages.tableViewModeLabelDuplicate)), jsx(DropdownItem, {
|
|
61
|
+
testId: "dropdown-item-inline-link",
|
|
62
|
+
onClick: () => onViewModeChange(isJira ? 'count' : 'inline'),
|
|
63
|
+
isSelected: !isTable,
|
|
64
|
+
description: formatMessage(
|
|
65
|
+
// TODO EDM-9573, remove once EDM-9431 is merged
|
|
66
|
+
isJira ? displayViewDropDownMessages.inlineLinkViewModeDescription : displayViewDropDownMessages.inlineLinkViewModeDescriptionDuplicate),
|
|
67
|
+
elemBefore: InlineIcon
|
|
68
|
+
}, jsx(FormattedMessage
|
|
69
|
+
// TODO EDM-9573, remove once EDM-9431 is merged
|
|
70
|
+
, isJira ? displayViewDropDownMessages.inlineLinkViewModeLabel : displayViewDropDownMessages.inlineLinkViewModeLabelDuplicate)))));
|
|
71
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { defineMessages } from 'react-intl-next';
|
|
2
|
+
export const displayViewDropDownMessages = defineMessages({
|
|
3
|
+
// TODO EDM-9573
|
|
4
|
+
// remove duplicate from end of key once EDM-9431 is merged
|
|
5
|
+
tableViewModeLabelDuplicate: {
|
|
6
|
+
id: 'linkDataSource.configmodal.tableViewModeLabel',
|
|
7
|
+
description: 'Display search results as a table',
|
|
8
|
+
defaultMessage: 'Table'
|
|
9
|
+
},
|
|
10
|
+
// remove duplicate from end of key once EDM-9431 is merged
|
|
11
|
+
tableViewModeDescriptionDuplicate: {
|
|
12
|
+
id: 'linkDataSource.configmodal.tableViewModeDescription',
|
|
13
|
+
description: 'Description for table view mode',
|
|
14
|
+
defaultMessage: 'Display search results as a table'
|
|
15
|
+
},
|
|
16
|
+
// remove duplicate from end of key once EDM-9431 is merged
|
|
17
|
+
inlineLinkViewModeLabelDuplicate: {
|
|
18
|
+
id: 'linkDataSource.configmodal.inlineLinkViewModeLabel',
|
|
19
|
+
description: 'Display the number of search results as an inline smart link',
|
|
20
|
+
defaultMessage: 'Inline link'
|
|
21
|
+
},
|
|
22
|
+
// remove duplicate from end of key once EDM-9431 is merged
|
|
23
|
+
inlineLinkViewModeDescriptionDuplicate: {
|
|
24
|
+
id: 'linkDataSource.configmodal.inlineLinkViewModeDescription',
|
|
25
|
+
description: 'Description for inline view mode',
|
|
26
|
+
defaultMessage: 'Display the number of search results or as an inline smart link'
|
|
27
|
+
},
|
|
28
|
+
// delete once EDM-9431 is merged
|
|
29
|
+
tableViewModeLabel: {
|
|
30
|
+
id: 'linkDataSource.jira-issues.configmodal.tableViewModeLabel',
|
|
31
|
+
description: 'Display Jira search results as a table',
|
|
32
|
+
defaultMessage: 'Table'
|
|
33
|
+
},
|
|
34
|
+
// delete once EDM-9431 is merged
|
|
35
|
+
tableViewModeDescription: {
|
|
36
|
+
id: 'linkDataSource.jira-issues.configmodal.tableViewModeDescription',
|
|
37
|
+
description: 'Description for table view mode',
|
|
38
|
+
defaultMessage: 'Display Jira search results as a table'
|
|
39
|
+
},
|
|
40
|
+
// delete once EDM-9431 is merged
|
|
41
|
+
inlineLinkViewModeLabel: {
|
|
42
|
+
id: 'linkDataSource.jira-issues.configmodal.inlineLinkViewModeLabel',
|
|
43
|
+
description: 'Display the number of search results as an inline smart link',
|
|
44
|
+
defaultMessage: 'Inline link'
|
|
45
|
+
},
|
|
46
|
+
// delete once EDM-9431 is merged
|
|
47
|
+
inlineLinkViewModeDescription: {
|
|
48
|
+
id: 'linkDataSource.jira-issues.configmodal.inlineLinkViewModeDescription',
|
|
49
|
+
description: 'Description for inline link view mode',
|
|
50
|
+
defaultMessage: 'Display the number of search results or as an inline smart link'
|
|
51
|
+
}
|
|
52
|
+
});
|
|
@@ -27,6 +27,8 @@ import { NoResults } from '../../common/error-state/no-results';
|
|
|
27
27
|
import { InitialStateView } from '../../common/initial-state-view';
|
|
28
28
|
import { CancelButton } from '../../common/modal/cancel-button';
|
|
29
29
|
import { ContentContainer } from '../../common/modal/content-container';
|
|
30
|
+
import { SmartCardPlaceholder, SmartLink } from '../../common/modal/count-view-smart-link';
|
|
31
|
+
import { DisplayViewDropDown } from '../../common/modal/display-view-dropdown/display-view-drop-down';
|
|
30
32
|
import { SiteSelector } from '../../common/modal/site-selector';
|
|
31
33
|
import { EmptyState, IssueLikeDataTableView } from '../../issue-like-table';
|
|
32
34
|
import ConfluenceSearchContainer from '../confluence-search-container';
|
|
@@ -64,11 +66,13 @@ export const PlainConfluenceSearchConfigModal = props => {
|
|
|
64
66
|
wrappedColumnKeys: initialWrappedColumnKeys,
|
|
65
67
|
onCancel,
|
|
66
68
|
onInsert,
|
|
69
|
+
viewMode = 'table',
|
|
67
70
|
parameters: initialParameters,
|
|
68
71
|
url: urlBeingEdited,
|
|
69
72
|
visibleColumnKeys: initialVisibleColumnKeys
|
|
70
73
|
} = props;
|
|
71
74
|
const [availableSites, setAvailableSites] = useState(undefined);
|
|
75
|
+
const [currentViewMode, setCurrentViewMode] = useState(viewMode);
|
|
72
76
|
const [cloudId, setCloudId] = useState(initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.cloudId);
|
|
73
77
|
const [searchString, setSearchString] = useState(initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.searchString);
|
|
74
78
|
const [visibleColumnKeys, setVisibleColumnKeys] = useState(initialVisibleColumnKeys);
|
|
@@ -133,6 +137,7 @@ export const PlainConfluenceSearchConfigModal = props => {
|
|
|
133
137
|
// TODO: further refactoring in EDM-9573
|
|
134
138
|
// https://stash.atlassian.com/projects/ATLASSIAN/repos/atlassian-frontend-monorepo/pull-requests/82725/overview?commentId=6829171
|
|
135
139
|
const onSiteSelection = useCallback(site => {
|
|
140
|
+
userInteractionActions.current.add(DatasourceAction.INSTANCE_UPDATED);
|
|
136
141
|
setSearchString(undefined);
|
|
137
142
|
setCloudId(site.cloudId);
|
|
138
143
|
reset({
|
|
@@ -207,14 +212,45 @@ export const PlainConfluenceSearchConfigModal = props => {
|
|
|
207
212
|
const resolvedWithNoResults = status === 'resolved' && !responseItems.length;
|
|
208
213
|
const hasConfluenceSearchParams = selectedConfluenceSite && searchString;
|
|
209
214
|
const selectedConfluenceSiteUrl = selectedConfluenceSite === null || selectedConfluenceSite === void 0 ? void 0 : selectedConfluenceSite.url;
|
|
210
|
-
const confluenceSearchUrl = selectedConfluenceSiteUrl && searchString !== undefined && `${selectedConfluenceSiteUrl}/wiki/search
|
|
215
|
+
const confluenceSearchUrl = selectedConfluenceSiteUrl && searchString !== undefined && `${selectedConfluenceSiteUrl}/wiki/search?text=${encodeURI(searchString)}`;
|
|
211
216
|
const analyticsPayload = useMemo(() => ({
|
|
212
217
|
extensionKey,
|
|
213
218
|
destinationObjectTypes,
|
|
214
219
|
searchCount: searchCount.current,
|
|
215
220
|
actions: Array.from(userInteractionActions.current)
|
|
216
221
|
}), [destinationObjectTypes, extensionKey]);
|
|
217
|
-
const
|
|
222
|
+
const isDataReady = (visibleColumnKeys || []).length > 0;
|
|
223
|
+
const fireInlineViewedEvent = useCallback(() => {
|
|
224
|
+
fireEvent('ui.link.viewed.count', {
|
|
225
|
+
...analyticsPayload,
|
|
226
|
+
searchMethod: DatasourceSearchMethod.DATASOURCE_SEARCH_QUERY,
|
|
227
|
+
totalItemCount: totalCount || 0
|
|
228
|
+
});
|
|
229
|
+
}, [analyticsPayload, fireEvent, totalCount]);
|
|
230
|
+
const fireTableViewedEvent = useCallback(() => {
|
|
231
|
+
if (isDataReady) {
|
|
232
|
+
fireEvent('ui.table.viewed.datasourceConfigModal', {
|
|
233
|
+
...analyticsPayload,
|
|
234
|
+
totalItemCount: totalCount || 0,
|
|
235
|
+
searchMethod: DatasourceSearchMethod.DATASOURCE_SEARCH_QUERY,
|
|
236
|
+
displayedColumnCount: visibleColumnCount.current
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
}, [analyticsPayload, fireEvent, totalCount, isDataReady]);
|
|
240
|
+
useEffect(() => {
|
|
241
|
+
const isResolved = status === 'resolved';
|
|
242
|
+
const isTableViewMode = currentViewMode === 'issue' || currentViewMode === 'table';
|
|
243
|
+
const isInlineViewMode = currentViewMode === 'count' || currentViewMode === 'inline';
|
|
244
|
+
if (!isResolved) {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
if (isTableViewMode) {
|
|
248
|
+
fireTableViewedEvent();
|
|
249
|
+
} else if (isInlineViewMode) {
|
|
250
|
+
fireInlineViewedEvent();
|
|
251
|
+
}
|
|
252
|
+
}, [currentViewMode, fireInlineViewedEvent, fireTableViewedEvent, status]);
|
|
253
|
+
const renderTableModalContent = useCallback(() => {
|
|
218
254
|
if (status === 'rejected') {
|
|
219
255
|
return jsx(ModalLoadingError, null);
|
|
220
256
|
} else if (status === 'unauthorized') {
|
|
@@ -238,7 +274,22 @@ export const PlainConfluenceSearchConfigModal = props => {
|
|
|
238
274
|
}
|
|
239
275
|
return confluenceSearchTable;
|
|
240
276
|
}, [columns.length, selectedConfluenceSiteUrl, confluenceSearchTable, resolvedWithNoResults, status, urlBeingEdited, hasConfluenceSearchParams]);
|
|
241
|
-
const
|
|
277
|
+
const renderInlineLinkModalContent = useCallback(() => {
|
|
278
|
+
if (status === 'unauthorized') {
|
|
279
|
+
return jsx(AccessRequired, {
|
|
280
|
+
url: selectedConfluenceSiteUrl || urlBeingEdited
|
|
281
|
+
});
|
|
282
|
+
} else if (status === 'empty' || !selectedConfluenceSiteUrl) {
|
|
283
|
+
return jsx(SmartCardPlaceholder, {
|
|
284
|
+
placeholderText: confluenceSearchModalMessages.resultsCountSmartCardPlaceholderText
|
|
285
|
+
});
|
|
286
|
+
} else {
|
|
287
|
+
return confluenceSearchUrl && jsx(SmartLink, {
|
|
288
|
+
url: confluenceSearchUrl
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
}, [confluenceSearchUrl, selectedConfluenceSiteUrl, status, urlBeingEdited]);
|
|
292
|
+
const shouldShowResultsCount = !!totalCount && currentViewMode === 'table';
|
|
242
293
|
const onInsertPressed = useCallback((e, analyticsEvent) => {
|
|
243
294
|
var _insertButtonClickedE;
|
|
244
295
|
if (!isParametersSet || !cloudId) {
|
|
@@ -250,7 +301,7 @@ export const PlainConfluenceSearchConfigModal = props => {
|
|
|
250
301
|
...analyticsPayload,
|
|
251
302
|
totalItemCount: totalCount || 0,
|
|
252
303
|
displayedColumnCount: visibleColumnCount.current,
|
|
253
|
-
display: DatasourceDisplay.DATASOURCE_TABLE,
|
|
304
|
+
display: currentViewMode === 'inline' ? DatasourceDisplay.DATASOURCE_INLINE : DatasourceDisplay.DATASOURCE_TABLE,
|
|
254
305
|
searchCount: searchCount.current,
|
|
255
306
|
searchMethod: DatasourceSearchMethod.DATASOURCE_SEARCH_QUERY,
|
|
256
307
|
actions: Array.from(userInteractionActions.current)
|
|
@@ -259,32 +310,45 @@ export const PlainConfluenceSearchConfigModal = props => {
|
|
|
259
310
|
});
|
|
260
311
|
const consumerEvent = (_insertButtonClickedE = insertButtonClickedEvent.clone()) !== null && _insertButtonClickedE !== void 0 ? _insertButtonClickedE : undefined;
|
|
261
312
|
insertButtonClickedEvent.fire(EVENT_CHANNEL);
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
},
|
|
268
|
-
views: [{
|
|
269
|
-
type: 'table',
|
|
270
|
-
properties: {
|
|
271
|
-
columns: (visibleColumnKeys || []).map(key => {
|
|
272
|
-
const width = columnCustomSizes === null || columnCustomSizes === void 0 ? void 0 : columnCustomSizes[key];
|
|
273
|
-
const isWrapped = wrappedColumnKeys === null || wrappedColumnKeys === void 0 ? void 0 : wrappedColumnKeys.includes(key);
|
|
274
|
-
return {
|
|
275
|
-
key,
|
|
276
|
-
...(width ? {
|
|
277
|
-
width
|
|
278
|
-
} : {}),
|
|
279
|
-
...(isWrapped ? {
|
|
280
|
-
isWrapped
|
|
281
|
-
} : {})
|
|
282
|
-
};
|
|
283
|
-
})
|
|
313
|
+
if (currentViewMode === 'inline') {
|
|
314
|
+
onInsert({
|
|
315
|
+
type: 'inlineCard',
|
|
316
|
+
attrs: {
|
|
317
|
+
url: confluenceSearchUrl
|
|
284
318
|
}
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
|
|
319
|
+
}, consumerEvent);
|
|
320
|
+
} else {
|
|
321
|
+
onInsert(buildDatasourceAdf({
|
|
322
|
+
id: datasourceId,
|
|
323
|
+
parameters: {
|
|
324
|
+
...parameters,
|
|
325
|
+
cloudId
|
|
326
|
+
},
|
|
327
|
+
views: [{
|
|
328
|
+
type: 'table',
|
|
329
|
+
properties: {
|
|
330
|
+
columns: (visibleColumnKeys || []).map(key => {
|
|
331
|
+
const width = columnCustomSizes === null || columnCustomSizes === void 0 ? void 0 : columnCustomSizes[key];
|
|
332
|
+
const isWrapped = wrappedColumnKeys === null || wrappedColumnKeys === void 0 ? void 0 : wrappedColumnKeys.includes(key);
|
|
333
|
+
return {
|
|
334
|
+
key,
|
|
335
|
+
...(width ? {
|
|
336
|
+
width
|
|
337
|
+
} : {}),
|
|
338
|
+
...(isWrapped ? {
|
|
339
|
+
isWrapped
|
|
340
|
+
} : {})
|
|
341
|
+
};
|
|
342
|
+
})
|
|
343
|
+
}
|
|
344
|
+
}]
|
|
345
|
+
}), consumerEvent);
|
|
346
|
+
}
|
|
347
|
+
}, [isParametersSet, cloudId, analyticsPayload, totalCount, currentViewMode, onInsert, confluenceSearchUrl, datasourceId, parameters, visibleColumnKeys, columnCustomSizes, wrappedColumnKeys]);
|
|
348
|
+
const handleViewModeChange = selectedMode => {
|
|
349
|
+
userInteractionActions.current.add(DatasourceAction.DISPLAY_VIEW_CHANGED);
|
|
350
|
+
setCurrentViewMode(selectedMode);
|
|
351
|
+
};
|
|
288
352
|
const onSearch = useCallback(newSearchString => {
|
|
289
353
|
searchCount.current++;
|
|
290
354
|
userInteractionActions.current.add(DatasourceAction.QUERY_UPDATED);
|
|
@@ -316,14 +380,17 @@ export const PlainConfluenceSearchConfigModal = props => {
|
|
|
316
380
|
selectedSite: selectedConfluenceSite,
|
|
317
381
|
testId: "confluence-search-datasource-modal--site-selector",
|
|
318
382
|
label: siteSelectorLabel
|
|
319
|
-
}))
|
|
383
|
+
})), !hasNoConfluenceSites && jsx(DisplayViewDropDown, {
|
|
384
|
+
onViewModeChange: handleViewModeChange,
|
|
385
|
+
viewMode: currentViewMode
|
|
386
|
+
})), jsx(ModalBody, null, !hasNoConfluenceSites ? jsx(Fragment, null, jsx(Box, {
|
|
320
387
|
xcss: inputContainerStyles
|
|
321
388
|
}, jsx(ConfluenceSearchContainer, {
|
|
322
389
|
cloudId: cloudId,
|
|
323
390
|
isSearching: status === 'loading',
|
|
324
391
|
onSearch: onSearch,
|
|
325
392
|
initialSearchValue: initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.searchString
|
|
326
|
-
})),
|
|
393
|
+
})), currentViewMode === 'inline' ? renderInlineLinkModalContent() : renderTableModalContent()) : jsx(NoInstancesView, {
|
|
327
394
|
title: confluenceSearchModalMessages.noAccessToConfluenceSitesTitle,
|
|
328
395
|
description: confluenceSearchModalMessages.noAccessToConfluenceSitesDescription,
|
|
329
396
|
testId: 'no-confluence-instances-content'
|
|
@@ -44,5 +44,10 @@ export const confluenceSearchModalMessages = defineMessages({
|
|
|
44
44
|
id: 'linkDataSource.confluence-search.no.confluence.sites.access.description',
|
|
45
45
|
description: 'Description that shows in the modal when user has no access to any Confluence sites',
|
|
46
46
|
defaultMessage: 'To request access, contact your admin.'
|
|
47
|
+
},
|
|
48
|
+
resultsCountSmartCardPlaceholderText: {
|
|
49
|
+
id: 'linkDataSource.confluence-search.configmodal.placeholder.issues',
|
|
50
|
+
description: 'Placeholder text that will be placed next to a count of confluence search results',
|
|
51
|
+
defaultMessage: '### Results'
|
|
47
52
|
}
|
|
48
53
|
});
|
|
@@ -10,7 +10,7 @@ import { IntlMessagesProvider } from '@atlaskit/intl-messages-provider';
|
|
|
10
10
|
import Modal, { ModalBody, ModalFooter, ModalHeader, ModalTitle, ModalTransition } from '@atlaskit/modal-dialog';
|
|
11
11
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
12
12
|
import LinkUrl from '@atlaskit/smart-card/link-url';
|
|
13
|
-
import {
|
|
13
|
+
import { N800 } from '@atlaskit/theme/colors';
|
|
14
14
|
import { EVENT_CHANNEL, useDatasourceAnalyticsEvents } from '../../../analytics';
|
|
15
15
|
import { componentMetadata } from '../../../analytics/constants';
|
|
16
16
|
import { DatasourceAction, DatasourceDisplay } from '../../../analytics/types';
|
|
@@ -32,29 +32,19 @@ import { InitialStateView } from '../../common/initial-state-view';
|
|
|
32
32
|
import { initialStateViewMessages } from '../../common/initial-state-view/messages';
|
|
33
33
|
import { CancelButton } from '../../common/modal/cancel-button';
|
|
34
34
|
import { ContentContainer } from '../../common/modal/content-container';
|
|
35
|
+
import { SmartCardPlaceholder, SmartLink } from '../../common/modal/count-view-smart-link';
|
|
36
|
+
import { DisplayViewDropDown } from '../../common/modal/display-view-dropdown/display-view-drop-down';
|
|
35
37
|
import { SiteSelector } from '../../common/modal/site-selector';
|
|
36
38
|
import { EmptyState, IssueLikeDataTableView } from '../../issue-like-table';
|
|
37
|
-
import LinkRenderType from '../../issue-like-table/render-type/link';
|
|
38
39
|
import { availableBasicFilterTypes } from '../basic-filters/ui';
|
|
39
40
|
import { isQueryTooComplex } from '../basic-filters/utils/isQueryTooComplex';
|
|
40
41
|
import { JiraSearchContainer } from '../jira-search-container';
|
|
41
|
-
import { JiraDisplayViewDropDown } from './jira-display-view-dropdown/jira-display-view-drop-down';
|
|
42
42
|
import { JiraInitialStateSVG } from './jira-issues-initial-state-svg';
|
|
43
43
|
import { modalMessages } from './messages';
|
|
44
|
-
const placeholderSmartLinkStyles = css({
|
|
45
|
-
backgroundColor: `var(--ds-surface-raised, ${N0})`,
|
|
46
|
-
borderRadius: "var(--ds-border-radius-200, 3px)",
|
|
47
|
-
boxShadow: '0px 1px 1px rgba(9, 30, 66, 0.25), 0px 0px 1px rgba(9, 30, 66, 0.31)',
|
|
48
|
-
color: `var(--ds-text-brand, ${B400})`,
|
|
49
|
-
padding: `${"var(--ds-space-0, 0px)"} ${"var(--ds-space-025, 2px)"}`
|
|
50
|
-
});
|
|
51
44
|
const issueCountStyles = css({
|
|
52
45
|
flex: 1,
|
|
53
46
|
fontWeight: 600
|
|
54
47
|
});
|
|
55
|
-
const smartLinkContainerStyles = css({
|
|
56
|
-
paddingLeft: "var(--ds-space-025, 2px)"
|
|
57
|
-
});
|
|
58
48
|
const getDisplayValue = (currentViewMode, itemCount) => {
|
|
59
49
|
if (currentViewMode === 'issue') {
|
|
60
50
|
return DatasourceDisplay.DATASOURCE_TABLE;
|
|
@@ -422,12 +412,9 @@ export const PlainJiraIssuesConfigModal = props => {
|
|
|
422
412
|
url: selectedJiraSiteUrl || urlBeingEdited
|
|
423
413
|
});
|
|
424
414
|
} else if (status === 'empty' || !jql || !selectedJiraSiteUrl) {
|
|
425
|
-
return jsx(
|
|
426
|
-
|
|
427
|
-
}
|
|
428
|
-
"data-testid": `jira-datasource-modal--smart-card-placeholder`,
|
|
429
|
-
css: placeholderSmartLinkStyles
|
|
430
|
-
}, jsx(FormattedMessage, modalMessages.issuesCountSmartCardPlaceholderText)));
|
|
415
|
+
return jsx(SmartCardPlaceholder, {
|
|
416
|
+
placeholderText: modalMessages.issuesCountSmartCardPlaceholderText
|
|
417
|
+
});
|
|
431
418
|
} else {
|
|
432
419
|
let url;
|
|
433
420
|
if (responseItems.length === 1 && retrieveUrlForSmartCardRender()) {
|
|
@@ -435,11 +422,9 @@ export const PlainJiraIssuesConfigModal = props => {
|
|
|
435
422
|
} else {
|
|
436
423
|
url = `${selectedJiraSiteUrl}/issues/?jql=${getBooleanFF('platform.linking-platform.datasource.enable-stricter-jql-encoding') ? encodeURIComponent(jql) : encodeURI(jql)}`;
|
|
437
424
|
}
|
|
438
|
-
return jsx(
|
|
439
|
-
css: smartLinkContainerStyles
|
|
440
|
-
}, jsx(LinkRenderType, {
|
|
425
|
+
return jsx(SmartLink, {
|
|
441
426
|
url: url
|
|
442
|
-
})
|
|
427
|
+
});
|
|
443
428
|
}
|
|
444
429
|
}, [jql, selectedJiraSite === null || selectedJiraSite === void 0 ? void 0 : selectedJiraSite.url, status, urlBeingEdited, responseItems, retrieveUrlForSmartCardRender]);
|
|
445
430
|
const renderIssuesModeContent = useCallback(() => {
|
|
@@ -501,7 +486,7 @@ export const PlainJiraIssuesConfigModal = props => {
|
|
|
501
486
|
selectedSite: selectedJiraSite,
|
|
502
487
|
testId: "jira-datasource-modal--site-selector",
|
|
503
488
|
label: siteSelectorLabel
|
|
504
|
-
})), !hasNoJiraSites && jsx(
|
|
489
|
+
})), !hasNoJiraSites && jsx(DisplayViewDropDown, {
|
|
505
490
|
onViewModeChange: handleViewModeChange,
|
|
506
491
|
viewMode: currentViewMode
|
|
507
492
|
})), jsx(ModalBody, null, !hasNoJiraSites ? jsx(Fragment, null, jsx(JiraSearchContainer, {
|
|
@@ -15,26 +15,6 @@ export const modalMessages = defineMessages({
|
|
|
15
15
|
description: 'Title for the Jira Issues modal when a user has to select a site to inserting issues from',
|
|
16
16
|
defaultMessage: 'Insert Jira issues from'
|
|
17
17
|
},
|
|
18
|
-
tableViewModeLabel: {
|
|
19
|
-
id: 'linkDataSource.jira-issues.configmodal.tableViewModeLabel',
|
|
20
|
-
description: 'Display Jira search results as a table',
|
|
21
|
-
defaultMessage: 'Table'
|
|
22
|
-
},
|
|
23
|
-
tableViewModeDescription: {
|
|
24
|
-
id: 'linkDataSource.jira-issues.configmodal.tableViewModeDescription',
|
|
25
|
-
description: 'Description for table view mode',
|
|
26
|
-
defaultMessage: 'Display Jira search results as a table'
|
|
27
|
-
},
|
|
28
|
-
inlineLinkViewModeLabel: {
|
|
29
|
-
id: 'linkDataSource.jira-issues.configmodal.inlineLinkViewModeLabel',
|
|
30
|
-
description: 'Display the number of search results as an inline smart link',
|
|
31
|
-
defaultMessage: 'Inline link'
|
|
32
|
-
},
|
|
33
|
-
inlineLinkViewModeDescription: {
|
|
34
|
-
id: 'linkDataSource.jira-issues.configmodal.inlineLinkViewModeDescription',
|
|
35
|
-
description: 'Description for inline link view mode',
|
|
36
|
-
defaultMessage: 'Display the number of search results or as an inline smart link'
|
|
37
|
-
},
|
|
38
18
|
issuesCountSmartCardPlaceholderText: {
|
|
39
19
|
id: 'linkDataSource.jira-issues.configmodal.placeholder.issues',
|
|
40
20
|
description: 'Placeholder text that will be placed next to a count of jira issues',
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { css, jsx } from '@emotion/react';
|
|
3
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
4
|
+
import { B400, N0 } from '@atlaskit/theme/colors';
|
|
5
|
+
import LinkRenderType from '../../../issue-like-table/render-type/link';
|
|
6
|
+
var placeholderSmartLinkStyles = css({
|
|
7
|
+
backgroundColor: "var(--ds-surface-raised, ".concat(N0, ")"),
|
|
8
|
+
borderRadius: "var(--ds-border-radius-200, 3px)",
|
|
9
|
+
boxShadow: '0px 1px 1px rgba(9, 30, 66, 0.25), 0px 0px 1px rgba(9, 30, 66, 0.31)',
|
|
10
|
+
color: "var(--ds-text-brand, ".concat(B400, ")"),
|
|
11
|
+
padding: "var(--ds-space-0, 0px)".concat(" ", "var(--ds-space-025, 2px)")
|
|
12
|
+
});
|
|
13
|
+
var smartLinkContainerStyles = css({
|
|
14
|
+
paddingLeft: "var(--ds-space-025, 2px)"
|
|
15
|
+
});
|
|
16
|
+
export var SmartCardPlaceholder = function SmartCardPlaceholder(_ref) {
|
|
17
|
+
var placeholderText = _ref.placeholderText;
|
|
18
|
+
return jsx("div", {
|
|
19
|
+
css: smartLinkContainerStyles
|
|
20
|
+
}, jsx("span", {
|
|
21
|
+
"data-testid": "datasource-modal--smart-card-placeholder",
|
|
22
|
+
css: placeholderSmartLinkStyles
|
|
23
|
+
}, jsx(FormattedMessage, placeholderText)));
|
|
24
|
+
};
|
|
25
|
+
export var SmartLink = function SmartLink(_ref2) {
|
|
26
|
+
var url = _ref2.url;
|
|
27
|
+
return jsx("div", {
|
|
28
|
+
css: smartLinkContainerStyles
|
|
29
|
+
}, jsx(LinkRenderType, {
|
|
30
|
+
url: url
|
|
31
|
+
}));
|
|
32
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
3
|
+
import { FormattedMessage, useIntl } from 'react-intl-next';
|
|
4
|
+
import DropdownMenu, { DropdownItem, DropdownItemGroup } from '@atlaskit/dropdown-menu';
|
|
5
|
+
import TableIcon from '@atlaskit/icon/glyph/table';
|
|
6
|
+
import { Box, xcss } from '@atlaskit/primitives';
|
|
7
|
+
import { displayViewDropDownMessages } from './messages';
|
|
8
|
+
var dropDownItemGroupStyles = xcss({
|
|
9
|
+
width: '320px',
|
|
10
|
+
height: '140px',
|
|
11
|
+
paddingTop: 'space.050',
|
|
12
|
+
paddingBottom: 'space.050',
|
|
13
|
+
borderRadius: 'border.radius'
|
|
14
|
+
});
|
|
15
|
+
var InlineIcon = jsx("svg", {
|
|
16
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
17
|
+
width: "24",
|
|
18
|
+
height: "24",
|
|
19
|
+
viewBox: "0 0 24 24",
|
|
20
|
+
fill: "none"
|
|
21
|
+
}, jsx("path", {
|
|
22
|
+
fillRule: "evenodd",
|
|
23
|
+
clipRule: "evenodd",
|
|
24
|
+
d: "M4 9C2.89543 9 2 9.67155 2 10.5V13.5C2 14.3285 2.89543 15 4 15H20C21.1046 15 22 14.3285 22 13.5V10.5C22 9.67155 21.1046 9 20 9H4ZM4.22222 11.25C4.22222 10.5 4.22222 10.5 5 10.5H7C7.55556 10.5 7.55556 10.5 7.55556 11.25V13C7.55556 13.5 7.55556 13.5 7 13.5H5C4.22222 13.5 4.22222 13.5 4.22222 13V11.25ZM9 12C9 11.7929 9.2239 11.625 9.5 11.625H19.5C19.7761 11.625 20 11.7929 20 12C20 12.2071 19.7761 12.375 19.5 12.375H9.5C9.2239 12.375 9 12.2071 9 12Z",
|
|
25
|
+
fill: 'currentColor'
|
|
26
|
+
}));
|
|
27
|
+
export var DisplayViewDropDown = function DisplayViewDropDown(_ref) {
|
|
28
|
+
var onViewModeChange = _ref.onViewModeChange,
|
|
29
|
+
viewMode = _ref.viewMode;
|
|
30
|
+
var _useIntl = useIntl(),
|
|
31
|
+
formatMessage = _useIntl.formatMessage;
|
|
32
|
+
// TODO: further refactoring in EDM-9573
|
|
33
|
+
// temporary fix. transition 'count' to 'inline', 'issue' to 'table'
|
|
34
|
+
var isJira = viewMode === 'issue' || viewMode === 'count';
|
|
35
|
+
var isTable = viewMode === 'table' || viewMode === 'issue';
|
|
36
|
+
var triggerText = isTable ? formatMessage(
|
|
37
|
+
// TODO EDM-9573, remove once EDM-9431 is merged
|
|
38
|
+
isJira ? displayViewDropDownMessages.tableViewModeLabel : displayViewDropDownMessages.tableViewModeLabelDuplicate) : formatMessage(
|
|
39
|
+
// TODO EDM-9573, remove once EDM-9431 is merged
|
|
40
|
+
isJira ? displayViewDropDownMessages.inlineLinkViewModeLabel : displayViewDropDownMessages.inlineLinkViewModeLabelDuplicate);
|
|
41
|
+
return jsx(DropdownMenu, {
|
|
42
|
+
trigger: triggerText,
|
|
43
|
+
testId: "datasource-modal--view-drop-down"
|
|
44
|
+
}, jsx(Box, {
|
|
45
|
+
xcss: dropDownItemGroupStyles
|
|
46
|
+
}, jsx(DropdownItemGroup, null, jsx(DropdownItem, {
|
|
47
|
+
testId: "dropdown-item-table",
|
|
48
|
+
onClick: function onClick() {
|
|
49
|
+
return onViewModeChange(isJira ? 'issue' : 'table');
|
|
50
|
+
},
|
|
51
|
+
isSelected: isTable,
|
|
52
|
+
description: formatMessage(
|
|
53
|
+
// TODO EDM-9573, remove once EDM-9431 is merged
|
|
54
|
+
isJira ? displayViewDropDownMessages.tableViewModeDescription : displayViewDropDownMessages.tableViewModeDescriptionDuplicate),
|
|
55
|
+
elemBefore: jsx(TableIcon, {
|
|
56
|
+
label: "table icon"
|
|
57
|
+
})
|
|
58
|
+
}, jsx(FormattedMessage
|
|
59
|
+
// TODO EDM-9573, remove once EDM-9431 is merged
|
|
60
|
+
, isJira ? displayViewDropDownMessages.tableViewModeLabel : displayViewDropDownMessages.tableViewModeLabelDuplicate)), jsx(DropdownItem, {
|
|
61
|
+
testId: "dropdown-item-inline-link",
|
|
62
|
+
onClick: function onClick() {
|
|
63
|
+
return onViewModeChange(isJira ? 'count' : 'inline');
|
|
64
|
+
},
|
|
65
|
+
isSelected: !isTable,
|
|
66
|
+
description: formatMessage(
|
|
67
|
+
// TODO EDM-9573, remove once EDM-9431 is merged
|
|
68
|
+
isJira ? displayViewDropDownMessages.inlineLinkViewModeDescription : displayViewDropDownMessages.inlineLinkViewModeDescriptionDuplicate),
|
|
69
|
+
elemBefore: InlineIcon
|
|
70
|
+
}, jsx(FormattedMessage
|
|
71
|
+
// TODO EDM-9573, remove once EDM-9431 is merged
|
|
72
|
+
, isJira ? displayViewDropDownMessages.inlineLinkViewModeLabel : displayViewDropDownMessages.inlineLinkViewModeLabelDuplicate)))));
|
|
73
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { defineMessages } from 'react-intl-next';
|
|
2
|
+
export var displayViewDropDownMessages = defineMessages({
|
|
3
|
+
// TODO EDM-9573
|
|
4
|
+
// remove duplicate from end of key once EDM-9431 is merged
|
|
5
|
+
tableViewModeLabelDuplicate: {
|
|
6
|
+
id: 'linkDataSource.configmodal.tableViewModeLabel',
|
|
7
|
+
description: 'Display search results as a table',
|
|
8
|
+
defaultMessage: 'Table'
|
|
9
|
+
},
|
|
10
|
+
// remove duplicate from end of key once EDM-9431 is merged
|
|
11
|
+
tableViewModeDescriptionDuplicate: {
|
|
12
|
+
id: 'linkDataSource.configmodal.tableViewModeDescription',
|
|
13
|
+
description: 'Description for table view mode',
|
|
14
|
+
defaultMessage: 'Display search results as a table'
|
|
15
|
+
},
|
|
16
|
+
// remove duplicate from end of key once EDM-9431 is merged
|
|
17
|
+
inlineLinkViewModeLabelDuplicate: {
|
|
18
|
+
id: 'linkDataSource.configmodal.inlineLinkViewModeLabel',
|
|
19
|
+
description: 'Display the number of search results as an inline smart link',
|
|
20
|
+
defaultMessage: 'Inline link'
|
|
21
|
+
},
|
|
22
|
+
// remove duplicate from end of key once EDM-9431 is merged
|
|
23
|
+
inlineLinkViewModeDescriptionDuplicate: {
|
|
24
|
+
id: 'linkDataSource.configmodal.inlineLinkViewModeDescription',
|
|
25
|
+
description: 'Description for inline view mode',
|
|
26
|
+
defaultMessage: 'Display the number of search results or as an inline smart link'
|
|
27
|
+
},
|
|
28
|
+
// delete once EDM-9431 is merged
|
|
29
|
+
tableViewModeLabel: {
|
|
30
|
+
id: 'linkDataSource.jira-issues.configmodal.tableViewModeLabel',
|
|
31
|
+
description: 'Display Jira search results as a table',
|
|
32
|
+
defaultMessage: 'Table'
|
|
33
|
+
},
|
|
34
|
+
// delete once EDM-9431 is merged
|
|
35
|
+
tableViewModeDescription: {
|
|
36
|
+
id: 'linkDataSource.jira-issues.configmodal.tableViewModeDescription',
|
|
37
|
+
description: 'Description for table view mode',
|
|
38
|
+
defaultMessage: 'Display Jira search results as a table'
|
|
39
|
+
},
|
|
40
|
+
// delete once EDM-9431 is merged
|
|
41
|
+
inlineLinkViewModeLabel: {
|
|
42
|
+
id: 'linkDataSource.jira-issues.configmodal.inlineLinkViewModeLabel',
|
|
43
|
+
description: 'Display the number of search results as an inline smart link',
|
|
44
|
+
defaultMessage: 'Inline link'
|
|
45
|
+
},
|
|
46
|
+
// delete once EDM-9431 is merged
|
|
47
|
+
inlineLinkViewModeDescription: {
|
|
48
|
+
id: 'linkDataSource.jira-issues.configmodal.inlineLinkViewModeDescription',
|
|
49
|
+
description: 'Description for inline link view mode',
|
|
50
|
+
defaultMessage: 'Display the number of search results or as an inline smart link'
|
|
51
|
+
}
|
|
52
|
+
});
|