@rh-support/manage 1.0.34 → 1.0.36

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 (18) hide show
  1. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentEditor.d.ts.map +1 -1
  2. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentEditor.js +3 -1
  3. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestion.d.ts +6 -0
  4. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestion.d.ts.map +1 -0
  5. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestion.js +23 -0
  6. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestionHint.d.ts +8 -0
  7. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestionHint.d.ts.map +1 -0
  8. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestionHint.js +47 -0
  9. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestionHintAccept.d.ts +9 -0
  10. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestionHintAccept.d.ts.map +1 -0
  11. package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestionHintAccept.js +117 -0
  12. package/lib/esm/context/TopContentProvider.d.ts.map +1 -1
  13. package/lib/esm/context/TopContentProvider.js +1 -0
  14. package/lib/esm/reducers/TopContentReducer.d.ts +32 -2
  15. package/lib/esm/reducers/TopContentReducer.d.ts.map +1 -1
  16. package/lib/esm/reducers/TopContentReducer.js +82 -13
  17. package/lib/esm/scss/_pf4-overrides.scss +18 -0
  18. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"TopContentEditor.d.ts","sourceRoot":"","sources":["../../../../../src/components/TopContentManagement/TopContentEditor/TopContentEditor.tsx"],"names":[],"mappings":"AA2CA,wBAAgB,gBAAgB,gBAsT/B"}
1
+ {"version":3,"file":"TopContentEditor.d.ts","sourceRoot":"","sources":["../../../../../src/components/TopContentManagement/TopContentEditor/TopContentEditor.tsx"],"names":[],"mappings":"AA4CA,wBAAgB,gBAAgB,gBAuT/B"}
@@ -25,6 +25,7 @@ import { TopContentHeader } from '../TopContentHeader';
25
25
  import { TopContentProductVersionSelector } from '../TopContentProductVersionSelector';
26
26
  import { TopContentCategory } from './TopContentCategoryContent/TopContentCategory';
27
27
  import { TopContentCategoryNew } from './TopContentCategoryContent/TopContentCategoryNew';
