@atlaskit/link-datasource 1.19.8 → 1.19.10

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 (45) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/analytics/constants.js +1 -1
  3. package/dist/cjs/ui/jira-issues-modal/basic-filters/hooks/messages.js +14 -0
  4. package/dist/cjs/ui/jira-issues-modal/basic-filters/hooks/useFilterOptions.js +34 -10
  5. package/dist/cjs/ui/jira-issues-modal/basic-filters/hooks/useHydrateJqlQuery.js +24 -9
  6. package/dist/cjs/ui/jira-issues-modal/basic-filters/ui/async-popup-select/index.js +1 -4
  7. package/dist/cjs/ui/jira-issues-modal/basic-filters/ui/async-popup-select/messages.js +3 -2
  8. package/dist/cjs/ui/jira-issues-modal/basic-filters/ui/index.js +1 -3
  9. package/dist/cjs/ui/jira-issues-modal/basic-filters/ui/menu-list/messages.js +3 -2
  10. package/dist/cjs/ui/jira-issues-modal/basic-filters/utils/extractValuesFromNonComplexJQL.js +11 -3
  11. package/dist/cjs/ui/jira-issues-modal/jira-search-container/index.js +27 -18
  12. package/dist/cjs/ui/jira-issues-modal/modal/index.js +4 -1
  13. package/dist/es2019/analytics/constants.js +1 -1
  14. package/dist/es2019/ui/jira-issues-modal/basic-filters/hooks/messages.js +8 -0
  15. package/dist/es2019/ui/jira-issues-modal/basic-filters/hooks/useFilterOptions.js +25 -4
  16. package/dist/es2019/ui/jira-issues-modal/basic-filters/hooks/useHydrateJqlQuery.js +21 -3
  17. package/dist/es2019/ui/jira-issues-modal/basic-filters/ui/async-popup-select/index.js +1 -3
  18. package/dist/es2019/ui/jira-issues-modal/basic-filters/ui/async-popup-select/messages.js +3 -2
  19. package/dist/es2019/ui/jira-issues-modal/basic-filters/ui/index.js +1 -3
  20. package/dist/es2019/ui/jira-issues-modal/basic-filters/ui/menu-list/messages.js +3 -2
  21. package/dist/es2019/ui/jira-issues-modal/basic-filters/utils/extractValuesFromNonComplexJQL.js +11 -1
  22. package/dist/es2019/ui/jira-issues-modal/jira-search-container/index.js +12 -6
  23. package/dist/es2019/ui/jira-issues-modal/modal/index.js +4 -1
  24. package/dist/esm/analytics/constants.js +1 -1
  25. package/dist/esm/ui/jira-issues-modal/basic-filters/hooks/messages.js +8 -0
  26. package/dist/esm/ui/jira-issues-modal/basic-filters/hooks/useFilterOptions.js +33 -9
  27. package/dist/esm/ui/jira-issues-modal/basic-filters/hooks/useHydrateJqlQuery.js +24 -9
  28. package/dist/esm/ui/jira-issues-modal/basic-filters/ui/async-popup-select/index.js +1 -4
  29. package/dist/esm/ui/jira-issues-modal/basic-filters/ui/async-popup-select/messages.js +3 -2
  30. package/dist/esm/ui/jira-issues-modal/basic-filters/ui/index.js +1 -3
  31. package/dist/esm/ui/jira-issues-modal/basic-filters/ui/menu-list/messages.js +3 -2
  32. package/dist/esm/ui/jira-issues-modal/basic-filters/utils/extractValuesFromNonComplexJQL.js +11 -3
  33. package/dist/esm/ui/jira-issues-modal/jira-search-container/index.js +26 -17
  34. package/dist/esm/ui/jira-issues-modal/modal/index.js +4 -1
  35. package/dist/types/ui/jira-issues-modal/basic-filters/hooks/messages.d.ts +7 -0
  36. package/dist/types/ui/jira-issues-modal/basic-filters/hooks/useFilterOptions.d.ts +3 -1
  37. package/dist/types/ui/jira-issues-modal/basic-filters/ui/async-popup-select/index.d.ts +1 -2
  38. package/dist/types/ui/jira-issues-modal/basic-filters/ui/index.d.ts +1 -2
  39. package/dist/types/ui/jira-issues-modal/jira-search-container/index.d.ts +1 -0
  40. package/dist/types-ts4.5/ui/jira-issues-modal/basic-filters/hooks/messages.d.ts +7 -0
  41. package/dist/types-ts4.5/ui/jira-issues-modal/basic-filters/hooks/useFilterOptions.d.ts +3 -1
  42. package/dist/types-ts4.5/ui/jira-issues-modal/basic-filters/ui/async-popup-select/index.d.ts +1 -2
  43. package/dist/types-ts4.5/ui/jira-issues-modal/basic-filters/ui/index.d.ts +1 -2
  44. package/dist/types-ts4.5/ui/jira-issues-modal/jira-search-container/index.d.ts +1 -0
  45. package/package.json +1 -1
