@rh-support/manage 2.1.82 → 2.1.84

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 (53) hide show
  1. package/lib/esm/Manage.d.ts.map +1 -1
  2. package/lib/esm/Manage.js +4 -3
  3. package/lib/esm/ManageTabs.d.ts +1 -0
  4. package/lib/esm/ManageTabs.d.ts.map +1 -1
  5. package/lib/esm/ManageTabs.js +44 -40
  6. package/lib/esm/Routes.d.ts +1 -0
  7. package/lib/esm/Routes.d.ts.map +1 -1
  8. package/lib/esm/Routes.js +15 -9
  9. package/lib/esm/components/Configs/ConfigsTable.js +1 -1
  10. package/lib/esm/components/Groups/ManageGroupUsers/ManageGroupUsers.js +1 -1
  11. package/lib/esm/components/ManageBookmarkedAccountsTab/ManageGroupedBookmarkedAccountsTab.js +1 -1
  12. package/lib/esm/components/ManagePartnerships/index.js +1 -1
  13. package/lib/esm/components/ManagePreferences/ManagePreferences.d.ts.map +1 -1
  14. package/lib/esm/components/ManagePreferences/ManagePreferences.js +1 -2
  15. package/lib/esm/components/ManagePreferences/PreferencesBody.js +1 -1
  16. package/lib/esm/components/ManageTags/TagsManagement.d.ts +3 -0
  17. package/lib/esm/components/ManageTags/TagsManagement.d.ts.map +1 -0
  18. package/lib/esm/components/ManageTags/TagsManagement.js +11 -0
  19. package/lib/esm/components/ManageTags/TagsManager.d.ts +3 -0
  20. package/lib/esm/components/ManageTags/TagsManager.d.ts.map +1 -0
  21. package/lib/esm/components/ManageTags/TagsManager.js +240 -0
  22. package/lib/esm/components/ManageTags/index.d.ts +2 -0
  23. package/lib/esm/components/ManageTags/index.d.ts.map +1 -0
  24. package/lib/esm/components/ManageTags/index.js +1 -0
  25. package/lib/esm/components/NotificationEmails/index.js +1 -1
  26. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/TopContentComponent.d.ts.map +1 -1
  27. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/TopContentComponent.js +1 -1
  28. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/TopContentSingleItem.d.ts +2 -1
  29. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/TopContentSingleItem.d.ts.map +1 -1
  30. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/TopContentSingleItem.js +43 -11
  31. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentEditor.d.ts.map +1 -1
  32. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentEditor.js +38 -9
  33. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestion.d.ts +1 -0
  34. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestion.d.ts.map +1 -1
  35. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestion.js +35 -10
  36. package/lib/esm/components/TopContentManagement/TopContentManagement.d.ts.map +1 -1
  37. package/lib/esm/components/TopContentManagement/TopContentManagement.js +4 -3
  38. package/lib/esm/context/TagManagementContextProvider.d.ts +8 -0
  39. package/lib/esm/context/TagManagementContextProvider.d.ts.map +1 -0
  40. package/lib/esm/context/TagManagementContextProvider.js +10 -0
  41. package/lib/esm/reducers/TagManagmentReducer.d.ts +27 -0
  42. package/lib/esm/reducers/TagManagmentReducer.d.ts.map +1 -0
  43. package/lib/esm/reducers/TagManagmentReducer.js +127 -0
  44. package/lib/esm/reducers/TopContentReducer.d.ts +5 -4
  45. package/lib/esm/reducers/TopContentReducer.d.ts.map +1 -1
  46. package/lib/esm/reducers/TopContentReducer.js +10 -2
  47. package/lib/esm/scss/_main.scss +48 -12
  48. package/lib/esm/scss/_pf-overrides.scss +24 -0
  49. package/lib/esm/scss/index.scss +2 -2
  50. package/package.json +12 -10
  51. package/lib/esm/ManageTab.d.ts +0 -10
  52. package/lib/esm/ManageTab.d.ts.map +0 -1
  53. package/lib/esm/ManageTab.js +0 -22
