@atlaskit/link-datasource 1.29.4 → 1.30.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/ui/confluence-search-modal/basic-filters/filters/date-range-picker/index.js +126 -33
  3. package/dist/cjs/ui/confluence-search-modal/basic-filters/filters/date-range-picker/messages.js +50 -0
  4. package/dist/cjs/ui/confluence-search-modal/basic-filters/filters/date-range-picker/styled.js +6 -4
  5. package/dist/cjs/ui/confluence-search-modal/basic-filters/filters/date-range-picker/trigger.js +6 -6
  6. package/dist/cjs/ui/confluence-search-modal/basic-filters/filters/date-range-picker/utils.js +66 -0
  7. package/dist/cjs/ui/confluence-search-modal/basic-filters/index.js +12 -2
  8. package/dist/cjs/ui/confluence-search-modal/modal/index.js +36 -13
  9. package/dist/cjs/ui/table-footer/powered-by-jsm-assets/index.js +1 -1
  10. package/dist/es2019/ui/confluence-search-modal/basic-filters/filters/date-range-picker/index.js +116 -31
  11. package/dist/es2019/ui/confluence-search-modal/basic-filters/filters/date-range-picker/messages.js +50 -0
  12. package/dist/es2019/ui/confluence-search-modal/basic-filters/filters/date-range-picker/styled.js +6 -4
  13. package/dist/es2019/ui/confluence-search-modal/basic-filters/filters/date-range-picker/trigger.js +6 -6
  14. package/dist/es2019/ui/confluence-search-modal/basic-filters/filters/date-range-picker/utils.js +57 -0
  15. package/dist/es2019/ui/confluence-search-modal/basic-filters/index.js +8 -1
  16. package/dist/es2019/ui/confluence-search-modal/modal/index.js +32 -7
  17. package/dist/es2019/ui/table-footer/powered-by-jsm-assets/index.js +1 -1
  18. package/dist/esm/ui/confluence-search-modal/basic-filters/filters/date-range-picker/index.js +128 -35
  19. package/dist/esm/ui/confluence-search-modal/basic-filters/filters/date-range-picker/messages.js +50 -0
  20. package/dist/esm/ui/confluence-search-modal/basic-filters/filters/date-range-picker/styled.js +6 -4
  21. package/dist/esm/ui/confluence-search-modal/basic-filters/filters/date-range-picker/trigger.js +6 -6
  22. package/dist/esm/ui/confluence-search-modal/basic-filters/filters/date-range-picker/utils.js +59 -0
  23. package/dist/esm/ui/confluence-search-modal/basic-filters/index.js +12 -2
  24. package/dist/esm/ui/confluence-search-modal/modal/index.js +36 -13
  25. package/dist/esm/ui/table-footer/powered-by-jsm-assets/index.js +1 -1
  26. package/dist/types/ui/common/modal/popup-select/types.d.ts +3 -1
  27. package/dist/types/ui/confluence-search-modal/basic-filters/filters/date-range-picker/index.d.ts +4 -3
  28. package/dist/types/ui/confluence-search-modal/basic-filters/filters/date-range-picker/messages.d.ts +50 -0
  29. package/dist/types/ui/confluence-search-modal/basic-filters/filters/date-range-picker/trigger.d.ts +4 -4
  30. package/dist/types/ui/confluence-search-modal/basic-filters/filters/date-range-picker/utils.d.ts +6 -0
  31. package/dist/types/ui/confluence-search-modal/basic-filters/index.d.ts +2 -2
  32. package/dist/types/ui/confluence-search-modal/confluence-search-container/index.d.ts +1 -1
  33. package/dist/types/ui/confluence-search-modal/modal/index.d.ts +1 -1
  34. package/dist/types/ui/confluence-search-modal/types.d.ts +3 -3
  35. package/dist/types-ts4.5/ui/common/modal/popup-select/types.d.ts +3 -1
  36. package/dist/types-ts4.5/ui/confluence-search-modal/basic-filters/filters/date-range-picker/index.d.ts +4 -3
  37. package/dist/types-ts4.5/ui/confluence-search-modal/basic-filters/filters/date-range-picker/messages.d.ts +50 -0
  38. package/dist/types-ts4.5/ui/confluence-search-modal/basic-filters/filters/date-range-picker/trigger.d.ts +4 -4
  39. package/dist/types-ts4.5/ui/confluence-search-modal/basic-filters/filters/date-range-picker/utils.d.ts +6 -0
  40. package/dist/types-ts4.5/ui/confluence-search-modal/basic-filters/index.d.ts +2 -2
  41. package/dist/types-ts4.5/ui/confluence-search-modal/confluence-search-container/index.d.ts +1 -1
  42. package/dist/types-ts4.5/ui/confluence-search-modal/modal/index.d.ts +1 -1
  43. package/dist/types-ts4.5/ui/confluence-search-modal/types.d.ts +3 -3
  44. package/package.json +10 -9
