@rh-support/cases 2.6.191 → 2.6.194

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":"GroupsFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/GroupsFilter.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAUrD,OAAO,KAA2D,MAAM,OAAO,CAAC;AAShF,MAAM,WAAW,iBAAiB;IAC9B,qFAAqF;IACrF,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;IAC1C,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,KAAK,IAAI,CAAC;IAC5D,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAID,wBAAgB,YAAY,CAAC,EACzB,cAAc,EAAE,wBAAwB,EACxC,cAAc,EACd,SAAiB,EACjB,QAAmC,EACnC,uBAA+B,EAC/B,WAAW,EAAE,eAAe,GAC/B,GAAE,iBAAsB,qBAuTxB"}
1
+ {"version":3,"file":"GroupsFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/case-list/case-list-filters/GroupsFilter.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAKrD,OAAO,KAA2D,MAAM,OAAO,CAAC;AAShF,MAAM,WAAW,iBAAiB;IAC9B,qFAAqF;IACrF,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;IAC1C,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,KAAK,IAAI,CAAC;IAC5D,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAID,wBAAgB,YAAY,CAAC,EACzB,cAAc,EAAE,wBAAwB,EACxC,cAAc,EACd,SAAiB,EACjB,QAAmC,EACnC,uBAA+B,EAC/B,WAAW,EAAE,eAAe,GAC/B,GAAE,iBAAsB,qBA+RxB"}
@@ -1,8 +1,8 @@
1
- import { useApolloClient } from '@apollo/client/react';
2
1
  import { Badge, Button, MenuFooter, MenuToggle, Select, SelectList, SelectOption, TextInputGroup, TextInputGroupMain, TextInputGroupUtilities, } from '@patternfly/react-core';
3
2
  import TimesIcon from '@patternfly/react-icons/dist/js/icons/times-icon';
3
+ import { GlobalMetadataStateContext } from '@rh-support/react-context';
4
4
  import { ability, resourceActions, resources } from '@rh-support/user-permissions';
5
- import { GET_CASE_GROUP, getDropdownBtnPlaceholder, handleGraphQLCaseGroupsResponse, } from '@rh-support/utils';
5
+ import { getDropdownBtnPlaceholder } from '@rh-support/utils';
6
6
  import isEmpty from 'lodash/isEmpty';
7
7
  import isUndefined from 'lodash/isUndefined';
8
8
  import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
@@ -14,9 +14,8 @@ import { CaseListFilterDispatchContext, CaseListFilterStateContext } from '../Ca
14
14
  import { updateFilter } from '../CaseListFilterReducer';
15
15
  const EMPTY_GROUPS = [];
16
16
  export function GroupsFilter({ selectedGroups: controlledSelectedGroups, onGroupsChange, hideLabel = false, idPrefix = 'case-list-group-filter', showSelectionCountBadge = false, placeholder: placeholderProp, } = {}) {
17
- var _a;
17
+ var _a, _b;
18
18
  const { t } = useTranslation();
19
- const apolloClient = useApolloClient();
20
19
  const { filterInfo } = useContext(CaseListFilterStateContext);
21
20
  const dispatch = useContext(CaseListFilterDispatchContext);
22
21
  const isControlled = typeof onGroupsChange === 'function';
@@ -25,31 +24,12 @@ export function GroupsFilter({ selectedGroups: controlledSelectedGroups, onGroup
25
24
  const selectedGroups = isControlled
26
25
  ? controlledSelectedGroups || EMPTY_GROUPS
27
26
  : (_a = filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrKeys.group]) !== null && _a !== void 0 ? _a : EMPTY_GROUPS;
27
+ const { globalMetadataState: { caseGroups }, } = useContext(GlobalMetadataStateContext);
28
+ const isLoading = caseGroups.isFetching;
28
29
  const [inputValue, setInputValue] = useState('');
29
- const [caseGroups, setCaseGroups] = useState([]);
30
- const [isLoading, setIsLoading] = useState(false);
31
30
  const [focusedItemIndex, setFocusedItemIndex] = useState(null);
32
31
  const [activeItem, setActiveItem] = useState(null);
33
- useEffect(() => {
34
- setIsLoading(true);
35
- apolloClient
36
- .query({
37
- query: GET_CASE_GROUP,
38
- fetchPolicy: 'cache-first',
39
- })
40
- .then(({ data }) => {
41
- var _a, _b, _c, _d;
42
- const edges = (_d = (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.redhat_support_uiapi) === null || _a === void 0 ? void 0 : _a.query) === null || _b === void 0 ? void 0 : _b.RedHatSupportCaseGroup__c) === null || _c === void 0 ? void 0 : _c.edges) !== null && _d !== void 0 ? _d : [];
43
- setCaseGroups(handleGraphQLCaseGroupsResponse(edges));
44
- })
45
- .catch((err) => {
46
- console.error('[GroupsFilter] Failed to fetch case groups:', err);
47
- setCaseGroups([]);
48
- })
49
- .finally(() => setIsLoading(false));
50
- // eslint-disable-next-line react-hooks/exhaustive-deps
51
- }, []);
52
- const list = useMemo(() => caseGroups.map((group) => ({ value: group.name, key: group.groupNum })), [caseGroups]);
32
+ const list = useMemo(() => (caseGroups.data || []).map((group) => ({ value: group.name, key: group.groupNum })), [caseGroups.data]);
53
33
  const [selectOptions, setSelectOptions] = useState(list);
