@rh-support/manage 2.5.276 → 2.5.281

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 -160
  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 -97
  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 -220
  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 -104
  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 -50
@@ -1 +1 @@
1
- {"version":3,"file":"ManageTabs.d.ts","sourceRoot":"","sources":["../../src/ManageTabs.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAAa,MAAM,kBAAkB,CAAC;AAiBlE,UAAU,MAAM;IACZ,UAAU,EAAE,mBAAmB,CAAC,EAAE,CAAC,CAAC;IACpC,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,qBAgOvC"}
1
+ {"version":3,"file":"ManageTabs.d.ts","sourceRoot":"","sources":["../../src/ManageTabs.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAAa,MAAM,kBAAkB,CAAC;AAclE,UAAU,MAAM;IACZ,UAAU,EAAE,mBAAmB,CAAC,EAAE,CAAC,CAAC;IACpC,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,qBAyMvC"}
@@ -1,6 +1,6 @@
1
1
  import { Tab, TabContent, Tabs, TabsComponent, TabTitleText } from '@patternfly/react-core';
2
- import { ErrorBoundary, LoadingIndicator, useDocumentTitle } from '@rh-support/components';
3
- import { ability, resourceActions, resources } from '@rh-support/user-permissions';
2
+ import { ErrorBoundary, useDocumentTitle } from '@rh-support/components';
3
+ import { ability, CaseDetailsFields, resourceActions, resources } from '@rh-support/user-permissions';
4
4
  import map from 'lodash/map';
5
5
  import React, { useState } from 'react';
6
6
  import { Trans, useTranslation } from 'react-i18next';
@@ -8,46 +8,29 @@ import { useParams } from 'react-router-dom';
8
8
  import { ConfigsTable } from './components/Configs/ConfigsTable';
9
9
  import { ManageGroupUsers } from './components/Groups/ManageGroupUsers';
10
10
  import { ManageGroupedBookmarkedAccountsTab } from './components/ManageBookmarkedAccountsTab';
11
- import { ManageCaseLabelsTab } from './components/ManageCaseLabels';
12
11
  import { ExpiredContentManagement } from './components/ManageExpiredContents/ExpiredContentManagement';
13
- // TODO: Uncomment when partnerships tab is re-implemented
14
- // import { ManagePartnerships } from './components/ManagePartnerships/index';
12
+ import { ManagePartnerships } from './components/ManagePartnerships/index';
15
13
  import { ManagePreferences } from './components/ManagePreferences';
16
14
  import { TagsManagement } from './components/ManageTags';
17
- // import { NotificationEmails } from './components/NotificationEmails/index';
15
+ import { NotificationEmails } from './components/NotificationEmails/index';
18
16
  import { TopContentManagement } from './components/TopContentManagement';
19
17
  import { PageTitle } from './constants/pageTitle';
20
- import { useCurrentUserContact } from './hooks/useCurrentUserContact';
21
18
  import { Routes } from './Routes';
22
19
  export function ManageTabs(props) {
23
20
  var _a, _b;
24
21
  const [activeTabKey, setActiveTabKey] = useState(0);
25
22
  const { activeTab } = useParams();
26
23
  const { t } = useTranslation();
27
- const { loading: contactLoading } = useCurrentUserContact();
28
- const { groupsRoute, bookmarkedAccountsRoute, caseLabelsRoute, topContentRoute,
29
- // notificationEmailsRoute,
30
- preferencesRoute, configsRoute,
31
- // partnershipsRoute, // TODO: Uncomment when partnerships tab is re-implemented
32
- tagsManagerRoute, expiredContentRoute, } = Routes.getPaths();
24
+ const { groupsRoute, bookmarkedAccountsRoute, topContentRoute, notificationEmailsRoute, preferencesRoute, configsRoute, partnershipsRoute, tagsManagerRoute, expiredContentRoute, } = Routes.getPaths();
33
25
  useDocumentTitle(PageTitle.MANAGE);
34
26
  const canViewManageTab = ability.can(resourceActions.READ, resources.MANAGE);
35
27
  const canViewManageTopContent = ability.can(resourceActions.READ, resources.TOP_CONTENT) && canViewManageTab;
36
28
  const canViewCaseGroups = ability.can(resourceActions.READ, resources.CASE_GROUPS) && canViewManageTab;
37
29
  const canManageBookmarkAccounts = ability.can(resourceActions.CREATE, resources.BOOKMARK_ACCOUNTS) && canViewManageTab;
38
- // const canViewEmailNotificationTab = ability.can(resourceActions.READ, resources.NOTIFICATION_EMAIL);
39
- // TODO: Uncomment when partnerships tab is re-implemented
40
- // const canViewPartnershipsTab = ability.can(resourceActions.READ, resources.PARTNERSHIPS);
41
- // const canAddCustomNotification = ability.can(
42
- // resourceActions.PATCH,
43
- // resources.CASE_DETAILS,
44
- // CaseDetailsFields.CASE_DETAILS_SEND_NOTIFICATIONS
45
- // );
30
+ const canViewEmailNotificationTab = ability.can(resourceActions.READ, resources.NOTIFICATION_EMAIL);
31
+ const canViewPartnershipsTab = ability.can(resourceActions.READ, resources.PARTNERSHIPS);
32
+ const canAddCustomNotification = ability.can(resourceActions.PATCH, resources.CASE_DETAILS, CaseDetailsFields.CASE_DETAILS_SEND_NOTIFICATIONS);
46
33
  const canViewConfigsTab = ability.can(resourceActions.READ, resources.APP_INTERNAL_CONFIGS);
47
- if (contactLoading) {
48
- return (React.createElement("div", { className: "grid-main manage" },
49
- React.createElement(LoadingIndicator, { show: true, size: "sm" })));
50
- }
51
34
  const tabsToRender = [];
52
35
  canManageBookmarkAccounts &&
53
36
  tabsToRender.push({
@@ -67,15 +50,6 @@ export function ManageTabs(props) {
67
50
  component: React.createElement(ManageGroupUsers, null),
68
51
  id: 'manage-groups',
69
52
  });
70
- tabsToRender.push({
71
- title: 'Case labels',
72
- key: 'case-labels-tab',
73
- 'data-tracking-id': 'manage-case-labels-tab',
74
- routePath: caseLabelsRoute,
75
- component: React.createElement(ManageCaseLabelsTab, null),
76
- id: 'manage-case-labels',
77
- });
78
- /* TODO: Re-enable notification emails tab when ready
79
53
  canViewEmailNotificationTab &&
80
54
  canAddCustomNotification &&
81
55
  tabsToRender.push({
@@ -83,20 +57,18 @@ export function ManageTabs(props) {
83
57
  key: 'notification-emails-tab',
84
58
  'data-tracking-id': 'notification-emails-tab',
85
59
  routePath: notificationEmailsRoute,
86
- component: <NotificationEmails />,
60
+ component: React.createElement(NotificationEmails, null),
87
61
  id: 'notification-emails',
88
62
  });
89
- */
90
- // TODO: Uncomment when partnerships tab is re-implemented
91
- // canViewPartnershipsTab &&
92
- // tabsToRender.push({
93
- // title: 'Partnerships',
94
- // key: 'partnerships-tab',
95
- // 'data-tracking-id': 'partnerships-tab',
96
- // routePath: partnershipsRoute,
97
- // component: <ManagePartnerships />,
98
- // id: 'partnerships',
99
- // });
63
+ canViewPartnershipsTab &&
64
+ tabsToRender.push({
65
+ title: 'Partnerships',
66
+ key: 'partnerships-tab',
67
+ 'data-tracking-id': 'partnerships-tab',
68
+ routePath: partnershipsRoute,
69
+ component: React.createElement(ManagePartnerships, null),
70
+ id: 'partnerships',
71
+ });
100
72
  tabsToRender.push({
101
73
  title: 'Preferences',
102
74
  key: 'preferences-tab',
@@ -11,7 +11,6 @@ interface ManageRoutes {
11
11
  };
12
12
  getPathsArray: () => string[];
13
13
  groups: Route;
14
- caseLabels: Route;
15
14
  savedSearches: Route;
16
15
  topContent: Route;
17
16
  expiredContent: Route;
@@ -1 +1 @@
1
- {"version":3,"file":"Routes.d.ts","sourceRoot":"","sources":["../../src/Routes.ts"],"names":[],"mappings":"AAAA,UAAU,KAAK;IACX,QAAQ,CAAC,OAAO,EAAE,MAAM,MAAM,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACzB;AAED,UAAU,YAAY;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,KAAK,CAAC;IAC1B,eAAe,EAAE,KAAK,CAAC;IACvB,QAAQ,EAAE,MAAM;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAC1C,aAAa,EAAE,MAAM,MAAM,EAAE,CAAC;IAC9B,MAAM,EAAE,KAAK,CAAC;IACd,UAAU,EAAE,KAAK,CAAC;IAClB,aAAa,EAAE,KAAK,CAAC;IACrB,UAAU,EAAE,KAAK,CAAC;IAClB,cAAc,EAAE,KAAK,CAAC;IACtB,WAAW,EAAE,KAAK,CAAC;IACnB,WAAW,EAAE,KAAK,CAAC;IACnB,kBAAkB,EAAE,KAAK,CAAC;IAC1B,OAAO,EAAE,KAAK,CAAC;IACf,YAAY,EAAE,KAAK,CAAC;CACvB;AAED,eAAO,MAAM,MAAM,EAAE,YA2FpB,CAAC"}
1
+ {"version":3,"file":"Routes.d.ts","sourceRoot":"","sources":["../../src/Routes.ts"],"names":[],"mappings":"AAAA,UAAU,KAAK;IACX,QAAQ,CAAC,OAAO,EAAE,MAAM,MAAM,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACzB;AAED,UAAU,YAAY;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,KAAK,CAAC;IAC1B,eAAe,EAAE,KAAK,CAAC;IACvB,QAAQ,EAAE,MAAM;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAC1C,aAAa,EAAE,MAAM,MAAM,EAAE,CAAC;IAC9B,MAAM,EAAE,KAAK,CAAC;IACd,aAAa,EAAE,KAAK,CAAC;IACrB,UAAU,EAAE,KAAK,CAAC;IAClB,cAAc,EAAE,KAAK,CAAC;IACtB,WAAW,EAAE,KAAK,CAAC;IACnB,WAAW,EAAE,KAAK,CAAC;IACnB,kBAAkB,EAAE,KAAK,CAAC;IAC1B,OAAO,EAAE,KAAK,CAAC;IACf,YAAY,EAAE,KAAK,CAAC;CACvB;AAED,eAAO,MAAM,MAAM,EAAE,YAqFpB,CAAC"}
package/lib/esm/Routes.js CHANGED
@@ -12,12 +12,6 @@ export const Routes = {
12
12
  return getPath(this);
13
13
  },
14
14
  },
15
- caseLabels: {
16
- path: 'case-labels',
17
- getPath() {
18
- return getPath(this);
19
- },
20
- },
21
15
  fileDiagnostics: {
22
16
  path: 'file-diagnostics',
23
17
  getPath() {
@@ -1,12 +1,10 @@
1
- import { ICaseGroup } from '@cee-eng/hydrajs/@types/api/public/caseGroups';
1
+ import { ICaseGroup, IGroupUser } from '@cee-eng/hydrajs/@types/api/public/caseGroups';
2
2
  import React from 'react';
3
- import type { IGroupUserWithContactId } from '../../../utils/caseGroupMapper';
4
3
  interface IProps {
5
4
  group: ICaseGroup;
6
- user: IGroupUserWithContactId;
5
+ user: IGroupUser;
7
6
  id: string;
8
- onToggle: (user: IGroupUserWithContactId, isChecked: boolean) => void;
9
- onToggleSuccess?: (user: IGroupUserWithContactId, isChecked: boolean) => void;
7
+ onToggle: (user: IGroupUser, isChecked: boolean) => void;
10
8
  }
11
9
  export declare const DefaultGroupSwitch: (props: IProps) => React.JSX.Element;
12
10
  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;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"}
1
+ {"version":3,"file":"DefaultGroupSwitch.d.ts","sourceRoot":"","sources":["../../../../../src/components/Groups/DefualtGroupSwitch/DefaultGroupSwitch.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,+CAA+C,CAAC;AAIvF,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,UAAU,MAAM;IACZ,KAAK,EAAE,UAAU,CAAC;IAClB,IAAI,EAAE,UAAU,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CAC5D;AAED,eAAO,MAAM,kBAAkB,GAAI,OAAO,MAAM,sBA+C/C,CAAC"}
@@ -7,40 +7,33 @@ 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 { publicApi } from '@cee-eng/hydrajs';
10
11
  import { Switch } from '@patternfly/react-core';
11
- import { LoadingIndicator, ToastNotification } from '@rh-support/components';
12
+ import { LoadingIndicator, ToastNotification, useFetch } from '@rh-support/components';
13
+ import { useGlobalStateContext } from '@rh-support/react-context';
12
14
  import React from 'react';
13
15
  import { useTranslation } from 'react-i18next';
14
- import { useToggleDefaultGroup } from '../../../hooks/useCaseGroupGraphQL';
15
16
  export const DefaultGroupSwitch = (props) => {
16
- const { group, id, user, onToggle, onToggleSuccess } = props;
17
+ const { globalMetadataState: { loggedInUsersAccount }, } = useGlobalStateContext();
18
+ const { group, id, user, onToggle } = props;
17
19
  // @ts-ignore
18
20
  const { t } = useTranslation();
19
- const { toggleDefault, loading: isFetching } = useToggleDefaultGroup();
20
- const handleToggle = (isChecked) => __awaiter(void 0, void 0, void 0, function* () {
21
- if (!user.contactSfId) {
22
- ToastNotification.addDangerMessage(t('Cannot update default group: contact information is missing'));
23
- return;
24
- }
21
+ const toggleDefaultGroupFetch = useFetch(publicApi.caseGroups.toggleDefaultGroup, {
22
+ propgateErrors: true,
23
+ });
24
+ // Handle Toggle
25
+ const toggleDefault = (isChecked) => __awaiter(void 0, void 0, void 0, function* () {
25
26
  try {
26
27
  onToggle(user, isChecked);
27
- const groupId = isChecked ? group.groupNum : null;
28
- yield toggleDefault(user.contactSfId, groupId);
29
- onToggleSuccess === null || onToggleSuccess === void 0 ? void 0 : onToggleSuccess(user, isChecked);
28
+ yield toggleDefaultGroupFetch.request(group.groupNum, user.ssoUsername, isChecked, loggedInUsersAccount.data.secureSupport);
30
29
  ToastNotification.addSuccessMessage(t(`Default group updated successfully`));
31
30
  }
32
31
  catch (e) {
33
32
  onToggle(user, user.isDefault);
34
- const message = String((e === null || e === void 0 ? void 0 : e.message) || '');
35
- if (message.includes('insufficient access rights')) {
36
- ToastNotification.addDangerMessage(t('You do not have permission to change the default group for this user'));
37
- }
38
- else {
39
- ToastNotification.addDangerMessage(t('Could not toggle default status'));
40
- }
33
+ ToastNotification.addDangerMessage(t('Could not toggle default status'));
41
34
  }
42
35
  });
43
36
  return (React.createElement(React.Fragment, null,
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) }),
45
- React.createElement(LoadingIndicator, { show: isFetching, size: "xs" })));
37
+ 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: user.access === false || user.write === false || toggleDefaultGroupFetch.isFetching, isChecked: user.isDefault, onChange: (_event, isChecked) => toggleDefault(isChecked) }),
38
+ React.createElement(LoadingIndicator, { show: toggleDefaultGroupFetch.isFetching, size: "xs" })));
46
39
  };
@@ -3,7 +3,6 @@ import React from 'react';
3
3
  interface IProps {
4
4
  isDisabled?: boolean;
5
5
  onSelect: (group: ICaseGroup | null) => void;
6
- onAddMembers?: () => void;
7
6
  }
8
7
  export declare const GroupSelect: (props: IProps) => React.JSX.Element;
9
8
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"GroupSelect.d.ts","sourceRoot":"","sources":["../../../../../src/components/Groups/GroupSelect/GroupSelect.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,+CAA+C,CAAC;AAwC3E,OAAO,KAAmD,MAAM,OAAO,CAAC;AAWxE,UAAU,MAAM;IACZ,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,KAAK,IAAI,CAAC;IAC7C,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;CAC7B;AAKD,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,sBAgpBxC,CAAC"}
1
+ {"version":3,"file":"GroupSelect.d.ts","sourceRoot":"","sources":["../../../../../src/components/Groups/GroupSelect/GroupSelect.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,+CAA+C,CAAC;AAwC3E,OAAO,KAAmD,MAAM,OAAO,CAAC;AAKxE,UAAU,MAAM;IACZ,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,KAAK,IAAI,CAAC;CAChD;AAKD,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,sBAmjBxC,CAAC"}
@@ -7,30 +7,26 @@ 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 { useApolloClient } from '@apollo/client/react';
10
+ import { publicApi } from '@cee-eng/hydrajs';
11
11
  import { Button, Divider, Dropdown, MenuContent, MenuItem, MenuList, MenuToggle, Select, SelectList, SelectOption, Spinner, TextInput, TextInputGroup, TextInputGroupMain, TextInputGroupUtilities, } from '@patternfly/react-core';
12
12
  import CogIcon from '@patternfly/react-icons/dist/js/icons/cog-icon';
13
13
  import TimesIcon from '@patternfly/react-icons/dist/js/icons/times-icon';
14
- import { AlertMessage, AlertType, ToastNotification, useConfirmation, usePrevious, useSelectKeyboardNavigator, } from '@rh-support/components';
14
+ import { AlertMessage, AlertType, ToastNotification, useConfirmation, useFetch, usePrevious, useSelectKeyboardNavigator, } from '@rh-support/components';
15
15
  import { fetchCaseGroupsForSSO, setCaseGroups, useGlobalDispatchContext, useGlobalStateContext, } from '@rh-support/react-context';
16
16
  import { ability, resourceActions, resources } from '@rh-support/user-permissions';
17
- import { GET_CASE_GROUP_MEMBERS } from '@rh-support/utils';
17
+ import { haventLoadedMetadata } from '@rh-support/utils';
18
18
  import find from 'lodash/find';
19
19
  import isEmpty from 'lodash/isEmpty';
20
- import unescape from 'lodash/unescape';
21
20
  import React, { useCallback, useEffect, useRef, useState } from 'react';
22
21
  import { Trans, useTranslation } from 'react-i18next';
23
22
  import { GroupSelectActions } from '../../../constants/GroupSelectActions';
24
- import { useCreateCaseGroup, useCreateCaseGroupMember, useDeleteCaseGroup, useRenameCaseGroup, } from '../../../hooks/useCaseGroupGraphQL';
25
23
  const actions = GroupSelectActions;
26
24
  const unGroupedCaseGroupNumber = '-1';
27
25
  export const GroupSelect = (props) => {
28
- var _a;
29
26
  const { t } = useTranslation();
30
27
  const { onSelect: onSelectProp } = props;
31
28
  const manageActionsRef = useRef();
32
- const apolloClient = useApolloClient();
33
- const { globalMetadataState: { caseGroups, loggedInUsersAccount }, } = useGlobalStateContext();
29
+ const { globalMetadataState: { caseGroups, loggedInUserJwtToken }, } = useGlobalStateContext();
34
30
  const dispatch = useGlobalDispatchContext();
35
31
  const selectAGroupText = caseGroups.isFetching
36
32
  ? t('Loading groups')
@@ -41,39 +37,11 @@ export const GroupSelect = (props) => {
41
37
  const confirmation = useConfirmation();
42
38
  const [input, setInput] = useState('');
43
39
  const [shouldFilter, setShouldFilter] = useState(false);
44
- const accountId = (_a = loggedInUsersAccount === null || loggedInUsersAccount === void 0 ? void 0 : loggedInUsersAccount.data) === null || _a === void 0 ? void 0 : _a.salesforceAccountId;
45
- // GraphQL hooks for mutations
46
- const { createGroup: createGroupMutation, loading: createLoading } = useCreateCaseGroup();
47
- const { createMember: createMemberMutation } = useCreateCaseGroupMember();
48
- const { renameGroup: renameGroupMutation, loading: renameLoading } = useRenameCaseGroup();
49
- const { deleteGroup: deleteGroupMutation, loading: deleteLoading } = useDeleteCaseGroup();
50
- const hasFetchedFromGraphQL = useRef(false);
51
- const [groupsFetchCompleted, setGroupsFetchCompleted] = useState(false);
52
- // Always fetch groups from GraphQL — never rely on potentially stale Hydra data.
53
- // Auto-select only after this settles so members can load against real group data.
54
- useEffect(() => {
55
- if (!apolloClient || !accountId) {
56
- setGroupsFetchCompleted(true);
57
- return;
58
- }
59
- if (hasFetchedFromGraphQL.current)
60
- return;
61
- hasFetchedFromGraphQL.current = true;
62
- const fetchGroups = () => __awaiter(void 0, void 0, void 0, function* () {
63
- try {
64
- yield fetchCaseGroupsForSSO(dispatch, apolloClient, accountId);
65
- }
66
- finally {
67
- setGroupsFetchCompleted(true);
68
- }
69
- });
70
- fetchGroups();
71
- }, [dispatch, apolloClient, accountId]);
72
- // Set default group once groups are loaded
40
+ // Fetch groups on init
73
41
  useEffect(() => {
74
42
  var _a, _b;
75
- if (!groupsFetchCompleted || caseGroups.isFetching)
76
- return;
43
+ if (haventLoadedMetadata(caseGroups, (data) => data === undefined))
44
+ fetchCaseGroupsForSSO(dispatch, loggedInUserJwtToken.preferred_username);
77
45
  if (isEmpty(selectedGroup) && !isEmpty(caseGroups) && ((_a = caseGroups === null || caseGroups === void 0 ? void 0 : caseGroups.data) === null || _a === void 0 ? void 0 : _a.length) > 0) {
78
46
  const defaultCaseGroup = find(caseGroups === null || caseGroups === void 0 ? void 0 : caseGroups.data, (g) => g.isDefault);
79
47
  const newSelectedGroup = (defaultCaseGroup === null || defaultCaseGroup === void 0 ? void 0 : defaultCaseGroup.groupNum) === '-1'
@@ -85,7 +53,7 @@ export const GroupSelect = (props) => {
85
53
  }
86
54
  }
87
55
  // eslint-disable-next-line react-hooks/exhaustive-deps
88
- }, [caseGroups, groupsFetchCompleted]);
56
+ }, [dispatch, loggedInUserJwtToken, caseGroups]);
89
57
  // handle dropdown open/close toggle
90
58
  const [isOpen, setIsOpen] = useState(false);
91
59
  // handle group selection
@@ -113,7 +81,6 @@ export const GroupSelect = (props) => {
113
81
  // Group actions dropdown state
114
82
  const hasGroupPermissions = ability.can(resourceActions.CREATE, resources.CASE_GROUPS);
115
83
  const [showDropdown, setShowDropdown] = useState(hasGroupPermissions);
116
- useEffect(() => setShowDropdown(hasGroupPermissions), [hasGroupPermissions]);
117
84
  const [showInput, setShowInput] = useState(false);
118
85
  const [isDropdownOpen, setIsDropdownOpen] = useState(false);
119
86
  const toggleIsDropdownOpen = () => setIsDropdownOpen(!isDropdownOpen);
@@ -123,10 +90,19 @@ export const GroupSelect = (props) => {
123
90
  closeDropdown();
124
91
  setAction(action);
125
92
  };
93
+ // fetch objects for apis
126
94
  const [showErrorMessage] = useState(false);
95
+ const createGroupFetch = useFetch(publicApi.caseGroups.createGroup, { propgateErrors: true });
96
+ const renameGroupFetch = useFetch(publicApi.caseGroups.renameGroup, { propgateErrors: true });
97
+ const deleteGroupFetch = useFetch(publicApi.caseGroups.deleteGroup, { propgateErrors: true });
98
+ const duplicateGroupFetch = useFetch(publicApi.caseGroups.createGroup, { propgateErrors: true });
127
99
  // group actions input state
128
100
  const textInputRef = useRef();
129
- const disableOnFetch = caseGroups.isFetching || createLoading || renameLoading || deleteLoading;
101
+ const disableOnFetch = caseGroups.isFetching ||
102
+ createGroupFetch.isFetching ||
103
+ renameGroupFetch.isFetching ||
104
+ deleteGroupFetch.isFetching ||
105
+ duplicateGroupFetch.isFetching;
130
106
  const onChange = (e, value) => {
131
107
  if (!showInput) {
132
108
  setIsOpen(true);
@@ -148,78 +124,56 @@ export const GroupSelect = (props) => {
148
124
  // eslint-disable-next-line react-hooks/exhaustive-deps
149
125
  }, [input, showInput]);
150
126
  // group actions
151
- function createGroup(groupName) {
127
+ function setGroupOnFetch(groupName) {
128
+ return __awaiter(this, void 0, void 0, function* () {
129
+ yield fetchCaseGroupsForSSO(dispatch, loggedInUserJwtToken.preferred_username);
130
+ setSelectedGroup(groupName);
131
+ });
132
+ }
133
+ function createGroup(groupName, ssoUsername) {
152
134
  return __awaiter(this, void 0, void 0, function* () {
153
- if (!accountId) {
154
- ToastNotification.addDangerMessage(t('There was an error while creating this group'));
155
- return;
156
- }
157
135
  try {
158
- const response = yield createGroupMutation(groupName, accountId);
159
- const createdRecord = response.redhat_support_uiapi.CaseGroup__cCreate.RedHatSupportRecord;
136
+ yield createGroupFetch.request({ name: groupName, contactSsoName: ssoUsername });
160
137
  ToastNotification.addSuccessMessage(t('Group has been successfully created'));
161
- const newGroup = {
162
- groupNum: createdRecord.Id,
163
- name: unescape(createdRecord.Name.value),
164
- isPrivate: false,
165
- isDefault: false,
166
- defaultMembers: [],
167
- members: [],
168
- };
169
- const updatedGroups = [...(caseGroups.data || []), newGroup];
170
- setCaseGroups(dispatch, updatedGroups);
171
- setShowDropdown(true);
172
- setShowInput(false);
173
- setSelectedGroup(groupName);
174
- }
175
- catch (e) {
176
- const message = String((e === null || e === void 0 ? void 0 : e.message) || '');
177
- if (message.includes('insufficient access rights')) {
178
- ToastNotification.addDangerMessage(t('You do not have permission to create this group'));
138
+ try {
139
+ yield setGroupOnFetch(groupName);
140
+ setShowDropdown(true);
141
+ setShowInput(false);
142
+ setSelectedGroup(groupName);
179
143
  }
180
- else {
181
- ToastNotification.addDangerMessage(t('There was an error while creating this group'));
144
+ catch (error) {
145
+ ToastNotification.addDangerMessage(t("We're having an issue finding this group's users"));
146
+ onClear();
182
147
  }
183
148
  }
149
+ catch (e) {
150
+ ToastNotification.addDangerMessage(t('There was an error while creating this group'));
151
+ }
184
152
  });
185
153
  }
186
154
  const [action, setAction] = useState('');
187
155
  const isUserInputAGroup = () => (caseGroups.data || []).find((value) => value.name === input);
188
- const handleDeleteGroup = () => __awaiter(void 0, void 0, void 0, function* () {
189
- const groupToDelete = getGroup(selectedGroup);
190
- yield confirmation({
191
- catchOnCancel: true,
192
- title: t('Delete group'),
193
- description: (React.createElement(Trans, null,
194
- "Are you sure you want to delete ",
195
- React.createElement("strong", null, groupToDelete.name),
196
- "?")),
197
- });
198
- yield deleteGroupMutation(groupToDelete.groupNum);
199
- const index = (caseGroups.data || []).findIndex((value) => value.name === groupToDelete.name);
200
- (caseGroups.data || []).splice(index, 1);
201
- setCaseGroups(dispatch, caseGroups.data || []);
202
- onClear();
203
- ToastNotification.addSuccessMessage(t('Group has been successfully deleted'));
204
- });
205
156
  const onAction = () => __awaiter(void 0, void 0, void 0, function* () {
206
- var _a, _b, _c, _d;
207
- const needsUniqueName = action === actions.create || action === actions.rename || action === actions.duplicate;
208
- if (needsUniqueName && isUserInputAGroup()) {
209
- ToastNotification.addWarningMessage(t('Group already exists'));
210
- return;
211
- }
212
157
  switch (action) {
213
158
  case actions.create: {
214
- yield createGroup(input);
159
+ if (isUserInputAGroup()) {
160
+ ToastNotification.addWarningMessage(t('Group already exists'));
161
+ break;
162
+ }
163
+ yield createGroup(input, loggedInUserJwtToken.preferred_username);
215
164
  setAction('');
216
165
  break;
217
166
  }
218
167
  case actions.rename: {
168
+ if (isUserInputAGroup()) {
169
+ ToastNotification.addWarningMessage(t('Group already exists'));
170
+ break;
171
+ }
219
172
  const previousGroup = selectedGroup;
220
173
  const group = getGroup(previousGroup);
221
174
  try {
222
- yield renameGroupMutation(group.groupNum, input);
175
+ // change name in the current caseGroups list
176
+ yield renameGroupFetch.request(input, group.groupNum, group.isPrivate);
223
177
  const copyCaseGroups = [...(caseGroups.data || [])];
224
178
  const index = copyCaseGroups.findIndex((value) => value.name === previousGroup);
225
179
  copyCaseGroups[index].name = input;
@@ -231,13 +185,7 @@ export const GroupSelect = (props) => {
231
185
  ToastNotification.addSuccessMessage(t('Group has been renamed'));
232
186
  }
233
187
  catch (e) {
234
- const message = String((e === null || e === void 0 ? void 0 : e.message) || '');
235
- if (message.includes('insufficient access rights')) {
236
- ToastNotification.addDangerMessage(t('You do not have permission to rename this group'));
237
- }
238
- else {
239
- ToastNotification.addDangerMessage(t('There was an error renaming this group'));
240
- }
188
+ ToastNotification.addDangerMessage(t('There was an error renaming this group '));
241
189
  }
242
190
  finally {
243
191
  setAction('');
@@ -246,13 +194,32 @@ export const GroupSelect = (props) => {
246
194
  }
247
195
  case actions.delete: {
248
196
  try {
249
- yield handleDeleteGroup();
197
+ const groupToDelete = getGroup(selectedGroup);
198
+ try {
199
+ // get confirmation on delete
200
+ yield confirmation({
201
+ catchOnCancel: true,
202
+ title: t('Delete group'),
203
+ description: (React.createElement(Trans, null,
204
+ "Are you sure you want to delete ",
205
+ React.createElement("strong", null, groupToDelete.name),
206
+ "?")),
207
+ });
208
+ // delete action is confirmed
209
+ yield deleteGroupFetch.request(groupToDelete.groupNum);
210
+ // remove group from list
211
+ const index = (caseGroups.data || []).findIndex((value) => value.name === groupToDelete.name);
212
+ (caseGroups.data || []).splice(index, 1);
213
+ setCaseGroups(dispatch, caseGroups.data || []);
214
+ onClear();
215
+ ToastNotification.addSuccessMessage(t('Group has been successfully deleted'));
216
+ }
217
+ catch (_a) {
218
+ // user didn't confirm the delete action
219
+ }
250
220
  }
251
221
  catch (e) {
252
- const message = String((e === null || e === void 0 ? void 0 : e.message) || '');
253
- if (message.includes('insufficient access rights')) {
254
- ToastNotification.addDangerMessage(t('You do not have permission to delete this group'));
255
- }
222
+ ToastNotification.addDangerMessage(t('There was an error deleting this group'));
256
223
  }
257
224
  finally {
258
225
  setAction('');
@@ -260,63 +227,23 @@ export const GroupSelect = (props) => {
260
227
  }
261
228
  }
262
229
  case actions.duplicate: {
263
- if (!accountId) {
264
- ToastNotification.addDangerMessage(t('There was an error while duplicating group'));
230
+ if (isUserInputAGroup()) {
231
+ ToastNotification.addWarningMessage(t('Group already exists'));
265
232
  break;
266
233
  }
267
234
  try {
268
- const sourceGroup = getGroup(selectedGroup);
269
- const dupResponse = yield createGroupMutation(input, accountId);
270
- const dupRecord = dupResponse.redhat_support_uiapi.CaseGroup__cCreate.RedHatSupportRecord;
271
- const newGroupId = dupRecord.Id;
272
- if (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.groupNum) {
273
- const membersResponse = yield apolloClient.query({
274
- query: GET_CASE_GROUP_MEMBERS,
275
- variables: {
276
- where: { Group__c: { eq: sourceGroup.groupNum } },
277
- first: 2000,
278
- },
279
- fetchPolicy: 'network-only',
280
- });
281
- const sourceMembers = ((_d = (_c = (_b = (_a = membersResponse.data) === null || _a === void 0 ? void 0 : _a.redhat_support_uiapi) === null || _b === void 0 ? void 0 : _b.query) === null || _c === void 0 ? void 0 : _c.RedHatSupportCaseGroupMember__c) === null || _d === void 0 ? void 0 : _d.edges) ||
282
- [];
283
- const contactIds = sourceMembers
284
- .filter(({ node }) => { var _a; return (_a = node.Contact__c) === null || _a === void 0 ? void 0 : _a.value; })
285
- .map(({ node }) => node.Contact__c.value);
286
- if (contactIds.length > 0) {
287
- const results = yield Promise.allSettled(contactIds.map((contactId) => createMemberMutation(contactId, newGroupId)));
288
- const failed = results.filter((r) => r.status === 'rejected');
289
- if (failed.length > 0) {
290
- ToastNotification.addWarningMessage(t('Group duplicated but {{count}} members could not be copied', {
291
- count: failed.length,
292
- }));
293
- }
294
- }
295
- }
296
- const dupGroup = {
297
- groupNum: newGroupId,
298
- name: unescape(dupRecord.Name.value),
299
- isPrivate: false,
300
- isDefault: false,
301
- defaultMembers: [],
302
- members: [],
303
- };
304
- const updatedDupGroups = [...(caseGroups.data || []), dupGroup];
305
- setCaseGroups(dispatch, updatedDupGroups);
235
+ yield duplicateGroupFetch.request({
236
+ name: input,
237
+ contactSsoName: loggedInUserJwtToken.preferred_username,
238
+ });
239
+ yield setGroupOnFetch(input);
306
240
  setShowDropdown(true);
307
241
  setShowInput(false);
308
- setSelectedGroup(input);
309
242
  setInput('');
310
243
  ToastNotification.addSuccessMessage(t('Group has been successfully duplicated'));
311
244
  }
312
245
  catch (e) {
313
- const message = String((e === null || e === void 0 ? void 0 : e.message) || '');
314
- if (message.includes('insufficient access rights')) {
315
- ToastNotification.addDangerMessage(t('You do not have permission to duplicate this group'));
316
- }
317
- else {
318
- ToastNotification.addDangerMessage(t('There was an error while duplicating group'));
319
- }
246
+ ToastNotification.addDangerMessage(t('There was an error while duplicating group'));
320
247
  }
321
248
  finally {
322
249
  setAction('');
@@ -357,17 +284,11 @@ export const GroupSelect = (props) => {
357
284
  setAction('');
358
285
  setInput(selectedGroup);
359
286
  };
360
- const handleAddMembers = () => {
361
- var _a;
362
- closeDropdown();
363
- (_a = props.onAddMembers) === null || _a === void 0 ? void 0 : _a.call(props);
364
- };
365
287
  const dropdownItems = [
366
288
  React.createElement(MenuItem, { className: "create-group-action", isDisabled: !ability.can(resourceActions.CREATE, resources.CASE_GROUPS), key: "create", onClick: onActionFocus(actions.create), "data-tracking-id": "manage-group-create" }, t('Create')),
367
289
  React.createElement(Divider, { component: "li" }),
368
290
  React.createElement(MenuItem, { className: "create-group-action", isDisabled: !selectedGroup || !ability.can(resourceActions.UPDATE, resources.CASE_GROUPS), key: "rename", onClick: onActionFocus(actions.rename), "data-tracking-id": "manage-group-rename" }, t('Rename')),
369
291
  React.createElement(MenuItem, { className: "create-group-action", isDisabled: !selectedGroup || !ability.can(resourceActions.CREATE, resources.CASE_GROUPS), key: "duplicate", onClick: onActionFocus(actions.duplicate), "data-tracking-id": "manage-group-duplicate" }, t('Duplicate')),
370
- React.createElement(MenuItem, { className: "create-group-action", isDisabled: !selectedGroup || !ability.can(resourceActions.CREATE, resources.CASE_GROUPS), key: "add-members", onClick: handleAddMembers, "data-tracking-id": "manage-group-add-members" }, t('Add members')),
371
292
  React.createElement(MenuItem, { isDanger: true, className: "create-group-action del-btn", isDisabled: !selectedGroup || !ability.can(resourceActions.DELETE, resources.CASE_GROUPS), key: "delete", onClick: onActionFocus(actions.delete), "data-tracking-id": "manage-group-delete" }, t('Delete')),
372
293
  ];
373
294
  const dropdownToggle = (toggleRef) => (React.createElement(MenuToggle, { isFullHeight: true, className: "pf-v6-u-ml-sm manage-group-actions-toggle-options pf-v6-u-p-md", ref: toggleRef, isDisabled: props.isDisabled || disableOnFetch, onClick: toggleIsDropdownOpen, isExpanded: isDropdownOpen, "data-tracking-id": "manage-group-toggle-options", "aria-label": "Group actions dropdown toggle", icon: React.createElement(CogIcon, null) }));
@@ -394,11 +315,14 @@ export const GroupSelect = (props) => {
394
315
  };
395
316
  const selectTypeahead = manageActionsRef.current.querySelector('input');
396
317
  if (!showInput) {
318
+ // adds event listeners that prevent using enter to select a group.
397
319
  selectTypeahead.addEventListener('keydown', dontSubmitOnEnterCb);
398
320
  selectTypeahead.addEventListener('keyup', dontSubmitOnEnterCb);
399
321
  selectTypeahead.addEventListener('keypress', dontSubmitOnEnterCb);
400
322
  }
401
323
  else {
324
+ // adds event listeners that allows submitting actions using enter on select
325
+ // inupt used for getting user input for actions.
402
326
  selectTypeahead.addEventListener('keydown', submitOnEnterCb);
403
327
  }
404
328
  return () => {
@@ -412,6 +336,7 @@ export const GroupSelect = (props) => {
412
336
  }
413
337
  };
414
338
  }, [manageActionsRef, showInput]);
339
+ //added for validation of new group name
415
340
  const containsOnlySpecialChars = (str) => {
416
341
  return /^[^a-zA-Z0-9]*$/.test(str);
417
342
  };
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"ManageGroupUsers.d.ts","sourceRoot":"","sources":["../../../../../src/components/Groups/ManageGroupUsers/ManageGroupUsers.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAS5D,eAAO,MAAM,gBAAgB,yBA4L5B,CAAC"}