@rh-support/troubleshoot 0.2.108 → 0.2.113

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -19,5 +19,3 @@ export function TroubleshootApp(routeProps: RouteComponentProps<{}>) {
19
19
  </RootTroubleshootProvider>);
20
20
  }
21
21
  ```
22
-
23
- .
@@ -1 +1 @@
1
- {"version":3,"file":"CaseOpenshiftClusterId.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/CaseEditView/Tabs/CaseDetails/CaseOpenshiftClusterId/CaseOpenshiftClusterId.tsx"],"names":[],"mappings":"AAuBA,wBAAgB,sBAAsB,gBAqRrC"}
1
+ {"version":3,"file":"CaseOpenshiftClusterId.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/CaseEditView/Tabs/CaseDetails/CaseOpenshiftClusterId/CaseOpenshiftClusterId.tsx"],"names":[],"mappings":"AAuBA,wBAAgB,sBAAsB,gBA4RrC"}
@@ -55,7 +55,9 @@ export function CaseOpenshiftClusterId() {
55
55
  if (!openshiftClusterID || getIsClusterIdInvalid(openshiftClusterID))
56
56
  return;
57
57
  let openshiftClusterVersion;
58
- if (clusterDetails && clusterDetails.external_id === openshiftClusterID && clusterDetails.openshift_version) {
58
+ if (clusterDetails &&
59
+ clusterDetails.external_cluster_id === openshiftClusterID &&
60
+ clusterDetails.openshift_version) {
59
61
  openshiftClusterVersion = clusterDetails.openshift_version;
60
62
  }
61
63
  else {
@@ -128,7 +130,7 @@ export function CaseOpenshiftClusterId() {
128
130
  }
129
131
  });
130
132
  const onClusterIdSave = (selectedCluster) => __awaiter(this, void 0, void 0, function* () {
131
- const selectedClusterId = selectedCluster === null || selectedCluster === void 0 ? void 0 : selectedCluster.external_id;
133
+ const selectedClusterId = selectedCluster === null || selectedCluster === void 0 ? void 0 : selectedCluster.external_cluster_id;
132
134
  if (isEmpty(selectedClusterId))
133
135
  return;
134
136
  setLocalOpenshiftClusterIDState(selectedClusterId);
@@ -1 +1 @@
1
- {"version":3,"file":"ProductVersion.d.ts","sourceRoot":"","sources":["../../../../../../src/components/CaseEditView/Tabs/CaseDetails/ProductVersion.tsx"],"names":[],"mappings":"AAsBA,UAAU,MAAM;IACZ,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACvC;AAYD,iBAAS,eAAe,CAAC,KAAK,EAAE,MAAM,eAkOrC;AAED,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"ProductVersion.d.ts","sourceRoot":"","sources":["../../../../../../src/components/CaseEditView/Tabs/CaseDetails/ProductVersion.tsx"],"names":[],"mappings":"AAsBA,UAAU,MAAM;IACZ,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACvC;AAYD,iBAAS,eAAe,CAAC,KAAK,EAAE,MAAM,eA0PrC;AAED,eAAe,eAAe,CAAC"}
@@ -16,7 +16,7 @@ import findIndex from 'lodash/findIndex';
16
16
  import isEmpty from 'lodash/isEmpty';
17
17
  import isEqual from 'lodash/isEqual';
18
18
  import uniq from 'lodash/uniq';
19
- import React, { useContext, useEffect, useState } from 'react';
19
+ import React, { useContext, useEffect, useMemo, useState } from 'react';
20
20
  import { Trans, useTranslation } from 'react-i18next';
21
21
  import { useCaseDispatch, useCaseSelector } from '../../../../context/CaseContext';
22
22
  import { getVersionsDetails, updateCaseDetails } from '../../../../reducers/CaseReducer';
@@ -33,19 +33,29 @@ function ProductNVersion(props) {
33
33
  const [versions, setVersions] = useState([]);
34
34
  const [isProductUpdating, setIsProductUpdating] = useState(false);
35
35
  const [isVersionUpdating, setIsVersionUpdating] = useState(false);
36
- const { product, version, caseNumber, contactSSOName } = useCaseSelector((state) => ({
36
+ const { product, version, caseNumber, contactSSOName, versionsDetails } = useCaseSelector((state) => ({
37
37
  product: state.caseDetails.product,
38
38
  version: state.caseDetails.version,
39
39
  contactSSOName: state.caseDetails.contactSSOName,
40
40
  caseNumber: state.caseDetails.caseNumber,
41
+ versionsDetails: state.versionsDetails,
41
42
  }), isEqual);
43
+ const productVenisons = useMemo(() => versionsDetails.data.map(({ name }) => name),
44
+ // eslint-disable-next-line react-hooks/exhaustive-deps
45
+ [product, versionsDetails.data]);
42
46
  const caseDispatch = useCaseDispatch();
43
47
  const dispatchToGlobalMetadataReducer = useContext(GlobalMetadataDispatchContext);
44
48
  const { globalMetadataState: { allProducts }, } = useContext(GlobalMetadataStateContext);
49
+ const productSEVersions = useMemo(() => getVersions(allProducts.data.productsResult, product), [allProducts.data.productsResult, product]);
45
50
  const [isProductInValid, setIsProductInValid] = useState(false);
46
51
  const [selectedProductLocal, setSelectedProductLocal] = useState(product);
47
52
  const [selectedVersionLocal, setSelectedVersionLocal] = useState(version);
48
53
  const canEditCase = useCanEditCase();
54
+ useEffect(() => {
55
+ setVersions(productVenisons);
56
+ if ((productVenisons === null || productVenisons === void 0 ? void 0 : productVenisons.length) && !selectedVersionLocal)
57
+ setSelectedVersionLocal(productVenisons[0]);
58
+ }, [productVenisons, selectedVersionLocal]);
49
59
  /**
50
60
  * Sync local version from global state if they change from someplace else
51
61
  */
@@ -53,17 +63,20 @@ function ProductNVersion(props) {
53
63
  setSelectedVersionLocal(version);
54
64
  }, [version]);
55
65
  useEffect(() => {
66
+ var _a;
56
67
  if (haventLoadedMetadata(allProducts, (data) => isEmpty(data.productsResult))) {
57
68
  fetchProducts(dispatchToGlobalMetadataReducer, contactSSOName);
58
69
  }
59
- if (allProducts.data && allProducts.data.productsResult.length !== 0) {
60
- const versions = getVersions(allProducts.data.productsResult, product);
70
+ if (allProducts.data && ((_a = allProducts.data.productsResult) === null || _a === void 0 ? void 0 : _a.length) !== 0) {
71
+ const productSEVersions = getVersions(allProducts.data.productsResult, product);
72
+ const versions = (productSEVersions === null || productSEVersions === void 0 ? void 0 : productSEVersions.length) ? productSEVersions : productVenisons;
61
73
  setVersions(versions);
62
74
  }
63
75
  setSelectedProductLocal(product);
64
76
  // eslint-disable-next-line react-hooks/exhaustive-deps
65
77
  }, [allProducts, product, dispatchToGlobalMetadataReducer, contactSSOName]);
66
78
  const onProductChange = (option) => __awaiter(this, void 0, void 0, function* () {
79
+ var _a, _b, _c;
67
80
  if (canEditCase.alert())
68
81
  return;
69
82
  validateProduct(option);
@@ -72,8 +85,8 @@ function ProductNVersion(props) {
72
85
  if (!option.value.product) {
73
86
  return;
74
87
  }
75
- const hasSingleVersion = option.value.versions.length < 2;
76
- setVersions(option.value.versions);
88
+ const hasSingleVersion = ((_b = (_a = option === null || option === void 0 ? void 0 : option.value) === null || _a === void 0 ? void 0 : _a.versions) === null || _b === void 0 ? void 0 : _b.length) < 2;
89
+ setVersions((_c = option === null || option === void 0 ? void 0 : option.value) === null || _c === void 0 ? void 0 : _c.versions);
77
90
  if (hasSingleVersion) {
78
91
  setIsProductUpdating(true);
79
92
  setIsVersionUpdating(true);
@@ -95,6 +108,14 @@ function ProductNVersion(props) {
95
108
  ToastNotification.addDangerMessage(t(`Product and Version failed to update`));
96
109
  }
97
110
  }
111
+ else {
112
+ setIsVersionUpdating(true);
113
+ try {
114
+ yield getVersionsDetails(caseDispatch, option.value.product);
115
+ }
116
+ catch (e) { }
117
+ setIsVersionUpdating(false);
118
+ }
98
119
  });
99
120
  let previousProduct = usePrevious(selectedProductLocal);
100
121
  const onVersionChange = (option) => __awaiter(this, void 0, void 0, function* () {
@@ -161,7 +182,7 @@ function ProductNVersion(props) {
161
182
  }, [caseDispatch, product]);
162
183
  return (React.createElement(React.Fragment, null,
163
184
  React.createElement(AlertMessage, { show: !allProducts.isFetching && allProducts.isError, title: t('There was an error loading products.'), variant: AlertType.DANGER }),
164
- isEmpty(selectedVersionLocal) && !(versions.length < 2) && (React.createElement(Alert, { isInline: true, className: "pf-u-mb-md", variant: AlertVariant.danger, title: React.createElement(Trans, null, "Please clear the errors to change the product on your case") })),
185
+ isEmpty(selectedVersionLocal) && !((selectedVersionLocal === null || selectedVersionLocal === void 0 ? void 0 : selectedVersionLocal.length) < 2) && (React.createElement(Alert, { isInline: true, className: "pf-u-mb-md", variant: AlertVariant.danger, title: React.createElement(Trans, null, "Please clear the errors to change the product on your case") })),
165
186
  React.createElement(React.Fragment, null,
166
187
  React.createElement("div", { className: "form-group all-product-selector-dropdown" },
167
188
  React.createElement("div", { className: "product-selector-wrapper" },
@@ -169,7 +190,7 @@ function ProductNVersion(props) {
169
190
  React.createElement(Trans, null, "Product")),
170
191
  React.createElement(Dropdown, { className: "open-case-product", placeholder: t('Select a product'), id: "case-details-product-selector", selectedItem: toOption({
171
192
  product: selectedProductLocal,
172
- versions: getVersions(allProducts.data.productsResult, product),
193
+ versions: (productSEVersions === null || productSEVersions === void 0 ? void 0 : productSEVersions.length) ? productSEVersions : productVenisons,
173
194
  featuredVersion: '',
174
195
  selectedVersion: selectedVersionLocal,
175
196
  isTopProduct: checkIsTopProduct(allProducts.data.productsResult, product),
@@ -179,7 +200,7 @@ function ProductNVersion(props) {
179
200
  React.createElement("label", { htmlFor: "version-dropdown" },
180
201
  React.createElement(Trans, null, "Version")),
181
202
  React.createElement(Dropdown, { className: "open-case-version", id: "version-dropdown", selectedItem: toOption(selectedVersionLocal), list: toOptions(uniq(versions)), title: t(`Select a version`), isInValid: isEmpty(selectedVersionLocal), disabled: isVersionUpdating ||
182
- versions.length < 2 ||
203
+ (selectedVersionLocal === null || selectedVersionLocal === void 0 ? void 0 : selectedVersionLocal.length) < 2 ||
183
204
  (allProducts.isFetching && !allProducts.isError), onChange: onVersionChange, isLoadingList: isVersionUpdating, "data-tracking-id": "case-details-version-selector" }))))));
184
205
  }
185
206
  export default ProductNVersion;
@@ -1 +1 @@
1
- {"version":3,"file":"Cep.d.ts","sourceRoot":"","sources":["../../../../src/components/CaseManagement/Cep.tsx"],"names":[],"mappings":"AAyBA,UAAU,MAAM;CAAG;AAEnB,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,eAuRhC"}
1
+ {"version":3,"file":"Cep.d.ts","sourceRoot":"","sources":["../../../../src/components/CaseManagement/Cep.tsx"],"names":[],"mappings":"AAyBA,UAAU,MAAM;CAAG;AAEnB,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,eA4RhC"}
@@ -46,6 +46,9 @@ export function Cep(props) {
46
46
  useEffect(() => {
47
47
  setCepDetailsLocal(cepDetails);
48
48
  }, [cepDetails]);
49
+ const clearCepForm = () => {
50
+ setCepDetailsLocal(cepDetails);
51
+ };
49
52
  const onCepChange = (e) => __awaiter(this, void 0, void 0, function* () {
50
53
  if (canEditCase.alert())
51
54
  return;
@@ -61,6 +64,7 @@ export function Cep(props) {
61
64
  description: t('Are you sure?'),
62
65
  });
63
66
  cepUpdate({ cep: false });
67
+ clearCepForm();
64
68
  }
65
69
  else {
66
70
  setCaseDetails(caseDispatch, { cep: false });
@@ -153,13 +157,13 @@ export function Cep(props) {
153
157
  React.createElement(Trans, null, "Contact information"),
154
158
  "\u00A0",
155
159
  React.createElement("span", { className: "form-required", "aria-hidden": true }, "*")),
156
- React.createElement(TextAreaResizable, { id: "cep-contactInformation", className: `form-control`, "aria-required": true, required: true, maxLength: 2000, name: "cep-contactInformation", value: cepDetailsLocal.contactInformation, onChange: onCepContactInformationsChange, "aria-label": "auto resizing text area example", isSpaceAllowed: false, autoResize: true }),
160
+ React.createElement(TextAreaResizable, { id: "cep-contactInformation", className: `form-control`, "aria-required": true, isRequired: true, maxLength: 2000, name: "cep-contactInformation", value: cepDetailsLocal.contactInformation, onChange: onCepContactInformationsChange, "aria-label": "auto resizing text area example", isSpaceAllowed: false, autoResize: true }),
157
161
  React.createElement("p", { className: "form-instructions" },
158
162
  React.createElement(Trans, null, "Please provide phone number, chat ID or email."))),
159
163
  React.createElement("div", { className: "form-group" },
160
164
  React.createElement("label", { htmlFor: "cep-notes" },
161
165
  React.createElement(Trans, null, "Notes")),
162
- React.createElement(TextAreaResizable, { id: "cep-notes", className: `form-control`, "aria-required": true, required: true, maxLength: 2000, name: "cep-notese", value: cepDetailsLocal.notes, onChange: onCepNotesChange, isSpaceAllowed: false, autoResize: true }),
166
+ React.createElement(TextAreaResizable, { id: "cep-notes", className: `form-control`, "aria-required": false, isRequired: false, maxLength: 2000, name: "cep-notese", value: cepDetailsLocal.notes, onChange: onCepNotesChange, isSpaceAllowed: false, autoResize: true }),
163
167
  React.createElement("p", { className: "form-instructions" },
164
168
  React.createElement(Trans, null, "Provide any pertinent information that Red Hat Support should be aware of that's not already captured in the issue statement or comments.")))))));
165
169
  }
@@ -1 +1 @@
1
- {"version":3,"file":"OpenShiftClusterId.d.ts","sourceRoot":"","sources":["../../../../src/components/CaseManagement/OpenShiftClusterId.tsx"],"names":[],"mappings":"AAwBA,eAAO,MAAM,oBAAoB,mBAShC,CAAC;AAEF,eAAO,MAAM,uBAAuB,mBAInC,CAAC;AAEF,eAAO,MAAM,4BAA4B,mBAKxC,CAAC;AAEF,eAAO,MAAM,qBAAqB,mBAIjC,CAAC;AAEF,wBAAgB,kBAAkB,gBA6RjC"}
1
+ {"version":3,"file":"OpenShiftClusterId.d.ts","sourceRoot":"","sources":["../../../../src/components/CaseManagement/OpenShiftClusterId.tsx"],"names":[],"mappings":"AAwBA,eAAO,MAAM,oBAAoB,mBAShC,CAAC;AAEF,eAAO,MAAM,uBAAuB,mBAInC,CAAC;AAEF,eAAO,MAAM,4BAA4B,mBAKxC,CAAC;AAEF,eAAO,MAAM,qBAAqB,mBAIjC,CAAC;AAEF,wBAAgB,kBAAkB,gBAoSjC"}
@@ -96,7 +96,9 @@ export function OpenShiftClusterId() {
96
96
  if (!openshiftClusterID || getIsClusterIdInvalid(openshiftClusterID))
97
97
  return;
98
98
  let openshiftClusterVersion;
99
- if (clusterDetails && clusterDetails.external_id === openshiftClusterID && clusterDetails.openshift_version) {
99
+ if (clusterDetails &&
100
+ clusterDetails.external_cluster_id === openshiftClusterID &&
101
+ clusterDetails.openshift_version) {
100
102
  openshiftClusterVersion = clusterDetails.openshift_version;
101
103
  }
102
104
  else {
@@ -163,7 +165,7 @@ export function OpenShiftClusterId() {
163
165
  // eslint-disable-next-line react-hooks/exhaustive-deps
164
166
  }, [noClusterIdReason]);
165
167
  const onClusterIdStateUpdate = (selectedCluster) => {
166
- const selectedId = selectedCluster.external_id;
168
+ const selectedId = selectedCluster === null || selectedCluster === void 0 ? void 0 : selectedCluster.external_cluster_id;
167
169
  if (isEmpty(selectedId))
168
170
  return;
169
171
  resetClusterData();
@@ -1,8 +1,8 @@
1
- import { ICluster } from '@rh-support/api';
1
+ import { IClusterSubscription } from '@cee-eng/hydrajs/@types/models/cloud';
2
2
  import { IDClassNameProps } from '@rh-support/types/shared';
3
3
  interface IProps extends IDClassNameProps {
4
4
  openshiftClusterIDState: string;
5
- onClusterIdStateUpdate: (cluster: Partial<ICluster>, value?: string) => void;
5
+ onClusterIdStateUpdate: (cluster: Partial<IClusterSubscription>, value?: string) => void;
6
6
  isClusterIdInvalid: boolean;
7
7
  clusterIdDropdownFormInstructions?: JSX.Element;
8
8
  onClusterClear: () => void;
@@ -10,7 +10,7 @@ interface IProps extends IDClassNameProps {
10
10
  isDisabled?: boolean;
11
11
  noClusterIdReasonExplanation?: string;
12
12
  }
13
- declare const fetchClusterIdDetails: (clusterId: string) => Promise<ICluster>;
13
+ declare const fetchClusterIdDetails: (clusterId: string) => Promise<import("@cee-eng/hydrajs/@types/models/cloud").ICluster>;
14
14
  declare function OpenshiftDropdownV4(props: IProps): JSX.Element;
15
15
  declare namespace OpenshiftDropdownV4 {
16
16
  var defaultProps: {};
@@ -1 +1 @@
1
- {"version":3,"file":"OpenshiftDropdownV4.d.ts","sourceRoot":"","sources":["../../../../src/components/CaseManagement/OpenshiftDropdownV4.tsx"],"names":[],"mappings":"AACA,OAAO,EAAsB,QAAQ,EAAqB,MAAM,iBAAiB,CAAC;AAElF,OAAO,EAAE,gBAAgB,EAAuB,MAAM,0BAA0B,CAAC;AAUjF,UAAU,MAAO,SAAQ,gBAAgB;IACrC,uBAAuB,EAAE,MAAM,CAAC;IAChC,sBAAsB,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7E,kBAAkB,EAAE,OAAO,CAAC;IAC5B,iCAAiC,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IAChD,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,IAAI,EAAE,OAAO,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,4BAA4B,CAAC,EAAE,MAAM,CAAC;CACzC;AAcD,QAAA,MAAM,qBAAqB,cAAqB,MAAM,sBASrD,CAAC;AAeF,iBAAS,mBAAmB,CAAC,KAAK,EAAE,MAAM,eA6OzC;kBA7OQ,mBAAmB;;;AAgP5B,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,CAAC"}
1
+ {"version":3,"file":"OpenshiftDropdownV4.d.ts","sourceRoot":"","sources":["../../../../src/components/CaseManagement/OpenshiftDropdownV4.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAgC,MAAM,sCAAsC,CAAC;AAE1G,OAAO,EAAE,gBAAgB,EAAuB,MAAM,0BAA0B,CAAC;AAWjF,UAAU,MAAO,SAAQ,gBAAgB;IACrC,uBAAuB,EAAE,MAAM,CAAC;IAChC,sBAAsB,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,oBAAoB,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACzF,kBAAkB,EAAE,OAAO,CAAC;IAC5B,iCAAiC,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IAChD,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,IAAI,EAAE,OAAO,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,4BAA4B,CAAC,EAAE,MAAM,CAAC;CACzC;AAQD,QAAA,MAAM,qBAAqB,cAAqB,MAAM,qEASrD,CAAC;AAeF,iBAAS,mBAAmB,CAAC,KAAK,EAAE,MAAM,eAwTzC;kBAxTQ,mBAAmB;;;AA2T5B,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,CAAC"}
@@ -7,10 +7,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { Divider, Select, SelectOption, SelectVariant } from '@patternfly/react-core';
11
- import { getAccountClusters } from '@rh-support/api';
12
- import { useFetch } from '@rh-support/components';
10
+ import { cloud } from '@cee-eng/hydrajs';
11
+ import { Checkbox, Divider, Select, SelectOption, SelectVariant } from '@patternfly/react-core';
13
12
  import find from 'lodash/find';
13
+ import findIndex from 'lodash/findIndex';
14
14
  import groupBy from 'lodash/groupBy';
15
15
  import isEmpty from 'lodash/isEmpty';
16
16
  import React, { useEffect, useRef, useState } from 'react';
@@ -24,19 +24,19 @@ const defaultProps = {
24
24
  };
25
25
  const fetchClusterIdDetails = (clusterId) => __awaiter(void 0, void 0, void 0, function* () {
26
26
  try {
27
- const clustersResponse = yield getAccountClusters({
27
+ const clustersResponse = yield cloud.getAccountClusters({
28
28
  order: 'display_name asc',
29
- search: `external_id ILIKE '%${clusterId}%'`,
29
+ search: `external_id ILIKE '%${clusterId}%'`,
30
30
  });
31
31
  const clusterDetails = (clustersResponse.items || []).find((item) => item.external_id === clusterId);
32
32
  return clusterDetails;
33
33
  }
34
34
  catch (e) { }
35
35
  });
36
- const createState = (external_id, display_name) => {
36
+ const createState = (external_cluster_id, display_name) => {
37
37
  return {
38
38
  display_name,
39
- external_id,
39
+ external_cluster_id,
40
40
  toString: () => display_name || '',
41
41
  compareTo: function (value) {
42
42
  const displayName = this.toString().toLowerCase();
@@ -47,47 +47,65 @@ const createState = (external_id, display_name) => {
47
47
  };
48
48
  function OpenshiftDropdownV4(props) {
49
49
  const { t } = useTranslation();
50
- const PER_PAGE = 200;
51
- const { request: getAccountClustersRequest, isFetching: isFetchingClusters } = useFetch(getAccountClusters, {
52
- propgateErrors: true,
53
- });
50
+ const PER_PAGE = 20;
54
51
  const [clustersRawResponse, setClustersRawResponse] = useState([]);
55
52
  const abortControllerRef = useRef(undefined);
56
53
  const [clustersSelectOptions, setClustersSelectOptions] = useState([]);
57
54
  const [isOpen, setIsOpen] = useState(false);
58
55
  const [validated, setValidated] = useState('default');
59
56
  const [inputVal, setInputVal] = useState('');
57
+ const [showArchivedClusters, setShowArchivedClusters] = useState(false);
58
+ const [isFetchingClusters, setIsFetchingClusters] = useState(false);
59
+ const [totalResultsNo, setTotalResultsNo] = useState(0);
60
60
  // gets a cluster id and returns display name
61
- const getDisplayNameById = (clusters, id) => {
61
+ const getDisplayNameById = (clusters, id, noClusterIdReasonExplanation) => {
62
62
  if (isEmpty(id))
63
63
  return '';
64
- if (id === 'dont-have-id')
65
- return t("I don't have my Cluster ID");
64
+ if (id === 'dont-have-id') {
65
+ return noClusterIdReasonExplanation === 'v3-cluster'
66
+ ? t('The case is for a v3 cluster')
67
+ : t("I don't have my Cluster ID");
68
+ }
66
69
  if (id === 'v3-cluster')
67
70
  return t('The case is for a v3 cluster');
68
- const cluster = find(clusters, (o) => o.external_id === id);
71
+ const cluster = find(clusters, (o) => o.external_cluster_id === id);
69
72
  return isEmpty(cluster) ? id : getDisplayNameForCluster(cluster);
70
73
  };
71
74
  const onDropdownClear = () => __awaiter(this, void 0, void 0, function* () {
72
75
  setIsOpen(false);
73
76
  setInputVal('');
74
77
  props.onClusterClear();
78
+ const fetchedClusters = yield fetchAccountClusters();
79
+ setClustersRawResponse(fetchedClusters.items);
80
+ setTotalResultsNo(fetchedClusters.total);
81
+ setClustersSelectOptions(getClusterOptions(fetchedClusters.items));
75
82
  });
76
83
  const onToggle = (isOpen) => setIsOpen(isOpen);
77
84
  const onViewMoreClick = () => __awaiter(this, void 0, void 0, function* () {
78
- const fetchedClusters = yield fetchAccountClusters();
79
- const clusterResponse = [...clustersRawResponse, ...fetchedClusters.items];
85
+ const page = Math.floor(clustersRawResponse.length / PER_PAGE) + 1;
86
+ const fetchedClusters = yield fetchAccountClusters(inputVal, page);
87
+ const clusterResponse = [...clustersRawResponse, ...((fetchedClusters === null || fetchedClusters === void 0 ? void 0 : fetchedClusters.items) || [])];
80
88
  setClustersRawResponse(clusterResponse);
89
+ setTotalResultsNo(fetchedClusters.total);
81
90
  setClustersSelectOptions(getClusterOptions(clusterResponse));
82
91
  });
83
92
  const onSelect = (event, selectedCluster) => __awaiter(this, void 0, void 0, function* () {
84
93
  setInputVal('');
85
- props.onClusterIdStateUpdate(selectedCluster);
86
- setIsOpen(false);
94
+ if (event.target.tagName !== 'BUTTON') {
95
+ // checkbox is clicked
96
+ setShowArchivedClusters(!showArchivedClusters);
97
+ // reset
98
+ props.onClusterClear();
99
+ setClustersRawResponse([]);
100
+ }
101
+ else {
102
+ props.onClusterIdStateUpdate(selectedCluster);
103
+ setIsOpen(false);
104
+ }
87
105
  });
88
106
  const getClusterOptions = (clusters) => {
89
107
  const clustersResponseGrouped = groupBy(clusters, 'dns.base_domain') || [];
90
- const domainNames = Object.keys(clustersResponseGrouped);
108
+ const domainNames = Object.keys(clustersResponseGrouped) || [];
91
109
  // move undefined to the end of domains array
92
110
  const undefinedIndex = domainNames.findIndex((i) => i === 'undefined');
93
111
  if (undefinedIndex !== -1 && undefinedIndex !== domainNames.length - 1) {
@@ -100,23 +118,28 @@ function OpenshiftDropdownV4(props) {
100
118
  domainNames.forEach((domain, index) => {
101
119
  domain !== 'undefined' &&
102
120
  clusterOptions.push(React.createElement(SelectOption, { isDisabled: true, className: "pf-u-font-weight-bold pf-u-color-400", value: createState(domain, domain), key: domain + index }));
103
- clustersResponseGrouped[domain].forEach((cluster, i) => {
104
- clusterOptions.push(React.createElement(SelectOption, { key: i + cluster.external_id, value: createState(cluster.external_id, cluster.display_name) }));
105
- });
121
+ clustersResponseGrouped[domain] &&
122
+ clustersResponseGrouped[domain].forEach((cluster, i) => {
123
+ clusterOptions.push(React.createElement(SelectOption, { key: cluster.external_cluster_id, value: createState(cluster.external_cluster_id, cluster.display_name) }));
124
+ });
106
125
  clusterOptions.push(React.createElement(Divider, { component: "div", key: index + domain }));
107
126
  });
108
127
  return [
109
- ...clusterOptions,
128
+ React.createElement(SelectOption, { key: 'show-hide-archived-clusters', inputId: "check-box" },
129
+ React.createElement(Checkbox, { label: t('Show archived clusters'), key: "show-archived-clusters", "aria-label": t('Show archived clusters'), id: "show-archived-clusters", "data-tracking-id": "show-hide-archived-clusters", isChecked: showArchivedClusters, className: "archived-clusters-checkbox" })),
130
+ React.createElement(Divider, { component: "div", key: 'cluster-id-options-divider-e' }),
131
+ React.createElement(SelectOption, { key: 'dont-have-id', value: createState('dont-have-id', t("I don't have my Cluster ID")) }),
110
132
  ...(!props.isV4
111
133
  ? [
112
134
  React.createElement(SelectOption, { key: 'v3-cluster', value: createState('v3-cluster', t('The case is for a v3 cluster')) }),
113
135
  ]
114
136
  : []),
115
- React.createElement(SelectOption, { key: 'dont-have-id', value: createState('dont-have-id', t("I don't have my Cluster ID")) }),
137
+ ...(clusterOptions.length !== 0 ? [React.createElement(Divider, { component: "div", key: 'cluster-id-options-divider' })] : []),
138
+ ...clusterOptions,
116
139
  ];
117
140
  };
118
- const fetchAccountClusters = (search = '') => __awaiter(this, void 0, void 0, function* () {
119
- const page = Math.floor(clustersRawResponse.length / PER_PAGE) + 1;
141
+ const fetchAccountClusters = (search = '', page = 0) => __awaiter(this, void 0, void 0, function* () {
142
+ setIsFetchingClusters(true);
120
143
  try {
121
144
  if (abortControllerRef.current !== undefined) {
122
145
  // Cancel the previous request
@@ -126,26 +149,56 @@ function OpenshiftDropdownV4(props) {
126
149
  let controller = new AbortController();
127
150
  abortControllerRef.current = controller;
128
151
  // query language: https://github.com/yaacov/tree-search-language
129
- const clustersResponse = yield getAccountClustersRequest({
152
+ const clustersResponse = yield cloud.getAccountClustersSubscription({
130
153
  order: 'display_name asc',
131
154
  page,
132
155
  size: PER_PAGE,
133
- search: `external_id ILIKE '%${search}%' OR display_name ILIKE '%${search}%' OR dns.base_domain ILIKE '%${search}%'`,
156
+ search: `${showArchivedClusters ? '' : "status!='Archived'"} ${search && !showArchivedClusters ? 'AND' : ''} ${search ? `(external_cluster_id ILIKE '%${search}%' OR display_name ILIKE '%${search}%')` : ''}`,
157
+ fields: 'external_cluster_id,display_name,status,metrics.openshift_version',
134
158
  }, controller.signal);
135
- const items = clustersResponse.items.map((item) => ({
136
- display_name: getDisplayNameForCluster(item),
137
- external_id: item.external_id,
138
- dns: item.dns,
139
- }));
159
+ const items = clustersResponse.items
160
+ .filter((c) => !isEmpty(c.external_cluster_id))
161
+ .map((item) => {
162
+ var _a, _b;
163
+ return ({
164
+ display_name: getDisplayNameForCluster(item),
165
+ external_cluster_id: item.external_cluster_id,
166
+ openshift_version: ((_b = (_a = item === null || item === void 0 ? void 0 : item.metrics) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.openshift_version) || '',
167
+ });
168
+ });
169
+ try {
170
+ // old api has dns info
171
+ // new api doesn't have dns info but we can exclude archived clusters
172
+ // call old api get all clusters and call new api get limitted number of clusters
173
+ // then add dns info to the new api response
174
+ const promiseArray = clustersResponse.items.map((cluster) => cloud.getAccountClusters({
175
+ order: 'display_name asc',
176
+ search: `external_id='${cluster.external_cluster_id}' OR display_name='${cluster.external_cluster_id}'`,
177
+ }, controller.signal));
178
+ const oldApiResponse = yield Promise.allSettled(promiseArray);
179
+ oldApiResponse.forEach((response) => {
180
+ var _a, _b;
181
+ if (response.status === 'fulfilled' && ((_b = (_a = response.value) === null || _a === void 0 ? void 0 : _a.items) === null || _b === void 0 ? void 0 : _b[0].dns)) {
182
+ var index = findIndex(items, { external_cluster_id: response.value.items[0].external_id });
183
+ items[index] = Object.assign(Object.assign({}, items[index]), { dns: response.value.items[0].dns });
184
+ }
185
+ });
186
+ }
187
+ catch (e) {
188
+ // silently fails
189
+ }
190
+ setIsFetchingClusters(false);
140
191
  return {
141
192
  items,
142
- totalResult: clustersResponse.total,
143
- page: clustersResponse.page,
193
+ totalResult: items.length,
194
+ page,
195
+ total: clustersResponse.total,
144
196
  };
145
197
  }
146
198
  catch (e) {
147
199
  // silently fails
148
- return { items: [], totalResult: 0, page: 0 };
200
+ setIsFetchingClusters(false);
201
+ return { items: [], totalResult: 0, page: 0, total: 0 };
149
202
  }
150
203
  });
151
204
  // need to get clusters on load
@@ -154,10 +207,11 @@ function OpenshiftDropdownV4(props) {
154
207
  useEffect(() => {
155
208
  let isUnmounted = false;
156
209
  const fetchClusters = () => __awaiter(this, void 0, void 0, function* () {
157
- const fetchedClusters = yield fetchAccountClusters();
210
+ const fetchedClusters = yield fetchAccountClusters(inputVal);
158
211
  if (!isUnmounted) {
159
- setClustersSelectOptions(getClusterOptions(fetchedClusters.items));
160
212
  setClustersRawResponse(fetchedClusters.items);
213
+ setTotalResultsNo(fetchedClusters.total);
214
+ setClustersSelectOptions(getClusterOptions(fetchedClusters.items));
161
215
  }
162
216
  });
163
217
  fetchClusters();
@@ -165,7 +219,7 @@ function OpenshiftDropdownV4(props) {
165
219
  isUnmounted = true;
166
220
  };
167
221
  // eslint-disable-next-line react-hooks/exhaustive-deps
168
- }, [props.isV4]);
222
+ }, [props.isV4, showArchivedClusters]);
169
223
  useEffect(() => {
170
224
  if (props.isClusterIdInvalid) {
171
225
  setValidated('error');
@@ -178,15 +232,16 @@ function OpenshiftDropdownV4(props) {
178
232
  setInputVal(input);
179
233
  props.onClusterIdStateUpdate(createState(input, input));
180
234
  const fetchedClusters = yield fetchAccountClusters(input);
181
- setClustersSelectOptions(getClusterOptions(fetchedClusters.items));
182
235
  setClustersRawResponse(fetchedClusters.items);
236
+ setTotalResultsNo(fetchedClusters.total);
237
+ setClustersSelectOptions(getClusterOptions(fetchedClusters.items));
183
238
  });
184
239
  const getSelectedItem = () => {
185
240
  if (!isEmpty(inputVal)) {
186
241
  return createState(props.openshiftClusterIDState, inputVal);
187
242
  }
188
243
  else {
189
- return createState(props.openshiftClusterIDState, getDisplayNameById(clustersRawResponse, props.openshiftClusterIDState));
244
+ return createState(props.openshiftClusterIDState, getDisplayNameById(clustersRawResponse, props.openshiftClusterIDState, props.noClusterIdReasonExplanation));
190
245
  }
191
246
  };
192
247
  const titleId = 'case-details-cluster-nickname-selector';
@@ -197,8 +252,8 @@ function OpenshiftDropdownV4(props) {
197
252
  React.createElement("span", { className: "form-required", "aria-hidden": true }, "*"),
198
253
  React.createElement(CaseOpenShiftPopover, null)),
199
254
  React.createElement("span", { id: titleId, hidden: true }, "Select a state"),
200
- React.createElement(Select, Object.assign({ variant: SelectVariant.typeahead, isDisabled: props.isDisabled, typeAheadAriaLabel: t('Search by Cluster ID, alias, and domain or manually enter your Cluster ID'), onToggle: onToggle, onSelect: onSelect, onClear: onDropdownClear, selections: getSelectedItem(), isOpen: isOpen, "aria-labelledby": titleId, placeholderText: t('Search by Cluster ID, alias, and domain or manually enter your Cluster ID'), hasInlineFilter: false, onTypeaheadInputChanged: onTypeaheadInputChanged, onFilter: () => undefined, validated: validated, "aria-invalid": props.isClusterIdInvalid, "aria-describedby": "clusterID-validate-helper", required: true }, (isFetchingClusters && { loadingVariant: 'spinner' }), (!isFetchingClusters &&
201
- PER_PAGE <= clustersRawResponse.length && {
255
+ React.createElement(Select, Object.assign({ variant: SelectVariant.typeahead, isDisabled: props.isDisabled, typeAheadAriaLabel: t('Search by Cluster ID and alias or manually enter your Cluster ID'), onToggle: onToggle, onSelect: onSelect, onClear: onDropdownClear, selections: getSelectedItem(), isOpen: isOpen, "aria-labelledby": titleId, placeholderText: t('Search by Cluster ID and alias or manually enter your Cluster ID'), hasInlineFilter: false, onTypeaheadInputChanged: onTypeaheadInputChanged, onFilter: () => undefined, validated: validated, "aria-invalid": props.isClusterIdInvalid, "aria-describedby": "clusterID-validate-helper", required: true }, (isFetchingClusters && { loadingVariant: 'spinner' }), (!isFetchingClusters &&
256
+ clustersRawResponse.length < totalResultsNo && {
202
257
  loadingVariant: {
203
258
  text: 'Display additional results',
204
259
  onClick: onViewMoreClick,
@@ -31,6 +31,10 @@ button,
31
31
  font-size: 14px;
32
32
  }
33
33
 
34
+ .archived-clusters-checkbox {
35
+ grid-gap: 0px;
36
+ }
37
+
34
38
  .case-details-tabs .case-details-tabs-content {
35
39
  background-color: #f0f0f0;
36
40
  margin-left: -1.8rem;
@@ -1,7 +1,7 @@
1
+ import { IClusterSubscriptionExtended } from '@cee-eng/hydrajs/@types/models/cloud';
1
2
  import { ISEProduct } from '@cee-eng/hydrajs/@types/models/product';
2
- import { ICluster } from '@rh-support/api';
3
- export declare const getDisplayNameById: (clusters: Partial<ICluster>[], id: string) => string;
4
- export declare const getDisplayNameForCluster: (cluster: Partial<ICluster>) => string;
3
+ export declare const getDisplayNameById: (clusters: Partial<IClusterSubscriptionExtended>[], id: string) => string;
4
+ export declare const getDisplayNameForCluster: (cluster: Partial<IClusterSubscriptionExtended>) => string;
5
5
  export declare const invalidGuidHelperText = "Please enter a valid Cluster ID (For example: d3aa88e2-c754-41e0-8ba6-4198a34aa0a2)";
6
6
  export declare const isClusterIdEnabledForProduct: (selectedProduct: string, allProducts: Partial<ISEProduct>[]) => boolean;
7
7
  export declare const isOpenShiftV3Product: (product: string, pcmConfig: any) => boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"caseOpenshiftClusterIdUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/caseOpenshiftClusterIdUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAM3C,eAAO,MAAM,kBAAkB,aAAc,QAAQ,QAAQ,CAAC,EAAE,MAAM,MAAM,WAI3E,CAAC;AAEF,eAAO,MAAM,wBAAwB,YAAa,QAAQ,QAAQ,CAAC,WAIlE,CAAC;AAEF,eAAO,MAAM,qBAAqB,wFACuD,CAAC;AAE1F,eAAO,MAAM,4BAA4B,oBAAqB,MAAM,eAAe,QAAQ,UAAU,CAAC,EAAE,YAIvG,CAAC;AAEF,eAAO,MAAM,oBAAoB,YAAa,MAAM,4BAenD,CAAC;AAEF,eAAO,MAAM,qBAAqB,sCACkC,CAAC"}
1
+ {"version":3,"file":"caseOpenshiftClusterIdUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/caseOpenshiftClusterIdUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAMpE,eAAO,MAAM,kBAAkB,aAAc,QAAQ,4BAA4B,CAAC,EAAE,MAAM,MAAM,WAI/F,CAAC;AAEF,eAAO,MAAM,wBAAwB,YAAa,QAAQ,4BAA4B,CAAC,WAKtF,CAAC;AAEF,eAAO,MAAM,qBAAqB,wFACuD,CAAC;AAE1F,eAAO,MAAM,4BAA4B,oBAAqB,MAAM,eAAe,QAAQ,UAAU,CAAC,EAAE,YAIvG,CAAC;AAEF,eAAO,MAAM,oBAAoB,YAAa,MAAM,4BAenD,CAAC;AAEF,eAAO,MAAM,qBAAqB,sCACkC,CAAC"}
@@ -5,15 +5,16 @@ import isEmpty from 'lodash/isEmpty';
5
5
  export const getDisplayNameById = (clusters, id) => {
6
6
  if (isEmpty(id))
7
7
  return '';
8
- const cluster = find(clusters, (o) => o.external_id === id);
8
+ const cluster = find(clusters, (o) => o.external_cluster_id === id);
9
9
  return isEmpty(cluster) ? `${id}` : cluster.display_name;
10
10
  };
11
11
  export const getDisplayNameForCluster = (cluster) => {
12
12
  if (isEmpty(cluster))
13
13
  return '';
14
- if (isEmpty(cluster.display_name) || cluster.display_name === cluster.external_id)
15
- return `${cluster.external_id}`;
16
- return `${cluster.external_id} <${cluster.display_name}>`;
14
+ const clusterId = (cluster === null || cluster === void 0 ? void 0 : cluster.external_cluster_id) || cluster.external_id;
15
+ if (isEmpty(cluster.display_name) || cluster.display_name === clusterId)
16
+ return clusterId;
17
+ return `${clusterId} <${cluster.display_name}>`;
17
18
  };
18
19
  export const invalidGuidHelperText = 'Please enter a valid Cluster ID (For example: d3aa88e2-c754-41e0-8ba6-4198a34aa0a2)';
19
20
  export const isClusterIdEnabledForProduct = (selectedProduct, allProducts) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/troubleshoot",
3
- "version": "0.2.108",
3
+ "version": "0.2.113",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -26,7 +26,7 @@
26
26
  "lib/**/*"
27
27
  ],
28
28
  "peerDependencies": {
29
- "@cee-eng/hydrajs": "4.10.0",
29
+ "@cee-eng/hydrajs": "4.10.2",
30
30
  "@cee-eng/ui-toolkit": "1.1.6",
31
31
  "@patternfly/patternfly": "4.185.1",
32
32
  "@patternfly/pfe-accordion": "1.12.3",
@@ -63,7 +63,7 @@
63
63
  "react-virtualized": "^9.21.2"
64
64
  },
65
65
  "dependencies": {
66
- "@cee-eng/hydrajs": "4.10.0",
66
+ "@cee-eng/hydrajs": "4.10.2",
67
67
  "@cee-eng/ui-toolkit": "1.1.6",
68
68
  "@patternfly/patternfly": "4.185.1",
69
69
  "@patternfly/pfe-accordion": "1.12.3",
@@ -73,12 +73,12 @@
73
73
  "@patternfly/react-core": "4.202.16",
74
74
  "@progress/kendo-drawing": "^1.6.0",
75
75
  "@progress/kendo-react-pdf": "^3.12.0",
76
- "@rh-support/api": "0.3.18",
77
- "@rh-support/components": "1.1.62",
78
- "@rh-support/react-context": "0.2.64",
79
- "@rh-support/types": "0.3.0",
80
- "@rh-support/user-permissions": "0.2.50",
81
- "@rh-support/utils": "0.2.39",
76
+ "@rh-support/api": "0.3.21",
77
+ "@rh-support/components": "1.1.68",
78
+ "@rh-support/react-context": "0.2.72",
79
+ "@rh-support/types": "0.2.0",
80
+ "@rh-support/user-permissions": "0.2.57",
81
+ "@rh-support/utils": "0.2.43",
82
82
  "@types/react-redux": "^7.1.12",
83
83
  "@types/redux": "^3.6.0",
84
84
  "@webcomponents/webcomponentsjs": "^2.2.10",
@@ -143,5 +143,5 @@
143
143
  "not ie <= 11",
144
144
  "not op_mini all"
145
145
  ],
146
- "gitHead": "d079ee3127aa11ae00fa9febdf6519e9005140df"
146
+ "gitHead": "6bbb463984ea647a4be39bc7dd259dc3d8ecbf8d"
147
147
  }