@rh-support/troubleshoot 0.2.102 → 0.2.104

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":"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;AAYjF,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,eA4TzC;kBA5TQ,mBAAmB;;;AA+T5B,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;AAYjF,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,eA0TzC;kBA1TQ,mBAAmB;;;AA6T5B,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,CAAC"}
@@ -48,7 +48,7 @@ const createState = (external_cluster_id, display_name) => {
48
48
  };
49
49
  function OpenshiftDropdownV4(props) {
50
50
  const { t } = useTranslation();
51
- const OLD_API_PER_PAGE_GET_ALL = 5000;
51
+ const OLD_API_PER_PAGE_GET_ALL = 10000;
52
52
  const PER_PAGE = 200;
53
53
  const [clustersRawResponse, setClustersRawResponse] = useState([]);
54
54
  const abortControllerRef = useRef(undefined);
@@ -58,6 +58,7 @@ function OpenshiftDropdownV4(props) {
58
58
  const [inputVal, setInputVal] = useState('');
59
59
  const [showArchivedClusters, setShowArchivedClusters] = useState(false);
60
60
  const [isFetchingClusters, setIsFetchingClusters] = useState(false);
61
+ const [totalResultsNo, setTotalResultsNo] = useState(0);
61
62
  // gets a cluster id and returns display name
62
63
  const getDisplayNameById = (clusters, id, noClusterIdReasonExplanation) => {
63
64
  if (isEmpty(id))
@@ -80,8 +81,9 @@ function OpenshiftDropdownV4(props) {
80
81
  const onToggle = (isOpen) => setIsOpen(isOpen);
81
82
  const onViewMoreClick = () => __awaiter(this, void 0, void 0, function* () {
82
83
  const fetchedClusters = yield fetchAccountClusters(inputVal);
83
- const clusterResponse = [...clustersRawResponse, ...fetchedClusters.items];
84
+ const clusterResponse = [...clustersRawResponse, ...((fetchedClusters === null || fetchedClusters === void 0 ? void 0 : fetchedClusters.items) || [])];
84
85
  setClustersRawResponse(clusterResponse);
86
+ setTotalResultsNo(fetchedClusters.total);
85
87
  setClustersSelectOptions(getClusterOptions(clusterResponse));
86
88
  });
87
89
  const onSelect = (event, selectedCluster) => __awaiter(this, void 0, void 0, function* () {
@@ -100,7 +102,7 @@ function OpenshiftDropdownV4(props) {
100
102
  });
101
103
  const getClusterOptions = (clusters) => {
102
104
  const clustersResponseGrouped = groupBy(clusters, 'dns.base_domain') || [];
103
- const domainNames = Object.keys(clustersResponseGrouped);
105
+ const domainNames = Object.keys(clustersResponseGrouped) || [];
104
106
  // move undefined to the end of domains array
105
107
  const undefinedIndex = domainNames.findIndex((i) => i === 'undefined');
106
108
  if (undefinedIndex !== -1 && undefinedIndex !== domainNames.length - 1) {
@@ -113,9 +115,10 @@ function OpenshiftDropdownV4(props) {
113
115
  domainNames.forEach((domain, index) => {
114
116
  domain !== 'undefined' &&
115
117
  clusterOptions.push(React.createElement(SelectOption, { isDisabled: true, className: "pf-u-font-weight-bold pf-u-color-400", value: createState(domain, domain), key: domain + index }));
116
- clustersResponseGrouped[domain].forEach((cluster, i) => {
117
- clusterOptions.push(React.createElement(SelectOption, { key: cluster.external_cluster_id, value: createState(cluster.external_cluster_id, cluster.display_name) }));
118
- });
118
+ clustersResponseGrouped[domain] &&
119
+ clustersResponseGrouped[domain].forEach((cluster, i) => {
120
+ clusterOptions.push(React.createElement(SelectOption, { key: cluster.external_cluster_id, value: createState(cluster.external_cluster_id, cluster.display_name) }));
121
+ });
119
122
  clusterOptions.push(React.createElement(Divider, { component: "div", key: index + domain }));
120
123
  });
121
124
  return [
@@ -145,50 +148,43 @@ function OpenshiftDropdownV4(props) {
145
148
  let controller = new AbortController();
146
149
  abortControllerRef.current = controller;
147
150
  let clustersResponse;
151
+ let total;
148
152
  // query language: https://github.com/yaacov/tree-search-language
149
- // old api has dns info but we cannot exclude archived clusters
153
+ // old api has dns info
150
154
  // new api doesn't have dns info but we can exclude archived clusters
151
- if (showArchivedClusters) {
152
- // call old api
153
- clustersResponse = yield cloud.getAccountClusters({
155
+ // call old api get all clusters and call new api get limitted number of clusters
156
+ // then add dns info to the new api response
157
+ const clustersResponses = yield Promise.allSettled([
158
+ cloud.getAccountClustersSubscription({
154
159
  order: 'display_name asc',
155
160
  page,
156
161
  size: PER_PAGE,
162
+ search: `${showArchivedClusters ? '' : "status!='Archived' AND "} (external_cluster_id ILIKE '%${search}%' OR display_name ILIKE '%${search}%')`,
163
+ fields: 'external_cluster_id,display_name,status,metrics.openshift_version',
164
+ }, controller.signal),
165
+ cloud.getAccountClusters({
166
+ order: 'display_name asc',
167
+ page: 1,
168
+ size: OLD_API_PER_PAGE_GET_ALL,
157
169
  search: `external_id ILIKE '%${search}%' OR display_name ILIKE '%${search}%' OR dns.base_domain ILIKE '%${search}%'`,
158
- }, controller.signal);
159
- clustersResponse = clustersResponse.items;
170
+ }, controller.signal),
171
+ ]);
172
+ if (clustersResponses[0].status === 'fulfilled' && clustersResponses[1].status === 'fulfilled') {
173
+ const newApi = ((_a = clustersResponses[0].value) === null || _a === void 0 ? void 0 : _a.items) || [];
174
+ const oldApi = ((_b = clustersResponses[1].value) === null || _b === void 0 ? void 0 : _b.items) || [];
175
+ clustersResponse = map(newApi, function (item) {
176
+ return merge(item, find(oldApi, { external_id: item.external_cluster_id }));
177
+ });
178
+ total = clustersResponses[0].value.total;
179
+ }
180
+ else if (clustersResponses[0].status === 'fulfilled' && clustersResponses[1].status === 'rejected') {
181
+ // old api used only for getting dns info therefore if fails still we have clusterIds
182
+ clustersResponse = clustersResponses[0].value.items;
183
+ total = clustersResponses[0].value.total;
160
184
  }
161
185
  else {
162
- // call old api get all clusters and call new api get limitted number of clusters
163
- // then add dns info to the new api response
164
- const clustersResponses = yield Promise.allSettled([
165
- cloud.getAccountClustersSubscription({
166
- order: 'display_name asc',
167
- page,
168
- size: PER_PAGE,
169
- search: `${showArchivedClusters ? '' : "status!='Archived' AND "} (external_cluster_id ILIKE '%${search}%' OR display_name ILIKE '%${search}%')`,
170
- fields: 'external_cluster_id,display_name,status,metrics.openshift_version',
171
- }, controller.signal),
172
- cloud.getAccountClusters({
173
- order: 'display_name asc',
174
- page: 1,
175
- size: OLD_API_PER_PAGE_GET_ALL,
176
- search: `external_id ILIKE '%${search}%' OR display_name ILIKE '%${search}%' OR dns.base_domain ILIKE '%${search}%'`,
177
- }, controller.signal),
178
- ]);
179
- if (clustersResponses[0].status === 'fulfilled' && clustersResponses[1].status === 'fulfilled') {
180
- const newApi = ((_a = clustersResponses[0].value) === null || _a === void 0 ? void 0 : _a.items) || [];
181
- const oldApi = ((_b = clustersResponses[1].value) === null || _b === void 0 ? void 0 : _b.items) || [];
182
- clustersResponse = map(newApi, function (item) {
183
- return merge(item, find(oldApi, { external_id: item.external_cluster_id }));
184
- });
185
- }
186
- else if (clustersResponses[0].status === 'fulfilled' && clustersResponses[1].status === 'rejected') {
187
- clustersResponse = clustersResponses[0].value.items;
188
- }
189
- else {
190
- clustersResponse = [];
191
- }
186
+ clustersResponse = [];
187
+ total = 0;
192
188
  }
193
189
  const items = clustersResponse.map((item) => {
194
190
  var _a, _b;
@@ -204,12 +200,13 @@ function OpenshiftDropdownV4(props) {
204
200
  items,
205
201
  totalResult: clustersResponse.length,
206
202
  page,
203
+ total,
207
204
  };
208
205
  }
209
206
  catch (e) {
210
207
  // silently fails
211
208
  setIsFetchingClusters(false);
212
- return { items: [], totalResult: 0, page: 0 };
209
+ return { items: [], totalResult: 0, page: 0, total: 0 };
213
210
  }
214
211
  });
215
212
  // need to get clusters on load
@@ -220,8 +217,9 @@ function OpenshiftDropdownV4(props) {
220
217
  const fetchClusters = () => __awaiter(this, void 0, void 0, function* () {
221
218
  const fetchedClusters = yield fetchAccountClusters(inputVal);
222
219
  if (!isUnmounted) {
223
- setClustersSelectOptions(getClusterOptions(fetchedClusters.items));
224
220
  setClustersRawResponse(fetchedClusters.items);
221
+ setTotalResultsNo(fetchedClusters.total);
222
+ setClustersSelectOptions(getClusterOptions(fetchedClusters.items));
225
223
  }
226
224
  });
227
225
  fetchClusters();
@@ -242,8 +240,9 @@ function OpenshiftDropdownV4(props) {
242
240
  setInputVal(input);
243
241
  props.onClusterIdStateUpdate(createState(input, input));
244
242
  const fetchedClusters = yield fetchAccountClusters(input);
245
- setClustersSelectOptions(getClusterOptions(fetchedClusters.items));
246
243
  setClustersRawResponse(fetchedClusters.items);
244
+ setTotalResultsNo(fetchedClusters.total);
245
+ setClustersSelectOptions(getClusterOptions(fetchedClusters.items));
247
246
  });
248
247
  const getSelectedItem = () => {
249
248
  if (!isEmpty(inputVal)) {
@@ -262,7 +261,7 @@ function OpenshiftDropdownV4(props) {
262
261
  React.createElement(CaseOpenShiftPopover, null)),
263
262
  React.createElement("span", { id: titleId, hidden: true }, "Select a state"),
264
263
  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 &&
265
- PER_PAGE <= clustersRawResponse.length && {
264
+ clustersRawResponse.length < totalResultsNo && {
266
265
  loadingVariant: {
267
266
  text: 'Display additional results',
268
267
  onClick: onViewMoreClick,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/troubleshoot",
3
- "version": "0.2.102",
3
+ "version": "0.2.104",
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": "82a2161f34c47eeb658bec78e6af2eff79a61b2f"
146
+ "gitHead": "f2b203085e179115277901c8d155d7c72f7f152e"
147
147
  }