@rh-support/manage 1.0.41 → 1.0.42
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.
|
@@ -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;
|
|
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,18 +7,21 @@ 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 {
|
|
10
|
+
import { Button, Card, CardBody, Form, FormGroup, Select, SelectOption, SelectVariant, TextInput, Tooltip, ValidatedOptions, } from '@patternfly/react-core';
|
|
11
11
|
import PencilAltIcon from '@patternfly/react-icons/dist/js/icons/pencil-alt-icon';
|
|
12
12
|
import { ToastNotification } from '@rh-support/components';
|
|
13
13
|
import { getVersion, isRegularVersion, isValidUrl } from '@rh-support/utils';
|
|
14
|
-
import { isEmpty, isUndefined } from 'lodash';
|
|
14
|
+
import { isEmpty, isUndefined, trim } from 'lodash';
|
|
15
15
|
import React, { useEffect, useMemo, useState } from 'react';
|
|
16
16
|
import { Trans, useTranslation } from 'react-i18next';
|
|
17
|
+
import { CATEGORY_LIMIT } from '../../../../constants/TopContent';
|
|
17
18
|
import { useTopContentContext, useTopContentDispatchContext } from '../../../../context/TopContentProvider';
|
|
19
|
+
import { flagContentUsage } from '../../../../reducers/TopContentHelpers';
|
|
18
20
|
import { ContentMode, deleteTopContentSuggestion, fetchCategories, saveAddedNewSectionContents, saveAddToTopContent, } from '../../../../reducers/TopContentReducer';
|
|
21
|
+
import CategoryLimit from '../../CategoryLimit/CategoryLimit';
|
|
19
22
|
export const TopContentSuggestionHintAccept = ({ onCancel, resources }) => {
|
|
20
23
|
const { t } = useTranslation();
|
|
21
|
-
const { categories, topContentResponse, topContentEditState, selectedProduct, selectedVersion, isCatOnlyForMajorVersion, isAddingCategory, suggestion, } = useTopContentContext();
|
|
24
|
+
const { categories, topContentResponse, topContentEditState, selectedProduct, selectedVersion, isCatOnlyForMajorVersion, isAddingCategory, suggestion, categoryUsage, } = useTopContentContext();
|
|
22
25
|
const topContentDispatch = useTopContentDispatchContext();
|
|
23
26
|
const [isSelectOpen, setSelectOpen] = useState(false);
|
|
24
27
|
const [selected, setSelected] = useState();
|
|
@@ -27,6 +30,7 @@ export const TopContentSuggestionHintAccept = ({ onCancel, resources }) => {
|
|
|
27
30
|
const [linkToContent, setLinkToContent] = useState('');
|
|
28
31
|
const [isEditClicked, setIsEditClicked] = useState(false);
|
|
29
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]);
|
|
30
34
|
const isMajorVersionOnly = isUndefined(getVersion(selectedVersion).minor);
|
|
31
35
|
const minorSelectedNoMinorContentButAvailableMajorContent = !topContentResponse.isFetching &&
|
|
32
36
|
!isEmpty(topContentResponse.data) &&
|
|
@@ -34,6 +38,8 @@ export const TopContentSuggestionHintAccept = ({ onCancel, resources }) => {
|
|
|
34
38
|
isRegularVersion(selectedVersion) &&
|
|
35
39
|
isCatOnlyForMajorVersion &&
|
|
36
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));
|
|
37
43
|
const onToggle = () => {
|
|
38
44
|
setSelectOpen((previousToggleState) => !previousToggleState);
|
|
39
45
|
};
|
|
@@ -41,7 +47,11 @@ export const TopContentSuggestionHintAccept = ({ onCancel, resources }) => {
|
|
|
41
47
|
setSelected(selection);
|
|
42
48
|
onToggle();
|
|
43
49
|
};
|
|
44
|
-
const isDisabled = isEmpty(linkToContent) ||
|
|
50
|
+
const isDisabled = isEmpty(linkToContent) ||
|
|
51
|
+
isEmpty(trim(resourceTitle)) ||
|
|
52
|
+
isUndefined(selected) ||
|
|
53
|
+
!isValidUrl(linkToContent) ||
|
|
54
|
+
(isCategoryLimitReached && !isCategoryInList);
|
|
45
55
|
const addContentToCategory = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
56
|
try {
|
|
47
57
|
setIsSaving(true);
|
|
@@ -105,7 +115,7 @@ export const TopContentSuggestionHintAccept = ({ onCancel, resources }) => {
|
|
|
105
115
|
ToastNotification.addDangerMessage(t('There was an error loading top content categories'));
|
|
106
116
|
}
|
|
107
117
|
}, [topContentDispatch, t]);
|
|
108
|
-
return (React.createElement(Card,
|
|
118
|
+
return (React.createElement(Card, { className: "pf-u-m-sm" },
|
|
109
119
|
React.createElement(CardBody, { className: "card-hint" },
|
|
110
120
|
React.createElement(Form, null,
|
|
111
121
|
isEditClicked ? (React.createElement(React.Fragment, null,
|
|
@@ -114,7 +124,7 @@ export const TopContentSuggestionHintAccept = ({ onCancel, resources }) => {
|
|
|
114
124
|
? ValidatedOptions.error
|
|
115
125
|
: ValidatedOptions.default })),
|
|
116
126
|
React.createElement(FormGroup, { label: t('Headline'), isRequired: true, fieldId: "simple-form-email-01" },
|
|
117
|
-
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(resourceTitle) ? ValidatedOptions.error : ValidatedOptions.default })))) : (React.createElement("span", null,
|
|
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,
|
|
118
128
|
React.createElement(Button, { variant: "link", isInline: true },
|
|
119
129
|
React.createElement("u", null,
|
|
120
130
|
React.createElement("a", { className: "hint-title pf-u-font-size-md", target: "_blank", href: linkToContent, rel: "noreferrer" }, resources.resourceTitle))),
|
|
@@ -123,7 +133,8 @@ export const TopContentSuggestionHintAccept = ({ onCancel, resources }) => {
|
|
|
123
133
|
React.createElement(FormGroup, { label: t('Category'), isRequired: true, fieldId: "simple-form-email-01" },
|
|
124
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 },
|
|
125
135
|
React.createElement("div", null, category.categoryName)))))),
|
|
126
|
-
React.createElement(
|
|
136
|
+
React.createElement("div", { className: "pf-u-mt-sm" },
|
|
137
|
+
isCategoryLimitReached && !isCategoryInList && !isUndefined(selected) && React.createElement(CategoryLimit, null),
|
|
127
138
|
React.createElement(Button, { variant: "primary", onClick: onSaveContent, isDisabled: isSaving || isDisabled, isLoading: isSaving, "data-tracking-id": "suggested-content-save-button" },
|
|
128
139
|
React.createElement(Trans, null, "Save")),
|
|
129
140
|
React.createElement(Button, { variant: "link", onClick: () => onCancel(false) },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rh-support/manage",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.42",
|
|
4
4
|
"description": "Customer Support Manage App",
|
|
5
5
|
"author": "Jordan Eudy <jeudy100@gmail.com>",
|
|
6
6
|
"homepage": "",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"not op_mini all"
|
|
52
52
|
],
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@cee-eng/hydrajs": "4.
|
|
54
|
+
"@cee-eng/hydrajs": "4.15.64",
|
|
55
55
|
"@patternfly/patternfly": "4.196.7",
|
|
56
56
|
"@patternfly/pfe-accordion": "1.12.3",
|
|
57
57
|
"@patternfly/pfe-collapse": "1.12.3",
|
|
@@ -87,19 +87,19 @@
|
|
|
87
87
|
"typescript": "4.3.5"
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
|
-
"@cee-eng/hydrajs": "4.
|
|
90
|
+
"@cee-eng/hydrajs": "4.15.64",
|
|
91
91
|
"@patternfly/patternfly": "4.196.7",
|
|
92
92
|
"@patternfly/pfe-accordion": "1.12.3",
|
|
93
93
|
"@patternfly/pfe-collapse": "1.12.3",
|
|
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.
|
|
97
|
+
"@rh-support/components": "1.2.24",
|
|
98
98
|
"@rh-support/configs": "1.0.3",
|
|
99
|
-
"@rh-support/react-context": "1.0.
|
|
99
|
+
"@rh-support/react-context": "1.0.32",
|
|
100
100
|
"@rh-support/types": "0.2.0",
|
|
101
|
-
"@rh-support/user-permissions": "1.0.
|
|
102
|
-
"@rh-support/utils": "1.0.
|
|
101
|
+
"@rh-support/user-permissions": "1.0.14",
|
|
102
|
+
"@rh-support/utils": "1.0.12",
|
|
103
103
|
"@types/react-beautiful-dnd": "^13.0.0",
|
|
104
104
|
"i18next": ">=17.0.1",
|
|
105
105
|
"lodash": ">=4.17.15",
|
|
@@ -109,5 +109,5 @@
|
|
|
109
109
|
"react-i18next": ">=10.11.0",
|
|
110
110
|
"react-router-dom": ">=5.1.2"
|
|
111
111
|
},
|
|
112
|
-
"gitHead": "
|
|
112
|
+
"gitHead": "415d159b0afb5dddc9247a314d138571433625a2"
|
|
113
113
|
}
|