@rh-support/manage 2.6.1 → 2.6.11
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/ManageTabs.d.ts.map +1 -1
- package/lib/esm/ManageTabs.js +48 -20
- package/lib/esm/Routes.d.ts +1 -0
- package/lib/esm/Routes.d.ts.map +1 -1
- package/lib/esm/Routes.js +6 -0
- package/lib/esm/components/Configs/ConfigsTable.d.ts.map +1 -1
- package/lib/esm/components/Configs/ConfigsTable.js +33 -9
- package/lib/esm/components/Groups/AddMembersModal/AddMembersModal.d.ts +12 -0
- package/lib/esm/components/Groups/AddMembersModal/AddMembersModal.d.ts.map +1 -0
- package/lib/esm/components/Groups/AddMembersModal/AddMembersModal.js +80 -0
- package/lib/esm/components/Groups/AddMembersModal/index.d.ts +2 -0
- package/lib/esm/components/Groups/AddMembersModal/index.d.ts.map +1 -0
- package/lib/esm/components/Groups/AddMembersModal/index.js +1 -0
- package/lib/esm/components/Groups/DefualtGroupSwitch/DefaultGroupSwitch.d.ts +5 -3
- package/lib/esm/components/Groups/DefualtGroupSwitch/DefaultGroupSwitch.d.ts.map +1 -1
- package/lib/esm/components/Groups/DefualtGroupSwitch/DefaultGroupSwitch.js +21 -14
- package/lib/esm/components/Groups/GroupSelect/GroupSelect.d.ts +1 -0
- package/lib/esm/components/Groups/GroupSelect/GroupSelect.d.ts.map +1 -1
- package/lib/esm/components/Groups/GroupSelect/GroupSelect.js +240 -105
- package/lib/esm/components/Groups/GroupUserPermissionsSelect/GroupUserPermissionsSelect.d.ts.map +1 -1
- package/lib/esm/components/Groups/GroupUserPermissionsSelect/GroupUserPermissionsSelect.js +19 -14
- package/lib/esm/components/Groups/ManageGroupUsers/ManageGroupUsers.d.ts.map +1 -1
- package/lib/esm/components/Groups/ManageGroupUsers/ManageGroupUsers.js +187 -77
- package/lib/esm/components/ManageBookmarkedAccountsTab/AddEditBookmarkModal.d.ts.map +1 -1
- package/lib/esm/components/ManageBookmarkedAccountsTab/AddEditBookmarkModal.js +15 -12
- package/lib/esm/components/ManageBookmarkedAccountsTab/BookmarkAccountSelector.d.ts.map +1 -1
- package/lib/esm/components/ManageBookmarkedAccountsTab/BookmarkAccountSelector.js +106 -67
- package/lib/esm/components/ManageBookmarkedAccountsTab/BookmarkGroupSelector.d.ts.map +1 -1
- package/lib/esm/components/ManageBookmarkedAccountsTab/ManageGroupedBookmarkedAccountsTab.d.ts.map +1 -1
- package/lib/esm/components/ManageBookmarkedAccountsTab/ManageGroupedBookmarkedAccountsTab.js +15 -22
- package/lib/esm/components/ManageCaseLabels/AddEditCaseLabelModal.d.ts +19 -0
- package/lib/esm/components/ManageCaseLabels/AddEditCaseLabelModal.d.ts.map +1 -0
- package/lib/esm/components/ManageCaseLabels/AddEditCaseLabelModal.js +97 -0
- package/lib/esm/components/ManageCaseLabels/ManageCaseLabelsTab.d.ts +3 -0
- package/lib/esm/components/ManageCaseLabels/ManageCaseLabelsTab.d.ts.map +1 -0
- package/lib/esm/components/ManageCaseLabels/ManageCaseLabelsTab.js +220 -0
- package/lib/esm/components/ManageCaseLabels/index.d.ts +2 -0
- package/lib/esm/components/ManageCaseLabels/index.d.ts.map +1 -0
- package/lib/esm/components/ManageCaseLabels/index.js +1 -0
- package/lib/esm/components/ManageCaseLabels/types.d.ts +6 -0
- package/lib/esm/components/ManageCaseLabels/types.d.ts.map +1 -0
- package/lib/esm/components/ManageCaseLabels/types.js +1 -0
- package/lib/esm/components/ManageExpiredContents/ExpiredContentCategory.js +4 -4
- package/lib/esm/components/ManageExpiredContents/ExpiredContentHeader.js +1 -1
- package/lib/esm/components/ManageExpiredContents/ExpiredContentManager.d.ts.map +1 -1
- package/lib/esm/components/ManageExpiredContents/ExpiredContentManager.js +12 -12
- package/lib/esm/components/ManageExpiredContents/ExpiredContentSingleItem.js +3 -3
- package/lib/esm/components/ManageExpiredContents/ExpiredContentSingleItemView.d.ts.map +1 -1
- package/lib/esm/components/ManageExpiredContents/ExpiredContentSingleItemView.js +43 -35
- package/lib/esm/components/ManagePartnerships/NonOrgCustomerInfoModal.d.ts.map +1 -1
- package/lib/esm/components/ManagePartnerships/NonOrgCustomerInfoModal.js +8 -5
- package/lib/esm/components/ManagePartnerships/PartnershipsList.d.ts.map +1 -1
- package/lib/esm/components/ManagePartnerships/PartnershipsList.js +19 -12
- package/lib/esm/components/ManagePartnerships/PartnershipsTermsModal.d.ts.map +1 -1
- package/lib/esm/components/ManagePartnerships/PartnershipsTermsModal.js +17 -20
- package/lib/esm/components/ManagePartnerships/RequestCollaborationModal.d.ts.map +1 -1
- package/lib/esm/components/ManagePartnerships/RequestCollaborationModal.js +39 -27
- package/lib/esm/components/ManagePartnerships/Requests.d.ts +1 -0
- package/lib/esm/components/ManagePartnerships/Requests.d.ts.map +1 -1
- package/lib/esm/components/ManagePartnerships/Requests.js +22 -9
- package/lib/esm/components/ManagePartnerships/index.js +1 -1
- package/lib/esm/components/ManagePreferences/PreferencesBody.d.ts.map +1 -1
- package/lib/esm/components/ManagePreferences/PreferencesBody.js +1 -5
- package/lib/esm/components/ManagePreferences/PreferencesHeader.js +1 -1
- package/lib/esm/components/ManagePreferences/components/PreferenceSelect.d.ts +1 -1
- package/lib/esm/components/ManagePreferences/components/PreferenceSelect.d.ts.map +1 -1
- package/lib/esm/components/ManagePreferences/components/PreferenceSelect.js +26 -27
- package/lib/esm/components/ManagePreferences/components/PreferenceSwitch.d.ts.map +1 -1
- package/lib/esm/components/ManagePreferences/components/PreferenceSwitch.js +6 -6
- package/lib/esm/components/ManagePreferences/sections/PreferencesACL.d.ts.map +1 -1
- package/lib/esm/components/ManagePreferences/sections/PreferencesACL.js +8 -9
- package/lib/esm/components/ManagePreferences/sections/PreferencesCaseCreate.d.ts.map +1 -1
- package/lib/esm/components/ManagePreferences/sections/PreferencesCaseCreate.js +77 -63
- package/lib/esm/components/ManagePreferences/sections/PreferencesCaseSearch.d.ts.map +1 -1
- package/lib/esm/components/ManagePreferences/sections/PreferencesCaseSearch.js +3 -4
- package/lib/esm/components/ManagePreferences/sections/PreferencesCaseView.d.ts.map +1 -1
- package/lib/esm/components/ManagePreferences/sections/PreferencesCaseView.js +47 -103
- package/lib/esm/components/ManageTable/ManageTable.d.ts +3 -4
- package/lib/esm/components/ManageTable/ManageTable.d.ts.map +1 -1
- package/lib/esm/components/ManageTable/ManageTable.js +12 -18
- package/lib/esm/components/ManageTags/TagsManager.d.ts.map +1 -1
- package/lib/esm/components/ManageTags/TagsManager.js +58 -50
- package/lib/esm/components/NotificationEmails/NotificationEmailsModal.d.ts.map +1 -1
- package/lib/esm/components/NotificationEmails/NotificationEmailsModal.js +35 -26
- package/lib/esm/components/NotificationEmails/index.d.ts.map +1 -1
- package/lib/esm/components/NotificationEmails/index.js +10 -7
- package/lib/esm/components/TopContentManagement/CategoryLimit/CategoryLimit.d.ts.map +1 -1
- package/lib/esm/components/TopContentManagement/CategoryLimit/CategoryLimit.js +2 -3
- package/lib/esm/components/TopContentManagement/CategoryLimit/CategoryLimitGuidelines.js +6 -6
- package/lib/esm/components/TopContentManagement/CategoryLimit/QuestionAnswer.js +1 -1
- package/lib/esm/components/TopContentManagement/ContentUsage/ContentAccordion.d.ts.map +1 -1
- package/lib/esm/components/TopContentManagement/ContentUsage/ContentAccordion.js +7 -9
- package/lib/esm/components/TopContentManagement/ContentUsage/PerformanceMetricClickCount.d.ts +1 -0
- package/lib/esm/components/TopContentManagement/ContentUsage/PerformanceMetricClickCount.d.ts.map +1 -1
- package/lib/esm/components/TopContentManagement/ContentUsage/PerformanceMetricClickCount.js +2 -2
- package/lib/esm/components/TopContentManagement/ContentUsage/PerformanceMetrics.d.ts.map +1 -1
- package/lib/esm/components/TopContentManagement/ContentUsage/PerformanceMetrics.js +12 -10
- package/lib/esm/components/TopContentManagement/ContentUsage/PerformanceMetricsSelect.d.ts +2 -3
- package/lib/esm/components/TopContentManagement/ContentUsage/PerformanceMetricsSelect.d.ts.map +1 -1
- package/lib/esm/components/TopContentManagement/ContentUsage/PerformanceMetricsSelect.js +16 -9
- package/lib/esm/components/TopContentManagement/ContentUsage/VersionPerformanceMetrics.d.ts.map +1 -1
- package/lib/esm/components/TopContentManagement/ContentUsage/VersionPerformanceMetrics.js +15 -16
- package/lib/esm/components/TopContentManagement/NoTopContentFound.d.ts.map +1 -1
- package/lib/esm/components/TopContentManagement/NoTopContentFound.js +14 -15
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/AddNewCategoryDropDown.d.ts.map +1 -1
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/AddNewCategoryDropDown.js +47 -39
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/TopContentCategory.d.ts.map +1 -1
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/TopContentCategory.js +12 -6
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/TopContentCategoryNew.js +3 -3
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/TopContentComponent.d.ts.map +1 -1
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/TopContentComponent.js +11 -7
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/TopContentSingleItem.d.ts.map +1 -1
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/TopContentSingleItem.js +62 -53
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/TopContentSingleItemLink.d.ts.map +1 -1
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/TopContentSingleItemLink.js +2 -3
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentEditor.d.ts.map +1 -1
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentEditor.js +8 -9
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestion.js +2 -2
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestionHint.js +4 -5
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestionHintAccept.d.ts.map +1 -1
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestionHintAccept.js +51 -25
- package/lib/esm/components/TopContentManagement/TopContentHeader.js +1 -1
- package/lib/esm/components/TopContentManagement/TopContentProductVersionSelector.d.ts.map +1 -1
- package/lib/esm/components/TopContentManagement/TopContentProductVersionSelector.js +64 -32
- package/lib/esm/constants/GroupSelectActions.d.ts +2 -1
- package/lib/esm/constants/GroupSelectActions.d.ts.map +1 -1
- package/lib/esm/constants/GroupSelectActions.js +1 -0
- package/lib/esm/constants/PartnershipLink.d.ts +3 -0
- package/lib/esm/constants/PartnershipLink.d.ts.map +1 -0
- package/lib/esm/constants/PartnershipLink.js +2 -0
- package/lib/esm/context/ExpiredContentContextProvider.d.ts.map +1 -1
- package/lib/esm/hooks/useCaseGroupGraphQL.d.ts +42 -0
- package/lib/esm/hooks/useCaseGroupGraphQL.d.ts.map +1 -0
- package/lib/esm/hooks/useCaseGroupGraphQL.js +117 -0
- package/lib/esm/hooks/useCaseLabelGraphQL.d.ts +26 -0
- package/lib/esm/hooks/useCaseLabelGraphQL.d.ts.map +1 -0
- package/lib/esm/hooks/useCaseLabelGraphQL.js +104 -0
- package/lib/esm/hooks/useCurrentUserContact.d.ts +8 -0
- package/lib/esm/hooks/useCurrentUserContact.d.ts.map +1 -0
- package/lib/esm/hooks/useCurrentUserContact.js +74 -0
- package/lib/esm/hooks/useVersionsDiffer.d.ts.map +1 -1
- package/lib/esm/index.d.ts.map +1 -1
- package/lib/esm/index.js +2 -0
- package/lib/esm/reducers/ExpiredContentReducer.d.ts.map +1 -1
- package/lib/esm/reducers/ManagePartnershipsReducer.d.ts.map +1 -1
- package/lib/esm/reducers/TagManagmentReducer.d.ts +1 -1
- package/lib/esm/reducers/TagManagmentReducer.d.ts.map +1 -1
- package/lib/esm/reducers/TopContentHelpers.d.ts.map +1 -1
- package/lib/esm/reducers/TopContentReducer.d.ts.map +1 -1
- package/lib/esm/reducers/TopContentReducer.js +5 -2
- package/lib/esm/scss/_main.scss +266 -24
- package/lib/esm/scss/_pf-overrides.scss +66 -53
- package/lib/esm/scss/index.scss +5 -4
- package/lib/esm/utils/caseGroupMapper.d.ts +18 -0
- package/lib/esm/utils/caseGroupMapper.d.ts.map +1 -0
- package/lib/esm/utils/caseGroupMapper.js +50 -0
- package/package.json +21 -22
|
@@ -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;
|
|
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"}
|
package/lib/esm/ManageTabs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Tab, TabContent, Tabs, TabsComponent, TabTitleText } from '@patternfly/react-core';
|
|
2
|
-
import { ErrorBoundary, useDocumentTitle } from '@rh-support/components';
|
|
3
|
-
import { ability,
|
|
2
|
+
import { ErrorBoundary, LoadingIndicator, useDocumentTitle } from '@rh-support/components';
|
|
3
|
+
import { ability, 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,29 +8,46 @@ 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';
|
|
11
12
|
import { ExpiredContentManagement } from './components/ManageExpiredContents/ExpiredContentManagement';
|
|
12
|
-
|
|
13
|
+
// TODO: Uncomment when partnerships tab is re-implemented
|
|
14
|
+
// import { ManagePartnerships } from './components/ManagePartnerships/index';
|
|
13
15
|
import { ManagePreferences } from './components/ManagePreferences';
|
|
14
16
|
import { TagsManagement } from './components/ManageTags';
|
|
15
|
-
import { NotificationEmails } from './components/NotificationEmails/index';
|
|
17
|
+
// import { NotificationEmails } from './components/NotificationEmails/index';
|
|
16
18
|
import { TopContentManagement } from './components/TopContentManagement';
|
|
17
19
|
import { PageTitle } from './constants/pageTitle';
|
|
20
|
+
import { useCurrentUserContact } from './hooks/useCurrentUserContact';
|
|
18
21
|
import { Routes } from './Routes';
|
|
19
22
|
export function ManageTabs(props) {
|
|
20
23
|
var _a, _b;
|
|
21
24
|
const [activeTabKey, setActiveTabKey] = useState(0);
|
|
22
25
|
const { activeTab } = useParams();
|
|
23
26
|
const { t } = useTranslation();
|
|
24
|
-
const {
|
|
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();
|
|
25
33
|
useDocumentTitle(PageTitle.MANAGE);
|
|
26
34
|
const canViewManageTab = ability.can(resourceActions.READ, resources.MANAGE);
|
|
27
35
|
const canViewManageTopContent = ability.can(resourceActions.READ, resources.TOP_CONTENT) && canViewManageTab;
|
|
28
36
|
const canViewCaseGroups = ability.can(resourceActions.READ, resources.CASE_GROUPS) && canViewManageTab;
|
|
29
37
|
const canManageBookmarkAccounts = ability.can(resourceActions.CREATE, resources.BOOKMARK_ACCOUNTS) && canViewManageTab;
|
|
30
|
-
const canViewEmailNotificationTab = ability.can(resourceActions.READ, resources.NOTIFICATION_EMAIL);
|
|
31
|
-
|
|
32
|
-
const
|
|
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
|
+
// );
|
|
33
46
|
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
|
+
}
|
|
34
51
|
const tabsToRender = [];
|
|
35
52
|
canManageBookmarkAccounts &&
|
|
36
53
|
tabsToRender.push({
|
|
@@ -50,6 +67,15 @@ export function ManageTabs(props) {
|
|
|
50
67
|
component: React.createElement(ManageGroupUsers, null),
|
|
51
68
|
id: 'manage-groups',
|
|
52
69
|
});
|
|
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
|
|
53
79
|
canViewEmailNotificationTab &&
|
|
54
80
|
canAddCustomNotification &&
|
|
55
81
|
tabsToRender.push({
|
|
@@ -57,18 +83,20 @@ export function ManageTabs(props) {
|
|
|
57
83
|
key: 'notification-emails-tab',
|
|
58
84
|
'data-tracking-id': 'notification-emails-tab',
|
|
59
85
|
routePath: notificationEmailsRoute,
|
|
60
|
-
component:
|
|
86
|
+
component: <NotificationEmails />,
|
|
61
87
|
id: 'notification-emails',
|
|
62
88
|
});
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
+
// });
|
|
72
100
|
tabsToRender.push({
|
|
73
101
|
title: 'Preferences',
|
|
74
102
|
key: 'preferences-tab',
|
|
@@ -130,13 +158,13 @@ export function ManageTabs(props) {
|
|
|
130
158
|
return (React.createElement("div", { className: "grid-main manage" },
|
|
131
159
|
React.createElement(ErrorBoundary, { isPageLevelError: true }, (_b = (_a = tabsToRender[0]) === null || _a === void 0 ? void 0 : _a.component) !== null && _b !== void 0 ? _b : React.createElement(React.Fragment, null))));
|
|
132
160
|
/**
|
|
133
|
-
* Render array with
|
|
161
|
+
* Render array with tabs
|
|
134
162
|
*/
|
|
135
163
|
return (React.createElement("div", { className: "grid-main manage", role: "region", style: { display: 'flex' } },
|
|
136
164
|
React.createElement(Tabs, { activeKey: getActiveTabKey(), onSelect: handleTabClick, "aria-label": t('Manage tabs'), component: TabsComponent.nav, isVertical: true, style: { width: 'auto' } }, map(tabsToRender, (tab, index) => (React.createElement(Tab, { eventKey: index, tabContentRef: tab.ref, tabContentId: `pf-tab-${index}-${tab.title.split(' ')[0]}-tabpanel`, title: React.createElement(TabTitleText, null,
|
|
137
165
|
React.createElement(Trans, null, tab.title)), "data-tracking-id": tab['data-tracking-id'], key: tab.title, href: `#${props.basePath}/${tab.routePath}`, "aria-controls": tab.id })))),
|
|
138
166
|
map(tabsToRender, (tab, index) => {
|
|
139
|
-
return index === getActiveTabKey() ? (React.createElement(TabContent, { activeKey: getActiveTabKey(), id: tab.id, "aria-label": tab.title },
|
|
167
|
+
return index === getActiveTabKey() ? (React.createElement(TabContent, { activeKey: getActiveTabKey(), id: tab.id, "aria-label": tab.title, style: { borderRadius: '6px' } },
|
|
140
168
|
React.createElement(ErrorBoundary, { errorMsgInfo: {
|
|
141
169
|
message: t('There was an error loading manage tab. Please try refreshing the page.'),
|
|
142
170
|
}, isPageLevelError: true }, tab.component))) : (React.createElement(React.Fragment, null));
|
package/lib/esm/Routes.d.ts
CHANGED
package/lib/esm/Routes.d.ts.map
CHANGED
|
@@ -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,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,
|
|
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"}
|
package/lib/esm/Routes.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigsTable.d.ts","sourceRoot":"","sources":["../../../../src/components/Configs/ConfigsTable.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ConfigsTable.d.ts","sourceRoot":"","sources":["../../../../src/components/Configs/ConfigsTable.tsx"],"names":[],"mappings":"AAOA,OAAO,KAA0C,MAAM,OAAO,CAAC;AAO/D,eAAO,MAAM,YAAY,yBAqLxB,CAAC"}
|
|
@@ -10,18 +10,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { configuration, maintenance } from '@cee-eng/hydrajs';
|
|
11
11
|
import { SearchInput } from '@patternfly/react-core';
|
|
12
12
|
import { defaultTableSortMethod, ErrorBoundary, ToastNotification, useFetch } from '@rh-support/components/';
|
|
13
|
-
import {
|
|
13
|
+
import { GlobalMetadataDispatchContext, GlobalMetadataReducerConstants } from '@rh-support/react-context';
|
|
14
|
+
import { formatDate, getApiResourceObject } from '@rh-support/utils';
|
|
14
15
|
import isEmpty from 'lodash/isEmpty';
|
|
15
|
-
import React, { useEffect, useState } from 'react';
|
|
16
|
-
import { Trans } from 'react-i18next';
|
|
16
|
+
import React, { useContext, useEffect, useState } from 'react';
|
|
17
|
+
import { Trans, useTranslation } from 'react-i18next';
|
|
17
18
|
import { ManageTable } from '../ManageTable/ManageTable';
|
|
18
19
|
import { ConfigInLineEdit } from './ConfigInLineEdit';
|
|
19
20
|
import { ConfigSwitch } from './ConfigSwitch';
|
|
20
21
|
export const ConfigsTable = () => {
|
|
22
|
+
const { t } = useTranslation();
|
|
21
23
|
const [configValues, setConfigValues] = useState([]);
|
|
22
24
|
const [filteredValues, setFilteredValues] = useState([]);
|
|
23
25
|
const [searchString, setSearchString] = useState('');
|
|
24
26
|
const [keepPageNumberOnDataChange, setKeepPageNumberOnDataChange] = useState(undefined);
|
|
27
|
+
const dispatchToGlobalMetadataReducer = useContext(GlobalMetadataDispatchContext);
|
|
25
28
|
const { request: getConfigs, isFetching } = useFetch(configuration.getConfig);
|
|
26
29
|
const { request: updateConfig, isFetching: isUpdating } = useFetch(maintenance.updateHydraConfiguration, {
|
|
27
30
|
propgateErrors: true,
|
|
@@ -31,6 +34,23 @@ export const ConfigsTable = () => {
|
|
|
31
34
|
setKeepPageNumberOnDataChange(false);
|
|
32
35
|
setSearchString(str);
|
|
33
36
|
};
|
|
37
|
+
// Function to reload all configs and update the global context
|
|
38
|
+
const reloadAndUpdateContext = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
+
try {
|
|
40
|
+
const allConfigs = yield configuration.getConfig(configType);
|
|
41
|
+
setConfigValues(allConfigs);
|
|
42
|
+
setFilteredValues(allConfigs);
|
|
43
|
+
if (dispatchToGlobalMetadataReducer) {
|
|
44
|
+
dispatchToGlobalMetadataReducer({
|
|
45
|
+
type: GlobalMetadataReducerConstants.setPcmConfig,
|
|
46
|
+
payload: { pcmConfig: getApiResourceObject(allConfigs) },
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
console.error('Failed to reload configurations', error);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
34
54
|
const onUpdate = (fieldName, fieldValue, id) => __awaiter(void 0, void 0, void 0, function* () {
|
|
35
55
|
try {
|
|
36
56
|
yield updateConfig({
|
|
@@ -48,6 +68,7 @@ export const ConfigsTable = () => {
|
|
|
48
68
|
});
|
|
49
69
|
setKeepPageNumberOnDataChange(true);
|
|
50
70
|
setConfigValues(updatedData);
|
|
71
|
+
yield reloadAndUpdateContext();
|
|
51
72
|
}
|
|
52
73
|
catch (e) {
|
|
53
74
|
ToastNotification.addDangerMessage('Failed to update config');
|
|
@@ -68,9 +89,10 @@ export const ConfigsTable = () => {
|
|
|
68
89
|
},
|
|
69
90
|
{
|
|
70
91
|
// @ts-ignore
|
|
71
|
-
cell: (data) =>
|
|
92
|
+
cell: (data) => {
|
|
72
93
|
const value = data.fieldValue;
|
|
73
94
|
const name = data.fieldName;
|
|
95
|
+
console.log(data);
|
|
74
96
|
if (value === '0' || value === '1') {
|
|
75
97
|
return (React.createElement(ConfigSwitch, { id: data.id, isChecked: value === '1' ? true : false, onChange: onUpdate, isUpdating: isUpdating, fieldName: name }));
|
|
76
98
|
}
|
|
@@ -96,9 +118,11 @@ export const ConfigsTable = () => {
|
|
|
96
118
|
];
|
|
97
119
|
useEffect(() => {
|
|
98
120
|
const loadConfig = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
121
|
+
if (getConfigs) {
|
|
122
|
+
const data = yield getConfigs(configType);
|
|
123
|
+
setConfigValues(data);
|
|
124
|
+
setFilteredValues(data);
|
|
125
|
+
}
|
|
102
126
|
});
|
|
103
127
|
loadConfig();
|
|
104
128
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -120,7 +144,7 @@ export const ConfigsTable = () => {
|
|
|
120
144
|
React.createElement("div", { className: "toolbar-right" },
|
|
121
145
|
React.createElement("label", { htmlFor: "search-config-filelds" },
|
|
122
146
|
React.createElement(Trans, null, "Filter by")),
|
|
123
|
-
React.createElement(SearchInput, { className: "pf-
|
|
147
|
+
React.createElement(SearchInput, { className: "pf-v6-u-flex-grow-1 pf-v6-c-search-input pf-v6-u-background-color-100", id: "search-config-filelds", placeholder: "Search for an existing config name", value: searchString, onChange: (_, value) => onSearchChange(value), onClear: () => onSearchChange(''), "aria-label": "Search for an existing config name" }))),
|
|
124
148
|
React.createElement(ErrorBoundary, { errorMsgInfo: { message: 'There was an error loading config page' } },
|
|
125
|
-
React.createElement(ManageTable, { sortInfo: { column: 'created-date', direction: 'desc' }, ariaLabel: 'Table to manage pcm config', columns: columns, data: filteredValues, isFetching: isFetching, isError: false, errorTitle: 'Config table error', errorComponent: React.createElement(Trans, null, "Could not get configs"), keepPageNumberOnDataChange: keepPageNumberOnDataChange }))));
|
|
149
|
+
React.createElement(ManageTable, { sortInfo: { column: 'created-date', direction: 'desc' }, ariaLabel: t('Table to manage pcm config'), columns: columns, data: filteredValues, isFetching: isFetching, isError: false, errorTitle: 'Config table error', errorComponent: React.createElement(Trans, null, "Could not get configs"), keepPageNumberOnDataChange: keepPageNumberOnDataChange }))));
|
|
126
150
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ICaseGroup } from '@cee-eng/hydrajs/@types/api/public/caseGroups';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { IGroupUserWithContactId } from '../../../utils/caseGroupMapper';
|
|
4
|
+
interface IProps {
|
|
5
|
+
readonly group: ICaseGroup;
|
|
6
|
+
readonly existingMembers: IGroupUserWithContactId[];
|
|
7
|
+
readonly onSuccess: () => void;
|
|
8
|
+
readonly onClose: () => void;
|
|
9
|
+
}
|
|
10
|
+
export declare function AddMembersModal({ group, existingMembers, onSuccess, onClose }: IProps): React.JSX.Element;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=AddMembersModal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AddMembersModal.d.ts","sourceRoot":"","sources":["../../../../../src/components/Groups/AddMembersModal/AddMembersModal.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+CAA+C,CAAC;AAM3E,OAAO,KAAgC,MAAM,OAAO,CAAC;AAIrD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAE9E,UAAU,MAAM;IACZ,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,eAAe,EAAE,uBAAuB,EAAE,CAAC;IACpD,QAAQ,CAAC,SAAS,EAAE,MAAM,IAAI,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC;CAChC;AAED,wBAAgB,eAAe,CAAC,EAAE,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,MAAM,qBAyGrF"}
|
|
@@ -0,0 +1,80 @@
|
|
|
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 { Button, Modal, ModalBody, ModalFooter, ModalHeader, ModalVariant } from '@patternfly/react-core';
|
|
11
|
+
import { CaseContactsSelectorExternal, ToastNotification } from '@rh-support/components';
|
|
12
|
+
import { useGlobalStateContext } from '@rh-support/react-context';
|
|
13
|
+
import React, { useCallback, useState } from 'react';
|
|
14
|
+
import { useTranslation } from 'react-i18next';
|
|
15
|
+
import { useCreateCaseGroupMember } from '../../../hooks/useCaseGroupGraphQL';
|
|
16
|
+
export function AddMembersModal({ group, existingMembers, onSuccess, onClose }) {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
const { t } = useTranslation();
|
|
19
|
+
const { globalMetadataState: { loggedInUserRights, loggedInUsersAccount }, } = useGlobalStateContext();
|
|
20
|
+
const { createMember, loading: createLoading } = useCreateCaseGroupMember();
|
|
21
|
+
const [selectedContacts, setSelectedContacts] = useState([]);
|
|
22
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
23
|
+
const accountNumber = (_b = (_a = loggedInUsersAccount === null || loggedInUsersAccount === void 0 ? void 0 : loggedInUsersAccount.data) === null || _a === void 0 ? void 0 : _a.accountNumber) !== null && _b !== void 0 ? _b : '';
|
|
24
|
+
const contactSsoUsername = '';
|
|
25
|
+
const contactsToExclude = existingMembers.map((m) => ({
|
|
26
|
+
ssoUsername: m.ssoUsername,
|
|
27
|
+
firstName: m.firstName,
|
|
28
|
+
lastName: m.lastName,
|
|
29
|
+
}));
|
|
30
|
+
const onChange = useCallback((contacts) => {
|
|
31
|
+
if (!(contacts === null || contacts === void 0 ? void 0 : contacts.length))
|
|
32
|
+
return;
|
|
33
|
+
const contact = contacts[0];
|
|
34
|
+
if (!('ssoUsername' in contact))
|
|
35
|
+
return;
|
|
36
|
+
setSelectedContacts((prev) => {
|
|
37
|
+
const exists = prev.some((c) => c.ssoUsername === contact.ssoUsername);
|
|
38
|
+
return exists ? prev.filter((c) => c.ssoUsername !== contact.ssoUsername) : [...prev, contact];
|
|
39
|
+
});
|
|
40
|
+
}, []);
|
|
41
|
+
const onSubmit = () => __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
const validContacts = selectedContacts.filter((contact) => contact.id);
|
|
43
|
+
if (validContacts.length === 0)
|
|
44
|
+
return;
|
|
45
|
+
setIsSubmitting(true);
|
|
46
|
+
try {
|
|
47
|
+
const results = yield Promise.allSettled(validContacts.map((contact) => createMember(contact.id, group.groupNum)));
|
|
48
|
+
const succeeded = results.filter((r) => r.status === 'fulfilled');
|
|
49
|
+
const failed = results.filter((r) => r.status === 'rejected');
|
|
50
|
+
if (succeeded.length > 0) {
|
|
51
|
+
ToastNotification.addSuccessMessage(t('{{count}} people have been successfully added.', { count: succeeded.length }));
|
|
52
|
+
onSuccess();
|
|
53
|
+
}
|
|
54
|
+
if (failed.length > 0) {
|
|
55
|
+
const firstError = failed[0].reason;
|
|
56
|
+
const message = String((firstError === null || firstError === void 0 ? void 0 : firstError.message) || '');
|
|
57
|
+
if (message.includes('Organization Administrator')) {
|
|
58
|
+
ToastNotification.addDangerMessage(t('Organization Administrators cannot be added as case group members'));
|
|
59
|
+
}
|
|
60
|
+
else if (message.includes('insufficient access rights')) {
|
|
61
|
+
ToastNotification.addDangerMessage(t('You do not have permission to add members to this group'));
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
ToastNotification.addDangerMessage(t('There was an error adding members to this group. Please try again or refresh'));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
onClose();
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
setIsSubmitting(false);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
return (React.createElement(Modal, { variant: ModalVariant.medium, isOpen: true, onClose: onClose, "aria-label": t('Add members to group') },
|
|
74
|
+
React.createElement(ModalHeader, { title: t('Add members to {{groupName}}', { groupName: group.name }) }),
|
|
75
|
+
React.createElement(ModalBody, null,
|
|
76
|
+
React.createElement(CaseContactsSelectorExternal, { id: "add-members-contact-select", selectedAccountNumber: accountNumber, loggedInUserRights: loggedInUserRights.data, contactSsoUsername: contactSsoUsername, contactsToExclude: [...contactsToExclude, ...selectedContacts], contactFilter: (contact) => !contact.isOrgAdmin, selected: selectedContacts, onChange: onChange, onContactEnriched: () => { }, multiple: true, clearButton: true, isDisabled: isSubmitting, placeholder: t('Search by name or SSO username') })),
|
|
77
|
+
React.createElement(ModalFooter, null,
|
|
78
|
+
React.createElement(Button, { key: "confirm", variant: "primary", onClick: onSubmit, isDisabled: selectedContacts.length === 0 || isSubmitting || createLoading, isLoading: isSubmitting, spinnerAriaValueText: isSubmitting ? t('Adding members') : undefined }, t('Add')),
|
|
79
|
+
React.createElement(Button, { key: "cancel", variant: "link", onClick: onClose, isDisabled: isSubmitting }, t('Cancel')))));
|
|
80
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/Groups/AddMembersModal/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AddMembersModal';
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { ICaseGroup
|
|
1
|
+
import { ICaseGroup } from '@cee-eng/hydrajs/@types/api/public/caseGroups';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import type { IGroupUserWithContactId } from '../../../utils/caseGroupMapper';
|
|
3
4
|
interface IProps {
|
|
4
5
|
group: ICaseGroup;
|
|
5
|
-
user:
|
|
6
|
+
user: IGroupUserWithContactId;
|
|
6
7
|
id: string;
|
|
7
|
-
onToggle: (user:
|
|
8
|
+
onToggle: (user: IGroupUserWithContactId, isChecked: boolean) => void;
|
|
9
|
+
onToggleSuccess?: (user: IGroupUserWithContactId, isChecked: boolean) => void;
|
|
8
10
|
}
|
|
9
11
|
export declare const DefaultGroupSwitch: (props: IProps) => React.JSX.Element;
|
|
10
12
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultGroupSwitch.d.ts","sourceRoot":"","sources":["../../../../../src/components/Groups/DefualtGroupSwitch/DefaultGroupSwitch.tsx"],"names":[],"mappings":"
|
|
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"}
|
|
@@ -7,33 +7,40 @@ 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';
|
|
11
10
|
import { Switch } from '@patternfly/react-core';
|
|
12
|
-
import { LoadingIndicator, ToastNotification
|
|
13
|
-
import { useGlobalStateContext } from '@rh-support/react-context';
|
|
11
|
+
import { LoadingIndicator, ToastNotification } from '@rh-support/components';
|
|
14
12
|
import React from 'react';
|
|
15
13
|
import { useTranslation } from 'react-i18next';
|
|
14
|
+
import { useToggleDefaultGroup } from '../../../hooks/useCaseGroupGraphQL';
|
|
16
15
|
export const DefaultGroupSwitch = (props) => {
|
|
17
|
-
const {
|
|
18
|
-
const { group, id, user, onToggle } = props;
|
|
16
|
+
const { group, id, user, onToggle, onToggleSuccess } = props;
|
|
19
17
|
// @ts-ignore
|
|
20
18
|
const { t } = useTranslation();
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
+
}
|
|
26
25
|
try {
|
|
27
26
|
onToggle(user, isChecked);
|
|
28
|
-
|
|
27
|
+
const groupId = isChecked ? group.groupNum : null;
|
|
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) {
|
|
32
33
|
onToggle(user, user.isDefault);
|
|
33
|
-
|
|
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
|
+
}
|
|
34
41
|
}
|
|
35
42
|
});
|
|
36
43
|
return (React.createElement(React.Fragment, null,
|
|
37
|
-
React.createElement(Switch, { "aria-label": "Toggle default group", "data-tracking-id": `group-user-toggle-default-${user.isDefault ? 'off' : 'on'}`, label: t('On')
|
|
38
|
-
React.createElement(LoadingIndicator, { show:
|
|
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" })));
|
|
39
46
|
};
|
|
@@ -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;
|
|
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,sBAypBxC,CAAC"}
|