@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.
Files changed (36) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/cjs/ui/confluence-search-modal/basic-filters/filters/date-range-picker/index.js +57 -62
  3. package/dist/cjs/ui/confluence-search-modal/basic-filters/filters/date-range-picker/styled.js +5 -5
  4. package/dist/cjs/ui/confluence-search-modal/basic-filters/filters/date-range-picker/utils.js +29 -25
  5. package/dist/cjs/ui/confluence-search-modal/basic-filters/hooks/useBasicFilterHydration.js +6 -1
  6. package/dist/cjs/ui/confluence-search-modal/basic-filters/index.js +9 -2
  7. package/dist/cjs/ui/confluence-search-modal/confluence-search-container/index.js +38 -18
  8. package/dist/cjs/ui/confluence-search-modal/modal/index.js +11 -25
  9. package/dist/cjs/ui/issue-like-table/render-type/link/index.js +1 -2
  10. package/dist/es2019/ui/confluence-search-modal/basic-filters/filters/date-range-picker/index.js +51 -60
  11. package/dist/es2019/ui/confluence-search-modal/basic-filters/filters/date-range-picker/styled.js +5 -5
  12. package/dist/es2019/ui/confluence-search-modal/basic-filters/filters/date-range-picker/utils.js +25 -23
  13. package/dist/es2019/ui/confluence-search-modal/basic-filters/hooks/useBasicFilterHydration.js +6 -1
  14. package/dist/es2019/ui/confluence-search-modal/basic-filters/index.js +7 -2
  15. package/dist/es2019/ui/confluence-search-modal/confluence-search-container/index.js +29 -13
  16. package/dist/es2019/ui/confluence-search-modal/modal/index.js +9 -25
  17. package/dist/es2019/ui/issue-like-table/render-type/link/index.js +1 -2
  18. package/dist/esm/ui/confluence-search-modal/basic-filters/filters/date-range-picker/index.js +59 -64
  19. package/dist/esm/ui/confluence-search-modal/basic-filters/filters/date-range-picker/styled.js +5 -5
  20. package/dist/esm/ui/confluence-search-modal/basic-filters/filters/date-range-picker/utils.js +25 -23
  21. package/dist/esm/ui/confluence-search-modal/basic-filters/hooks/useBasicFilterHydration.js +6 -1
  22. package/dist/esm/ui/confluence-search-modal/basic-filters/index.js +9 -2
  23. package/dist/esm/ui/confluence-search-modal/confluence-search-container/index.js +38 -18
  24. package/dist/esm/ui/confluence-search-modal/modal/index.js +11 -25
  25. package/dist/esm/ui/issue-like-table/render-type/link/index.js +1 -2
  26. package/dist/types/ui/confluence-search-modal/basic-filters/filters/date-range-picker/index.d.ts +3 -3
  27. package/dist/types/ui/confluence-search-modal/basic-filters/filters/date-range-picker/utils.d.ts +3 -3
  28. package/dist/types/ui/confluence-search-modal/basic-filters/hooks/useBasicFilterHydration.d.ts +2 -1
  29. package/dist/types/ui/confluence-search-modal/basic-filters/index.d.ts +2 -2
  30. package/dist/types/ui/confluence-search-modal/confluence-search-container/index.d.ts +4 -8
  31. package/dist/types-ts4.5/ui/confluence-search-modal/basic-filters/filters/date-range-picker/index.d.ts +3 -3
  32. package/dist/types-ts4.5/ui/confluence-search-modal/basic-filters/filters/date-range-picker/utils.d.ts +3 -3
  33. package/dist/types-ts4.5/ui/confluence-search-modal/basic-filters/hooks/useBasicFilterHydration.d.ts +2 -1
  34. package/dist/types-ts4.5/ui/confluence-search-modal/basic-filters/index.d.ts +2 -2
  35. package/dist/types-ts4.5/ui/confluence-search-modal/confluence-search-container/index.d.ts +4 -8
  36. package/package.json +11 -11
@@ -2,108 +2,95 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
- import React, { useCallback, useEffect, useRef, useState } from 'react';
5
+ import React, { useCallback, useState } from 'react';
6
6
  import { FormattedMessage, useIntl } from 'react-intl-next';
7
7
  import { DatePicker } from '@atlaskit/datetime-picker';
8
8
  import ErrorIcon from '@atlaskit/icon/glyph/error';
9
9
  import Popup from '@atlaskit/popup';
10
10
  import { R400 } from '@atlaskit/theme/colors';
11
11
  import { layers } from '@atlaskit/theme/constants';
12
- import { CLOLBasicFilters } from '../../types';
13
12
  import { dateRangeMessages } from './messages';
14
13
  import { PopupComponent } from './PopupComponent';
15
14
  import { CustomDateWrapper, CustomDropdown, CustomDropdownItem, DatePickersWrapper, DateRangeErrorMessage, SelectDateRangeButton } from './styled';
16
15
  import { PopupTrigger } from './trigger';
17
- import { getCurrentOptionLabel, getDropdownLabel, getInvalidDateRange } from './utils';
18
- var lastModifiedValues = ['anyTime', 'today', 'yesterday', 'past7Days', 'past30Days', 'pastYear', 'custom'];
16
+ import { getCurrentOptionLabel, getDropdownLabel, useInvalidDateRange } from './utils';
17
+ var dateRangeValues = ['anyTime', 'today', 'yesterday', 'past7Days', 'past30Days', 'pastYear', 'custom'];
19
18
  var defaultOptionValue = 'anyTime';