@@ -1,4 +1,5 @@
1
- export const asyncPopupSelectMessages = {
1
+ import { defineMessages } from 'react-intl-next';
2
+ export const asyncPopupSelectMessages = defineMessages({
2
3
  loadingMessage: {
3
4
  id: 'linkDataSource.basic-filter.loading-message',
4
5
  defaultMessage: 'Loading...',
@@ -14,4 +15,4 @@ export const asyncPopupSelectMessages = {
14
15
  defaultMessage: 'Something went wrong',
15
16
  description: 'The text for when an error occurs when loading options'
16
17
  }
17
- };
18
+ });
@@ -6,9 +6,19 @@ import { isQueryTooComplex } from './isQueryTooComplex';
6
6
  // Map of field keys to their respective clauses in the Jast
7
7
 
8
8
  const getFieldValues = operand => {
9
+ const mapValuesFromList = value => {
10
+ if (value.operandType === OPERAND_TYPE_VALUE) {
11
+ return value.value;
12
+ }
13
+ // we only support EMPTY keyword atm, hence making sure if operandType is a KEYWORD, then its an EMPTY keyword
14
+ if (value.operandType === OPERAND_TYPE_KEYWORD && value.value === OPERAND_EMPTY) {
15
+ return value.value;
16
+ }
17
+ return undefined;
18
+ };
9
19
  switch (operand.operandType) {
10
20
  case OPERAND_TYPE_LIST:
11
- return operand.values.map(value => value.operandType === OPERAND_TYPE_VALUE && value.value || undefined).filter(value => !!value);
21
+ return operand.values.map(mapValuesFromList).filter(value => !!value);
12
22
  case OPERAND_TYPE_VALUE:
13
23
  return operand.value ? [operand.value] : [];
14
24
  case OPERAND_TYPE_KEYWORD:
@@ -23,7 +23,7 @@ const inputContainerStyles = css({
23
23
  const basicSearchInputContainerStyles = xcss({
24
24
  flexGrow: 1
25
25
  });
26
- const DEFAULT_JQL_QUERY = 'created >= -30d order by created DESC';
26
+ export const DEFAULT_JQL_QUERY = 'created >= -30d order by created DESC';
27
27
  export const ALLOWED_ORDER_BY_KEYS = ['key', 'summary', 'assignee', 'status', 'created'];
28
28
  const JiraSearchMethodSwitcher = ModeSwitcher;
29
29
  export const JiraSearchContainer = props => {
@@ -35,7 +35,7 @@ export const JiraSearchContainer = props => {
35
35
  initialSearchMethod
36
36
  } = props;
37
37
  const {
38
- cloudId,
38
+ cloudId: currentCloudId,
39
39
  jql: initialJql
40
40
  } = parameters || {};
41
41
  const {
@@ -47,6 +47,7 @@ export const JiraSearchContainer = props => {
47
47
  const [basicSearchTerm, setBasicSearchTerm] = useState('');
48
48
  const [currentSearchMethod, setCurrentSearchMethod] = useState(initialSearchMethod);
49
49
  const [jql, setJql] = useState(initialJql || DEFAULT_JQL_QUERY);
50
+ const [cloudId, setCloudId] = useState(currentCloudId);
50
51
  const [isComplexQuery, setIsComplexQuery] = useState(false);
51
52
  const [orderKey, setOrderKey] = useState();
52
53
  const [orderDirection, setOrderDirection] = useState();
@@ -161,11 +162,17 @@ export const JiraSearchContainer = props => {
161
162
  setFilterSelections(updatedSelection);
162
163
  handleBasicFilterSelectionChange(updatedSelection);
163
164
  }, [handleBasicFilterSelectionChange, filterSelections]);
164
- const handleBasicFiltersReset = useCallback(() => {
165
- if (Object.keys(filterSelections).length > 0) {
165
+ useEffect(() => {
166
+ if (currentCloudId !== cloudId) {
167
+ setBasicSearchTerm('');
168
+ setJql(DEFAULT_JQL_QUERY);
169
+ setIsComplexQuery(false);
170
+ setOrderKey(undefined);
171
+ setOrderDirection(undefined);
166
172
  setFilterSelections({});
173
+ setCloudId(currentCloudId);
167
174
  }
168
- }, [filterSelections]);
175
+ }, [currentCloudId, cloudId]);
169
176
  return jsx("div", {
170
177
  css: inputContainerStyles,
171
178
  "data-testid": "jira-search-container"
@@ -181,7 +188,6 @@ export const JiraSearchContainer = props => {
181
188
  cloudId: cloudId || '',
182
189
  onChange: handleSelectionChange,
183
190
  selections: filterSelections,
184
- onReset: handleBasicFiltersReset,
185
191
  isJQLHydrating: basicFilterHydrationStatus === 'loading'
186
192
  })), currentSearchMethod === 'jql' && jsx(JiraJQLEditor, {
187
193
  cloudId: cloudId || '',
@@ -7,6 +7,7 @@ import { v4 as uuidv4 } from 'uuid';
7
7
  import { withAnalyticsContext } from '@atlaskit/analytics-next';
8
8
  import Button from '@atlaskit/button/standard-button';
9
9
  import Modal, { ModalBody, ModalFooter, ModalHeader, ModalTitle, ModalTransition } from '@atlaskit/modal-dialog';
10
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
10
11
  import LinkUrl from '@atlaskit/smart-card/link-url';
11
12
  import { B400, N0, N40, N800 } from '@atlaskit/theme/colors';
12
13
  import { EVENT_CHANNEL, useDatasourceAnalyticsEvents } from '../../../analytics';
@@ -25,6 +26,7 @@ import { NoResults } from '../../common/error-state/no-results';
25
26
  import { EmptyState, IssueLikeDataTableView, scrollableContainerShadowsCssComponents } from '../../issue-like-table';
26
27
  import LinkRenderType from '../../issue-like-table/render-type/link';
27
28
  import { availableBasicFilterTypes } from '../basic-filters/ui';
29
+ import { isQueryTooComplex } from '../basic-filters/utils/isQueryTooComplex';
28
30
  import { InitialStateView } from '../initial-state-view';
29
31
  import { JiraSearchContainer } from '../jira-search-container';
30
32
  import { ModeSwitcher } from '../mode-switcher';
@@ -108,7 +110,7 @@ export const PlainJiraIssuesConfigModal = props => {
108
110
  // analytics related parameters
109
111
  const searchCount = useRef(0);
110
112
  const userInteractionActions = useRef(new Set());
111
- const initialSearchMethod = 'jql'; // TODO EDM-7688 This where we can add feature that decides if it's basic or jql based on JQL content (Regexp)
113
+ const initialSearchMethod = getBooleanFF('platform.linking-platform.datasource.show-jlol-basic-filters') && !isQueryTooComplex((initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.jql) || '') ? 'basic' : 'jql';
112
114
  const [currentSearchMethod, setCurrentSearchMethod] = useState(initialSearchMethod);
113
115
  const searchMethodSearchedWith = useRef(null);
114
116
  const visibleColumnCount = useRef((visibleColumnKeys === null || visibleColumnKeys === void 0 ? void 0 : visibleColumnKeys.length) || 0);
@@ -290,6 +292,7 @@ export const PlainJiraIssuesConfigModal = props => {
290
292
  }, [analyticsPayload, onCancel]);
291
293
  const onSiteSelection = useCallback(site => {
292
294
  userInteractionActions.current.add(DatasourceAction.INSTANCE_UPDATED);
295
+ setJql('');
293
296
  setCloudId(site.cloudId);
294
297
  reset({
295
298
  shouldForceRequest: true
@@ -1,5 +1,5 @@
1
1
  export var EVENT_CHANNEL = 'media';
2
2
  export var packageMetaData = {
3
3
  packageName: "@atlaskit/link-datasource",
4
- packageVersion: "1.19.8"
4
+ packageVersion: "1.19.10"
5
5
  };
@@ -0,0 +1,8 @@
1
+ import { defineMessages } from 'react-intl-next';
2
+ export var filterOptionMessages = defineMessages({
3
+ assigneeUnassignedFilterOption: {
4
+ id: 'linkDataSource.basic-filter.dropdown.select.assignee.unassigned',
5
+ description: 'Text to display for Unassigned assignee filter option.',
6
+ defaultMessage: 'Unassigned'
7
+ }
8
+ });
@@ -3,11 +3,22 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import _regeneratorRuntime from "@babel/runtime/regenerator";
5
5
  import { useCallback, useEffect, useRef, useState } from 'react';
6
+ import { useIntl } from 'react-intl-next';
6
7
  import { useBasicFilterAGG } from '../../../../services/useBasicFilterAGG';
7
8
  import { mapFieldValuesToFilterOptions, mapFieldValuesToPageCursor, mapFieldValuesToTotalCount } from '../utils/transformers';
9
+ import { filterOptionMessages } from './messages';
10
+ export var getAssigneeUnassignedFilterOption = function getAssigneeUnassignedFilterOption(formatMessage) {
11
+ return {
12
+ label: formatMessage(filterOptionMessages.assigneeUnassignedFilterOption),
13
+ optionType: 'avatarLabel',
14
+ value: 'empty'
15
+ };
16
+ };
8
17
  export var useFilterOptions = function useFilterOptions(_ref) {
9
18
  var filterType = _ref.filterType,
10
19
  cloudId = _ref.cloudId;
20
+ var _useIntl = useIntl(),
21
+ formatMessage = _useIntl.formatMessage;
11
22
  var _useState = useState([]),
12
23
  _useState2 = _slicedToArray(_useState, 2),
13
24
  filterOptions = _useState2[0],
@@ -39,6 +50,8 @@ export var useFilterOptions = function useFilterOptions(_ref) {
39
50
  isRequestLikeInitialSearch,
40
51
  initialResponseData,
41
52
  response,
53
+ mappedResponse,
54
+ mappedTotalCount,
42
55
  _args = arguments;
43
56
  return _regeneratorRuntime.wrap(function _callee$(_context) {
44
57
  while (1) switch (_context.prev = _context.next) {
@@ -77,34 +90,45 @@ export var useFilterOptions = function useFilterOptions(_ref) {
77
90
  setErrors(response.errors);
78
91
  return _context.abrupt("return");
79
92
  case 18:
93
+ mappedResponse = mapFieldValuesToFilterOptions(response);
94
+ mappedTotalCount = mapFieldValuesToTotalCount(response);
80
95
  if (isNewSearch) {
81
- setFilterOptions(mapFieldValuesToFilterOptions(response));
82
96
  if (isRequestLikeInitialSearch) {
83
97
  /**
84
98
  * The initial dataset is used in couple of paths, eg: when a user searches and clears the search text.
85
99
  * During these times, we dont want to fetch data again and again, hence a mini cache setup to store and provide the initial dataset
86
100
  */
87
101
  initialData.current = response;
102
+
103
+ /**
104
+ * For assignee filter option, we want `Unassigned` as an option.
105
+ * Since `Unassigned/EMPTY` is not returned by the API, we add it manually, but only for the initial list
106
+ */
107
+ if (filterType === 'assignee') {
108
+ mappedResponse.unshift(getAssigneeUnassignedFilterOption(formatMessage));
109
+ mappedTotalCount += 1;
110
+ }
88
111
  }
112
+ setFilterOptions(mappedResponse);
89
113
  } else {
90
- setFilterOptions([].concat(_toConsumableArray(filterOptions), _toConsumableArray(mapFieldValuesToFilterOptions(response))));
114
+ setFilterOptions([].concat(_toConsumableArray(filterOptions), _toConsumableArray(mappedResponse)));
91
115
  }
92
- setTotalCount(mapFieldValuesToTotalCount(response));
116
+ setTotalCount(mappedTotalCount);
93
117
  setNextPageCursor(mapFieldValuesToPageCursor(response));
94
118
  setStatus('resolved');
95
- _context.next = 28;
119
+ _context.next = 30;
96
120
  break;
97
- case 24:
98
- _context.prev = 24;
121
+ case 26:
122
+ _context.prev = 26;
99
123
  _context.t1 = _context["catch"](5);
100
124
  setStatus('rejected');
101
125
  setErrors([_context.t1]);
102
- case 28:
126
+ case 30:
103
127
  case "end":
104
128
  return _context.stop();
105
129
  }
106
- }, _callee, null, [[5, 24]]);
107
- })), [cloudId, filterOptions, filterType, getFieldValues]);
130
+ }, _callee, null, [[5, 26]]);
131
+ })), [cloudId, filterOptions, filterType, formatMessage, getFieldValues]);
108
132
  useEffect(function () {
109
133
  if (status !== 'rejected' && errors.length !== 0) {
110
134
  setErrors([]);
@@ -1,19 +1,27 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
1
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
2
4
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
5
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
6
+ var _excluded = ["assignee"];
4
7
  import _regeneratorRuntime from "@babel/runtime/regenerator";
5
8
  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; }
6
9
  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; }
7
10
  import { useCallback, useEffect, useState } from 'react';
11
+ import { useIntl } from 'react-intl-next';
12
+ import { OPERAND_EMPTY } from '@atlaskit/jql-ast';
8
13
  import { useBasicFilterAGG } from '../../../../services/useBasicFilterAGG';
9
14
  import { extractValuesFromNonComplexJQL } from '../utils/extractValuesFromNonComplexJQL';
10
15
  import { removeFuzzyCharacter } from '../utils/isClauseTooComplex';
11
16
  import { mapHydrateResponseData } from '../utils/transformers';
17
+ import { getAssigneeUnassignedFilterOption } from './useFilterOptions';
12
18
  export var useHydrateJqlQuery = function useHydrateJqlQuery(cloudId, jql) {
13
19
  var _useState = useState({}),
14
20
  _useState2 = _slicedToArray(_useState, 2),
15
21
  hydratedOptions = _useState2[0],
16
22
  setHydratedOptions = _useState2[1];
23
+ var _useIntl = useIntl(),
24
+ formatMessage = _useIntl.formatMessage;
17
25
  var _useState3 = useState('empty'),
18
26
  _useState4 = _slicedToArray(_useState3, 2),
19
27
  status = _useState4[0],
@@ -25,7 +33,7 @@ export var useHydrateJqlQuery = function useHydrateJqlQuery(cloudId, jql) {
25
33
  var _useBasicFilterAGG = useBasicFilterAGG(),
26
34
  getHydratedJQL = _useBasicFilterAGG.getHydratedJQL;
27
35
  var fetchHydratedJqlOptions = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
28
- var response, _extractValuesFromNon, text, summary, key, _ref2, _ref3, textFieldValue, mappedValues;
36
+ var response, _mapHydrateResponseDa, mappedHydratedAssigneeValue, restOfMappedHydratedResponse, _extractValuesFromNon, text, summary, key, extractedAssigneeValue, _ref2, _ref3, textFieldValue, mappedValues;
29
37
  return _regeneratorRuntime.wrap(function _callee$(_context) {
30
38
  while (1) switch (_context.prev = _context.next) {
31
39
  case 0:
@@ -43,29 +51,36 @@ export var useHydrateJqlQuery = function useHydrateJqlQuery(cloudId, jql) {
43
51
  setErrors(response.errors);
44
52
  return _context.abrupt("return");
45
53
  case 9:
54
+ _mapHydrateResponseDa = mapHydrateResponseData(response), mappedHydratedAssigneeValue = _mapHydrateResponseDa.assignee, restOfMappedHydratedResponse = _objectWithoutProperties(_mapHydrateResponseDa, _excluded);
46
55
  /**
47
56
  * Hydrate logic does not return text field, hence we parse and extract value from jql
48
57
  */
49
- _extractValuesFromNon = extractValuesFromNonComplexJQL(jql), text = _extractValuesFromNon.text, summary = _extractValuesFromNon.summary, key = _extractValuesFromNon.key;
58
+ _extractValuesFromNon = extractValuesFromNonComplexJQL(jql), text = _extractValuesFromNon.text, summary = _extractValuesFromNon.summary, key = _extractValuesFromNon.key, extractedAssigneeValue = _extractValuesFromNon.assignee;
50
59
  _ref2 = text || summary || key || [], _ref3 = _slicedToArray(_ref2, 1), textFieldValue = _ref3[0];
51
- mappedValues = _objectSpread(_objectSpread({}, mapHydrateResponseData(response)), textFieldValue ? {
60
+ mappedValues = _objectSpread(_objectSpread({}, restOfMappedHydratedResponse), {}, {
61
+ /**
62
+ * Special handling for assignee as we need to inject Unassigned value if JQL contains EMPTY keyword for assignee
63
+ */
64
+ assignee: [].concat(_toConsumableArray(mappedHydratedAssigneeValue || []), _toConsumableArray(extractedAssigneeValue !== null && extractedAssigneeValue !== void 0 && extractedAssigneeValue.includes(OPERAND_EMPTY) // checks and adds EMPTY filter option if extracted assignee values from jql contains EMPTY
65
+ ? [getAssigneeUnassignedFilterOption(formatMessage)] : []))
66
+ }, textFieldValue ? {
52
67
  basicInputTextValue: removeFuzzyCharacter(textFieldValue)
53
68
  } : {});
54
69
  setHydratedOptions(mappedValues);
55
70
  setStatus('resolved');
56
- _context.next = 20;
71
+ _context.next = 21;
57
72
  break;
58
- case 16:
59
- _context.prev = 16;
73
+ case 17:
74
+ _context.prev = 17;
60
75
  _context.t0 = _context["catch"](0);
61
76
  setErrors([_context.t0]);
62
77
  setStatus('rejected');
63
- case 20:
78
+ case 21:
64
79
  case "end":
65
80
  return _context.stop();
66
81
  }
67
- }, _callee, null, [[0, 16]]);
68
- })), [cloudId, getHydratedJQL, jql]);
82
+ }, _callee, null, [[0, 17]]);
83
+ })), [cloudId, formatMessage, getHydratedJQL, jql]);
69
84
  useEffect(function () {
70
85
  if (status !== 'rejected' && errors.length !== 0) {
71
86
  setErrors([]);
@@ -31,8 +31,6 @@ var AsyncPopupSelect = function AsyncPopupSelect(_ref) {
31
31
  isJQLHydrating = _ref.isJQLHydrating,
32
32
  _ref$onSelectionChang = _ref.onSelectionChange,
33
33
  onSelectionChange = _ref$onSelectionChang === void 0 ? function () {} : _ref$onSelectionChang,
34
- _ref$onReset = _ref.onReset,
35
- resetSelection = _ref$onReset === void 0 ? function () {} : _ref$onReset,
36
34
  _ref$isDisabled = _ref.isDisabled,
37
35
  isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled;
38
36
  var _useIntl = useIntl(),
@@ -182,9 +180,8 @@ var AsyncPopupSelect = function AsyncPopupSelect(_ref) {
182
180
  setSortedOptions([]);
183
181
  setSearchTerm('');
184
182
  resetHook();
185
- resetSelection();
186
183
  }
187
- }, [cloudId, resetHook, resetSelection]);
184
+ }, [cloudId, resetHook]);
188
185
  useEffect(function () {
189
186
  if (!isEqual(selection, selectedOptions)) {
190
187
  setSelectedOptions(selection);
@@ -1,4 +1,5 @@
1
- export var asyncPopupSelectMessages = {
1
+ import { defineMessages } from 'react-intl-next';
2
+ export var asyncPopupSelectMessages = defineMessages({
2
3
  selectPlaceholder: {
3
4
  id: 'linkDataSource.basic-filter.dropdown.select.placeholder',
4
5
  description: 'Placeholder text to be displayed for the search input box.',
@@ -34,4 +35,4 @@ export var asyncPopupSelectMessages = {
34
35
  defaultMessage: 'Show more',
35
36
  description: 'The text to show more options in dropdown'
36
37
  }
37
- };
38
+ });
@@ -9,7 +9,6 @@ var BasicFilterContainer = function BasicFilterContainer(_ref) {
9
9
  var cloudId = _ref.cloudId,
10
10
  onChange = _ref.onChange,
11
11
  selections = _ref.selections,
12
- onReset = _ref.onReset,
13
12
  isJQLHydrating = _ref.isJQLHydrating;
14
13
  return /*#__PURE__*/React.createElement(Flex, {
15
14
  xcss: basicFilterContainerStyles,
@@ -23,8 +22,7 @@ var BasicFilterContainer = function BasicFilterContainer(_ref) {
23
22
  selection: selections[filter] || [],
24
23
  isJQLHydrating: isJQLHydrating,
25
24
  isDisabled: !cloudId,
26
- onSelectionChange: onChange,
27
- onReset: onReset
25
+ onSelectionChange: onChange
28
26
  });
29
27
  }));
30
28
  };
@@ -1,4 +1,5 @@
1
- export var asyncPopupSelectMessages = {
1
+ import { defineMessages } from 'react-intl-next';
2
+ export var asyncPopupSelectMessages = defineMessages({
2
3
  loadingMessage: {
3
4
  id: 'linkDataSource.basic-filter.loading-message',
4
5
  defaultMessage: 'Loading...',
@@ -14,4 +15,4 @@ export var asyncPopupSelectMessages = {
14
15
  defaultMessage: 'Something went wrong',
15
16
  description: 'The text for when an error occurs when loading options'
16
17
  }
17
- };
18
+ });
@@ -14,11 +14,19 @@ import { isQueryTooComplex } from './isQueryTooComplex';
14
14
  // Map of field keys to their respective clauses in the Jast
15
15
 
16
16
  var getFieldValues = function getFieldValues(operand) {
17
+ var mapValuesFromList = function mapValuesFromList(value) {
18
+ if (value.operandType === OPERAND_TYPE_VALUE) {
19
+ return value.value;
20
+ }
21
+ // we only support EMPTY keyword atm, hence making sure if operandType is a KEYWORD, then its an EMPTY keyword
22
+ if (value.operandType === OPERAND_TYPE_KEYWORD && value.value === OPERAND_EMPTY) {
23
+ return value.value;
24
+ }
25
+ return undefined;
26
+ };
17
27
  switch (operand.operandType) {
18
28
  case OPERAND_TYPE_LIST:
19
- return operand.values.map(function (value) {
20
- return value.operandType === OPERAND_TYPE_VALUE && value.value || undefined;
21
- }).filter(function (value) {
29
+ return operand.values.map(mapValuesFromList).filter(function (value) {
22
30
  return !!value;
23
31
  });
24
32
  case OPERAND_TYPE_VALUE:
@@ -29,7 +29,7 @@ var inputContainerStyles = css({
29
29
  var basicSearchInputContainerStyles = xcss({
30
30
  flexGrow: 1
31
31
  });
32
- var DEFAULT_JQL_QUERY = 'created >= -30d order by created DESC';
32
+ export var DEFAULT_JQL_QUERY = 'created >= -30d order by created DESC';
33
33
  export var ALLOWED_ORDER_BY_KEYS = ['key', 'summary', 'assignee', 'status', 'created'];
34
34
  var JiraSearchMethodSwitcher = ModeSwitcher;
35
35
  export var JiraSearchContainer = function JiraSearchContainer(props) {
@@ -39,7 +39,7 @@ export var JiraSearchContainer = function JiraSearchContainer(props) {
39
39
  onSearchMethodChangeCallback = props.onSearchMethodChange,
40
40
  initialSearchMethod = props.initialSearchMethod;
41
41
  var _ref = parameters || {},
42
- cloudId = _ref.cloudId,
42
+ currentCloudId = _ref.cloudId,
43
43
  initialJql = _ref.jql;
44
44
  var _useIntl = useIntl(),
45
45
  formatMessage = _useIntl.formatMessage;
@@ -57,22 +57,26 @@ export var JiraSearchContainer = function JiraSearchContainer(props) {
57
57
  _useState6 = _slicedToArray(_useState5, 2),
58
58
  jql = _useState6[0],
59
59
  setJql = _useState6[1];
60
- var _useState7 = useState(false),
60
+ var _useState7 = useState(currentCloudId),
61
61
  _useState8 = _slicedToArray(_useState7, 2),
62
- isComplexQuery = _useState8[0],
63
- setIsComplexQuery = _useState8[1];
64
- var _useState9 = useState(),
62
+ cloudId = _useState8[0],
63
+ setCloudId = _useState8[1];
64
+ var _useState9 = useState(false),
65
65
  _useState10 = _slicedToArray(_useState9, 2),
66
- orderKey = _useState10[0],
67
- setOrderKey = _useState10[1];
66
+ isComplexQuery = _useState10[0],
67
+ setIsComplexQuery = _useState10[1];
68
68
  var _useState11 = useState(),
69
69
  _useState12 = _slicedToArray(_useState11, 2),
70
- orderDirection = _useState12[0],
71
- setOrderDirection = _useState12[1];
72
- var _useState13 = useState({}),
70
+ orderKey = _useState12[0],
71
+ setOrderKey = _useState12[1];
72
+ var _useState13 = useState(),
73
73
  _useState14 = _slicedToArray(_useState13, 2),
74
- filterSelections = _useState14[0],
75
- setFilterSelections = _useState14[1];
74
+ orderDirection = _useState14[0],
75
+ setOrderDirection = _useState14[1];
76
+ var _useState15 = useState({}),
77
+ _useState16 = _slicedToArray(_useState15, 2),
78
+ filterSelections = _useState16[0],
79
+ setFilterSelections = _useState16[1];
76
80
  var showBasicFilters = useMemo(function () {
77
81
  if (getBooleanFF('platform.linking-platform.datasource.show-jlol-basic-filters')) {
78
82
  return true;
@@ -181,11 +185,17 @@ export var JiraSearchContainer = function JiraSearchContainer(props) {
181
185
  setFilterSelections(updatedSelection);
182
186
  handleBasicFilterSelectionChange(updatedSelection);
183
187
  }, [handleBasicFilterSelectionChange, filterSelections]);
184
- var handleBasicFiltersReset = useCallback(function () {
185
- if (Object.keys(filterSelections).length > 0) {
188
+ useEffect(function () {
189
+ if (currentCloudId !== cloudId) {
190
+ setBasicSearchTerm('');
191
+ setJql(DEFAULT_JQL_QUERY);
192
+ setIsComplexQuery(false);
193
+ setOrderKey(undefined);
194
+ setOrderDirection(undefined);
186
195
  setFilterSelections({});
196
+ setCloudId(currentCloudId);
187
197
  }
188
- }, [filterSelections]);
198
+ }, [currentCloudId, cloudId]);
189
199
  return jsx("div", {
190
200
  css: inputContainerStyles,
191
201
  "data-testid": "jira-search-container"
@@ -201,7 +211,6 @@ export var JiraSearchContainer = function JiraSearchContainer(props) {
201
211
  cloudId: cloudId || '',
202
212
  onChange: handleSelectionChange,
203
213
  selections: filterSelections,
204
- onReset: handleBasicFiltersReset,
205
214
  isJQLHydrating: basicFilterHydrationStatus === 'loading'
206
215
  })), currentSearchMethod === 'jql' && jsx(JiraJQLEditor, {
207
216
  cloudId: cloudId || '',
@@ -14,6 +14,7 @@ import { v4 as uuidv4 } from 'uuid';
14
14
  import { withAnalyticsContext } from '@atlaskit/analytics-next';
15
15
  import Button from '@atlaskit/button/standard-button';
16
16
  import Modal, { ModalBody, ModalFooter, ModalHeader, ModalTitle, ModalTransition } from '@atlaskit/modal-dialog';
17
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
17
18
  import LinkUrl from '@atlaskit/smart-card/link-url';
18
19
  import { B400, N0, N40, N800 } from '@atlaskit/theme/colors';
19
20
  import { EVENT_CHANNEL, useDatasourceAnalyticsEvents } from '../../../analytics';
@@ -32,6 +33,7 @@ import { NoResults } from '../../common/error-state/no-results';
32
33
  import { EmptyState, IssueLikeDataTableView, scrollableContainerShadowsCssComponents } from '../../issue-like-table';
33
34
  import LinkRenderType from '../../issue-like-table/render-type/link';
34
35
  import { availableBasicFilterTypes } from '../basic-filters/ui';
36
+ import { isQueryTooComplex } from '../basic-filters/utils/isQueryTooComplex';
35
37
  import { InitialStateView } from '../initial-state-view';
36
38
  import { JiraSearchContainer } from '../jira-search-container';
37
39
  import { ModeSwitcher } from '../mode-switcher';
@@ -129,7 +131,7 @@ export var PlainJiraIssuesConfigModal = function PlainJiraIssuesConfigModal(prop
129
131
  // analytics related parameters
130
132
  var searchCount = useRef(0);
131
133
  var userInteractionActions = useRef(new Set());
132
- var initialSearchMethod = 'jql'; // TODO EDM-7688 This where we can add feature that decides if it's basic or jql based on JQL content (Regexp)
134
+ var initialSearchMethod = getBooleanFF('platform.linking-platform.datasource.show-jlol-basic-filters') && !isQueryTooComplex((initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.jql) || '') ? 'basic' : 'jql';
133
135
  var _useState11 = useState(initialSearchMethod),
134
136
  _useState12 = _slicedToArray(_useState11, 2),
135
137
  currentSearchMethod = _useState12[0],
@@ -331,6 +333,7 @@ export var PlainJiraIssuesConfigModal = function PlainJiraIssuesConfigModal(prop
331
333
  }, [analyticsPayload, onCancel]);
332
334
  var onSiteSelection = useCallback(function (site) {
333
335
  userInteractionActions.current.add(DatasourceAction.INSTANCE_UPDATED);
336
+ setJql('');
334
337
  setCloudId(site.cloudId);
335
338
  reset({
336
339
  shouldForceRequest: true
@@ -0,0 +1,7 @@
1
+ export declare const filterOptionMessages: {
2
+ assigneeUnassignedFilterOption: {
3
+ id: string;
4
+ description: string;
5
+ defaultMessage: string;
6
+ };
7
+ };
@@ -1,4 +1,5 @@
1
- import { BasicFilterFieldType, SelectOption } from '../types';
1
+ import { IntlShape } from 'react-intl-next';
2
+ import { AvatarLabelOption, BasicFilterFieldType, SelectOption } from '../types';
2
3
  interface FilterOptionsProps {
3
4
  filterType: BasicFilterFieldType;
4
5
  cloudId: string;
@@ -16,5 +17,6 @@ export interface FilterOptionsState {
16
17
  status: 'empty' | 'loading' | 'resolved' | 'rejected' | 'loadingMore';
17
18
  errors: unknown[];
18
19
  }
20
+ export declare const getAssigneeUnassignedFilterOption: (formatMessage: IntlShape['formatMessage']) => AvatarLabelOption;
19
21
  export declare const useFilterOptions: ({ filterType, cloudId, }: FilterOptionsProps) => FilterOptionsState;
20
22
  export {};
@@ -6,9 +6,8 @@ export interface AsyncPopupSelectProps {
6
6
  selection: SelectOption[];
7
7
  isJQLHydrating: boolean;
8
8
  onSelectionChange?: (filterType: BasicFilterFieldType, options: SelectOption[]) => void;
9
- onReset?: () => void;
10
9
  isDisabled?: boolean;
11
10
  }
12
11
  export declare const SEARCH_DEBOUNCE_MS = 350;
13
- declare const AsyncPopupSelect: ({ filterType, cloudId, selection, isJQLHydrating, onSelectionChange, onReset: resetSelection, isDisabled, }: AsyncPopupSelectProps) => JSX.Element;
12
+ declare const AsyncPopupSelect: ({ filterType, cloudId, selection, isJQLHydrating, onSelectionChange, isDisabled, }: AsyncPopupSelectProps) => JSX.Element;
14
13
  export default AsyncPopupSelect;
@@ -5,8 +5,7 @@ export interface BasicFilterContainerProps {
5
5
  cloudId: string;
6
6
  selections: SelectedOptionsMap;
7
7
  onChange: (filterType: BasicFilterFieldType, options: SelectOption[]) => void;
8
- onReset: () => void;
9
8
  isJQLHydrating: boolean;
10
9
  }
11
- declare const BasicFilterContainer: ({ cloudId, onChange, selections, onReset, isJQLHydrating, }: BasicFilterContainerProps) => JSX.Element;
10
+ declare const BasicFilterContainer: ({ cloudId, onChange, selections, isJQLHydrating, }: BasicFilterContainerProps) => JSX.Element;
12
11
  export default BasicFilterContainer;
@@ -2,6 +2,7 @@ import { jsx } from '@emotion/react';
2
2
  import type { JiraSearchMethod } from '../../../common/types';
3
3
  import { SelectedOptionsMap } from '../basic-filters/types';
4
4
  import { JiraIssueDatasourceParameters, JiraIssueDatasourceParametersQuery } from '../types';
5
+ export declare const DEFAULT_JQL_QUERY = "created >= -30d order by created DESC";
5
6
  export declare const ALLOWED_ORDER_BY_KEYS: string[];
6
7
  export interface SearchContainerProps {
7
8
  isSearching?: boolean;
@@ -0,0 +1,7 @@
1
+ export declare const filterOptionMessages: {
2
+ assigneeUnassignedFilterOption: {
3
+ id: string;
4
+ description: string;
5
+ defaultMessage: string;
6
+ };
7
+ };
@@ -1,4 +1,5 @@
1
- import { BasicFilterFieldType, SelectOption } from '../types';
1
+ import { IntlShape } from 'react-intl-next';
2
+ import { AvatarLabelOption, BasicFilterFieldType, SelectOption } from '../types';
2
3
  interface FilterOptionsProps {
3
4
  filterType: BasicFilterFieldType;
4
5
  cloudId: string;
@@ -16,5 +17,6 @@ export interface FilterOptionsState {
16
17
  status: 'empty' | 'loading' | 'resolved' | 'rejected' | 'loadingMore';
17
18
  errors: unknown[];
18
19
  }
20
+ export declare const getAssigneeUnassignedFilterOption: (formatMessage: IntlShape['formatMessage']) => AvatarLabelOption;
19
21
  export declare const useFilterOptions: ({ filterType, cloudId, }: FilterOptionsProps) => FilterOptionsState;
20
22
  export {};
@@ -6,9 +6,8 @@ export interface AsyncPopupSelectProps {
6
6
  selection: SelectOption[];
7
7
  isJQLHydrating: boolean;
8
8
  onSelectionChange?: (filterType: BasicFilterFieldType, options: SelectOption[]) => void;
9
- onReset?: () => void;
10
9
  isDisabled?: boolean;
11
10
  }
12
11
  export declare const SEARCH_DEBOUNCE_MS = 350;
13
- declare const AsyncPopupSelect: ({ filterType, cloudId, selection, isJQLHydrating, onSelectionChange, onReset: resetSelection, isDisabled, }: AsyncPopupSelectProps) => JSX.Element;
12
+ declare const AsyncPopupSelect: ({ filterType, cloudId, selection, isJQLHydrating, onSelectionChange, isDisabled, }: AsyncPopupSelectProps) => JSX.Element;
14
13
  export default AsyncPopupSelect;
@@ -5,8 +5,7 @@ export interface BasicFilterContainerProps {
5
5
  cloudId: string;
6
6
  selections: SelectedOptionsMap;
7
7
  onChange: (filterType: BasicFilterFieldType, options: SelectOption[]) => void;
8
- onReset: () => void;
9
8
  isJQLHydrating: boolean;
10
9
  }
11
- declare const BasicFilterContainer: ({ cloudId, onChange, selections, onReset, isJQLHydrating, }: BasicFilterContainerProps) => JSX.Element;
10
+ declare const BasicFilterContainer: ({ cloudId, onChange, selections, isJQLHydrating, }: BasicFilterContainerProps) => JSX.Element;
12
11
  export default BasicFilterContainer;
@@ -2,6 +2,7 @@ import { jsx } from '@emotion/react';
2
2
  import type { JiraSearchMethod } from '../../../common/types';
3
3
  import { SelectedOptionsMap } from '../basic-filters/types';
4
4
  import { JiraIssueDatasourceParameters, JiraIssueDatasourceParametersQuery } from '../types';
5
+ export declare const DEFAULT_JQL_QUERY = "created >= -30d order by created DESC";
5
6
  export declare const ALLOWED_ORDER_BY_KEYS: string[];
6
7
  export interface SearchContainerProps {
7
8
  isSearching?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/link-datasource",
3
- "version": "1.19.8",
3
+ "version": "1.19.10",
4
4
  "description": "UI Components to support linking platform dataset feature",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"