@rh-support/cases 2.6.185 → 2.6.187
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 +85 -38
- package/lib/esm/components/case-list/CaseListFilterContext.d.ts.map +1 -1
- package/lib/esm/components/case-list/CaseListFilterContext.js +2 -1
- package/lib/esm/components/case-list/CaseListFilterHelpers.d.ts +3 -2
- package/lib/esm/components/case-list/CaseListFilterHelpers.d.ts.map +1 -1
- package/lib/esm/components/case-list/CaseListFilterHelpers.js +19 -6
- package/lib/esm/components/case-list/CaseListFilterReducer.d.ts +29 -0
- package/lib/esm/components/case-list/CaseListFilterReducer.d.ts.map +1 -1
- package/lib/esm/components/case-list/CaseListFilterReducer.js +1 -0
- package/lib/esm/components/case-list/case-list-filters/AdditionalFilters.d.ts.map +1 -1
- package/lib/esm/components/case-list/case-list-filters/AdditionalFilters.js +5 -0
- package/lib/esm/components/case-list/case-list-filters/CaseListFilterChips.d.ts.map +1 -1
- package/lib/esm/components/case-list/case-list-filters/CaseListFilterChips.js +5 -1
- package/lib/esm/components/case-list/case-list-filters/CaseListFilters.d.ts.map +1 -1
- package/lib/esm/components/case-list/case-list-filters/CaseListFilters.js +1 -2
- package/lib/esm/components/case-list/case-list-filters/CreatorSsoNameFilterChip.d.ts.map +1 -1
- package/lib/esm/components/case-list/case-list-filters/CreatorSsoNameFilterChip.js +3 -0
- package/lib/esm/components/case-list/case-list-filters/GroupsFilter.d.ts +11 -1
- package/lib/esm/components/case-list/case-list-filters/GroupsFilter.d.ts.map +1 -1
- package/lib/esm/components/case-list/case-list-filters/GroupsFilter.js +116 -71
- package/lib/esm/components/case-list/case-list-filters/VersionsFilter.d.ts.map +1 -1
- package/lib/esm/components/case-list/case-list-filters/VersionsFilter.js +1 -29
- package/lib/esm/components/case-list/case-list-table/CaseListTable.d.ts.map +1 -1
- package/lib/esm/components/case-list/case-list-table/CaseListTable.js +11 -5
- package/lib/esm/components/case-list/case-search/AdvanceSearch.d.ts.map +1 -1
- package/lib/esm/components/case-list/case-search/AdvanceSearch.js +1 -1
- package/lib/esm/components/case-list/case-search/AdvanceSearchToggleButton.d.ts +8 -0
- package/lib/esm/components/case-list/case-search/AdvanceSearchToggleButton.d.ts.map +1 -0
- package/lib/esm/components/case-list/case-search/AdvanceSearchToggleButton.js +8 -0
- package/lib/esm/components/case-list/case-search/CaseSearch.d.ts.map +1 -1
- package/lib/esm/components/case-list/case-search/CaseSearch.js +51 -20
- package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchAccountSection.d.ts +10 -0
- package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchAccountSection.d.ts.map +1 -0
- package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchAccountSection.js +29 -0
- package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchAuditsSection.d.ts +10 -0
- package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchAuditsSection.d.ts.map +1 -0
- package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchAuditsSection.js +16 -0
- package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchCaseSection.d.ts +9 -0
- package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchCaseSection.d.ts.map +1 -0
- package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchCaseSection.js +21 -0
- package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchDateRangeField.d.ts +12 -0
- package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchDateRangeField.d.ts.map +1 -0
- package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchDateRangeField.js +31 -0
- package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchFieldBlock.d.ts +10 -0
- package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchFieldBlock.d.ts.map +1 -0
- package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchFieldBlock.js +10 -0
- package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchModal.d.ts +10 -0
- package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchModal.d.ts.map +1 -0
- package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchModal.js +92 -0
- package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchOwnerSection.d.ts +9 -0
- package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchOwnerSection.d.ts.map +1 -0
- package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchOwnerSection.js +20 -0
- package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchProductSection.d.ts +9 -0
- package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchProductSection.d.ts.map +1 -0
- package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchProductSection.js +28 -0
- package/lib/esm/components/case-list/case-search/advance-search-modal/ProductVersionDrilldownSelect.d.ts +9 -0
- package/lib/esm/components/case-list/case-search/advance-search-modal/ProductVersionDrilldownSelect.d.ts.map +1 -0
- package/lib/esm/components/case-list/case-search/advance-search-modal/ProductVersionDrilldownSelect.js +241 -0
- package/lib/esm/components/case-list/case-search/advance-search-modal/SelectableLabelFilter.d.ts +11 -0
- package/lib/esm/components/case-list/case-search/advance-search-modal/SelectableLabelFilter.d.ts.map +1 -0
- package/lib/esm/components/case-list/case-search/advance-search-modal/SelectableLabelFilter.js +23 -0
- package/lib/esm/css/caseList.css +13 -1
- package/lib/esm/css/caseSearch.css +114 -0
- package/lib/esm/enums/caseSearch.d.ts +1 -0
- package/lib/esm/enums/caseSearch.d.ts.map +1 -1
- package/lib/esm/enums/caseSearch.js +1 -1
- package/lib/esm/hooks/useFilterStateOnLoad.d.ts +1 -1
- package/lib/esm/hooks/useFilterStateOnLoad.d.ts.map +1 -1
- package/lib/esm/utils/advanceSearchFormMapper.d.ts +11 -0
- package/lib/esm/utils/advanceSearchFormMapper.d.ts.map +1 -0
- package/lib/esm/utils/advanceSearchFormMapper.js +71 -0
- package/lib/esm/utils/advanceSearchUtils.d.ts +24 -0
- package/lib/esm/utils/advanceSearchUtils.d.ts.map +1 -0
- package/lib/esm/utils/advanceSearchUtils.js +149 -0
- package/lib/esm/utils/caseListGraphQLUtils.d.ts.map +1 -1
- package/lib/esm/utils/caseListGraphQLUtils.js +55 -19
- package/lib/esm/utils/caseListMapper.js +4 -4
- package/lib/esm/utils/caseListVariablesBuilder.d.ts +1 -0
- package/lib/esm/utils/caseListVariablesBuilder.d.ts.map +1 -1
- package/lib/esm/utils/caseListVariablesBuilder.js +240 -34
- package/lib/esm/utils/caseSearchUtils.d.ts.map +1 -1
- package/lib/esm/utils/caseSearchUtils.js +5 -2
- package/lib/esm/utils/constants.d.ts +2 -0
- package/lib/esm/utils/constants.d.ts.map +1 -1
- package/lib/esm/utils/constants.js +6 -0
- package/package.json +7 -8
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IAdvanceSearchFormState } from '../../CaseListFilterReducer';
|
|
3
|
+
interface IProps {
|
|
4
|
+
formState: IAdvanceSearchFormState;
|
|
5
|
+
onChange: (updates: Partial<IAdvanceSearchFormState>) => void;
|
|
6
|
+
showDateValidationErrors?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function AdvanceSearchAuditsSection({ formState, onChange, showDateValidationErrors }: IProps): React.JSX.Element;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=AdvanceSearchAuditsSection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AdvanceSearchAuditsSection.d.ts","sourceRoot":"","sources":["../../../../../../src/components/case-list/case-search/advance-search-modal/AdvanceSearchAuditsSection.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAItE,UAAU,MAAM;IACZ,SAAS,EAAE,uBAAuB,CAAC;IACnC,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,uBAAuB,CAAC,KAAK,IAAI,CAAC;IAC9D,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACtC;AAED,wBAAgB,0BAA0B,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,wBAAgC,EAAE,EAAE,MAAM,qBAgD3G"}
|
package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchAuditsSection.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Stack, TextInput } from '@patternfly/react-core';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Trans, useTranslation } from 'react-i18next';
|
|
4
|
+
import { AdvanceSearchDateRangeField } from './AdvanceSearchDateRangeField';
|
|
5
|
+
import { AdvanceSearchFieldBlock } from './AdvanceSearchFieldBlock';
|
|
6
|
+
export function AdvanceSearchAuditsSection({ formState, onChange, showDateValidationErrors = false }) {
|
|
7
|
+
const { t } = useTranslation();
|
|
8
|
+
return (React.createElement(Stack, null,
|
|
9
|
+
React.createElement(AdvanceSearchFieldBlock, { label: React.createElement(Trans, null, "Enter created by name Or SSO") },
|
|
10
|
+
React.createElement(TextInput, { id: "advance-search-created-by", type: "text", value: formState.createdByNameAndSso, onChange: (_event, value) => onChange({ createdByNameAndSso: value }), "aria-label": t('Created by name and SSO'), placeholder: t('Created by name & SSO') })),
|
|
11
|
+
React.createElement(AdvanceSearchFieldBlock, { label: React.createElement(Trans, null, "Enter last modified by name Or SSO") },
|
|
12
|
+
React.createElement(TextInput, { id: "advance-search-last-modified-by", type: "text", value: formState.lastModifiedByNameAndSso, onChange: (_event, value) => onChange({ lastModifiedByNameAndSso: value }), "aria-label": t('Last modified by name and SSO'), placeholder: t('Last modified by name & SSO') })),
|
|
13
|
+
React.createElement(AdvanceSearchDateRangeField, { label: t('Created in date range'), fieldId: "advance-search-created-date", value: formState.createdDateRange, showValidationErrors: showDateValidationErrors, onChange: (createdDateRange) => onChange({ createdDateRange }) }),
|
|
14
|
+
React.createElement(AdvanceSearchDateRangeField, { label: t('Last modified in date range'), fieldId: "advance-search-last-modified-date", value: formState.lastModifiedDateRange, showValidationErrors: showDateValidationErrors, onChange: (lastModifiedDateRange) => onChange({ lastModifiedDateRange }) }),
|
|
15
|
+
React.createElement(AdvanceSearchDateRangeField, { label: t('Closed in date range'), fieldId: "advance-search-closed-date", value: formState.closedDateRange, showValidationErrors: showDateValidationErrors, onChange: (closedDateRange) => onChange({ closedDateRange }) })));
|
|
16
|
+
}
|
package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchCaseSection.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IAdvanceSearchFormState } from '../../CaseListFilterReducer';
|
|
3
|
+
interface IProps {
|
|
4
|
+
formState: IAdvanceSearchFormState;
|
|
5
|
+
onChange: (updates: Partial<IAdvanceSearchFormState>) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function AdvanceSearchCaseSection({ formState, onChange }: IProps): React.JSX.Element;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=AdvanceSearchCaseSection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AdvanceSearchCaseSection.d.ts","sourceRoot":"","sources":["../../../../../../src/components/case-list/case-search/advance-search-modal/AdvanceSearchCaseSection.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAInD,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAItE,UAAU,MAAM;IACZ,SAAS,EAAE,uBAAuB,CAAC;IACnC,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,uBAAuB,CAAC,KAAK,IAAI,CAAC;CACjE;AAED,wBAAgB,wBAAwB,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,MAAM,qBA4CvE"}
|
package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchCaseSection.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Checkbox, Stack } from '@patternfly/react-core';
|
|
2
|
+
import { GlobalMetadataStateContext } from '@rh-support/react-context';
|
|
3
|
+
import { toNewCaseTypeMapper } from '@rh-support/utils';
|
|
4
|
+
import React, { useContext, useMemo } from 'react';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
import { PORTAL_DISPLAY_STATUSES } from '../../../../utils/constants';
|
|
7
|
+
import { AdvanceSearchFieldBlock } from './AdvanceSearchFieldBlock';
|
|
8
|
+
import { SelectableLabelFilter } from './SelectableLabelFilter';
|
|
9
|
+
export function AdvanceSearchCaseSection({ formState, onChange }) {
|
|
10
|
+
const { t } = useTranslation();
|
|
11
|
+
const { globalMetadataState } = useContext(GlobalMetadataStateContext);
|
|
12
|
+
const { allCaseSeverities, allCaseTypes } = globalMetadataState;
|
|
13
|
+
const severityOptions = useMemo(() => allCaseSeverities.data || [], [allCaseSeverities.data]);
|
|
14
|
+
const supportTypeOptions = useMemo(() => toNewCaseTypeMapper(allCaseTypes.data).sort(), [allCaseTypes.data]);
|
|
15
|
+
return (React.createElement(Stack, null,
|
|
16
|
+
React.createElement(SelectableLabelFilter, { label: t('Status'), options: PORTAL_DISPLAY_STATUSES, selected: formState.statuses, onChange: (statuses) => onChange({ statuses }), sectionId: "advance-search-status" }),
|
|
17
|
+
React.createElement(SelectableLabelFilter, { label: t('Severity'), options: severityOptions, selected: formState.severities, onChange: (severities) => onChange({ severities }), sectionId: "advance-search-severity" }),
|
|
18
|
+
React.createElement(SelectableLabelFilter, { label: t('Support type'), options: supportTypeOptions, selected: formState.supportTypes, onChange: (supportTypes) => onChange({ supportTypes }), sectionId: "advance-search-support-type" }),
|
|
19
|
+
React.createElement(AdvanceSearchFieldBlock, { label: t('Escalated') },
|
|
20
|
+
React.createElement(Checkbox, { id: "advance-search-escalated", className: "pf-v6-u-m-0", inputClassName: "pf-v6-u-m-0", label: t('Show escalated only'), isChecked: formState.showEscalatedOnly, onChange: (_event, checked) => onChange({ showEscalatedOnly: checked }), "data-tracking-id": "advance-search-escalated-filter" }))));
|
|
21
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IAdvanceSearchDateRange } from '../../CaseListFilterReducer';
|
|
3
|
+
interface IProps {
|
|
4
|
+
label: string;
|
|
5
|
+
value: IAdvanceSearchDateRange;
|
|
6
|
+
onChange: (value: IAdvanceSearchDateRange) => void;
|
|
7
|
+
fieldId: string;
|
|
8
|
+
showValidationErrors?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function AdvanceSearchDateRangeField({ label, value, onChange, fieldId, showValidationErrors }: IProps): React.JSX.Element;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=AdvanceSearchDateRangeField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AdvanceSearchDateRangeField.d.ts","sourceRoot":"","sources":["../../../../../../src/components/case-list/case-search/advance-search-modal/AdvanceSearchDateRangeField.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAIvC,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAKtE,UAAU,MAAM;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,uBAAuB,CAAC;IAC/B,QAAQ,EAAE,CAAC,KAAK,EAAE,uBAAuB,KAAK,IAAI,CAAC;IACnD,OAAO,EAAE,MAAM,CAAC;IAChB,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,wBAAgB,2BAA2B,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,oBAA4B,EAAE,EAAE,MAAM,qBA+DpH"}
|
package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchDateRangeField.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Flex, FlexItem, FormGroup } from '@patternfly/react-core';
|
|
2
|
+
import { CustomDatePicker } from '@rh-support/components';
|
|
3
|
+
import React, { useMemo } from 'react';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { getAdvanceSearchDateRangeFieldErrors, parseAdvanceSearchDate } from '../../../../utils/advanceSearchUtils';
|
|
6
|
+
import { AdvanceSearchFieldBlock } from './AdvanceSearchFieldBlock';
|
|
7
|
+
const parseDatePickerValue = (value) => { var _a; return (_a = parseAdvanceSearchDate(value)) !== null && _a !== void 0 ? _a : new Date(Number.NaN); };
|
|
8
|
+
export function AdvanceSearchDateRangeField({ label, value, onChange, fieldId, showValidationErrors = false }) {
|
|
9
|
+
const { t } = useTranslation();
|
|
10
|
+
const fieldErrors = useMemo(() => getAdvanceSearchDateRangeFieldErrors(value, {
|
|
11
|
+
invalidDateFormat: t('Invalid date format.'),
|
|
12
|
+
invalidDateRange: t('Invalid date range.'),
|
|
13
|
+
}), [t, value]);
|
|
14
|
+
const endDateValidators = useMemo(() => [
|
|
15
|
+
(date) => {
|
|
16
|
+
const startDate = parseAdvanceSearchDate(value.startDate);
|
|
17
|
+
if (startDate && date < startDate) {
|
|
18
|
+
return t('Invalid date range.');
|
|
19
|
+
}
|
|
20
|
+
return '';
|
|
21
|
+
},
|
|
22
|
+
], [t, value.startDate]);
|
|
23
|
+
return (React.createElement(AdvanceSearchFieldBlock, { label: label },
|
|
24
|
+
React.createElement(Flex, { direction: { default: 'row' }, flexWrap: { default: 'nowrap' }, spaceItems: { default: 'spaceItemsSm' }, alignItems: { default: 'alignItemsFlexStart' }, className: "pf-v6-u-w-100" },
|
|
25
|
+
React.createElement(FlexItem, { flex: { default: 'flex_1' }, className: "pf-v6-u-min-width-0" },
|
|
26
|
+
React.createElement(FormGroup, { label: t('Start date'), fieldId: `${fieldId}-start` },
|
|
27
|
+
React.createElement(CustomDatePicker, { id: `${fieldId}-start`, value: value.startDate, "aria-label": t('Start date'), dateParse: parseDatePickerValue, validationError: showValidationErrors ? fieldErrors.startDate : undefined, onChange: (_event, date) => onChange(Object.assign(Object.assign({}, value), { startDate: date })) }))),
|
|
28
|
+
React.createElement(FlexItem, { flex: { default: 'flex_1' }, className: "pf-v6-u-min-width-0" },
|
|
29
|
+
React.createElement(FormGroup, { label: t('End date'), fieldId: `${fieldId}-end` },
|
|
30
|
+
React.createElement(CustomDatePicker, { id: `${fieldId}-end`, value: value.endDate, "aria-label": t('End date'), dateParse: parseDatePickerValue, validators: endDateValidators, validationError: showValidationErrors ? fieldErrors.endDate : undefined, popoverPosition: "bottom-end", onChange: (_event, date) => onChange(Object.assign(Object.assign({}, value), { endDate: date })) }))))));
|
|
31
|
+
}
|
package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchFieldBlock.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface IProps {
|
|
3
|
+
label: React.ReactNode;
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
headerActions?: React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
/** Shared spacing for advance-search field groups */
|
|
8
|
+
export declare function AdvanceSearchFieldBlock({ label, children, headerActions }: IProps): React.JSX.Element;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=AdvanceSearchFieldBlock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AdvanceSearchFieldBlock.d.ts","sourceRoot":"","sources":["../../../../../../src/components/case-list/case-search/advance-search-modal/AdvanceSearchFieldBlock.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,UAAU,MAAM;IACZ,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,aAAa,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACnC;AAED,qDAAqD;AACrD,wBAAgB,uBAAuB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,EAAE,MAAM,qBAkBjF"}
|
package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchFieldBlock.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Flex, FlexItem } from '@patternfly/react-core';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
/** Shared spacing for advance-search field groups */
|
|
4
|
+
export function AdvanceSearchFieldBlock({ label, children, headerActions }) {
|
|
5
|
+
return (React.createElement(Flex, { direction: { default: 'column' }, spaceItems: { default: 'spaceItemsSm' }, className: "pf-v6-u-pt-sm pf-v6-u-pb-md" },
|
|
6
|
+
React.createElement(Flex, { alignItems: { default: 'alignItemsCenter' }, spaceItems: { default: 'spaceItemsSm' }, className: "pf-v6-u-px-md pf-v6-u-py-sm" },
|
|
7
|
+
React.createElement(FlexItem, { className: "pf-v6-u-font-size-sm pf-v6-u-font-weight-bold" }, label),
|
|
8
|
+
headerActions ? React.createElement(FlexItem, null, headerActions) : null),
|
|
9
|
+
React.createElement("div", { className: "pf-v6-u-px-md" }, children)));
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IAdvanceSearchFormState } from '../../CaseListFilterReducer';
|
|
3
|
+
interface IProps {
|
|
4
|
+
isOpen: boolean;
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
onSearch: (formState: IAdvanceSearchFormState) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function AdvanceSearchModal({ isOpen, onClose, onSearch }: IProps): React.JSX.Element;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=AdvanceSearchModal.d.ts.map
|
package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchModal.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AdvanceSearchModal.d.ts","sourceRoot":"","sources":["../../../../../../src/components/case-list/case-search/advance-search-modal/AdvanceSearchModal.tsx"],"names":[],"mappings":"AAWA,OAAO,KAA+D,MAAM,OAAO,CAAC;AAUpF,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAOtE,UAAU,MAAM;IACZ,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,CAAC,SAAS,EAAE,uBAAuB,KAAK,IAAI,CAAC;CAC1D;AAED,wBAAgB,kBAAkB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,MAAM,qBA2KvE"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Button, Divider, ExpandableSection, Flex, FlexItem, ModalBody, ModalFooter, Stack, } from '@patternfly/react-core';
|
|
2
|
+
import { AbilityContext, CaseListFields, resourceActions, resources } from '@rh-support/user-permissions';
|
|
3
|
+
import React, { useCallback, useContext, useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { Trans, useTranslation } from 'react-i18next';
|
|
5
|
+
import { createInitialAdvanceSearchFormState, hasInvalidAdvanceSearchDates, isAdvanceSearchFormEmpty, mapFilterStateToAdvanceSearchForm, } from '../../../../utils/advanceSearchUtils';
|
|
6
|
+
import { CaseListFilterStateContext } from '../../CaseListFilterContext';
|
|
7
|
+
import { AdvanceSearchAccountSection } from './AdvanceSearchAccountSection';
|
|
8
|
+
import { AdvanceSearchAuditsSection } from './AdvanceSearchAuditsSection';
|
|
9
|
+
import { AdvanceSearchCaseSection } from './AdvanceSearchCaseSection';
|
|
10
|
+
import { AdvanceSearchOwnerSection } from './AdvanceSearchOwnerSection';
|
|
11
|
+
import { AdvanceSearchProductSection } from './AdvanceSearchProductSection';
|
|
12
|
+
export function AdvanceSearchModal({ isOpen, onClose, onSearch }) {
|
|
13
|
+
const { t } = useTranslation();
|
|
14
|
+
const ability = useContext(AbilityContext);
|
|
15
|
+
const filterState = useContext(CaseListFilterStateContext);
|
|
16
|
+
const canReadAccounts = ability.can(resourceActions.READ, resources.ACCOUNTS_FILTER);
|
|
17
|
+
const canAccessProductsFilter = ability.can(resourceActions.PATCH, resources.CASE_LIST, CaseListFields.PRODUCTS_FILTER);
|
|
18
|
+
const [formState, setFormState] = useState(createInitialAdvanceSearchFormState);
|
|
19
|
+
const [isCaseSectionExpanded, setIsCaseSectionExpanded] = useState(true);
|
|
20
|
+
const [isProductSectionExpanded, setIsProductSectionExpanded] = useState(true);
|
|
21
|
+
const [isAccountSectionExpanded, setIsAccountSectionExpanded] = useState(true);
|
|
22
|
+
const [isOwnerSectionExpanded, setIsOwnerSectionExpanded] = useState(true);
|
|
23
|
+
const [isAuditsSectionExpanded, setIsAuditsSectionExpanded] = useState(true);
|
|
24
|
+
const [showDateValidationErrors, setShowDateValidationErrors] = useState(false);
|
|
25
|
+
const modalRef = useRef(null);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (isOpen) {
|
|
28
|
+
setFormState(mapFilterStateToAdvanceSearchForm(filterState));
|
|
29
|
+
setShowDateValidationErrors(false);
|
|
30
|
+
}
|
|
31
|
+
// Hydrate form only when the panel opens
|
|
32
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33
|
+
}, [isOpen]);
|
|
34
|
+
const updateFormState = useCallback((updates) => {
|
|
35
|
+
setFormState((previousState) => (Object.assign(Object.assign({}, previousState), updates)));
|
|
36
|
+
}, []);
|
|
37
|
+
const handleClearAll = () => {
|
|
38
|
+
const clearedFormState = createInitialAdvanceSearchFormState();
|
|
39
|
+
setFormState(clearedFormState);
|
|
40
|
+
setShowDateValidationErrors(false);
|
|
41
|
+
onSearch(clearedFormState);
|
|
42
|
+
onClose();
|
|
43
|
+
};
|
|
44
|
+
const hasDateErrors = hasInvalidAdvanceSearchDates(formState);
|
|
45
|
+
const handleSearch = () => {
|
|
46
|
+
if (hasDateErrors) {
|
|
47
|
+
setShowDateValidationErrors(true);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
onSearch(formState);
|
|
51
|
+
onClose();
|
|
52
|
+
};
|
|
53
|
+
const isSearchDisabled = isAdvanceSearchFormEmpty(formState) || (showDateValidationErrors && hasDateErrors);
|
|
54
|
+
const handleBackdropMouseDown = (event) => {
|
|
55
|
+
if (modalRef.current && !modalRef.current.contains(event.target)) {
|
|
56
|
+
onClose();
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const sectionToggleLabel = (text) => (React.createElement("span", { className: "pf-v6-u-font-size-md pf-v6-u-font-weight-bold" }, text));
|
|
60
|
+
if (!isOpen) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
return (React.createElement(React.Fragment, null,
|
|
64
|
+
React.createElement("div", { className: "advance-search-modal-backdrop", onMouseDown: handleBackdropMouseDown, "aria-hidden": "true" }),
|
|
65
|
+
React.createElement("div", { ref: modalRef, role: "dialog", "aria-modal": "true", "aria-label": t('Advanced search'), className: "pf-v6-c-modal-box advance-search-modal", "data-tracking-id": "advance-search-modal" },
|
|
66
|
+
React.createElement(ModalBody, { className: "pf-v6-u-p-0" },
|
|
67
|
+
React.createElement(Stack, null,
|
|
68
|
+
React.createElement(ExpandableSection, { className: "advance-search-expandable-section", toggleContent: sectionToggleLabel(t('Case')), isExpanded: isCaseSectionExpanded, onToggle: (_event, expanded) => setIsCaseSectionExpanded(expanded) },
|
|
69
|
+
React.createElement(AdvanceSearchCaseSection, { formState: formState, onChange: updateFormState })),
|
|
70
|
+
canAccessProductsFilter && (React.createElement(ExpandableSection, { className: "advance-search-expandable-section", toggleContent: sectionToggleLabel(t('Product')), isExpanded: isProductSectionExpanded, onToggle: (_event, expanded) => setIsProductSectionExpanded(expanded) },
|
|
71
|
+
React.createElement(AdvanceSearchProductSection, { formState: formState, onChange: updateFormState }))),
|
|
72
|
+
React.createElement(ExpandableSection, { className: "advance-search-expandable-section", toggleContent: sectionToggleLabel(t('Account')), isExpanded: isAccountSectionExpanded, onToggle: (_event, expanded) => setIsAccountSectionExpanded(expanded) },
|
|
73
|
+
React.createElement(AdvanceSearchAccountSection, { formState: formState, onChange: updateFormState, canReadAccounts: canReadAccounts })),
|
|
74
|
+
React.createElement(ExpandableSection, { className: "advance-search-expandable-section", toggleContent: sectionToggleLabel(t('Case owner & assignment')), isExpanded: isOwnerSectionExpanded, onToggle: (_event, expanded) => setIsOwnerSectionExpanded(expanded) },
|
|
75
|
+
React.createElement(AdvanceSearchOwnerSection, { formState: formState, onChange: updateFormState })),
|
|
76
|
+
React.createElement(ExpandableSection, { className: "advance-search-expandable-section", toggleContent: sectionToggleLabel(t('Audits')), isExpanded: isAuditsSectionExpanded, onToggle: (_event, expanded) => setIsAuditsSectionExpanded(expanded) },
|
|
77
|
+
React.createElement(AdvanceSearchAuditsSection, { formState: formState, onChange: updateFormState, showDateValidationErrors: showDateValidationErrors })))),
|
|
78
|
+
React.createElement(Divider, null),
|
|
79
|
+
React.createElement(ModalFooter, { className: "pf-v6-u-p-0" },
|
|
80
|
+
React.createElement(Flex, { justifyContent: { default: 'justifyContentSpaceBetween' }, alignItems: { default: 'alignItemsCenter' }, className: "pf-v6-u-w-100 pf-v6-u-p-md" },
|
|
81
|
+
React.createElement(FlexItem, null,
|
|
82
|
+
React.createElement(Button, { variant: "tertiary", size: "sm", onClick: handleClearAll },
|
|
83
|
+
React.createElement(Trans, null, "Clear all"))),
|
|
84
|
+
React.createElement(FlexItem, null,
|
|
85
|
+
React.createElement(Flex, { spaceItems: { default: 'spaceItemsSm' } },
|
|
86
|
+
React.createElement(FlexItem, null,
|
|
87
|
+
React.createElement(Button, { variant: "secondary", size: "sm", onClick: onClose },
|
|
88
|
+
React.createElement(Trans, null, "Cancel"))),
|
|
89
|
+
React.createElement(FlexItem, null,
|
|
90
|
+
React.createElement(Button, { variant: "primary", size: "sm", onClick: handleSearch, isDisabled: isSearchDisabled, "data-tracking-id": "advance-search-modal-search-button" },
|
|
91
|
+
React.createElement(Trans, null, "Search"))))))))));
|
|
92
|
+
}
|
package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchOwnerSection.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IAdvanceSearchFormState } from '../../CaseListFilterReducer';
|
|
3
|
+
interface IProps {
|
|
4
|
+
formState: IAdvanceSearchFormState;
|
|
5
|
+
onChange: (updates: Partial<IAdvanceSearchFormState>) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function AdvanceSearchOwnerSection({ formState, onChange }: IProps): React.JSX.Element;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=AdvanceSearchOwnerSection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AdvanceSearchOwnerSection.d.ts","sourceRoot":"","sources":["../../../../../../src/components/case-list/case-search/advance-search-modal/AdvanceSearchOwnerSection.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAI1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAGtE,UAAU,MAAM;IACZ,SAAS,EAAE,uBAAuB,CAAC;IACnC,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,uBAAuB,CAAC,KAAK,IAAI,CAAC;CACjE;AAED,wBAAgB,yBAAyB,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,MAAM,qBAwDxE"}
|
package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchOwnerSection.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Button, Stack, TextInput } from '@patternfly/react-core';
|
|
2
|
+
import TimesIcon from '@patternfly/react-icons/dist/js/icons/times-icon';
|
|
3
|
+
import { AbilityContext, CaseListFields, resourceActions, resources } from '@rh-support/user-permissions';
|
|
4
|
+
import React, { useContext } from 'react';
|
|
5
|
+
import { Trans, useTranslation } from 'react-i18next';
|
|
6
|
+
import { GroupsFilter } from '../../case-list-filters/GroupsFilter';
|
|
7
|
+
import { AdvanceSearchFieldBlock } from './AdvanceSearchFieldBlock';
|
|
8
|
+
export function AdvanceSearchOwnerSection({ formState, onChange }) {
|
|
9
|
+
const { t } = useTranslation();
|
|
10
|
+
const ability = useContext(AbilityContext);
|
|
11
|
+
const canAccessGroupsFilter = ability.can(resourceActions.PATCH, resources.CASE_LIST, CaseListFields.GROUPS_FILTER);
|
|
12
|
+
const hasSelectedGroups = formState.groups.length > 0;
|
|
13
|
+
return (React.createElement(Stack, null,
|
|
14
|
+
React.createElement(AdvanceSearchFieldBlock, { label: React.createElement(Trans, null, "Enter owner name Or SSO") },
|
|
15
|
+
React.createElement(TextInput, { id: "advance-search-owner", type: "text", value: formState.ownerNameAndSso, onChange: (_event, value) => onChange({ ownerNameAndSso: value }), "aria-label": t('Owner name and SSO'), placeholder: t('Owner name & SSO') })),
|
|
16
|
+
React.createElement(AdvanceSearchFieldBlock, { label: React.createElement(Trans, null, "Enter case assigned to name Or SSO") },
|
|
17
|
+
React.createElement(TextInput, { id: "advance-search-assigned-to", type: "text", value: formState.assignedToNameAndSso, onChange: (_event, value) => onChange({ assignedToNameAndSso: value }), "aria-label": t('Case assigned to name and SSO'), placeholder: t('Case assigned to name and SSO') })),
|
|
18
|
+
canAccessGroupsFilter && (React.createElement(AdvanceSearchFieldBlock, { label: React.createElement(Trans, null, "Select case group"), headerActions: hasSelectedGroups ? (React.createElement(Button, { variant: "plain", icon: React.createElement(TimesIcon, { "aria-hidden": true }), "aria-label": t('Clear groups selection'), onClick: () => onChange({ groups: [] }), "data-tracking-id": "advance-search-groups-clear", className: "pf-v6-u-p-0" })) : undefined },
|
|
19
|
+
React.createElement(GroupsFilter, { selectedGroups: formState.groups, onGroupsChange: (groups) => onChange({ groups }), hideLabel: true, idPrefix: "advance-search-groups-filter", showSelectionCountBadge: true, placeholder: t('Case group') })))));
|
|
20
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IAdvanceSearchFormState } from '../../CaseListFilterReducer';
|
|
3
|
+
interface IProps {
|
|
4
|
+
formState: IAdvanceSearchFormState;
|
|
5
|
+
onChange: (updates: Partial<IAdvanceSearchFormState>) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function AdvanceSearchProductSection({ formState, onChange }: IProps): React.JSX.Element;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=AdvanceSearchProductSection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AdvanceSearchProductSection.d.ts","sourceRoot":"","sources":["../../../../../../src/components/case-list/case-search/advance-search-modal/AdvanceSearchProductSection.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAIvC,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAYtE,UAAU,MAAM;IACZ,SAAS,EAAE,uBAAuB,CAAC;IACnC,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,uBAAuB,CAAC,KAAK,IAAI,CAAC;CACjE;AAED,wBAAgB,2BAA2B,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,MAAM,qBAqD1E"}
|
package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchProductSection.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Button, Stack, TextInput } from '@patternfly/react-core';
|
|
2
|
+
import TimesIcon from '@patternfly/react-icons/dist/js/icons/times-icon';
|
|
3
|
+
import React, { useMemo } from 'react';
|
|
4
|
+
import { Trans, useTranslation } from 'react-i18next';
|
|
5
|
+
import { SolrKeys } from '../../../../enums/filters';
|
|
6
|
+
import { AdvanceSearchFieldBlock } from './AdvanceSearchFieldBlock';
|
|
7
|
+
import { ProductVersionDrilldownSelect } from './ProductVersionDrilldownSelect';
|
|
8
|
+
// Temporary until openShiftClusterIdRelevantInCases is available via GraphQL product metadata.
|
|
9
|
+
const OCP_PRODUCT_NAME = 'OpenShift Container Platform';
|
|
10
|
+
const isOcpProductName = (productName) => productName.trim() === OCP_PRODUCT_NAME;
|
|
11
|
+
const hasOcpProductSelected = (products) => products.some((product) => isOcpProductName(product.value));
|
|
12
|
+
export function AdvanceSearchProductSection({ formState, onChange }) {
|
|
13
|
+
const { t } = useTranslation();
|
|
14
|
+
const selectedVersionCount = useMemo(() => formState.products.reduce((count, product) => { var _a; return count + (((_a = product[SolrKeys.version]) === null || _a === void 0 ? void 0 : _a.length) || 0); }, 0), [formState.products]);
|
|
15
|
+
const showClusterIdField = useMemo(() => hasOcpProductSelected(formState.products), [formState.products]);
|
|
16
|
+
const handleProductsChange = (products) => {
|
|
17
|
+
const updates = { products };
|
|
18
|
+
if (!hasOcpProductSelected(products) && formState.openshiftClusterId) {
|
|
19
|
+
updates.openshiftClusterId = '';
|
|
20
|
+
}
|
|
21
|
+
onChange(updates);
|
|
22
|
+
};
|
|
23
|
+
return (React.createElement(Stack, null,
|
|
24
|
+
React.createElement(AdvanceSearchFieldBlock, { label: React.createElement(Trans, null, "Select Product & version"), headerActions: selectedVersionCount > 0 ? (React.createElement(Button, { variant: "plain", icon: React.createElement(TimesIcon, { "aria-hidden": true }), "aria-label": t('Clear product and version selection'), onClick: () => onChange({ products: [], openshiftClusterId: '' }), "data-tracking-id": "advance-search-product-version-clear", className: "pf-v6-u-p-0" })) : undefined },
|
|
25
|
+
React.createElement(ProductVersionDrilldownSelect, { products: formState.products, onChange: handleProductsChange })),
|
|
26
|
+
showClusterIdField && (React.createElement(AdvanceSearchFieldBlock, { label: t('Enter clusterID') },
|
|
27
|
+
React.createElement(TextInput, { id: "advance-search-cluster-id", type: "text", value: formState.openshiftClusterId, onChange: (_event, value) => onChange({ openshiftClusterId: value }), "aria-label": t('Cluster ID'), placeholder: t('Cluster ID') })))));
|
|
28
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IProductFilter } from '../../CaseListFilterReducer';
|
|
3
|
+
interface IProps {
|
|
4
|
+
products: IProductFilter[];
|
|
5
|
+
onChange: (products: IProductFilter[]) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function ProductVersionDrilldownSelect({ products, onChange }: IProps): React.JSX.Element;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=ProductVersionDrilldownSelect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProductVersionDrilldownSelect.d.ts","sourceRoot":"","sources":["../../../../../../src/components/case-list/case-search/advance-search-modal/ProductVersionDrilldownSelect.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAgD,MAAM,OAAO,CAAC;AAIrE,OAAO,EAAE,cAAc,EAAuB,MAAM,6BAA6B,CAAC;AAclF,UAAU,MAAM;IACZ,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,QAAQ,EAAE,CAAC,QAAQ,EAAE,cAAc,EAAE,KAAK,IAAI,CAAC;CAClD;AAED,wBAAgB,6BAA6B,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,MAAM,qBAsZ3E"}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { useApolloClient } from '@apollo/client/react';
|
|
2
|
+
import { Badge, Divider, DrilldownMenu, Flex, FlexItem, Menu, MenuContainer, MenuContent, MenuItem, MenuList, MenuToggle, SearchInput, Spinner, } from '@patternfly/react-core';
|
|
3
|
+
import { GlobalMetadataStateContext } from '@rh-support/react-context';
|
|
4
|
+
import { compareVersions, GET_PRODUCTS, handleGraphQLVersionsResponse } from '@rh-support/utils';
|
|
5
|
+
import React, { useContext, useMemo, useRef, useState } from 'react';
|
|
6
|
+
import { useTranslation } from 'react-i18next';
|
|
7
|
+
import { SolrKeys } from '../../../../enums/filters';
|
|
8
|
+
const ROOT_MENU_ID = 'advance-search-product-version-root';
|
|
9
|
+
export function ProductVersionDrilldownSelect({ products, onChange }) {
|
|
10
|
+
var _a;
|
|
11
|
+
const { t } = useTranslation();
|
|
12
|
+
const apolloClient = useApolloClient();
|
|
13
|
+
const { globalMetadataState: { allProducts }, } = useContext(GlobalMetadataStateContext);
|
|
14
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
15
|
+
const [productSearch, setProductSearch] = useState('');
|
|
16
|
+
const [menuDrilledIn, setMenuDrilledIn] = useState([]);
|
|
17
|
+
const [drilldownPath, setDrilldownPath] = useState([]);
|
|
18
|
+
const [activeMenu, setActiveMenu] = useState(ROOT_MENU_ID);
|
|
19
|
+
const [menuHeights, setMenuHeights] = useState({});
|
|
20
|
+
const [versionsByProductId, setVersionsByProductId] = useState({});
|
|
21
|
+
const [loadingProductIds, setLoadingProductIds] = useState({});
|
|
22
|
+
const toggleRef = useRef(null);
|
|
23
|
+
const menuRef = useRef(null);
|
|
24
|
+
const productOptions = useMemo(() => {
|
|
25
|
+
var _a, _b;
|
|
26
|
+
return ((_b = (_a = allProducts.data) === null || _a === void 0 ? void 0 : _a.productsResult) === null || _b === void 0 ? void 0 : _b.map((product) => ({
|
|
27
|
+
name: product.product || product.name || '',
|
|
28
|
+
productId: product.productId || '',
|
|
29
|
+
}))) || [];
|
|
30
|
+
}, [(_a = allProducts.data) === null || _a === void 0 ? void 0 : _a.productsResult]);
|
|
31
|
+
const filteredProducts = useMemo(() => {
|
|
32
|
+
if (!productSearch.trim()) {
|
|
33
|
+
return productOptions;
|
|
34
|
+
}
|
|
35
|
+
const formattedValue = productSearch.replace(/\\/g, '');
|
|
36
|
+
const searchPattern = new RegExp(formattedValue, 'i');
|
|
37
|
+
return productOptions.filter((product) => searchPattern.test(product.name));
|
|
38
|
+
}, [productOptions, productSearch]);
|
|
39
|
+
const selectedFilterCount = useMemo(() => products.reduce((count, product) => {
|
|
40
|
+
const versions = product[SolrKeys.version] || [];
|
|
41
|
+
return count + (versions.length > 0 ? versions.length : 1);
|
|
42
|
+
}, 0), [products]);
|
|
43
|
+
const resetDrilldownState = () => {
|
|
44
|
+
setMenuDrilledIn([]);
|
|
45
|
+
setDrilldownPath([]);
|
|
46
|
+
setActiveMenu(ROOT_MENU_ID);
|
|
47
|
+
setProductSearch('');
|
|
48
|
+
setMenuHeights({});
|
|
49
|
+
};
|
|
50
|
+
const handleOpenChange = (open) => {
|
|
51
|
+
setIsOpen(open);
|
|
52
|
+
if (!open) {
|
|
53
|
+
resetDrilldownState();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const setHeight = (menuId, height) => {
|
|
57
|
+
setMenuHeights((previousHeights) => {
|
|
58
|
+
if (previousHeights[menuId] === undefined ||
|
|
59
|
+
(menuId !== ROOT_MENU_ID && previousHeights[menuId] !== height)) {
|
|
60
|
+
return Object.assign(Object.assign({}, previousHeights), { [menuId]: height });
|
|
61
|
+
}
|
|
62
|
+
return previousHeights;
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
const updateMenuHeight = (menuId) => {
|
|
66
|
+
requestAnimationFrame(() => {
|
|
67
|
+
var _a;
|
|
68
|
+
const menuContent = (_a = document.getElementById(menuId)) === null || _a === void 0 ? void 0 : _a.querySelector('.pf-v6-c-menu__content');
|
|
69
|
+
if (menuContent instanceof HTMLElement) {
|
|
70
|
+
setHeight(menuId, menuContent.clientHeight);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
const drillIn = (_event, fromMenuId, toMenuId, pathId) => {
|
|
75
|
+
setMenuDrilledIn((previousMenus) => [...previousMenus, fromMenuId]);
|
|
76
|
+
setDrilldownPath((previousPath) => [...previousPath, pathId]);
|
|
77
|
+
setActiveMenu(toMenuId);
|
|
78
|
+
const productId = pathId.replace('product-', '');
|
|
79
|
+
const product = productOptions.find((item) => item.productId === productId);
|
|
80
|
+
if (product) {
|
|
81
|
+
fetchVersionsForProduct(product);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const drillOut = (_event, toMenuId) => {
|
|
85
|
+
setMenuDrilledIn((previousMenus) => previousMenus.slice(0, -1));
|
|
86
|
+
setDrilldownPath((previousPath) => previousPath.slice(0, -1));
|
|
87
|
+
setActiveMenu(toMenuId);
|
|
88
|
+
};
|
|
89
|
+
const fetchVersionsForProduct = (product) => {
|
|
90
|
+
if (!product.productId || versionsByProductId[product.productId] || loadingProductIds[product.productId]) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
setLoadingProductIds((previousState) => (Object.assign(Object.assign({}, previousState), { [product.productId]: true })));
|
|
94
|
+
apolloClient
|
|
95
|
+
.query({
|
|
96
|
+
query: GET_PRODUCTS,
|
|
97
|
+
variables: {
|
|
98
|
+
where: { ParentProduct__c: { eq: product.productId }, IsActive: { eq: true } },
|
|
99
|
+
first: 200,
|
|
100
|
+
orderBy: { Name: { order: 'ASC' } },
|
|
101
|
+
},
|
|
102
|
+
fetchPolicy: 'cache-first',
|
|
103
|
+
})
|
|
104
|
+
.then(({ data }) => {
|
|
105
|
+
var _a, _b, _c, _d;
|
|
106
|
+
const edges = (_d = (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.salesforce_support_uiapi) === null || _a === void 0 ? void 0 : _a.query) === null || _b === void 0 ? void 0 : _b.SalesforceSupportProduct2) === null || _c === void 0 ? void 0 : _c.edges) !== null && _d !== void 0 ? _d : [];
|
|
107
|
+
const versionData = handleGraphQLVersionsResponse(edges, product.name);
|
|
108
|
+
const sortedVersions = [...versionData].sort((versionA, versionB) => compareVersions(versionA.name, versionB.name));
|
|
109
|
+
setVersionsByProductId((previousState) => (Object.assign(Object.assign({}, previousState), { [product.productId]: sortedVersions })));
|
|
110
|
+
updateMenuHeight(`versions-menu-${product.productId}`);
|
|
111
|
+
})
|
|
112
|
+
.catch((error) => {
|
|
113
|
+
console.error('[ProductVersionDrilldownSelect] Failed to fetch versions:', error);
|
|
114
|
+
setVersionsByProductId((previousState) => (Object.assign(Object.assign({}, previousState), { [product.productId]: [] })));
|
|
115
|
+
updateMenuHeight(`versions-menu-${product.productId}`);
|
|
116
|
+
})
|
|
117
|
+
.finally(() => {
|
|
118
|
+
setLoadingProductIds((previousState) => (Object.assign(Object.assign({}, previousState), { [product.productId]: false })));
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
const getProductAppliedFilterCount = (product) => {
|
|
122
|
+
const selectedProduct = products.find((item) => item.value === product.name);
|
|
123
|
+
if (!selectedProduct) {
|
|
124
|
+
return 0;
|
|
125
|
+
}
|
|
126
|
+
const versions = selectedProduct[SolrKeys.version] || [];
|
|
127
|
+
return versions.length > 0 ? versions.length : 1;
|
|
128
|
+
};
|
|
129
|
+
const isProductOnlySelected = (product) => {
|
|
130
|
+
var _a;
|
|
131
|
+
const selectedProduct = products.find((item) => item.value === product.name);
|
|
132
|
+
return !!selectedProduct && !((_a = selectedProduct[SolrKeys.version]) === null || _a === void 0 ? void 0 : _a.length);
|
|
133
|
+
};
|
|
134
|
+
const toggleProductOnlySelection = (product) => {
|
|
135
|
+
var _a;
|
|
136
|
+
const productIndex = products.findIndex((item) => item.value === product.name);
|
|
137
|
+
if (productIndex === -1) {
|
|
138
|
+
onChange([
|
|
139
|
+
...products,
|
|
140
|
+
{
|
|
141
|
+
field: SolrKeys.product,
|
|
142
|
+
value: product.name,
|
|
143
|
+
productId: product.productId,
|
|
144
|
+
[SolrKeys.version]: [],
|
|
145
|
+
},
|
|
146
|
+
]);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const currentProduct = products[productIndex];
|
|
150
|
+
const hasVersions = (((_a = currentProduct[SolrKeys.version]) === null || _a === void 0 ? void 0 : _a.length) || 0) > 0;
|
|
151
|
+
if (!hasVersions) {
|
|
152
|
+
onChange(products.filter((_, index) => index !== productIndex));
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const nextProducts = [...products];
|
|
156
|
+
nextProducts[productIndex] = Object.assign(Object.assign({}, currentProduct), { [SolrKeys.version]: [] });
|
|
157
|
+
onChange(nextProducts);
|
|
158
|
+
};
|
|
159
|
+
const isVersionSelected = (productName, versionName) => {
|
|
160
|
+
var _a, _b;
|
|
161
|
+
const selectedProduct = products.find((product) => product.value === productName);
|
|
162
|
+
return (_b = (_a = selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct[SolrKeys.version]) === null || _a === void 0 ? void 0 : _a.some((version) => version.value === versionName)) !== null && _b !== void 0 ? _b : false;
|
|
163
|
+
};
|
|
164
|
+
const toggleVersionSelection = (product, version) => {
|
|
165
|
+
const nextProducts = [...products];
|
|
166
|
+
const productIndex = nextProducts.findIndex((item) => item.value === product.name);
|
|
167
|
+
if (productIndex === -1) {
|
|
168
|
+
onChange([
|
|
169
|
+
...nextProducts,
|
|
170
|
+
{
|
|
171
|
+
field: SolrKeys.product,
|
|
172
|
+
value: product.name,
|
|
173
|
+
productId: product.productId,
|
|
174
|
+
[SolrKeys.version]: [
|
|
175
|
+
{
|
|
176
|
+
field: SolrKeys.version,
|
|
177
|
+
value: version.name,
|
|
178
|
+
productId: version.id,
|
|
179
|
+
},
|
|
180
|
+
],
|
|
181
|
+
},
|
|
182
|
+
]);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
const currentProduct = nextProducts[productIndex];
|
|
186
|
+
const currentVersions = currentProduct[SolrKeys.version] || [];
|
|
187
|
+
const versionIndex = currentVersions.findIndex((item) => item.value === version.name);
|
|
188
|
+
const nextVersions = versionIndex >= 0
|
|
189
|
+
? currentVersions.filter((_, index) => index !== versionIndex)
|
|
190
|
+
: [
|
|
191
|
+
...currentVersions,
|
|
192
|
+
{
|
|
193
|
+
field: SolrKeys.version,
|
|
194
|
+
value: version.name,
|
|
195
|
+
productId: version.id,
|
|
196
|
+
},
|
|
197
|
+
];
|
|
198
|
+
if (nextVersions.length === 0) {
|
|
199
|
+
onChange(nextProducts.filter((_, index) => index !== productIndex));
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
nextProducts[productIndex] = Object.assign(Object.assign({}, currentProduct), { [SolrKeys.version]: nextVersions });
|
|
203
|
+
onChange(nextProducts);
|
|
204
|
+
};
|
|
205
|
+
const renderVersionItems = (product) => {
|
|
206
|
+
const versions = versionsByProductId[product.productId];
|
|
207
|
+
const isLoading = loadingProductIds[product.productId];
|
|
208
|
+
if (isLoading || versions === undefined) {
|
|
209
|
+
return (React.createElement(MenuItem, { itemId: `loading-${product.productId}`, isDisabled: true },
|
|
210
|
+
React.createElement(Spinner, { size: "sm", "aria-label": t('Loading versions') }),
|
|
211
|
+
" ",
|
|
212
|
+
t('Loading...')));
|
|
213
|
+
}
|
|
214
|
+
if (!versions.length) {
|
|
215
|
+
return (React.createElement(MenuItem, { itemId: `no-versions-${product.productId}`, isDisabled: true }, t('No versions found')));
|
|
216
|
+
}
|
|
217
|
+
return versions.map((version) => (React.createElement(MenuItem, { key: `${product.productId}-${version.name}`, itemId: `version-${product.productId}-${version.name}`, hasCheckbox: true, isSelected: isVersionSelected(product.name, version.name), onClick: () => toggleVersionSelection(product, version) }, version.name)));
|
|
218
|
+
};
|
|
219
|
+
const renderProductDrilldownMenu = (product) => (React.createElement(DrilldownMenu, { id: `versions-menu-${product.productId}` },
|
|
220
|
+
React.createElement(MenuItem, { itemId: `breadcrumb-${product.productId}`, direction: "up" }, product.name),
|
|
221
|
+
React.createElement(Divider, { component: "li" }),
|
|
222
|
+
React.createElement(MenuItem, { itemId: `product-only-${product.productId}`, hasCheckbox: true, isSelected: isProductOnlySelected(product), onClick: () => toggleProductOnlySelection(product) }, t('Entire product')),
|
|
223
|
+
React.createElement(Divider, { component: "li" }),
|
|
224
|
+
renderVersionItems(product)));
|
|
225
|
+
const toggleLabel = t('Select Product & version');
|
|
226
|
+
const isRootMenuActive = activeMenu === ROOT_MENU_ID;
|
|
227
|
+
return (React.createElement(MenuContainer, { isOpen: isOpen, onOpenChange: handleOpenChange, menuRef: menuRef, toggleRef: toggleRef, popperProps: { direction: 'down', enableFlip: false, width: 'trigger' }, toggle: React.createElement(MenuToggle, { ref: toggleRef, onClick: () => handleOpenChange(!isOpen), isExpanded: isOpen, isFullWidth: true, "aria-label": t('Select Product & version') },
|
|
228
|
+
React.createElement(Flex, { alignItems: { default: 'alignItemsCenter' }, justifyContent: { default: 'justifyContentSpaceBetween' }, className: "pf-v6-u-w-100 advance-search-dropdown-toggle-content" },
|
|
229
|
+
React.createElement(FlexItem, { className: "pf-v6-u-text-align-left" }, toggleLabel),
|
|
230
|
+
selectedFilterCount > 0 ? (React.createElement(FlexItem, { className: "advance-search-dropdown-toggle-badge-wrap" },
|
|
231
|
+
React.createElement(Badge, { className: "advance-search-dropdown-toggle-badge" }, t('{{count}} selected', { count: selectedFilterCount })))) : null)), menu: React.createElement(Menu, { id: ROOT_MENU_ID, ref: menuRef, containsDrilldown: true, drilldownItemPath: drilldownPath, drilledInMenus: menuDrilledIn, activeMenu: activeMenu, onDrillIn: drillIn, onDrillOut: drillOut, onGetMenuHeight: setHeight, isScrollable: true, "data-tracking-id": "advance-search-product-version-drilldown" },
|
|
232
|
+
React.createElement(MenuContent, { menuHeight: `${menuHeights[activeMenu]}px` },
|
|
233
|
+
!isRootMenuActive ? null : (React.createElement("div", { className: "advance-search-product-version-search pf-v6-u-p-sm", onMouseDown: (event) => event.stopPropagation() },
|
|
234
|
+
React.createElement(SearchInput, { placeholder: t('Find product by name'), value: productSearch, onChange: (_event, value) => setProductSearch(value), onClear: () => setProductSearch(''), "aria-label": t('Find product by name') }))),
|
|
235
|
+
React.createElement(MenuList, null, filteredProducts.length === 0 ? (React.createElement(MenuItem, { itemId: "no-products-found", isDisabled: true }, t('No results found'))) : (filteredProducts.map((product) => {
|
|
236
|
+
const productAppliedCount = getProductAppliedFilterCount(product);
|
|
237
|
+
return (React.createElement(MenuItem, { key: product.productId, itemId: `product-${product.productId}`, direction: "down", actions: productAppliedCount > 0 ? (React.createElement(Badge, { className: "advance-search-product-menu-item-badge pf-v6-u-mx-sm", "aria-label": t('{{count}} filters applied', {
|
|
238
|
+
count: productAppliedCount,
|
|
239
|
+
}) }, productAppliedCount)) : undefined, drilldownMenu: renderProductDrilldownMenu(product) }, product.name));
|
|
240
|
+
}))))) }));
|
|
241
|
+
}
|
package/lib/esm/components/case-list/case-search/advance-search-modal/SelectableLabelFilter.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface IProps {
|
|
3
|
+
label: string;
|
|
4
|
+
options: string[];
|
|
5
|
+
selected: string[];
|
|
6
|
+
onChange: (selected: string[]) => void;
|
|
7
|
+
sectionId: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function SelectableLabelFilter({ label, options, selected, onChange, sectionId }: IProps): React.JSX.Element;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=SelectableLabelFilter.d.ts.map
|
package/lib/esm/components/case-list/case-search/advance-search-modal/SelectableLabelFilter.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectableLabelFilter.d.ts","sourceRoot":"","sources":["../../../../../../src/components/case-list/case-search/advance-search-modal/SelectableLabelFilter.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,UAAU,MAAM;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACvC,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,qBAAqB,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,MAAM,qBAwD9F"}
|