@@ -1 +1 @@
1
- {"version":3,"file":"Manage.d.ts","sourceRoot":"","sources":["../../src/Manage.tsx"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,CAAC;AAI3B,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAC1D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAKvD,MAAM,WAAW,qBAAqB;CAAG;AACzC,UAAU,MAAM;IACZ,UAAU,EAAE,mBAAmB,CAAC,qBAAqB,CAAC,CAAC;IACvD,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ,SAAS,EAAE,GAAG,CAAC;QACf,oBAAoB,EAAE,GAAG,CAAC;QAC1B,MAAM,EAAE,GAAG,CAAC;QACZ,KAAK,EAAE,GAAG,CAAC;QACX,aAAa,EAAE;YACX,cAAc,EAAE,MAAM,CAAC;YACvB,OAAO,EAAE,MAAM,CAAC;SACnB,CAAC;KACL;IAED,UAAU,QAAQ;QACd,YAAY,EAAE,GAAG,CAAC;KACrB;IAED,UAAU,GAAG,CAAC;QACV,UAAU,iBAAkB,SAAQ,QAAQ;SAAG;KAClD;CACJ;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,qBAUnC"}
1
+ {"version":3,"file":"Manage.d.ts","sourceRoot":"","sources":["../../src/Manage.tsx"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,CAAC;AAI3B,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAC1D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAS,mBAAmB,EAAU,MAAM,kBAAkB,CAAC;AAItE,MAAM,WAAW,qBAAqB;CAAG;AACzC,UAAU,MAAM;IACZ,UAAU,EAAE,mBAAmB,CAAC,qBAAqB,CAAC,CAAC;IACvD,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ,SAAS,EAAE,GAAG,CAAC;QACf,oBAAoB,EAAE,GAAG,CAAC;QAC1B,MAAM,EAAE,GAAG,CAAC;QACZ,KAAK,EAAE,GAAG,CAAC;QACX,aAAa,EAAE;YACX,cAAc,EAAE,MAAM,CAAC;YACvB,OAAO,EAAE,MAAM,CAAC;SACnB,CAAC;KACL;IAED,UAAU,QAAQ;QACd,YAAY,EAAE,GAAG,CAAC;KACrB;IAED,UAAU,GAAG,CAAC;QACV,UAAU,iBAAkB,SAAQ,QAAQ;SAAG;KAClD;CACJ;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,qBAYnC"}
package/lib/esm/Manage.js CHANGED
@@ -1,11 +1,12 @@
1
1
  import './scss/index.scss';
2
2
  import { ConfirmationServiceProvider } from '@rh-support/components';
3
3
  import React from 'react';
4
+ import { Route, Switch } from 'react-router-dom';
4
5
  import { ManageTabs } from './ManageTabs';
5
- import { Routes } from './Routes';
6
6
  export function Manage(props) {
7
- Routes.basePath = props.basePath;
8
7
  return (React.createElement("div", { id: "rh-support-manage" },
9
8
  React.createElement(ConfirmationServiceProvider, null,
10
- React.createElement(ManageTabs, { routeProps: props.routeProps }))));
9
+ React.createElement(Switch, null,
10
+ React.createElement(Route, { path: `${props.basePath}/:activeTab?` },
11
+ React.createElement(ManageTabs, { routeProps: props.routeProps, basePath: props.basePath }))))));
11
12
  }
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { RouteComponentProps } from 'react-router-dom';
3
3
  interface IProps {
4
4
  routeProps: RouteComponentProps<{}>;
5
+ basePath: string;
5
6
  }
6
7
  export declare function ManageTabs(props: IProps): React.JSX.Element;
7
8
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"ManageTabs.d.ts","sourceRoot":"","sources":["../../src/ManageTabs.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAavD,UAAU,MAAM;IACZ,UAAU,EAAE,mBAAmB,CAAC,EAAE,CAAC,CAAC;CACvC;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,qBA4JvC"}
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;AAalE,UAAU,MAAM;IACZ,UAAU,EAAE,mBAAmB,CAAC,EAAE,CAAC,CAAC;IACpC,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,qBAyLvC"}
@@ -1,28 +1,27 @@
1
+ import { Tab, TabContent, Tabs, TabsComponent, TabTitleText } from '@patternfly/react-core';
1
2
  import { ErrorBoundary, useDocumentTitle } from '@rh-support/components';
2
3
  import { ability, CaseDetailsFields, resourceActions, resources } from '@rh-support/user-permissions';
3
4
  import map from 'lodash/map';
4
- import React from 'react';
5
+ import React, { useState } from 'react';
6
+ import { Trans, useTranslation } from 'react-i18next';
7
+ import { useParams } from 'react-router-dom';
5
8
  import { ConfigsTable } from './components/Configs/ConfigsTable';
6
9
  import { ManageGroupUsers } from './components/Groups/ManageGroupUsers';
7
10
  import { ManageGroupedBookmarkedAccountsTab } from './components/ManageBookmarkedAccountsTab';
8
11
  import { ManagePartnerships } from './components/ManagePartnerships/index';
9
12
  import { ManagePreferences } from './components/ManagePreferences';
13
+ import { TagsManagement } from './components/ManageTags';
10
14
  import { NotificationEmails } from './components/NotificationEmails/index';
11
15
  import { TopContentManagement } from './components/TopContentManagement';
12
16
  import { PageTitle } from './constants/pageTitle';
13
- import { ManageTab } from './ManageTab';
14
17
  import { Routes } from './Routes';
15
18
  export function ManageTabs(props) {
16
19
  var _a, _b;
17
- const history = props.routeProps.history;
18
- const { groupsRoute, bookmarkedAccountsRoute, topContentRoute, notificationEmailsRoute, preferencesRoute, configsRoute, partnershipsRoute, } = Routes.getPaths();
19
- // Changes route and saves the current path to the url query params
20
- const isOnlyBasePath = history.location.pathname === Routes.basePath;
20
+ const [activeTabKey, setActiveTabKey] = useState(0);
21
+ const { activeTab } = useParams();
22
+ const { t } = useTranslation();
23
+ const { groupsRoute, bookmarkedAccountsRoute, topContentRoute, notificationEmailsRoute, preferencesRoute, configsRoute, partnershipsRoute, tagsManagerRoute, } = Routes.getPaths();
21
24
  useDocumentTitle(PageTitle.MANAGE);
22
- const changeRouteThunk = (route) => {
23
- // add last selected manage tab to session storage
24
- history.push(route);
25
- };
26
25
  const canViewManageTab = ability.can(resourceActions.READ, resources.MANAGE);
27
26
  const canViewManageTopContent = ability.can(resourceActions.READ, resources.TOP_CONTENT) && canViewManageTab;
28
27
  const canViewCaseGroups = ability.can(resourceActions.READ, resources.CASE_GROUPS) && canViewManageTab;
@@ -38,10 +37,8 @@ export function ManageTabs(props) {
38
37
  key: 'bookmarked-accounts-tab',
39
38
  'data-tracking-id': 'manage-bookmarks-tab',
40
39
  routePath: bookmarkedAccountsRoute,
41
- onClick: () => {
42
- changeRouteThunk(bookmarkedAccountsRoute);
43
- },
44
40
  component: React.createElement(ManageGroupedBookmarkedAccountsTab, { canManageBookmarkAccounts: canManageBookmarkAccounts }),
41
+ id: 'manage-bookmarked-accounts',
45
42
  });
46
43
  canViewCaseGroups &&
47
44
  tabsToRender.push({
@@ -49,10 +46,8 @@ export function ManageTabs(props) {
49
46
  key: 'groups-tab',
50
47
  routePath: groupsRoute,
51
48
  'data-tracking-id': 'manage-groups-tab',
52
- onClick: () => {
53
- changeRouteThunk(groupsRoute);
54
- },
55
49
  component: React.createElement(ManageGroupUsers, null),
50
+ id: 'manage-groups',
56
51
  });
57
52
  canViewEmailNotificationTab &&
58
53
  canAddCustomNotification &&
@@ -61,10 +56,8 @@ export function ManageTabs(props) {
61
56
  key: 'notification-emails-tab',
62
57
  'data-tracking-id': 'notification-emails-tab',
63
58
  routePath: notificationEmailsRoute,
64
- onClick: () => {
65
- changeRouteThunk(notificationEmailsRoute);
66
- },
67
59
  component: React.createElement(NotificationEmails, null),
60
+ id: 'notification-emails',
68
61
  });
69
62
  canViewPartnershipsTab &&
70
63
  tabsToRender.push({
@@ -72,20 +65,16 @@ export function ManageTabs(props) {
72
65
  key: 'partnerships-tab',
73
66
  'data-tracking-id': 'partnerships-tab',
74
67
  routePath: partnershipsRoute,
75
- onClick: () => {
76
- changeRouteThunk(partnershipsRoute);
77
- },
78
68
  component: React.createElement(ManagePartnerships, null),
69
+ id: 'partnerships',
79
70
  });
80
71
  tabsToRender.push({
81
72
  title: 'Preferences',
82
73
  key: 'preferences-tab',
83
74
  'data-tracking-id': 'preferences-tab',
84
75
  routePath: preferencesRoute,
85
- onClick: () => {
86
- changeRouteThunk(preferencesRoute);
87
- },
88
76
  component: React.createElement(ManagePreferences, null),
77
+ id: 'preferences-body',
89
78
  });
90
79
  canViewManageTopContent &&
91
80
  tabsToRender.push({
@@ -93,10 +82,17 @@ export function ManageTabs(props) {
93
82
  key: 'top-content-tab',
94
83
  'data-tracking-id': 'manage-top-content-tab',
95
84
  routePath: topContentRoute,
96
- onClick: () => {
97
- changeRouteThunk(topContentRoute);
98
- },
99
85
  component: React.createElement(TopContentManagement, null),
86
+ id: 'manage-top-content',
87
+ });
88
+ canViewManageTopContent &&
89
+ tabsToRender.push({
90
+ title: 'Tags Manager',
91
+ key: 'tags-manager-tab',
92
+ 'data-tracking-id': 'tags-manager-tab',
93
+ routePath: tagsManagerRoute,
94
+ id: 'tags-manager',
95
+ component: React.createElement(TagsManagement, null),
100
96
  });
101
97
  canViewConfigsTab &&
102
98
  tabsToRender.push({
@@ -104,27 +100,35 @@ export function ManageTabs(props) {
104
100
  key: 'pcm-internal-configs-tab',
105
101
  'data-tracking-id': 'pcm-config-admin-tab',
106
102
  routePath: configsRoute,
107
- onClick: () => {
108
- changeRouteThunk(configsRoute);
109
- },
110
103
  component: React.createElement(ConfigsTable, null),
104
+ id: 'internal-config',
111
105
  });
106
+ const getActiveTabKey = () => {
107
+ if (!activeTab)
108
+ return activeTabKey;
109
+ const tabIndex = tabsToRender.findIndex((item) => item.routePath === activeTab);
110
+ return tabIndex > -1 ? tabIndex : activeTabKey;
111
+ };
112
+ // Toggle currently active tab
113
+ const handleTabClick = (event, tabIndex) => {
114
+ setActiveTabKey(tabIndex);
115
+ };
112
116
  /**
113
117
  * Render without tabs if there is only one element
114
118
  */
115
119
  if (tabsToRender.length === 1)
116
120
  return (React.createElement("div", { className: "grid-main manage" },
117
121
  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))));
118
- // To get selected index
119
- const getSelectedIndex = () => {
120
- if (isOnlyBasePath)
121
- return 0;
122
- const tabIndex = tabsToRender.findIndex((tab) => tab.routePath === history.location.pathname.substring(0, tab.routePath.length));
123
- return tabIndex > -1 ? tabIndex : 0;
124
- };
125
122
  /**
126
123
  * Render array with tabs
127
124
  */
128
- return (React.createElement("div", { className: "grid-main manage" },
129
- React.createElement("pfe-tabs", { "pfe-variant": "earth", "selected-index": getSelectedIndex(), vertical: true }, map(tabsToRender, (tab, index) => (React.createElement(ManageTab, { tabIndex: getSelectedIndex(), tab: tab, key: tab.key, loadComponent: index === getSelectedIndex() }))))));
125
+ return (React.createElement("div", { className: "grid-main manage", role: "region", style: { display: 'flex' } },
126
+ 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,
127
+ React.createElement(Trans, null, tab.title)), "data-tracking-id": tab['data-tracking-id'], key: tab.title, href: `#${props.basePath}/${tab.routePath}` })))),
128
+ map(tabsToRender, (tab, index) => {
129
+ return index === getActiveTabKey() ? (React.createElement(TabContent, { activeKey: getActiveTabKey(), id: tab.id, "aria-label": tab.title },
130
+ React.createElement(ErrorBoundary, { errorMsgInfo: {
131
+ message: t('There was an error loading manage tab. Please try refreshing the page.'),
132
+ }, isPageLevelError: true }, tab.component))) : (React.createElement(React.Fragment, null));
133
+ })));
130
134
  }