28
+ import { TopContentSuggestion } from './TopContentSuggestion/TopContentSuggestion';
28
29
  export function TopContentEditor() {
29
30
  const { t } = useTranslation();
30
31
  const [categoryToOpen, setCategoryToOpen] = useState(null);
@@ -112,7 +113,8 @@ export function TopContentEditor() {
112
113
  !topContentResponse.isFetching && topContentResponse.isError && (React.createElement(Alert, { isInline: true, variant: AlertVariant.danger, title: React.createElement(Trans, null, "Error loading Top Content") })),
113
114
  React.createElement(TopContentProductVersionSelector, { selectedProduct: selectedProduct, selectedVersion: selectedVersion, onProductChange: onProductChange, onVersionChange: onVersionChange }),
114
115
  !topContentResponse.isFetching && (React.createElement(TopContentSearch, { dataTrackingId: "top-content-filter-manage", topContentData: flagContentEditState, onSearch: onSearch, topContentResultsWrapperRef: topContentResultsRef })),
115
- React.createElement("div", { className: "top-content-manage-wrapper" },
116
+ React.createElement("div", { className: "top-content-manage-wrapper pf-u-pt-md" },
117
+ !topContentResponse.isFetching && !!filteredTC.length && React.createElement(TopContentSuggestion, null),
116
118
  topContentResponse.isFetching ? (React.createElement(Bullseye, null,
117
119
  React.createElement(EmptyState, { variant: EmptyStateVariant.full },
118
120
  React.createElement(Spinner, { size: "lg" })))) : (!topContentResponse.isFetching &&
@@ -0,0 +1,6 @@
1
+ import { FC } from 'react';
2
+ interface IProps {
3
+ }
4
+ export declare const TopContentSuggestion: FC<IProps>;
5
+ export {};
6
+ //# sourceMappingURL=TopContentSuggestion.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,23 @@
1
+ import { ExpandableSection, Panel, PanelMain, PanelMainBody, Title } from '@patternfly/react-core';
2
+ import React, { useEffect, useState } from 'react';
3
+ import { Trans } from 'react-i18next';
4
+ import { useTopContentContext, useTopContentDispatchContext } from '../../../../context/TopContentProvider';
5
+ import { fetchTopContentSuggestions } from '../../../../reducers/TopContentReducer';
6
+ import { TopContentSuggestionHint } from './TopContentSuggestionHint';
7
+ export const TopContentSuggestion = () => {
8
+ var _a;
9
+ const [isExpanded, setExpanded] = useState(false);
10
+ const onToggle = () => setExpanded((previousExpandedState) => !previousExpandedState);
11
+ const { selectedProduct, selectedVersion, suggestion } = useTopContentContext();
12
+ const topContentDispatch = useTopContentDispatchContext();
13
+ useEffect(() => {
14
+ if ((selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.name) && selectedVersion) {
15
+ fetchTopContentSuggestions(topContentDispatch, selectedProduct.name, selectedVersion);
16
+ }
17
+ }, [topContentDispatch, selectedProduct, selectedVersion]);
18
+ return (React.createElement(Panel, { variant: "raised", className: "pf-u-mx-md pf-u-p-md" },
19
+ React.createElement(PanelMain, null,
20
+ React.createElement(PanelMainBody, null,
21
+ 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 }))))))));
23
+ };
@@ -0,0 +1,8 @@
1
+ import { ITopContentResource } from '@cee-eng/hydrajs/@types/models/topContent/topContentModel';
2
+ import { FC } from 'react';
3
+ interface IProps {
4
+ resources: ITopContentResource;
5
+ }
6
+ export declare const TopContentSuggestionHint: FC<IProps>;
7
+ export {};
8
+ //# sourceMappingURL=TopContentSuggestionHint.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,47 @@
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, Card, CardBody, Truncate } from '@patternfly/react-core';
11
+ import { ToastNotification } from '@rh-support/components';
12
+ import React, { useState } from 'react';
13
+ import { Trans, useTranslation } from 'react-i18next';
14
+ import { useTopContentContext, useTopContentDispatchContext } from '../../../../context/TopContentProvider';
15
+ import { deleteTopContentSuggestion } from '../../../../reducers/TopContentReducer';
16
+ import { TopContentSuggestionHintAccept } from './TopContentSuggestionHintAccept';
17
+ export const TopContentSuggestionHint = ({ resources }) => {
18
+ const { t } = useTranslation();
19
+ const [isAccepted, setAccepted] = useState(false);
20
+ const [isRemoving, setIsRemoving] = useState(false);
21
+ const { suggestion } = useTopContentContext();
22
+ const topContentDispatch = useTopContentDispatchContext();
23
+ const onIgnore = () => __awaiter(void 0, void 0, void 0, function* () {
24
+ try {
25
+ setIsRemoving(true);
26
+ yield deleteTopContentSuggestion(topContentDispatch, suggestion, resources.id);
27
+ ToastNotification.addSuccessMessage(t('Suggestion successfully removed'));
28
+ }
29
+ catch (_a) {
30
+ ToastNotification.addDangerMessage(t('Failed to remove suggestion'));
31
+ }
32
+ finally {
33
+ setIsRemoving(false);
34
+ }
35
+ });
36
+ return !isAccepted ? (React.createElement(Card, { className: "pf-u-m-sm card-hint" },
37
+ React.createElement(CardBody, { className: "card-body" },
38
+ React.createElement("span", { className: "hint-title", "data-testid": "suggestion-content-title" },
39
+ React.createElement(Truncate, { content: resources === null || resources === void 0 ? void 0 : resources.resourceTitle })),
40
+ React.createElement("span", { className: "pf-u-float-right" },
41
+ React.createElement(Button, { variant: "link", isInline: true, className: "pf-u-mr-xl", onClick: () => setAccepted(true), title: "Accept" },
42
+ React.createElement("b", null,
43
+ React.createElement(Trans, null, "Accept"))),
44
+ React.createElement(Button, { variant: "link", isInline: true, onClick: onIgnore, isDisabled: isRemoving },
45
+ React.createElement("b", null,
46
+ React.createElement(Trans, null, "Ignore"))))))) : (React.createElement(TopContentSuggestionHintAccept, { onCancel: setAccepted, resources: resources }));
47
+ };
@@ -0,0 +1,9 @@
1
+ import { ITopContentResource } from '@cee-eng/hydrajs/@types/models/topContent/topContentModel';
2
+ import { FC } from 'react';
3
+ interface IProps {
4
+ onCancel: (isAccepted: boolean) => void;
5
+ resources: ITopContentResource;
6
+ }
7
+ export declare const TopContentSuggestionHintAccept: FC<IProps>;
8
+ export {};
9
+ //# sourceMappingURL=TopContentSuggestionHintAccept.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,117 @@
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 { ActionGroup, Button, Card, CardBody, Form, FormGroup, Select, SelectOption, SelectVariant, TextInput, } from '@patternfly/react-core';
11
+ import { ToastNotification } from '@rh-support/components';
12
+ import { getVersion, isRegularVersion } from '@rh-support/utils';
13
+ import { isEmpty, isUndefined } from 'lodash';
14
+ import React, { useEffect, useMemo, useState } from 'react';
15
+ import { Trans, useTranslation } from 'react-i18next';
16
+ import { useTopContentContext, useTopContentDispatchContext } from '../../../../context/TopContentProvider';
17
+ import { ContentMode, deleteTopContentSuggestion, fetchCategories, saveAddedNewSectionContents, saveAddToTopContent, } from '../../../../reducers/TopContentReducer';
18
+ export const TopContentSuggestionHintAccept = ({ onCancel, resources }) => {
19
+ const { t } = useTranslation();
20
+ const { categories, topContentResponse, topContentEditState, selectedProduct, selectedVersion, isCatOnlyForMajorVersion, isAddingCategory, suggestion, } = useTopContentContext();
21
+ const topContentDispatch = useTopContentDispatchContext();
22
+ const [isSelectOpen, setSelectOpen] = useState(false);
23
+ const [selected, setSelected] = useState();
24
+ const [isSaving, setIsSaving] = useState(false);
25
+ const [resourceTitle, setResourceTitle] = useState('');
26
+ const categoryToSave = useMemo(() => topContentEditState.find((category) => category.categoryId === (selected === null || selected === void 0 ? void 0 : selected.id)), [topContentEditState, selected]);
27
+ const isMajorVersionOnly = isUndefined(getVersion(selectedVersion).minor);
28
+ const minorSelectedNoMinorContentButAvailableMajorContent = !topContentResponse.isFetching &&
29
+ !isEmpty(topContentResponse.data) &&
30
+ getVersion(selectedVersion).minor &&
31
+ isRegularVersion(selectedVersion) &&
32
+ isCatOnlyForMajorVersion &&
33
+ !isAddingCategory;
34
+ const onToggle = () => {
35
+ setSelectOpen((previousToggleState) => !previousToggleState);
36
+ };
37
+ const onSelect = (event, selection, isPlaceholder) => {
38
+ setSelected(selection);
39
+ onToggle();
40
+ };
41
+ const addContentToCategory = () => __awaiter(void 0, void 0, void 0, function* () {
42
+ try {
43
+ setIsSaving(true);
44
+ const newContent = {
45
+ contentTitle: resourceTitle,
46
+ contentRank: categoryToSave === null || categoryToSave === void 0 ? void 0 : categoryToSave.content.length,
47
+ contentUrl: resources.resourceViewUri,
48
+ mode: ContentMode.ADD,
49
+ };
50
+ yield saveAddToTopContent(topContentDispatch, topContentEditState, categoryToSave.id, categoryToSave === null || categoryToSave === void 0 ? void 0 : categoryToSave.categoryId, newContent, -1);
51
+ yield deleteTopContentSuggestion(topContentDispatch, suggestion, resources.id);
52
+ ToastNotification.addSuccessMessage(t('Content has been successfully added'));
53
+ }
54
+ catch (e) {
55
+ ToastNotification.addDangerMessage(t('Failed to save top content'));
56
+ }
57
+ finally {
58
+ setIsSaving(false);
59
+ }
60
+ });
61
+ const addContentToNewCategory = () => __awaiter(void 0, void 0, void 0, function* () {
62
+ try {
63
+ setIsSaving(true);
64
+ const newContent = {
65
+ contentTitle: resourceTitle,
66
+ contentUrl: resources.resourceViewUri,
67
+ isAttentionNeeded: false,
68
+ mode: ContentMode.NEW_SECTION_CONTENT,
69
+ };
70
+ yield saveAddedNewSectionContents(topContentDispatch, topContentEditState, selected, selectedProduct, selectedVersion, isMajorVersionOnly, newContent, minorSelectedNoMinorContentButAvailableMajorContent);
71
+ yield deleteTopContentSuggestion(topContentDispatch, suggestion, resources.id);
72
+ ToastNotification.addSuccessMessage(t('Content has been successfully added'));
73
+ }
74
+ catch (e) {
75
+ ToastNotification.addDangerMessage(t('Failed to save top content'));
76
+ }
77
+ finally {
78
+ setIsSaving(false);
79
+ }
80
+ });
81
+ const onSaveContent = () => __awaiter(void 0, void 0, void 0, function* () {
82
+ if (minorSelectedNoMinorContentButAvailableMajorContent || isUndefined(categoryToSave)) {
83
+ // if top contents are available for major version only or if selected category is not present
84
+ // for this version then create a new category
85
+ addContentToNewCategory();
86
+ }
87
+ else {
88
+ //otherwise get and push to existing category
89
+ addContentToCategory();
90
+ }
91
+ });
92
+ useEffect(() => {
93
+ setResourceTitle(resources.resourceTitle);
94
+ }, [resources.resourceTitle]);
95
+ useEffect(() => {
96
+ try {
97
+ fetchCategories(topContentDispatch);
98
+ }
99
+ catch (_a) {
100
+ ToastNotification.addDangerMessage(t('There was an error loading top content categories'));
101
+ }
102
+ }, [topContentDispatch, t]);
103
+ return (React.createElement(Card, null,
104
+ React.createElement(CardBody, { className: "card-hint" },
105
+ React.createElement("span", { className: "hint-title" }, resources.resourceTitle),
106
+ React.createElement(Form, null,
107
+ 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 },
109
+ 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" },
114
+ React.createElement(Trans, null, "Save")),
115
+ React.createElement(Button, { variant: "link", onClick: () => onCancel(false) },
116
+ React.createElement(Trans, null, "Cancel")))))));
117
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"TopContentProvider.d.ts","sourceRoot":"","sources":["../../../src/context/TopContentProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAiC,MAAM,OAAO,CAAC;AAEtD,OAAO,EAAE,gBAAgB,EAAqB,6BAA6B,EAAE,MAAM,+BAA+B,CAAC;AAEnH,eAAO,MAAM,uBAAuB,EAAE,gBAarC,CAAC;AAGF,eAAO,MAAM,sBAAsB,iCAAiE,CAAC;AACrG,eAAO,MAAM,yBAAyB,8CAA6C,CAAC;AAEpF,wBAAgB,oBAAoB,qBAMnC;AAED,wBAAgB,4BAA4B,kCAM3C;AAED,wBAAgB,yBAAyB,CAAC,EAAE,QAAQ,EAAE;;CAAA,eAOrD"}
1
+ {"version":3,"file":"TopContentProvider.d.ts","sourceRoot":"","sources":["../../../src/context/TopContentProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAiC,MAAM,OAAO,CAAC;AAEtD,OAAO,EAAE,gBAAgB,EAAqB,6BAA6B,EAAE,MAAM,+BAA+B,CAAC;AAEnH,eAAO,MAAM,uBAAuB,EAAE,gBAcrC,CAAC;AAGF,eAAO,MAAM,sBAAsB,iCAAiE,CAAC;AACrG,eAAO,MAAM,yBAAyB,8CAA6C,CAAC;AAEpF,wBAAgB,oBAAoB,qBAMnC;AAED,wBAAgB,4BAA4B,kCAM3C;AAED,wBAAgB,yBAAyB,CAAC,EAAE,QAAQ,EAAE;;CAAA,eAOrD"}
@@ -14,6 +14,7 @@ export const intialTopContentContext = {
14
14
  contentUrls: {},
15
15
  isSearchModeEnabled: false,
16
16
  categoryUsage: {},
17
+ suggestion: {},
17
18
  };
18
19
  const initalDispatchContext = null;
19
20
  export const TopContentStateContext = React.createContext(intialTopContentContext);
@@ -24,6 +24,20 @@ interface categoryDups {
24
24
  export interface IContentUrlsDups {
25
25
  [url: string]: categoryDups;
26
26
  }
27
+ interface ITopContentSuggestionLinkedResources {
28
+ id: number;
29
+ numberOfCaseLinked: number;
30
+ productName: string;
31
+ version: string;
32
+ resourceDisplayId: string;
33
+ resourceType: string;
34
+ resourceTitle: string;
35
+ resourceViewUri: string;
36
+ }
37
+ export interface ITopContentSuggestion {
38
+ linkedResourcesCount?: number;
39
+ linkedResources?: Array<ITopContentSuggestionLinkedResources>;
40
+ }
27
41
  export interface ITopContentState {
28
42
  isFetchingSolrSearch: boolean;
29
43
  selectedProduct: Partial<IHydraProduct>;
@@ -37,6 +51,7 @@ export interface ITopContentState {
37
51
  contentUrls: IContentUrlsDups;
38
52
  isSearchModeEnabled: boolean;
39
53
  categoryUsage: ITopContentResourceUsagesResponse;
54
+ suggestion: ITopContentSuggestion;
40
55
  }
41
56
  export declare enum ContentMode {
42
57
  INITIAL = "initial",
@@ -60,7 +75,8 @@ export declare enum TopContentReducerConstants {
60
75
  changeTopContentStateOnCatsArrangementSave = "changeTopContentStateOnCatsArrangementSave",
61
76
  setIsSearchModeEnabled = "setIsSearchModeEnabled",
62
77
  resetDuplicatUrls = "resetDuplicatUrls",
63
- getTopContentResourceUsage = "getTopContentResourceUsage"
78
+ getTopContentResourceUsage = "getTopContentResourceUsage",
79
+ setTopContentSuggestions = "setTopContentSuggestions"
64
80
  }
65
81
  declare type IActionType = IAction<TopContentReducerConstants, ITopContentState>;
66
82
  export declare type TopContentReducerDispatchType = (value: IActionType) => void;
@@ -77,7 +93,7 @@ export declare const fetchTopContentRecourseUsage: (dispatch: TopContentReducerD
77
93
  export declare const addTopContent: (dispatch: TopContentReducerDispatchType, topContentEditState: ITopContentEditState[], categoryId: number) => void;
78
94
  export declare const deleteTopContent: (dispatch: TopContentReducerDispatchType, topContentEditState: ITopContentEditState[], categoryId: number, topContentId: number) => Promise<never>;
79
95
  export declare const removeTopContent: (dispatch: TopContentReducerDispatchType, topContentEditState: ITopContentEditState[], categoryId: number, i: number) => void;
80
- export declare const saveAddedNewSectionContents: (dispatch: TopContentReducerDispatchType, topContentEditState: ITopContentEditState[], selectedCategory: ITopContentCategory, selectedProduct: Partial<IProduct>, selectedVersion: string, isCatOnlyForMajorVersion: boolean, newContent: any) => Promise<never>;
96
+ export declare const saveAddedNewSectionContents: (dispatch: TopContentReducerDispatchType, topContentEditState: ITopContentEditState[], selectedCategory: ITopContentCategory, selectedProduct: Partial<IProduct>, selectedVersion: string, isCatOnlyForMajorVersion: boolean, newContent: any, isCreatingNewSet?: boolean) => Promise<never>;
81
97
  export declare const saveAddToTopContent: (dispatch: TopContentReducerDispatchType, topContentEditState: ITopContentEditState[], id: number, categoryId: number, content: ITopContentItemState, index: number) => Promise<never>;
82
98
  export declare const saveChangeInCategoryContent: (dispatch: TopContentReducerDispatchType, topContentEditState: ITopContentEditState[], categoryId: number, content: ITopContentItemState, index: number) => Promise<never>;
83
99
  export declare const reArrangeContent: (dispatch: TopContentReducerDispatchType, topContentEditState: ITopContentEditState[], categoryId: number) => Promise<never>;
@@ -85,5 +101,19 @@ export declare const reArrangeCategory: (topContentEditState: ITopContentEditSta
85
101
  export declare const fetchCategories: (dispatch: TopContentReducerDispatchType) => Promise<never>;
86
102
  export declare const setIsSearchModeEnabled: (dispatch: TopContentReducerDispatchType, isSearchModeEnabled: boolean) => void;
87
103
  export declare const resetDuplicatUrls: (dispatch: TopContentReducerDispatchType) => void;
104
+ /**
105
+ * This function is used for to get top content suggestions from server
106
+ * @param dispatch TopContentReducerDispatchType
107
+ * @param productName string
108
+ * @param version string
109
+ */
110
+ export declare const fetchTopContentSuggestions: (dispatch: TopContentReducerDispatchType, productName: string, version: string) => Promise<void>;
111
+ /**
112
+ * This function is used to remove selected top suggestion from server
113
+ * @param dispatch TopContentReducerDispatchType
114
+ * @param suggestion ITopContentSuggestion
115
+ * @param suggestionId number
116
+ */
117
+ export declare const deleteTopContentSuggestion: (dispatch: TopContentReducerDispatchType, suggestion: ITopContentSuggestion, suggestionId: number) => Promise<never>;
88
118
  export {};
89
119
  //# sourceMappingURL=TopContentReducer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TopContentReducer.d.ts","sourceRoot":"","sources":["../../../src/reducers/TopContentReducer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,IAAI,aAAa,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AAC7F,OAAO,EACH,WAAW,EAEX,mBAAmB,EACnB,eAAe,EAGf,iCAAiC,EACpC,MAAM,2DAA2D,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAOxE,MAAM,WAAW,oBAAqB,SAAQ,WAAW;IACrD,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAAC,eAAe,EAAE,SAAS,CAAC;IAC1E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,oBAAoB,EAAE,CAAC;IAChC,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;;;;;;EAOE;AACF,UAAU,YAAY;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC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,6BAA6B,mBAwB5E,CAAC;AAEF,eAAO,MAAM,sBAAsB,aAAc,6BAA6B,uBAAuB,OAAO,SAK3G,CAAC;AAEF,eAAO,MAAM,iBAAiB,aAAc,6BAA6B,SAKxE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,aACzB,6BAA6B,eAC1B,MAAM,WACV,MAAM,kBAsBlB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,aACzB,6BAA6B,cAC3B,qBAAqB,gBACnB,MAAM,mBAavB,CAAC"}
@@ -38,8 +38,10 @@ export var TopContentReducerConstants;
38
38
  TopContentReducerConstants["setIsSearchModeEnabled"] = "setIsSearchModeEnabled";
39
39
  TopContentReducerConstants["resetDuplicatUrls"] = "resetDuplicatUrls";
40
40
  TopContentReducerConstants["getTopContentResourceUsage"] = "getTopContentResourceUsage";
41
+ TopContentReducerConstants["setTopContentSuggestions"] = "setTopContentSuggestions";
41
42
  })(TopContentReducerConstants || (TopContentReducerConstants = {}));
42
43
  export const TopContentReducer = (pState, action) => {
44
+ var _a, _b;
43
45
  switch (action.type) {
44
46
  case TopContentReducerConstants.resetContentWithSelectedProduct: {
45
47
  return Object.assign(Object.assign({}, intialTopContentContext), { selectedProduct: Object.assign({}, action.payload.selectedProduct) });
@@ -54,7 +56,7 @@ export const TopContentReducer = (pState, action) => {
54
56
  return Object.assign(Object.assign({}, pState), { isCatOnlyForMajorVersion: action.payload.isCatOnlyForMajorVersion, topContentEditState: action.payload.topContentEditState, isCreatingNewSet: action.payload.isCreatingNewSet });
55
57
  }
56
58
  case TopContentReducerConstants.changeTopContentStateOnSave: {
57
- return Object.assign(Object.assign({}, pState), { topContentEditState: action.payload.topContentEditState, topContentResponse: action.payload.topContentResponse, contentUrls: action.payload.contentUrls });
59
+ return Object.assign(Object.assign({}, pState), { isCatOnlyForMajorVersion: (_a = action.payload) === null || _a === void 0 ? void 0 : _a.isCatOnlyForMajorVersion, topContentEditState: action.payload.topContentEditState, topContentResponse: action.payload.topContentResponse, contentUrls: action.payload.contentUrls });
58
60
  }
59
61
  case TopContentReducerConstants.changeTopContentStateOnCatsArrangementSave: {
60
62
  return Object.assign(Object.assign({}, pState), { topContentEditState: [...action.payload.topContentEditState], topContentResponse: action.payload.topContentResponse });
@@ -77,6 +79,9 @@ export const TopContentReducer = (pState, action) => {
77
79
  case TopContentReducerConstants.getTopContentResourceUsage: {
78
80
  return Object.assign(Object.assign({}, pState), { categoryUsage: action.payload.categoryUsage });
79
81
  }
82
+ case TopContentReducerConstants.setTopContentSuggestions: {
83
+ return Object.assign(Object.assign({}, pState), { suggestion: (_b = action.payload) === null || _b === void 0 ? void 0 : _b.suggestion });
84
+ }
80
85
  default: {
81
86
  return pState;
82
87
  }
@@ -313,7 +318,7 @@ export const removeTopContent = (dispatch, topContentEditState, categoryId, i) =
313
318
  payload: { topContentEditState },
314
319
  });
315
320
  };
316
- export const saveAddedNewSectionContents = (dispatch, topContentEditState, selectedCategory, selectedProduct, selectedVersion, isCatOnlyForMajorVersion, newContent) => __awaiter(void 0, void 0, void 0, function* () {
321
+ export const saveAddedNewSectionContents = (dispatch, topContentEditState, selectedCategory, selectedProduct, selectedVersion, isCatOnlyForMajorVersion, newContent, isCreatingNewSet = false) => __awaiter(void 0, void 0, void 0, function* () {
317
322
  const versionObj = getVersion(selectedVersion);
318
323
  const createMasterIdParam = {
319
324
  productId: selectedProduct.id,
@@ -335,18 +340,25 @@ export const saveAddedNewSectionContents = (dispatch, topContentEditState, selec
335
340
  try {
336
341
  const res = yield pcm.topContent.postTopContent({ topContents: [toAdd] });
337
342
  const newSavedContent = res.topContents[0];
338
- topContentEditState = [...topContentEditState].map((cat) => {
339
- if (cat.catMode === CategoryMode.NEW_SECTION) {
340
- cat = Object.assign(Object.assign(Object.assign({}, cat), newSavedContent), { catMode: CategoryMode.EXISTING_SECTION, content: [
341
- Object.assign(Object.assign({}, newContent), { contentRank: 0, topContentId: newSavedContent.id, mode: ContentMode.INITIAL, createdBy: newSavedContent.createdBy, createdOn: newSavedContent.createdOn }),
342
- ] });
343
- }
344
- return cat;
345
- });
343
+ const oldCat = {
344
+ id: -1,
345
+ categoryRank: 0,
346
+ };
347
+ const newCat = Object.assign(Object.assign(Object.assign({}, oldCat), newSavedContent), { catMode: CategoryMode.EXISTING_SECTION, content: [
348
+ Object.assign(Object.assign({}, newContent), { contentRank: 0, topContentId: newSavedContent.id, mode: ContentMode.INITIAL, createdBy: newSavedContent.createdBy, createdOn: newSavedContent.createdOn }),
349
+ ] });
350
+ if (isCreatingNewSet) {
351
+ topContentEditState = [newCat];
352
+ }
353
+ else {
354
+ topContentEditState = topContentEditState.filter((cat) => cat.catMode !== CategoryMode.NEW_SECTION);
355
+ topContentEditState = [...topContentEditState, newCat];
356
+ }
346
357
  dispatch({
347
358
  type: TopContentReducerConstants.changeTopContentStateOnSave,
348
359
  payload: {
349
360
  topContentEditState,
361
+ isCatOnlyForMajorVersion,
350
362
  topContentResponse: getApiResourceObject(topContentEditState),
351
363
  contentUrls: getContentUrls(topContentEditState),
352
364
  },
@@ -372,16 +384,24 @@ export const saveAddToTopContent = (dispatch, topContentEditState, id, categoryI
372
384
  };
373
385
  const res = yield pcm.topContent.postTopContent({ topContents: [toAdd] });
374
386
  topContentEditState.forEach((cat) => {
375
- var _a, _b, _c;
387
+ var _a, _b, _c, _d, _e, _f;
376
388
  if (cat.id === id) {
377
- cat.content[index] = Object.assign(Object.assign({}, cat.content[index]), { mode: ContentMode.INITIAL, contentTitle: content.contentTitle, contentUrl: content.contentUrl, topContentId: (_a = res === null || res === void 0 ? void 0 : res.topContents[0]) === null || _a === void 0 ? void 0 : _a.id, createdBy: (_b = res === null || res === void 0 ? void 0 : res.topContents[0]) === null || _b === void 0 ? void 0 : _b.createdBy, createdOn: (_c = res === null || res === void 0 ? void 0 : res.topContents[0]) === null || _c === void 0 ? void 0 : _c.createdOn });
389
+ if (index === -1) {
390
+ //moving suggested content to top content
391
+ const newContent = Object.assign(Object.assign({}, content), { mode: ContentMode.INITIAL, topContentId: (_a = res === null || res === void 0 ? void 0 : res.topContents[0]) === null || _a === void 0 ? void 0 : _a.id, createdBy: (_b = res === null || res === void 0 ? void 0 : res.topContents[0]) === null || _b === void 0 ? void 0 : _b.createdBy, createdOn: (_c = res === null || res === void 0 ? void 0 : res.topContents[0]) === null || _c === void 0 ? void 0 : _c.createdOn });
392
+ cat.content = [...cat.content, newContent];
393
+ }
394
+ else {
395
+ // creating a new top content
396
+ cat.content[index] = Object.assign(Object.assign({}, cat.content[index]), { mode: ContentMode.INITIAL, contentTitle: content.contentTitle, contentUrl: content.contentUrl, topContentId: (_d = res === null || res === void 0 ? void 0 : res.topContents[0]) === null || _d === void 0 ? void 0 : _d.id, createdBy: (_e = res === null || res === void 0 ? void 0 : res.topContents[0]) === null || _e === void 0 ? void 0 : _e.createdBy, createdOn: (_f = res === null || res === void 0 ? void 0 : res.topContents[0]) === null || _f === void 0 ? void 0 : _f.createdOn });
397
+ }
378
398
  }
379
399
  });
380
400
  // update both current state and original get state
381
401
  dispatch({
382
402
  type: TopContentReducerConstants.changeTopContentStateOnSave,
383
403
  payload: {
384
- topContentEditState,
404
+ topContentEditState: [...topContentEditState],
385
405
  topContentResponse: getApiResourceObject(topContentEditState),
386
406
  contentUrls: getContentUrls(topContentEditState),
387
407
  },
@@ -511,3 +531,52 @@ export const resetDuplicatUrls = (dispatch) => {
511
531
  payload: { contentUrls: {} },
512
532
  });
513
533
  };
534
+ /**
535
+ * This function is used for to get top content suggestions from server
536
+ * @param dispatch TopContentReducerDispatchType
537
+ * @param productName string
538
+ * @param version string
539
+ */
540
+ export const fetchTopContentSuggestions = (dispatch, productName, version) => __awaiter(void 0, void 0, void 0, function* () {
541
+ try {
542
+ dispatch({
543
+ type: TopContentReducerConstants.setTopContentSuggestions,
544
+ payload: { suggestion: {} },
545
+ });
546
+ const topContentSuggestions = yield pcm.topContent.suggestedTopContent({
547
+ productName: productName,
548
+ version,
549
+ });
550
+ dispatch({
551
+ type: TopContentReducerConstants.setTopContentSuggestions,
552
+ payload: { suggestion: topContentSuggestions },
553
+ });
554
+ }
555
+ catch (e) {
556
+ dispatch({
557
+ type: TopContentReducerConstants.setTopContentSuggestions,
558
+ payload: { suggestion: {} },
559
+ });
560
+ }
561
+ });
562
+ /**
563
+ * This function is used to remove selected top suggestion from server
564
+ * @param dispatch TopContentReducerDispatchType
565
+ * @param suggestion ITopContentSuggestion
566
+ * @param suggestionId number
567
+ */
568
+ export const deleteTopContentSuggestion = (dispatch, suggestion, suggestionId) => __awaiter(void 0, void 0, void 0, function* () {
569
+ var _b, _c;
570
+ try {
571
+ yield pcm.topContent.deleteTopContentSuggestion(suggestionId);
572
+ suggestion.linkedResources = (_b = suggestion.linkedResources) === null || _b === void 0 ? void 0 : _b.filter((resource) => resource.id !== suggestionId);
573
+ suggestion.linkedResourcesCount = (_c = suggestion.linkedResources) === null || _c === void 0 ? void 0 : _c.length;
574
+ dispatch({
575
+ type: TopContentReducerConstants.setTopContentSuggestions,
576
+ payload: { suggestion },
577
+ });
578
+ }
579
+ catch (e) {
580
+ return Promise.reject(e);
581
+ }
582
+ });
@@ -108,3 +108,21 @@ div.performance-metrics-modal {
108
108
  }
109
109
  }
110
110
  }
111
+
112
+ #top-content-suggestion {
113
+ .pf-c-expandable-section__content {
114
+ border: unset;
115
+ }
116
+ .card-hint {
117
+ background-color: var(--pf-global--BackgroundColor--200);
118
+ }
119
+ .card-body {
120
+ padding: var(--pf-global--spacer--md);
121
+ }
122
+ .hint-title {
123
+ color: var(--pf-global--primary-color--100);
124
+ }
125
+ .accordion_title {
126
+ color: var(--pf-global--Color--100);
127
+ }
128
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/manage",
3
- "version": "1.0.34",
3
+ "version": "1.0.36",
4
4
  "description": "Customer Support Manage App",
5
5
  "author": "Jordan Eudy <jeudy100@gmail.com>",
6
6
  "homepage": "",
@@ -94,9 +94,9 @@
94
94
  "@patternfly/pfe-tabs": "1.12.3",
95
95
  "@patternfly/react-core": "4.264.0",
96
96
  "@patternfly/react-table": "4.111.33",
97
- "@rh-support/components": "1.2.18",
97
+ "@rh-support/components": "1.2.20",
98
98
  "@rh-support/configs": "1.0.1",
99
- "@rh-support/react-context": "1.0.25",
99
+ "@rh-support/react-context": "1.0.27",
100
100
  "@rh-support/types": "0.2.0",
101
101
  "@rh-support/user-permissions": "1.0.11",
102
102
  "@rh-support/utils": "1.0.9",
@@ -109,5 +109,5 @@
109
109
  "react-i18next": ">=10.11.0",
110
110
  "react-router-dom": ">=5.1.2"
111
111
  },
112
- "gitHead": "67c86ae65999c9e8d868a567bcd70f8d7401d386"
112
+ "gitHead": "4400d957d019194adb8d28fca41cc4795b02d3ea"
113
113
  }