@atlaskit/link-datasource 1.27.3 → 1.28.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 +12 -0
- package/dist/cjs/ui/common/modal/popup-select/constants.js +8 -0
- package/dist/cjs/ui/common/modal/popup-select/footer.js +3 -2
- package/dist/cjs/ui/common/modal/popup-select/formatOptionLabel.js +11 -6
- package/dist/cjs/ui/common/modal/popup-select/index.js +2 -1
- package/dist/cjs/ui/common/modal/popup-select/menu-list/errorMessage.js +3 -3
- package/dist/cjs/ui/common/modal/popup-select/menu-list/index.js +4 -2
- package/dist/cjs/ui/common/modal/popup-select/menu-list/loadingMessage.js +3 -2
- package/dist/cjs/ui/common/modal/popup-select/menu-list/noOptionsMessage.js +3 -3
- package/dist/cjs/ui/common/modal/popup-select/menu-list/showMoreButton.js +1 -1
- package/dist/cjs/ui/confluence-search-modal/basic-filters/filters/date-range-picker/PopupComponent.js +19 -0
- package/dist/cjs/ui/confluence-search-modal/basic-filters/filters/date-range-picker/index.js +89 -0
- package/dist/cjs/ui/confluence-search-modal/basic-filters/filters/date-range-picker/messages.js +49 -0
- package/dist/cjs/ui/confluence-search-modal/basic-filters/filters/date-range-picker/styled.js +75 -0
- package/dist/cjs/ui/confluence-search-modal/basic-filters/filters/date-range-picker/trigger.js +32 -0
- package/dist/cjs/ui/confluence-search-modal/basic-filters/index.js +5 -3
- package/dist/cjs/ui/confluence-search-modal/basic-filters/types.js +11 -0
- package/dist/cjs/ui/confluence-search-modal/confluence-search-container/index.js +16 -1
- package/dist/cjs/ui/confluence-search-modal/modal/index.js +36 -15
- package/dist/cjs/ui/datasource-table-view/datasourceTableView.js +1 -0
- package/dist/cjs/ui/jira-issues-modal/basic-filters/ui/async-popup-select/index.js +6 -5
- package/dist/cjs/ui/jira-issues-modal/jira-search-container/index.js +3 -3
- package/dist/cjs/ui/table-footer/index.js +8 -2
- package/dist/cjs/ui/table-footer/messages.js +5 -0
- package/dist/cjs/ui/table-footer/powered-by-jsm-assets/index.js +53 -0
- package/dist/es2019/ui/common/modal/popup-select/constants.js +2 -0
- package/dist/es2019/ui/common/modal/popup-select/footer.js +3 -2
- package/dist/es2019/ui/common/modal/popup-select/formatOptionLabel.js +8 -6
- package/dist/es2019/ui/common/modal/popup-select/index.js +2 -1
- package/dist/es2019/ui/common/modal/popup-select/menu-list/errorMessage.js +2 -2
- package/dist/es2019/ui/common/modal/popup-select/menu-list/index.js +4 -2
- package/dist/es2019/ui/common/modal/popup-select/menu-list/loadingMessage.js +4 -2
- package/dist/es2019/ui/common/modal/popup-select/menu-list/noOptionsMessage.js +2 -2
- package/dist/es2019/ui/common/modal/popup-select/menu-list/showMoreButton.js +1 -1
- package/dist/es2019/ui/confluence-search-modal/basic-filters/filters/date-range-picker/PopupComponent.js +7 -0
- package/dist/es2019/ui/confluence-search-modal/basic-filters/filters/date-range-picker/index.js +68 -0
- package/dist/es2019/ui/confluence-search-modal/basic-filters/filters/date-range-picker/messages.js +43 -0
- package/dist/es2019/ui/confluence-search-modal/basic-filters/filters/date-range-picker/styled.js +66 -0
- package/dist/es2019/ui/confluence-search-modal/basic-filters/filters/date-range-picker/trigger.js +26 -0
- package/dist/es2019/ui/confluence-search-modal/basic-filters/index.js +7 -2
- package/dist/es2019/ui/confluence-search-modal/basic-filters/types.js +5 -0
- package/dist/es2019/ui/confluence-search-modal/confluence-search-container/index.js +13 -1
- package/dist/es2019/ui/confluence-search-modal/modal/index.js +27 -8
- package/dist/es2019/ui/datasource-table-view/datasourceTableView.js +1 -0
- package/dist/es2019/ui/jira-issues-modal/basic-filters/ui/async-popup-select/index.js +4 -3
- package/dist/es2019/ui/jira-issues-modal/jira-search-container/index.js +1 -1
- package/dist/es2019/ui/table-footer/index.js +7 -1
- package/dist/es2019/ui/table-footer/messages.js +5 -0
- package/dist/es2019/ui/table-footer/powered-by-jsm-assets/index.js +45 -0
- package/dist/esm/ui/common/modal/popup-select/constants.js +2 -0
- package/dist/esm/ui/common/modal/popup-select/footer.js +3 -2
- package/dist/esm/ui/common/modal/popup-select/formatOptionLabel.js +8 -6
- package/dist/esm/ui/common/modal/popup-select/index.js +2 -1
- package/dist/esm/ui/common/modal/popup-select/menu-list/errorMessage.js +2 -2
- package/dist/esm/ui/common/modal/popup-select/menu-list/index.js +4 -2
- package/dist/esm/ui/common/modal/popup-select/menu-list/loadingMessage.js +3 -2
- package/dist/esm/ui/common/modal/popup-select/menu-list/noOptionsMessage.js +2 -2
- package/dist/esm/ui/common/modal/popup-select/menu-list/showMoreButton.js +1 -1
- package/dist/esm/ui/confluence-search-modal/basic-filters/filters/date-range-picker/PopupComponent.js +9 -0
- package/dist/esm/ui/confluence-search-modal/basic-filters/filters/date-range-picker/index.js +79 -0
- package/dist/esm/ui/confluence-search-modal/basic-filters/filters/date-range-picker/messages.js +43 -0
- package/dist/esm/ui/confluence-search-modal/basic-filters/filters/date-range-picker/styled.js +68 -0
- package/dist/esm/ui/confluence-search-modal/basic-filters/filters/date-range-picker/trigger.js +25 -0
- package/dist/esm/ui/confluence-search-modal/basic-filters/index.js +5 -3
- package/dist/esm/ui/confluence-search-modal/basic-filters/types.js +5 -0
- package/dist/esm/ui/confluence-search-modal/confluence-search-container/index.js +16 -1
- package/dist/esm/ui/confluence-search-modal/modal/index.js +36 -15
- package/dist/esm/ui/datasource-table-view/datasourceTableView.js +1 -0
- package/dist/esm/ui/jira-issues-modal/basic-filters/ui/async-popup-select/index.js +4 -3
- package/dist/esm/ui/jira-issues-modal/jira-search-container/index.js +1 -1
- package/dist/esm/ui/table-footer/index.js +8 -2
- package/dist/esm/ui/table-footer/messages.js +5 -0
- package/dist/esm/ui/table-footer/powered-by-jsm-assets/index.js +46 -0
- package/dist/types/analytics/generated/analytics.types.d.ts +7 -0
- package/dist/types/ui/common/modal/popup-select/constants.d.ts +2 -0
- package/dist/types/ui/common/modal/popup-select/footer.d.ts +2 -1
- package/dist/types/ui/common/modal/popup-select/index.d.ts +5 -4
- package/dist/types/ui/common/modal/popup-select/menu-list/index.d.ts +1 -1
- package/dist/types/ui/common/modal/popup-select/menu-list/loadingMessage.d.ts +3 -1
- package/dist/types/ui/common/modal/popup-select/types.d.ts +6 -1
- package/dist/types/ui/confluence-search-modal/basic-filters/filters/date-range-picker/PopupComponent.d.ts +3 -0
- package/dist/types/ui/confluence-search-modal/basic-filters/filters/date-range-picker/index.d.ts +8 -0
- package/dist/types/ui/confluence-search-modal/basic-filters/filters/date-range-picker/messages.d.ts +42 -0
- package/dist/types/ui/confluence-search-modal/basic-filters/filters/date-range-picker/styled.d.ts +31 -0
- package/dist/types/ui/confluence-search-modal/basic-filters/filters/date-range-picker/trigger.d.ts +10 -0
- package/dist/types/ui/confluence-search-modal/basic-filters/index.d.ts +4 -1
- package/dist/types/ui/confluence-search-modal/basic-filters/types.d.ts +20 -0
- package/dist/types/ui/confluence-search-modal/confluence-search-container/index.d.ts +2 -1
- package/dist/types/ui/confluence-search-modal/types.d.ts +4 -1
- package/dist/types/ui/jira-issues-modal/basic-filters/hooks/useFilterOptions.d.ts +2 -1
- package/dist/types/ui/jira-issues-modal/basic-filters/types.d.ts +1 -20
- package/dist/types/ui/jira-issues-modal/basic-filters/ui/async-popup-select/index.d.ts +2 -2
- package/dist/types/ui/jira-issues-modal/basic-filters/ui/index.d.ts +2 -1
- package/dist/types/ui/jira-issues-modal/basic-filters/utils/transformers.d.ts +2 -1
- package/dist/types/ui/jira-issues-modal/jira-search-container/index.d.ts +0 -1
- package/dist/types/ui/table-footer/index.d.ts +2 -1
- package/dist/types/ui/table-footer/messages.d.ts +5 -0
- package/dist/types/ui/table-footer/powered-by-jsm-assets/index.d.ts +4 -0
- package/dist/types-ts4.5/analytics/generated/analytics.types.d.ts +7 -0
- package/dist/types-ts4.5/ui/common/modal/popup-select/constants.d.ts +2 -0
- package/dist/types-ts4.5/ui/common/modal/popup-select/footer.d.ts +2 -1
- package/dist/types-ts4.5/ui/common/modal/popup-select/index.d.ts +5 -4
- package/dist/types-ts4.5/ui/common/modal/popup-select/menu-list/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/common/modal/popup-select/menu-list/loadingMessage.d.ts +3 -1
- package/dist/types-ts4.5/ui/common/modal/popup-select/types.d.ts +6 -1
- package/dist/types-ts4.5/ui/confluence-search-modal/basic-filters/filters/date-range-picker/PopupComponent.d.ts +3 -0
- package/dist/types-ts4.5/ui/confluence-search-modal/basic-filters/filters/date-range-picker/index.d.ts +8 -0
- package/dist/types-ts4.5/ui/confluence-search-modal/basic-filters/filters/date-range-picker/messages.d.ts +42 -0
- package/dist/types-ts4.5/ui/confluence-search-modal/basic-filters/filters/date-range-picker/styled.d.ts +31 -0
- package/dist/types-ts4.5/ui/confluence-search-modal/basic-filters/filters/date-range-picker/trigger.d.ts +10 -0
- package/dist/types-ts4.5/ui/confluence-search-modal/basic-filters/index.d.ts +4 -1
- package/dist/types-ts4.5/ui/confluence-search-modal/basic-filters/types.d.ts +20 -0
- package/dist/types-ts4.5/ui/confluence-search-modal/confluence-search-container/index.d.ts +2 -1
- package/dist/types-ts4.5/ui/confluence-search-modal/types.d.ts +4 -1
- package/dist/types-ts4.5/ui/jira-issues-modal/basic-filters/hooks/useFilterOptions.d.ts +2 -1
- package/dist/types-ts4.5/ui/jira-issues-modal/basic-filters/types.d.ts +1 -20
- package/dist/types-ts4.5/ui/jira-issues-modal/basic-filters/ui/async-popup-select/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/jira-issues-modal/basic-filters/ui/index.d.ts +2 -1
- package/dist/types-ts4.5/ui/jira-issues-modal/basic-filters/utils/transformers.d.ts +2 -1
- package/dist/types-ts4.5/ui/jira-issues-modal/jira-search-container/index.d.ts +0 -1
- package/dist/types-ts4.5/ui/table-footer/index.d.ts +2 -1
- package/dist/types-ts4.5/ui/table-footer/messages.d.ts +5 -0
- package/dist/types-ts4.5/ui/table-footer/powered-by-jsm-assets/index.d.ts +4 -0
- package/examples-helpers/buildAssetsIssuesTable.tsx +71 -0
- package/examples-helpers/useAssetsTableProps.tsx +57 -0
- package/package.json +10 -5
package/dist/es2019/ui/confluence-search-modal/basic-filters/filters/date-range-picker/styled.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import styled from '@emotion/styled';
|
|
2
|
+
import { B400, B50, N0, N20, N30, R400 } from '@atlaskit/theme/colors';
|
|
3
|
+
export const PopupComponentContainer = styled.div({
|
|
4
|
+
boxSizing: 'border-box',
|
|
5
|
+
display: 'block',
|
|
6
|
+
flex: '1 1 auto',
|
|
7
|
+
overflow: 'visible',
|
|
8
|
+
background: `var(--ds-background-input, ${N0})`,
|
|
9
|
+
':focus': {
|
|
10
|
+
outline: 'none'
|
|
11
|
+
},
|
|
12
|
+
boxShadow: "var(--ds-shadow-overlay, 0px 0px 1px 0px rgba(9, 30, 66, 0.31), 0px 3px 5px 0px rgba(9, 30, 66, 0.20))"
|
|
13
|
+
});
|
|
14
|
+
export const CustomDropdown = styled.div({
|
|
15
|
+
width: '360px',
|
|
16
|
+
background: `var(--ds-background-input, ${N0})`,
|
|
17
|
+
borderRadius: '3px',
|
|
18
|
+
boxShadow: "var(--ds-shadow-overlay, 0px 0px 1px 0px rgba(9, 30, 66, 0.31), 0px 3px 5px 0px rgba(9, 30, 66, 0.20))",
|
|
19
|
+
zIndex: '900'
|
|
20
|
+
});
|
|
21
|
+
export const CustomDropdownItem = styled.div(props => ({
|
|
22
|
+
height: '36px',
|
|
23
|
+
width: '100%',
|
|
24
|
+
display: 'flex',
|
|
25
|
+
justifyContent: 'flex-start',
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
paddingLeft: props.isSelected ? '15px' : '16px',
|
|
28
|
+
boxSizing: 'border-box',
|
|
29
|
+
color: props.isSelected ? `var(--ds-text-selected, ${B400})` : 'inherit',
|
|
30
|
+
background: props.isSelected ? `var(--ds-background-accent-blue-subtlest, ${B50})` : 'transparent',
|
|
31
|
+
borderLeft: props.isSelected ? `2px solid ${`var(--ds-text-selected, ${B400})`}` : 'none',
|
|
32
|
+
'&:hover': {
|
|
33
|
+
background: props.isSelected ? `var(--ds-background-accent-blue-subtlest, ${B50})` : `var(--ds-background-input-hovered, ${N20})`,
|
|
34
|
+
cursor: 'default'
|
|
35
|
+
}
|
|
36
|
+
}));
|
|
37
|
+
export const CustomDateWrapper = styled.div({
|
|
38
|
+
padding: "var(--ds-space-150, 12px)",
|
|
39
|
+
boxSizing: 'border-box'
|
|
40
|
+
});
|
|
41
|
+
export const DatePickersWrapper = styled.div({
|
|
42
|
+
display: 'flex',
|
|
43
|
+
justifyContent: 'space-between',
|
|
44
|
+
alignItems: 'center',
|
|
45
|
+
width: '100%'
|
|
46
|
+
});
|
|
47
|
+
export const SelectDateRangeButton = styled.button({
|
|
48
|
+
background: `var(--ds-background-accent-gray-subtler, ${N20})`,
|
|
49
|
+
border: 'none',
|
|
50
|
+
font: 'inherit',
|
|
51
|
+
width: '70px',
|
|
52
|
+
height: '40px',
|
|
53
|
+
marginTop: "var(--ds-space-150, 12px)",
|
|
54
|
+
borderRadius: '3px',
|
|
55
|
+
'&:hover': {
|
|
56
|
+
background: `var(--ds-background-accent-gray-subtler, ${N30})`,
|
|
57
|
+
cursor: 'pointer'
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
export const DateRangeErrorMessage = styled.div({
|
|
61
|
+
display: 'flex',
|
|
62
|
+
lineHeight: 1.3333,
|
|
63
|
+
marginTop: "var(--ds-space-050, 4px)",
|
|
64
|
+
fontSize: '12px',
|
|
65
|
+
color: `var(--ds-text-danger, ${R400})`
|
|
66
|
+
});
|
package/dist/es2019/ui/confluence-search-modal/basic-filters/filters/date-range-picker/trigger.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import Button from '@atlaskit/button/standard-button';
|
|
4
|
+
import ChevronDownIcon from '@atlaskit/icon/glyph/chevron-down';
|
|
5
|
+
export const PopupTrigger = ({
|
|
6
|
+
triggerProps,
|
|
7
|
+
optionSelected,
|
|
8
|
+
label,
|
|
9
|
+
selectedLabel,
|
|
10
|
+
onClickButton
|
|
11
|
+
}) => {
|
|
12
|
+
return /*#__PURE__*/React.createElement(Button, _extends({}, triggerProps, {
|
|
13
|
+
testId: 'confluence-search-modal--date-range-button',
|
|
14
|
+
onClick: onClickButton,
|
|
15
|
+
isSelected: optionSelected,
|
|
16
|
+
iconAfter: /*#__PURE__*/React.createElement("span", {
|
|
17
|
+
style: {
|
|
18
|
+
display: 'flex',
|
|
19
|
+
alignItems: 'center'
|
|
20
|
+
}
|
|
21
|
+
}, /*#__PURE__*/React.createElement(ChevronDownIcon, {
|
|
22
|
+
size: "medium",
|
|
23
|
+
label: ""
|
|
24
|
+
}))
|
|
25
|
+
}), label, selectedLabel ? `: ${selectedLabel}` : '');
|
|
26
|
+
};
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Flex, xcss } from '@atlaskit/primitives';
|
|
3
|
+
import { DateRangePicker } from './filters/date-range-picker';
|
|
3
4
|
const basicFilterContainerStyles = xcss({
|
|
4
5
|
paddingLeft: 'space.100'
|
|
5
6
|
});
|
|
6
|
-
const BasicFilterContainer = ({
|
|
7
|
+
const BasicFilterContainer = ({
|
|
8
|
+
onChange
|
|
9
|
+
}) => {
|
|
7
10
|
return /*#__PURE__*/React.createElement(Flex, {
|
|
8
11
|
xcss: basicFilterContainerStyles,
|
|
9
12
|
gap: "space.100",
|
|
10
13
|
testId: "clol-basic-filter-container"
|
|
11
|
-
}, /*#__PURE__*/React.createElement(
|
|
14
|
+
}, /*#__PURE__*/React.createElement(DateRangePicker, {
|
|
15
|
+
onSelectionChange: onChange
|
|
16
|
+
}), /*#__PURE__*/React.createElement(React.Fragment, null));
|
|
12
17
|
};
|
|
13
18
|
export default BasicFilterContainer;
|
|
@@ -15,6 +15,7 @@ const ConfluenceSearchContainer = ({
|
|
|
15
15
|
}) => {
|
|
16
16
|
const currentCloudId = useRef(cloudId);
|
|
17
17
|
const [searchBarSearchString, setSearchBarSearchString] = useState(initialSearchValue !== null && initialSearchValue !== void 0 ? initialSearchValue : '');
|
|
18
|
+
const [filterSelections, setFilterSelections] = useState({});
|
|
18
19
|
const handleSearchChange = useCallback(e => {
|
|
19
20
|
const rawSearch = e.currentTarget.value;
|
|
20
21
|
setSearchBarSearchString(rawSearch);
|
|
@@ -28,6 +29,15 @@ const ConfluenceSearchContainer = ({
|
|
|
28
29
|
currentCloudId.current = cloudId;
|
|
29
30
|
}
|
|
30
31
|
}, [cloudId]);
|
|
32
|
+
const handleBasicFilterSelectionChange = useCallback((filterType, options) => {
|
|
33
|
+
const updatedSelection = {
|
|
34
|
+
...filterSelections,
|
|
35
|
+
[filterType]: options
|
|
36
|
+
};
|
|
37
|
+
setFilterSelections(updatedSelection);
|
|
38
|
+
//TODO: move to debounce fn in https://product-fabric.atlassian.net/browse/EDM-9485
|
|
39
|
+
onSearch(searchBarSearchString, updatedSelection);
|
|
40
|
+
}, [filterSelections, onSearch, searchBarSearchString]);
|
|
31
41
|
const showBasicFilters = useMemo(() => {
|
|
32
42
|
if (getBooleanFF('platform.linking-platform.datasource.show-clol-basic-filters')) {
|
|
33
43
|
return true;
|
|
@@ -45,6 +55,8 @@ const ConfluenceSearchContainer = ({
|
|
|
45
55
|
searchTerm: searchBarSearchString,
|
|
46
56
|
placeholder: searchMessages.searchLabel,
|
|
47
57
|
fullWidth: !showBasicFilters
|
|
48
|
-
}), showBasicFilters && /*#__PURE__*/React.createElement(BasicFilters,
|
|
58
|
+
}), showBasicFilters && /*#__PURE__*/React.createElement(BasicFilters, {
|
|
59
|
+
onChange: handleBasicFilterSelectionChange
|
|
60
|
+
}));
|
|
49
61
|
};
|
|
50
62
|
export default ConfluenceSearchContainer;
|
|
@@ -69,13 +69,16 @@ export const PlainConfluenceSearchConfigModal = props => {
|
|
|
69
69
|
viewMode = 'table',
|
|
70
70
|
parameters: initialParameters,
|
|
71
71
|
url: urlBeingEdited,
|
|
72
|
-
visibleColumnKeys: initialVisibleColumnKeys
|
|
72
|
+
visibleColumnKeys: initialVisibleColumnKeys,
|
|
73
|
+
disableDisplayDropdown = false,
|
|
74
|
+
overrideParameters
|
|
73
75
|
} = props;
|
|
74
76
|
const [availableSites, setAvailableSites] = useState(undefined);
|
|
75
77
|
const [currentViewMode, setCurrentViewMode] = useState(viewMode);
|
|
76
78
|
const [cloudId, setCloudId] = useState(initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.cloudId);
|
|
77
79
|
const [searchString, setSearchString] = useState(initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.searchString);
|
|
78
80
|
const [visibleColumnKeys, setVisibleColumnKeys] = useState(initialVisibleColumnKeys);
|
|
81
|
+
const [lastModified, setLastModified] = useState();
|
|
79
82
|
|
|
80
83
|
// analytics related parameters
|
|
81
84
|
const searchCount = useRef(0);
|
|
@@ -87,9 +90,21 @@ export const PlainConfluenceSearchConfigModal = props => {
|
|
|
87
90
|
const parameters = useMemo(() => ({
|
|
88
91
|
...initialParameters,
|
|
89
92
|
cloudId,
|
|
90
|
-
searchString
|
|
91
|
-
|
|
93
|
+
searchString,
|
|
94
|
+
...(lastModified && {
|
|
95
|
+
lastModified
|
|
96
|
+
})
|
|
97
|
+
}), [cloudId, lastModified, initialParameters, searchString /** Add more parameters when more filters are added */]);
|
|
92
98
|
const isParametersSet = useMemo(() => !!cloudId && Object.values(parameters !== null && parameters !== void 0 ? parameters : {}).filter(v => v !== undefined).length > 1, [cloudId, parameters]);
|
|
99
|
+
const parametersToSend = useMemo(() => {
|
|
100
|
+
if (!isParametersSet) {
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
...parameters,
|
|
105
|
+
...(overrideParameters !== null && overrideParameters !== void 0 ? overrideParameters : {})
|
|
106
|
+
};
|
|
107
|
+
}, [parameters, overrideParameters, isParametersSet]);
|
|
93
108
|
const {
|
|
94
109
|
reset,
|
|
95
110
|
status,
|
|
@@ -104,7 +119,7 @@ export const PlainConfluenceSearchConfigModal = props => {
|
|
|
104
119
|
destinationObjectTypes
|
|
105
120
|
} = useDatasourceTableState({
|
|
106
121
|
datasourceId,
|
|
107
|
-
parameters:
|
|
122
|
+
parameters: parametersToSend,
|
|
108
123
|
fieldKeys: visibleColumnKeys
|
|
109
124
|
});
|
|
110
125
|
const {
|
|
@@ -321,7 +336,7 @@ export const PlainConfluenceSearchConfigModal = props => {
|
|
|
321
336
|
onInsert(buildDatasourceAdf({
|
|
322
337
|
id: datasourceId,
|
|
323
338
|
parameters: {
|
|
324
|
-
...
|
|
339
|
+
...parametersToSend,
|
|
325
340
|
cloudId
|
|
326
341
|
},
|
|
327
342
|
views: [{
|
|
@@ -344,14 +359,18 @@ export const PlainConfluenceSearchConfigModal = props => {
|
|
|
344
359
|
}]
|
|
345
360
|
}, confluenceSearchUrl), consumerEvent);
|
|
346
361
|
}
|
|
347
|
-
}, [isParametersSet, cloudId, analyticsPayload, totalCount, currentViewMode, onInsert, confluenceSearchUrl, datasourceId,
|
|
362
|
+
}, [isParametersSet, cloudId, analyticsPayload, totalCount, currentViewMode, onInsert, confluenceSearchUrl, datasourceId, parametersToSend, visibleColumnKeys, columnCustomSizes, wrappedColumnKeys]);
|
|
348
363
|
const handleViewModeChange = selectedMode => {
|
|
349
364
|
userInteractionActions.current.add(DatasourceAction.DISPLAY_VIEW_CHANGED);
|
|
350
365
|
setCurrentViewMode(selectedMode);
|
|
351
366
|
};
|
|
352
|
-
const onSearch = useCallback(newSearchString => {
|
|
367
|
+
const onSearch = useCallback((newSearchString, filters) => {
|
|
353
368
|
searchCount.current++;
|
|
354
369
|
userInteractionActions.current.add(DatasourceAction.QUERY_UPDATED);
|
|
370
|
+
if (filters !== null && filters !== void 0 && filters.lastModified) {
|
|
371
|
+
const lastModifiedValue = filters.lastModified.find(range => range.value);
|
|
372
|
+
setLastModified(lastModifiedValue === null || lastModifiedValue === void 0 ? void 0 : lastModifiedValue.value);
|
|
373
|
+
}
|
|
355
374
|
setSearchString(newSearchString);
|
|
356
375
|
reset({
|
|
357
376
|
shouldForceRequest: true
|
|
@@ -380,7 +399,7 @@ export const PlainConfluenceSearchConfigModal = props => {
|
|
|
380
399
|
selectedSite: selectedConfluenceSite,
|
|
381
400
|
testId: "confluence-search-datasource-modal--site-selector",
|
|
382
401
|
label: siteSelectorLabel
|
|
383
|
-
})), !hasNoConfluenceSites && jsx(DisplayViewDropDown, {
|
|
402
|
+
})), !hasNoConfluenceSites && !disableDisplayDropdown && jsx(DisplayViewDropDown, {
|
|
384
403
|
onViewModeChange: handleViewModeChange,
|
|
385
404
|
viewMode: currentViewMode
|
|
386
405
|
})), jsx(ModalBody, null, !hasNoConfluenceSites ? jsx(Fragment, null, jsx(Box, {
|
|
@@ -173,6 +173,7 @@ const DatasourceTableViewWithoutAnalytics = ({
|
|
|
173
173
|
testId: "datasource-table-view-skeleton",
|
|
174
174
|
isCompact: true
|
|
175
175
|
}), jsx(TableFooter, {
|
|
176
|
+
datasourceId: datasourceId,
|
|
176
177
|
itemCount: isDataReady ? totalCount : undefined,
|
|
177
178
|
onRefresh: onRefresh,
|
|
178
179
|
isLoading: !isDataReady || status === 'loading',
|
|
@@ -3,9 +3,9 @@ import isEqual from 'lodash/isEqual';
|
|
|
3
3
|
import { useIntl } from 'react-intl-next';
|
|
4
4
|
import { useDebouncedCallback } from 'use-debounce';
|
|
5
5
|
import { FilterPopupSelect } from '../../../../common/modal/popup-select';
|
|
6
|
+
import { SEARCH_DEBOUNCE_MS } from '../../../../common/modal/popup-select/constants';
|
|
6
7
|
import { useFilterOptions } from '../../hooks/useFilterOptions';
|
|
7
8
|
import { asyncPopupSelectMessages } from './messages';
|
|
8
|
-
export const SEARCH_DEBOUNCE_MS = 350;
|
|
9
9
|
const AsyncPopupSelect = ({
|
|
10
10
|
filterType,
|
|
11
11
|
site,
|
|
@@ -82,11 +82,12 @@ const AsyncPopupSelect = ({
|
|
|
82
82
|
const isEmpty = status === 'resolved' && filterOptionsLength === 0;
|
|
83
83
|
const popupSelectOptions = isLoading || isError ? [] : filterOptions; // if not set to [], then on loading, no loading UI will be shown
|
|
84
84
|
const areAllResultsLoaded = filterOptionsLength === totalCount;
|
|
85
|
+
const filterName = `jlol-basic-filter-${filterType}`;
|
|
85
86
|
const shouldShowFooter = (status === 'resolved' || isLoadingMore) && filterOptionsLength > 0; // footer should not disappear when there is an inline spinner for loading more data
|
|
86
87
|
const shouldDisplayShowMoreButton = status === 'resolved' && !!pageCursor && !areAllResultsLoaded;
|
|
87
88
|
const triggerButtonLabel = formatMessage(asyncPopupSelectMessages[`${filterType}Label`]);
|
|
88
89
|
return /*#__PURE__*/React.createElement(FilterPopupSelect, {
|
|
89
|
-
filterName:
|
|
90
|
+
filterName: filterName,
|
|
90
91
|
status: status,
|
|
91
92
|
showLoading: isLoading,
|
|
92
93
|
showHydrating: isJQLHydrating,
|
|
@@ -100,7 +101,7 @@ const AsyncPopupSelect = ({
|
|
|
100
101
|
onSelectionChange: handleOptionSelection,
|
|
101
102
|
onMenuOpen: handleMenuOpen,
|
|
102
103
|
menuListProps: {
|
|
103
|
-
filterName
|
|
104
|
+
filterName,
|
|
104
105
|
isError,
|
|
105
106
|
isEmpty,
|
|
106
107
|
isLoading,
|
|
@@ -8,6 +8,7 @@ import { Flex, xcss } from '@atlaskit/primitives';
|
|
|
8
8
|
import { useDatasourceAnalyticsEvents } from '../../../analytics';
|
|
9
9
|
import { BasicSearchInput } from '../../common/modal/basic-search-input';
|
|
10
10
|
import { basicSearchInputMessages } from '../../common/modal/basic-search-input/messages';
|
|
11
|
+
import { FILTER_SELECTION_DEBOUNCE_MS } from '../../common/modal/popup-select/constants';
|
|
11
12
|
import { BasicFilters } from '../basic-filters';
|
|
12
13
|
import { useHydrateJqlQuery } from '../basic-filters/hooks/useHydrateJqlQuery';
|
|
13
14
|
import { isQueryTooComplex } from '../basic-filters/utils/isQueryTooComplex';
|
|
@@ -25,7 +26,6 @@ const basicSearchInputContainerStyles = xcss({
|
|
|
25
26
|
});
|
|
26
27
|
export const DEFAULT_JQL_QUERY = 'ORDER BY created DESC';
|
|
27
28
|
export const ALLOWED_ORDER_BY_KEYS = ['key', 'summary', 'assignee', 'status', 'created'];
|
|
28
|
-
export const FILTER_SELECTION_DEBOUNCE_MS = 500;
|
|
29
29
|
export const JiraSearchContainer = props => {
|
|
30
30
|
const {
|
|
31
31
|
isSearching,
|
|
@@ -7,9 +7,12 @@ import { FormattedMessage, FormattedNumber, useIntl } from 'react-intl-next';
|
|
|
7
7
|
import Button from '@atlaskit/button';
|
|
8
8
|
import Heading from '@atlaskit/heading';
|
|
9
9
|
import RefreshIcon from '@atlaskit/icon/glyph/refresh';
|
|
10
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
10
11
|
import LinkUrl from '@atlaskit/smart-card/link-url';
|
|
11
12
|
import { N0, N40, N800, N90 } from '@atlaskit/theme/colors';
|
|
13
|
+
import { ASSETS_LIST_OF_LINKS_DATASOURCE_ID } from '../assets-modal';
|
|
12
14
|
import { footerMessages } from './messages';
|
|
15
|
+
import { PoweredByJSMAssets } from './powered-by-jsm-assets';
|
|
13
16
|
import { SyncInfo } from './sync-info';
|
|
14
17
|
const FooterWrapper = styled.div({
|
|
15
18
|
padding: `${"var(--ds-space-0, 0px)"} ${"var(--ds-space-200, 16px)"}`,
|
|
@@ -40,6 +43,7 @@ const SyncTextWrapper = styled.div({
|
|
|
40
43
|
fontSize: '12px'
|
|
41
44
|
});
|
|
42
45
|
export const TableFooter = ({
|
|
46
|
+
datasourceId,
|
|
43
47
|
itemCount,
|
|
44
48
|
onRefresh,
|
|
45
49
|
isLoading,
|
|
@@ -77,7 +81,9 @@ export const TableFooter = ({
|
|
|
77
81
|
values: {
|
|
78
82
|
itemCount
|
|
79
83
|
}
|
|
80
|
-
}))))),
|
|
84
|
+
}))))), getBooleanFF('platform.linking-platform.datasource-assets_objects_add_jsm_promotional_tag') && datasourceId === ASSETS_LIST_OF_LINKS_DATASOURCE_ID ? jsx(PoweredByJSMAssets, {
|
|
85
|
+
text: intl.formatMessage(footerMessages.powerByJSM)
|
|
86
|
+
}) : null, jsx(SyncWrapper, null, onRefresh && jsx(Fragment, null, jsx(SyncTextWrapper, {
|
|
81
87
|
"data-testid": "sync-text"
|
|
82
88
|
}, isLoading ? jsx(FormattedMessage, footerMessages.loadingText) : jsx(SyncInfo, {
|
|
83
89
|
lastSyncTime: lastSyncTime
|
|
@@ -14,5 +14,10 @@ export const footerMessages = defineMessages({
|
|
|
14
14
|
id: 'linkDataSource.table-footer.refresh',
|
|
15
15
|
description: 'Label for refresh icon',
|
|
16
16
|
defaultMessage: 'Refresh'
|
|
17
|
+
},
|
|
18
|
+
powerByJSM: {
|
|
19
|
+
id: 'linkDataSource.table-footer.power-by-jsm',
|
|
20
|
+
description: 'Displayed on the issue like table footer to increase JSM Assets visibility',
|
|
21
|
+
defaultMessage: 'Powered by Assets in Jira Service Management'
|
|
17
22
|
}
|
|
18
23
|
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { JiraServiceManagementIcon } from '@atlaskit/logo';
|
|
3
|
+
import { Box, xcss } from '@atlaskit/primitives';
|
|
4
|
+
import { useDatasourceAnalyticsEvents } from '../../../analytics';
|
|
5
|
+
const jsmTextStyles = xcss({
|
|
6
|
+
fontSize: 'small',
|
|
7
|
+
color: 'color.text.subtle',
|
|
8
|
+
marginLeft: "var(--ds-space-075, 6px)",
|
|
9
|
+
':hover': {
|
|
10
|
+
color: 'color.link.pressed'
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
const jsmContainerStyles = xcss({
|
|
14
|
+
display: 'flex',
|
|
15
|
+
flexDirection: 'row-reverse'
|
|
16
|
+
});
|
|
17
|
+
export const PoweredByJSMAssets = props => {
|
|
18
|
+
const ASSETS_LINK = '/jira/servicedesk/assets';
|
|
19
|
+
const {
|
|
20
|
+
fireEvent
|
|
21
|
+
} = useDatasourceAnalyticsEvents();
|
|
22
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
23
|
+
xcss: jsmContainerStyles,
|
|
24
|
+
padding: "space.150"
|
|
25
|
+
}, /*#__PURE__*/React.createElement("a", {
|
|
26
|
+
"data-testid": 'powered-by-jsm-assets-link',
|
|
27
|
+
onClick: () => fireEvent('ui.link.clicked.poweredBy', {
|
|
28
|
+
componentHierarchy: 'datasourceTable',
|
|
29
|
+
extensionKey: 'jsm-cmdb-gateway'
|
|
30
|
+
}),
|
|
31
|
+
href: ASSETS_LINK,
|
|
32
|
+
rel: "noreferrer",
|
|
33
|
+
target: "_blank",
|
|
34
|
+
style: {
|
|
35
|
+
display: 'inline-flex',
|
|
36
|
+
alignItems: 'center'
|
|
37
|
+
}
|
|
38
|
+
}, /*#__PURE__*/React.createElement(JiraServiceManagementIcon, {
|
|
39
|
+
size: "xsmall",
|
|
40
|
+
appearance: "brand",
|
|
41
|
+
label: props.text
|
|
42
|
+
}), /*#__PURE__*/React.createElement(Box, {
|
|
43
|
+
xcss: jsmTextStyles
|
|
44
|
+
}, props.text)));
|
|
45
|
+
};
|
|
@@ -16,9 +16,10 @@ var footerPaginationInfoStyles = xcss({
|
|
|
16
16
|
});
|
|
17
17
|
var PopupFooter = function PopupFooter(_ref) {
|
|
18
18
|
var currentDisplayCount = _ref.currentDisplayCount,
|
|
19
|
-
totalCount = _ref.totalCount
|
|
19
|
+
totalCount = _ref.totalCount,
|
|
20
|
+
filterName = _ref.filterName;
|
|
20
21
|
return /*#__PURE__*/React.createElement(Flex, {
|
|
21
|
-
testId: "
|
|
22
|
+
testId: "".concat(filterName, "--footer"),
|
|
22
23
|
direction: "row",
|
|
23
24
|
alignItems: "center",
|
|
24
25
|
justifyContent: "end",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { Fragment } from 'react';
|
|
2
2
|
import Avatar from '@atlaskit/avatar';
|
|
3
3
|
import PeopleGroupIcon from '@atlaskit/icon/glyph/people-group';
|
|
4
4
|
import Lozenge from '@atlaskit/lozenge';
|
|
@@ -29,14 +29,14 @@ var IconOptionLabel = function IconOptionLabel(_ref) {
|
|
|
29
29
|
};
|
|
30
30
|
return /*#__PURE__*/React.createElement(AvatarOptionLabel, {
|
|
31
31
|
data: avatarOptionLabelData,
|
|
32
|
-
testId: "
|
|
32
|
+
testId: "basic-filter-popup-select-option--icon-label"
|
|
33
33
|
});
|
|
34
34
|
};
|
|
35
35
|
var LozengeOptionLabel = function LozengeOptionLabel(_ref2) {
|
|
36
36
|
var data = _ref2.data;
|
|
37
37
|
return /*#__PURE__*/React.createElement(Lozenge, {
|
|
38
38
|
appearance: data.appearance,
|
|
39
|
-
testId: "
|
|
39
|
+
testId: "basic-filter-popup-select-option--lozenge"
|
|
40
40
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
41
41
|
xcss: [commonLabelStyles]
|
|
42
42
|
}, data.label));
|
|
@@ -46,7 +46,7 @@ var AvatarOptionLabel = function AvatarOptionLabel(_ref3) {
|
|
|
46
46
|
testId = _ref3.testId;
|
|
47
47
|
return /*#__PURE__*/React.createElement(Flex, {
|
|
48
48
|
alignItems: "center",
|
|
49
|
-
testId: testId || '
|
|
49
|
+
testId: testId || 'basic-filter-popup-select-option--avatar'
|
|
50
50
|
}, data.isGroup ? /*#__PURE__*/React.createElement(Flex, {
|
|
51
51
|
alignItems: "center",
|
|
52
52
|
justifyContent: "center",
|
|
@@ -59,11 +59,13 @@ var AvatarOptionLabel = function AvatarOptionLabel(_ref3) {
|
|
|
59
59
|
src: data.avatar,
|
|
60
60
|
size: "xsmall"
|
|
61
61
|
}), /*#__PURE__*/React.createElement(Box, {
|
|
62
|
-
xcss: [commonLabelStyles, avatarOptionLabelStyles]
|
|
63
|
-
testId: "nidhin"
|
|
62
|
+
xcss: [commonLabelStyles, avatarOptionLabelStyles]
|
|
64
63
|
}, data.label));
|
|
65
64
|
};
|
|
66
65
|
var formatOptionLabel = function formatOptionLabel(data) {
|
|
66
|
+
if (data.optionType === 'defaultOption') {
|
|
67
|
+
return /*#__PURE__*/React.createElement(Fragment, null);
|
|
68
|
+
}
|
|
67
69
|
if (data.optionType === 'lozengeLabel') {
|
|
68
70
|
return /*#__PURE__*/React.createElement(LozengeOptionLabel, {
|
|
69
71
|
data: data
|
|
@@ -205,7 +205,8 @@ export var FilterPopupSelect = function FilterPopupSelect(_ref) {
|
|
|
205
205
|
},
|
|
206
206
|
footer: shouldShowFooter && /*#__PURE__*/React.createElement(PopupFooter, {
|
|
207
207
|
currentDisplayCount: options.length,
|
|
208
|
-
totalCount: totalCount
|
|
208
|
+
totalCount: totalCount,
|
|
209
|
+
filterName: filterName
|
|
209
210
|
})
|
|
210
211
|
});
|
|
211
212
|
};
|
|
@@ -4,7 +4,7 @@ import { useDebouncedCallback } from 'use-debounce';
|
|
|
4
4
|
import ErrorIcon from '@atlaskit/icon/glyph/error';
|
|
5
5
|
import { N500 } from '@atlaskit/theme/colors';
|
|
6
6
|
import { useDatasourceAnalyticsEvents } from '../../../../../analytics';
|
|
7
|
-
import { SEARCH_DEBOUNCE_MS } from '
|
|
7
|
+
import { SEARCH_DEBOUNCE_MS } from '../constants';
|
|
8
8
|
import { asyncPopupSelectMessages } from './messages';
|
|
9
9
|
import CustomSelectMessage from './selectMessage';
|
|
10
10
|
var getErrorReasonType = function getErrorReasonType(errors) {
|
|
@@ -45,7 +45,7 @@ var CustomErrorMessage = function CustomErrorMessage(_ref3) {
|
|
|
45
45
|
size: "xlarge"
|
|
46
46
|
}),
|
|
47
47
|
message: asyncPopupSelectMessages.errorMessage,
|
|
48
|
-
testId: "
|
|
48
|
+
testId: "".concat(filterName, "--error-message")
|
|
49
49
|
});
|
|
50
50
|
};
|
|
51
51
|
export default CustomErrorMessage;
|
|
@@ -39,7 +39,9 @@ var CustomMenuList = function CustomMenuList(_ref) {
|
|
|
39
39
|
};
|
|
40
40
|
var renderChildren = function renderChildren() {
|
|
41
41
|
if (isLoading) {
|
|
42
|
-
return /*#__PURE__*/React.createElement(CustomDropdownLoadingMessage,
|
|
42
|
+
return /*#__PURE__*/React.createElement(CustomDropdownLoadingMessage, {
|
|
43
|
+
filterName: filterName
|
|
44
|
+
});
|
|
43
45
|
}
|
|
44
46
|
if (isError) {
|
|
45
47
|
return /*#__PURE__*/React.createElement(CustomErrorMessage, {
|
|
@@ -52,7 +54,7 @@ var CustomMenuList = function CustomMenuList(_ref) {
|
|
|
52
54
|
filterName: filterName
|
|
53
55
|
});
|
|
54
56
|
}
|
|
55
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, children, shouldDisplayShowMore && /*#__PURE__*/React.createElement(Box, {
|
|
57
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children, shouldDisplayShowMore && handleShowMore && /*#__PURE__*/React.createElement(Box, {
|
|
56
58
|
xcss: showMoreButtonBoxStyles
|
|
57
59
|
}, /*#__PURE__*/React.createElement(ShowMoreButton, {
|
|
58
60
|
onShowMore: handleShowMore,
|
|
@@ -2,13 +2,14 @@ import React from 'react';
|
|
|
2
2
|
import Spinner from '@atlaskit/spinner';
|
|
3
3
|
import { asyncPopupSelectMessages } from './messages';
|
|
4
4
|
import CustomSelectMessage from './selectMessage';
|
|
5
|
-
var CustomDropdownLoadingMessage = function CustomDropdownLoadingMessage() {
|
|
5
|
+
var CustomDropdownLoadingMessage = function CustomDropdownLoadingMessage(_ref) {
|
|
6
|
+
var filterName = _ref.filterName;
|
|
6
7
|
return /*#__PURE__*/React.createElement(CustomSelectMessage, {
|
|
7
8
|
icon: /*#__PURE__*/React.createElement(Spinner, {
|
|
8
9
|
size: "large"
|
|
9
10
|
}),
|
|
10
11
|
message: asyncPopupSelectMessages.loadingMessage,
|
|
11
|
-
testId: "
|
|
12
|
+
testId: "".concat(filterName, "--loading-message")
|
|
12
13
|
});
|
|
13
14
|
};
|
|
14
15
|
export default CustomDropdownLoadingMessage;
|
|
@@ -4,7 +4,7 @@ import { useDebouncedCallback } from 'use-debounce';
|
|
|
4
4
|
import QuestionCircleIcon from '@atlaskit/icon/glyph/question-circle';
|
|
5
5
|
import { N500 } from '@atlaskit/theme/colors';
|
|
6
6
|
import { useDatasourceAnalyticsEvents } from '../../../../../analytics';
|
|
7
|
-
import { SEARCH_DEBOUNCE_MS } from '
|
|
7
|
+
import { SEARCH_DEBOUNCE_MS } from '../constants';
|
|
8
8
|
import { asyncPopupSelectMessages } from './messages';
|
|
9
9
|
import CustomSelectMessage from './selectMessage';
|
|
10
10
|
var CustomNoOptionsMessage = function CustomNoOptionsMessage(_ref) {
|
|
@@ -33,7 +33,7 @@ var CustomNoOptionsMessage = function CustomNoOptionsMessage(_ref) {
|
|
|
33
33
|
label: ""
|
|
34
34
|
}),
|
|
35
35
|
message: asyncPopupSelectMessages.noOptionsMessage,
|
|
36
|
-
testId: "
|
|
36
|
+
testId: "".concat(filterName, "--no-options-message")
|
|
37
37
|
});
|
|
38
38
|
};
|
|
39
39
|
export default CustomNoOptionsMessage;
|
|
@@ -20,7 +20,7 @@ var ShowMoreButton = function ShowMoreButton(_ref) {
|
|
|
20
20
|
return /*#__PURE__*/React.createElement(Button, {
|
|
21
21
|
onClick: handleShowMore,
|
|
22
22
|
appearance: "link",
|
|
23
|
-
testId: "
|
|
23
|
+
testId: "".concat(filterName, "--show-more-button")
|
|
24
24
|
}, formatMessage(asyncPopupSelectMessages.showMoreMessage));
|
|
25
25
|
};
|
|
26
26
|
export default ShowMoreButton;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import { PopupComponentContainer } from './styled';
|
|
4
|
+
export var PopupComponent = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
5
|
+
return /*#__PURE__*/React.createElement(PopupComponentContainer, _extends({}, props, {
|
|
6
|
+
"data-testId": 'confluence-search-datasource-popup-container',
|
|
7
|
+
ref: ref
|
|
8
|
+
}));
|
|
9
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import React, { useCallback, useState } from 'react';
|
|
3
|
+
import { FormattedMessage, useIntl } from 'react-intl-next';
|
|
4
|
+
import Popup from '@atlaskit/popup';
|
|
5
|
+
import { layers } from '@atlaskit/theme/constants';
|
|
6
|
+
import { CLOLBasicFilters } from '../../types';
|
|
7
|
+
import { dateRangeMessages } from './messages';
|
|
8
|
+
import { PopupComponent } from './PopupComponent';
|
|
9
|
+
import { CustomDropdown, CustomDropdownItem } from './styled';
|
|
10
|
+
import { PopupTrigger } from './trigger';
|
|
11
|
+
var lastModifiedValues = ['anyTime', 'today', 'yesterday', 'past7Days', 'past30Days', 'pastYear', 'custom'];
|
|
12
|
+
var defaultOptionValue = 'anyTime';
|
|
13
|
+
var filterName = CLOLBasicFilters.lastModified;
|
|
14
|
+
export var DateRangePicker = function DateRangePicker(_ref) {
|
|
15
|
+
var onSelectionChange = _ref.onSelectionChange;
|
|
16
|
+
var _useState = useState(null),
|
|
17
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
18
|
+
currentOption = _useState2[0],
|
|
19
|
+
setCurrentOption = _useState2[1];
|
|
20
|
+
var _useState3 = useState(false),
|
|
21
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
22
|
+
isPickerOpen = _useState4[0],
|
|
23
|
+
setIsPickerOpen = _useState4[1];
|
|
24
|
+
var _useIntl = useIntl(),
|
|
25
|
+
formatMessage = _useIntl.formatMessage;
|
|
26
|
+
var onClickFilterOption = useCallback(function (option) {
|
|
27
|
+
setCurrentOption(option);
|
|
28
|
+
setIsPickerOpen(false);
|
|
29
|
+
onSelectionChange(filterName, [{
|
|
30
|
+
optionType: 'defaultOption',
|
|
31
|
+
label: option,
|
|
32
|
+
value: option
|
|
33
|
+
}]);
|
|
34
|
+
}, [onSelectionChange]);
|
|
35
|
+
var handleTogglePopup = useCallback(function () {
|
|
36
|
+
setIsPickerOpen(!isPickerOpen);
|
|
37
|
+
}, [isPickerOpen]);
|
|
38
|
+
return /*#__PURE__*/React.createElement(Popup, {
|
|
39
|
+
isOpen: isPickerOpen,
|
|
40
|
+
onClose: handleTogglePopup,
|
|
41
|
+
popupComponent: PopupComponent,
|
|
42
|
+
zIndex: layers.modal(),
|
|
43
|
+
content: function content() {
|
|
44
|
+
return /*#__PURE__*/React.createElement(CustomDropdown, null, lastModifiedValues.map(function (option) {
|
|
45
|
+
return /*#__PURE__*/React.createElement(CustomDropdownItem, {
|
|
46
|
+
key: option
|
|
47
|
+
//want to show Anytime as selected if none of the other options are selected
|
|
48
|
+
,
|
|
49
|
+
isSelected: currentOption ? option === currentOption : option === defaultOptionValue,
|
|
50
|
+
onClick: function onClick() {
|
|
51
|
+
return onClickFilterOption(option);
|
|
52
|
+
}
|
|
53
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, getCurrentOptionLabel(option)));
|
|
54
|
+
}));
|
|
55
|
+
},
|
|
56
|
+
placement: "bottom-start",
|
|
57
|
+
trigger: function trigger(triggerProps) {
|
|
58
|
+
return /*#__PURE__*/React.createElement(PopupTrigger, {
|
|
59
|
+
triggerProps: triggerProps,
|
|
60
|
+
optionSelected: !!currentOption,
|
|
61
|
+
label: formatMessage(dateRangeMessages.dateRangeTitle),
|
|
62
|
+
selectedLabel: formatMessage(getCurrentOptionLabel(currentOption)),
|
|
63
|
+
onClickButton: handleTogglePopup
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
var getCurrentOptionLabel = function getCurrentOptionLabel(option) {
|
|
69
|
+
var mapping = {
|
|
70
|
+
anyTime: 'dateRangeAnyTime',
|
|
71
|
+
today: 'dateRangeToday',
|
|
72
|
+
yesterday: 'dateRangeYesterday',
|
|
73
|
+
past7Days: 'dateRangeLastWeek',
|
|
74
|
+
past30Days: 'dateRangeLastMonth',
|
|
75
|
+
pastYear: 'dateRangeLastYear',
|
|
76
|
+
custom: 'dateRangeCustom'
|
|
77
|
+
};
|
|
78
|
+
return option ? dateRangeMessages[mapping[option]] : dateRangeMessages[mapping['anyTime']];
|
|
79
|
+
};
|