@rh-support/manage 1.0.301-beta.3 → 1.1.0

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 (52) hide show
  1. package/lib/esm/ManageTabs.d.ts.map +1 -1
  2. package/lib/esm/ManageTabs.js +4 -21
  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/Configs/ConfigInLineEdit.js +1 -1
  7. package/lib/esm/components/Groups/GroupUserPermissionsSelect/GroupUserPermissionsSelect.js +1 -1
  8. package/lib/esm/components/ManageTable/ManageTable.d.ts +0 -1
  9. package/lib/esm/components/ManageTable/ManageTable.d.ts.map +1 -1
  10. package/lib/esm/components/ManageTable/ManageTable.js +3 -4
  11. package/lib/esm/components/NotificationEmails/NotificationEmailsModal.d.ts.map +1 -1
  12. package/lib/esm/components/NotificationEmails/NotificationEmailsModal.js +1 -0
  13. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/AddNewCategoryDropDown.d.ts.map +1 -1
  14. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/AddNewCategoryDropDown.js +29 -10
  15. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestion.d.ts.map +1 -1
  16. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestion.js +10 -3
  17. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestionHint.d.ts.map +1 -1
  18. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestionHint.js +23 -6
  19. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestionHintAccept.d.ts.map +1 -1
  20. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestionHintAccept.js +39 -14
  21. package/lib/esm/components/TopContentManagement/TopContentProductVersionSelector.d.ts.map +1 -1
  22. package/lib/esm/components/TopContentManagement/TopContentProductVersionSelector.js +31 -30
  23. package/lib/esm/scss/_main.scss +8 -0
  24. package/lib/esm/scss/_pf4-overrides.scss +4 -0
  25. package/package.json +10 -10
  26. package/lib/esm/components/ManagePartnerships/NonOrgCustomerInfoModal.d.ts +0 -2
  27. package/lib/esm/components/ManagePartnerships/NonOrgCustomerInfoModal.d.ts.map +0 -1
  28. package/lib/esm/components/ManagePartnerships/NonOrgCustomerInfoModal.js +0 -15
  29. package/lib/esm/components/ManagePartnerships/PartnerLinkNameForm.d.ts +0 -12
  30. package/lib/esm/components/ManagePartnerships/PartnerLinkNameForm.d.ts.map +0 -1
  31. package/lib/esm/components/ManagePartnerships/PartnerLinkNameForm.js +0 -21
  32. package/lib/esm/components/ManagePartnerships/PartnershipsList.d.ts +0 -2
  33. package/lib/esm/components/ManagePartnerships/PartnershipsList.d.ts.map +0 -1
  34. package/lib/esm/components/ManagePartnerships/PartnershipsList.js +0 -164
  35. package/lib/esm/components/ManagePartnerships/PartnershipsTermsModal.d.ts +0 -2
  36. package/lib/esm/components/ManagePartnerships/PartnershipsTermsModal.d.ts.map +0 -1
  37. package/lib/esm/components/ManagePartnerships/PartnershipsTermsModal.js +0 -97
  38. package/lib/esm/components/ManagePartnerships/PendingRequests.d.ts +0 -3
  39. package/lib/esm/components/ManagePartnerships/PendingRequests.d.ts.map +0 -1
  40. package/lib/esm/components/ManagePartnerships/PendingRequests.js +0 -190
  41. package/lib/esm/components/ManagePartnerships/RequestCollaborationModal.d.ts +0 -8
  42. package/lib/esm/components/ManagePartnerships/RequestCollaborationModal.d.ts.map +0 -1
  43. package/lib/esm/components/ManagePartnerships/RequestCollaborationModal.js +0 -130
  44. package/lib/esm/components/ManagePartnerships/index.d.ts +0 -2
  45. package/lib/esm/components/ManagePartnerships/index.d.ts.map +0 -1
  46. package/lib/esm/components/ManagePartnerships/index.js +0 -27
  47. package/lib/esm/context/ManagePartnershipsProvider.d.ts +0 -11
  48. package/lib/esm/context/ManagePartnershipsProvider.d.ts.map +0 -1
  49. package/lib/esm/context/ManagePartnershipsProvider.js +0 -26
  50. package/lib/esm/reducers/ManagePartnershipsReducer.d.ts +0 -16
  51. package/lib/esm/reducers/ManagePartnershipsReducer.d.ts.map +0 -1
  52. package/lib/esm/reducers/ManagePartnershipsReducer.js +0 -30