20
19
  export var DateRangePicker = function DateRangePicker(_ref) {
21
20
  var onSelectionChange = _ref.onSelectionChange,
22
21
  selection = _ref.selection;
23
- var _useState = useState(selection === null || selection === void 0 ? void 0 : selection.value),
22
+ var _ref2 = selection || {},
23
+ selectedValue = _ref2.value,
24
+ fromDate = _ref2.from,
25
+ toDate = _ref2.to;
26
+ var todayDate = new Date().toISOString();
27
+ var _useIntl = useIntl(),
28
+ locale = _useIntl.locale,
29
+ formatMessage = _useIntl.formatMessage,
30
+ formatDate = _useIntl.formatDate;
31
+ var _useState = useState(selectedValue),
24
32
  _useState2 = _slicedToArray(_useState, 2),
25
33
  currentOption = _useState2[0],
26
34
  setCurrentOption = _useState2[1];
27
- var _useState3 = useState(getInvalidDateRange(selection === null || selection === void 0 ? void 0 : selection.from, selection === null || selection === void 0 ? void 0 : selection.to)),
35
+ var _useState3 = useState(fromDate),
28
36
  _useState4 = _slicedToArray(_useState3, 2),
29
- invalidDateRange = _useState4[0],
30
- setInvalidDateRange = _useState4[1];
31
- var customFromDate = useRef(selection === null || selection === void 0 ? void 0 : selection.from);
32
- var customToDate = useRef(selection === null || selection === void 0 ? void 0 : selection.to);
33
- var _useState5 = useState(false),
37
+ customFromDate = _useState4[0],
38
+ setCustomFromDate = _useState4[1];
39
+ var _useState5 = useState(toDate),
34
40
  _useState6 = _slicedToArray(_useState5, 2),
35
- isPickerOpen = _useState6[0],
36
- setIsPickerOpen = _useState6[1];
37
- var _useIntl = useIntl(),
38
- locale = _useIntl.locale,
39
- formatMessage = _useIntl.formatMessage,
40
- formatDate = _useIntl.formatDate;
41
- var isCustomSelected = currentOption === 'custom' || (selection === null || selection === void 0 ? void 0 : selection.value) === 'custom';
42
- var maxDate = new Date().toISOString();
43
- useEffect(function () {
44
- if (isPickerOpen) {
45
- customFromDate.current = selection === null || selection === void 0 ? void 0 : selection.from;
46
- customToDate.current = selection === null || selection === void 0 ? void 0 : selection.to;
47
- }
48
- }, [isPickerOpen, selection === null || selection === void 0 ? void 0 : selection.from, selection === null || selection === void 0 ? void 0 : selection.to]);
49
- var handleFromOnChange = function handleFromOnChange(date) {
50
- customFromDate.current = date;
51
- setInvalidDateRange(getInvalidDateRange(customFromDate.current, customToDate.current));
52
- };
53
- var handleToOnChange = function handleToOnChange(date) {
54
- customToDate.current = date;
55
- setInvalidDateRange(getInvalidDateRange(customFromDate.current, customToDate.current));
56
- };
41
+ customToDate = _useState6[0],
42
+ setCustomToDate = _useState6[1];
43
+ var _useState7 = useState(false),
44
+ _useState8 = _slicedToArray(_useState7, 2),
45
+ isPickerOpen = _useState8[0],
46
+ setIsPickerOpen = _useState8[1];
47
+ var isCustomSelected = currentOption === 'custom';
48
+ var invalidDateRange = useInvalidDateRange(customFromDate, customToDate);
57
49
  var handleClickUpdateDateRange = function handleClickUpdateDateRange() {
58
- var label = 'custom';
59
- if (customFromDate.current && !customToDate.current) {
60
- label = customFromDate.current;
61
- } else if (customToDate.current && !customFromDate.current) {
62
- label = customToDate.current;
63
- }
64
- onSelectionChange(CLOLBasicFilters.lastModified, {
65
- optionType: 'dateRange',
66
- label: label,
50
+ onSelectionChange({
67
51
  value: 'custom',
68
- from: customFromDate.current,
69
- to: customToDate.current
52
+ from: customFromDate,
53
+ to: customToDate
70
54
  });
71
55
  setIsPickerOpen(false);
72
56
  };
73
57
  var handleClickFilterOption = useCallback(function (option) {
74
58
  setCurrentOption(option);
75
- onSelectionChange(CLOLBasicFilters.lastModified, {
76
- optionType: 'dateRange',
77
- label: option,
59
+ onSelectionChange({
78
60
  value: option
79
61
  });
80
62
  if (option !== 'custom') {
81
63
  setIsPickerOpen(false);
82
64
  }
83
65
  }, [onSelectionChange]);
84
- var handleTogglePopup = useCallback(function () {
85
- // If users click out of popup, we let selection prop define the current option when opened again until user sets state
86
- setCurrentOption(undefined);
87
- setIsPickerOpen(!isPickerOpen);
88
- }, [isPickerOpen]);
66
+ var handlePickerToggle = function handlePickerToggle() {
67
+ if (isPickerOpen) {
68
+ setCustomToDate(toDate);
69
+ setCustomFromDate(fromDate);
70
+ setIsPickerOpen(false);
71
+ return;
72
+ }
73
+ setIsPickerOpen(true);
74
+ return;
75
+ };
89
76
  return /*#__PURE__*/React.createElement(Popup, {
90
77
  isOpen: isPickerOpen,
91
- onClose: handleTogglePopup,
78
+ onClose: handlePickerToggle,
92
79
  popupComponent: PopupComponent,
93
80
  zIndex: layers.modal(),
94
81
  content: function content() {
95
- return /*#__PURE__*/React.createElement(CustomDropdown, null, lastModifiedValues.map(function (option) {
82
+ return /*#__PURE__*/React.createElement(CustomDropdown, null, dateRangeValues.map(function (option) {
96
83
  return /*#__PURE__*/React.createElement(CustomDropdownItem, {
97
84
  key: option
98
85
  // want to show Anytime as selected if none of the other options are selected
99
86
  ,
100
- isSelected: selection !== null && selection !== void 0 && selection.value ? option === selection.value : option === defaultOptionValue,
87
+ isSelected: selectedValue ? option === selectedValue : option === defaultOptionValue,
101
88
  onClick: function onClick() {
102
89
  return handleClickFilterOption(option);
103
90
  }
104
91
  }, getDropdownLabel(option, formatMessage));
105
92
  }), isPickerOpen && isCustomSelected && /*#__PURE__*/React.createElement(CustomDateWrapper, null, /*#__PURE__*/React.createElement(DatePickersWrapper, null, /*#__PURE__*/React.createElement(DatePicker, {
106
- maxDate: maxDate,
93
+ maxDate: todayDate,
107
94
  innerProps: {
108
95
  style: {
109
96
  width: 140
@@ -111,8 +98,11 @@ export var DateRangePicker = function DateRangePicker(_ref) {
111
98
  },
112
99
  testId: "date-from-picker",
113
100
  dateFormat: "D MMM YYYY",
114
- onChange: handleFromOnChange,
115
- defaultValue: selection === null || selection === void 0 ? void 0 : selection.from,
101
+ onChange: setCustomFromDate,
102
+ onDelete: function onDelete() {
103
+ return setCustomFromDate(undefined);
104
+ },
105
+ defaultValue: fromDate,
116
106
  placeholder: formatMessage(dateRangeMessages.dateRangeFrom),
117
107
  isInvalid: Boolean(invalidDateRange),
118
108
  locale: locale,
@@ -126,7 +116,7 @@ export var DateRangePicker = function DateRangePicker(_ref) {
126
116
  }
127
117
  }
128
118
  }), /*#__PURE__*/React.createElement(FormattedMessage, dateRangeMessages.dateRangeToLabel), /*#__PURE__*/React.createElement(DatePicker, {
129
- maxDate: maxDate,
119
+ maxDate: todayDate,
130
120
  innerProps: {
131
121
  style: {
132
122
  width: 140
@@ -134,8 +124,11 @@ export var DateRangePicker = function DateRangePicker(_ref) {
134
124
  },
135
125
  testId: "date-to-picker",
136
126
  dateFormat: "D MMM YYYY",
137
- onChange: handleToOnChange,
138
- defaultValue: selection === null || selection === void 0 ? void 0 : selection.to,
127
+ onChange: setCustomToDate,
128
+ onDelete: function onDelete() {
129
+ return setCustomToDate(undefined);
130
+ },
131
+ defaultValue: toDate,
139
132
  placeholder: formatMessage(dateRangeMessages.dateRangeTo),
140
133
  isInvalid: Boolean(invalidDateRange),
141
134
  locale: locale,
@@ -160,12 +153,14 @@ export var DateRangePicker = function DateRangePicker(_ref) {
160
153
  },
161
154
  placement: "bottom-start",
162
155
  trigger: function trigger(triggerProps) {
156
+ var labelText = getCurrentOptionLabel(formatDate, formatMessage, selectedValue, toDate, fromDate);
157
+ var isSelected = !!selectedValue || isPickerOpen;
163
158
  return /*#__PURE__*/React.createElement(PopupTrigger, {
164
159
  triggerProps: triggerProps,
165
- isSelected: !!(selection !== null && selection !== void 0 && selection.value) || isPickerOpen,
160
+ isSelected: isSelected,
166
161
  labelPrefix: formatMessage(dateRangeMessages.dateRangeTitle),
167
- selectedLabel: getCurrentOptionLabel(formatDate, formatMessage, selection),
168
- onClick: handleTogglePopup
162
+ selectedLabel: labelText,
163
+ onClick: handlePickerToggle
169
164
  });
170
165
  }
171
166
  });
@@ -6,7 +6,7 @@ export var PopupComponentContainer = styled.div({
6
6
  display: 'block',
7
7
  flex: '1 1 auto',
8
8
  overflow: 'visible',
9
- borderRadius: "var(--ds-border-radius-200, 3px)",
9
+ borderRadius: "var(--ds-border-radius-100, 4px)",
10
10
  background: "var(--ds-background-input, ".concat(N0, ")"),
11
11
  ':focus': {
12
12
  outline: 'none'
@@ -16,7 +16,7 @@ export var PopupComponentContainer = styled.div({
16
16
  export var CustomDropdown = styled.div({
17
17
  width: '340px',
18
18
  background: "var(--ds-background-input, ".concat(N0, ")"),
19
- borderRadius: "var(--ds-border-radius-200, 3px)",
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
  });
@@ -55,7 +55,7 @@ export var SelectDateRangeButton = styled.button({
55
55
  width: '70px',
56
56
  height: '40px',
57
57
  marginTop: "var(--ds-space-150, 12px)",
58
- borderRadius: "var(--ds-border-radius-200, 3px)",
58
+ borderRadius: "var(--ds-border-radius-100, 4px)",
59
59
  '&:hover': {
60
60
  background: "var(--ds-background-accent-gray-subtler, ".concat(N30, ")"),
61
61
  cursor: 'pointer'
@@ -64,7 +64,7 @@ export var SelectDateRangeButton = styled.button({
64
64
  export var DateRangeErrorMessage = styled.div({
65
65
  display: 'flex',
66
66
  lineHeight: 1.3333,
67
- marginTop: "var(--ds-space-050, 4px)",
68
- fontSize: '12px',
67
+ marginTop: "var(--ds-space-050, 2px)",
68
+ fontSize: "var(--ds-font-size-075, 12px)",
69
69
  color: "var(--ds-text-danger, ".concat(R400, ")")
70
70
  });
@@ -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';
@@ -16,13 +16,13 @@ export var getDropdownLabel = function getDropdownLabel() {
16
16
  };
17
17
  return formatMessage(dateRangeMessages[mapping[option]]);
18
18
  };
19
- export var getCurrentOptionLabel = function getCurrentOptionLabel(formatDate, formatMessage, selection) {
20
- var selectedOption = selection === null || selection === void 0 ? void 0 : selection.value;
19
+ export var getCurrentOptionLabel = function getCurrentOptionLabel(formatDate, formatMessage, value, to, from) {
20
+ var selectedOption = value;
21
21
  if (selectedOption === 'custom') {
22
- var hasFromDate = !!(selection !== null && selection !== void 0 && selection.from);
23
- var hasToDate = !!(selection !== null && selection !== void 0 && selection.to);
24
- var formattedFromDate = getFormattedDate((selection === null || selection === void 0 ? void 0 : selection.from) || '', 'date', formatDate);
25
- var formattedToDate = getFormattedDate((selection === null || selection === void 0 ? void 0 : selection.to) || '', 'date', formatDate);
22
+ var hasFromDate = !!from;
23
+ var hasToDate = !!to;
24
+ var formattedFromDate = getFormattedDate(from || '', 'date', formatDate);
25
+ var formattedToDate = getFormattedDate(to || '', 'date', formatDate);
26
26
  if (hasFromDate && !hasToDate) {
27
27
  return formatMessage(dateRangeMessages.dateRangeAfterLabel, {
28
28
  date: formattedFromDate
@@ -39,21 +39,23 @@ export var getCurrentOptionLabel = function getCurrentOptionLabel(formatDate, fo
39
39
  }
40
40
  return getDropdownLabel(selectedOption, formatMessage);
41
41
  };
42
- export var getInvalidDateRange = function getInvalidDateRange(from, to) {
43
- if (!from && !to) {
42
+ export var useInvalidDateRange = function useInvalidDateRange(from, to) {
43
+ return useMemo(function () {
44
+ if (!from && !to) {
45
+ return null;
46
+ }
47
+ var dateFrom = new Date("".concat(from).concat(from ? 'T00:00:00' : ''));
48
+ var dateTo = new Date("".concat(to).concat(to ? 'T00:00:00' : ''));
49
+ var now = new Date();
50
+ if (dateFrom > now) {
51
+ return /*#__PURE__*/React.createElement(FormattedMessage, dateRangeMessages.dateRangeCustomInvalidDateAfterToday);
52
+ }
53
+ if (dateFrom > dateTo) {
54
+ return /*#__PURE__*/React.createElement(FormattedMessage, dateRangeMessages.dateRangeCustomInvalidDateAfterEnd);
55
+ }
56
+ if (dateTo > now) {
57
+ return /*#__PURE__*/React.createElement(FormattedMessage, dateRangeMessages.dateRangeCustomInvalidToDateAfterToday);
58
+ }
44
59
  return null;
45
- }
46
- var dateFrom = new Date("".concat(from).concat(from ? 'T00:00:00' : ''));
47
- var dateTo = new Date("".concat(to).concat(to ? 'T00:00:00' : ''));
48
- var now = new Date();
49
- if (dateFrom > now) {
50
- return /*#__PURE__*/React.createElement(FormattedMessage, dateRangeMessages.dateRangeCustomInvalidDateAfterToday);
51
- }
52
- if (dateFrom > dateTo) {
53
- return /*#__PURE__*/React.createElement(FormattedMessage, dateRangeMessages.dateRangeCustomInvalidDateAfterEnd);
54
- }
55
- if (dateTo > now) {
56
- return /*#__PURE__*/React.createElement(FormattedMessage, dateRangeMessages.dateRangeCustomInvalidToDateAfterToday);
57
- }
58
- return null;
60
+ }, [from, to]);
59
61
  };
@@ -64,9 +64,14 @@ export var useBasicFilterHydration = function useBasicFilterHydration() {
64
64
  return _ref.apply(this, arguments);
65
65
  };
66
66
  }(), [getUsersFromAccountIDs]);
67
+ var reset = useCallback(function () {
68
+ setStatus('empty');
69
+ setUsers([]);
70
+ }, []);
67
71
  return {
68
72
  hydrateUsersFromAccountIds: hydrateUsersFromAccountIds,
69
73
  status: status,
70
- users: users
74
+ users: users,
75
+ reset: reset
71
76
  };
72
77
  };
@@ -1,8 +1,12 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
1
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2
5
  import React from 'react';
3
6
  import { Flex, xcss } from '@atlaskit/primitives';
4
7
  import { DateRangePicker } from './filters/date-range-picker';
5
8
  import EditedOrCreatedByFilter from './filters/edited-or-created-by';
9
+ import { CLOLBasicFilters } from './types';
6
10
  var basicFilterContainerStyles = xcss({
7
11
  paddingLeft: 'space.100'
8
12
  });
@@ -18,8 +22,11 @@ var BasicFilterContainer = function BasicFilterContainer(_ref) {
18
22
  _ref3 = _slicedToArray(_ref2, 1),
19
23
  lastModifiedValue = _ref3[0];
20
24
  var lastModifiedSelection = (lastModifiedValue === null || lastModifiedValue === void 0 ? void 0 : lastModifiedValue.optionType) === 'dateRange' ? lastModifiedValue : undefined;
21
- var onDateRangePickerChange = function onDateRangePickerChange(filterType, updatedOption) {
22
- onChange(filterType, [updatedOption]);
25
+ var onDateRangePickerChange = function onDateRangePickerChange(updatedOption) {
26
+ onChange(CLOLBasicFilters.lastModified, _objectSpread({
27
+ optionType: 'dateRange',
28
+ label: updatedOption.value
29
+ }, updatedOption));
23
30
  };
24
31
  return /*#__PURE__*/React.createElement(Flex, {
25
32
  xcss: basicFilterContainerStyles,
@@ -10,30 +10,48 @@ import { BasicSearchInput } from '../../common/modal/basic-search-input';
10
10
  import { FILTER_SELECTION_DEBOUNCE_MS } from '../../common/modal/popup-select/constants';
11
11
  import BasicFilters from '../basic-filters';
12
12
  import { useBasicFilterHydration } from '../basic-filters/hooks/useBasicFilterHydration';
13
- import { CLOLBasicFilters } from '../basic-filters/types';
14
13
  import { searchMessages } from './messages';
15
14
  var basicSearchInputContainerStyles = xcss({
16
15
  flexGrow: 1
17
16
  });
18
17
  var ConfluenceSearchContainer = function ConfluenceSearchContainer(_ref) {
19
- var cloudId = _ref.cloudId,
20
- initialSearchValue = _ref.initialSearchValue,
21
- initialFilterSelection = _ref.initialFilterSelection,
18
+ var _ref$parameters = _ref.parameters,
19
+ cloudId = _ref$parameters.cloudId,
20
+ initialSearchValue = _ref$parameters.searchString,
21
+ lastModified = _ref$parameters.lastModified,
22
+ lastModifiedFrom = _ref$parameters.lastModifiedFrom,
23
+ lastModifiedTo = _ref$parameters.lastModifiedTo,
24
+ contributorAccountIds = _ref$parameters.contributorAccountIds,
22
25
  isSearching = _ref.isSearching,
23
26
  onSearch = _ref.onSearch;
24
27
  var _useBasicFilterHydrat = useBasicFilterHydration(),
25
28
  hydrateUsersFromAccountIds = _useBasicFilterHydrat.hydrateUsersFromAccountIds,
26
29
  users = _useBasicFilterHydrat.users,
27
- status = _useBasicFilterHydrat.status;
30
+ status = _useBasicFilterHydrat.status,
31
+ resetHydrationHook = _useBasicFilterHydrat.reset;
28
32
  var currentCloudId = useRef(cloudId);
29
- var _useState = useState(initialSearchValue !== null && initialSearchValue !== void 0 ? initialSearchValue : ''),
33
+ var _useState = useState(contributorAccountIds !== null && contributorAccountIds !== void 0 ? contributorAccountIds : []),
30
34
  _useState2 = _slicedToArray(_useState, 2),
31
- searchBarSearchString = _useState2[0],
32
- setSearchBarSearchString = _useState2[1];
33
- var _useState3 = useState({}),
35
+ initialContributorAccountIds = _useState2[0],
36
+ setInitialContributorAccountIds = _useState2[1];
37
+ var _useState3 = useState(initialSearchValue !== null && initialSearchValue !== void 0 ? initialSearchValue : ''),
34
38
  _useState4 = _slicedToArray(_useState3, 2),
35
- filterSelections = _useState4[0],
36
- setFilterSelections = _useState4[1];
39
+ searchBarSearchString = _useState4[0],
40
+ setSearchBarSearchString = _useState4[1];
41
+ var _useState5 = useState(function () {
42
+ return lastModified ? {
43
+ lastModified: [{
44
+ optionType: 'dateRange',
45
+ label: lastModified,
46
+ value: lastModified,
47
+ from: lastModifiedFrom,
48
+ to: lastModifiedTo
49
+ }]
50
+ } : {};
51
+ }),
52
+ _useState6 = _slicedToArray(_useState5, 2),
53
+ filterSelections = _useState6[0],
54
+ setFilterSelections = _useState6[1];
37
55
  var handleSearchChange = useCallback(function (e) {
38
56
  var rawSearch = e.currentTarget.value;
39
57
  setSearchBarSearchString(rawSearch);
@@ -44,7 +62,7 @@ var ConfluenceSearchContainer = function ConfluenceSearchContainer(_ref) {
44
62
  _useDebouncedCallback2 = _slicedToArray(_useDebouncedCallback, 1),
45
63
  debouncedBasicFilterSelectionChange = _useDebouncedCallback2[0];
46
64
  var handleBasicFilterSelectionChange = useCallback(function (filterType, options) {
47
- var updatedSelection = _objectSpread(_objectSpread({}, filterSelections), {}, _defineProperty({}, filterType, options));
65
+ var updatedSelection = _objectSpread(_objectSpread({}, filterSelections), {}, _defineProperty({}, filterType, Array.isArray(options) ? options : [options]));
48
66
  setFilterSelections(updatedSelection);
49
67
  debouncedBasicFilterSelectionChange(updatedSelection);
50
68
  }, [debouncedBasicFilterSelectionChange, filterSelections]);
@@ -53,11 +71,13 @@ var ConfluenceSearchContainer = function ConfluenceSearchContainer(_ref) {
53
71
  // https://stash.atlassian.com/projects/ATLASSIAN/repos/atlassian-frontend-monorepo/pull-requests/82725/overview?commentId=6827913
54
72
  useEffect(function () {
55
73
  if (currentCloudId.current !== cloudId) {
74
+ setInitialContributorAccountIds([]);
75
+ resetHydrationHook();
56
76
  setSearchBarSearchString('');
57
77
  setFilterSelections({});
58
78
  currentCloudId.current = cloudId;
59
79
  }
60
- }, [cloudId]);
80
+ }, [cloudId, resetHydrationHook]);
61
81
  var showBasicFilters = useMemo(function () {
62
82
  if (getBooleanFF('platform.linking-platform.datasource.show-clol-basic-filters')) {
63
83
  return true;
@@ -65,19 +85,19 @@ var ConfluenceSearchContainer = function ConfluenceSearchContainer(_ref) {
65
85
  return false;
66
86
  }, []);
67
87
  useEffect(function () {
68
- var accountIds = initialFilterSelection === null || initialFilterSelection === void 0 ? void 0 : initialFilterSelection[CLOLBasicFilters.editedOrCreatedBy];
69
- var hasAccountIds = accountIds && accountIds.length > 0;
88
+ var hasAccountIds = (initialContributorAccountIds === null || initialContributorAccountIds === void 0 ? void 0 : initialContributorAccountIds.length) > 0;
70
89
  if (hasAccountIds && status === 'empty' && showBasicFilters) {
71
- hydrateUsersFromAccountIds(accountIds);
90
+ hydrateUsersFromAccountIds(initialContributorAccountIds);
72
91
  }
73
- }, [hydrateUsersFromAccountIds, initialFilterSelection, showBasicFilters, status]);
92
+ }, [hydrateUsersFromAccountIds, initialContributorAccountIds, showBasicFilters, status]);
74
93
  useEffect(function () {
75
94
  if (status === 'resolved') {
76
95
  setFilterSelections({
96
+ lastModified: filterSelections.lastModified,
77
97
  editedOrCreatedBy: users
78
98
  });
79
99
  }
80
- }, [users, status]);
100
+ }, [users, status, filterSelections.lastModified]);
81
101
  return /*#__PURE__*/React.createElement(Flex, {
82
102
  alignItems: "center",
83
103
  xcss: basicSearchInputContainerStyles
@@ -116,28 +116,16 @@ export var PlainConfluenceSearchConfigModal = function PlainConfluenceSearchConf
116
116
  var searchCount = useRef(0);
117
117
  var userInteractionActions = useRef(new Set());
118
118
  var visibleColumnCount = useRef((visibleColumnKeys === null || visibleColumnKeys === void 0 ? void 0 : visibleColumnKeys.length) || 0);
119
-
120
- // TODO: further refactoring in EDM-9573
121
- // https://stash.atlassian.com/projects/ATLASSIAN/repos/atlassian-frontend-monorepo/pull-requests/82725/overview?commentId=6829210
122
119
  var parameters = useMemo(function () {
123
- return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, initialParameters), {}, {
124
- cloudId: cloudId,
125
- searchString: searchString
126
- }, ((initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.lastModified) || (lastModified === null || lastModified === void 0 ? void 0 : lastModified.value)) && {
127
- lastModified: lastModified === null || lastModified === void 0 ? void 0 : lastModified.value
128
- }), ((initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.lastModifiedFrom) || (lastModified === null || lastModified === void 0 ? void 0 : lastModified.from)) && {
129
- lastModifiedFrom: lastModified === null || lastModified === void 0 ? void 0 : lastModified.from
130
- }), ((initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.lastModifiedTo) || (lastModified === null || lastModified === void 0 ? void 0 : lastModified.to)) && {
131
- lastModifiedTo: lastModified === null || lastModified === void 0 ? void 0 : lastModified.to
132
- }), ((initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.contributorAccountIds) || (contributorAccountIds === null || contributorAccountIds === void 0 ? void 0 : contributorAccountIds.length) > 0) && {
133
- contributorAccountIds: contributorAccountIds
120
+ return _objectSpread(_objectSpread({}, initialParameters), {}, {
121
+ cloudId: cloudId || '',
122
+ searchString: searchString,
123
+ lastModified: lastModified === null || lastModified === void 0 ? void 0 : lastModified.value,
124
+ lastModifiedFrom: lastModified === null || lastModified === void 0 ? void 0 : lastModified.from,
125
+ lastModifiedTo: lastModified === null || lastModified === void 0 ? void 0 : lastModified.to,
126
+ contributorAccountIds: (contributorAccountIds === null || contributorAccountIds === void 0 ? void 0 : contributorAccountIds.length) > 0 ? contributorAccountIds : undefined
134
127
  });
135
128
  }, [initialParameters, cloudId, searchString, lastModified, contributorAccountIds]);
136
- var initialFilterSelection = useMemo(function () {
137
- return {
138
- editedOrCreatedBy: (initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.contributorAccountIds) || []
139
- };
140
- }, [initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.contributorAccountIds]);
141
129
  var isParametersSet = useMemo(function () {
142
130
  return !!cloudId && Object.values(parameters !== null && parameters !== void 0 ? parameters : {}).filter(function (v) {
143
131
  return v !== undefined;
@@ -459,9 +447,9 @@ export var PlainConfluenceSearchConfigModal = function PlainConfluenceSearchConf
459
447
  userInteractionActions.current.add(DatasourceAction.QUERY_UPDATED);
460
448
  if (filters) {
461
449
  var editedOrCreatedBy = filters.editedOrCreatedBy,
462
- _lastModified = filters.lastModified;
463
- if (_lastModified) {
464
- var updatedDateRangeOption = _lastModified.find(function (range) {
450
+ lastModifiedList = filters.lastModified;
451
+ if (lastModifiedList) {
452
+ var updatedDateRangeOption = lastModifiedList.find(function (range) {
465
453
  return range.value;
466
454
  });
467
455
  if ((updatedDateRangeOption === null || updatedDateRangeOption === void 0 ? void 0 : updatedDateRangeOption.optionType) === 'dateRange') {
@@ -513,11 +501,9 @@ export var PlainConfluenceSearchConfigModal = function PlainConfluenceSearchConf
513
501
  })), jsx(ModalBody, null, !hasNoConfluenceSites ? jsx(Fragment, null, jsx(Box, {
514
502
  xcss: inputContainerStyles
515
503
  }, jsx(ConfluenceSearchContainer, {
516
- cloudId: cloudId,
517
504
  isSearching: status === 'loading',
518
505
  onSearch: onSearch,
519
- initialSearchValue: initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.searchString,
520
- initialFilterSelection: initialFilterSelection
506
+ parameters: parameters
521
507
  })), currentViewMode === 'inline' ? renderInlineLinkModalContent() : renderTableModalContent()) : jsx(NoInstancesView, {
522
508
  title: confluenceSearchModalMessages.noAccessToConfluenceSitesTitle,
523
509
  description: confluenceSearchModalMessages.noAccessToConfluenceSitesDescription,
@@ -27,8 +27,7 @@ var LinkRenderType = function LinkRenderType(_ref) {
27
27
  }, [style]);
28
28
  var anchor = useMemo(function () {
29
29
  return /*#__PURE__*/React.createElement(HoverCard, {
30
- url: url,
31
- showServerActions: true
30
+ url: url
32
31
  }, /*#__PURE__*/React.createElement(LinkUrl, {
33
32
  href: url,
34
33
  style: _objectSpread(_objectSpread({}, linkStyle), {}, {
@@ -1,9 +1,9 @@
1
1
  /// <reference types="react" />
2
2
  import { type DateRangeOption } from '../../../../common/modal/popup-select/types';
3
- import { CLOLBasicFilters } from '../../types';
3
+ export type DateRangeSelection = Pick<DateRangeOption, 'value' | 'from' | 'to'>;
4
4
  interface DateRangeProps {
5
- onSelectionChange: (filterType: CLOLBasicFilters, options: DateRangeOption) => void;
6
- selection?: DateRangeOption;
5
+ onSelectionChange: (options: DateRangeSelection) => void;
6
+ selection?: DateRangeSelection;
7
7
  }
8
8
  export declare const DateRangePicker: ({ onSelectionChange, selection, }: DateRangeProps) => JSX.Element;
9
9
  export {};
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { type IntlShape } from 'react-intl-next';
3
- import { type DateRangeOption, type DateRangeType } from '../../../../common/modal/popup-select/types';
3
+ import { type DateRangeType } from '../../../../common/modal/popup-select/types';
4
4
  export declare const getDropdownLabel: (option: DateRangeType | undefined, formatMessage: IntlShape['formatMessage']) => string;
5
- export declare const getCurrentOptionLabel: (formatDate: IntlShape['formatDate'], formatMessage: IntlShape['formatMessage'], selection?: DateRangeOption) => string;
6
- export declare const getInvalidDateRange: (from: string | undefined, to: string | undefined) => JSX.Element | null;
5
+ export declare const getCurrentOptionLabel: (formatDate: IntlShape['formatDate'], formatMessage: IntlShape['formatMessage'], value?: DateRangeType, to?: string, from?: string) => string;
6
+ export declare const useInvalidDateRange: (from?: string, to?: string) => JSX.Element | null;
@@ -1,6 +1,7 @@
1
- import { CommonBasicFilterHookState, SelectOption } from '../../../common/modal/popup-select/types';
1
+ import { type CommonBasicFilterHookState, type SelectOption } from '../../../common/modal/popup-select/types';
2
2
  export interface BasicFilterHydrationState extends Omit<CommonBasicFilterHookState, 'errors'> {
3
3
  hydrateUsersFromAccountIds: (accountIds: string[]) => void;
4
4
  users: SelectOption[];
5
+ reset: () => void;
5
6
  }
6
7
  export declare const useBasicFilterHydration: () => BasicFilterHydrationState;
@@ -1,10 +1,10 @@
1
1
  /// <reference types="react" />
2
2
  import { type SelectOption } from '../../common/modal/popup-select/types';
3
- import { type CLOLBasicFilters, type SelectedOptionsMap } from './types';
3
+ import { CLOLBasicFilters, type SelectedOptionsMap } from './types';
4
4
  export interface BasicFilterContainerProps {
5
5
  cloudId?: string;
6
6
  selections: SelectedOptionsMap;
7
- onChange: (filterType: CLOLBasicFilters, options: SelectOption[]) => void;
7
+ onChange: (filterType: CLOLBasicFilters, options: SelectOption | SelectOption[]) => void;
8
8
  isHydrating?: boolean;
9
9
  }
10
10
  declare const BasicFilterContainer: ({ cloudId, onChange, selections, isHydrating, }: BasicFilterContainerProps) => JSX.Element;
@@ -1,14 +1,10 @@
1
1
  /// <reference types="react" />
2
- import { CLOLBasicFilters, type SelectedOptionsMap } from '../basic-filters/types';
3
- export type FilterInitialSelectionMap = {
4
- [CLOLBasicFilters.editedOrCreatedBy]?: string[];
5
- };
2
+ import { type SelectedOptionsMap } from '../basic-filters/types';
3
+ import { type ConfluenceSearchDatasourceParameters } from '../types';
6
4
  interface Props {
7
- cloudId?: string;
8
- initialSearchValue?: string;
9
- initialFilterSelection?: FilterInitialSelectionMap;
5
+ parameters: ConfluenceSearchDatasourceParameters;
10
6
  isSearching: boolean;
11
7
  onSearch: (searchTerm: string, filters?: SelectedOptionsMap) => void;
12
8
  }
13
- declare const ConfluenceSearchContainer: ({ cloudId, initialSearchValue, initialFilterSelection, isSearching, onSearch, }: Props) => JSX.Element;
9
+ declare const ConfluenceSearchContainer: ({ parameters: { cloudId, searchString: initialSearchValue, lastModified, lastModifiedFrom, lastModifiedTo, contributorAccountIds, }, isSearching, onSearch, }: Props) => JSX.Element;
14
10
  export default ConfluenceSearchContainer;
@@ -1,9 +1,9 @@
1
1
  /// <reference types="react" />
2
2
  import { type DateRangeOption } from '../../../../common/modal/popup-select/types';
3
- import { CLOLBasicFilters } from '../../types';
3
+ export type DateRangeSelection = Pick<DateRangeOption, 'value' | 'from' | 'to'>;
4
4
  interface DateRangeProps {
5
- onSelectionChange: (filterType: CLOLBasicFilters, options: DateRangeOption) => void;
6
- selection?: DateRangeOption;
5
+ onSelectionChange: (options: DateRangeSelection) => void;
6
+ selection?: DateRangeSelection;
7
7
  }
8
8
  export declare const DateRangePicker: ({ onSelectionChange, selection, }: DateRangeProps) => JSX.Element;
9
9
  export {};
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { type IntlShape } from 'react-intl-next';
3
- import { type DateRangeOption, type DateRangeType } from '../../../../common/modal/popup-select/types';
3
+ import { type DateRangeType } from '../../../../common/modal/popup-select/types';
4
4
  export declare const getDropdownLabel: (option: DateRangeType | undefined, formatMessage: IntlShape['formatMessage']) => string;
5
- export declare const getCurrentOptionLabel: (formatDate: IntlShape['formatDate'], formatMessage: IntlShape['formatMessage'], selection?: DateRangeOption) => string;
6
- export declare const getInvalidDateRange: (from: string | undefined, to: string | undefined) => JSX.Element | null;
5
+ export declare const getCurrentOptionLabel: (formatDate: IntlShape['formatDate'], formatMessage: IntlShape['formatMessage'], value?: DateRangeType, to?: string, from?: string) => string;
6
+ export declare const useInvalidDateRange: (from?: string, to?: string) => JSX.Element | null;