@atlaskit/link-datasource 2.0.1 → 2.0.3
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 +23 -0
- package/dist/cjs/ui/confluence-search-modal/basic-filters/filters/date-range-picker/index.js +57 -62
- package/dist/cjs/ui/confluence-search-modal/basic-filters/filters/date-range-picker/styled.js +5 -5
- package/dist/cjs/ui/confluence-search-modal/basic-filters/filters/date-range-picker/utils.js +29 -25
- package/dist/cjs/ui/confluence-search-modal/basic-filters/hooks/useBasicFilterHydration.js +6 -1
- package/dist/cjs/ui/confluence-search-modal/basic-filters/index.js +9 -2
- package/dist/cjs/ui/confluence-search-modal/confluence-search-container/index.js +38 -18
- package/dist/cjs/ui/confluence-search-modal/modal/index.js +11 -25
- package/dist/cjs/ui/issue-like-table/render-type/link/index.js +1 -2
- package/dist/es2019/ui/confluence-search-modal/basic-filters/filters/date-range-picker/index.js +51 -60
- package/dist/es2019/ui/confluence-search-modal/basic-filters/filters/date-range-picker/styled.js +5 -5
- package/dist/es2019/ui/confluence-search-modal/basic-filters/filters/date-range-picker/utils.js +25 -23
- package/dist/es2019/ui/confluence-search-modal/basic-filters/hooks/useBasicFilterHydration.js +6 -1
- package/dist/es2019/ui/confluence-search-modal/basic-filters/index.js +7 -2
- package/dist/es2019/ui/confluence-search-modal/confluence-search-container/index.js +29 -13
- package/dist/es2019/ui/confluence-search-modal/modal/index.js +9 -25
- package/dist/es2019/ui/issue-like-table/render-type/link/index.js +1 -2
- package/dist/esm/ui/confluence-search-modal/basic-filters/filters/date-range-picker/index.js +59 -64
- package/dist/esm/ui/confluence-search-modal/basic-filters/filters/date-range-picker/styled.js +5 -5
- package/dist/esm/ui/confluence-search-modal/basic-filters/filters/date-range-picker/utils.js +25 -23
- package/dist/esm/ui/confluence-search-modal/basic-filters/hooks/useBasicFilterHydration.js +6 -1
- package/dist/esm/ui/confluence-search-modal/basic-filters/index.js +9 -2
- package/dist/esm/ui/confluence-search-modal/confluence-search-container/index.js +38 -18
- package/dist/esm/ui/confluence-search-modal/modal/index.js +11 -25
- package/dist/esm/ui/issue-like-table/render-type/link/index.js +1 -2
- package/dist/types/ui/confluence-search-modal/basic-filters/filters/date-range-picker/index.d.ts +3 -3
- package/dist/types/ui/confluence-search-modal/basic-filters/filters/date-range-picker/utils.d.ts +3 -3
- package/dist/types/ui/confluence-search-modal/basic-filters/hooks/useBasicFilterHydration.d.ts +2 -1
- package/dist/types/ui/confluence-search-modal/basic-filters/index.d.ts +2 -2
- package/dist/types/ui/confluence-search-modal/confluence-search-container/index.d.ts +4 -8
- package/dist/types-ts4.5/ui/confluence-search-modal/basic-filters/filters/date-range-picker/index.d.ts +3 -3
- package/dist/types-ts4.5/ui/confluence-search-modal/basic-filters/filters/date-range-picker/utils.d.ts +3 -3
- package/dist/types-ts4.5/ui/confluence-search-modal/basic-filters/hooks/useBasicFilterHydration.d.ts +2 -1
- package/dist/types-ts4.5/ui/confluence-search-modal/basic-filters/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/confluence-search-modal/confluence-search-container/index.d.ts +4 -8
- package/package.json +11 -11
package/dist/es2019/ui/confluence-search-modal/basic-filters/filters/date-range-picker/index.js
CHANGED
|
@@ -1,94 +1,79 @@
|
|
|
1
|
-
import React, { useCallback,
|
|
1
|
+
import React, { useCallback, useState } from 'react';
|
|
2
2
|
import { FormattedMessage, useIntl } from 'react-intl-next';
|
|
3
3
|
import { DatePicker } from '@atlaskit/datetime-picker';
|
|
4
4
|
import ErrorIcon from '@atlaskit/icon/glyph/error';
|
|
5
5
|
import Popup from '@atlaskit/popup';
|
|
6
6
|
import { R400 } from '@atlaskit/theme/colors';
|
|
7
7
|
import { layers } from '@atlaskit/theme/constants';
|
|
8
|
-
import { CLOLBasicFilters } from '../../types';
|
|
9
8
|
import { dateRangeMessages } from './messages';
|
|
10
9
|
import { PopupComponent } from './PopupComponent';
|
|
11
10
|
import { CustomDateWrapper, CustomDropdown, CustomDropdownItem, DatePickersWrapper, DateRangeErrorMessage, SelectDateRangeButton } from './styled';
|
|
12
11
|
import { PopupTrigger } from './trigger';
|
|
13
|
-
import { getCurrentOptionLabel, getDropdownLabel,
|
|
14
|
-
const
|
|
12
|
+
import { getCurrentOptionLabel, getDropdownLabel, useInvalidDateRange } from './utils';
|
|
13
|
+
const dateRangeValues = ['anyTime', 'today', 'yesterday', 'past7Days', 'past30Days', 'pastYear', 'custom'];
|
|
15
14
|
const defaultOptionValue = 'anyTime';
|
|
16
15
|
export const DateRangePicker = ({
|
|
17
16
|
onSelectionChange,
|
|
18
17
|
selection
|
|
19
18
|
}) => {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
const {
|
|
20
|
+
value: selectedValue,
|
|
21
|
+
from: fromDate,
|
|
22
|
+
to: toDate
|
|
23
|
+
} = selection || {};
|
|
24
|
+
const todayDate = new Date().toISOString();
|
|
25
25
|
const {
|
|
26
26
|
locale,
|
|
27
27
|
formatMessage,
|
|
28
28
|
formatDate
|
|
29
29
|
} = useIntl();
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
}, [isPickerOpen, selection === null || selection === void 0 ? void 0 : selection.from, selection === null || selection === void 0 ? void 0 : selection.to]);
|
|
38
|
-
const handleFromOnChange = date => {
|
|
39
|
-
customFromDate.current = date;
|
|
40
|
-
setInvalidDateRange(getInvalidDateRange(customFromDate.current, customToDate.current));
|
|
41
|
-
};
|
|
42
|
-
const handleToOnChange = date => {
|
|
43
|
-
customToDate.current = date;
|
|
44
|
-
setInvalidDateRange(getInvalidDateRange(customFromDate.current, customToDate.current));
|
|
45
|
-
};
|
|
30
|
+
const [currentOption, setCurrentOption] = useState(selectedValue);
|
|
31
|
+
const [customFromDate, setCustomFromDate] = useState(fromDate);
|
|
32
|
+
const [customToDate, setCustomToDate] = useState(toDate);
|
|
33
|
+
const [isPickerOpen, setIsPickerOpen] = useState(false);
|
|
34
|
+
const isCustomSelected = currentOption === 'custom';
|
|
35
|
+
const invalidDateRange = useInvalidDateRange(customFromDate, customToDate);
|
|
46
36
|
const handleClickUpdateDateRange = () => {
|
|
47
|
-
|
|
48
|
-
if (customFromDate.current && !customToDate.current) {
|
|
49
|
-
label = customFromDate.current;
|
|
50
|
-
} else if (customToDate.current && !customFromDate.current) {
|
|
51
|
-
label = customToDate.current;
|
|
52
|
-
}
|
|
53
|
-
onSelectionChange(CLOLBasicFilters.lastModified, {
|
|
54
|
-
optionType: 'dateRange',
|
|
55
|
-
label: label,
|
|
37
|
+
onSelectionChange({
|
|
56
38
|
value: 'custom',
|
|
57
|
-
from: customFromDate
|
|
58
|
-
to: customToDate
|
|
39
|
+
from: customFromDate,
|
|
40
|
+
to: customToDate
|
|
59
41
|
});
|
|
60
42
|
setIsPickerOpen(false);
|
|
61
43
|
};
|
|
62
44
|
const handleClickFilterOption = useCallback(option => {
|
|
63
45
|
setCurrentOption(option);
|
|
64
|
-
onSelectionChange(
|
|
65
|
-
optionType: 'dateRange',
|
|
66
|
-
label: option,
|
|
46
|
+
onSelectionChange({
|
|
67
47
|
value: option
|
|
68
48
|
});
|
|
69
49
|
if (option !== 'custom') {
|
|
70
50
|
setIsPickerOpen(false);
|
|
71
51
|
}
|
|
72
52
|
}, [onSelectionChange]);
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
53
|
+
const handlePickerToggle = () => {
|
|
54
|
+
if (isPickerOpen) {
|
|
55
|
+
setCustomToDate(toDate);
|
|
56
|
+
setCustomFromDate(fromDate);
|
|
57
|
+
setIsPickerOpen(false);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
setIsPickerOpen(true);
|
|
61
|
+
return;
|
|
62
|
+
};
|
|
78
63
|
return /*#__PURE__*/React.createElement(Popup, {
|
|
79
64
|
isOpen: isPickerOpen,
|
|
80
|
-
onClose:
|
|
65
|
+
onClose: handlePickerToggle,
|
|
81
66
|
popupComponent: PopupComponent,
|
|
82
67
|
zIndex: layers.modal(),
|
|
83
68
|
content: () => {
|
|
84
|
-
return /*#__PURE__*/React.createElement(CustomDropdown, null,
|
|
69
|
+
return /*#__PURE__*/React.createElement(CustomDropdown, null, dateRangeValues.map(option => /*#__PURE__*/React.createElement(CustomDropdownItem, {
|
|
85
70
|
key: option
|
|
86
71
|
// want to show Anytime as selected if none of the other options are selected
|
|
87
72
|
,
|
|
88
|
-
isSelected:
|
|
73
|
+
isSelected: selectedValue ? option === selectedValue : option === defaultOptionValue,
|
|
89
74
|
onClick: () => handleClickFilterOption(option)
|
|
90
75
|
}, getDropdownLabel(option, formatMessage))), isPickerOpen && isCustomSelected && /*#__PURE__*/React.createElement(CustomDateWrapper, null, /*#__PURE__*/React.createElement(DatePickersWrapper, null, /*#__PURE__*/React.createElement(DatePicker, {
|
|
91
|
-
maxDate:
|
|
76
|
+
maxDate: todayDate,
|
|
92
77
|
innerProps: {
|
|
93
78
|
style: {
|
|
94
79
|
width: 140
|
|
@@ -96,8 +81,9 @@ export const DateRangePicker = ({
|
|
|
96
81
|
},
|
|
97
82
|
testId: "date-from-picker",
|
|
98
83
|
dateFormat: "D MMM YYYY",
|
|
99
|
-
onChange:
|
|
100
|
-
|
|
84
|
+
onChange: setCustomFromDate,
|
|
85
|
+
onDelete: () => setCustomFromDate(undefined),
|
|
86
|
+
defaultValue: fromDate,
|
|
101
87
|
placeholder: formatMessage(dateRangeMessages.dateRangeFrom),
|
|
102
88
|
isInvalid: Boolean(invalidDateRange),
|
|
103
89
|
locale: locale,
|
|
@@ -110,7 +96,7 @@ export const DateRangePicker = ({
|
|
|
110
96
|
}
|
|
111
97
|
}
|
|
112
98
|
}), /*#__PURE__*/React.createElement(FormattedMessage, dateRangeMessages.dateRangeToLabel), /*#__PURE__*/React.createElement(DatePicker, {
|
|
113
|
-
maxDate:
|
|
99
|
+
maxDate: todayDate,
|
|
114
100
|
innerProps: {
|
|
115
101
|
style: {
|
|
116
102
|
width: 140
|
|
@@ -118,8 +104,9 @@ export const DateRangePicker = ({
|
|
|
118
104
|
},
|
|
119
105
|
testId: "date-to-picker",
|
|
120
106
|
dateFormat: "D MMM YYYY",
|
|
121
|
-
onChange:
|
|
122
|
-
|
|
107
|
+
onChange: setCustomToDate,
|
|
108
|
+
onDelete: () => setCustomToDate(undefined),
|
|
109
|
+
defaultValue: toDate,
|
|
123
110
|
placeholder: formatMessage(dateRangeMessages.dateRangeTo),
|
|
124
111
|
isInvalid: Boolean(invalidDateRange),
|
|
125
112
|
locale: locale,
|
|
@@ -142,12 +129,16 @@ export const DateRangePicker = ({
|
|
|
142
129
|
}, formatMessage(dateRangeMessages.dateRangeUpdateButton))));
|
|
143
130
|
},
|
|
144
131
|
placement: "bottom-start",
|
|
145
|
-
trigger: triggerProps =>
|
|
146
|
-
|
|
147
|
-
isSelected
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
132
|
+
trigger: triggerProps => {
|
|
133
|
+
const labelText = getCurrentOptionLabel(formatDate, formatMessage, selectedValue, toDate, fromDate);
|
|
134
|
+
const isSelected = !!selectedValue || isPickerOpen;
|
|
135
|
+
return /*#__PURE__*/React.createElement(PopupTrigger, {
|
|
136
|
+
triggerProps: triggerProps,
|
|
137
|
+
isSelected: isSelected,
|
|
138
|
+
labelPrefix: formatMessage(dateRangeMessages.dateRangeTitle),
|
|
139
|
+
selectedLabel: labelText,
|
|
140
|
+
onClick: handlePickerToggle
|
|
141
|
+
});
|
|
142
|
+
}
|
|
152
143
|
});
|
|
153
144
|
};
|
package/dist/es2019/ui/confluence-search-modal/basic-filters/filters/date-range-picker/styled.js
CHANGED
|
@@ -6,7 +6,7 @@ export const PopupComponentContainer = styled.div({
|
|
|
6
6
|
display: 'block',
|
|
7
7
|
flex: '1 1 auto',
|
|
8
8
|
overflow: 'visible',
|
|
9
|
-
borderRadius: "var(--ds-border-radius-
|
|
9
|
+
borderRadius: "var(--ds-border-radius-100, 4px)",
|
|
10
10
|
background: `var(--ds-background-input, ${N0})`,
|
|
11
11
|
':focus': {
|
|
12
12
|
outline: 'none'
|
|
@@ -16,7 +16,7 @@ export const PopupComponentContainer = styled.div({
|
|
|
16
16
|
export const CustomDropdown = styled.div({
|
|
17
17
|
width: '340px',
|
|
18
18
|
background: `var(--ds-background-input, ${N0})`,
|
|
19
|
-
borderRadius: "var(--ds-border-radius-
|
|
19
|
+
borderRadius: "var(--ds-border-radius-100, 4px)",
|
|
20
20
|
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))",
|
|
21
21
|
zIndex: layers.modal()
|
|
22
22
|
});
|
|
@@ -53,7 +53,7 @@ export const SelectDateRangeButton = styled.button({
|
|
|
53
53
|
width: '70px',
|
|
54
54
|
height: '40px',
|
|
55
55
|
marginTop: "var(--ds-space-150, 12px)",
|
|
56
|
-
borderRadius: "var(--ds-border-radius-
|
|
56
|
+
borderRadius: "var(--ds-border-radius-100, 4px)",
|
|
57
57
|
'&:hover': {
|
|
58
58
|
background: `var(--ds-background-accent-gray-subtler, ${N30})`,
|
|
59
59
|
cursor: 'pointer'
|
|
@@ -62,7 +62,7 @@ export const SelectDateRangeButton = styled.button({
|
|
|
62
62
|
export const DateRangeErrorMessage = styled.div({
|
|
63
63
|
display: 'flex',
|
|
64
64
|
lineHeight: 1.3333,
|
|
65
|
-
marginTop: "var(--ds-space-050,
|
|
66
|
-
fontSize:
|
|
65
|
+
marginTop: "var(--ds-space-050, 2px)",
|
|
66
|
+
fontSize: "var(--ds-font-size-075, 12px)",
|
|
67
67
|
color: `var(--ds-text-danger, ${R400})`
|
|
68
68
|
});
|
package/dist/es2019/ui/confluence-search-modal/basic-filters/filters/date-range-picker/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
2
|
import { FormattedMessage } from 'react-intl-next';
|
|
3
3
|
import { getFormattedDate } from '../../../../../ui/issue-like-table/render-type/date-time';
|
|
4
4
|
import { dateRangeMessages } from './messages';
|
|
@@ -14,13 +14,13 @@ export const getDropdownLabel = (option = 'anyTime', formatMessage) => {
|
|
|
14
14
|
};
|
|
15
15
|
return formatMessage(dateRangeMessages[mapping[option]]);
|
|
16
16
|
};
|
|
17
|
-
export const getCurrentOptionLabel = (formatDate, formatMessage,
|
|
18
|
-
const selectedOption =
|
|
17
|
+
export const getCurrentOptionLabel = (formatDate, formatMessage, value, to, from) => {
|
|
18
|
+
const selectedOption = value;
|
|
19
19
|
if (selectedOption === 'custom') {
|
|
20
|
-
const hasFromDate = !!
|
|
21
|
-
const hasToDate = !!
|
|
22
|
-
const formattedFromDate = getFormattedDate(
|
|
23
|
-
const formattedToDate = getFormattedDate(
|
|
20
|
+
const hasFromDate = !!from;
|
|
21
|
+
const hasToDate = !!to;
|
|
22
|
+
const formattedFromDate = getFormattedDate(from || '', 'date', formatDate);
|
|
23
|
+
const formattedToDate = getFormattedDate(to || '', 'date', formatDate);
|
|
24
24
|
if (hasFromDate && !hasToDate) {
|
|
25
25
|
return formatMessage(dateRangeMessages.dateRangeAfterLabel, {
|
|
26
26
|
date: formattedFromDate
|
|
@@ -37,21 +37,23 @@ export const getCurrentOptionLabel = (formatDate, formatMessage, selection) => {
|
|
|
37
37
|
}
|
|
38
38
|
return getDropdownLabel(selectedOption, formatMessage);
|
|
39
39
|
};
|
|
40
|
-
export const
|
|
41
|
-
|
|
40
|
+
export const useInvalidDateRange = (from, to) => {
|
|
41
|
+
return useMemo(() => {
|
|
42
|
+
if (!from && !to) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const dateFrom = new Date(`${from}${from ? 'T00:00:00' : ''}`);
|
|
46
|
+
const dateTo = new Date(`${to}${to ? 'T00:00:00' : ''}`);
|
|
47
|
+
const now = new Date();
|
|
48
|
+
if (dateFrom > now) {
|
|
49
|
+
return /*#__PURE__*/React.createElement(FormattedMessage, dateRangeMessages.dateRangeCustomInvalidDateAfterToday);
|
|
50
|
+
}
|
|
51
|
+
if (dateFrom > dateTo) {
|
|
52
|
+
return /*#__PURE__*/React.createElement(FormattedMessage, dateRangeMessages.dateRangeCustomInvalidDateAfterEnd);
|
|
53
|
+
}
|
|
54
|
+
if (dateTo > now) {
|
|
55
|
+
return /*#__PURE__*/React.createElement(FormattedMessage, dateRangeMessages.dateRangeCustomInvalidToDateAfterToday);
|
|
56
|
+
}
|
|
42
57
|
return null;
|
|
43
|
-
}
|
|
44
|
-
const dateFrom = new Date(`${from}${from ? 'T00:00:00' : ''}`);
|
|
45
|
-
const dateTo = new Date(`${to}${to ? 'T00:00:00' : ''}`);
|
|
46
|
-
const now = new Date();
|
|
47
|
-
if (dateFrom > now) {
|
|
48
|
-
return /*#__PURE__*/React.createElement(FormattedMessage, dateRangeMessages.dateRangeCustomInvalidDateAfterToday);
|
|
49
|
-
}
|
|
50
|
-
if (dateFrom > dateTo) {
|
|
51
|
-
return /*#__PURE__*/React.createElement(FormattedMessage, dateRangeMessages.dateRangeCustomInvalidDateAfterEnd);
|
|
52
|
-
}
|
|
53
|
-
if (dateTo > now) {
|
|
54
|
-
return /*#__PURE__*/React.createElement(FormattedMessage, dateRangeMessages.dateRangeCustomInvalidToDateAfterToday);
|
|
55
|
-
}
|
|
56
|
-
return null;
|
|
58
|
+
}, [from, to]);
|
|
57
59
|
};
|
package/dist/es2019/ui/confluence-search-modal/basic-filters/hooks/useBasicFilterHydration.js
CHANGED
|
@@ -31,9 +31,14 @@ export const useBasicFilterHydration = () => {
|
|
|
31
31
|
setStatus('rejected');
|
|
32
32
|
}
|
|
33
33
|
}, [getUsersFromAccountIDs]);
|
|
34
|
+
const reset = useCallback(() => {
|
|
35
|
+
setStatus('empty');
|
|
36
|
+
setUsers([]);
|
|
37
|
+
}, []);
|
|
34
38
|
return {
|
|
35
39
|
hydrateUsersFromAccountIds,
|
|
36
40
|
status,
|
|
37
|
-
users
|
|
41
|
+
users,
|
|
42
|
+
reset
|
|
38
43
|
};
|
|
39
44
|
};
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { Flex, xcss } from '@atlaskit/primitives';
|
|
3
3
|
import { DateRangePicker } from './filters/date-range-picker';
|
|
4
4
|
import EditedOrCreatedByFilter from './filters/edited-or-created-by';
|
|
5
|
+
import { CLOLBasicFilters } from './types';
|
|
5
6
|
const basicFilterContainerStyles = xcss({
|
|
6
7
|
paddingLeft: 'space.100'
|
|
7
8
|
});
|
|
@@ -17,8 +18,12 @@ const BasicFilterContainer = ({
|
|
|
17
18
|
} = selections;
|
|
18
19
|
const [lastModifiedValue] = lastModified || [];
|
|
19
20
|
const lastModifiedSelection = (lastModifiedValue === null || lastModifiedValue === void 0 ? void 0 : lastModifiedValue.optionType) === 'dateRange' ? lastModifiedValue : undefined;
|
|
20
|
-
const onDateRangePickerChange =
|
|
21
|
-
onChange(
|
|
21
|
+
const onDateRangePickerChange = updatedOption => {
|
|
22
|
+
onChange(CLOLBasicFilters.lastModified, {
|
|
23
|
+
optionType: 'dateRange',
|
|
24
|
+
label: updatedOption.value,
|
|
25
|
+
...updatedOption
|
|
26
|
+
});
|
|
22
27
|
};
|
|
23
28
|
return /*#__PURE__*/React.createElement(Flex, {
|
|
24
29
|
xcss: basicFilterContainerStyles,
|
|
@@ -6,26 +6,40 @@ import { BasicSearchInput } from '../../common/modal/basic-search-input';
|
|
|
6
6
|
import { FILTER_SELECTION_DEBOUNCE_MS } from '../../common/modal/popup-select/constants';
|
|
7
7
|
import BasicFilters from '../basic-filters';
|
|
8
8
|
import { useBasicFilterHydration } from '../basic-filters/hooks/useBasicFilterHydration';
|
|
9
|
-
import { CLOLBasicFilters } from '../basic-filters/types';
|
|
10
9
|
import { searchMessages } from './messages';
|
|
11
10
|
const basicSearchInputContainerStyles = xcss({
|
|
12
11
|
flexGrow: 1
|
|
13
12
|
});
|
|
14
13
|
const ConfluenceSearchContainer = ({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
parameters: {
|
|
15
|
+
cloudId,
|
|
16
|
+
searchString: initialSearchValue,
|
|
17
|
+
lastModified,
|
|
18
|
+
lastModifiedFrom,
|
|
19
|
+
lastModifiedTo,
|
|
20
|
+
contributorAccountIds
|
|
21
|
+
},
|
|
18
22
|
isSearching,
|
|
19
23
|
onSearch
|
|
20
24
|
}) => {
|
|
21
25
|
const {
|
|
22
26
|
hydrateUsersFromAccountIds,
|
|
23
27
|
users,
|
|
24
|
-
status
|
|
28
|
+
status,
|
|
29
|
+
reset: resetHydrationHook
|
|
25
30
|
} = useBasicFilterHydration();
|
|
26
31
|
const currentCloudId = useRef(cloudId);
|
|
32
|
+
const [initialContributorAccountIds, setInitialContributorAccountIds] = useState(contributorAccountIds !== null && contributorAccountIds !== void 0 ? contributorAccountIds : []);
|
|
27
33
|
const [searchBarSearchString, setSearchBarSearchString] = useState(initialSearchValue !== null && initialSearchValue !== void 0 ? initialSearchValue : '');
|
|
28
|
-
const [filterSelections, setFilterSelections] = useState({
|
|
34
|
+
const [filterSelections, setFilterSelections] = useState(() => lastModified ? {
|
|
35
|
+
lastModified: [{
|
|
36
|
+
optionType: 'dateRange',
|
|
37
|
+
label: lastModified,
|
|
38
|
+
value: lastModified,
|
|
39
|
+
from: lastModifiedFrom,
|
|
40
|
+
to: lastModifiedTo
|
|
41
|
+
}]
|
|
42
|
+
} : {});
|
|
29
43
|
const handleSearchChange = useCallback(e => {
|
|
30
44
|
const rawSearch = e.currentTarget.value;
|
|
31
45
|
setSearchBarSearchString(rawSearch);
|
|
@@ -36,7 +50,7 @@ const ConfluenceSearchContainer = ({
|
|
|
36
50
|
const handleBasicFilterSelectionChange = useCallback((filterType, options) => {
|
|
37
51
|
const updatedSelection = {
|
|
38
52
|
...filterSelections,
|
|
39
|
-
[filterType]: options
|
|
53
|
+
[filterType]: Array.isArray(options) ? options : [options]
|
|
40
54
|
};
|
|
41
55
|
setFilterSelections(updatedSelection);
|
|
42
56
|
debouncedBasicFilterSelectionChange(updatedSelection);
|
|
@@ -46,11 +60,13 @@ const ConfluenceSearchContainer = ({
|
|
|
46
60
|
// https://stash.atlassian.com/projects/ATLASSIAN/repos/atlassian-frontend-monorepo/pull-requests/82725/overview?commentId=6827913
|
|
47
61
|
useEffect(() => {
|
|
48
62
|
if (currentCloudId.current !== cloudId) {
|
|
63
|
+
setInitialContributorAccountIds([]);
|
|
64
|
+
resetHydrationHook();
|
|
49
65
|
setSearchBarSearchString('');
|
|
50
66
|
setFilterSelections({});
|
|
51
67
|
currentCloudId.current = cloudId;
|
|
52
68
|
}
|
|
53
|
-
}, [cloudId]);
|
|
69
|
+
}, [cloudId, resetHydrationHook]);
|
|
54
70
|
const showBasicFilters = useMemo(() => {
|
|
55
71
|
if (getBooleanFF('platform.linking-platform.datasource.show-clol-basic-filters')) {
|
|
56
72
|
return true;
|
|
@@ -58,19 +74,19 @@ const ConfluenceSearchContainer = ({
|
|
|
58
74
|
return false;
|
|
59
75
|
}, []);
|
|
60
76
|
useEffect(() => {
|
|
61
|
-
const
|
|
62
|
-
const hasAccountIds = accountIds && accountIds.length > 0;
|
|
77
|
+
const hasAccountIds = (initialContributorAccountIds === null || initialContributorAccountIds === void 0 ? void 0 : initialContributorAccountIds.length) > 0;
|
|
63
78
|
if (hasAccountIds && status === 'empty' && showBasicFilters) {
|
|
64
|
-
hydrateUsersFromAccountIds(
|
|
79
|
+
hydrateUsersFromAccountIds(initialContributorAccountIds);
|
|
65
80
|
}
|
|
66
|
-
}, [hydrateUsersFromAccountIds,
|
|
81
|
+
}, [hydrateUsersFromAccountIds, initialContributorAccountIds, showBasicFilters, status]);
|
|
67
82
|
useEffect(() => {
|
|
68
83
|
if (status === 'resolved') {
|
|
69
84
|
setFilterSelections({
|
|
85
|
+
lastModified: filterSelections.lastModified,
|
|
70
86
|
editedOrCreatedBy: users
|
|
71
87
|
});
|
|
72
88
|
}
|
|
73
|
-
}, [users, status]);
|
|
89
|
+
}, [users, status, filterSelections.lastModified]);
|
|
74
90
|
return /*#__PURE__*/React.createElement(Flex, {
|
|
75
91
|
alignItems: "center",
|
|
76
92
|
xcss: basicSearchInputContainerStyles
|
|
@@ -89,29 +89,15 @@ export const PlainConfluenceSearchConfigModal = props => {
|
|
|
89
89
|
const searchCount = useRef(0);
|
|
90
90
|
const userInteractionActions = useRef(new Set());
|
|
91
91
|
const visibleColumnCount = useRef((visibleColumnKeys === null || visibleColumnKeys === void 0 ? void 0 : visibleColumnKeys.length) || 0);
|
|
92
|
-
|
|
93
|
-
// TODO: further refactoring in EDM-9573
|
|
94
|
-
// https://stash.atlassian.com/projects/ATLASSIAN/repos/atlassian-frontend-monorepo/pull-requests/82725/overview?commentId=6829210
|
|
95
92
|
const parameters = useMemo(() => ({
|
|
96
93
|
...initialParameters,
|
|
97
|
-
cloudId,
|
|
94
|
+
cloudId: cloudId || '',
|
|
98
95
|
searchString,
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
lastModifiedFrom: lastModified === null || lastModified === void 0 ? void 0 : lastModified.from
|
|
104
|
-
}),
|
|
105
|
-
...(((initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.lastModifiedTo) || (lastModified === null || lastModified === void 0 ? void 0 : lastModified.to)) && {
|
|
106
|
-
lastModifiedTo: lastModified === null || lastModified === void 0 ? void 0 : lastModified.to
|
|
107
|
-
}),
|
|
108
|
-
...(((initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.contributorAccountIds) || (contributorAccountIds === null || contributorAccountIds === void 0 ? void 0 : contributorAccountIds.length) > 0) && {
|
|
109
|
-
contributorAccountIds
|
|
110
|
-
})
|
|
96
|
+
lastModified: lastModified === null || lastModified === void 0 ? void 0 : lastModified.value,
|
|
97
|
+
lastModifiedFrom: lastModified === null || lastModified === void 0 ? void 0 : lastModified.from,
|
|
98
|
+
lastModifiedTo: lastModified === null || lastModified === void 0 ? void 0 : lastModified.to,
|
|
99
|
+
contributorAccountIds: (contributorAccountIds === null || contributorAccountIds === void 0 ? void 0 : contributorAccountIds.length) > 0 ? contributorAccountIds : undefined
|
|
111
100
|
}), [initialParameters, cloudId, searchString, lastModified, contributorAccountIds]);
|
|
112
|
-
const initialFilterSelection = useMemo(() => ({
|
|
113
|
-
editedOrCreatedBy: (initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.contributorAccountIds) || []
|
|
114
|
-
}), [initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.contributorAccountIds]);
|
|
115
101
|
const isParametersSet = useMemo(() => !!cloudId && Object.values(parameters !== null && parameters !== void 0 ? parameters : {}).filter(v => v !== undefined).length > 1, [cloudId, parameters]);
|
|
116
102
|
const parametersToSend = useMemo(() => {
|
|
117
103
|
if (!isParametersSet) {
|
|
@@ -409,10 +395,10 @@ export const PlainConfluenceSearchConfigModal = props => {
|
|
|
409
395
|
if (filters) {
|
|
410
396
|
const {
|
|
411
397
|
editedOrCreatedBy,
|
|
412
|
-
lastModified
|
|
398
|
+
lastModified: lastModifiedList
|
|
413
399
|
} = filters;
|
|
414
|
-
if (
|
|
415
|
-
const updatedDateRangeOption =
|
|
400
|
+
if (lastModifiedList) {
|
|
401
|
+
const updatedDateRangeOption = lastModifiedList.find(range => range.value);
|
|
416
402
|
if ((updatedDateRangeOption === null || updatedDateRangeOption === void 0 ? void 0 : updatedDateRangeOption.optionType) === 'dateRange') {
|
|
417
403
|
setLastModified({
|
|
418
404
|
value: updatedDateRangeOption.value,
|
|
@@ -460,11 +446,9 @@ export const PlainConfluenceSearchConfigModal = props => {
|
|
|
460
446
|
})), jsx(ModalBody, null, !hasNoConfluenceSites ? jsx(Fragment, null, jsx(Box, {
|
|
461
447
|
xcss: inputContainerStyles
|
|
462
448
|
}, jsx(ConfluenceSearchContainer, {
|
|
463
|
-
cloudId: cloudId,
|
|
464
449
|
isSearching: status === 'loading',
|
|
465
450
|
onSearch: onSearch,
|
|
466
|
-
|
|
467
|
-
initialFilterSelection: initialFilterSelection
|
|
451
|
+
parameters: parameters
|
|
468
452
|
})), currentViewMode === 'inline' ? renderInlineLinkModalContent() : renderTableModalContent()) : jsx(NoInstancesView, {
|
|
469
453
|
title: confluenceSearchModalMessages.noAccessToConfluenceSitesTitle,
|
|
470
454
|
description: confluenceSearchModalMessages.noAccessToConfluenceSitesDescription,
|
|
@@ -24,8 +24,7 @@ const LinkRenderType = ({
|
|
|
24
24
|
return (style === null || style === void 0 ? void 0 : style.appearance) && linkStyles[style.appearance] || {};
|
|
25
25
|
}, [style]);
|
|
26
26
|
const anchor = useMemo(() => /*#__PURE__*/React.createElement(HoverCard, {
|
|
27
|
-
url: url
|
|
28
|
-
showServerActions: true
|
|
27
|
+
url: url
|
|
29
28
|
}, /*#__PURE__*/React.createElement(LinkUrl, {
|
|
30
29
|
href: url,
|
|
31
30
|
style: {
|