@atlaskit/link-datasource 1.18.1 → 1.19.1

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 (48) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/analytics/constants.js +1 -1
  3. package/dist/cjs/ui/common/error-state/messages.js +10 -0
  4. package/dist/cjs/ui/common/error-state/no-instances-svg.js +154 -0
  5. package/dist/cjs/ui/common/error-state/no-instances.js +36 -0
  6. package/dist/cjs/ui/jira-issues-modal/basic-filters/ui/async-popup-select/index.js +1 -1
  7. package/dist/cjs/ui/jira-issues-modal/basic-filters/ui/async-popup-select/trigger.js +28 -21
  8. package/dist/cjs/ui/jira-issues-modal/basic-filters/ui/index.js +12 -36
  9. package/dist/cjs/ui/jira-issues-modal/jira-search-container/index.js +58 -20
  10. package/dist/cjs/ui/jira-issues-modal/modal/index.js +22 -11
  11. package/dist/cjs/ui/jira-issues-modal/site-selector/index.js +3 -3
  12. package/dist/es2019/analytics/constants.js +1 -1
  13. package/dist/es2019/ui/common/error-state/messages.js +10 -0
  14. package/dist/es2019/ui/common/error-state/no-instances-svg.js +147 -0
  15. package/dist/es2019/ui/common/error-state/no-instances.js +27 -0
  16. package/dist/es2019/ui/jira-issues-modal/basic-filters/ui/async-popup-select/index.js +1 -1
  17. package/dist/es2019/ui/jira-issues-modal/basic-filters/ui/async-popup-select/trigger.js +17 -14
  18. package/dist/es2019/ui/jira-issues-modal/basic-filters/ui/index.js +18 -33
  19. package/dist/es2019/ui/jira-issues-modal/jira-search-container/index.js +58 -17
  20. package/dist/es2019/ui/jira-issues-modal/modal/index.js +28 -10
  21. package/dist/es2019/ui/jira-issues-modal/site-selector/index.js +3 -3
  22. package/dist/esm/analytics/constants.js +1 -1
  23. package/dist/esm/ui/common/error-state/messages.js +10 -0
  24. package/dist/esm/ui/common/error-state/no-instances-svg.js +147 -0
  25. package/dist/esm/ui/common/error-state/no-instances.js +29 -0
  26. package/dist/esm/ui/jira-issues-modal/basic-filters/ui/async-popup-select/index.js +1 -1
  27. package/dist/esm/ui/jira-issues-modal/basic-filters/ui/async-popup-select/trigger.js +29 -22
  28. package/dist/esm/ui/jira-issues-modal/basic-filters/ui/index.js +11 -32
  29. package/dist/esm/ui/jira-issues-modal/jira-search-container/index.js +58 -18
  30. package/dist/esm/ui/jira-issues-modal/modal/index.js +22 -11
  31. package/dist/esm/ui/jira-issues-modal/site-selector/index.js +3 -3
  32. package/dist/types/analytics/generated/analytics.types.d.ts +5 -1
  33. package/dist/types/ui/common/error-state/messages.d.ts +10 -0
  34. package/dist/types/ui/common/error-state/no-instances-svg.d.ts +2 -0
  35. package/dist/types/ui/common/error-state/no-instances.d.ts +3 -0
  36. package/dist/types/ui/jira-issues-modal/basic-filters/ui/async-popup-select/index.d.ts +2 -1
  37. package/dist/types/ui/jira-issues-modal/basic-filters/ui/index.d.ts +7 -4
  38. package/dist/types/ui/jira-issues-modal/jira-search-container/index.d.ts +5 -1
  39. package/dist/types/ui/jira-issues-modal/site-selector/index.d.ts +1 -1
  40. package/dist/types-ts4.5/analytics/generated/analytics.types.d.ts +5 -1
  41. package/dist/types-ts4.5/ui/common/error-state/messages.d.ts +10 -0
  42. package/dist/types-ts4.5/ui/common/error-state/no-instances-svg.d.ts +2 -0
  43. package/dist/types-ts4.5/ui/common/error-state/no-instances.d.ts +3 -0
  44. package/dist/types-ts4.5/ui/jira-issues-modal/basic-filters/ui/async-popup-select/index.d.ts +2 -1
  45. package/dist/types-ts4.5/ui/jira-issues-modal/basic-filters/ui/index.d.ts +7 -4
  46. package/dist/types-ts4.5/ui/jira-issues-modal/jira-search-container/index.d.ts +5 -1
  47. package/dist/types-ts4.5/ui/jira-issues-modal/site-selector/index.d.ts +1 -1
  48. package/package.json +2 -2
@@ -32,9 +32,11 @@ var _useDatasourceTableState = require("../../../hooks/useDatasourceTableState")
32
32
  var _getAvailableJiraSites = require("../../../services/getAvailableJiraSites");
33
33
  var _accessRequired = require("../../common/error-state/access-required");
34
34
  var _modalLoadingError = require("../../common/error-state/modal-loading-error");
35
+ var _noInstances = require("../../common/error-state/no-instances");
35
36
  var _noResults = require("../../common/error-state/no-results");
36
37
  var _issueLikeTable = require("../../issue-like-table");
37
38
  var _link = _interopRequireDefault(require("../../issue-like-table/render-type/link"));
39
+ var _ui = require("../basic-filters/ui");
38
40
  var _initialStateView = require("../initial-state-view");
39
41
  var _jiraSearchContainer = require("../jira-search-container");
40
42
  var _modeSwitcher = require("../mode-switcher");
@@ -108,7 +110,7 @@ var PlainJiraIssuesConfigModal = exports.PlainJiraIssuesConfigModal = function P
108
110
  initialParameters = props.parameters,
109
111
  urlBeingEdited = props.url,
110
112
  initialVisibleColumnKeys = props.visibleColumnKeys;
111
- var _useState = (0, _react.useState)([]),
113
+ var _useState = (0, _react.useState)(undefined),
112
114
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
113
115
  availableSites = _useState2[0],
114
116
  setAvailableSites = _useState2[1];
@@ -139,6 +141,7 @@ var PlainJiraIssuesConfigModal = exports.PlainJiraIssuesConfigModal = function P
139
141
  setCurrentSearchMethod = _useState12[1];
