@rh-support/manage 2.5.263 → 2.5.271

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.
Files changed (56) hide show
  1. package/lib/esm/ManageTabs.d.ts.map +1 -1
  2. package/lib/esm/ManageTabs.js +18 -46
  3. package/lib/esm/Routes.d.ts +0 -1
  4. package/lib/esm/Routes.d.ts.map +1 -1
  5. package/lib/esm/Routes.js +0 -6
  6. package/lib/esm/components/Groups/DefualtGroupSwitch/DefaultGroupSwitch.d.ts +3 -5
  7. package/lib/esm/components/Groups/DefualtGroupSwitch/DefaultGroupSwitch.d.ts.map +1 -1
  8. package/lib/esm/components/Groups/DefualtGroupSwitch/DefaultGroupSwitch.js +14 -21
  9. package/lib/esm/components/Groups/GroupSelect/GroupSelect.d.ts +0 -1
  10. package/lib/esm/components/Groups/GroupSelect/GroupSelect.d.ts.map +1 -1
  11. package/lib/esm/components/Groups/GroupSelect/GroupSelect.js +85 -156
  12. package/lib/esm/components/Groups/ManageGroupUsers/ManageGroupUsers.d.ts.map +1 -1
  13. package/lib/esm/components/Groups/ManageGroupUsers/ManageGroupUsers.js +42 -163
  14. package/lib/esm/components/ManagePreferences/sections/PreferencesACL.d.ts.map +1 -1
  15. package/lib/esm/components/ManagePreferences/sections/PreferencesACL.js +4 -3
  16. package/lib/esm/components/ManagePreferences/sections/PreferencesCaseCreate.d.ts.map +1 -1
  17. package/lib/esm/components/ManagePreferences/sections/PreferencesCaseCreate.js +58 -73
  18. package/lib/esm/components/ManagePreferences/sections/PreferencesCaseView.d.ts.map +1 -1
  19. package/lib/esm/components/ManagePreferences/sections/PreferencesCaseView.js +98 -43
  20. package/lib/esm/constants/GroupSelectActions.d.ts +1 -2
  21. package/lib/esm/constants/GroupSelectActions.d.ts.map +1 -1
  22. package/lib/esm/constants/GroupSelectActions.js +0 -1
  23. package/lib/esm/hooks/useVersionsDiffer.d.ts.map +1 -1
  24. package/lib/esm/index.js +0 -1
  25. package/lib/esm/scss/_main.scss +0 -77
  26. package/package.json +8 -11
  27. package/lib/esm/components/Groups/AddMembersModal/AddMembersModal.d.ts +0 -12
  28. package/lib/esm/components/Groups/AddMembersModal/AddMembersModal.d.ts.map +0 -1
  29. package/lib/esm/components/Groups/AddMembersModal/AddMembersModal.js +0 -80
  30. package/lib/esm/components/Groups/AddMembersModal/index.d.ts +0 -2
  31. package/lib/esm/components/Groups/AddMembersModal/index.d.ts.map +0 -1
  32. package/lib/esm/components/Groups/AddMembersModal/index.js +0 -1
  33. package/lib/esm/components/ManageCaseLabels/AddEditCaseLabelModal.d.ts +0 -19
  34. package/lib/esm/components/ManageCaseLabels/AddEditCaseLabelModal.d.ts.map +0 -1
  35. package/lib/esm/components/ManageCaseLabels/AddEditCaseLabelModal.js +0 -83
  36. package/lib/esm/components/ManageCaseLabels/ManageCaseLabelsTab.d.ts +0 -3
  37. package/lib/esm/components/ManageCaseLabels/ManageCaseLabelsTab.d.ts.map +0 -1
  38. package/lib/esm/components/ManageCaseLabels/ManageCaseLabelsTab.js +0 -217
  39. package/lib/esm/components/ManageCaseLabels/index.d.ts +0 -2
  40. package/lib/esm/components/ManageCaseLabels/index.d.ts.map +0 -1
  41. package/lib/esm/components/ManageCaseLabels/index.js +0 -1
  42. package/lib/esm/components/ManageCaseLabels/types.d.ts +0 -6
  43. package/lib/esm/components/ManageCaseLabels/types.d.ts.map +0 -1
  44. package/lib/esm/components/ManageCaseLabels/types.js +0 -1
  45. package/lib/esm/hooks/useCaseGroupGraphQL.d.ts +0 -42
  46. package/lib/esm/hooks/useCaseGroupGraphQL.d.ts.map +0 -1
  47. package/lib/esm/hooks/useCaseGroupGraphQL.js +0 -109
  48. package/lib/esm/hooks/useCaseLabelGraphQL.d.ts +0 -26
  49. package/lib/esm/hooks/useCaseLabelGraphQL.d.ts.map +0 -1
  50. package/lib/esm/hooks/useCaseLabelGraphQL.js +0 -99
  51. package/lib/esm/hooks/useCurrentUserContact.d.ts +0 -8
  52. package/lib/esm/hooks/useCurrentUserContact.d.ts.map +0 -1
  53. package/lib/esm/hooks/useCurrentUserContact.js +0 -74
  54. package/lib/esm/utils/caseGroupMapper.d.ts +0 -18
  55. package/lib/esm/utils/caseGroupMapper.d.ts.map +0 -1
  56. package/lib/esm/utils/caseGroupMapper.js +0 -49