@@ -1,33 +1,78 @@
1
- import React, { useCallback, useState } from 'react';
1
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
2
2
  import { FormattedMessage, useIntl } from 'react-intl-next';
3
+ import { DatePicker } from '@atlaskit/datetime-picker';
4
+ import ErrorIcon from '@atlaskit/icon/glyph/error';
3
5
  import Popup from '@atlaskit/popup';
6
+ import { R400 } from '@atlaskit/theme/colors';
4
7
  import { layers } from '@atlaskit/theme/constants';
5
8
  import { CLOLBasicFilters } from '../../types';
6
9
  import { dateRangeMessages } from './messages';
7
10
  import { PopupComponent } from './PopupComponent';
8
- import { CustomDropdown, CustomDropdownItem } from './styled';
11
+ import { CustomDateWrapper, CustomDropdown, CustomDropdownItem, DatePickersWrapper, DateRangeErrorMessage, SelectDateRangeButton } from './styled';
9
12
  import { PopupTrigger } from './trigger';
13
+ import { getCurrentOptionLabel, getDropdownLabel, getInvalidDateRange } from './utils';
10
14
  const lastModifiedValues = ['anyTime', 'today', 'yesterday', 'past7Days', 'past30Days', 'pastYear', 'custom'];
11
15
  const defaultOptionValue = 'anyTime';