54
34
  const canViewManageTab = ability.can(resourceActions.READ, resources.MANAGE);
55
35
  const canViewCaseGroups = ability.can(resourceActions.READ, resources.CASE_GROUPS) && canViewManageTab;
@@ -153,7 +133,7 @@ export function GroupsFilter({ selectedGroups: controlledSelectedGroups, onGroup
153
133
  ? isLoading
154
134
  ? t('Loading...')
155
135
  : defaultEmptyPlaceholder
156
- : getDropdownBtnPlaceholder(isLoading ? t('Loading...') : defaultEmptyPlaceholder, selectedGroups, '', caseGroups.length, t('All selected'));
136
+ : getDropdownBtnPlaceholder(isLoading ? t('Loading...') : defaultEmptyPlaceholder, selectedGroups, '', ((_b = caseGroups.data) === null || _b === void 0 ? void 0 : _b.length) || 0, t('All selected'));
157
137
  const hasSelectedGroups = selectedGroups.length > 0;
158
138
  const onClick = () => {
159
139
  var _a;
@@ -187,12 +167,7 @@ export function GroupsFilter({ selectedGroups: controlledSelectedGroups, onGroup
187
167
  setFocusedItemIndex(null);
188
168
  setActiveItem(null);
189
169
  // eslint-disable-next-line react-hooks/exhaustive-deps
190
- }, [inputValue]);
191
- useEffect(() => {
192
- if (!inputValue) {
193
- setSelectOptions(list);
194
- }
195
- }, [list, inputValue]);
170
+ }, [inputValue, list]);
196
171
  useEffect(() => {
197
172
  if (isEmpty(selectedGroups)) {
198
173
  setSelectedItems({});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/cases",
3
- "version": "2.6.191",
3
+ "version": "2.6.194",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -38,11 +38,11 @@
38
38
  "@patternfly/patternfly": "6.2.1",
39
39
  "@patternfly/react-core": "6.2.1",
40
40
  "@patternfly/react-table": "6.2.1",
41
- "@rh-support/components": "2.5.187",
42
- "@rh-support/react-context": "2.5.281",
41
+ "@rh-support/components": "2.5.190",
42
+ "@rh-support/react-context": "2.5.284",
43
43
  "@rh-support/types": "2.0.26",
44
- "@rh-support/user-permissions": "2.5.133",
45
- "@rh-support/utils": "2.5.115",
44
+ "@rh-support/user-permissions": "2.5.136",
45
+ "@rh-support/utils": "2.5.118",
46
46
  "localforage": "^1.10.0",
47
47
  "lodash": "^4.17.21",
48
48
  "pegjs": "^0.10.0",
@@ -92,5 +92,5 @@
92
92
  "defaults and supports es6-module",
93
93
  "maintained node versions"
94
94
  ],
95
- "gitHead": "62de68194f68d9d3546ff5e6569d2d5137609e8e"
95
+ "gitHead": "9017d17207b6357a27edbab889de8f10696e745b"
96
96
  }