@@ -1,217 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { ActionList, ActionListItem, AlertVariant, Button, ButtonVariant, EmptyState, EmptyStateBody, EmptyStateFooter, EmptyStateVariant, ModalVariant, SearchInput, } from '@patternfly/react-core';
11
- import CubesIcon from '@patternfly/react-icons/dist/js/icons/cubes-icon';
12
- import PencilAltIcon from '@patternfly/react-icons/dist/js/icons/pencil-alt-icon';
13
- import TrashIcon from '@patternfly/react-icons/dist/js/icons/trash-icon';
14
- import { ErrorBoundary, ToastNotification, useConfirmation } from '@rh-support/components';
15
- import { useGlobalStateContext } from '@rh-support/react-context';
16
- import { getStringifiedParams } from '@rh-support/utils';
17
- import isEmpty from 'lodash/isEmpty';
18
- import React, { useEffect, useMemo, useState } from 'react';
19
- import { Trans, useTranslation } from 'react-i18next';
20
- import { useHistory } from 'react-router-dom';
21
- import { useCaseLabels, useCreateCaseLabel, useDeleteCaseLabel, useUpdateCaseLabel, } from '../../hooks/useCaseLabelGraphQL';
22
- import { ManageTable } from '../ManageTable';
23
- import { AddEditCaseLabelModal } from './AddEditCaseLabelModal';
24
- const isDuplicateCaseLabelGraphQLError = (error) => {
25
- var _a, _b, _c, _d;
26
- if (!error || typeof error !== 'object') {
27
- return false;
28
- }
29
- const apolloError = error;
30
- const messages = [
31
- ...((_b = (_a = apolloError.graphQLErrors) === null || _a === void 0 ? void 0 : _a.map((graphQLError) => graphQLError.message || '')) !== null && _b !== void 0 ? _b : []),
32
- ...((_d = (_c = apolloError.errors) === null || _c === void 0 ? void 0 : _c.map((graphQLError) => graphQLError.message || '')) !== null && _d !== void 0 ? _d : []),
33
- apolloError.message || '',
34
- ]
35
- .join(' ')
36
- .toLowerCase();
37
- return messages.includes('duplicate value found');
38
- };
39
- export function ManageCaseLabelsTab() {
40
- var _a;
41
- const { t } = useTranslation();
42
- const history = useHistory();
43
- const confirmation = useConfirmation();
44
- const { globalMetadataState: { loggedInUsersAccount }, } = useGlobalStateContext();
45
- const accountId = (_a = loggedInUsersAccount === null || loggedInUsersAccount === void 0 ? void 0 : loggedInUsersAccount.data) === null || _a === void 0 ? void 0 : _a.salesforceAccountId;
46
- const { labels: fetchedLabels, loading: isFetchingLabels, error: labelsError, refetch } = useCaseLabels(accountId);
47
- const { createCaseLabel, loading: isCreatingLabel } = useCreateCaseLabel();
48
- const { updateCaseLabel, loading: isUpdatingLabel } = useUpdateCaseLabel();
49
- const { deleteCaseLabel } = useDeleteCaseLabel();
50
- const [labels, setLabels] = useState([]);
51
- const [searchString, setSearchString] = useState('');
52
- const [isModalOpen, setIsModalOpen] = useState(false);
53
- const [isInAddMode, setIsInAddMode] = useState(true);
54
- const [selectedLabel, setSelectedLabel] = useState(null);
55
- useEffect(() => {
56
- setLabels(fetchedLabels);
57
- }, [fetchedLabels]);
58
- const filteredLabels = useMemo(() => {
59
- if (isEmpty(searchString)) {
60
- return labels;
61
- }
62
- return labels.filter((label) => label.name.toLowerCase().includes(searchString.toLowerCase()));
63
- }, [labels, searchString]);
64
- const hasNoLabels = !isFetchingLabels && !labelsError && labels.length === 0;
65
- const onOpenAddModal = () => {
66
- setIsInAddMode(true);
67
- setSelectedLabel(null);
68
- setIsModalOpen(true);
69
- };
70
- const onOpenEditModal = (label) => {
71
- setIsInAddMode(false);
72
- setSelectedLabel(label);
73
- setIsModalOpen(true);
74
- };
75
- const closeModal = () => {
76
- setIsModalOpen(false);
77
- setSelectedLabel(null);
78
- setIsInAddMode(true);
79
- };
80
- const onSaveLabel = (name, options) => __awaiter(this, void 0, void 0, function* () {
81
- if (isInAddMode) {
82
- if (!accountId) {
83
- ToastNotification.addDangerMessage(t('Unable to create case label. Account information is missing.'));
84
- return { success: false };
85
- }
86
- try {
87
- yield createCaseLabel(name, accountId);
88
- yield refetch();
89
- ToastNotification.addSuccessMessage(t('Case label has been successfully created.'));
90
- if (!(options === null || options === void 0 ? void 0 : options.keepOpen)) {
91
- closeModal();
92
- }
93
- return { success: true };
94
- }
95
- catch (error) {
96
- if (isDuplicateCaseLabelGraphQLError(error)) {
97
- return {
98
- success: false,
99
- fieldError: t('Label name already in use. Try a different name.'),
100
- };
101
- }
102
- ToastNotification.addDangerMessage(t('Case label failed to create.'));
103
- return { success: false };
104
- }
105
- }
106
- if (selectedLabel) {
107
- try {
108
- yield updateCaseLabel(selectedLabel.id, name);
109
- yield refetch();
110
- ToastNotification.addSuccessMessage(t('Case label has been successfully updated.'));
111
- closeModal();
112
- return { success: true };
113
- }
114
- catch (error) {
115
- if (isDuplicateCaseLabelGraphQLError(error)) {
116
- return {
117
- success: false,
118
- fieldError: t('Label name already in use. Try a different name.'),
119
- };
120
- }
121
- ToastNotification.addDangerMessage(t('Case label failed to update.'));
122
- return { success: false };
123
- }
124
- }
125
- return { success: false };
126
- });
127
- const onDeleteLabel = (label) => __awaiter(this, void 0, void 0, function* () {
128
- try {
129
- yield confirmation({
130
- catchOnCancel: true,
131
- confirmText: t('Delete label'),
132
- confirmButtonVariant: ButtonVariant.danger,
133
- cancelText: t('Cancel'),
134
- modalVariant: ModalVariant.large,
135
- title: t('Delete case label'),
136
- description: (React.createElement("div", { className: "case-label-delete-description", style: { display: 'flex', flexDirection: 'column', gap: '1.5rem' } },
137
- React.createElement("div", null, t('Are you sure you want to delete "{{name}}" case label?', { name: label.name })),
138
- React.createElement("div", { style: { whiteSpace: 'nowrap' } },
139
- t('This label is currently assigned to'),
140
- ' ',
141
- React.createElement("strong", null, t('{{count}} cases', { count: label.assignedCaseCount })),
142
- '. ',
143
- t('Deleting it will remove the label from all associated cases.')))),
144
- });
145
- }
146
- catch (_a) {
147
- // user cancelled
148
- return;
149
- }
150
- try {
151
- yield deleteCaseLabel(label.id);
152
- yield refetch();
153
- ToastNotification.addSuccessMessage(t('Case label has been successfully removed.'));
154
- }
155
- catch (_b) {
156
- ToastNotification.addDangerMessage(t('Case label failed to remove.'));
157
- }
158
- });
159
- const onViewAssignedCases = (label) => {
160
- const query = `caseLabel:("${label.id}") orderBy lastModifiedDate desc`;
161
- history.push({
162
- pathname: '/case/list',
163
- search: getStringifiedParams({
164
- query: encodeURIComponent(query),
165
- searchType: 'basic',
166
- }),
167
- });
168
- };
169
- const columns = [
170
- {
171
- accessor: (label) => label.name,
172
- sortable: false,
173
- id: 'case-label-row',
174
- title: '',
175
- cellWidth: 100,
176
- cell: (label) => (React.createElement("div", { className: "case-label-row" },
177
- React.createElement("div", { className: "case-label-row__info" },
178
- React.createElement("div", { className: "pf-v6-u-font-weight-bold" }, label.name),
179
- React.createElement("div", { className: "pf-v6-u-color-200 pf-v6-u-font-size-sm" }, t('{{count}} cases assigned', { count: label.assignedCaseCount }))),
180
- React.createElement("div", { className: "case-label-row__actions" },
181
- label.assignedCaseCount > 0 && (React.createElement(Button, { variant: ButtonVariant.link, isInline: true, onClick: () => onViewAssignedCases(label), "data-tracking-id": "case-label-view-assigned-cases" },
182
- React.createElement(Trans, null, "View assigned cases"))),
183
- React.createElement(ActionList, { isIconList: true },
184
- React.createElement(ActionListItem, null,
185
- React.createElement(Button, { icon: React.createElement(PencilAltIcon, null), "aria-label": t('Edit case label {{name}}', { name: label.name }), variant: "plain", onClick: () => onOpenEditModal(label), "data-tracking-id": "case-label-edit" })),
186
- React.createElement(ActionListItem, null,
187
- React.createElement(Button, { icon: React.createElement(TrashIcon, null), "aria-label": t('Delete case label {{name}}', { name: label.name }), variant: "plain", onClick: () => onDeleteLabel(label), "data-tracking-id": "case-label-delete" })))))),
188
- },
189
- ];
190
- return (React.createElement(React.Fragment, null,
191
- React.createElement("header", null,
192
- React.createElement("h2", null, t('Case labels')),
193
- React.createElement("p", null,
194
- React.createElement(Trans, null, "Case labels help you organize and categorize cases with custom tags, making them easier to find, filter, and manage."))),
195
- React.createElement("div", { className: "toolbar case-labels-toolbar" },
196
- React.createElement("div", { className: "toolbar-left" },
197
- hasNoLabels ? (React.createElement("span", null,
198
- React.createElement(Trans, null, "Case labels"))) : (React.createElement("label", { htmlFor: "search-case-label-input" },
199
- React.createElement(Trans, null, "Case labels"))),
200
- !hasNoLabels && (React.createElement(React.Fragment, null,
201
- React.createElement(SearchInput, { className: "pf-v6-u-flex-grow-1 pf-v6-c-search-input pf-v6-u-background-color-100", value: searchString, id: "search-case-label-input", placeholder: t('Search case label by name.'), "aria-label": t('Search case label by name'), onChange: (_, val) => setSearchString(val), onClear: () => setSearchString('') }),
202
- React.createElement("span", { className: "pf-v6-u-ml-sm" },
203
- React.createElement(Button, { variant: ButtonVariant.primary, isInline: true, onClick: onOpenAddModal, "data-tracking-id": "case-label-add-button" },
204
- React.createElement(Trans, null, "Add")))))),
205
- !hasNoLabels && (React.createElement("div", { className: "toolbar-right case-labels-toolbar__loaded pf-v6-u-color-200" }, t('{{loaded}} of {{total}} loaded.', {
206
- loaded: filteredLabels.length,
207
- total: filteredLabels.length,
208
- })))),
209
- React.createElement(AddEditCaseLabelModal, { isOpen: isModalOpen, addMode: isInAddMode, label: selectedLabel, isSaving: isCreatingLabel || isUpdatingLabel, onClose: closeModal, onSave: onSaveLabel }),
210
- React.createElement(ErrorBoundary, { errorMsgInfo: { message: t('There was an error loading case labels list') } }, hasNoLabels ? (React.createElement("div", { className: "table-wrapper case-labels-empty-state" },
211
- React.createElement(EmptyState, { headingLevel: "h2", icon: CubesIcon, titleText: t('Create your first case label'), variant: EmptyStateVariant.lg },
212
- React.createElement(EmptyStateBody, null,
213
- React.createElement(Trans, null, "Case labels help you organize and categorize cases with custom tags, making them easier to find, filter, and manage.")),
214
- React.createElement(EmptyStateFooter, null,
215
- React.createElement(Button, { variant: ButtonVariant.link, onClick: onOpenAddModal, "data-tracking-id": "case-label-empty-create-button" },
216
- React.createElement(Trans, null, "Create label")))))) : (React.createElement(ManageTable, { ariaLabel: t('Table to manage case labels'), columns: columns, data: filteredLabels, errorVariant: AlertVariant.warning, isFetching: isFetchingLabels, isError: !!labelsError, errorTitle: t('Case labels error'), errorComponent: React.createElement(Trans, null, "Could not get case labels"), pagination: false, noResultText: t('There are no results to display. Try adding a case label or refining your search') })))));
217
- }
@@ -1,2 +0,0 @@
1
- export * from './ManageCaseLabelsTab';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/ManageCaseLabels/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
@@ -1 +0,0 @@
1
- export * from './ManageCaseLabelsTab';
@@ -1,6 +0,0 @@
1
- export interface ICaseLabel {
2
- id: string;
3
- name: string;
4
- assignedCaseCount: number;
5
- }
6
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/ManageCaseLabels/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB,EAAE,MAAM,CAAC;CAC7B"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,42 +0,0 @@
1
- import { type CreateCaseGroupMemberResponse, type CreateCaseGroupResponse, type DeleteCaseGroupMemberResponse, type DeleteCaseGroupResponse, type RenameCaseGroupResponse, type ToggleDefaultGroupResponse } from '@rh-support/utils';
2
- import { type IGroupUserWithContactId } from '../utils/caseGroupMapper';
3
- interface UseCaseGroupMembersResult {
4
- data: IGroupUserWithContactId[];
5
- loading: boolean;
6
- error: Error | undefined;
7
- refetch: () => void;
8
- fetchMembers: (groupId: string) => void;
9
- }
10
- export declare function useCaseGroupMembers(): UseCaseGroupMembersResult;
11
- interface UseCreateCaseGroupResult {
12
- createGroup: (name: string, accountId: string) => Promise<CreateCaseGroupResponse>;
13
- loading: boolean;
14
- }
15
- export declare function useCreateCaseGroup(): UseCreateCaseGroupResult;
16
- interface UseCreateCaseGroupMemberResult {
17
- createMember: (contactId: string, groupId: string) => Promise<CreateCaseGroupMemberResponse>;
18
- loading: boolean;
19
- }
20
- export declare function useCreateCaseGroupMember(): UseCreateCaseGroupMemberResult;
21
- interface UseRenameCaseGroupResult {
22
- renameGroup: (id: string, newName: string) => Promise<RenameCaseGroupResponse>;
23
- loading: boolean;
24
- }
25
- export declare function useRenameCaseGroup(): UseRenameCaseGroupResult;
26
- interface UseDeleteCaseGroupResult {
27
- deleteGroup: (id: string) => Promise<DeleteCaseGroupResponse>;
28
- loading: boolean;
29
- }
30
- export declare function useDeleteCaseGroup(): UseDeleteCaseGroupResult;
31
- interface UseToggleDefaultGroupResult {
32
- toggleDefault: (contactId: string, groupId: string | null) => Promise<ToggleDefaultGroupResponse>;
33
- loading: boolean;
34
- }
35
- export declare function useToggleDefaultGroup(): UseToggleDefaultGroupResult;
36
- interface UseDeleteCaseGroupMemberResult {
37
- deleteMember: (memberId: string) => Promise<DeleteCaseGroupMemberResponse>;
38
- loading: boolean;
39
- }
40
- export declare function useDeleteCaseGroupMember(): UseDeleteCaseGroupMemberResult;
41
- export {};
42
- //# sourceMappingURL=useCaseGroupGraphQL.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useCaseGroupGraphQL.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCaseGroupGraphQL.ts"],"names":[],"mappings":"AACA,OAAO,EACH,KAAK,6BAA6B,EAClC,KAAK,uBAAuB,EAC5B,KAAK,6BAA6B,EAClC,KAAK,uBAAuB,EAE5B,KAAK,uBAAuB,EAC5B,KAAK,0BAA0B,EAQlC,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,KAAK,uBAAuB,EAAsC,MAAM,0BAA0B,CAAC;AAE5G,UAAU,yBAAyB;IAC/B,IAAI,EAAE,uBAAuB,EAAE,CAAC;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;IACzB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,YAAY,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3C;AAED,wBAAgB,mBAAmB,IAAI,yBAAyB,CA6B/D;AAED,UAAU,wBAAwB;IAC9B,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACnF,OAAO,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,kBAAkB,IAAI,wBAAwB,CAW7D;AAED,UAAU,8BAA8B;IACpC,YAAY,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,6BAA6B,CAAC,CAAC;IAC7F,OAAO,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,wBAAwB,IAAI,8BAA8B,CAgBzE;AAED,UAAU,wBAAwB;IAC9B,WAAW,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAC/E,OAAO,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,kBAAkB,IAAI,wBAAwB,CAW7D;AAED,UAAU,wBAAwB;IAC9B,WAAW,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAC9D,OAAO,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,kBAAkB,IAAI,wBAAwB,CAW7D;AAED,UAAU,2BAA2B;IACjC,aAAa,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,KAAK,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAClG,OAAO,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,qBAAqB,IAAI,2BAA2B,CAcnE;AAED,UAAU,8BAA8B;IACpC,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,6BAA6B,CAAC,CAAC;IAC3E,OAAO,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,wBAAwB,IAAI,8BAA8B,CAWzE"}
@@ -1,109 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { useMutation, useQuery } from '@apollo/client/react';
11
- import { CREATE_CASE_GROUP, CREATE_CASE_GROUP_MEMBER, DELETE_CASE_GROUP, DELETE_CASE_GROUP_MEMBER, GET_CASE_GROUP_MEMBERS, RENAME_CASE_GROUP, TOGGLE_DEFAULT_GROUP, } from '@rh-support/utils';
12
- import { useMemo, useState } from 'react';
13
- import { mapCaseGroupMemberNodeToIGroupUser } from '../utils/caseGroupMapper';
14
- export function useCaseGroupMembers() {
15
- const [groupId, setGroupId] = useState(undefined);
16
- const { data, loading, error, refetch } = useQuery(GET_CASE_GROUP_MEMBERS, {
17
- variables: { where: { Group__c: { eq: groupId } } },
18
- skip: !groupId,
19
- fetchPolicy: 'network-only',
20
- });
21
- const members = useMemo(() => {
22
- var _a, _b, _c;
23
- if (!data || !groupId)
24
- return [];
25
- const response = data;
26
- const edges = ((_c = (_b = (_a = response.redhat_support_uiapi) === null || _a === void 0 ? void 0 : _a.query) === null || _b === void 0 ? void 0 : _b.RedHatSupportCaseGroupMember__c) === null || _c === void 0 ? void 0 : _c.edges) || [];
27
- return edges
28
- .filter(({ node }) => node.Contact__r !== null)
29
- .map(({ node }) => mapCaseGroupMemberNodeToIGroupUser(node, groupId));
30
- }, [data, groupId]);
31
- const fetchMembers = (id) => {
32
- setGroupId(id);
33
- };
34
- return {
35
- data: members,
36
- loading,
37
- error: error,
38
- refetch,
39
- fetchMembers,
40
- };
41
- }
42
- export function useCreateCaseGroup() {
43
- const [mutate, { loading }] = useMutation(CREATE_CASE_GROUP);
44
- const createGroup = (name, accountId) => __awaiter(this, void 0, void 0, function* () {
45
- const result = yield mutate({
46
- variables: { name, accountId },
47
- });
48
- return result.data;
49
- });
50
- return { createGroup, loading };
51
- }
52
- export function useCreateCaseGroupMember() {
53
- const [mutate, { loading }] = useMutation(CREATE_CASE_GROUP_MEMBER);
54
- const createMember = (contactId, groupId) => __awaiter(this, void 0, void 0, function* () {
55
- const result = yield mutate({
56
- variables: {
57
- memberInput: {
58
- Contact__c: contactId,
59
- Group__c: groupId,
60
- },
61
- },
62
- });
63
- return result.data;
64
- });
65
- return { createMember, loading };
66
- }
67
- export function useRenameCaseGroup() {
68
- const [mutate, { loading }] = useMutation(RENAME_CASE_GROUP);
69
- const renameGroup = (id, newName) => __awaiter(this, void 0, void 0, function* () {
70
- const result = yield mutate({
71
- variables: { id, caseGroupPatch: { Name: newName } },
72
- });
73
- return result.data;
74
- });
75
- return { renameGroup, loading };
76
- }
77
- export function useDeleteCaseGroup() {
78
- const [mutate, { loading }] = useMutation(DELETE_CASE_GROUP);
79
- const deleteGroup = (id) => __awaiter(this, void 0, void 0, function* () {
80
- const result = yield mutate({
81
- variables: { id },
82
- });
83
- return result.data;
84
- });
85
- return { deleteGroup, loading };
86
- }
87
- export function useToggleDefaultGroup() {
88
- const [mutate, { loading }] = useMutation(TOGGLE_DEFAULT_GROUP);
89
- const toggleDefault = (contactId, groupId) => __awaiter(this, void 0, void 0, function* () {
90
- const result = yield mutate({
91
- variables: {
92
- id: contactId,
93
- contactPatch: { DefaultCaseGroup__c: groupId },
94
- },
95
- });
96
- return result.data;
97
- });
98
- return { toggleDefault, loading };
99
- }
100
- export function useDeleteCaseGroupMember() {
101
- const [mutate, { loading }] = useMutation(DELETE_CASE_GROUP_MEMBER);
102
- const deleteMember = (memberId) => __awaiter(this, void 0, void 0, function* () {
103
- const result = yield mutate({
104
- variables: { id: memberId },
105
- });
106
- return result.data;
107
- });
108
- return { deleteMember, loading };
109
- }
@@ -1,26 +0,0 @@
1
- import { type CreateCaseLabelResponse, type DeleteCaseLabelResponse, type UpdateCaseLabelResponse } from '@rh-support/utils';
2
- import { ICaseLabel } from '../components/ManageCaseLabels/types';
3
- interface UseCaseLabelsResult {
4
- labels: ICaseLabel[];
5
- loading: boolean;
6
- error: Error | undefined;
7
- refetch: () => Promise<void>;
8
- }
9
- export declare function useCaseLabels(accountId?: string): UseCaseLabelsResult;
10
- interface UseCreateCaseLabelResult {
11
- createCaseLabel: (name: string, accountId: string) => Promise<CreateCaseLabelResponse>;
12
- loading: boolean;
13
- }
14
- export declare function useCreateCaseLabel(): UseCreateCaseLabelResult;
15
- interface UseUpdateCaseLabelResult {
16
- updateCaseLabel: (id: string, name: string) => Promise<UpdateCaseLabelResponse>;
17
- loading: boolean;
18
- }
19
- export declare function useUpdateCaseLabel(): UseUpdateCaseLabelResult;
20
- interface UseDeleteCaseLabelResult {
21
- deleteCaseLabel: (id: string) => Promise<DeleteCaseLabelResponse>;
22
- loading: boolean;
23
- }
24
- export declare function useDeleteCaseLabel(): UseDeleteCaseLabelResult;
25
- export {};
26
- //# sourceMappingURL=useCaseLabelGraphQL.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useCaseLabelGraphQL.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCaseLabelGraphQL.ts"],"names":[],"mappings":"AACA,OAAO,EAEH,KAAK,uBAAuB,EAE5B,KAAK,uBAAuB,EAI5B,KAAK,uBAAuB,EAM/B,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AAQlE,UAAU,mBAAmB;IACzB,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;IACzB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAChC;AAED,wBAAgB,aAAa,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,mBAAmB,CAmCrE;AAED,UAAU,wBAAwB;IAC9B,eAAe,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACvF,OAAO,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,kBAAkB,IAAI,wBAAwB,CAkB7D;AAED,UAAU,wBAAwB;IAC9B,eAAe,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAChF,OAAO,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,kBAAkB,IAAI,wBAAwB,CAkB7D;AAED,UAAU,wBAAwB;IAC9B,eAAe,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAClE,OAAO,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,kBAAkB,IAAI,wBAAwB,CAW7D"}
@@ -1,99 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { useApolloClient, useMutation } from '@apollo/client/react';
11
- import { CREATE_CASE_LABEL, DELETE_CASE_LABEL, GET_CASE_LABELS, UPDATE_CASE_LABEL, } from '@rh-support/utils';
12
- import { useCallback, useEffect, useState } from 'react';
13
- const mapCaseLabelNode = (node) => {
14
- var _a, _b, _c, _d;
15
- return ({
16
- id: node.Id,
17
- name: (_b = (_a = node.Name) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : '',
18
- assignedCaseCount: (_d = (_c = node.Case_Label_Links__r) === null || _c === void 0 ? void 0 : _c.totalCount) !== null && _d !== void 0 ? _d : 0,
19
- });
20
- };
21
- export function useCaseLabels(accountId) {
22
- const client = useApolloClient();
23
- const [labels, setLabels] = useState([]);
24
- const [loading, setLoading] = useState(false);
25
- const [error, setError] = useState(undefined);
26
- const fetchLabels = useCallback(() => __awaiter(this, void 0, void 0, function* () {
27
- var _a, _b, _c, _d;
28
- if (!accountId) {
29
- setLabels([]);
30
- return;
31
- }
32
- setLoading(true);
33
- setError(undefined);
34
- try {
35
- const { data } = yield client.query({
36
- query: GET_CASE_LABELS,
37
- variables: { where: { Account__c: { eq: accountId } } },
38
- fetchPolicy: 'network-only',
39
- });
40
- 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.RedHatSupportCaseLabel__c) === null || _c === void 0 ? void 0 : _c.edges) !== null && _d !== void 0 ? _d : [];
41
- setLabels(edges.map(({ node }) => mapCaseLabelNode(node)).filter((label) => label.id && label.name));
42
- }
43
- catch (e) {
44
- setError(e);
45
- setLabels([]);
46
- }
47
- finally {
48
- setLoading(false);
49
- }
50
- }), [accountId, client]);
51
- useEffect(() => {
52
- fetchLabels();
53
- }, [fetchLabels]);
54
- return { labels, loading, error, refetch: fetchLabels };
55
- }
56
- export function useCreateCaseLabel() {
57
- const [mutate, { loading }] = useMutation(CREATE_CASE_LABEL);
58
- const createCaseLabel = (name, accountId) => __awaiter(this, void 0, void 0, function* () {
59
- const result = yield mutate({
60
- variables: {
61
- input: {
62
- RedHatSupportCaseLabel__c: {
63
- Name: name,
64
- Account__c: accountId,
65
- },
66
- },
67
- },
68
- });
69
- return result.data;
70
- });
71
- return { createCaseLabel, loading };
72
- }
73
- export function useUpdateCaseLabel() {
74
- const [mutate, { loading }] = useMutation(UPDATE_CASE_LABEL);
75
- const updateCaseLabel = (id, name) => __awaiter(this, void 0, void 0, function* () {
76
- const result = yield mutate({
77
- variables: {
78
- input: {
79
- Id: id,
80
- RedHatSupportCaseLabel__c: {
81
- Name: name,
82
- },
83
- },
84
- },
85
- });
86
- return result.data;
87
- });
88
- return { updateCaseLabel, loading };
89
- }
90
- export function useDeleteCaseLabel() {
91
- const [mutate, { loading }] = useMutation(DELETE_CASE_LABEL);
92
- const deleteCaseLabel = (id) => __awaiter(this, void 0, void 0, function* () {
93
- const result = yield mutate({
94
- variables: { id },
95
- });
96
- return result.data;
97
- });
98
- return { deleteCaseLabel, loading };
99
- }
@@ -1,8 +0,0 @@
1
- interface UseCurrentUserContactResult {
2
- isOrgAdmin: boolean;
3
- loading: boolean;
4
- error: Error | undefined;
5
- }
6
- export declare function useCurrentUserContact(): UseCurrentUserContactResult;
7
- export {};
8
- //# sourceMappingURL=useCurrentUserContact.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useCurrentUserContact.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCurrentUserContact.ts"],"names":[],"mappings":"AAMA,UAAU,2BAA2B;IACjC,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;CAC5B;AAED,wBAAgB,qBAAqB,IAAI,2BAA2B,CAiFnE"}
@@ -1,74 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { useApolloClient } from '@apollo/client/react';
11
- import { setLoggedInUserRoles, useGlobalDispatchContext, useGlobalStateContext } from '@rh-support/react-context';
12
- import { initUserRoles } from '@rh-support/user-permissions';
13
- import { GET_CONTACT_BY_SSO } from '@rh-support/utils';
14
- import { useCallback, useEffect, useRef, useState } from 'react';
15
- export function useCurrentUserContact() {
16
- const client = useApolloClient();
17
- const dispatch = useGlobalDispatchContext();
18
- const { globalMetadataState: { loggedInUserJwtToken, loggedInUser, loggedInUsersAccount, managedAccounts, accountManagers, bookmarkedAccounts, pcmConfig, viewAsCustomer, }, } = useGlobalStateContext();
19
- const ssoUsername = loggedInUserJwtToken === null || loggedInUserJwtToken === void 0 ? void 0 : loggedInUserJwtToken.preferred_username;
20
- const [isOrgAdmin, setIsOrgAdmin] = useState(false);
21
- const [loading, setLoading] = useState(true);
22
- const [error, setError] = useState(undefined);
23
- const hasFetched = useRef(false);
24
- const fetchContact = useCallback(() => __awaiter(this, void 0, void 0, function* () {
25
- var _a, _b, _c, _d, _e, _f;
26
- if (!ssoUsername || hasFetched.current) {
27
- if (!ssoUsername)
28
- setLoading(false);
29
- return;
30
- }
31
- hasFetched.current = true;
32
- setLoading(true);
33
- setError(undefined);
34
- try {
35
- const { data } = yield client.query({
36
- query: GET_CONTACT_BY_SSO,
37
- variables: { searchTerm: ssoUsername, namePattern: `%${ssoUsername}%` },
38
- fetchPolicy: 'cache-first',
39
- });
40
- const edges = ((_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.RedHatSupportContact) === null || _c === void 0 ? void 0 : _c.edges) || [];
41
- const match = edges[0];
42
- const adminStatus = (_f = (_e = (_d = match === null || match === void 0 ? void 0 : match.node) === null || _d === void 0 ? void 0 : _d.IsOrgAdmin__c) === null || _e === void 0 ? void 0 : _e.value) !== null && _f !== void 0 ? _f : false;
43
- setIsOrgAdmin(adminStatus);
44
- if ((loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.data) && (loggedInUsersAccount === null || loggedInUsersAccount === void 0 ? void 0 : loggedInUsersAccount.data)) {
45
- const updatedUser = Object.assign(Object.assign({}, loggedInUser.data), { isOrgAdmin: adminStatus });
46
- const { user } = initUserRoles(updatedUser, loggedInUsersAccount.data, (managedAccounts === null || managedAccounts === void 0 ? void 0 : managedAccounts.data) || [], (accountManagers === null || accountManagers === void 0 ? void 0 : accountManagers.data) || [], (bookmarkedAccounts === null || bookmarkedAccounts === void 0 ? void 0 : bookmarkedAccounts.data) || [], (pcmConfig === null || pcmConfig === void 0 ? void 0 : pcmConfig.data) || [], viewAsCustomer, loggedInUserJwtToken);
47
- setLoggedInUserRoles(dispatch, user);
48
- }
49
- }
50
- catch (e) {
51
- setError(e);
52
- setIsOrgAdmin(false);
53
- }
54
- finally {
55
- setLoading(false);
56
- }
57
- }), [
58
- client,
59
- ssoUsername,
60
- loggedInUser,
61
- loggedInUsersAccount,
62
- managedAccounts,
63
- accountManagers,
64
- bookmarkedAccounts,
65
- pcmConfig,
66
- viewAsCustomer,
67
- loggedInUserJwtToken,
68
- dispatch,
69
- ]);
70
- useEffect(() => {
71
- fetchContact();
72
- }, [fetchContact]);
73
- return { isOrgAdmin, loading, error };
74
- }
@@ -1,18 +0,0 @@
1
- import type { ICaseGroup, IGroupUser } from '@cee-eng/hydrajs/@types/api/public/caseGroups';
2
- import type { CaseGroupMemberNode, CaseGroupNode } from '@rh-support/utils';
3
- /** Extends the hydrajs IGroupUser with the Salesforce Contact record Id needed for mutations like ContactUpdate. */
4
- export interface IGroupUserWithContactId extends IGroupUser {
5
- contactSfId: string;
6
- memberRecordId: string;
7
- }
8
- /**
9
- * Maps a Salesforce GraphQL CaseGroupNode to the legacy ICaseGroup shape
10
- * used throughout the application.
11
- */
12
- export declare function mapCaseGroupNodeToICaseGroup(node: CaseGroupNode, isDefault?: boolean): ICaseGroup;
13
- /**
14
- * Maps a Salesforce GraphQL CaseGroupMemberNode to the legacy IGroupUser shape.
15
- * Derives `isDefault` by comparing the contact's DefaultCaseGroup__c against the current group Id.
16
- */
17
- export declare function mapCaseGroupMemberNodeToIGroupUser(node: CaseGroupMemberNode, groupId: string): IGroupUserWithContactId;
18
- //# sourceMappingURL=caseGroupMapper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"caseGroupMapper.d.ts","sourceRoot":"","sources":["../../../src/utils/caseGroupMapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,+CAA+C,CAAC;AAC5F,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAE5E,oHAAoH;AACpH,MAAM,WAAW,uBAAwB,SAAQ,UAAU;IACvD,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;CAC1B;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,aAAa,EAAE,SAAS,UAAQ,GAAG,UAAU,CAS/F;AAED;;;GAGG;AACH,wBAAgB,kCAAkC,CAC9C,IAAI,EAAE,mBAAmB,EACzB,OAAO,EAAE,MAAM,GAChB,uBAAuB,CA6BzB"}