12
- const filterName = CLOLBasicFilters.lastModified;
13
16
  export const DateRangePicker = ({
14
- onSelectionChange
17
+ onSelectionChange,
18
+ selection
15
19
  }) => {
16
- const [currentOption, setCurrentOption] = useState(null);
20
+ const [currentOption, setCurrentOption] = useState(selection === null || selection === void 0 ? void 0 : selection.value);
21
+ const [invalidDateRange, setInvalidDateRange] = useState(getInvalidDateRange(selection === null || selection === void 0 ? void 0 : selection.from, selection === null || selection === void 0 ? void 0 : selection.to));
22
+ const customFromDate = useRef(selection === null || selection === void 0 ? void 0 : selection.from);
23
+ const customToDate = useRef(selection === null || selection === void 0 ? void 0 : selection.to);
17
24
  const [isPickerOpen, setIsPickerOpen] = useState(false);
18
25
  const {
19
- formatMessage
26
+ locale,
27
+ formatMessage,
28
+ formatDate
20
29
  } = useIntl();
21
- const onClickFilterOption = useCallback(option => {
22
- setCurrentOption(option);
30
+ const isCustomSelected = currentOption === 'custom' || (selection === null || selection === void 0 ? void 0 : selection.value) === 'custom';
31
+ const maxDate = new Date().toISOString();
32
+ useEffect(() => {
33
+ if (isPickerOpen) {
34
+ customFromDate.current = selection === null || selection === void 0 ? void 0 : selection.from;
35
+ customToDate.current = selection === null || selection === void 0 ? void 0 : selection.to;
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
+ };
46
+ const handleClickUpdateDateRange = () => {
47
+ let label = 'custom';
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,
56
+ value: 'custom',
57
+ from: customFromDate.current,
58
+ to: customToDate.current
59
+ });
23
60
  setIsPickerOpen(false);
24
- onSelectionChange(filterName, [{
25
- optionType: 'defaultOption',
61
+ };
62
+ const handleClickFilterOption = useCallback(option => {
63
+ setCurrentOption(option);
64
+ onSelectionChange(CLOLBasicFilters.lastModified, {
65
+ optionType: 'dateRange',
26
66
  label: option,
27
67
  value: option
28
- }]);
68
+ });
69
+ if (option !== 'custom') {
70
+ setIsPickerOpen(false);
71
+ }
29
72
  }, [onSelectionChange]);
30
73
  const handleTogglePopup = useCallback(() => {
74
+ // If users click out of popup, we let selection prop define the current option when opened again until user sets state
75
+ setCurrentOption(undefined);
31
76
  setIsPickerOpen(!isPickerOpen);
32
77
  }, [isPickerOpen]);
33
78
  return /*#__PURE__*/React.createElement(Popup, {
@@ -38,31 +83,71 @@ export const DateRangePicker = ({
38
83
  content: () => {
39
84
  return /*#__PURE__*/React.createElement(CustomDropdown, null, lastModifiedValues.map(option => /*#__PURE__*/React.createElement(CustomDropdownItem, {
40
85
  key: option
41
- //want to show Anytime as selected if none of the other options are selected
86
+ // want to show Anytime as selected if none of the other options are selected
42
87
  ,
43
- isSelected: currentOption ? option === currentOption : option === defaultOptionValue,
44
- onClick: () => onClickFilterOption(option)
45
- }, /*#__PURE__*/React.createElement(FormattedMessage, getCurrentOptionLabel(option)))));
88
+ isSelected: selection !== null && selection !== void 0 && selection.value ? option === selection.value : option === defaultOptionValue,
89
+ onClick: () => handleClickFilterOption(option)
90
+ }, getDropdownLabel(option, formatMessage))), isPickerOpen && isCustomSelected && /*#__PURE__*/React.createElement(CustomDateWrapper, null, /*#__PURE__*/React.createElement(DatePickersWrapper, null, /*#__PURE__*/React.createElement(DatePicker, {
91
+ maxDate: maxDate,
92
+ innerProps: {
93
+ style: {
94
+ width: 140
95
+ }
96
+ },
97
+ testId: "date-from-picker",
98
+ dateFormat: "D MMM YYYY",
99
+ onChange: handleFromOnChange,
100
+ defaultValue: selection === null || selection === void 0 ? void 0 : selection.from,
101
+ placeholder: formatMessage(dateRangeMessages.dateRangeFrom),
102
+ isInvalid: Boolean(invalidDateRange),
103
+ locale: locale,
104
+ selectProps: {
105
+ styles: {
106
+ placeholder: base => ({
107
+ ...base,
108
+ width: 'max-content'
109
+ })
110
+ }
111
+ }
112
+ }), /*#__PURE__*/React.createElement(FormattedMessage, dateRangeMessages.dateRangeToLabel), /*#__PURE__*/React.createElement(DatePicker, {
113
+ maxDate: maxDate,
114
+ innerProps: {
115
+ style: {
116
+ width: 140
117
+ }
118
+ },
119
+ testId: "date-to-picker",
120
+ dateFormat: "D MMM YYYY",
121
+ onChange: handleToOnChange,
122
+ defaultValue: selection === null || selection === void 0 ? void 0 : selection.to,
123
+ placeholder: formatMessage(dateRangeMessages.dateRangeTo),
124
+ isInvalid: Boolean(invalidDateRange),
125
+ locale: locale,
126
+ selectProps: {
127
+ styles: {
128
+ placeholder: base => ({
129
+ ...base,
130
+ width: 'max-content'
131
+ })
132
+ }
133
+ }
134
+ })), invalidDateRange && /*#__PURE__*/React.createElement(DateRangeErrorMessage, null, /*#__PURE__*/React.createElement(ErrorIcon, {
135
+ size: "small",
136
+ primaryColor: `var(--ds-icon-danger, ${R400})`,
137
+ label: "Date range error"
138
+ }), invalidDateRange), /*#__PURE__*/React.createElement(SelectDateRangeButton, {
139
+ "data-testId": "custom-date-range-update-button",
140
+ disabled: Boolean(invalidDateRange),
141
+ onClick: handleClickUpdateDateRange
142
+ }, formatMessage(dateRangeMessages.dateRangeUpdateButton))));
46
143
  },
47
144
  placement: "bottom-start",
48
145
  trigger: triggerProps => /*#__PURE__*/React.createElement(PopupTrigger, {
49
146
  triggerProps: triggerProps,
50
- optionSelected: !!currentOption,
51
- label: formatMessage(dateRangeMessages.dateRangeTitle),
52
- selectedLabel: formatMessage(getCurrentOptionLabel(currentOption)),
53
- onClickButton: handleTogglePopup
147
+ isSelected: !!(selection !== null && selection !== void 0 && selection.value) || isPickerOpen,
148
+ labelPrefix: formatMessage(dateRangeMessages.dateRangeTitle),
149
+ selectedLabel: getCurrentOptionLabel(formatDate, formatMessage, selection),
150
+ onClick: handleTogglePopup
54
151
  })
55
152
  });
56
- };
57
- const getCurrentOptionLabel = option => {
58
- const mapping = {
59
- anyTime: 'dateRangeAnyTime',
60
- today: 'dateRangeToday',
61
- yesterday: 'dateRangeYesterday',
62
- past7Days: 'dateRangeLastWeek',
63
- past30Days: 'dateRangeLastMonth',
64
- pastYear: 'dateRangeLastYear',
65
- custom: 'dateRangeCustom'
66
- };
67
- return option ? dateRangeMessages[mapping[option]] : dateRangeMessages[mapping['anyTime']];
68
153
  };
