@rh-support/cases 2.7.20 → 2.7.21
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/lib/esm/components/case-list/CaseList.d.ts.map +1 -1
- package/lib/esm/components/case-list/CaseList.js +33 -16
- package/lib/esm/hooks/useFilterStateOnLoad.d.ts +1 -1
- package/lib/esm/hooks/useFilterStateOnLoad.d.ts.map +1 -1
- package/lib/esm/hooks/useFilterStateOnLoad.js +7 -6
- package/lib/esm/utils/caseGroupDefaultFilterUtils.d.ts +11 -3
- package/lib/esm/utils/caseGroupDefaultFilterUtils.d.ts.map +1 -1
- package/lib/esm/utils/caseGroupDefaultFilterUtils.js +31 -3
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CaseList.d.ts","sourceRoot":"","sources":["../../../../src/components/case-list/CaseList.tsx"],"names":[],"mappings":"AAAA,OAAO,wBAAwB,CAAC;AAChC,OAAO,0BAA0B,CAAC;AAuClC,OAAO,
|
|
1
|
+
{"version":3,"file":"CaseList.d.ts","sourceRoot":"","sources":["../../../../src/components/case-list/CaseList.tsx"],"names":[],"mappings":"AAAA,OAAO,wBAAwB,CAAC;AAChC,OAAO,0BAA0B,CAAC;AAuClC,OAAO,KAA+D,MAAM,OAAO,CAAC;AAGpF,OAAO,EAAE,mBAAmB,EAAe,MAAM,kBAAkB,CAAC;AAEpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,IAAI,CAAC;AA2C1C,UAAU,MAAM;IACZ,UAAU,EAAE,mBAAmB,CAAC,oBAAoB,CAAC,CAAC;CACzD;AAMD,MAAM,WAAW,gBAAgB;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAAC;CAChC;AAED,MAAM,WAAW,aAAa;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,qBA6yBrC"}
|
|
@@ -18,7 +18,7 @@ import { getStringifiedParams, getUrlParsedParams, haventLoadedMetadata, haventL
|
|
|
18
18
|
import isEmpty from 'lodash/isEmpty';
|
|
19
19
|
import isEqual from 'lodash/isEqual';
|
|
20
20
|
import some from 'lodash/some';
|
|
21
|
-
import React, { useContext, useEffect, useRef, useState } from 'react';
|
|
21
|
+
import React, { useCallback, useContext, useEffect, useRef, useState } from 'react';
|
|
22
22
|
import { Trans, useTranslation } from 'react-i18next';
|
|
23
23
|
import { useInView } from 'react-intersection-observer';
|
|
24
24
|
import { useLocation } from 'react-router-dom';
|
|
@@ -27,7 +27,7 @@ import { SolrKeys } from '../../enums/filters';
|
|
|
27
27
|
import { PageTitle } from '../../enums/pageTitle';
|
|
28
28
|
import { useCaseLabels } from '../../hooks/useCaseLabels';
|
|
29
29
|
import { useFilterStateOnLoad } from '../../hooks/useFilterStateOnLoad';
|
|
30
|
-
import { getDefaultGroupFilterSelection, shouldApplyDefaultGroupFilter } from '../../utils/caseGroupDefaultFilterUtils';
|
|
30
|
+
import { applyCaseGroupListFilterAccess, getDefaultGroupFilterSelection, shouldApplyDefaultGroupFilter, } from '../../utils/caseGroupDefaultFilterUtils';
|
|
31
31
|
import { clearPageCursors, getCaseListFromGraphQL, loadMoreCases, } from '../../utils/caseListGraphQLUtils';
|
|
32
32
|
import { createFilterStateFromUrlQuery, createURLQueryFromFilterState, FILTER_URL_CURRENT_PAGE_SEARCH_PARAM, FILTER_URL_PAGE_SIZE_SEARCH_PARAM, FILTER_URL_QUERY_SEARCH_PARAM, FILTER_URL_QUERY_TYPE, } from '../../utils/caseSearchUtils';
|
|
33
33
|
import { NewCaseButton } from '../case/NewCaseButton';
|
|
@@ -41,7 +41,7 @@ import { isNoFilterApplied, isOnlyDefaultFilterApplied, isOnlyGroupFilterApplied
|
|
|
41
41
|
import { updateFilterState } from './CaseListFilterReducer';
|
|
42
42
|
import { appendCaseList, setCaseList, setCurrentQuery, setCursorInfo, setIsFetching, setIsLoadingMore, setLoadMoreError, } from './CaseListReducer';
|
|
43
43
|
export function CaseList(props) {
|
|
44
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
44
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
45
45
|
const { t } = useTranslation();
|
|
46
46
|
useDocumentTitle(PageTitle.CASE_LIST);
|
|
47
47
|
const dispatchToGlobalMetadataReducer = useContext(GlobalMetadataDispatchContext);
|
|
@@ -49,6 +49,8 @@ export function CaseList(props) {
|
|
|
49
49
|
const CaseListDispatch = useCaseListDispatchContext();
|
|
50
50
|
const breakPoint = useBreakpoint();
|
|
51
51
|
const { globalMetadataState, globalMetadataState: { caseGroups, loggedInUser, loggedInUserRights, loggedInUsersAccount, userPreferences, managedAccounts, bookmarkedAccounts, allCaseTypes, allCaseSeverities, allCaseStatuses, allProducts, caseRecordTypes, caseListTraditionalSupportAgreed, hydraUserPreferences, }, } = useContext(GlobalMetadataStateContext);
|
|
52
|
+
const caseGroupEnabled = (_b = (_a = loggedInUsersAccount.data) === null || _a === void 0 ? void 0 : _a.caseGroupEnabled) !== null && _b !== void 0 ? _b : false;
|
|
53
|
+
const applyGroupFilterAccess = useCallback((state) => applyCaseGroupListFilterAccess(state, loggedInUsersAccount.data), [loggedInUsersAccount.data]);
|
|
52
54
|
const globalDispatchContext = useGlobalDispatchContext();
|
|
53
55
|
const apolloClient = useApolloClient();
|
|
54
56
|
const includeSecureSupportCases = Boolean(loggedInUsersAccount.data.secureSupport);
|
|
@@ -180,7 +182,7 @@ export function CaseList(props) {
|
|
|
180
182
|
prefetchRef.current = { cursor: '', data: null, loading: false };
|
|
181
183
|
loadMoreCooldownRef.current = true;
|
|
182
184
|
activeFilterStateRef.current = currentFilterState;
|
|
183
|
-
const result = yield getCaseListFromGraphQL(currentFilterState, apolloClient, undefined, controller.signal, undefined, includeSecureSupportCases);
|
|
185
|
+
const result = yield getCaseListFromGraphQL(applyGroupFilterAccess(currentFilterState), apolloClient, undefined, controller.signal, undefined, includeSecureSupportCases);
|
|
184
186
|
if (controller.signal.aborted) {
|
|
185
187
|
return;
|
|
186
188
|
}
|
|
@@ -234,7 +236,7 @@ export function CaseList(props) {
|
|
|
234
236
|
}
|
|
235
237
|
else {
|
|
236
238
|
prefetchRef.current = { cursor: '', data: null, loading: false };
|
|
237
|
-
result = yield loadMoreCases(activeFilterStateRef.current, apolloClient, endCursor, controller.signal, includeSecureSupportCases);
|
|
239
|
+
result = yield loadMoreCases(applyGroupFilterAccess(activeFilterStateRef.current), apolloClient, endCursor, controller.signal, includeSecureSupportCases);
|
|
238
240
|
}
|
|
239
241
|
if (controller.signal.aborted)
|
|
240
242
|
return;
|
|
@@ -284,7 +286,7 @@ export function CaseList(props) {
|
|
|
284
286
|
};
|
|
285
287
|
const checkNewCases = () => __awaiter(this, void 0, void 0, function* () {
|
|
286
288
|
try {
|
|
287
|
-
const { caseListResponse } = yield getCaseListFromGraphQL(filterState, apolloClient, undefined, undefined, undefined, includeSecureSupportCases);
|
|
289
|
+
const { caseListResponse } = yield getCaseListFromGraphQL(applyGroupFilterAccess(filterState), apolloClient, undefined, undefined, undefined, includeSecureSupportCases);
|
|
288
290
|
let changed = false;
|
|
289
291
|
if (caseListResponse.response.numFound <= filterState.paginationInfo.pageSize &&
|
|
290
292
|
caseListResponse.response.numFound !== caseList.numFound) {
|
|
@@ -313,15 +315,15 @@ export function CaseList(props) {
|
|
|
313
315
|
console.log(err);
|
|
314
316
|
}
|
|
315
317
|
});
|
|
316
|
-
const salesforceAccountId = (
|
|
318
|
+
const salesforceAccountId = (_c = loggedInUsersAccount.data) === null || _c === void 0 ? void 0 : _c.salesforceAccountId;
|
|
317
319
|
const { error: caseLabelsFetchError, refetch: refetchCaseLabels } = useCaseLabels(salesforceAccountId);
|
|
318
320
|
const retryCaseListFetch = () => {
|
|
319
321
|
refetchCaseLabels();
|
|
320
322
|
getCases(filterState);
|
|
321
323
|
};
|
|
322
|
-
const loggedInContactId = (
|
|
323
|
-
const loggedInIsOrgAdmin = (
|
|
324
|
-
const defaultCaseGroupId = (
|
|
324
|
+
const loggedInContactId = (_d = loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.data) === null || _d === void 0 ? void 0 : _d.id;
|
|
325
|
+
const loggedInIsOrgAdmin = (_e = loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.data) === null || _e === void 0 ? void 0 : _e.isOrgAdmin;
|
|
326
|
+
const defaultCaseGroupId = (_g = (_f = loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.data) === null || _f === void 0 ? void 0 : _f.defaultCaseGroup) !== null && _g !== void 0 ? _g : null;
|
|
325
327
|
const prevDefaultCaseGroupIdRef = useRef(defaultCaseGroupId);
|
|
326
328
|
useEffect(() => {
|
|
327
329
|
var _a;
|
|
@@ -357,7 +359,7 @@ export function CaseList(props) {
|
|
|
357
359
|
loggedInContactId,
|
|
358
360
|
loggedInIsOrgAdmin,
|
|
359
361
|
loggedInUser.isFetching,
|
|
360
|
-
(
|
|
362
|
+
(_h = loggedInUsersAccount.data) === null || _h === void 0 ? void 0 : _h.isInternal,
|
|
361
363
|
salesforceAccountId,
|
|
362
364
|
]);
|
|
363
365
|
useEffect(() => {
|
|
@@ -365,14 +367,14 @@ export function CaseList(props) {
|
|
|
365
367
|
return;
|
|
366
368
|
if (loggedInUser.isFetching || caseGroups.isFetching || caseGroups.data === undefined)
|
|
367
369
|
return;
|
|
368
|
-
if (!shouldApplyDefaultGroupFilter(queryFromUrl, hydraUserPreferences.data))
|
|
370
|
+
if (!shouldApplyDefaultGroupFilter(queryFromUrl, hydraUserPreferences.data, caseGroupEnabled))
|
|
369
371
|
return;
|
|
370
372
|
const canAutoSync = isNoFilterApplied(filterState) ||
|
|
371
373
|
isOnlyDefaultFilterApplied(filterState) ||
|
|
372
374
|
isOnlyGroupFilterApplied(filterState.filterInfo);
|
|
373
375
|
if (!canAutoSync)
|
|
374
376
|
return;
|
|
375
|
-
const nextGroupFilter = getDefaultGroupFilterSelection(caseGroups.data, loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.data);
|
|
377
|
+
const nextGroupFilter = getDefaultGroupFilterSelection(caseGroups.data, loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.data, caseGroupEnabled);
|
|
376
378
|
const currentGroupFilter = filterState.filterInfo[SolrKeys.group] || [];
|
|
377
379
|
if (userDismissedDefaultGroupRef.current && currentGroupFilter.length === 0) {
|
|
378
380
|
return;
|
|
@@ -388,6 +390,21 @@ export function CaseList(props) {
|
|
|
388
390
|
loggedInUser.isFetching,
|
|
389
391
|
location.pathname,
|
|
390
392
|
queryFromUrl,
|
|
393
|
+
caseGroupEnabled,
|
|
394
|
+
]);
|
|
395
|
+
useEffect(() => {
|
|
396
|
+
var _a, _b, _c;
|
|
397
|
+
if (loggedInUsersAccount.isFetching || ((_a = loggedInUsersAccount.data) === null || _a === void 0 ? void 0 : _a.isInternal) || caseGroupEnabled)
|
|
398
|
+
return;
|
|
399
|
+
if (!((_c = (_b = filterState.filterInfo) === null || _b === void 0 ? void 0 : _b[SolrKeys.group]) === null || _c === void 0 ? void 0 : _c.length))
|
|
400
|
+
return;
|
|
401
|
+
updateFilterState(filterDispatch, applyGroupFilterAccess(filterState));
|
|
402
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
403
|
+
}, [
|
|
404
|
+
caseGroupEnabled,
|
|
405
|
+
loggedInUsersAccount.isFetching,
|
|
406
|
+
(_j = loggedInUsersAccount.data) === null || _j === void 0 ? void 0 : _j.isInternal,
|
|
407
|
+
(_k = filterState.filterInfo) === null || _k === void 0 ? void 0 : _k[SolrKeys.group],
|
|
391
408
|
]);
|
|
392
409
|
useEffect(() => {
|
|
393
410
|
const loadMetadata = () => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -486,7 +503,7 @@ export function CaseList(props) {
|
|
|
486
503
|
if (decodedQueryFromUrl &&
|
|
487
504
|
decodedQueryFromUrl !== currentQuery &&
|
|
488
505
|
decodedQueryFromUrl !== lastPushedQueryRef.current) {
|
|
489
|
-
const filterStateFromQueryUrl = createFilterStateFromUrlQuery(decodedQueryFromUrl, globalMetadataState, undefined, 1, searchType);
|
|
506
|
+
const filterStateFromQueryUrl = applyGroupFilterAccess(createFilterStateFromUrlQuery(decodedQueryFromUrl, globalMetadataState, undefined, 1, searchType));
|
|
490
507
|
updateFilterState(filterDispatch, filterStateFromQueryUrl);
|
|
491
508
|
}
|
|
492
509
|
return;
|
|
@@ -578,8 +595,8 @@ export function CaseList(props) {
|
|
|
578
595
|
React.createElement(ErrorBoundary, { errorMsgInfo: { message: t('There was an error loading filter chips') } },
|
|
579
596
|
React.createElement(CaseListFilterChips, null))),
|
|
580
597
|
React.createElement("section", { className: "case-search-bottom" },
|
|
581
|
-
React.createElement("aside", { className: `case-search-filters ${((
|
|
582
|
-
React.createElement("h2", { className: "filter-header pf-v6-u-display-flex" }, ((
|
|
598
|
+
React.createElement("aside", { className: `case-search-filters ${((_l = filterSectionRef.current) === null || _l === void 0 ? void 0 : _l.expanded) ? '' : 'collapsed'}` },
|
|
599
|
+
React.createElement("h2", { className: "filter-header pf-v6-u-display-flex" }, ((_m = filterSectionRef.current) === null || _m === void 0 ? void 0 : _m.expanded) ? (React.createElement(React.Fragment, null,
|
|
583
600
|
React.createElement(Button, { isInline: true, className: "pf-v6-u-flex-shrink-0 pf-v6-u-flex-none case-search-filter-text-button", variant: "link", title: t('Collapse filter section'), "data-tracking-id": "collapse-case-list-filter", onClick: onToggleFilterBtnClick, iconPosition: "right", icon: React.createElement(OpenDrawerRightIcon, { className: "mirrored" }) },
|
|
584
601
|
React.createElement(Trans, null, "Filters")))) : (React.createElement(Button, { isInline: true, className: "pf-v6-c-button pf-m-link pf-m-inline pf-v6-u-flex-shrink-0 pf-v6-u-flex-none pf-v6-u-display-flex pf-v6-u-align-items-center pf-v6-u-justify-content-center pf-v6-u-px-lg", variant: "link", title: t('Expand filter section'), "data-tracking-id": "expand-case-list-filter", onClick: onToggleFilterBtnClick, iconPosition: "right", icon: React.createElement(OpenDrawerRightIcon, null) }, isXLScreen ? null : React.createElement(Trans, null, "Filters")))),
|
|
585
602
|
React.createElement("div", { className: "filter-wrapper" },
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CaseSearchQueryType } from '../enums/caseSearch';
|
|
2
2
|
export declare function useFilterStateOnLoad(): {
|
|
3
3
|
set: (queryFromUrl: string, pageSizeFromUrl: number | undefined, currentPageFromUrl: number, searchType: CaseSearchQueryType) => {
|
|
4
|
-
initFilterState:
|
|
4
|
+
initFilterState: import("../components/case-list/CaseListFilterReducer").ICaseListFilterState;
|
|
5
5
|
defaultSearchName: string;
|
|
6
6
|
};
|
|
7
7
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFilterStateOnLoad.d.ts","sourceRoot":"","sources":["../../../src/hooks/useFilterStateOnLoad.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"useFilterStateOnLoad.d.ts","sourceRoot":"","sources":["../../../src/hooks/useFilterStateOnLoad.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAW1D,wBAAgB,oBAAoB;wBAkBd,MAAM,mBACH,MAAM,GAAG,SAAS,sBACf,MAAM,cACd,mBAAmB;;;;EAwEtC"}
|
|
@@ -4,24 +4,25 @@ import findKey from 'lodash/findKey';
|
|
|
4
4
|
import { useContext, useMemo } from 'react';
|
|
5
5
|
import { CaseListFilterStateContext, initialCaseFilterState } from '../components/case-list/CaseListFilterContext';
|
|
6
6
|
import { SolrKeys } from '../enums/filters';
|
|
7
|
-
import { decodeCaseListUrlFilterQuery, getDefaultGroupFilterSelection, shouldApplyDefaultGroupFilter, } from '../utils/caseGroupDefaultFilterUtils';
|
|
7
|
+
import { applyCaseGroupListFilterAccess, decodeCaseListUrlFilterQuery, getDefaultGroupFilterSelection, shouldApplyDefaultGroupFilter, } from '../utils/caseGroupDefaultFilterUtils';
|
|
8
8
|
import { createFilterStateFromUrlQuery } from '../utils/caseSearchUtils';
|
|
9
9
|
// TODO Comment
|
|
10
10
|
export function useFilterStateOnLoad() {
|
|
11
|
-
const { globalMetadataState, globalMetadataState: { caseGroups, hydraUserPreferences }, } = useContext(GlobalMetadataStateContext);
|
|
11
|
+
const { globalMetadataState, globalMetadataState: { caseGroups, hydraUserPreferences, loggedInUsersAccount }, } = useContext(GlobalMetadataStateContext);
|
|
12
12
|
const filterState = useContext(CaseListFilterStateContext);
|
|
13
13
|
const savesSearches = find(hydraUserPreferences.data, (pref) => pref.key === UserPreferencesKeys.caseSavedSearchFilters);
|
|
14
14
|
const savedSearchesObj = useMemo(() => ((savesSearches === null || savesSearches === void 0 ? void 0 : savesSearches.value) ? JSON.parse(savesSearches.value) : {}), [savesSearches]);
|
|
15
15
|
const set = (queryFromUrl, pageSizeFromUrl, currentPageFromUrl, searchType) => {
|
|
16
|
-
var _a;
|
|
16
|
+
var _a, _b, _c;
|
|
17
17
|
let savedSearchFilterState = null;
|
|
18
18
|
const defaultSavedSearchKey = findKey(savedSearchesObj, { defaultChecked: true });
|
|
19
19
|
if (defaultSavedSearchKey) {
|
|
20
20
|
const { filterState: filterStateSaved, queryString, type, sortState, } = savedSearchesObj[defaultSavedSearchKey];
|
|
21
21
|
savedSearchFilterState = Object.assign(Object.assign({}, filterState), { sortInfo: sortState, filterQueryInfo: Object.assign(Object.assign({}, filterState.filterQueryInfo), { queryString, type }), filterInfo: Object.assign(Object.assign({}, initialCaseFilterState.filterInfo), filterStateSaved) });
|
|
22
22
|
}
|
|
23
|
-
const
|
|
24
|
-
const
|
|
23
|
+
const caseGroupEnabled = (_b = (_a = loggedInUsersAccount.data) === null || _a === void 0 ? void 0 : _a.caseGroupEnabled) !== null && _b !== void 0 ? _b : false;
|
|
24
|
+
const defaultGroupFilter = getDefaultGroupFilterSelection(caseGroups.data, (_c = globalMetadataState.loggedInUser) === null || _c === void 0 ? void 0 : _c.data, caseGroupEnabled);
|
|
25
|
+
const applyDefaultGroup = shouldApplyDefaultGroupFilter(queryFromUrl, hydraUserPreferences.data, caseGroupEnabled);
|
|
25
26
|
/**
|
|
26
27
|
When user lands on page for the first time:
|
|
27
28
|
If we have any query in url(for example redirect from dashboard), we apply the query, if not
|
|
@@ -36,7 +37,7 @@ export function useFilterStateOnLoad() {
|
|
|
36
37
|
: applyDefaultGroup && defaultGroupFilter.length > 0
|
|
37
38
|
? Object.assign(Object.assign({}, filterState), { filterInfo: Object.assign(Object.assign({}, filterState.filterInfo), { [SolrKeys.group]: defaultGroupFilter }) }) : filterState;
|
|
38
39
|
return {
|
|
39
|
-
initFilterState: defaultFilterState,
|
|
40
|
+
initFilterState: applyCaseGroupListFilterAccess(defaultFilterState, loggedInUsersAccount.data),
|
|
40
41
|
defaultSearchName: defaultSavedSearchKey && !queryFromUrl ? defaultSavedSearchKey : '',
|
|
41
42
|
};
|
|
42
43
|
};
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { ICaseGroup } from '@cee-eng/hydrajs/@types/api/public/caseGroups';
|
|
2
2
|
import { IPreference } from '@cee-eng/hydrajs/@types/models/general';
|
|
3
3
|
import type { ILoggedInSsoContact } from '@rh-support/utils';
|
|
4
|
+
import { ICaseListFilterState } from '../components/case-list/CaseListFilterReducer';
|
|
5
|
+
type ICaseGroupFilterAccount = {
|
|
6
|
+
isInternal?: boolean;
|
|
7
|
+
caseGroupEnabled?: boolean;
|
|
8
|
+
};
|
|
9
|
+
/** Drops case group filters when the account cannot use the groups filter (e.g. CaseGroupEnabled__c false). */
|
|
10
|
+
export declare function applyCaseGroupListFilterAccess(filterState: ICaseListFilterState, account?: ICaseGroupFilterAccount): ICaseListFilterState;
|
|
4
11
|
export declare function decodeCaseListUrlFilterQuery(queryFromUrl?: string): string;
|
|
5
12
|
export declare function hasDefaultSavedSearch(hydraUserPreferences?: IPreference[]): boolean;
|
|
6
|
-
/** Default group filter applies only when
|
|
7
|
-
export declare function shouldApplyDefaultGroupFilter(queryFromUrl?: string, hydraUserPreferences?: IPreference[]): boolean;
|
|
8
|
-
export declare function getDefaultGroupFilterSelection(caseGroups: ICaseGroup[] | undefined, loggedInUser?: ILoggedInSsoContact): Array<{
|
|
13
|
+
/** Default group filter applies only when case groups are enabled for the account, and URL/saved-search do not own filter state. */
|
|
14
|
+
export declare function shouldApplyDefaultGroupFilter(queryFromUrl?: string, hydraUserPreferences?: IPreference[], caseGroupEnabled?: boolean): boolean;
|
|
15
|
+
export declare function getDefaultGroupFilterSelection(caseGroups: ICaseGroup[] | undefined, loggedInUser?: ILoggedInSsoContact, caseGroupEnabled?: boolean): Array<{
|
|
9
16
|
key: string;
|
|
10
17
|
value: string;
|
|
11
18
|
}>;
|
|
19
|
+
export {};
|
|
12
20
|
//# sourceMappingURL=caseGroupDefaultFilterUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"caseGroupDefaultFilterUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/caseGroupDefaultFilterUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+CAA+C,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAErE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"caseGroupDefaultFilterUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/caseGroupDefaultFilterUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+CAA+C,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAErE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAI7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,+CAA+C,CAAC;AAMrF,KAAK,uBAAuB,GAAG;IAAE,UAAU,CAAC,EAAE,OAAO,CAAC;IAAC,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAOpF,+GAA+G;AAC/G,wBAAgB,8BAA8B,CAC1C,WAAW,EAAE,oBAAoB,EACjC,OAAO,CAAC,EAAE,uBAAuB,GAClC,oBAAoB,CAuBtB;AAED,wBAAgB,4BAA4B,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAa1E;AAED,wBAAgB,qBAAqB,CAAC,oBAAoB,GAAE,WAAW,EAAO,GAAG,OAAO,CAOvF;AAED,oIAAoI;AACpI,wBAAgB,6BAA6B,CACzC,YAAY,CAAC,EAAE,MAAM,EACrB,oBAAoB,GAAE,WAAW,EAAO,EACxC,gBAAgB,UAAO,GACxB,OAAO,CAUT;AAED,wBAAgB,8BAA8B,CAC1C,UAAU,EAAE,UAAU,EAAE,GAAG,SAAS,EACpC,YAAY,CAAC,EAAE,mBAAmB,EAClC,gBAAgB,UAAO,GACxB,KAAK,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAOvC"}
|
|
@@ -1,7 +1,29 @@
|
|
|
1
1
|
import { UserPreferencesKeys } from '@rh-support/react-context';
|
|
2
2
|
import find from 'lodash/find';
|
|
3
3
|
import findKey from 'lodash/findKey';
|
|
4
|
+
import { CaseSearchQueryType } from '../enums/caseSearch';
|
|
5
|
+
import { SolrKeys } from '../enums/filters';
|
|
4
6
|
import { buildDefaultGroupFilterSelection, getDefaultCaseGroupForFilter } from './caseGroupDefaultUtils';
|
|
7
|
+
import { createUserFriendlyQueryFromFilterStateAdvancedSearch } from './caseSearchUtils';
|
|
8
|
+
/** Same rule as CASE_LIST GROUPS_FILTER (internal or CaseGroupEnabled__c). */
|
|
9
|
+
function isCaseGroupListFilterAvailable(account) {
|
|
10
|
+
return Boolean((account === null || account === void 0 ? void 0 : account.isInternal) || (account === null || account === void 0 ? void 0 : account.caseGroupEnabled));
|
|
11
|
+
}
|
|
12
|
+
/** Drops case group filters when the account cannot use the groups filter (e.g. CaseGroupEnabled__c false). */
|
|
13
|
+
export function applyCaseGroupListFilterAccess(filterState, account) {
|
|
14
|
+
var _a, _b;
|
|
15
|
+
if (isCaseGroupListFilterAvailable(account)) {
|
|
16
|
+
return filterState;
|
|
17
|
+
}
|
|
18
|
+
const groupFilter = (_a = filterState.filterInfo) === null || _a === void 0 ? void 0 : _a[SolrKeys.group];
|
|
19
|
+
if (!Array.isArray(groupFilter) || groupFilter.length === 0) {
|
|
20
|
+
return filterState;
|
|
21
|
+
}
|
|
22
|
+
const filterInfo = Object.assign(Object.assign({}, filterState.filterInfo), { [SolrKeys.group]: [] });
|
|
23
|
+
const filterQueryInfo = ((_b = filterState.filterQueryInfo) === null || _b === void 0 ? void 0 : _b.type) === CaseSearchQueryType.ADVANCED
|
|
24
|
+
? Object.assign(Object.assign({}, filterState.filterQueryInfo), { parsedQuery: createUserFriendlyQueryFromFilterStateAdvancedSearch(filterInfo, filterState.filterQueryInfo.queryString || '') }) : filterState.filterQueryInfo;
|
|
25
|
+
return Object.assign(Object.assign({}, filterState), { filterInfo, filterQueryInfo });
|
|
26
|
+
}
|
|
5
27
|
export function decodeCaseListUrlFilterQuery(queryFromUrl) {
|
|
6
28
|
if (!queryFromUrl || queryFromUrl === 'undefined') {
|
|
7
29
|
return '';
|
|
@@ -21,14 +43,20 @@ export function hasDefaultSavedSearch(hydraUserPreferences = []) {
|
|
|
21
43
|
const savedSearchesObj = (savedSearchPreference === null || savedSearchPreference === void 0 ? void 0 : savedSearchPreference.value) ? JSON.parse(savedSearchPreference.value) : {};
|
|
22
44
|
return Boolean(findKey(savedSearchesObj, { defaultChecked: true }));
|
|
23
45
|
}
|
|
24
|
-
/** Default group filter applies only when
|
|
25
|
-
export function shouldApplyDefaultGroupFilter(queryFromUrl, hydraUserPreferences = []) {
|
|
46
|
+
/** Default group filter applies only when case groups are enabled for the account, and URL/saved-search do not own filter state. */
|
|
47
|
+
export function shouldApplyDefaultGroupFilter(queryFromUrl, hydraUserPreferences = [], caseGroupEnabled = true) {
|
|
48
|
+
if (!caseGroupEnabled) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
26
51
|
if (decodeCaseListUrlFilterQuery(queryFromUrl)) {
|
|
27
52
|
return false;
|
|
28
53
|
}
|
|
29
54
|
return !hasDefaultSavedSearch(hydraUserPreferences);
|
|
30
55
|
}
|
|
31
|
-
export function getDefaultGroupFilterSelection(caseGroups, loggedInUser) {
|
|
56
|
+
export function getDefaultGroupFilterSelection(caseGroups, loggedInUser, caseGroupEnabled = true) {
|
|
57
|
+
if (!caseGroupEnabled) {
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
32
60
|
const defaultGroup = getDefaultCaseGroupForFilter(caseGroups, loggedInUser);
|
|
33
61
|
return buildDefaultGroupFilterSelection(defaultGroup);
|
|
34
62
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rh-support/cases",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.21",
|
|
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.6.
|
|
42
|
-
"@rh-support/react-context": "2.6.
|
|
41
|
+
"@rh-support/components": "2.6.21",
|
|
42
|
+
"@rh-support/react-context": "2.6.21",
|
|
43
43
|
"@rh-support/types": "2.0.30",
|
|
44
|
-
"@rh-support/user-permissions": "2.6.
|
|
45
|
-
"@rh-support/utils": "2.6.
|
|
44
|
+
"@rh-support/user-permissions": "2.6.19",
|
|
45
|
+
"@rh-support/utils": "2.6.18",
|
|
46
46
|
"localforage": "^1.10.0",
|
|
47
47
|
"lodash": "^4.17.21",
|
|
48
48
|
"pegjs": "^0.10.0",
|
|
@@ -94,5 +94,5 @@
|
|
|
94
94
|
"defaults and supports es6-module",
|
|
95
95
|
"maintained node versions"
|
|
96
96
|
],
|
|
97
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "b47efd73e7afe275c94a32a3a3ff8c76f4c45ec1"
|
|
98
98
|
}
|