@rh-support/manage 2.5.258 → 2.5.260
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/Groups/DefualtGroupSwitch/DefaultGroupSwitch.d.ts +1 -0
- package/lib/esm/components/Groups/DefualtGroupSwitch/DefaultGroupSwitch.d.ts.map +1 -1
- package/lib/esm/components/Groups/DefualtGroupSwitch/DefaultGroupSwitch.js +3 -2
- package/lib/esm/components/Groups/ManageGroupUsers/ManageGroupUsers.d.ts.map +1 -1
- package/lib/esm/components/Groups/ManageGroupUsers/ManageGroupUsers.js +71 -11
- package/lib/esm/components/ManagePreferences/sections/PreferencesCaseCreate.d.ts.map +1 -1
- package/lib/esm/components/ManagePreferences/sections/PreferencesCaseCreate.js +65 -31
- package/package.json +6 -6
|
@@ -6,6 +6,7 @@ interface IProps {
|
|
|
6
6
|
user: IGroupUserWithContactId;
|
|
7
7
|
id: string;
|
|
8
8
|
onToggle: (user: IGroupUserWithContactId, isChecked: boolean) => void;
|
|
9
|
+
onToggleSuccess?: (user: IGroupUserWithContactId, isChecked: boolean) => void;
|
|
9
10
|
}
|
|
10
11
|
export declare const DefaultGroupSwitch: (props: IProps) => React.JSX.Element;
|
|
11
12
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultGroupSwitch.d.ts","sourceRoot":"","sources":["../../../../../src/components/Groups/DefualtGroupSwitch/DefaultGroupSwitch.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+CAA+C,CAAC;AAG3E,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAE9E,UAAU,MAAM;IACZ,KAAK,EAAE,UAAU,CAAC;IAClB,IAAI,EAAE,uBAAuB,CAAC;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,CAAC,IAAI,EAAE,uBAAuB,EAAE,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"DefaultGroupSwitch.d.ts","sourceRoot":"","sources":["../../../../../src/components/Groups/DefualtGroupSwitch/DefaultGroupSwitch.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+CAA+C,CAAC;AAG3E,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAE9E,UAAU,MAAM;IACZ,KAAK,EAAE,UAAU,CAAC;IAClB,IAAI,EAAE,uBAAuB,CAAC;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,CAAC,IAAI,EAAE,uBAAuB,EAAE,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IACtE,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,uBAAuB,EAAE,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CACjF;AAED,eAAO,MAAM,kBAAkB,GAAI,OAAO,MAAM,sBAgD/C,CAAC"}
|
|
@@ -13,7 +13,7 @@ import React from 'react';
|
|
|
13
13
|
import { useTranslation } from 'react-i18next';
|
|
14
14
|
import { useToggleDefaultGroup } from '../../../hooks/useCaseGroupGraphQL';
|
|
15
15
|
export const DefaultGroupSwitch = (props) => {
|
|
16
|
-
const { group, id, user, onToggle } = props;
|
|
16
|
+
const { group, id, user, onToggle, onToggleSuccess } = props;
|
|
17
17
|
// @ts-ignore
|
|
18
18
|
const { t } = useTranslation();
|
|
19
19
|
const { toggleDefault, loading: isFetching } = useToggleDefaultGroup();
|
|
@@ -26,6 +26,7 @@ export const DefaultGroupSwitch = (props) => {
|
|
|
26
26
|
onToggle(user, isChecked);
|
|
27
27
|
const groupId = isChecked ? group.groupNum : null;
|
|
28
28
|
yield toggleDefault(user.contactSfId, groupId);
|
|
29
|
+
onToggleSuccess === null || onToggleSuccess === void 0 ? void 0 : onToggleSuccess(user, isChecked);
|
|
29
30
|
ToastNotification.addSuccessMessage(t(`Default group updated successfully`));
|
|
30
31
|
}
|
|
31
32
|
catch (e) {
|
|
@@ -40,6 +41,6 @@ export const DefaultGroupSwitch = (props) => {
|
|
|
40
41
|
}
|
|
41
42
|
});
|
|
42
43
|
return (React.createElement(React.Fragment, null,
|
|
43
|
-
React.createElement(Switch, { "aria-label": "Toggle default group", "data-tracking-id": `group-user-toggle-default-${user.isDefault ? 'off' : 'on'}`, label: t('On'), id: id, isDisabled: isFetching || !user.contactSfId, isChecked: user.isDefault, onChange: (_event, isChecked) => handleToggle(isChecked) }),
|
|
44
|
+
React.createElement(Switch, { "aria-label": "Toggle default group", "data-tracking-id": `group-user-toggle-default-${user.isDefault ? 'off' : 'on'}`, label: user.isDefault ? t('On') : t('Off'), id: id, isDisabled: isFetching || !user.contactSfId, isChecked: user.isDefault, onChange: (_event, isChecked) => handleToggle(isChecked) }),
|
|
44
45
|
React.createElement(LoadingIndicator, { show: isFetching, size: "xs" })));
|
|
45
46
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ManageGroupUsers.d.ts","sourceRoot":"","sources":["../../../../../src/components/Groups/ManageGroupUsers/ManageGroupUsers.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ManageGroupUsers.d.ts","sourceRoot":"","sources":["../../../../../src/components/Groups/ManageGroupUsers/ManageGroupUsers.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAsC5D,eAAO,MAAM,gBAAgB,yBAwV5B,CAAC"}
|
|
@@ -7,12 +7,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { Button, Modal, ModalBody, ModalFooter, ModalHeader, ModalVariant, SearchInput } from '@patternfly/react-core';
|
|
10
|
+
import { Button, Modal, ModalBody, ModalFooter, ModalHeader, ModalVariant, SearchInput, Tooltip, } from '@patternfly/react-core';
|
|
11
11
|
import { ErrorBoundary, ToastNotification, usePrevious } from '@rh-support/components';
|
|
12
|
-
import { useGlobalStateContext } from '@rh-support/react-context';
|
|
12
|
+
import { GlobalMetadataReducerConstants, useGlobalDispatchContext, useGlobalStateContext, } from '@rh-support/react-context';
|
|
13
13
|
import { ability, resourceActions, resources } from '@rh-support/user-permissions';
|
|
14
14
|
import isEmpty from 'lodash/isEmpty';
|
|
15
|
-
import React, { useEffect, useState } from 'react';
|
|
15
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
16
16
|
import { Trans, useTranslation } from 'react-i18next';
|
|
17
17
|
import { useLocation } from 'react-router-dom';
|
|
18
18
|
import { useCaseGroupMembers, useDeleteCaseGroupMember } from '../../../hooks/useCaseGroupGraphQL';
|
|
@@ -24,15 +24,53 @@ import { GroupSelect } from '../GroupSelect';
|
|
|
24
24
|
// import { GroupUserPermissionsSelect } from '../GroupUserPermissionsSelect';
|
|
25
25
|
const RemoveMemberButton = ({ user, onRemove, isDisabled }) => {
|
|
26
26
|
const { t } = useTranslation();
|
|
27
|
-
|
|
27
|
+
const button = (React.createElement(Button, { variant: "link", isDanger: true, onClick: () => onRemove(user), isAriaDisabled: user.isOrgAdmin || isDisabled }, t('Remove')));
|
|
28
|
+
if (user.isOrgAdmin) {
|
|
29
|
+
return (React.createElement(Tooltip, { content: t('Organization Administrators cannot be removed because they have access to all groups') }, button));
|
|
30
|
+
}
|
|
31
|
+
return button;
|
|
28
32
|
};
|
|
29
33
|
export const ManageGroupUsers = () => {
|
|
34
|
+
var _a, _b;
|
|
30
35
|
const { t } = useTranslation();
|
|
31
36
|
const location = useLocation();
|
|
32
|
-
const { globalMetadataState: { loggedInUsersAccount }, } = useGlobalStateContext();
|
|
37
|
+
const { globalMetadataState: { caseGroups, loggedInUsersAccount, loggedInUser }, } = useGlobalStateContext();
|
|
38
|
+
const dispatchToGlobalMetadataReducer = useGlobalDispatchContext();
|
|
33
39
|
const disableGroupSelect = !loggedInUsersAccount || !loggedInUsersAccount.data || !loggedInUsersAccount.data.accountNumber;
|
|
34
40
|
const [selectedGroup, setSelectedGroup] = useState();
|
|
35
41
|
const { data: groupUsers, loading: isFetching, fetchMembers, refetch } = useCaseGroupMembers();
|
|
42
|
+
const defaultCaseGroupId = (_b = (_a = loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.data) === null || _a === void 0 ? void 0 : _a.defaultCaseGroup) !== null && _b !== void 0 ? _b : null;
|
|
43
|
+
const membersWithOrgAdmin = useMemo(() => {
|
|
44
|
+
var _a, _b, _c, _d;
|
|
45
|
+
const loggedInContact = loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.data;
|
|
46
|
+
const selectedGroupId = selectedGroup === null || selectedGroup === void 0 ? void 0 : selectedGroup.groupNum;
|
|
47
|
+
const syncLoggedInUserDefault = (members) => {
|
|
48
|
+
if (!(loggedInContact === null || loggedInContact === void 0 ? void 0 : loggedInContact.ssoUsername) || !selectedGroupId)
|
|
49
|
+
return members;
|
|
50
|
+
return members.map((member) => member.ssoUsername === loggedInContact.ssoUsername
|
|
51
|
+
? Object.assign(Object.assign({}, member), { isDefault: defaultCaseGroupId === selectedGroupId }) : member);
|
|
52
|
+
};
|
|
53
|
+
const members = syncLoggedInUserDefault(groupUsers || []);
|
|
54
|
+
const user = loggedInContact;
|
|
55
|
+
if (!(user === null || user === void 0 ? void 0 : user.isOrgAdmin) || !user.ssoUsername || !selectedGroup)
|
|
56
|
+
return members;
|
|
57
|
+
const alreadyPresent = members.some((m) => m.ssoUsername === user.ssoUsername);
|
|
58
|
+
if (alreadyPresent)
|
|
59
|
+
return members;
|
|
60
|
+
const syntheticEntry = {
|
|
61
|
+
firstName: (_a = user.firstName) !== null && _a !== void 0 ? _a : '',
|
|
62
|
+
lastName: (_b = user.lastName) !== null && _b !== void 0 ? _b : '',
|
|
63
|
+
isOrgAdmin: true,
|
|
64
|
+
access: true,
|
|
65
|
+
write: false,
|
|
66
|
+
isDefault: defaultCaseGroupId === selectedGroup.groupNum,
|
|
67
|
+
ssoUsername: user.ssoUsername,
|
|
68
|
+
email: (_c = user.email) !== null && _c !== void 0 ? _c : '',
|
|
69
|
+
contactSfId: (_d = user.id) !== null && _d !== void 0 ? _d : '',
|
|
70
|
+
memberRecordId: '',
|
|
71
|
+
};
|
|
72
|
+
return [...members, syntheticEntry];
|
|
73
|
+
}, [groupUsers, loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.data, selectedGroup, defaultCaseGroupId]);
|
|
36
74
|
const canManageCaseGroups = ability.can(resourceActions.CREATE, resources.CASE_GROUPS);
|
|
37
75
|
const [isAddMembersModalOpen, setIsAddMembersModalOpen] = useState(false);
|
|
38
76
|
const [memberToRemove, setMemberToRemove] = useState(null);
|
|
@@ -47,9 +85,9 @@ export const ManageGroupUsers = () => {
|
|
|
47
85
|
// ToastNotification.addDangerMessage(message);
|
|
48
86
|
// }
|
|
49
87
|
// set and sort fetched data.
|
|
50
|
-
const [initialData, setInitialData] = useState(
|
|
51
|
-
const [data, setData] = useState(
|
|
52
|
-
useEffect(() => setAllData(
|
|
88
|
+
const [initialData, setInitialData] = useState(membersWithOrgAdmin);
|
|
89
|
+
const [data, setData] = useState(membersWithOrgAdmin);
|
|
90
|
+
useEffect(() => setAllData(membersWithOrgAdmin || []), [membersWithOrgAdmin]);
|
|
53
91
|
function setAllData(users) {
|
|
54
92
|
setInitialData(users);
|
|
55
93
|
setData(users);
|
|
@@ -68,6 +106,28 @@ export const ManageGroupUsers = () => {
|
|
|
68
106
|
return tempUser;
|
|
69
107
|
}));
|
|
70
108
|
};
|
|
109
|
+
const onDefaultToggleSuccess = (user, isChecked) => {
|
|
110
|
+
var _a;
|
|
111
|
+
if (user.ssoUsername !== ((_a = loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.data) === null || _a === void 0 ? void 0 : _a.ssoUsername) || !selectedGroup)
|
|
112
|
+
return;
|
|
113
|
+
const groupId = isChecked ? selectedGroup.groupNum : null;
|
|
114
|
+
const updatedLoggedInUserData = Object.assign(Object.assign({}, loggedInUser.data), { defaultCaseGroup: groupId });
|
|
115
|
+
dispatchToGlobalMetadataReducer({
|
|
116
|
+
type: GlobalMetadataReducerConstants.setLoggedInUser,
|
|
117
|
+
payload: {
|
|
118
|
+
loggedInUser: Object.assign(Object.assign({}, loggedInUser), { data: updatedLoggedInUserData }),
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
if (caseGroups === null || caseGroups === void 0 ? void 0 : caseGroups.data) {
|
|
122
|
+
const updatedGroups = caseGroups.data.map((group) => (Object.assign(Object.assign({}, group), { isDefault: groupId !== null && group.groupNum === groupId })));
|
|
123
|
+
dispatchToGlobalMetadataReducer({
|
|
124
|
+
type: GlobalMetadataReducerConstants.setCaseGroups,
|
|
125
|
+
payload: {
|
|
126
|
+
caseGroups: Object.assign(Object.assign({}, caseGroups), { data: updatedGroups }),
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
};
|
|
71
131
|
const onGroupSelect = (group) => __awaiter(void 0, void 0, void 0, function* () {
|
|
72
132
|
setSelectedGroup(group);
|
|
73
133
|
if (group) {
|
|
@@ -145,7 +205,7 @@ export const ManageGroupUsers = () => {
|
|
|
145
205
|
{
|
|
146
206
|
id: 'default',
|
|
147
207
|
title: t('Default group'),
|
|
148
|
-
cell: (user, index) => (React.createElement(DefaultGroupSwitch, { id: `${index}`, onToggle: onDefaultToggle, group: selectedGroup, user: user })),
|
|
208
|
+
cell: (user, index) => (React.createElement(DefaultGroupSwitch, { id: `${index}`, onToggle: onDefaultToggle, onToggleSuccess: onDefaultToggleSuccess, group: selectedGroup, user: user })),
|
|
149
209
|
},
|
|
150
210
|
{
|
|
151
211
|
id: 'remove',
|
|
@@ -173,12 +233,12 @@ export const ManageGroupUsers = () => {
|
|
|
173
233
|
else {
|
|
174
234
|
setData(initialData);
|
|
175
235
|
}
|
|
176
|
-
}, [initialData, userSearch, setData, previousUserSearch,
|
|
236
|
+
}, [initialData, userSearch, setData, previousUserSearch, membersWithOrgAdmin]);
|
|
177
237
|
useEffect(() => {
|
|
178
238
|
if (location.pathname !== '/manage/groups') {
|
|
179
239
|
return;
|
|
180
240
|
}
|
|
181
|
-
setAllData(
|
|
241
|
+
setAllData(membersWithOrgAdmin || []);
|
|
182
242
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
183
243
|
}, [location.pathname, loggedInUsersAccount.data]);
|
|
184
244
|
return (React.createElement(React.Fragment, null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreferencesCaseCreate.d.ts","sourceRoot":"","sources":["../../../../../src/components/ManagePreferences/sections/PreferencesCaseCreate.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PreferencesCaseCreate.d.ts","sourceRoot":"","sources":["../../../../../src/components/ManagePreferences/sections/PreferencesCaseCreate.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAA2D,MAAM,OAAO,CAAC;AAkBhF,UAAU,MAAM;CAAG;AACnB,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,qBAwNlD"}
|
|
@@ -8,48 +8,73 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { useApolloClient } from '@apollo/client/react';
|
|
11
|
-
import { publicApi } from '@cee-eng/hydrajs';
|
|
12
11
|
import { Card, CardBody, CardHeader, SelectOption } from '@patternfly/react-core';
|
|
13
|
-
import { ToastNotification
|
|
14
|
-
import { fetchLanguageMetadata, GlobalMetadataDispatchContext, GlobalMetadataReducerConstants, GlobalMetadataStateContext, } from '@rh-support/react-context';
|
|
12
|
+
import { ToastNotification } from '@rh-support/components';
|
|
13
|
+
import { fetchCaseGroupsForAccount, fetchCaseGroupsForSSO, fetchLanguageMetadata, GlobalMetadataDispatchContext, GlobalMetadataReducerConstants, GlobalMetadataStateContext, } from '@rh-support/react-context';
|
|
15
14
|
import { haventLoadedMetadata, PreferredLanguages } from '@rh-support/utils';
|
|
16
15
|
import isEmpty from 'lodash/isEmpty';
|
|
17
16
|
import map from 'lodash/map';
|
|
18
|
-
import React, { useContext, useEffect, useMemo, useState } from 'react';
|
|
17
|
+
import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
19
18
|
import { Trans, useTranslation } from 'react-i18next';
|
|
19
|
+
import { useToggleDefaultGroup } from '../../../hooks/useCaseGroupGraphQL';
|
|
20
20
|
import { useUserPreferences } from '../../../hooks/useUserPreferences';
|
|
21
21
|
import { PreferenceSelect } from '../components/PreferenceSelect';
|
|
22
|
+
const UNGROUPED_CASE_LABEL = 'Ungrouped Case';
|
|
23
|
+
function resolveDefaultGroupLabel(defaultCaseGroupId, groupList) {
|
|
24
|
+
var _a;
|
|
25
|
+
if (!defaultCaseGroupId || defaultCaseGroupId === '-1') {
|
|
26
|
+
return UNGROUPED_CASE_LABEL;
|
|
27
|
+
}
|
|
28
|
+
const defaultGroup = groupList.find((group) => group.groupNum === defaultCaseGroupId);
|
|
29
|
+
return (_a = defaultGroup === null || defaultGroup === void 0 ? void 0 : defaultGroup.name) !== null && _a !== void 0 ? _a : UNGROUPED_CASE_LABEL;
|
|
30
|
+
}
|
|
22
31
|
export function PreferencesCaseCreate(props) {
|
|
32
|
+
var _a, _b, _c, _d, _e, _f;
|
|
23
33
|
const { t } = useTranslation();
|
|
24
34
|
const apolloClient = useApolloClient();
|
|
25
|
-
const { globalMetadataState: { caseGroups, caseLanguages,
|
|
35
|
+
const { globalMetadataState: { caseGroups, caseLanguages, loggedInUser, loggedInUserJwtToken, loggedInUsersAccount }, } = useContext(GlobalMetadataStateContext);
|
|
26
36
|
const dispatchToGlobalMetadataReducer = useContext(GlobalMetadataDispatchContext);
|
|
27
37
|
const languageConst = caseLanguages.data;
|
|
28
|
-
const
|
|
29
|
-
propgateErrors: true,
|
|
30
|
-
});
|
|
38
|
+
const { toggleDefault } = useToggleDefaultGroup();
|
|
31
39
|
const groupList = useMemo(() => caseGroups.data || [], [caseGroups.data]);
|
|
32
|
-
const
|
|
33
|
-
|
|
40
|
+
const contactId = (_a = loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.data) === null || _a === void 0 ? void 0 : _a.id;
|
|
41
|
+
const defaultCaseGroupId = (_c = (_b = loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.data) === null || _b === void 0 ? void 0 : _b.defaultCaseGroup) !== null && _c !== void 0 ? _c : null;
|
|
42
|
+
const salesforceAccountId = (_d = loggedInUsersAccount.data) === null || _d === void 0 ? void 0 : _d.salesforceAccountId;
|
|
43
|
+
const loggedInContactId = (_e = loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.data) === null || _e === void 0 ? void 0 : _e.id;
|
|
44
|
+
const loggedInIsOrgAdmin = (_f = loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.data) === null || _f === void 0 ? void 0 : _f.isOrgAdmin;
|
|
45
|
+
const hasFetchedCaseGroups = useRef(false);
|
|
46
|
+
const updateDefaultGroupPref = (groupId) => __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
if (!contactId) {
|
|
48
|
+
ToastNotification.addDangerMessage(t('Cannot update default group: contact information is missing'));
|
|
49
|
+
throw new Error('Missing contact id');
|
|
50
|
+
}
|
|
34
51
|
try {
|
|
35
|
-
yield
|
|
36
|
-
const updatedGroups = groupList.map((group) => (Object.assign(Object.assign({}, group), { isDefault: group.groupNum ===
|
|
52
|
+
yield toggleDefault(contactId, groupId);
|
|
53
|
+
const updatedGroups = groupList.map((group) => (Object.assign(Object.assign({}, group), { isDefault: groupId !== null && group.groupNum === groupId })));
|
|
37
54
|
dispatchToGlobalMetadataReducer({
|
|
38
55
|
type: GlobalMetadataReducerConstants.setCaseGroups,
|
|
39
56
|
payload: {
|
|
40
57
|
caseGroups: Object.assign(Object.assign({}, caseGroups), { data: updatedGroups }),
|
|
41
58
|
},
|
|
42
59
|
});
|
|
43
|
-
|
|
60
|
+
const updatedLoggedInUserData = Object.assign(Object.assign({}, loggedInUser.data), { defaultCaseGroup: groupId });
|
|
61
|
+
dispatchToGlobalMetadataReducer({
|
|
62
|
+
type: GlobalMetadataReducerConstants.setLoggedInUser,
|
|
63
|
+
payload: {
|
|
64
|
+
loggedInUser: Object.assign(Object.assign({}, loggedInUser), { data: updatedLoggedInUserData }),
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
setOriginalDefaultGroup(resolveDefaultGroupLabel(groupId, updatedGroups));
|
|
44
68
|
}
|
|
45
69
|
catch (error) {
|
|
46
70
|
const message = String((error === null || error === void 0 ? void 0 : error.message) || '');
|
|
47
71
|
if (message.includes('insufficient access rights')) {
|
|
48
72
|
ToastNotification.addDangerMessage(t('You do not have permission to change the default group'));
|
|
49
73
|
}
|
|
50
|
-
else {
|
|
74
|
+
else if (message !== 'Missing contact id') {
|
|
51
75
|
ToastNotification.addDangerMessage(t('Failed to update default group'));
|
|
52
76
|
}
|
|
77
|
+
throw error;
|
|
53
78
|
}
|
|
54
79
|
});
|
|
55
80
|
const languagesList = map(languageConst, (cl) => ({
|
|
@@ -81,20 +106,13 @@ export function PreferencesCaseCreate(props) {
|
|
|
81
106
|
}
|
|
82
107
|
});
|
|
83
108
|
const onDefaultGroupSelect = (event, selection) => __awaiter(this, void 0, void 0, function* () {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
if (!isEmpty(groupList)) {
|
|
89
|
-
const selectedGroup = groupList.find((group) => group.name === selection);
|
|
90
|
-
if (selectedGroup) {
|
|
91
|
-
yield updateDefaultGroupPref(selectedGroup.groupNum);
|
|
92
|
-
setOriginalDefaultGroup(selectedGroup.name);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
109
|
+
if (selection === UNGROUPED_CASE_LABEL) {
|
|
110
|
+
yield updateDefaultGroupPref(null);
|
|
111
|
+
return;
|
|
95
112
|
}
|
|
96
|
-
|
|
97
|
-
|
|
113
|
+
const selectedGroup = groupList.find((group) => group.name === selection);
|
|
114
|
+
if (selectedGroup) {
|
|
115
|
+
yield updateDefaultGroupPref(selectedGroup.groupNum);
|
|
98
116
|
}
|
|
99
117
|
});
|
|
100
118
|
useEffect(() => {
|
|
@@ -112,15 +130,31 @@ export function PreferencesCaseCreate(props) {
|
|
|
112
130
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
113
131
|
}, [caseLanguages, caseGroups, dispatchToGlobalMetadataReducer, loggedInUserJwtToken]);
|
|
114
132
|
useEffect(() => {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
133
|
+
if (loggedInUser.isFetching)
|
|
134
|
+
return;
|
|
135
|
+
setOriginalDefaultGroup(resolveDefaultGroupLabel(defaultCaseGroupId, groupList));
|
|
136
|
+
}, [defaultCaseGroupId, groupList, loggedInUser.isFetching]);
|
|
118
137
|
useEffect(() => {
|
|
119
138
|
if (haventLoadedMetadata(caseLanguages)) {
|
|
120
139
|
fetchLanguageMetadata(dispatchToGlobalMetadataReducer, apolloClient);
|
|
121
140
|
}
|
|
122
141
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
123
142
|
}, [caseLanguages, apolloClient]);
|
|
143
|
+
useEffect(() => {
|
|
144
|
+
var _a;
|
|
145
|
+
if (!salesforceAccountId || loggedInUser.isFetching || !contactId)
|
|
146
|
+
return;
|
|
147
|
+
if (hasFetchedCaseGroups.current)
|
|
148
|
+
return;
|
|
149
|
+
hasFetchedCaseGroups.current = true;
|
|
150
|
+
if ((_a = loggedInUsersAccount.data) === null || _a === void 0 ? void 0 : _a.isInternal) {
|
|
151
|
+
fetchCaseGroupsForAccount(dispatchToGlobalMetadataReducer, apolloClient, salesforceAccountId, defaultCaseGroupId, loggedInContactId, loggedInIsOrgAdmin);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
fetchCaseGroupsForSSO(dispatchToGlobalMetadataReducer, apolloClient, salesforceAccountId, defaultCaseGroupId, loggedInContactId, loggedInIsOrgAdmin);
|
|
155
|
+
}
|
|
156
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
157
|
+
}, [salesforceAccountId, loggedInUser.isFetching, contactId, defaultCaseGroupId]);
|
|
124
158
|
return (React.createElement(Card, { variant: "secondary", className: "preference-card" },
|
|
125
159
|
React.createElement(CardHeader, null,
|
|
126
160
|
React.createElement("h3", null,
|
|
@@ -132,5 +166,5 @@ export function PreferencesCaseCreate(props) {
|
|
|
132
166
|
React.createElement("p", { className: "form-instructions" },
|
|
133
167
|
React.createElement(Trans, null, "Preferred language will impact future cases, not existing ones."))),
|
|
134
168
|
React.createElement("div", { className: "form-group" },
|
|
135
|
-
React.createElement(PreferenceSelect, { label: "Default group", id: defaultGroupTitleId, onSelect: onDefaultGroupSelect, selections: originalDefaultGroup }, groupList.map((
|
|
169
|
+
React.createElement(PreferenceSelect, { label: "Default group", id: defaultGroupTitleId, onSelect: onDefaultGroupSelect, selections: originalDefaultGroup }, [UNGROUPED_CASE_LABEL, ...groupList.map((group) => group.name)].map((name, index) => (React.createElement(SelectOption, { key: index, value: name })))))))));
|
|
136
170
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rh-support/manage",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.260",
|
|
4
4
|
"description": "Customer Support Manage App",
|
|
5
5
|
"author": "Jordan Eudy <jeudy100@gmail.com>",
|
|
6
6
|
"license": "ISC",
|
|
@@ -78,12 +78,12 @@
|
|
|
78
78
|
"@patternfly/patternfly": "6.2.1",
|
|
79
79
|
"@patternfly/react-core": "6.2.1",
|
|
80
80
|
"@patternfly/react-table": "6.2.1",
|
|
81
|
-
"@rh-support/components": "2.5.
|
|
81
|
+
"@rh-support/components": "2.5.211",
|
|
82
82
|
"@rh-support/configs": "2.0.75",
|
|
83
|
-
"@rh-support/react-context": "2.5.
|
|
83
|
+
"@rh-support/react-context": "2.5.306",
|
|
84
84
|
"@rh-support/types": "2.0.26",
|
|
85
|
-
"@rh-support/user-permissions": "2.5.
|
|
86
|
-
"@rh-support/utils": "2.5.
|
|
85
|
+
"@rh-support/user-permissions": "2.5.158",
|
|
86
|
+
"@rh-support/utils": "2.5.139",
|
|
87
87
|
"@types/react-beautiful-dnd": "^13.0.0",
|
|
88
88
|
"i18next": "^23.15.0",
|
|
89
89
|
"lodash": ">=4.17.15",
|
|
@@ -102,5 +102,5 @@
|
|
|
102
102
|
"defaults and supports es6-module",
|
|
103
103
|
"maintained node versions"
|
|
104
104
|
],
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "8932407838770cc8548f647dddcc44d39a34dcfd"
|
|
106
106
|
}
|