@@ -39,5 +39,55 @@ export const dateRangeMessages = defineMessages({
39
39
  id: 'linkDataSource.confluence-search.configmodal.date.range.custom',
40
40
  defaultMessage: 'Custom',
41
41
  description: 'Custom date range'
42
+ },
43
+ dateRangeFrom: {
44
+ id: 'linkDataSource.confluence-search.configmodal.date.range.from',
45
+ defaultMessage: 'From',
46
+ description: 'Filter starting from a custom date'
47
+ },
48
+ dateRangeTo: {
49
+ id: 'linkDataSource.confluence-search.configmodal.date.range.to',
50
+ defaultMessage: 'To',
51
+ description: 'Filter up to a custom date'
52
+ },
53
+ dateRangeDateInputPlaceholder: {
54
+ id: 'linkDataSource.confluence-search.configmodal.date.range.input.placeholder',
55
+ defaultMessage: 'Choose a date',
56
+ description: 'Placeholder text for date input'
57
+ },
58
+ dateRangeCustomInvalidDateAfterToday: {
59
+ id: 'linkDataSource.confluence-search.configmodal.date.range.custom.invalid.after.today',
60
+ defaultMessage: 'The From date can’t be in the future',
61
+ description: 'error displayed when a date range begins after the current date'
62
+ },
63
+ dateRangeCustomInvalidToDateAfterToday: {
64
+ id: 'linkDataSource.confluence-search.configmodal.date.range.custom.invalid.to.after.today',
65
+ defaultMessage: 'The To date can’t be in the future',
66
+ description: 'error displayed when a date range ends after the current date'
67
+ },
68
+ dateRangeCustomInvalidDateAfterEnd: {
69
+ id: 'linkDataSource.confluence-search.configmodal.date.range.custom.invalid.after.end',
70
+ defaultMessage: 'The From date has to be before the To date',
71
+ description: 'error displayed when a date range begins after the end date'
72
+ },
73
+ dateRangeToLabel: {
74
+ id: 'linkDataSource.confluence-search.configmodal.date.range.to.Label',
75
+ defaultMessage: 'to',
76
+ description: "'to' in between from and to date pickers"
77
+ },
78
+ dateRangeUpdateButton: {
79
+ id: 'linkDataSource.confluence-search.configmodal.date.range.update.button',
80
+ defaultMessage: 'Update',
81
+ description: 'Text for update button in date filter picker'
82
+ },
83
+ dateRangeBeforeLabel: {
84
+ id: 'linkDataSource.confluence-search.configmodal.date.range.before.label',
85
+ defaultMessage: 'before {date}',
86
+ description: '`before date` for date picker dropdown'
87
+ },
88
+ dateRangeAfterLabel: {
89
+ id: 'linkDataSource.confluence-search.configmodal.date.range.after.label',
90
+ defaultMessage: 'after {date}',
91
+ description: '`after date` for date picker dropdown'
42
92
  }
43
93
  });
