@rh-support/troubleshoot 0.2.119 → 0.2.120

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.
@@ -1 +1 @@
1
- {"version":3,"file":"OpenshiftDropdownV4.d.ts","sourceRoot":"","sources":["../../../../src/components/CaseManagement/OpenshiftDropdownV4.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAG5E,OAAO,EAAE,gBAAgB,EAAuB,MAAM,0BAA0B,CAAC;AAcjF,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;IACtC,oBAAoB,CAAC,EAAE,MAAM,CAAC;CACjC;AAuBD,iBAAS,mBAAmB,CAAC,KAAK,EAAE,MAAM,eAiXzC;kBAjXQ,mBAAmB;;;AAoX5B,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
1
+ {"version":3,"file":"OpenshiftDropdownV4.d.ts","sourceRoot":"","sources":["../../../../src/components/CaseManagement/OpenshiftDropdownV4.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAG5E,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,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;IACtC,oBAAoB,CAAC,EAAE,MAAM,CAAC;CACjC;AAuBD,iBAAS,mBAAmB,CAAC,KAAK,EAAE,MAAM,eA6WzC;kBA7WQ,mBAAmB;;;AAgX5B,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
@@ -15,7 +15,7 @@ import groupBy from 'lodash/groupBy';
15
15
  import isEmpty from 'lodash/isEmpty';
16
16
  import React, { useEffect, useMemo, useRef, useState } from 'react';
17
17
  import { Trans, useTranslation } from 'react-i18next';
18
- import { getDisplayNameForCluster, getIsClusterIdInvalid, } from '../../utils/caseOpenshiftClusterIdUtils';
18
+ import { getDisplayNameForCluster } from '../../utils/caseOpenshiftClusterIdUtils';
19
19
  import CaseOpenShiftPopover from '../CaseEditView/Tabs/CaseDetails/CaseOpenshiftClusterId/CaseOpenShiftPopover';
20
20
  const defaultProps = {
21
21
  className: '',
@@ -48,7 +48,7 @@ function OpenshiftDropdownV4(props) {
48
48
  const [showArchivedClusters, setShowArchivedClusters] = useState(false);
49
49
  const [isFetchingClusters, setIsFetchingClusters] = useState(false);
50
50
  const [totalResultsNo, setTotalResultsNo] = useState(0);
51
- const { getFromCache, setInCache } = useLRUCache(25);
51
+ const { getFromCache, setInCache } = useLRUCache(50);
52
52
  // gets a cluster id and returns display name
53
53
  const getDisplayName = (id, noClusterIdReasonExplanation, display_name) => {
54
54
  if (isEmpty(id))
@@ -136,10 +136,12 @@ function OpenshiftDropdownV4(props) {
136
136
  };
137
137
  const fetchAClusterIdDetails = (clusterId) => __awaiter(this, void 0, void 0, function* () {
138
138
  var _a;
139
+ if (isEmpty(clusterId))
140
+ return {};
139
141
  setIsFetchingClusters(true);
140
142
  try {
141
143
  const clustersResponse = yield cloud.getAccountClustersSubscription({
142
- search: `external_cluster_id='${clusterId}'`,
144
+ search: `external_cluster_id='${clusterId.trim()}'`,
143
145
  fields: 'external_cluster_id,display_name,status,metrics.openshift_version',
144
146
  });
145
147
  setIsFetchingClusters(false);
@@ -157,6 +159,7 @@ function OpenshiftDropdownV4(props) {
157
159
  }
158
160
  });
159
161
  const fetchAccountClusters = (search = '', page = 0) => __awaiter(this, void 0, void 0, function* () {
162
+ search = search.trim();
160
163
  setIsFetchingClusters(true);
161
164
  try {
162
165
  let clustersResponse;
@@ -176,7 +179,7 @@ function OpenshiftDropdownV4(props) {
176
179
  order: 'display_name asc',
177
180
  page,
178
181
  size: PER_PAGE,
179
- search: `${showArchivedClusters ? '' : "status!='Archived'"} ${search && !showArchivedClusters ? 'AND' : ''} ${search
182
+ search: `external_cluster_id!='' AND ${showArchivedClusters ? '' : "status!='Archived'"} ${search && !showArchivedClusters ? 'AND' : ''} ${search
180
183
  ? `(external_cluster_id ILIKE '%${search}%' OR display_name ILIKE '%${search}%' OR console_url ILIKE '%${search}%')`
181
184
  : ''}`,
182
185
  fields: 'external_cluster_id,display_name,status,metrics.openshift_version,console_url',
@@ -184,9 +187,7 @@ function OpenshiftDropdownV4(props) {
184
187
  setInCache(`showArchived=${showArchivedClusters}input=${search}p=${page}`, clustersResponse);
185
188
  }
186
189
  setIsFetchingClusters(false);
187
- const items = clustersResponse.items
188
- .filter((c) => !isEmpty(c.external_cluster_id))
189
- .map((item) => {
190
+ const items = clustersResponse.items.map((item) => {
190
191
  var _a, _b;
191
192
  return ({
192
193
  display_name: item.display_name,
@@ -214,7 +215,7 @@ function OpenshiftDropdownV4(props) {
214
215
  // we have clusterId but need to get display name
215
216
  useEffect(() => {
216
217
  const getClusterDetails = () => __awaiter(this, void 0, void 0, function* () {
217
- if (props.openshiftClusterIDState &&
218
+ if (!isEmpty(props.openshiftClusterIDState) &&
218
219
  props.openshiftClusterIDState !== 'dont-have-id' &&
219
220
  props.openshiftClusterIDState !== 'v3-cluster' &&
220
221
  isEmpty(props.openshiftDisplayName)) {
@@ -260,20 +261,13 @@ function OpenshiftDropdownV4(props) {
260
261
  // when user type or paste a clusterId we land here
261
262
  const onTypeaheadInputChanged = (input) => __awaiter(this, void 0, void 0, function* () {
262
263
  setInputVal(input);
263
- if (getIsClusterIdInvalid(input)) {
264
- const fetchedClusters = yield fetchAccountClusters(input);
265
- setClustersRawResponse(fetchedClusters.items);
266
- setTotalResultsNo(fetchedClusters.total);
267
- setClustersSelectOptions(getClusterOptions(fetchedClusters.items));
268
- props.onClusterIdStateUpdate({ external_cluster_id: input });
269
- }
270
- else {
271
- // user paste a valid cluster id
272
- const fetchedCluster = yield fetchAClusterIdDetails(input);
273
- props.onClusterIdStateUpdate(fetchedCluster);
274
- }
264
+ const fetchedClusters = yield fetchAccountClusters(input);
265
+ setClustersRawResponse(fetchedClusters.items);
266
+ setTotalResultsNo(fetchedClusters.total);
267
+ setClustersSelectOptions(getClusterOptions(fetchedClusters.items));
268
+ props.onClusterIdStateUpdate({ external_cluster_id: input });
275
269
  });
276
- const debounceFn = debounce(onTypeaheadInputChanged, 1000);
270
+ const debounceFn = debounce(onTypeaheadInputChanged, 500);
277
271
  const getSelectedItem = () => {
278
272
  if (!isEmpty(inputVal)) {
279
273
  return createState(props.openshiftClusterIDState, inputVal);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/troubleshoot",
3
- "version": "0.2.119",
3
+ "version": "0.2.120",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -143,5 +143,5 @@
143
143
  "not ie <= 11",
144
144
  "not op_mini all"
145
145
  ],
146
- "gitHead": "1d8c25adcf1bc30eb2560bf210f96994b63237e3"
146
+ "gitHead": "403aee29c2ee4be4cadb20fb74753c495803d387"
147
147
  }