@@ -1 +1 @@
1
- {"version":3,"file":"ManageTabs.d.ts","sourceRoot":"","sources":["../../src/ManageTabs.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAoBvD,UAAU,MAAM;IACZ,UAAU,EAAE,mBAAmB,CAAC,EAAE,CAAC,CAAC;CACvC;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,eAgKvC"}
1
+ {"version":3,"file":"ManageTabs.d.ts","sourceRoot":"","sources":["../../src/ManageTabs.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAmBvD,UAAU,MAAM;IACZ,UAAU,EAAE,mBAAmB,CAAC,EAAE,CAAC,CAAC;CACvC;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,eAqIvC"}
@@ -1,13 +1,11 @@
1
1
  import { ErrorBoundary, useDocumentTitle } from '@rh-support/components';
2
- import { GlobalMetadataStateContext } from '@rh-support/react-context';
3
2
  import { ability, CaseDetailsFields, resourceActions, resources } from '@rh-support/user-permissions';
4
- import { CustomElements, getConfigField, PCM_CONFIG_FIELD_TYPE, requireCustomElement } from '@rh-support/utils';
3
+ import { CustomElements, requireCustomElement } from '@rh-support/utils';
5
4
  import map from 'lodash/map';
6
- import React, { useContext } from 'react';
5
+ import React from 'react';
7
6
  import { ConfigsTable } from './components/Configs/ConfigsTable';
8
7
  import { ManageGroupUsers } from './components/Groups/ManageGroupUsers';
9
8
  import { ManageGroupedBookmarkedAccountsTab } from './components/ManageBookmarkedAccountsTab';
10
- import { ManagePartnerships } from './components/ManagePartnerships/index';
11
9
  import { ManagePreferences } from './components/ManagePreferences';
12
10
  import { NotificationEmails } from './components/NotificationEmails/index';
13
11
  import { TopContentManagement } from './components/TopContentManagement';
@@ -23,9 +21,7 @@ requireCustomElement([
23
21
  export function ManageTabs(props) {
24
22
  var _a, _b;
25
23
  const history = props.routeProps.history;
26
- const { groupsRoute, bookmarkedAccountsRoute, topContentRoute, notificationEmailsRoute, preferencesRoute, configsRoute, partnershipsRoute, } = Routes.getPaths();
27
- const { globalMetadataState: { pcmConfig }, } = useContext(GlobalMetadataStateContext);
28
- const isPartnershipsEnabled = getConfigField(pcmConfig.data, 'isPartnershipEnabled', PCM_CONFIG_FIELD_TYPE.FEATURE_FLAG);
24
+ const { groupsRoute, bookmarkedAccountsRoute, topContentRoute, notificationEmailsRoute, preferencesRoute, configsRoute, } = Routes.getPaths();
29
25
  // Changes route and saves the current path to the url query params
30
26
  const isOnlyBasePath = history.location.pathname === Routes.basePath;
31
27
  useDocumentTitle(PageTitle.MANAGE);
@@ -38,7 +34,6 @@ export function ManageTabs(props) {
38
34
  const canViewCaseGroups = ability.can(resourceActions.READ, resources.CASE_GROUPS) && canViewManageTab;
39
35
  const canManageBookmarkAccounts = ability.can(resourceActions.CREATE, resources.BOOKMARK_ACCOUNTS) && canViewManageTab;
40
36
  const canViewEmailNotificationTab = ability.can(resourceActions.READ, resources.NOTIFICATION_EMAIL);
41
- const canViewPartnershipsTab = ability.can(resourceActions.READ, resources.PARTNERSHIPS);
42
37
  const canAddCustomNotification = ability.can(resourceActions.PATCH, resources.CASE_DETAILS, CaseDetailsFields.CASE_DETAILS_SEND_NOTIFICATIONS);
43
38
  const canViewConfigsTab = ability.can(resourceActions.READ, resources.APP_INTERNAL_CONFIGS);
44
39
  const tabsToRender = [];
@@ -76,18 +71,6 @@ export function ManageTabs(props) {
76
71
  },
77
72
  component: React.createElement(NotificationEmails, null),
78
73
  });
79
- canViewPartnershipsTab &&
80
- isPartnershipsEnabled &&
81
- tabsToRender.push({
82
- title: 'Partnerships',
83
- key: 'partnerships-tab',
84
- 'data-tracking-id': 'partnerships-tab',
85
- routePath: partnershipsRoute,
86
- onClick: () => {
87
- changeRouteThunk(partnershipsRoute);
88
- },
89
- component: React.createElement(ManagePartnerships, null),
90
- });
91
74
  tabsToRender.push({
92
75
  title: 'Preferences',
93
76
  key: 'preferences-tab',
@@ -129,7 +112,7 @@ export function ManageTabs(props) {
129
112
  const getSelectedIndex = () => {
130
113
  if (isOnlyBasePath)
131
114
  return 0;
132
- const tabIndex = tabsToRender.findIndex((tab) => tab.routePath === history.location.pathname.substring(0, tab.routePath.length));
115
+ const tabIndex = tabsToRender.findIndex((tab) => tab.routePath === history.location.pathname);
133
116
  return tabIndex > -1 ? tabIndex : 0;
134
117
  };
135
118
  /**
@@ -14,7 +14,6 @@ interface ManageRoutes {
14
14
  savedSearches: Route;
15
15
  topContent: Route;
16
16
  preferences: Route;
17
- partnerships: Route;
18
17
  notificationEmails: Route;
19
18
  configs: Route;
20
19
  }
@@ -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,YAAY,EAAE,KAAK,CAAC;IACpB,kBAAkB,EAAE,KAAK,CAAC;IAC1B,OAAO,EAAE,KAAK,CAAC;CAClB;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,kBAAkB,EAAE,KAAK,CAAC;IAC1B,OAAO,EAAE,KAAK,CAAC;CAClB;AAED,eAAO,MAAM,MAAM,EAAE,YAmEpB,CAAC"}
package/lib/esm/Routes.js CHANGED
@@ -36,12 +36,6 @@ export const Routes = {
36
36
  return getPath(this);
37
37
  },
38
38
  },
39
- partnerships: {
40
- path: '/partnerships',
41
- getPath() {
42
- return getPath(this);
43
- },
44
- },
45
39
  notificationEmails: {
46
40
  path: '/notification-emails',
47
41
  getPath() {
@@ -32,7 +32,7 @@ export function ConfigInLineEdit(props) {
32
32
  }, [props.fieldValue]);
33
33
  return (React.createElement(React.Fragment, null,
34
34
  React.createElement(InlineEdit, { labelProps: { htmlFor: 'case-details-custom-email' }, allowInlineEdit: true, initialIsEditing: false, onSave: onSave, onCancel: onCancel, saveDisabled: input === props.fieldValue || props.isUpdating || hasLargeInput, loadingIndicator: React.createElement(LoadingIndicator, { show: props.isUpdating, isInline: true }) },
35
- React.createElement(TextAreaAutosize, { id: `config-value-${props.id}`, name: `config-value-${props.id}`, "aria-invalid": hasLargeInput, className: `form-control${hasLargeInput ? ' form-invalid' : ''}`, value: input, "data-tracking-id": "open-case-describe-ktQ1-issue", onChange: onChange, disabled: props.isUpdating }),
35
+ React.createElement(TextAreaAutosize, { id: `config-value-${props.id}`, name: `config-value-${props.id}`, "aria-invalid": hasLargeInput, className: `form-control${hasLargeInput ? ' form-invalid' : ''}`, value: input, "data-tracking-id": "manage-case-describe-ktQ1-issue", onChange: onChange, disabled: props.isUpdating }),
36
36
  hasLargeInput && (React.createElement("p", { className: "form-instructions form-invalid" },
37
37
  "Config value cannot be more than ",
38
38
  CONFIG_FIELD_VALUE_LIMIT,
@@ -72,6 +72,6 @@ export const GroupUserPermissionsSelect = (props) => {
72
72
  * 4. Non-org admins cannot see the manage tab itself and thus that check is not added.
73
73
  */
74
74
  return (React.createElement(React.Fragment, null,
75
- React.createElement(Select, { isDisabled: updateUsersFetch.isFetching || !props.account.hasGroupACLs, className: "permissions-select", "aria-label": t('User permissions'), onToggle: onToggle, onSelect: onSelect, onClear: onClear, selections: option, isOpen: isOpen, "aria-labelledby": t('User permissions'), placeholderText: t('Select a permission') }, Object.keys(options).map((key) => (React.createElement(SelectOption, { key: key, value: options[key], "data-tracking-id": `group-user-permission-${key}` }, t(options[key]))))),
75
+ React.createElement(Select, { isDisabled: updateUsersFetch.isFetching, className: "permissions-select", "aria-label": t('User permissions'), onToggle: onToggle, onSelect: onSelect, onClear: onClear, selections: option, isOpen: isOpen, "aria-labelledby": t('User permissions'), placeholderText: t('Select a permission') }, Object.keys(options).map((key) => (React.createElement(SelectOption, { key: key, value: options[key], "data-tracking-id": `group-user-permission-${key}` }, t(options[key]))))),
76
76
  React.createElement(LoadingIndicator, { show: updateUsersFetch.isFetching, size: "xs" })));
77
77
  };
@@ -14,7 +14,6 @@ interface IProps {
14
14
  isError: boolean;
15
15
  pagination?: boolean;
16
16
  keepPageNumberOnDataChange?: boolean;
17
- headless?: boolean;
18
17
  actions?: IActions;
19
18
  areActionsDisabled?: IAreActionsDisabled;
20
19
  actionResolver?: IActionsResolver;
@@ -1 +1 @@
1
- {"version":3,"file":"ManageTable.d.ts","sourceRoot":"","sources":["../../../../src/components/ManageTable/ManageTable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGH,YAAY,EAQf,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC1F,OAAO,EAAE,OAAO,EAAE,SAAS,EAAmC,MAAM,wBAAwB,CAAC;AAC7F,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,UAAU,MAAM;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,SAAS,CAAC;IAGrB,cAAc,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,OAAO,EAAE,OAAO,CAAC;IAEjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,kBAAkB,CAAC,EAAE,mBAAmB,CAAC;IACzC,cAAc,CAAC,EAAE,gBAAgB,CAAC;IAElC,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AA0BD,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,eAgDxC"}
1
+ {"version":3,"file":"ManageTable.d.ts","sourceRoot":"","sources":["../../../../src/components/ManageTable/ManageTable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGH,YAAY,EAQf,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC1F,OAAO,EAAE,OAAO,EAAE,SAAS,EAAmC,MAAM,wBAAwB,CAAC;AAC7F,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,UAAU,MAAM;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,SAAS,CAAC;IAGrB,cAAc,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,OAAO,EAAE,OAAO,CAAC;IAEjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,0BAA0B,CAAC,EAAE,OAAO,CAAC;IAErC,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,kBAAkB,CAAC,EAAE,mBAAmB,CAAC;IACzC,cAAc,CAAC,EAAE,gBAAgB,CAAC;IAElC,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AA0BD,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,eA4CxC"}
@@ -31,13 +31,12 @@ const noResultFoundRow = (noResultString = '') => [
31
31
  },
32
32
  ];
33
33
  export function ManageTable(props) {
34
- const { ariaLabel, errorComponent, errorTitle, errorVariant, isError, isFetching, sortInfo, actions, keepPageNumberOnDataChange, areActionsDisabled, actionResolver, headless } = props, tableProps = __rest(props, ["ariaLabel", "errorComponent", "errorTitle", "errorVariant", "isError", "isFetching", "sortInfo", "actions", "keepPageNumberOnDataChange", "areActionsDisabled", "actionResolver", "headless"]);
35
- const pagination = () => (props.pagination !== undefined ? props.pagination : true);
34
+ const { ariaLabel, errorComponent, errorTitle, errorVariant, isError, isFetching, sortInfo, actions, keepPageNumberOnDataChange, areActionsDisabled, actionResolver } = props, tableProps = __rest(props, ["ariaLabel", "errorComponent", "errorTitle", "errorVariant", "isError", "isFetching", "sortInfo", "actions", "keepPageNumberOnDataChange", "areActionsDisabled", "actionResolver"]);
36
35
  return (React.createElement("div", { className: "table-wrapper" },
37
36
  isError && (React.createElement(React.Fragment, null,
38
37
  React.createElement(Alert, { variant: errorVariant, title: errorTitle, actionClose: React.createElement(AlertActionCloseButton, null) }, errorComponent))),
39
38
  React.createElement(Table, Object.assign({}, tableProps),
40
- React.createElement(PFTable, { sortInfo: sortInfo, "aria-label": ariaLabel, pagination: pagination(), emptyStateRow: noResultFoundRow(props.noResultText), actions: actions, areActionsDisabled: areActionsDisabled, actionResolver: actionResolver, isLoading: isFetching, keepPageNumberOnDataChange: keepPageNumberOnDataChange, headless: headless }),
41
- tableProps.data.length > 0 && pagination() && (React.createElement("footer", null,
39
+ React.createElement(PFTable, { sortInfo: sortInfo, "aria-label": ariaLabel, pagination: true, emptyStateRow: noResultFoundRow(props.noResultText), actions: actions, areActionsDisabled: areActionsDisabled, actionResolver: actionResolver, isLoading: isFetching, keepPageNumberOnDataChange: keepPageNumberOnDataChange }),
40
+ tableProps.data.length > 0 && (React.createElement("footer", null,
42
41
  React.createElement(TablePagination, { variant: PaginationVariant.bottom }))))));
43
42
  }
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationEmailsModal.d.ts","sourceRoot":"","sources":["../../../../src/components/NotificationEmails/NotificationEmailsModal.tsx"],"names":[],"mappings":"AAiBA,UAAU,MAAM;IACZ,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACzE,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACtE,yBAAyB,EAAE,GAAG,CAAC;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,yBAAyB,EAAE,OAAO,CAAC;IACnC,UAAU,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,eAAO,MAAM,uBAAuB,UAAW,MAAM,gBA6LpD,CAAC"}
1
+ {"version":3,"file":"NotificationEmailsModal.d.ts","sourceRoot":"","sources":["../../../../src/components/NotificationEmails/NotificationEmailsModal.tsx"],"names":[],"mappings":"AAiBA,UAAU,MAAM;IACZ,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACzE,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACtE,yBAAyB,EAAE,GAAG,CAAC;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,yBAAyB,EAAE,OAAO,CAAC;IACnC,UAAU,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,eAAO,MAAM,uBAAuB,UAAW,MAAM,gBA8LpD,CAAC"}
@@ -36,6 +36,7 @@ export const NotificationEmailsModal = (props) => {
36
36
  setSaveButtonIsClicked(false);
37
37
  setIsEmailDuplicate(false);
38
38
  };
39
+ // To check if email is valid
39
40
  const checkEmailIsValid = (email) => !isEmpty(email) && isEmailValid(email);
40
41
  const save = () => __awaiter(void 0, void 0, void 0, function* () {
41
42
  setSaveButtonIsClicked(true);
@@ -1 +1 @@
1
- {"version":3,"file":"AddNewCategoryDropDown.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/AddNewCategoryDropDown.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2DAA2D,CAAC;AAUhG,UAAU,MAAM;IACZ,gBAAgB,EAAE,CAAC,GAAG,EAAE,mBAAmB,KAAK,IAAI,CAAC;CACxD;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,eAmDnD"}
1
+ {"version":3,"file":"AddNewCategoryDropDown.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/AddNewCategoryDropDown.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2DAA2D,CAAC;AAShG,UAAU,MAAM;IACZ,gBAAgB,EAAE,CAAC,GAAG,EAAE,mBAAmB,KAAK,IAAI,CAAC;CACxD;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,eA4EnD"}
@@ -1,6 +1,6 @@
1
- import { Dropdown, ToastNotification } from '@rh-support/components';
2
- import { toOptions } from '@rh-support/utils';
3
- import React, { useEffect } from 'react';
1
+ import { Select, SelectOption, SelectVariant } from '@patternfly/react-core';
2
+ import { ToastNotification } from '@rh-support/components';
3
+ import React, { useEffect, useState } from 'react';
4
4
  import { Trans, useTranslation } from 'react-i18next';
5
5
  import { useTopContentContext, useTopContentDispatchContext } from '../../../../context/TopContentProvider';
6
6
  import { fetchCategories } from '../../../../reducers/TopContentReducer';
@@ -10,11 +10,29 @@ export function AddNewCategoryDropDown(props) {
10
10
  const topContentDispatch = useTopContentDispatchContext();
11
11
  const allAddedCategories = topContentEditState.map((cat) => cat.categoryName);
12
12
  const availableCategories = categories.data.filter((category) => !(allAddedCategories || []).includes(category.categoryName));
13
+ const [isOpen, setIsOpen] = useState(false);
14
+ const [selected, setSelected] = useState();
15
+ const getCategoryOptions = (options) => {
16
+ return options.map((category, id) => (React.createElement(SelectOption, { key: id, value: category }, category.categoryName)));
17
+ };
18
+ const onFilter = (_, value) => {
19
+ if (!value)
20
+ return getCategoryOptions(availableCategories);
21
+ const input = new RegExp(value, 'i');
22
+ const newOptions = availableCategories.filter((c) => input.test(c.categoryName));
23
+ return getCategoryOptions(newOptions);
24
+ };
25
+ const onToggle = (isExpanded) => {
26
+ setIsOpen(isExpanded);
27
+ };
28
+ const onSelect = (event, selection, isPlaceholder) => {
29
+ setSelected(selection);
30
+ props.onCategoryChange(selection);
31
+ onToggle(false);
32
+ };
13
33
  const onClearCategory = () => {
14
34
  props.onCategoryChange(undefined);
15
- };
16
- const onCategoryChange = (selectedItem) => {
17
- props.onCategoryChange(selectedItem.value);
35
+ setSelected(undefined);
18
36
  };
19
37
  useEffect(() => {
20
38
  try {
@@ -25,8 +43,9 @@ export function AddNewCategoryDropDown(props) {
25
43
  }
26
44
  }, [topContentDispatch, t]);
27
45
  return (React.createElement("div", { className: "form-group add-new-category" },
28
- React.createElement(Dropdown, { id: "new-category", name: "new-category", isLoadingList: categories.isFetching, disabled: categories.isFetching || categories.isFetching, required: true, title: t('Select an option or enter a new category'), placeholder: t('Select an option or enter a new category'), list: toOptions(availableCategories, { labelKey: 'categoryName' }), onChange: onCategoryChange, onClearSelection: onClearCategory, searchable: true, label: React.createElement("label", { htmlFor: "new-category" },
29
- React.createElement(Trans, null, "Category"),
30
- ' ',
31
- React.createElement("span", { className: "form-required", "aria-hidden": true }, "*")) })));
46
+ React.createElement("label", { htmlFor: "new-category" },
47
+ React.createElement(Trans, null, "Category"),
48
+ ' ',
49
+ React.createElement("span", { className: "form-required", "aria-hidden": true }, "*")),
50
+ React.createElement(Select, Object.assign({ variant: SelectVariant.typeahead, onToggle: onToggle, isOpen: isOpen, onClear: onClearCategory, onSelect: onSelect, onFilter: onFilter, selections: selected === null || selected === void 0 ? void 0 : selected.categoryName, placeholderText: t('Select an option or enter a new category') }, (categories.isFetching && { loadingVariant: 'spinner' }), { id: "new-category", "data-tracking-id": "new-category" }), getCategoryOptions(availableCategories))));
32
51
  }
@@ -1 +1 @@
1
- {"version":3,"file":"TopContentSuggestion.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestion.tsx"],"names":[],"mappings":"AACA,OAAc,EAAE,EAAE,EAAuB,MAAM,OAAO,CAAC;AAOvD,UAAU,MAAM;CAAG;AAEnB,eAAO,MAAM,oBAAoB,EAAE,EAAE,CAAC,MAAM,CAiC3C,CAAC"}
1
+ {"version":3,"file":"TopContentSuggestion.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestion.tsx"],"names":[],"mappings":"AAEA,OAAc,EAAE,EAAE,EAAuB,MAAM,OAAO,CAAC;AAOvD,UAAU,MAAM;CAAG;AAEnB,eAAO,MAAM,oBAAoB,EAAE,EAAE,CAAC,MAAM,CA6C3C,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { ExpandableSection, Panel, PanelMain, PanelMainBody, Title } from '@patternfly/react-core';
2
+ import { isEmpty } from 'lodash';
2
3
  import React, { useEffect, useState } from 'react';
3
4
  import { Trans } from 'react-i18next';
4
5
  import { useTopContentContext, useTopContentDispatchContext } from '../../../../context/TopContentProvider';
@@ -8,16 +9,22 @@ export const TopContentSuggestion = () => {
8
9
  var _a;
9
10
  const [isExpanded, setExpanded] = useState(false);
10
11
  const onToggle = () => setExpanded((previousExpandedState) => !previousExpandedState);
11
- const { selectedProduct, selectedVersion, suggestion } = useTopContentContext();
12
+ const { selectedProduct, selectedVersion, suggestion, topContentResponse } = useTopContentContext();
12
13
  const topContentDispatch = useTopContentDispatchContext();
14
+ const topContent = topContentResponse.data.reduce((ret, category) => {
15
+ return [...ret, ...category.content];
16
+ }, []);
17
+ const filteredSuggestion = (_a = suggestion.linkedResources) === null || _a === void 0 ? void 0 : _a.filter((resource) => !topContent.some((content) => content.contentUrl === resource.resourceViewUri));
13
18
  useEffect(() => {
14
19
  if ((selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.name) && selectedVersion) {
15
20
  fetchTopContentSuggestions(topContentDispatch, selectedProduct.name, selectedVersion);
16
21
  }
17
22
  }, [topContentDispatch, selectedProduct, selectedVersion]);
18
- return (React.createElement(Panel, { variant: "raised", className: "pf-u-mx-md pf-u-p-md" },
23
+ if (isEmpty(filteredSuggestion))
24
+ return React.createElement(React.Fragment, null);
25
+ return (React.createElement(Panel, { variant: "raised", className: "pf-u-mx-md pf-u-p-md top-content-panel" },
19
26
  React.createElement(PanelMain, null,
20
27
  React.createElement(PanelMainBody, null,
21
28
  React.createElement(ExpandableSection, { onToggle: onToggle, isExpanded: isExpanded, toggleContent: React.createElement(Title, { headingLevel: "h6", className: "accordion_title" },
22
- React.createElement(Trans, null, " Suggested top content resources")), id: "top-content-suggestion" }, (_a = suggestion.linkedResources) === null || _a === void 0 ? void 0 : _a.map((resources) => (React.createElement(TopContentSuggestionHint, { key: resources.id, resources: resources }))))))));
29
+ React.createElement(Trans, null, " Suggested top content resources")), id: "top-content-suggestion" }, filteredSuggestion === null || filteredSuggestion === void 0 ? void 0 : filteredSuggestion.map((resources) => (React.createElement(TopContentSuggestionHint, { key: resources.id, resources: resources }))))))));
23
30
  };
@@ -1 +1 @@
1
- {"version":3,"file":"TopContentSuggestionHint.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestionHint.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2DAA2D,CAAC;AAGhG,OAAc,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AAM5C,UAAU,MAAM;IACZ,SAAS,EAAE,mBAAmB,CAAC;CAClC;AAED,eAAO,MAAM,wBAAwB,EAAE,EAAE,CAAC,MAAM,CAiD/C,CAAC"}
1
+ {"version":3,"file":"TopContentSuggestionHint.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestionHint.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2DAA2D,CAAC;AAGhG,OAAc,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AAM5C,UAAU,MAAM;IACZ,SAAS,EAAE,mBAAmB,CAAC;CAClC;AAED,eAAO,MAAM,wBAAwB,EAAE,EAAE,CAAC,MAAM,CAuE/C,CAAC"}
@@ -7,8 +7,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { Button, Card, CardBody, Truncate } from '@patternfly/react-core';
11
- import { ToastNotification } from '@rh-support/components';
10
+ import { Button, ButtonVariant, Card, CardBody, Truncate } from '@patternfly/react-core';
11
+ import { ToastNotification, useConfirmation } from '@rh-support/components';
12
12
  import React, { useState } from 'react';
13
13
  import { Trans, useTranslation } from 'react-i18next';
14
14
  import { useTopContentContext, useTopContentDispatchContext } from '../../../../context/TopContentProvider';
@@ -18,15 +18,32 @@ export const TopContentSuggestionHint = ({ resources }) => {
18
18
  const { t } = useTranslation();
19
19
  const [isAccepted, setAccepted] = useState(false);
20
20
  const [isRemoving, setIsRemoving] = useState(false);
21
+ const confirmation = useConfirmation();
21
22
  const { suggestion } = useTopContentContext();
22
23
  const topContentDispatch = useTopContentDispatchContext();
24
+ const ignoreModalContent = (React.createElement(React.Fragment, null,
25
+ React.createElement("h2", null,
26
+ React.createElement(Trans, null, "Are you sure?")),
27
+ React.createElement("p", null,
28
+ React.createElement(Trans, null, "Removing this suggestion will permanently delete it."))));
23
29
  const onIgnore = () => __awaiter(void 0, void 0, void 0, function* () {
24
30
  try {
25
- setIsRemoving(true);
26
- yield deleteTopContentSuggestion(topContentDispatch, suggestion, resources.id);
27
- ToastNotification.addSuccessMessage(t('Suggestion successfully removed'));
31
+ try {
32
+ yield confirmation({
33
+ catchOnCancel: true,
34
+ confirmText: t('Yes, I am sure'),
35
+ confirmButtonVariant: ButtonVariant.danger,
36
+ description: ignoreModalContent,
37
+ });
38
+ setIsRemoving(true);
39
+ yield deleteTopContentSuggestion(topContentDispatch, suggestion, resources.id);
40
+ ToastNotification.addSuccessMessage(t('Suggestion successfully removed'));
41
+ }
42
+ catch (_a) {
43
+ // user didn't confirm the ignore action
44
+ }
28
45
  }
29
- catch (_a) {
46
+ catch (_b) {
30
47
  ToastNotification.addDangerMessage(t('Failed to remove suggestion'));
31
48
  }
32
49
  finally {
@@ -1 +1 @@
1
- {"version":3,"file":"TopContentSuggestionHintAccept.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestionHintAccept.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAuB,mBAAmB,EAAE,MAAM,2DAA2D,CAAC;AAgBrH,OAAc,EAAE,EAAE,EAAgC,MAAM,OAAO,CAAC;AAahE,UAAU,MAAM;IACZ,QAAQ,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,SAAS,EAAE,mBAAmB,CAAC;CAClC;AAED,eAAO,MAAM,8BAA8B,EAAE,EAAE,CAAC,MAAM,CA8KrD,CAAC"}
1
+ {"version":3,"file":"TopContentSuggestionHintAccept.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestionHintAccept.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAuB,mBAAmB,EAAE,MAAM,2DAA2D,CAAC;AAkBrH,OAAc,EAAE,EAAE,EAAgC,MAAM,OAAO,CAAC;AAgBhE,UAAU,MAAM;IACZ,QAAQ,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,SAAS,EAAE,mBAAmB,CAAC;CAClC;AAED,eAAO,MAAM,8BAA8B,EAAE,EAAE,CAAC,MAAM,CAkPrD,CAAC"}
@@ -7,23 +7,30 @@ 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 { ActionGroup, Button, Card, CardBody, Form, FormGroup, Select, SelectOption, SelectVariant, TextInput, } from '@patternfly/react-core';
10
+ import { Button, Card, CardBody, Form, FormGroup, Select, SelectOption, SelectVariant, TextInput, Tooltip, ValidatedOptions, } from '@patternfly/react-core';
11
+ import PencilAltIcon from '@patternfly/react-icons/dist/js/icons/pencil-alt-icon';
11
12
  import { ToastNotification } from '@rh-support/components';
12
- import { getVersion, isRegularVersion } from '@rh-support/utils';
13
- import { isEmpty, isUndefined } from 'lodash';
13
+ import { getVersion, isRegularVersion, isValidUrl } from '@rh-support/utils';
14
+ import { isEmpty, isUndefined, trim } from 'lodash';
14
15
  import React, { useEffect, useMemo, useState } from 'react';
15
16
  import { Trans, useTranslation } from 'react-i18next';
17
+ import { CATEGORY_LIMIT } from '../../../../constants/TopContent';
16
18
  import { useTopContentContext, useTopContentDispatchContext } from '../../../../context/TopContentProvider';
19
+ import { flagContentUsage } from '../../../../reducers/TopContentHelpers';
17
20
  import { ContentMode, deleteTopContentSuggestion, fetchCategories, saveAddedNewSectionContents, saveAddToTopContent, } from '../../../../reducers/TopContentReducer';
21
+ import CategoryLimit from '../../CategoryLimit/CategoryLimit';
18
22
  export const TopContentSuggestionHintAccept = ({ onCancel, resources }) => {
19
23
  const { t } = useTranslation();
20
- const { categories, topContentResponse, topContentEditState, selectedProduct, selectedVersion, isCatOnlyForMajorVersion, isAddingCategory, suggestion, } = useTopContentContext();
24
+ const { categories, topContentResponse, topContentEditState, selectedProduct, selectedVersion, isCatOnlyForMajorVersion, isAddingCategory, suggestion, categoryUsage, } = useTopContentContext();
21
25
  const topContentDispatch = useTopContentDispatchContext();
22
26
  const [isSelectOpen, setSelectOpen] = useState(false);
23
27
  const [selected, setSelected] = useState();
24
28
  const [isSaving, setIsSaving] = useState(false);
25
29
  const [resourceTitle, setResourceTitle] = useState('');
30
+ const [linkToContent, setLinkToContent] = useState('');
31
+ const [isEditClicked, setIsEditClicked] = useState(false);
26
32
  const categoryToSave = useMemo(() => topContentEditState.find((category) => category.categoryId === (selected === null || selected === void 0 ? void 0 : selected.id)), [topContentEditState, selected]);
33
+ const flagContentEditState = useMemo(() => flagContentUsage(topContentEditState, categoryUsage, selectedVersion), [topContentEditState, categoryUsage, selectedVersion]);
27
34
  const isMajorVersionOnly = isUndefined(getVersion(selectedVersion).minor);
28
35
  const minorSelectedNoMinorContentButAvailableMajorContent = !topContentResponse.isFetching &&
29
36
  !isEmpty(topContentResponse.data) &&
@@ -31,6 +38,8 @@ export const TopContentSuggestionHintAccept = ({ onCancel, resources }) => {
31
38
  isRegularVersion(selectedVersion) &&
32
39
  isCatOnlyForMajorVersion &&
33
40
  !isAddingCategory;
41
+ const isCategoryLimitReached = (minorSelectedNoMinorContentButAvailableMajorContent ? [] : flagContentEditState).length >= CATEGORY_LIMIT.MAX;
42
+ const isCategoryInList = flagContentEditState.some((c) => c.categoryId === (selected === null || selected === void 0 ? void 0 : selected.id));
34
43
  const onToggle = () => {
35
44
  setSelectOpen((previousToggleState) => !previousToggleState);
36
45
  };
@@ -38,13 +47,18 @@ export const TopContentSuggestionHintAccept = ({ onCancel, resources }) => {
38
47
  setSelected(selection);
39
48
  onToggle();
40
49
  };
50
+ const isDisabled = isEmpty(linkToContent) ||
51
+ isEmpty(trim(resourceTitle)) ||
52
+ isUndefined(selected) ||
53
+ !isValidUrl(linkToContent) ||
54
+ (isCategoryLimitReached && !isCategoryInList);
41
55
  const addContentToCategory = () => __awaiter(void 0, void 0, void 0, function* () {
42
56
  try {
43
57
  setIsSaving(true);
44
58
  const newContent = {
45
59
  contentTitle: resourceTitle,
46
60
  contentRank: categoryToSave === null || categoryToSave === void 0 ? void 0 : categoryToSave.content.length,
47
- contentUrl: resources.resourceViewUri,
61
+ contentUrl: linkToContent,
48
62
  mode: ContentMode.ADD,
49
63
  };
50
64
  yield saveAddToTopContent(topContentDispatch, topContentEditState, categoryToSave.id, categoryToSave === null || categoryToSave === void 0 ? void 0 : categoryToSave.categoryId, newContent, -1);
@@ -63,7 +77,7 @@ export const TopContentSuggestionHintAccept = ({ onCancel, resources }) => {
63
77
  setIsSaving(true);
64
78
  const newContent = {
65
79
  contentTitle: resourceTitle,
66
- contentUrl: resources.resourceViewUri,
80
+ contentUrl: linkToContent,
67
81
  isAttentionNeeded: false,
68
82
  mode: ContentMode.NEW_SECTION_CONTENT,
69
83
  };
@@ -91,7 +105,8 @@ export const TopContentSuggestionHintAccept = ({ onCancel, resources }) => {
91
105
  });
92
106
  useEffect(() => {
93
107
  setResourceTitle(resources.resourceTitle);
94
- }, [resources.resourceTitle]);
108
+ setLinkToContent(resources.resourceViewUri);
109
+ }, [resources.resourceTitle, resources.resourceViewUri]);
95
110
  useEffect(() => {
96
111
  try {
97
112
  fetchCategories(topContentDispatch);
@@ -100,17 +115,27 @@ export const TopContentSuggestionHintAccept = ({ onCancel, resources }) => {
100
115
  ToastNotification.addDangerMessage(t('There was an error loading top content categories'));
101
116
  }
102
117
  }, [topContentDispatch, t]);
103
- return (React.createElement(Card, null,
118
+ return (React.createElement(Card, { className: "pf-u-m-sm" },
104
119
  React.createElement(CardBody, { className: "card-hint" },
105
- React.createElement("span", { className: "hint-title" }, resources.resourceTitle),
106
120
  React.createElement(Form, null,
121
+ isEditClicked ? (React.createElement(React.Fragment, null,
122
+ React.createElement(FormGroup, { label: t('Link to content'), isRequired: true, fieldId: "top-content-link" },
123
+ React.createElement(TextInput, { isRequired: true, type: "text", id: "top-content-resource-link", name: "top-content-resource-link", "data-tracking-id": "top-content-resource-link", value: linkToContent, onChange: setLinkToContent, validated: isEmpty(linkToContent) || !isValidUrl(linkToContent)
124
+ ? ValidatedOptions.error
125
+ : ValidatedOptions.default })),
126
+ React.createElement(FormGroup, { label: t('Headline'), isRequired: true, fieldId: "simple-form-email-01" },
127
+ React.createElement(TextInput, { isRequired: true, type: "text", id: "top-content-headline-category", name: "top-content-headline-category", "data-tracking-id": "top-content-headline-category", value: resourceTitle, onChange: setResourceTitle, validated: isEmpty(trim(resourceTitle)) ? ValidatedOptions.error : ValidatedOptions.default })))) : (React.createElement("span", null,
128
+ React.createElement(Button, { variant: "link", isInline: true },
129
+ React.createElement("u", null,
130
+ React.createElement("a", { className: "hint-title pf-u-font-size-md", target: "_blank", href: linkToContent, rel: "noreferrer" }, resources.resourceTitle))),
131
+ React.createElement(Tooltip, { content: t('Edit Link to content and Headline'), position: "top" },
132
+ React.createElement(Button, { variant: "link", icon: React.createElement(PencilAltIcon, null), onClick: () => setIsEditClicked((pre) => !pre) })))),
107
133
  React.createElement(FormGroup, { label: t('Category'), isRequired: true, fieldId: "simple-form-email-01" },
108
- React.createElement(Select, { variant: SelectVariant.single, id: "category-selection", name: "category-selection", "data-testid": "category-selection", placeholderText: "Select a category", onToggle: onToggle, isOpen: isSelectOpen, onSelect: onSelect, selections: selected === null || selected === void 0 ? void 0 : selected.categoryName, isDisabled: categories.isFetching || categories.isError }, categories.data.map((category, id) => (React.createElement(SelectOption, { key: id, value: category },
134
+ React.createElement(Select, Object.assign({ variant: SelectVariant.single, id: "category-selection", name: "category-selection", "data-testid": "category-selection", placeholderText: "Select a category", onToggle: onToggle, isOpen: isSelectOpen, onSelect: onSelect, selections: selected === null || selected === void 0 ? void 0 : selected.categoryName, isDisabled: categories.isError, loadingVariant: 'spinner' }, (categories.isFetching && { loadingVariant: 'spinner' })), categories.data.map((category, id) => (React.createElement(SelectOption, { key: id, value: category },
109
135
  React.createElement("div", null, category.categoryName)))))),
110
- React.createElement(FormGroup, { label: t('Headline'), isRequired: true, fieldId: "simple-form-email-01" },
111
- React.createElement(TextInput, { isRequired: true, type: "text", id: "top-content-hind-category", name: "top-content-hind-category", "data-tracking-id": "top-content-hind-category", value: resourceTitle, onChange: setResourceTitle })),
112
- React.createElement(ActionGroup, null,
113
- React.createElement(Button, { variant: "primary", onClick: onSaveContent, isDisabled: isSaving || isUndefined(selected), isLoading: isSaving, "data-tracking-id": "suggested-content-save-button" },
136
+ React.createElement("div", { className: "pf-u-mt-sm" },
137
+ isCategoryLimitReached && !isCategoryInList && !isUndefined(selected) && React.createElement(CategoryLimit, null),
138
+ React.createElement(Button, { variant: "primary", onClick: onSaveContent, isDisabled: isSaving || isDisabled, isLoading: isSaving, "data-tracking-id": "suggested-content-save-button" },
114
139
  React.createElement(Trans, null, "Save")),
115
140
  React.createElement(Button, { variant: "link", onClick: () => onCancel(false) },
116
141
  React.createElement(Trans, null, "Cancel")))))));
@@ -1 +1 @@
1
- {"version":3,"file":"TopContentProductVersionSelector.d.ts","sourceRoot":"","sources":["../../../../src/components/TopContentManagement/TopContentProductVersionSelector.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAEnF,OAAO,EAAE,gBAAgB,EAAW,MAAM,0BAA0B,CAAC;AASrE,UAAU,MAAO,SAAQ,gBAAgB;IACrC,eAAe,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IACxC,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC;IAC3D,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,SAAS,EAAE,MAAM,CAAC;CACrB;AAQD,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,aAAa,CAAC,MAAM,EAAE,CAAC,2BAG1E;AAqBD,iBAAS,gCAAgC,CAAC,KAAK,EAAE,MAAM,eA4HtD;kBA5HQ,gCAAgC;;;AA+HzC,OAAO,EAAE,gCAAgC,EAAE,CAAC"}
1
+ {"version":3,"file":"TopContentProductVersionSelector.d.ts","sourceRoot":"","sources":["../../../../src/components/TopContentManagement/TopContentProductVersionSelector.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAGnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAS5D,UAAU,MAAO,SAAQ,gBAAgB;IACrC,eAAe,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IACxC,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC;IAC3D,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,SAAS,EAAE,MAAM,CAAC;CACrB;AAQD,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,aAAa,CAAC,MAAM,EAAE,CAAC,2BAG1E;AAqBD,iBAAS,gCAAgC,CAAC,KAAK,EAAE,MAAM,eAsItD;kBAtIQ,gCAAgC;;;AAyIzC,OAAO,EAAE,gCAAgC,EAAE,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import { products as productsApi } from '@cee-eng/hydrajs';
2
- import { Dropdown, useFetch } from '@rh-support/components';
3
- import { getUniqueSortedVersions, getVersion, toOption, toOptions } from '@rh-support/utils';
2
+ import { Select, SelectOption, SelectVariant } from '@patternfly/react-core';
3
+ import { useFetch } from '@rh-support/components';
4
+ import { getUniqueSortedVersions, getVersion } from '@rh-support/utils';
4
5
  import isEmpty from 'lodash/isEmpty';
5
6
  import React, { useEffect, useState } from 'react';
6
7
  import { Trans, useTranslation } from 'react-i18next';
@@ -40,10 +41,9 @@ function TopContentProductVersionSelector(props) {
40
41
  initialData: [],
41
42
  });
42
43
  const { request: getProductVersions, isFetching: isLoadingVersions, data: versions, } = useFetch(productsApi.getProductVersions, { initialData: [], postProcessor: postVersionsProcessor });
43
- const [isProductInValid, setIsProductInValid] = useState(false);
44
- const [isVersionInValid, setIsVersionInValid] = useState(false);
45
- const [isProductBlured, setIsProductBlured] = useState(false);
46
- const [isVersionBlured, setIsVersionBlured] = useState(false);
44
+ const [isProductOpen, setIsProductOpen] = useState(false);
45
+ const [isVersionOpen, setIsVersionOpen] = useState(false);
46
+ const { selectedProduct, selectedVersion } = props;
47
47
  const topContentDispatch = useTopContentDispatchContext();
48
48
  /**
49
49
  * Fetch products on load
@@ -64,48 +64,49 @@ function TopContentProductVersionSelector(props) {
64
64
  }, [versions]);
65
65
  const onProductChange = (option) => {
66
66
  setIsAddingCategory(topContentDispatch, false);
67
- props.onProductChange(option.value);
68
- validateProduct(option);
69
- isProductValid(option) && getProductVersions(option.value.name);
67
+ props.onProductChange(option);
68
+ getProductVersions(option.name);
70
69
  };
71
70
  const onVersionChange = (option) => {
72
71
  setIsAddingCategory(topContentDispatch, false);
73
- props.onVersionChange(option.value);
74
- validateVersion(option);
72
+ props.onVersionChange(option);
75
73
  };
76
74
  const onProductClear = () => {
77
- onProductChange(toOption({ name: '', id: '' }, { labelKey: 'name' }));
75
+ onProductChange({ name: '', id: '' });
78
76
  };
79
- const onProductOuterClick = (selectedItem) => {
80
- setIsProductBlured(true);
77
+ const getProductOptions = (options) => {
78
+ return options.map((product, id) => (React.createElement(SelectOption, { key: id, value: product }, product.name)));
81
79
  };
82
- const onVersionOuterClick = (selectedItem) => {
83
- setIsVersionBlured(true);
80
+ const onProductFilter = (_, value) => {
81
+ if (!value)
82
+ return getProductOptions(products);
83
+ const input = new RegExp(value, 'i');
84
+ const newOptions = products === null || products === void 0 ? void 0 : products.filter((p) => input.test(p.name));
85
+ return getProductOptions(newOptions);
84
86
  };
85
- const validateProduct = (selectedItem) => {
86
- setIsProductInValid(!selectedItem);
87
+ const onProductToggle = (isExpanded) => {
88
+ setIsProductOpen(isExpanded);
87
89
  };
88
- const isProductValid = (selectedItem) => {
89
- return !isEmpty(selectedItem) && !isEmpty(selectedItem.label);
90
+ const onProductSelect = (event, selection, isPlaceholder) => {
91
+ onProductChange(selection);
92
+ onProductToggle(false);
90
93
  };
91
- const validateVersion = (selectedItem) => {
92
- setIsVersionInValid(isEmpty(selectedItem) || isEmpty(selectedItem.label));
94
+ const onVersionToggle = (isExpanded) => {
95
+ setIsVersionOpen(isExpanded);
96
+ };
97
+ const onVersionSelect = (e, selection, isPlaceholder) => {
98
+ onVersionChange(selection);
99
+ onVersionToggle(false);
93
100
  };
94
- useEffect(() => {
95
- setIsProductInValid(false);
96
- setIsVersionInValid(false);
97
- isProductBlured && setIsProductInValid(isEmpty(props.selectedProduct.name));
98
- isVersionBlured && setIsVersionInValid(isEmpty(props.selectedVersion));
99
- }, [isProductBlured, isVersionBlured, props.selectedProduct.name, props.selectedVersion]);
100
101
  return (React.createElement("div", { className: "toolbar" },
101
102
  React.createElement("div", { className: "toolbar-left" },
102
103
  React.createElement("label", { htmlFor: 'tc-product-dropdown-downshift-search' },
103
104
  React.createElement(Trans, null, "Product")),
104
- React.createElement(Dropdown, { className: `tc-product-dropdown`, placeholder: t('Select a product'), list: products ? toOptions(products, { labelKey: 'name' }) : [], title: `Select a product`, selectedItem: toOption(props.selectedProduct, { labelKey: 'name' }), isInValid: isProductInValid, onChange: onProductChange, onOuterClick: onProductOuterClick, searchable: true, isLoadingList: isLoadingProducts, onClearSelection: onProductClear, id: "tc-product-dropdown-selector", "data-tracking-id": "tc-product-dropdown-selector" })),
105
+ React.createElement(Select, Object.assign({ variant: SelectVariant.typeahead, onToggle: onProductToggle, selections: selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.name, isOpen: isProductOpen, onSelect: onProductSelect, onClear: onProductClear, placeholderText: t('Select a product') }, (isLoadingProducts && { loadingVariant: 'spinner' }), { id: "tc-product-dropdown-selector", "data-tracking-id": "tc-product-dropdown-selector", onFilter: onProductFilter, isDisabled: isLoadingProducts }), getProductOptions(products))),
105
106
  React.createElement("div", { className: "toolbar-right" },
106
107
  React.createElement("label", { htmlFor: "version-selector-dropdown-toggle" },
107
108
  React.createElement(Trans, null, "Version")),
108
- React.createElement(Dropdown, { selectedItem: toOption(props.selectedVersion), list: props.selectedProduct ? toOptions(versions === null || versions === void 0 ? void 0 : versions.items) : [], id: "version-selector-dropdown", placeholder: t('Select a version'), isLoadingList: isLoadingVersions, title: `Versions for ${props.selectedProduct.name}`, disabled: isEmpty(versions === null || versions === void 0 ? void 0 : versions.items), isInValid: isVersionInValid, onChange: onVersionChange, onOuterClick: onVersionOuterClick, "data-tracking-id": "version-dropdown-selector" }))));
109
+ React.createElement(Select, Object.assign({ variant: SelectVariant.single, onToggle: onVersionToggle, onSelect: onVersionSelect, selections: selectedVersion, isOpen: isVersionOpen, placeholderText: t('Select a version'), isDisabled: isEmpty(versions === null || versions === void 0 ? void 0 : versions.items) }, (isLoadingVersions && { loadingVariant: 'spinner' }), { id: "version-dropdown-selector", "data-tracking-id": "version-dropdown-selector" }), ((versions === null || versions === void 0 ? void 0 : versions.items) || []).map((version, id) => (React.createElement(SelectOption, { key: id, value: version }, version)))))));
109
110
  }
110
111
  TopContentProductVersionSelector.defaultProps = defaultProps;
111
112
  export { TopContentProductVersionSelector };
@@ -307,3 +307,11 @@ div.prefhostnameTooltip {
307
307
  svg.hostnameSpinner {
308
308
  vertical-align: -0.65rem !important;
309
309
  }
310
+
311
+ #version-dropdown-selector {
312
+ z-index: 9999;
313
+ }
314
+
315
+ #tc-product-dropdown-selector {
316
+ z-index: 9999;
317
+ }
@@ -126,3 +126,7 @@ div.performance-metrics-modal {
126
126
  color: var(--pf-global--Color--100);
127
127
  }
128
128
  }
129
+
130
+ .top-content-panel {
131
+ z-index: 100;
132
+ }