@@ -1,10 +1,12 @@
1
1
  import styled from '@emotion/styled';
2
2
  import { B400, B50, N0, N20, N30, R400 } from '@atlaskit/theme/colors';
3
+ import { layers } from '@atlaskit/theme/constants';
3
4
  export const PopupComponentContainer = styled.div({
4
5
  boxSizing: 'border-box',
5
6
  display: 'block',
6
7
  flex: '1 1 auto',
7
8
  overflow: 'visible',
9
+ borderRadius: "var(--ds-border-radius-200, 3px)",
8
10
  background: `var(--ds-background-input, ${N0})`,
9
11
  ':focus': {
10
12
  outline: 'none'
@@ -12,11 +14,11 @@ export const PopupComponentContainer = styled.div({
12
14
  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
15
  });
14
16
  export const CustomDropdown = styled.div({
15
- width: '360px',
17
+ width: '340px',
16
18
  background: `var(--ds-background-input, ${N0})`,
17
- borderRadius: '3px',
19
+ borderRadius: "var(--ds-border-radius-200, 3px)",
18
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))",
19
- zIndex: '900'
21
+ zIndex: layers.modal()
20
22
  });
21
23
  export const CustomDropdownItem = styled.div(props => ({
22
24
  height: '36px',
@@ -51,7 +53,7 @@ export const SelectDateRangeButton = styled.button({
51
53
  width: '70px',
52
54
  height: '40px',
53
55
  marginTop: "var(--ds-space-150, 12px)",
54
- borderRadius: '3px',
56
+ borderRadius: "var(--ds-border-radius-200, 3px)",
55
57
  '&:hover': {
56
58
  background: `var(--ds-background-accent-gray-subtler, ${N30})`,
57
59
  cursor: 'pointer'
@@ -4,15 +4,15 @@ import Button from '@atlaskit/button/standard-button';
4
4
  import ChevronDownIcon from '@atlaskit/icon/glyph/chevron-down';
5
5
  export const PopupTrigger = ({
6
6
  triggerProps,
7
- optionSelected,
8
- label,
7
+ isSelected,
8
+ labelPrefix,
9
9
  selectedLabel,
10
- onClickButton
10
+ onClick
11
11
  }) => {
12
12
  return /*#__PURE__*/React.createElement(Button, _extends({}, triggerProps, {
13
13
  testId: 'confluence-search-modal--date-range-button',
14
- onClick: onClickButton,
15
- isSelected: optionSelected,
14
+ onClick: onClick,
15
+ isSelected: isSelected,
16
16
  iconAfter: /*#__PURE__*/React.createElement("span", {
17
17
  style: {
18
18
  display: 'flex',
@@ -22,5 +22,5 @@ export const PopupTrigger = ({
22
22
  size: "medium",
23
23
  label: ""
24
24
  }))
25
- }), label, selectedLabel ? `: ${selectedLabel}` : '');
25
+ }), labelPrefix, selectedLabel ? `: ${selectedLabel}` : '');
26
26
  };
@@ -0,0 +1,57 @@
1
+ import React from 'react';
2
+ import { FormattedMessage } from 'react-intl-next';
3
+ import { getFormattedDate } from '../../../../../ui/issue-like-table/render-type/date-time';
4
+ import { dateRangeMessages } from './messages';
5
+ export const getDropdownLabel = (option = 'anyTime', formatMessage) => {
6
+ const mapping = {
7
+ anyTime: 'dateRangeAnyTime',
8
+ today: 'dateRangeToday',
9
+ yesterday: 'dateRangeYesterday',
10
+ past7Days: 'dateRangeLastWeek',
11
+ past30Days: 'dateRangeLastMonth',
12
+ pastYear: 'dateRangeLastYear',
13
+ custom: 'dateRangeCustom'
14
+ };
15
+ return formatMessage(dateRangeMessages[mapping[option]]);
16
+ };
17
+ export const getCurrentOptionLabel = (formatDate, formatMessage, selection) => {
18
+ const selectedOption = selection === null || selection === void 0 ? void 0 : selection.value;
19
+ if (selectedOption === 'custom') {
20
+ const hasFromDate = !!(selection !== null && selection !== void 0 && selection.from);
21
+ const hasToDate = !!(selection !== null && selection !== void 0 && selection.to);
22
+ const formattedFromDate = getFormattedDate((selection === null || selection === void 0 ? void 0 : selection.from) || '', 'date', formatDate);
23
+ const formattedToDate = getFormattedDate((selection === null || selection === void 0 ? void 0 : selection.to) || '', 'date', formatDate);
24
+ if (hasFromDate && !hasToDate) {
25
+ return formatMessage(dateRangeMessages.dateRangeAfterLabel, {
26
+ date: formattedFromDate
27
+ });
28
+ }
29
+ if (!hasFromDate && hasToDate) {
30
+ return formatMessage(dateRangeMessages.dateRangeBeforeLabel, {
31
+ date: formattedToDate
32
+ });
33
+ }
34
+ if (hasFromDate && hasToDate) {
35
+ return `${formattedFromDate} - ${formattedToDate}`;
36
+ }
37
+ }
38
+ return getDropdownLabel(selectedOption, formatMessage);
39
+ };
40
+ export const getInvalidDateRange = (from, to) => {
41
+ if (!from && !to) {
42
+ 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;
57
+ };
@@ -12,8 +12,14 @@ const BasicFilterContainer = ({
12
12
  isHydrating
13
13
  }) => {
14
14
  const {
15
+ lastModified,
15
16
  editedOrCreatedBy
16
17
  } = selections;
18
+ const [lastModifiedValue] = lastModified || [];
19
+ const lastModifiedSelection = (lastModifiedValue === null || lastModifiedValue === void 0 ? void 0 : lastModifiedValue.optionType) === 'dateRange' ? lastModifiedValue : undefined;
20
+ const onDateRangePickerChange = (filterType, updatedOption) => {
21
+ onChange(filterType, [updatedOption]);
22
+ };
17
23
  return /*#__PURE__*/React.createElement(Flex, {
18
24
  xcss: basicFilterContainerStyles,
19
25
  gap: "space.100",
@@ -24,7 +30,8 @@ const BasicFilterContainer = ({
24
30
  selection: editedOrCreatedBy || [],
25
31
  isHydrating: isHydrating
26
32
  }), /*#__PURE__*/React.createElement(DateRangePicker, {
27
- onSelectionChange: onChange
33
+ selection: lastModifiedSelection,
34
+ onSelectionChange: onDateRangePickerChange
28
35
  }));
29
36
  };
30
37
  export default BasicFilterContainer;
@@ -78,8 +78,12 @@ export const PlainConfluenceSearchConfigModal = props => {
78
78
  const [cloudId, setCloudId] = useState(initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.cloudId);
79
79
  const [searchString, setSearchString] = useState(initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.searchString);
80
80
  const [visibleColumnKeys, setVisibleColumnKeys] = useState(initialVisibleColumnKeys);
81
- const [lastModified, setLastModified] = useState(initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.lastModified);
82
81
  const [contributorAccountIds, setContributorAccountIds] = useState((initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.contributorAccountIds) || []);
82
+ const [lastModified, setLastModified] = useState(initialParameters !== null && initialParameters !== void 0 && initialParameters.lastModified ? {
83
+ value: initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.lastModified,
84
+ from: initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.lastModifiedFrom,
85
+ to: initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.lastModifiedTo
86
+ } : undefined);
83
87
 
84
88
  // analytics related parameters
85
89
  const searchCount = useRef(0);
@@ -92,13 +96,19 @@ export const PlainConfluenceSearchConfigModal = props => {
92
96
  ...initialParameters,
93
97
  cloudId,
94
98
  searchString,
95
- ...(((initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.lastModified) || lastModified) && {
96
- lastModified
99
+ ...(((initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.lastModified) || (lastModified === null || lastModified === void 0 ? void 0 : lastModified.value)) && {
100
+ lastModified: lastModified === null || lastModified === void 0 ? void 0 : lastModified.value
101
+ }),
102
+ ...(((initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.lastModifiedFrom) || (lastModified === null || lastModified === void 0 ? void 0 : lastModified.from)) && {
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
97
107
  }),
98
108
  ...(((initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.contributorAccountIds) || (contributorAccountIds === null || contributorAccountIds === void 0 ? void 0 : contributorAccountIds.length) > 0) && {
99
109
  contributorAccountIds
100
110
  })
101
- }), [cloudId, lastModified, contributorAccountIds, initialParameters, searchString /** Add more parameters when more filters are added */]);
111
+ }), [initialParameters, cloudId, searchString, lastModified, contributorAccountIds]);
102
112
  const initialFilterSelection = useMemo(() => ({
103
113
  editedOrCreatedBy: (initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.contributorAccountIds) || []
104
114
  }), [initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.contributorAccountIds]);
@@ -246,8 +256,17 @@ export const PlainConfluenceSearchConfigModal = props => {
246
256
  if (contributorAccountIds.length > 0) {
247
257
  params.append('contributors', contributorAccountIds.join(','));
248
258
  }
259
+ if (lastModified !== null && lastModified !== void 0 && lastModified.value) {
260
+ params.append('lastModified', lastModified.value);
261
+ }
262
+ if (lastModified !== null && lastModified !== void 0 && lastModified.from) {
263
+ params.append('from', lastModified === null || lastModified === void 0 ? void 0 : lastModified.from);
264
+ }
265
+ if (lastModified !== null && lastModified !== void 0 && lastModified.to) {
266
+ params.append('to', lastModified === null || lastModified === void 0 ? void 0 : lastModified.to);
267
+ }
249
268
  return `${selectedConfluenceSiteUrl}/wiki/search?${params.toString()}`;
250
- }, [contributorAccountIds, searchString, selectedConfluenceSiteUrl]);
269
+ }, [contributorAccountIds, lastModified, searchString, selectedConfluenceSiteUrl]);
251
270
  const analyticsPayload = useMemo(() => ({
252
271
  extensionKey,
253
272
  destinationObjectTypes,
@@ -393,8 +412,14 @@ export const PlainConfluenceSearchConfigModal = props => {
393
412
  lastModified
394
413
  } = filters;
395
414
  if (lastModified) {
396
- const lastModifiedValue = lastModified.find(range => range.value);
397
- setLastModified(lastModifiedValue === null || lastModifiedValue === void 0 ? void 0 : lastModifiedValue.value);
415
+ const updatedDateRangeOption = lastModified.find(range => range.value);
416
+ if ((updatedDateRangeOption === null || updatedDateRangeOption === void 0 ? void 0 : updatedDateRangeOption.optionType) === 'dateRange') {
417
+ setLastModified({
418
+ value: updatedDateRangeOption.value,
419
+ from: updatedDateRangeOption.from,
420
+ to: updatedDateRangeOption.to
421
+ });
422
+ }
398
423
  }
399
424
  if (editedOrCreatedBy) {
400
425
  const accountIds = editedOrCreatedBy.map(user => user.value);
@@ -5,7 +5,7 @@ import { useDatasourceAnalyticsEvents } from '../../../analytics';
5
5
  const jsmTextStyles = xcss({
6
6
  fontSize: 'small',
7
7
  color: 'color.text.subtle',
8
- marginLeft: "var(--ds-space-075, 6px)",
8
+ marginLeft: 'space.075',
9
9
  ':hover': {
10
10
  color: 'color.link.pressed'
11
11
  }