140
142
  var searchMethodSearchedWith = (0, _react.useRef)(null);
141
143
  var visibleColumnCount = (0, _react.useRef)((visibleColumnKeys === null || visibleColumnKeys === void 0 ? void 0 : visibleColumnKeys.length) || 0);
144
+ var basicFilterSelectionsSearchedWith = (0, _react.useRef)({});
142
145
  var parameters = (0, _react.useMemo)(function () {
143
146
  return !!cloudId ? {
144
147
  cloudId: cloudId,
@@ -178,14 +181,14 @@ var PlainJiraIssuesConfigModal = exports.PlainJiraIssuesConfigModal = function P
178
181
  modalRenderInstanceId = _useRef.current;
179
182
  var selectedJiraSite = (0, _react.useMemo)(function () {
180
183
  if (cloudId) {
181
- return availableSites.find(function (jiraSite) {
184
+ return availableSites === null || availableSites === void 0 ? void 0 : availableSites.find(function (jiraSite) {
182
185
  return jiraSite.cloudId === cloudId;
183
186
  });
184
187
  } else {
185
188
  var currentlyLoggedInSiteUrl = window.location.origin;
186
- return availableSites.find(function (jiraSite) {
189
+ return (availableSites === null || availableSites === void 0 ? void 0 : availableSites.find(function (jiraSite) {
187
190
  return jiraSite.url === currentlyLoggedInSiteUrl;
188
- }) || availableSites[0];
191
+ })) || (availableSites === null || availableSites === void 0 ? void 0 : availableSites[0]);
189
192
  }
190
193
  }, [availableSites, cloudId]);
191
194
  var analyticsPayload = (0, _react.useMemo)(function () {
@@ -199,6 +202,7 @@ var PlainJiraIssuesConfigModal = exports.PlainJiraIssuesConfigModal = function P
199
202
  var isInsertDisabled = !isParametersSet || status === 'rejected' || status === 'unauthorized' || status === 'loading';
200
203
  var shouldShowIssueCount = !!totalCount && totalCount !== 1 && currentViewMode === 'issue';
201
204
  var isDataReady = (visibleColumnKeys || []).length > 0;
205
+ var hasNoJiraSites = availableSites && availableSites.length === 0;
202
206
  (0, _react.useEffect)(function () {
203
207
  var shouldStartUfoExperience = status === 'loading';
204
208
  if (shouldStartUfoExperience) {
@@ -302,9 +306,12 @@ var PlainJiraIssuesConfigModal = exports.PlainJiraIssuesConfigModal = function P
302
306
  }
303
307
  }, [currentViewMode, status, fireIssueViewAnalytics, fireCountViewedEvent]);
304
308
  (0, _useColumnPickerRenderedFailedUfoExperience.useColumnPickerRenderedFailedUfoExperience)(status, modalRenderInstanceId);
305
- var onSearch = (0, _react.useCallback)(function (newParameters, searchMethod) {
309
+ var onSearch = (0, _react.useCallback)(function (newParameters, _ref2) {
310
+ var searchMethod = _ref2.searchMethod,
311
+ basicFilterSelections = _ref2.basicFilterSelections;
306
312
  searchCount.current++;
307
313
  searchMethodSearchedWith.current = searchMethod;
314
+ basicFilterSelectionsSearchedWith.current = basicFilterSelections;
308
315
  if (jql !== newParameters.jql) {
309
316
  userInteractionActions.current.add(_types.DatasourceAction.QUERY_UPDATED);
310
317
  }
@@ -343,6 +350,10 @@ var PlainJiraIssuesConfigModal = exports.PlainJiraIssuesConfigModal = function P
343
350
  if (!isParametersSet || !jql || !selectedJiraSite) {
344
351
  return;
345
352
  }
353
+ var filterSelectionCount = _ui.availableBasicFilterTypes.reduce(function (current, filter) {
354
+ var _basicFilterSelection;
355
+ return _objectSpread(_objectSpread({}, current), {}, (0, _defineProperty2.default)({}, "".concat(filter, "BasicFilterSelectionCount"), ((_basicFilterSelection = basicFilterSelectionsSearchedWith.current[filter]) === null || _basicFilterSelection === void 0 ? void 0 : _basicFilterSelection.length) || 0));
356
+ }, {});
346
357
  var insertButtonClickedEvent = analyticsEvent.update({
347
358
  actionSubjectId: 'insert',
348
359
  attributes: _objectSpread(_objectSpread({}, analyticsPayload), {}, {
@@ -352,7 +363,7 @@ var PlainJiraIssuesConfigModal = exports.PlainJiraIssuesConfigModal = function P
352
363
  searchCount: searchCount.current,
353
364
  searchMethod: (0, _utils.mapSearchMethod)(searchMethodSearchedWith.current),
354
365
  actions: Array.from(userInteractionActions.current)
355
- }),
366
+ }, searchMethodSearchedWith.current === 'basic' ? _objectSpread({}, filterSelectionCount) : {}),
356
367
  eventType: 'ui'
357
368
  });
358
369
 
@@ -515,12 +526,12 @@ var PlainJiraIssuesConfigModal = exports.PlainJiraIssuesConfigModal = function P
515
526
  shouldScrollInViewport: true
516
527
  }, (0, _react2.jsx)(_modalDialog.ModalHeader, null, (0, _react2.jsx)(_modalDialog.ModalTitle, null, (0, _react2.jsx)("div", {
517
528
  css: dropdownContainerStyles
518
- }, availableSites.length < 2 ? (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _messages.modalMessages.insertIssuesTitle) : (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _messages.modalMessages.insertIssuesTitleManySites), (0, _react2.jsx)(_siteSelector.JiraSiteSelector, {
529
+ }, availableSites && availableSites.length > 1 ? (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _messages.modalMessages.insertIssuesTitleManySites), (0, _react2.jsx)(_siteSelector.JiraSiteSelector, {
519
530
  availableSites: availableSites,
520
531
  onSiteSelection: onSiteSelection,
521
532
  selectedJiraSite: selectedJiraSite,
522
533
  testId: "jira-jql-datasource-modal--site-selector"
523
- })))), (0, _react2.jsx)(_modeSwitcher.ModeSwitcher, {
534
+ })) : (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _messages.modalMessages.insertIssuesTitle))), !hasNoJiraSites && (0, _react2.jsx)(_modeSwitcher.ModeSwitcher, {
524
535
  isCompact: true,
525
536
  options: [{
526
537
  label: formatMessage(_messages.modalMessages.issueViewModeLabel),
@@ -531,13 +542,13 @@ var PlainJiraIssuesConfigModal = exports.PlainJiraIssuesConfigModal = function P
531
542
  }],
532
543
  onOptionValueChange: handleViewModeChange,
533
544
  selectedOptionValue: currentViewMode
534
- })), (0, _react2.jsx)(_modalDialog.ModalBody, null, (0, _react2.jsx)(_jiraSearchContainer.JiraSearchContainer, {
545
+ })), (0, _react2.jsx)(_modalDialog.ModalBody, null, !hasNoJiraSites ? (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)(_jiraSearchContainer.JiraSearchContainer, {
535
546
  isSearching: status === 'loading',
536
547
  parameters: parameters,
537
548
  onSearch: onSearch,
538
549
  initialSearchMethod: initialSearchMethod,
539
550
  onSearchMethodChange: setCurrentSearchMethod
540
- }), currentViewMode === 'count' ? renderCountModeContent() : renderIssuesModeContent()), (0, _react2.jsx)(_modalDialog.ModalFooter, null, shouldShowIssueCount && (0, _react2.jsx)("div", {
551
+ }), currentViewMode === 'count' ? renderCountModeContent() : renderIssuesModeContent()) : (0, _react2.jsx)(_noInstances.NoInstancesView, null)), (0, _react2.jsx)(_modalDialog.ModalFooter, null, shouldShowIssueCount && (0, _react2.jsx)("div", {
541
552
  "data-testid": "jira-jql-datasource-modal-total-issues-count",
542
553
  css: issueCountStyles
543
554
  }, (0, _react2.jsx)(_linkUrl.default, {
@@ -556,7 +567,7 @@ var PlainJiraIssuesConfigModal = exports.PlainJiraIssuesConfigModal = function P
556
567
  })))), (0, _react2.jsx)(_standardButton.default, {
557
568
  appearance: "default",
558
569
  onClick: onCancelClick
559
- }, (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _messages.modalMessages.cancelButtonText)), (0, _react2.jsx)(_standardButton.default, {
570
+ }, (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _messages.modalMessages.cancelButtonText)), !hasNoJiraSites && (0, _react2.jsx)(_standardButton.default, {
560
571
  appearance: "primary",
561
572
  onClick: onInsertPressed,
562
573
  isDisabled: isInsertDisabled,
@@ -31,7 +31,7 @@ var JiraSiteSelector = exports.JiraSiteSelector = function JiraSiteSelector(prop
31
31
  var _useIntl = (0, _reactIntlNext.useIntl)(),
32
32
  formatMessage = _useIntl.formatMessage;
33
33
  var onChange = function onChange(newValue) {
34
- var selectedSite = availableSites.find(function (site) {
34
+ var selectedSite = availableSites === null || availableSites === void 0 ? void 0 : availableSites.find(function (site) {
35
35
  return site.cloudId === (newValue === null || newValue === void 0 ? void 0 : newValue.value);
36
36
  });
37
37
  if (selectedSite) {
@@ -39,7 +39,7 @@ var JiraSiteSelector = exports.JiraSiteSelector = function JiraSiteSelector(prop
39
39
  }
40
40
  };
41
41
  var availableSitesOptions = (0, _react.useMemo)(function () {
42
- return availableSites.map(function (site) {
42
+ return availableSites === null || availableSites === void 0 ? void 0 : availableSites.map(function (site) {
43
43
  return {
44
44
  label: site.displayName,
45
45
  value: site.cloudId
@@ -55,7 +55,7 @@ var JiraSiteSelector = exports.JiraSiteSelector = function JiraSiteSelector(prop
55
55
  }, (0, _react2.jsx)(_select.default, {
56
56
  css: selectStyles,
57
57
  classNamePrefix: testId,
58
- isLoading: availableSites.length === 0,
58
+ isLoading: !availableSites,
59
59
  onChange: onChange,
60
60
  options: availableSitesOptions,
61
61
  placeholder: formatMessage(_messages.siteSelectorMessages.chooseSite),
@@ -1,5 +1,5 @@
1
1
  export const EVENT_CHANNEL = 'media';
2
2
  export const packageMetaData = {
3
3
  packageName: "@atlaskit/link-datasource",
4
- packageVersion: "1.18.1"
4
+ packageVersion: "1.19.1"
5
5
  };
@@ -44,5 +44,15 @@ export const loadingErrorMessages = defineMessages({
44
44
  id: 'linkDataSource.jira-issues.unableToLoadResults',
45
45
  description: 'Error state message letting the user know we were unable the load the requested list of results',
46
46
  defaultMessage: 'Unable to load results'
47
+ },
48
+ noAccessToJiraSitesTitle: {
49
+ id: 'linkDataSource.jira-issues.no.jira.sites.access.title',
50
+ description: 'Title that shows in the modal when user has no access to any Jira sites',
51
+ defaultMessage: "You don't have access to any Jira sites"
52
+ },
53
+ noAccessToJiraSitesDescription: {
54
+ id: 'linkDataSource.jira-issues.no.jira.sites.access.description',
55
+ description: 'Description that shows in the modal when user has no access to any Jira sites',
56
+ defaultMessage: 'To request access, contact your admin.'
47
57
  }
48
58
  });
@@ -0,0 +1,147 @@
1
+ import React from 'react';
2
+ export const NoInstancesSvg = () => {
3
+ return /*#__PURE__*/React.createElement("svg", {
4
+ width: "147",
5
+ height: "171",
6
+ viewBox: "0 0 147 171",
7
+ fill: "none",
8
+ xmlns: "http://www.w3.org/2000/svg"
9
+ }, /*#__PURE__*/React.createElement("g", {
10
+ clipPath: "url(#clip0_1442_1679)"
11
+ }, /*#__PURE__*/React.createElement("rect", {
12
+ width: "146.22",
13
+ height: "169.36",
14
+ transform: "translate(0.0300293 0.875)",
15
+ fill: "white",
16
+ fillOpacity: "0.01"
17
+ }), /*#__PURE__*/React.createElement("path", {
18
+ opacity: "0.3",
19
+ d: "M110.62 170.234H97.46C96.31 170.234 95.38 169.304 95.38 168.154C95.38 167.004 96.31 166.074 97.46 166.074H110.62C111.77 166.074 112.7 167.004 112.7 168.154C112.7 169.304 111.77 170.234 110.62 170.234Z",
20
+ fill: "#B3BAC5"
21
+ }), /*#__PURE__*/React.createElement("path", {
22
+ opacity: "0.3",
23
+ d: "M85.24 170.234H72.08C70.93 170.234 70 169.304 70 168.154C70 167.004 70.93 166.074 72.08 166.074H85.24C86.39 166.074 87.32 167.004 87.32 168.154C87.32 169.304 86.39 170.234 85.24 170.234Z",
24
+ fill: "#B3BAC5"
25
+ }), /*#__PURE__*/React.createElement("path", {
26
+ opacity: "0.3",
27
+ d: "M59.86 170.234H46.71C45.56 170.234 44.63 169.304 44.63 168.154C44.63 167.004 45.56 166.074 46.71 166.074H59.87C61.02 166.074 61.95 167.004 61.95 168.154C61.95 169.304 61.01 170.234 59.86 170.234Z",
28
+ fill: "#B3BAC5"
29
+ }), /*#__PURE__*/React.createElement("path", {
30
+ opacity: "0.3",
31
+ d: "M34.49 170.234H21.33C20.18 170.234 19.25 169.304 19.25 168.154C19.25 167.004 20.18 166.074 21.33 166.074H34.49C35.64 166.074 36.57 167.004 36.57 168.154C36.57 169.304 35.64 170.234 34.49 170.234Z",
32
+ fill: "#B3BAC5"
33
+ }), /*#__PURE__*/React.createElement("path", {
34
+ opacity: "0.3",
35
+ d: "M9.11003 170.234H2.11003C0.960029 170.234 0.0300293 169.304 0.0300293 168.154V161.154C0.0300293 160.004 0.960029 159.074 2.11003 159.074C3.26003 159.074 4.19003 160.004 4.19003 161.154V166.074H9.11003C10.26 166.074 11.19 167.004 11.19 168.154C11.19 169.304 10.26 170.234 9.11003 170.234Z",
36
+ fill: "#B3BAC5"
37
+ }), /*#__PURE__*/React.createElement("path", {
38
+ opacity: "0.3",
39
+ d: "M2.11003 149.954C0.960029 149.954 0.0300293 149.024 0.0300293 147.874V133.574C0.0300293 132.424 0.960029 131.494 2.11003 131.494C3.26003 131.494 4.19003 132.424 4.19003 133.574V147.874C4.19003 149.024 3.26003 149.954 2.11003 149.954Z",
40
+ fill: "#B3BAC5"
41
+ }), /*#__PURE__*/React.createElement("path", {
42
+ opacity: "0.3",
43
+ d: "M2.11003 122.374C0.960029 122.374 0.0300293 121.444 0.0300293 120.294V105.994C0.0300293 104.844 0.960029 103.914 2.11003 103.914C3.26003 103.914 4.19003 104.844 4.19003 105.994V120.294C4.19003 121.444 3.26003 122.374 2.11003 122.374Z",
44
+ fill: "#B3BAC5"
45
+ }), /*#__PURE__*/React.createElement("path", {
46
+ opacity: "0.3",
47
+ d: "M2.11003 94.7942C0.960029 94.7942 0.0300293 93.8542 0.0300293 92.7042V78.4042C0.0300293 77.2542 0.960029 76.3242 2.11003 76.3242C3.26003 76.3242 4.19003 77.2542 4.19003 78.4042V92.7042C4.19003 93.8542 3.26003 94.7942 2.11003 94.7942Z",
48
+ fill: "#B3BAC5"
49
+ }), /*#__PURE__*/React.createElement("path", {
50
+ opacity: "0.3",
51
+ d: "M2.11003 67.2041C0.960029 67.2041 0.0300293 66.2741 0.0300293 65.1241V50.8241C0.0300293 49.6741 0.960029 48.7441 2.11003 48.7441C3.26003 48.7441 4.19003 49.6741 4.19003 50.8241V65.1241C4.19003 66.2741 3.26003 67.2041 2.11003 67.2041Z",
52
+ fill: "#B3BAC5"
53
+ }), /*#__PURE__*/React.createElement("path", {
54
+ opacity: "0.3",
55
+ d: "M2.11003 39.6241C0.960029 39.6241 0.0300293 38.6841 0.0300293 37.5441V23.2441C0.0300293 22.0941 0.960029 21.1641 2.11003 21.1641C3.26003 21.1641 4.19003 22.0941 4.19003 23.2441V37.5441C4.19003 38.6841 3.26003 39.6241 2.11003 39.6241Z",
56
+ fill: "#B3BAC5"
57
+ }), /*#__PURE__*/React.createElement("path", {
58
+ opacity: "0.3",
59
+ d: "M2.11003 12.035C0.960029 12.035 0.0300293 11.105 0.0300293 9.955V2.955C0.0300293 1.805 0.960029 0.875 2.11003 0.875H9.11003C10.26 0.875 11.19 1.805 11.19 2.955C11.19 4.105 10.26 5.035 9.11003 5.035H4.19003V9.955C4.19003 11.105 3.26003 12.035 2.11003 12.035Z",
60
+ fill: "#B3BAC5"
61
+ }), /*#__PURE__*/React.createElement("path", {
62
+ opacity: "0.3",
63
+ d: "M110.6 5.035H97.44C96.29 5.035 95.36 4.105 95.36 2.955C95.36 1.805 96.29 0.875 97.44 0.875H110.6C111.75 0.875 112.68 1.805 112.68 2.955C112.68 4.105 111.74 5.035 110.6 5.035Z",
64
+ fill: "#B3BAC5"
65
+ }), /*#__PURE__*/React.createElement("path", {
66
+ opacity: "0.3",
67
+ d: "M85.22 5.035H72.07C70.92 5.035 69.99 4.105 69.99 2.955C69.99 1.805 70.92 0.875 72.07 0.875H85.23C86.38 0.875 87.31 1.805 87.31 2.955C87.31 4.105 86.37 5.035 85.22 5.035Z",
68
+ fill: "#B3BAC5"
69
+ }), /*#__PURE__*/React.createElement("path", {
70
+ opacity: "0.3",
71
+ d: "M59.85 5.035H46.7C45.55 5.035 44.62 4.105 44.62 2.955C44.62 1.805 45.55 0.875 46.7 0.875H59.86C61.01 0.875 61.94 1.805 61.94 2.955C61.94 4.105 61 5.035 59.85 5.035Z",
72
+ fill: "#B3BAC5"
73
+ }), /*#__PURE__*/React.createElement("path", {
74
+ opacity: "0.3",
75
+ d: "M34.48 5.035H21.33C20.18 5.035 19.25 4.105 19.25 2.955C19.25 1.805 20.18 0.875 21.33 0.875H34.49C35.64 0.875 36.57 1.805 36.57 2.955C36.57 4.105 35.63 5.035 34.48 5.035Z",
76
+ fill: "#B3BAC5"
77
+ }), /*#__PURE__*/React.createElement("path", {
78
+ opacity: "0.3",
79
+ d: "M129.81 12.035C128.66 12.035 127.73 11.105 127.73 9.955V5.035H122.81C121.66 5.035 120.73 4.105 120.73 2.955C120.73 1.805 121.66 0.875 122.81 0.875H129.81C130.96 0.875 131.89 1.805 131.89 2.955V9.955C131.89 11.105 130.96 12.035 129.81 12.035Z",
80
+ fill: "#B3BAC5"
81
+ }), /*#__PURE__*/React.createElement("path", {
82
+ opacity: "0.3",
83
+ d: "M129.83 122.374C128.68 122.374 127.75 121.444 127.75 120.294V105.994C127.75 104.844 128.68 103.914 129.83 103.914C130.98 103.914 131.91 104.844 131.91 105.994V120.294C131.91 121.444 130.98 122.374 129.83 122.374Z",
84
+ fill: "#B3BAC5"
85
+ }), /*#__PURE__*/React.createElement("path", {
86
+ opacity: "0.3",
87
+ d: "M129.82 94.7842C128.67 94.7842 127.74 93.8542 127.74 92.7042V78.4042C127.74 77.2542 128.67 76.3242 129.82 76.3242C130.97 76.3242 131.9 77.2542 131.9 78.4042V92.7042C131.91 93.8542 130.97 94.7842 129.82 94.7842Z",
88
+ fill: "#B3BAC5"
89
+ }), /*#__PURE__*/React.createElement("path", {
90
+ opacity: "0.3",
91
+ d: "M129.82 67.2041C128.67 67.2041 127.74 66.2741 127.74 65.1241V50.8241C127.74 49.6741 128.67 48.7441 129.82 48.7441C130.97 48.7441 131.9 49.6741 131.9 50.8241V65.1241C131.9 66.2741 130.97 67.2041 129.82 67.2041Z",
92
+ fill: "#B3BAC5"
93
+ }), /*#__PURE__*/React.createElement("path", {
94
+ opacity: "0.3",
95
+ d: "M129.82 39.6241C128.67 39.6241 127.74 38.6941 127.74 37.5441V23.2441C127.74 22.0941 128.67 21.1641 129.82 21.1641C130.97 21.1641 131.9 22.0941 131.9 23.2441V37.5441C131.9 38.6841 130.96 39.6241 129.82 39.6241Z",
96
+ fill: "#B3BAC5"
97
+ }), /*#__PURE__*/React.createElement("path", {
98
+ d: "M107.63 118.355L101.57 112.375L93.26 120.795L99.32 126.775C100.87 128.305 101.95 130.235 102.44 132.345C102.93 134.465 104.01 136.395 105.56 137.915L130.13 162.155C133.85 165.825 139.85 165.785 143.52 162.065C147.19 158.345 147.15 152.345 143.43 148.675L118.86 124.435C117.31 122.905 115.37 121.855 113.24 121.385C111.13 120.935 109.18 119.885 107.63 118.355Z",
99
+ fill: "#CFD4DB"
100
+ }), /*#__PURE__*/React.createElement("path", {
101
+ d: "M107.63 118.355L105.79 116.535C103.46 114.235 99.72 114.265 97.42 116.595C95.12 118.925 95.15 122.665 97.48 124.965L99.32 126.785C100.87 128.315 101.95 130.245 102.44 132.355C102.93 134.475 104.01 136.405 105.56 137.925L130.13 162.165C133.85 165.835 139.85 165.795 143.52 162.075C147.19 158.355 147.15 152.355 143.43 148.685L118.86 124.445C117.31 122.915 115.37 121.865 113.24 121.395C111.13 120.935 109.18 119.885 107.63 118.355Z",
102
+ fill: "url(#paint0_linear_1442_1679)"
103
+ }), /*#__PURE__*/React.createElement("path", {
104
+ d: "M113 121.335C110.98 120.845 109.12 119.815 107.63 118.355L105.79 116.535C103.46 114.235 99.72 114.265 97.42 116.595C95.12 118.925 95.15 122.665 97.48 124.965L99.32 126.785C100.8 128.245 101.85 130.085 102.37 132.105C104.39 130.605 106.31 128.935 108.11 127.115C109.9 125.295 111.53 123.365 113 121.335Z",
105
+ fill: "#B3BAC5"
106
+ }), /*#__PURE__*/React.createElement("path", {
107
+ d: "M66.94 137.126C53.72 137.216 41.26 132.146 31.85 122.866C12.44 103.696 12.23 72.3057 31.39 52.8757C40.67 43.4657 53.07 38.2357 66.28 38.1457C79.5 38.0557 91.96 43.1257 101.37 52.4057C110.78 61.6857 116.01 74.0857 116.1 87.2957C116.19 100.506 111.12 112.976 101.84 122.386C92.55 131.806 80.16 137.036 66.94 137.126ZM39.8 61.1757C32.73 68.3357 28.88 77.8257 28.94 87.8857C29.08 108.656 46.09 125.446 66.87 125.316C76.93 125.246 86.37 121.266 93.44 114.106C100.51 106.946 104.37 97.4557 104.3 87.3957C104.23 77.3357 100.25 67.8957 93.09 60.8257C85.93 53.7557 76.44 49.8957 66.38 49.9657C56.3 50.0357 46.87 54.0157 39.8 61.1757Z",
108
+ fill: "url(#paint1_linear_1442_1679)"
109
+ }), /*#__PURE__*/React.createElement("path", {
110
+ d: "M84.27 75.5345L79.11 70.3345C78.35 69.5645 77.11 69.5645 76.34 70.3245L66.64 79.9545L57.03 70.2545C56.27 69.4845 55.03 69.4845 54.26 70.2445L49.06 75.4045C48.29 76.1645 48.29 77.4045 49.05 78.1745L58.68 87.8745L48.98 97.5045C48.21 98.2645 48.21 99.5045 48.97 100.275L54.13 105.475C54.89 106.245 56.13 106.245 56.9 105.485L66.6 95.8545L76.23 105.555C76.99 106.325 78.23 106.325 79 105.565L84.2 100.405C84.97 99.6445 84.97 98.4045 84.21 97.6345L74.58 87.9345L84.28 78.3045C85.03 77.5345 85.04 76.2945 84.27 75.5345Z",
111
+ fill: "#C1C7D0"
112
+ })), /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("linearGradient", {
113
+ id: "paint0_linear_1442_1679",
114
+ x1: "95.4796",
115
+ y1: "139.562",
116
+ x2: "146.445",
117
+ y2: "140.204",
118
+ gradientUnits: "userSpaceOnUse"
119
+ }, /*#__PURE__*/React.createElement("stop", {
120
+ stopColor: "#B3BAC5"
121
+ }), /*#__PURE__*/React.createElement("stop", {
122
+ offset: "1",
123
+ stopColor: "#DFE1E5",
124
+ stopOpacity: "0.5"
125
+ })), /*#__PURE__*/React.createElement("linearGradient", {
126
+ id: "paint1_linear_1442_1679",
127
+ x1: "31.1877",
128
+ y1: "122.181",
129
+ x2: "102.046",
130
+ y2: "53.0865",
131
+ gradientUnits: "userSpaceOnUse"
132
+ }, /*#__PURE__*/React.createElement("stop", {
133
+ offset: "0.5572",
134
+ stopColor: "#C1C7D0"
135
+ }), /*#__PURE__*/React.createElement("stop", {
136
+ offset: "0.966",
137
+ stopColor: "#E9EBEF",
138
+ stopOpacity: "0.5"
139
+ })), /*#__PURE__*/React.createElement("clipPath", {
140
+ id: "clip0_1442_1679"
141
+ }, /*#__PURE__*/React.createElement("rect", {
142
+ width: "146.22",
143
+ height: "169.36",
144
+ fill: "white",
145
+ transform: "translate(0.0300293 0.875)"
146
+ }))));
147
+ };
@@ -0,0 +1,27 @@
1
+ /** @jsx jsx */
2
+ import { css, jsx } from '@emotion/react';
3
+ import { FormattedMessage } from 'react-intl-next';
4
+ import { Flex, xcss } from '@atlaskit/primitives';
5
+ import { loadingErrorMessages } from './messages';
6
+ import { NoInstancesSvg } from './no-instances-svg';
7
+ const titleStyles = css({
8
+ fontWeight: "var(--ds-font-weight-semibold, 600)",
9
+ fontSize: "var(--ds-font-size-200, 16px)",
10
+ marginTop: "var(--ds-space-200, 16px)"
11
+ });
12
+ const descriptionStyles = css({
13
+ marginTop: "var(--ds-space-100, 8px)"
14
+ });
15
+ const containerStyles = xcss({
16
+ marginTop: '60px'
17
+ });
18
+ export const NoInstancesView = () => jsx(Flex, {
19
+ testId: "no-jira-instances-content",
20
+ direction: "column",
21
+ alignItems: "center",
22
+ xcss: containerStyles
23
+ }, jsx(NoInstancesSvg, null), jsx("span", {
24
+ css: titleStyles
25
+ }, jsx(FormattedMessage, loadingErrorMessages.noAccessToJiraSitesTitle)), jsx("span", {
26
+ css: descriptionStyles
27
+ }, jsx(FormattedMessage, loadingErrorMessages.noAccessToJiraSitesDescription)));
@@ -20,6 +20,7 @@ const AsyncPopupSelect = ({
20
20
  filterType,
21
21
  cloudId,
22
22
  selection,
23
+ isJQLHydrating,
23
24
  onSelectionChange = () => {},
24
25
  onReset: resetSelection = () => {},
25
26
  isDisabled = false
@@ -151,7 +152,6 @@ const AsyncPopupSelect = ({
151
152
  }
152
153
  }, [selectedOptions, selection]);
153
154
  const filterOptionsLength = filterOptions.length;
154
- const isJQLHydrating = false;
155
155
  const isError = status === 'rejected';
156
156
  const isLoading = status === 'loading' || status === 'empty';
157
157
  const isLoadingMore = status === 'loadingMore';
@@ -1,4 +1,4 @@
1
- import React, { forwardRef } from 'react';
1
+ import React, { forwardRef, useCallback } from 'react';
2
2
  import styled from '@emotion/styled';
3
3
  import { FormattedMessage } from 'react-intl-next';
4
4
  import Badge from '@atlaskit/badge';
@@ -38,23 +38,17 @@ const PopupTrigger = /*#__PURE__*/forwardRef(({
38
38
  selectedOptions
39
39
  }, ref) => {
40
40
  const [firstOption] = selectedOptions || [];
41
- const testId = `jlol-basic-filter-${filterType}-trigger`;
42
41
  const hasOptions = selectedOptions && selectedOptions.length > 0;
43
42
  const showButtonLoading = !isDisabled && isLoading;
44
- if (showButtonLoading) {
45
- return /*#__PURE__*/React.createElement(LoadingStateAnimationWrapper, null, /*#__PURE__*/React.createElement(Button, {
46
- iconAfter: /*#__PURE__*/React.createElement(Spinner, {
47
- size: 'xsmall'
48
- }),
49
- testId: testId
50
- }, /*#__PURE__*/React.createElement(FormattedMessage, asyncPopupSelectMessages[`${filterType}Label`])));
51
- }
52
- return /*#__PURE__*/React.createElement(Button, {
53
- ref: ref,
43
+ const LoadingButton = useCallback(() => /*#__PURE__*/React.createElement(LoadingStateAnimationWrapper, null, /*#__PURE__*/React.createElement(Button, {
44
+ iconAfter: /*#__PURE__*/React.createElement(Spinner, {
45
+ size: 'xsmall'
46
+ })
47
+ }, /*#__PURE__*/React.createElement(FormattedMessage, asyncPopupSelectMessages[`${filterType}Label`]))), [filterType]);
48
+ const DefaultButton = useCallback(() => /*#__PURE__*/React.createElement(Button, {
54
49
  appearance: "default",
55
50
  isSelected: isSelected || hasOptions,
56
51
  isDisabled: isDisabled,
57
- testId: testId,
58
52
  iconAfter: /*#__PURE__*/React.createElement(ChevronDownIcon, {
59
53
  label: ""
60
54
  })
@@ -65,6 +59,15 @@ const PopupTrigger = /*#__PURE__*/forwardRef(({
65
59
  alignItems: "center"
66
60
  }, /*#__PURE__*/React.createElement(Badge, {
67
61
  appearance: "primary"
68
- }, "+", selectedOptions.length - 1))));
62
+ }, "+", selectedOptions.length - 1)))), [filterType, firstOption, hasOptions, isDisabled, isSelected, selectedOptions]);
63
+
64
+ /**
65
+ * We had an issue with the popup component referencing a stale DOM ref for the trigger button.
66
+ * Hence introducing a Box to make sure ref is always the same and only content is refreshed on re-renders
67
+ */
68
+ return /*#__PURE__*/React.createElement(Box, {
69
+ ref: ref,
70
+ testId: `jlol-basic-filter-${filterType}-trigger`
71
+ }, showButtonLoading ? /*#__PURE__*/React.createElement(LoadingButton, null) : /*#__PURE__*/React.createElement(DefaultButton, null));
69
72
  });
70
73
  export default PopupTrigger;
@@ -1,47 +1,32 @@
1
- import React, { useCallback, useEffect, useState } from 'react';
1
+ import React from 'react';
2
2
  import { Flex, xcss } from '@atlaskit/primitives';
3
- import { isValidJql } from '../utils';
4
3
  import AsyncPopupSelect from './async-popup-select';
5
- const availableBasicFilterTypes = ['project', 'issuetype', 'status', 'assignee'];
4
+ export const availableBasicFilterTypes = ['project', 'issuetype', 'status', 'assignee'];
6
5
  const basicFilterContainerStyles = xcss({
7
6
  paddingLeft: "var(--ds-space-100, 8px)"
8
7
  });
9
8
  const BasicFilterContainer = ({
10
- jql,
11
9
  cloudId,
12
- onChange
10
+ onChange,
11
+ selections,
12
+ onReset,
13
+ isJQLHydrating
13
14
  }) => {
14
- const [selection, setSelection] = useState({});
15
- useEffect(() => {
16
- if (isValidJql(jql)) {
17
- // hydrate hook call goes in here
18
- }
19
- }, [jql]);
20
- const handleSelectionChange = useCallback((filterType, options) => {
21
- const updatedSelection = {
22
- ...selection,
23
- [filterType]: options
24
- };
25
- setSelection(updatedSelection);
26
- onChange(updatedSelection);
27
- }, [onChange, selection]);
28
- const handleReset = useCallback(() => {
29
- if (Object.keys(selection).length > 0) {
30
- setSelection({});
31
- }
32
- }, [selection]);
33
15
  return /*#__PURE__*/React.createElement(Flex, {
34
16
  xcss: basicFilterContainerStyles,
35
17
  gap: "space.100",
36
18
  testId: "jlol-basic-filter-container"
37
- }, availableBasicFilterTypes.map(filter => /*#__PURE__*/React.createElement(AsyncPopupSelect, {
38
- cloudId: cloudId,
39
- filterType: filter,
40
- key: filter,
41
- selection: selection[filter] || [],
42
- isDisabled: !cloudId,
43
- onSelectionChange: handleSelectionChange,
44
- onReset: handleReset
45
- })));
19
+ }, availableBasicFilterTypes.map(filter => {
20
+ return /*#__PURE__*/React.createElement(AsyncPopupSelect, {
21
+ cloudId: cloudId,
22
+ filterType: filter,
23
+ key: filter,
24
+ selection: selections[filter] || [],
25
+ isJQLHydrating: isJQLHydrating,
26
+ isDisabled: !cloudId,
27
+ onSelectionChange: onChange,
28
+ onReset: onReset
29
+ });
30
+ }));
46
31
  };
47
32
  export default BasicFilterContainer;
@@ -7,6 +7,7 @@ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
7
7
  import { Flex, xcss } from '@atlaskit/primitives';
8
8
  import { useDatasourceAnalyticsEvents } from '../../../analytics';
9
9
  import { BasicFilters } from '../basic-filters';
10
+ import { useHydrateJqlQuery } from '../basic-filters/hooks/useHydrateJqlQuery';
10
11
  import { SEARCH_DEBOUNCE_MS } from '../basic-filters/ui/async-popup-select';
11
12
  import { isQueryTooComplex } from '../basic-filters/utils/isQueryTooComplex';
12
13
  import { BasicSearchInput } from '../basic-search-input';
@@ -49,7 +50,18 @@ export const JiraSearchContainer = props => {
49
50
  const [isComplexQuery, setIsComplexQuery] = useState(false);
50
51
  const [orderKey, setOrderKey] = useState();
51
52
  const [orderDirection, setOrderDirection] = useState();
52
- const [filters, setFilters] = useState({});
53
+ const [filterSelections, setFilterSelections] = useState({});
54
+ const showBasicFilters = useMemo(() => {
55
+ if (getBooleanFF('platform.linking-platform.datasource.show-jlol-basic-filters')) {
56
+ return true;
57
+ }
58
+ return false;
59
+ }, []);
60
+ const {
61
+ hydratedOptions,
62
+ fetchHydratedJqlOptions,
63
+ status: basicFilterHydrationStatus
64
+ } = useHydrateJqlQuery(cloudId || '', jql);
53
65
  const onSearchMethodChange = useCallback(searchMethod => {
54
66
  onSearchMethodChangeCallback(searchMethod);
55
67
  setCurrentSearchMethod(searchMethod);
@@ -59,11 +71,11 @@ export const JiraSearchContainer = props => {
59
71
  setBasicSearchTerm(rawSearch);
60
72
  setJql(buildJQL({
61
73
  rawSearch,
62
- filterValues: filters,
74
+ filterValues: filterSelections,
63
75
  orderDirection,
64
76
  orderKey
65
77
  }));
66
- }, [filters, orderDirection, orderKey]);
78
+ }, [filterSelections, orderDirection, orderKey]);
67
79
  const onQueryChange = useCallback(query => {
68
80
  var _query$split$map$filt, _fragments$at, _fragments$at2, _fragments$at3;
69
81
  // determine if order keys have been set so they can be saved and persisted when changes occur in basic search
@@ -82,14 +94,21 @@ export const JiraSearchContainer = props => {
82
94
  const handleSearch = useCallback(() => {
83
95
  onSearch({
84
96
  jql
85
- }, currentSearchMethod);
86
- setIsComplexQuery(isQueryTooComplex(jql));
97
+ }, {
98
+ searchMethod: currentSearchMethod,
99
+ basicFilterSelections: filterSelections
100
+ });
87
101
  if (currentSearchMethod === 'basic') {
88
102
  fireEvent('ui.form.submitted.basicSearch', {});
89
103
  } else if (currentSearchMethod === 'jql') {
90
104
  fireEvent('ui.jqlEditor.searched', {});
105
+ const isCurrentQueryComplex = isQueryTooComplex(jql);
106
+ setIsComplexQuery(isCurrentQueryComplex);
107
+ if (showBasicFilters && !isCurrentQueryComplex) {
108
+ fetchHydratedJqlOptions();
109
+ }
91
110
  }
92
- }, [currentSearchMethod, fireEvent, jql, onSearch]);
111
+ }, [currentSearchMethod, fetchHydratedJqlOptions, filterSelections, fireEvent, jql, onSearch, showBasicFilters]);
93
112
  const [debouncedBasicFilterSelectionChange] = useDebouncedCallback(filterValues => {
94
113
  const jqlWithFilterValues = buildJQL({
95
114
  rawSearch: basicSearchTerm,
@@ -100,24 +119,44 @@ export const JiraSearchContainer = props => {
100
119
  setJql(jqlWithFilterValues);
101
120
  onSearch({
102
121
  jql: jqlWithFilterValues
103
- }, currentSearchMethod);
122
+ }, {
123
+ searchMethod: currentSearchMethod,
124
+ basicFilterSelections: filterSelections
125
+ });
104
126
  }, SEARCH_DEBOUNCE_MS);
105
127
  const handleBasicFilterSelectionChange = useCallback(filterValues => {
106
- setFilters(filterValues);
128
+ setFilterSelections(filterValues);
107
129
  debouncedBasicFilterSelectionChange(filterValues);
108
130
  }, [debouncedBasicFilterSelectionChange]);
109
131
  useEffect(() => {
110
- setIsComplexQuery(isQueryTooComplex(jql));
132
+ const isCurrentQueryComplex = isQueryTooComplex(jql);
133
+ setIsComplexQuery(isCurrentQueryComplex);
134
+ if (showBasicFilters && !isCurrentQueryComplex && jql !== DEFAULT_JQL_QUERY) {
135
+ fetchHydratedJqlOptions();
136
+ }
111
137
  // eslint-disable-next-line react-hooks/exhaustive-deps
112
138
  }, []);
113
- const showBasicFilters = useMemo(() => {
114
- if (getBooleanFF('platform.linking-platform.datasource.show-jlol-basic-filters')) {
115
- return true;
139
+ useEffect(() => {
140
+ if (basicFilterHydrationStatus === 'resolved') {
141
+ setFilterSelections(hydratedOptions);
116
142
  }
117
- return false;
118
- }, []);
143
+ }, [hydratedOptions, basicFilterHydrationStatus]);
144
+ const handleSelectionChange = useCallback((filterType, options) => {
145
+ const updatedSelection = {
146
+ ...filterSelections,
147
+ [filterType]: options
148
+ };
149
+ setFilterSelections(updatedSelection);
150
+ handleBasicFilterSelectionChange(updatedSelection);
151
+ }, [handleBasicFilterSelectionChange, filterSelections]);
152
+ const handleBasicFiltersReset = useCallback(() => {
153
+ if (Object.keys(filterSelections).length > 0) {
154
+ setFilterSelections({});
155
+ }
156
+ }, [filterSelections]);
119
157
  return jsx("div", {
120
- css: inputContainerStyles
158
+ css: inputContainerStyles,
159
+ "data-testid": "jira-search-container"
121
160
  }, currentSearchMethod === 'basic' && jsx(Flex, {
122
161
  alignItems: "center",
123
162
  xcss: basicSearchInputContainerStyles
@@ -127,9 +166,11 @@ export const JiraSearchContainer = props => {
127
166
  onSearch: handleSearch,
128
167
  searchTerm: basicSearchTerm
129
168
  }), showBasicFilters && jsx(BasicFilters, {
130
- jql: jql,
131
169
  cloudId: cloudId || '',
132
- onChange: handleBasicFilterSelectionChange
170
+ onChange: handleSelectionChange,
171
+ selections: filterSelections,
172
+ onReset: handleBasicFiltersReset,
173
+ isJQLHydrating: basicFilterHydrationStatus === 'loading'
133
174
  })), currentSearchMethod === 'jql' && jsx(JiraJQLEditor, {
134
175
  cloudId: cloudId || '',
135
176
  isSearching: isSearching,