@@ -13,6 +13,7 @@ interface ManageRoutes {
13
13
  groups: Route;
14
14
  savedSearches: Route;
15
15
  topContent: Route;
16
+ tagsManager: Route;
16
17
  preferences: Route;
17
18
  notificationEmails: Route;
18
19
  configs: 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,aAAa,EAAE,KAAK,CAAC;IACrB,UAAU,EAAE,KAAK,CAAC;IAClB,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,YAyEpB,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,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,YA+EpB,CAAC"}
package/lib/esm/Routes.js CHANGED
@@ -1,55 +1,61 @@
1
1
  export const Routes = {
2
2
  basePath: '',
3
3
  groups: {
4
- path: '/groups',
4
+ path: 'groups',
5
5
  getPath() {
6
6
  return getPath(this);
7
7
  },
8
8
  },
9
9
  bookmarkedAccounts: {
10
- path: '/bookmarks',
10
+ path: 'bookmarks',
11
11
  getPath() {
12
12
  return getPath(this);
13
13
  },
14
14
  },
15
15
  fileDiagnostics: {
16
- path: '/file-diagnostics',
16
+ path: 'file-diagnostics',
17
17
  getPath() {
18
18
  return getPath(this);
19
19
  },
20
20
  },
21
21
  savedSearches: {
22
- path: '/saved-searches',
22
+ path: 'saved-searches',
23
23
  getPath() {
24
24
  return getPath(this);
25
25
  },
26
26
  },
27
27
  topContent: {
28
- path: '/top-content',
28
+ path: 'top-content',
29
+ getPath() {
30
+ return getPath(this);
31
+ },
32
+ },
33
+ tagsManager: {
34
+ path: 'tags-manager',
29
35
  getPath() {
30
36
  return getPath(this);
31
37
  },
32
38
  },
33
39
  preferences: {
34
- path: '/preferences',
40
+ path: 'preferences',
35
41
  getPath() {
36
42
  return getPath(this);
37
43
  },
38
44
  },
39
45
  partnerships: {
40
- path: '/partnerships',
46
+ path: 'partnerships',
41
47
  getPath() {
42
48
  return getPath(this);
43
49
  },
44
50
  },
45
51
  notificationEmails: {
46
- path: '/notification-emails',
52
+ path: 'notification-emails',
47
53
  getPath() {
48
54
  return getPath(this);
49
55
  },
50
56
  },
51
57
  configs: {
52
- path: '/configs',
58
+ path: 'configs',
53
59
  getPath() {
54
60
  return getPath(this);
55
61
  },
@@ -112,7 +112,7 @@ export const ConfigsTable = () => {
112
112
  setFilteredValues(configValues);
113
113
  }
114
114
  }, [searchString, configValues]);
115
- return (React.createElement("section", { id: "notification-emails" },
115
+ return (React.createElement(React.Fragment, null,
116
116
  React.createElement("header", null,
117
117
  React.createElement("h2", null, "Internal app configs"),
118
118
  "Edit app configs that used as flags or other settings here."),
@@ -129,7 +129,7 @@ export const ManageGroupUsers = () => {
129
129
  setAllData(response || []);
130
130
  // eslint-disable-next-line react-hooks/exhaustive-deps
131
131
  }, [location.pathname]);
132
- return (React.createElement("section", { id: "manage-groups" },
132
+ return (React.createElement(React.Fragment, null,
133
133
  React.createElement(AlertMessage, { variant: AlertType.INFO, show: loggedInUserRights.data.isOrgAdmin() && !loggedInUsersAccount.data.hasGroupACLs, isInline: true, className: "pf-v5-u-mb-md", title: t("Case Group Access Control Lists (ACLs) haven't been activated on your account.") },
134
134
  React.createElement("p", null,
135
135
  React.createElement(Trans, { i18nKey: "i18nRequestControl" },
@@ -245,7 +245,7 @@ export function ManageGroupedBookmarkedAccountsTab({ canManageBookmarkAccounts }
245
245
  };
246
246
  if (!canManageBookmarkAccounts)
247
247
  return null;
248
- return (React.createElement("section", { id: "manage-bookmarked-accounts" },
248
+ return (React.createElement(React.Fragment, null,
249
249
  React.createElement("header", null,
250
250
  React.createElement("h2", null, t('Bookmarks')),
251
251
  React.createElement("p", null,
@@ -12,7 +12,7 @@ export function ManagePartnerships() {
12
12
  const { t } = useTranslation();
13
13
  const { globalMetadataState: { loggedInUserRights }, } = useGlobalStateContext();
14
14
  return (React.createElement(React.Fragment, null,
15
- React.createElement("header", { className: "pf-v5-u-mt-md pf-v5-u-mb-xs" },
15
+ React.createElement("header", { className: "pf-v5-u-mb-xs" },
16
16
  React.createElement("h2", null,
17
17
  React.createElement(Trans, null, "Partnerships")),
18
18
  React.createElement("p", null, loggedInUserRights.data.isPartner() ? (React.createElement(Trans, null, "Add, edit, or remove partnerships and manage your collaboration requests")) : (React.createElement(React.Fragment, null, loggedInUserRights.data.isCustomerOrgAdmin() ? (React.createElement(Trans, null, "Confirm, filter, or remove partnerships and manage collaboration requests.")) : (React.createElement(Trans, null, "Filter or remove partnerships and manage collaboration requests.")))))),
@@ -1 +1 @@
1
- {"version":3,"file":"ManagePreferences.d.ts","sourceRoot":"","sources":["../../../../src/components/ManagePreferences/ManagePreferences.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,UAAU,MAAM;CAAG;AAEnB,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,qBAM9C"}
1
+ {"version":3,"file":"ManagePreferences.d.ts","sourceRoot":"","sources":["../../../../src/components/ManagePreferences/ManagePreferences.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,UAAU,MAAM;CAAG;AAEnB,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,qBAE9C"}
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
2
  import { Preferences } from './Preferences';
3
3
  export function ManagePreferences(props) {
4
- return (React.createElement("section", { id: "manage-preferences" },
5
- React.createElement(Preferences, null)));
4
+ return React.createElement(Preferences, null);
6
5
  }
@@ -3,7 +3,7 @@ import { PreferencesCaseCreate } from './sections/PreferencesCaseCreate';
3
3
  import { PreferencesCaseSearch } from './sections/PreferencesCaseSearch';
4
4
  import { PreferencesCaseView } from './sections/PreferencesCaseView';
5
5
  export function PreferencesBody(props) {
6
- return (React.createElement("section", { className: "pfe-l-grid pfe-m-gutters pfe-m-all-4-col", id: "preferences-body" },
6
+ return (React.createElement("div", { className: "pfe-l-grid pfe-m-gutters pfe-m-all-4-col" },
7
7
  React.createElement(PreferencesCaseSearch, null),
8
8
  React.createElement(PreferencesCaseView, null),
9
9
  React.createElement(PreferencesCaseCreate, null)));
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ export declare function TagsManagement(): React.JSX.Element;
3
+ //# sourceMappingURL=TagsManagement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TagsManagement.d.ts","sourceRoot":"","sources":["../../../../src/components/ManageTags/TagsManagement.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,wBAAgB,cAAc,sBAS7B"}
@@ -0,0 +1,11 @@
1
+ import { ErrorBoundary } from '@rh-support/components';
2
+ import React from 'react';
3
+ import { useTranslation } from 'react-i18next';
4
+ import { TagManagementContextProvider } from '../../context/TagManagementContextProvider';
5
+ import TagsManager from './TagsManager';
6
+ export function TagsManagement() {
7
+ const { t } = useTranslation();
8
+ return (React.createElement(ErrorBoundary, { errorMsgInfo: { message: t('There was an error loading contents') } },
9
+ React.createElement(TagManagementContextProvider, null,
10
+ React.createElement(TagsManager, null))));
11
+ }
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ export default function TagsManager(): React.JSX.Element;
3
+ //# sourceMappingURL=TagsManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TagsManager.d.ts","sourceRoot":"","sources":["../../../../src/components/ManageTags/TagsManager.tsx"],"names":[],"mappings":"AAyBA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAOxE,MAAM,CAAC,OAAO,UAAU,WAAW,sBA+WlC"}
@@ -0,0 +1,240 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { ActionList, ActionListItem, Bullseye, Button, ButtonVariant, EmptyState, EmptyStateVariant, Flex, FormGroup, FormHelperText, HelperText, HelperTextItem, Modal, SearchInput, Spinner, TextInput, } from '@patternfly/react-core';
11
+ import PencilAltIcon from '@patternfly/react-icons/dist/js/icons/pencil-alt-icon';
12
+ import TrashIcon from '@patternfly/react-icons/dist/js/icons/trash-icon';
13
+ import { ErrorBoundary, ToastNotification } from '@rh-support/components';
14
+ import { formatDate } from '@rh-support/utils';
15
+ import { isEmpty, isNull, isUndefined } from 'lodash';
16
+ import React, { useContext, useEffect, useMemo, useState } from 'react';
17
+ import { Trans, useTranslation } from 'react-i18next';
18
+ import { TagManagementDispatchContext, TagManagementStateContext } from '../../context/TagManagementContextProvider';
19
+ import { createNewTags, deleteTag, fetchTopContentTags, updateTag } from '../../reducers/TagManagmentReducer';
20
+ import { ManageTable } from '../ManageTable';
21
+ export default function TagsManager() {
22
+ const { t } = useTranslation();
23
+ const [createTagModalOpen, setCreateTagModalOpen] = useState(false);
24
+ const [newTagName, setNewTagName] = useState('');
25
+ const [isCreatingNewTag, setIsCreatingNewTag] = useState(false);
26
+ const [createTagError, setCreateTagError] = useState('');
27
+ const [editTagModalOpen, setEditTagModalOpen] = useState(false);
28
+ const [editTagName, setEditTagName] = useState('');
29
+ const [isEditingTagName, setisEditingTagName] = useState(false);
30
+ const [selectedEditTag, setSelectedEditTag] = useState(null);
31
+ const [editTagError, setEditTagError] = useState('');
32
+ const [selectedDeleteTag, setSelectedDeleteTag] = useState(null);
33
+ const [isDeletingTag, setIsDeletingTag] = useState(false);
34
+ const [deleteTagModalOpen, setDeleteTagModalOpen] = useState(false);
35
+ const [tagSearchTerm, setTagSearchTerm] = useState('');
36
+ const { tagResponse, tags } = useContext(TagManagementStateContext);
37
+ const dispatch = useContext(TagManagementDispatchContext);
38
+ const tagsByIds = useMemo(() => tags.reduce((acc, t) => (Object.assign(Object.assign({}, acc), { [t.id]: t })), {}), [tags]);
39
+ const getCreateTagError = (tagName) => {
40
+ tagName = tagName.trim();
41
+ if (isEmpty(tagName))
42
+ return t('Tag name cannot be empty.');
43
+ const existingTag = tags.find((t) => t.tagName === tagName);
44
+ if (existingTag)
45
+ return t('Tag with this name is already present.');
46
+ return '';
47
+ };
48
+ //filtering tags for user search
49
+ const filteredTagIds = useMemo(() => {
50
+ if (isEmpty(tagSearchTerm))
51
+ return tags.map((t) => t.id);
52
+ const filteredIds = [];
53
+ tags.forEach((t) => {
54
+ if (t.tagName.toLowerCase().includes(tagSearchTerm)) {
55
+ filteredIds.push(t.id);
56
+ }
57
+ });
58
+ return filteredIds;
59
+ }, [tagSearchTerm, tags]);
60
+ useEffect(() => {
61
+ fetchTopContentTags(dispatch);
62
+ // eslint-disable-next-line react-hooks/exhaustive-deps
63
+ }, []);
64
+ const onCreateNewTag = () => __awaiter(this, void 0, void 0, function* () {
65
+ const errorMsg = getCreateTagError(newTagName);
66
+ if (!isEmpty(errorMsg)) {
67
+ setCreateTagError(errorMsg);
68
+ return;
69
+ }
70
+ try {
71
+ setIsCreatingNewTag(true);
72
+ yield createNewTags(dispatch, [{ tagName: newTagName.trim(), isActive: true }]);
73
+ ToastNotification.addSuccessMessage(t('Successfully created tag'));
74
+ }
75
+ catch (err) {
76
+ console.log({ err });
77
+ ToastNotification.addSuccessMessage(t('Error creating tag'));
78
+ }
79
+ finally {
80
+ setIsCreatingNewTag(false);
81
+ onCanceCreateNewTag();
82
+ }
83
+ });
84
+ const onCanceCreateNewTag = () => {
85
+ setCreateTagError('');
86
+ setCreateTagModalOpen(false);
87
+ setNewTagName('');
88
+ };
89
+ const onEditTagClick = (tag) => __awaiter(this, void 0, void 0, function* () {
90
+ setEditTagName(tag.tagName);
91
+ setSelectedEditTag(tag);
92
+ setEditTagModalOpen(true);
93
+ });
94
+ const onEditTagConfirm = () => __awaiter(this, void 0, void 0, function* () {
95
+ const errorMsg = getCreateTagError(editTagName);
96
+ if (!isEmpty(errorMsg)) {
97
+ setEditTagError(errorMsg);
98
+ return;
99
+ }
100
+ if (isNull(selectedEditTag) || isUndefined(selectedEditTag))
101
+ return;
102
+ try {
103
+ setisEditingTagName(true);
104
+ yield updateTag(dispatch, { id: selectedEditTag.id, tagName: editTagName.trim() }, tags);
105
+ ToastNotification.addSuccessMessage(t('Successfully edited tag'));
106
+ }
107
+ catch (err) {
108
+ console.log(err);
109
+ ToastNotification.addSuccessMessage(t('Error editing tag'));
110
+ }
111
+ finally {
112
+ setisEditingTagName(false);
113
+ onEditCancel();
114
+ }
115
+ });
116
+ const onEditCancel = () => {
117
+ setEditTagModalOpen(false);
118
+ setSelectedEditTag(null);
119
+ setEditTagName('');
120
+ setEditTagError('');
121
+ };
122
+ const onDeleteTagClick = (tag) => __awaiter(this, void 0, void 0, function* () {
123
+ setDeleteTagModalOpen(true);
124
+ setSelectedDeleteTag(tag);
125
+ });
126
+ const onDeleteTagConfirm = () => __awaiter(this, void 0, void 0, function* () {
127
+ if (isNull(selectedDeleteTag) || isUndefined(selectedDeleteTag))
128
+ return;
129
+ try {
130
+ setIsDeletingTag(true);
131
+ yield deleteTag(dispatch, selectedDeleteTag, { tagResponse, tags });
132
+ ToastNotification.addSuccessMessage(t('Tag deleted successfully'));
133
+ }
134
+ catch (err) {
135
+ console.log(err);
136
+ ToastNotification.addSuccessMessage(t('Error deleting tag'));
137
+ }
138
+ finally {
139
+ setDeleteTagModalOpen(false);
140
+ setIsDeletingTag(false);
141
+ setSelectedDeleteTag(null);
142
+ }
143
+ });
144
+ const columns = [
145
+ {
146
+ accessor: (id) => tagsByIds[id].tagName,
147
+ sortable: false,
148
+ id: 'tagname-manage-table',
149
+ title: t('Tag'),
150
+ cellWidth: 20,
151
+ },
152
+ {
153
+ id: 'article-count-for-tags',
154
+ sortable: false,
155
+ title: t('No of top contents'),
156
+ cellWidth: 20,
157
+ cell: (id) => `${tagsByIds[id].numberOfLinkedContents || 0} articles`,
158
+ },
159
+ {
160
+ id: 'tag-created-by',
161
+ sortable: false,
162
+ title: t('Created by'),
163
+ cellWidth: 30,
164
+ cell: (id) => tagsByIds[id].createdBy,
165
+ },
166
+ {
167
+ id: 'tag-modified-date',
168
+ sortable: false,
169
+ title: t('Modified date'),
170
+ cellWidth: 20,
171
+ cell: (id) => formatDate(tagsByIds[id].modifiedDate),
172
+ },
173
+ {
174
+ id: 'tag-manage-actions',
175
+ title: '',
176
+ sortable: false,
177
+ cellWidth: 10,
178
+ cell: (id) => (React.createElement(ActionList, { isIconList: true },
179
+ React.createElement(ActionListItem, null,
180
+ React.createElement(Button, { variant: "plain", "data-tracking-id": "edit-tag", "aria-label": `edit tag ${tagsByIds[id].tagName}`, onClick: () => onEditTagClick(tagsByIds[id]) },
181
+ React.createElement(PencilAltIcon, null))),
182
+ React.createElement(ActionListItem, null,
183
+ React.createElement(Button, { "aria-label": `delete tag ${tagsByIds[id].tagName}`, variant: "plain", "data-tracking-id": "delete-tag", onClick: () => onDeleteTagClick(tagsByIds[id]) },
184
+ React.createElement(TrashIcon, null))))),
185
+ },
186
+ ];
187
+ const CreateTagModel = (React.createElement(Modal, { title: t('Create a tag'), onClose: onCanceCreateNewTag, isOpen: createTagModalOpen, actions: [
188
+ React.createElement(Button, { key: "create-tag", variant: ButtonVariant.primary, onClick: onCreateNewTag, isLoading: isCreatingNewTag, isDisabled: !isEmpty(createTagError) || isCreatingNewTag },
189
+ React.createElement(Trans, null, "Create")),
190
+ React.createElement(Button, { key: "cancel-create-tag", variant: ButtonVariant.link, onClick: onCanceCreateNewTag }, "Cancel"),
191
+ ] },
192
+ React.createElement(FormGroup, { label: "Tag name", isRequired: true },
193
+ React.createElement(TextInput, { isRequired: true, type: "text", id: "create-new-tag-text-input", value: newTagName, onChange: (e, v) => {
194
+ setNewTagName(v);
195
+ setCreateTagError('');
196
+ }, placeholder: t('Enter a unique name to create a tag'), validated: isEmpty(createTagError) ? 'default' : 'error' }),
197
+ !isEmpty(createTagError) && (React.createElement(FormHelperText, null,
198
+ React.createElement(HelperText, null,
199
+ React.createElement(HelperTextItem, { variant: "error" }, createTagError)))))));
200
+ const EditTagModal = (React.createElement(Modal, { title: t('Edit Tag'), isOpen: editTagModalOpen, onClose: onEditCancel, actions: [
201
+ React.createElement(Button, { key: "edit-tag", variant: ButtonVariant.primary, onClick: onEditTagConfirm, isLoading: isEditingTagName, isDisabled: !isEmpty(editTagError) || isEditingTagName },
202
+ React.createElement(Trans, null, "Save")),
203
+ React.createElement(Button, { key: "cancel-edit-tag", variant: ButtonVariant.link, onClick: onEditCancel }, "Cancel"),
204
+ ] },
205
+ React.createElement(FormGroup, { label: "Tag name", isRequired: true },
206
+ React.createElement(TextInput, { isRequired: true, type: "text", id: "edit-tag-text-input", value: editTagName, onChange: (e, v) => {
207
+ setEditTagName(v);
208
+ setEditTagError('');
209
+ }, placeholder: t('Enter a unique name for this tag') }),
210
+ !isEmpty(editTagError) && (React.createElement(FormHelperText, null,
211
+ React.createElement(HelperText, null,
212
+ React.createElement(HelperTextItem, { variant: "error" }, editTagError)))))));
213
+ const DeleteTagModel = () => (React.createElement(Modal, { title: t('Are you sure?'), isOpen: deleteTagModalOpen, onClose: () => setDeleteTagModalOpen(false), actions: [
214
+ React.createElement(Button, { key: "delete-tag", variant: ButtonVariant.danger, onClick: onDeleteTagConfirm, isLoading: isDeletingTag, isDisabled: isDeletingTag },
215
+ React.createElement(Trans, null, "Yes, I am sure")),
216
+ React.createElement(Button, { key: "cancel-delete-tag", variant: ButtonVariant.link, onClick: () => setDeleteTagModalOpen(false) }, "Cancel"),
217
+ ] },
218
+ React.createElement(Trans, null, "Deleting this tag will permanently untag all content associated with it. Are you sure you want to proceed?")));
219
+ return (React.createElement(React.Fragment, null,
220
+ CreateTagModel,
221
+ EditTagModal,
222
+ React.createElement(DeleteTagModel, null),
223
+ React.createElement("header", null,
224
+ React.createElement("h2", null, "Tags"),
225
+ React.createElement("p", { className: "pf-v5-u-my-sm" },
226
+ React.createElement(Trans, null, "Add, edit or remove tags and manage tagged top content."))),
227
+ React.createElement("div", { className: "toolbar" },
228
+ React.createElement(Flex, { alignItems: { default: 'alignItemsCenter' }, className: "pf-v5-u-w-100" },
229
+ React.createElement("label", { htmlFor: "tag-search-input" },
230
+ React.createElement(Trans, null, "Search Tag")),
231
+ React.createElement("div", { className: "pf-v5-u-flex-grow-1" },
232
+ React.createElement(SearchInput, { type: "text", id: "tag-search-input", value: tagSearchTerm, onChange: (e, v) => setTagSearchTerm(v), placeholder: t('Search for a tag') })),
233
+ React.createElement("span", { className: "pf-v5-u-ml-sm" },
234
+ React.createElement(Button, { variant: ButtonVariant.primary, isInline: true, onClick: () => setCreateTagModalOpen(true), "data-tracking-id": "tag-create-button" },
235
+ React.createElement(Trans, null, "Create tag"))))),
236
+ React.createElement("div", { className: "tags-manager-wrapper" },
237
+ React.createElement(ErrorBoundary, { errorMsgInfo: { message: t('There was an error loading tags list') } }, tagResponse.isFetching ? (React.createElement(Bullseye, null,
238
+ React.createElement(EmptyState, { variant: EmptyStateVariant.full },
239
+ React.createElement(Spinner, { size: "lg" })))) : (React.createElement(ManageTable, { ariaLabel: t('Table to manage tags'), data: filteredTagIds, columns: columns, isError: false, keepPageNumberOnDataChange: true }))))));
240
+ }
@@ -0,0 +1,2 @@
1
+ export { TagsManagement } from './TagsManagement';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/ManageTags/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1 @@
1
+ export { TagsManagement } from './TagsManagement';