@rh-support/manage 2.1.82 → 2.1.84
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/esm/Manage.d.ts.map +1 -1
- package/lib/esm/Manage.js +4 -3
- package/lib/esm/ManageTabs.d.ts +1 -0
- package/lib/esm/ManageTabs.d.ts.map +1 -1
- package/lib/esm/ManageTabs.js +44 -40
- package/lib/esm/Routes.d.ts +1 -0
- package/lib/esm/Routes.d.ts.map +1 -1
- package/lib/esm/Routes.js +15 -9
- package/lib/esm/components/Configs/ConfigsTable.js +1 -1
- package/lib/esm/components/Groups/ManageGroupUsers/ManageGroupUsers.js +1 -1
- package/lib/esm/components/ManageBookmarkedAccountsTab/ManageGroupedBookmarkedAccountsTab.js +1 -1
- package/lib/esm/components/ManagePartnerships/index.js +1 -1
- package/lib/esm/components/ManagePreferences/ManagePreferences.d.ts.map +1 -1
- package/lib/esm/components/ManagePreferences/ManagePreferences.js +1 -2
- package/lib/esm/components/ManagePreferences/PreferencesBody.js +1 -1
- package/lib/esm/components/ManageTags/TagsManagement.d.ts +3 -0
- package/lib/esm/components/ManageTags/TagsManagement.d.ts.map +1 -0
- package/lib/esm/components/ManageTags/TagsManagement.js +11 -0
- package/lib/esm/components/ManageTags/TagsManager.d.ts +3 -0
- package/lib/esm/components/ManageTags/TagsManager.d.ts.map +1 -0
- package/lib/esm/components/ManageTags/TagsManager.js +240 -0
- package/lib/esm/components/ManageTags/index.d.ts +2 -0
- package/lib/esm/components/ManageTags/index.d.ts.map +1 -0
- package/lib/esm/components/ManageTags/index.js +1 -0
- package/lib/esm/components/NotificationEmails/index.js +1 -1
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/TopContentComponent.d.ts.map +1 -1
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/TopContentComponent.js +1 -1
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/TopContentSingleItem.d.ts +2 -1
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/TopContentSingleItem.d.ts.map +1 -1
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/TopContentSingleItem.js +43 -11
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentEditor.d.ts.map +1 -1
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentEditor.js +38 -9
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestion.d.ts +1 -0
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestion.d.ts.map +1 -1
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestion.js +35 -10
- package/lib/esm/components/TopContentManagement/TopContentManagement.d.ts.map +1 -1
- package/lib/esm/components/TopContentManagement/TopContentManagement.js +4 -3
- package/lib/esm/context/TagManagementContextProvider.d.ts +8 -0
- package/lib/esm/context/TagManagementContextProvider.d.ts.map +1 -0
- package/lib/esm/context/TagManagementContextProvider.js +10 -0
- package/lib/esm/reducers/TagManagmentReducer.d.ts +27 -0
- package/lib/esm/reducers/TagManagmentReducer.d.ts.map +1 -0
- package/lib/esm/reducers/TagManagmentReducer.js +127 -0
- package/lib/esm/reducers/TopContentReducer.d.ts +5 -4
- package/lib/esm/reducers/TopContentReducer.d.ts.map +1 -1
- package/lib/esm/reducers/TopContentReducer.js +10 -2
- package/lib/esm/scss/_main.scss +48 -12
- package/lib/esm/scss/_pf-overrides.scss +24 -0
- package/lib/esm/scss/index.scss +2 -2
- package/package.json +12 -10
- package/lib/esm/ManageTab.d.ts +0 -10
- package/lib/esm/ManageTab.d.ts.map +0 -1
- package/lib/esm/ManageTab.js +0 -22
|
@@ -155,7 +155,7 @@ export function NotificationEmails() {
|
|
|
155
155
|
setIsAddingNotificationEmail(true);
|
|
156
156
|
editEmail({ firstName: '', lastName: '', email: emailToAdd });
|
|
157
157
|
};
|
|
158
|
-
return (React.createElement(
|
|
158
|
+
return (React.createElement(React.Fragment, null,
|
|
159
159
|
React.createElement("header", null,
|
|
160
160
|
React.createElement("h2", null, t('Notification emails')),
|
|
161
161
|
t('Add, edit or remove emails from your account that were added to receive notifications.')),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TopContentComponent.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/TopContentComponent.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAKxC,OAAO,EAGH,oBAAoB,EAGvB,MAAM,wCAAwC,CAAC;AAGhD,MAAM,WAAW,yBAAyB;IACtC,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;CACxB;AAED,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,iBAAiB,CAAC,yBAAyB,
|
|
1
|
+
{"version":3,"file":"TopContentComponent.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/TopContentComponent.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAKxC,OAAO,EAGH,oBAAoB,EAGvB,MAAM,wCAAwC,CAAC;AAGhD,MAAM,WAAW,yBAAyB;IACtC,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;CACxB;AAED,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,iBAAiB,CAAC,yBAAyB,CA0GlF,CAAC"}
|
|
@@ -57,7 +57,7 @@ export const TopContentComponent = (props) => {
|
|
|
57
57
|
React.createElement(Droppable, { droppableId: `${props.category.id}`, type: `drop-inner-${props.category.id}`, isDropDisabled: !isArrangingContent, key: `drop-inner-${props.category.id}` }, (provided) => (React.createElement("div", { ref: provided.innerRef },
|
|
58
58
|
React.createElement("ul", { "aria-label": t('Content list'), className: "list-flat list-flushleft" },
|
|
59
59
|
props.category.content.map((content, i) => (React.createElement(Draggable, { key: `drag-inner-${i}${props.category.id}`, draggableId: `drag-inner-${i}${props.category.id}`, index: i, isDragDisabled: !isArrangingContent }, (provided, snapshot) => (React.createElement("div", Object.assign({ key: `${i}-c`, "aria-label": t('Content'), ref: provided.innerRef }, provided.draggableProps, provided.dragHandleProps),
|
|
60
|
-
React.createElement(TopContentSingleItem, { isArrangingContent: isArrangingContent, category: props.category, snapshot: snapshot, i: i })))))),
|
|
60
|
+
React.createElement(TopContentSingleItem, { isArrangingContent: isArrangingContent, category: props.category, snapshot: snapshot, i: i, key: content.topContentId })))))),
|
|
61
61
|
provided.placeholder),
|
|
62
62
|
!isSearchModeEnabled && buttons)))));
|
|
63
63
|
};
|
|
@@ -4,9 +4,10 @@ import { ITopContentEditState } from '../../../../reducers/TopContentReducer';
|
|
|
4
4
|
interface IProps {
|
|
5
5
|
isArrangingContent: boolean;
|
|
6
6
|
category: ITopContentEditState;
|
|
7
|
-
snapshot
|
|
7
|
+
snapshot?: DraggableStateSnapshot;
|
|
8
8
|
i: number;
|
|
9
9
|
}
|
|
10
|
+
export declare function formatDuplicateWarning(arr: any): any;
|
|
10
11
|
export declare const TopContentSingleItem: ({ isArrangingContent, category, snapshot, i }: IProps) => React.JSX.Element;
|
|
11
12
|
export {};
|
|
12
13
|
//# sourceMappingURL=TopContentSingleItem.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TopContentSingleItem.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/TopContentSingleItem.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TopContentSingleItem.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/TopContentSingleItem.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAmD,MAAM,OAAO,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAU7D,OAAO,EAIH,oBAAoB,EAOvB,MAAM,wCAAwC,CAAC;AAIhD,UAAU,MAAM;IACZ,kBAAkB,EAAE,OAAO,CAAC;IAC5B,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,QAAQ,CAAC,EAAE,sBAAsB,CAAC;IAClC,CAAC,EAAE,MAAM,CAAC;CACb;AAED,wBAAgB,sBAAsB,CAAC,GAAG,KAAA,OASzC;AAED,eAAO,MAAM,oBAAoB,kDAAmD,MAAM,sBA4czF,CAAC"}
|
|
@@ -8,23 +8,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { search } from '@cee-eng/hydrajs';
|
|
11
|
-
import { Button, Icon, TextInput, ValidatedOptions } from '@patternfly/react-core';
|
|
11
|
+
import { Button, Flex, FlexItem, FormGroup, Icon, Label, TextInput, ValidatedOptions } from '@patternfly/react-core';
|
|
12
12
|
import EditAltIcon from '@patternfly/react-icons/dist/js/icons/edit-alt-icon';
|
|
13
13
|
import ExclamationCircleIcon from '@patternfly/react-icons/dist/js/icons/exclamation-circle-icon';
|
|
14
14
|
import GripVerticalIcon from '@patternfly/react-icons/dist/js/icons/grip-vertical-icon';
|
|
15
|
-
import { ToastNotification, useDebounce } from '@rh-support/components';
|
|
15
|
+
import { TagsSelector, ToastNotification, useDebounce } from '@rh-support/components';
|
|
16
16
|
import { formatDate, getDrupalResIdIfTypeFromUrl, getText, isValidUrl } from '@rh-support/utils';
|
|
17
|
+
import { differenceBy, isEqual } from 'lodash';
|
|
17
18
|
import cloneDeep from 'lodash/cloneDeep';
|
|
18
19
|
import findIndex from 'lodash/findIndex';
|
|
19
20
|
import isEmpty from 'lodash/isEmpty';
|
|
20
|
-
import React, { useEffect, useState } from 'react';
|
|
21
|
+
import React, { useContext, useEffect, useMemo, useState } from 'react';
|
|
21
22
|
import { Trans, useTranslation } from 'react-i18next';
|
|
23
|
+
import { TagManagementDispatchContext, TagManagementStateContext, } from '../../../../context/TagManagementContextProvider';
|
|
22
24
|
import { useTopContentContext, useTopContentDispatchContext } from '../../../../context/TopContentProvider';
|
|
25
|
+
import { updateTopContentWithTags } from '../../../../reducers/TagManagmentReducer';
|
|
23
26
|
import { getTopContentUrl } from '../../../../reducers/TopContentHelpers';
|
|
24
27
|
import { ContentMode, deleteTopContent, fetchTopContent, removeTopContent, saveAddedNewSectionContents, saveAddToTopContent, saveChangeInCategoryContent, setIsAddingCategory, } from '../../../../reducers/TopContentReducer';
|
|
25
28
|
import { AddNewCategoryDropDown } from './AddNewCategoryDropDown';
|
|
26
29
|
import { TopContentSingleItemLink } from './TopContentSingleItemLink';
|
|
27
|
-
function formatDuplicateWarning(arr) {
|
|
30
|
+
export function formatDuplicateWarning(arr) {
|
|
28
31
|
if (arr.length === 0 || arr.length === 1)
|
|
29
32
|
return arr;
|
|
30
33
|
if (arr.length === 2) {
|
|
@@ -44,9 +47,13 @@ export const TopContentSingleItem = ({ isArrangingContent, category, snapshot, i
|
|
|
44
47
|
const content = category.content && category.content[i];
|
|
45
48
|
const { t } = useTranslation();
|
|
46
49
|
const { topContentEditState, isCatOnlyForMajorVersion, selectedProduct, selectedVersion, contentUrls } = useTopContentContext();
|
|
50
|
+
const tagManagementEditState = useContext(TagManagementStateContext);
|
|
51
|
+
const { tags: tagOptions } = tagManagementEditState;
|
|
47
52
|
const topContentDispatch = useTopContentDispatchContext();
|
|
53
|
+
const tagManagmentDispatch = useContext(TagManagementDispatchContext);
|
|
48
54
|
const [localContentUrl, setLocalContentUrl] = useState(content.contentUrl);
|
|
49
55
|
const [localContentTitle, setLocalContentTitle] = useState(content.contentTitle);
|
|
56
|
+
const [localSelectedTags, setLocalSelectedTags] = useState(content.tags);
|
|
50
57
|
const [newCategory, setNewCategory] = useState(undefined);
|
|
51
58
|
const [contentTitleIsValid, setContentTitleIsValid] = useState(true);
|
|
52
59
|
const [contentUrlIsValid, setContentUrlIsValid] = useState(true);
|
|
@@ -55,11 +62,16 @@ export const TopContentSingleItem = ({ isArrangingContent, category, snapshot, i
|
|
|
55
62
|
const [isSaving, setIsSaving] = useState(false);
|
|
56
63
|
const duplicateTitleCategoryIndex = findIndex(category.content, (c) => c.contentTitle === localContentTitle.trim());
|
|
57
64
|
const isDuplicateTitle = duplicateTitleCategoryIndex !== -1 && duplicateTitleCategoryIndex !== i && !isEmpty(localContentTitle.trim());
|
|
65
|
+
const oldTagsIds = useMemo(() => { var _a; return ((_a = content === null || content === void 0 ? void 0 : content.tags) === null || _a === void 0 ? void 0 : _a.map((t) => t.id)) || []; }, [content === null || content === void 0 ? void 0 : content.tags]);
|
|
66
|
+
const localTagsIds = useMemo(() => localSelectedTags === null || localSelectedTags === void 0 ? void 0 : localSelectedTags.map((t) => t.id), [localSelectedTags]);
|
|
58
67
|
const onContentTitleChange = (contentTitle, event) => {
|
|
59
68
|
const contentTitleIsValid = event.target.validity.valid;
|
|
60
69
|
setContentTitleIsValid(contentTitleIsValid);
|
|
61
70
|
setLocalContentTitle(contentTitle);
|
|
62
71
|
};
|
|
72
|
+
const handleLocalTagChange = (tags) => {
|
|
73
|
+
setLocalSelectedTags(tags);
|
|
74
|
+
};
|
|
63
75
|
const updateContentTitleFromUrl = (contentUrl) => __awaiter(void 0, void 0, void 0, function* () {
|
|
64
76
|
var _a, _b, _c;
|
|
65
77
|
// throws toast warning and clears it after 4 seconds
|
|
@@ -149,7 +161,11 @@ export const TopContentSingleItem = ({ isArrangingContent, category, snapshot, i
|
|
|
149
161
|
try {
|
|
150
162
|
const newContent = Object.assign(Object.assign({}, content), { contentTitle: localContentTitle, contentUrl: localContentUrl });
|
|
151
163
|
setIsSaving(true);
|
|
152
|
-
yield saveAddToTopContent(topContentDispatch, topContentEditState, category.id, category.categoryId, newContent, i);
|
|
164
|
+
const addedContent = yield saveAddToTopContent(topContentDispatch, topContentEditState, category.id, category.categoryId, newContent, i);
|
|
165
|
+
yield updateTopContentWithTags(tagManagmentDispatch, {
|
|
166
|
+
id: addedContent.topContents[0].id,
|
|
167
|
+
tagList: localSelectedTags.map((t) => parseInt(t.id)),
|
|
168
|
+
}, tagManagementEditState);
|
|
153
169
|
ToastNotification.addSuccessMessage(t('Content added successfully'));
|
|
154
170
|
}
|
|
155
171
|
catch (error) {
|
|
@@ -161,10 +177,12 @@ export const TopContentSingleItem = ({ isArrangingContent, category, snapshot, i
|
|
|
161
177
|
return;
|
|
162
178
|
});
|
|
163
179
|
const onSaveUpdateContent = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
180
|
+
const newTags = differenceBy(localTagsIds, oldTagsIds);
|
|
181
|
+
const deletedTags = differenceBy(oldTagsIds, localTagsIds);
|
|
164
182
|
try {
|
|
165
|
-
const updatedContent = Object.assign(Object.assign({}, content), { contentTitle: localContentTitle, contentUrl: localContentUrl });
|
|
183
|
+
const updatedContent = Object.assign(Object.assign({}, content), { contentTitle: localContentTitle, contentUrl: localContentUrl, tagList: newTags, tags: localSelectedTags.map((t) => ({ id: t.id, tagName: t.tagName })) });
|
|
166
184
|
setIsSaving(true);
|
|
167
|
-
yield saveChangeInCategoryContent(topContentDispatch, topContentEditState, category.categoryId, updatedContent);
|
|
185
|
+
yield saveChangeInCategoryContent(topContentDispatch, topContentEditState, category.categoryId, updatedContent, deletedTags);
|
|
168
186
|
editToggle();
|
|
169
187
|
ToastNotification.addSuccessMessage(t('Content updated successfully'));
|
|
170
188
|
}
|
|
@@ -179,7 +197,11 @@ export const TopContentSingleItem = ({ isArrangingContent, category, snapshot, i
|
|
|
179
197
|
try {
|
|
180
198
|
const newContent = Object.assign(Object.assign({}, content), { contentTitle: localContentTitle, contentUrl: localContentUrl });
|
|
181
199
|
setIsSaving(true);
|
|
182
|
-
yield saveAddedNewSectionContents(topContentDispatch, topContentEditState, newCategory, selectedProduct, selectedVersion, isCatOnlyForMajorVersion, newContent);
|
|
200
|
+
const newCategoryContent = yield saveAddedNewSectionContents(topContentDispatch, topContentEditState, newCategory, selectedProduct, selectedVersion, isCatOnlyForMajorVersion, newContent);
|
|
201
|
+
yield updateTopContentWithTags(tagManagmentDispatch, {
|
|
202
|
+
id: newCategoryContent.topContents[0].id,
|
|
203
|
+
tagList: localSelectedTags.map((t) => parseInt(t.id)),
|
|
204
|
+
}, tagManagementEditState);
|
|
183
205
|
ToastNotification.addSuccessMessage(t('Category created successfully'));
|
|
184
206
|
setIsAddingCategory(topContentDispatch, false);
|
|
185
207
|
}
|
|
@@ -224,6 +246,7 @@ export const TopContentSingleItem = ({ isArrangingContent, category, snapshot, i
|
|
|
224
246
|
setShowDuplicateError(false);
|
|
225
247
|
setContentUrlIsValid(true);
|
|
226
248
|
setIsAddingCategory(topContentDispatch, false);
|
|
249
|
+
setLocalSelectedTags(content.tags);
|
|
227
250
|
};
|
|
228
251
|
useDebounce(() => {
|
|
229
252
|
onLocalContentUrlChange();
|
|
@@ -235,6 +258,7 @@ export const TopContentSingleItem = ({ isArrangingContent, category, snapshot, i
|
|
|
235
258
|
useEffect(() => {
|
|
236
259
|
setLocalContentTitle(content.contentTitle);
|
|
237
260
|
setLocalContentUrl(content.contentUrl);
|
|
261
|
+
setLocalSelectedTags(content.tags);
|
|
238
262
|
}, [content]);
|
|
239
263
|
// To check if input has spaces
|
|
240
264
|
const doesInputHasSpaces = isEmpty(localContentTitle.trim());
|
|
@@ -243,20 +267,23 @@ export const TopContentSingleItem = ({ isArrangingContent, category, snapshot, i
|
|
|
243
267
|
isDuplicateTitle ||
|
|
244
268
|
!(contentTitleIsValid && contentUrlIsValid && localContentTitle && localContentUrl) ||
|
|
245
269
|
(!newCategory && content.mode === ContentMode.NEW_SECTION_CONTENT) ||
|
|
246
|
-
(localContentUrl === content.contentUrl &&
|
|
270
|
+
(localContentUrl === content.contentUrl &&
|
|
271
|
+
localContentTitle === content.contentTitle &&
|
|
272
|
+
isEqual(localTagsIds, oldTagsIds));
|
|
247
273
|
const lastModifiedBy = t(`Last modified {{created}} by {{by}}`, {
|
|
248
274
|
created: formatDate(content.updatedOn || content.createdOn),
|
|
249
275
|
by: content.updatedBy || content.createdBy,
|
|
250
276
|
});
|
|
251
277
|
return (React.createElement(React.Fragment, null,
|
|
252
|
-
isPreview && content.mode !== ContentMode.ADD && content.mode !== ContentMode.NEW_SECTION_CONTENT && (React.createElement("li", { className: `push-bottom-narrow ${snapshot.isDragging ? 'list-flat tc-drag' : ''}` },
|
|
278
|
+
isPreview && content.mode !== ContentMode.ADD && content.mode !== ContentMode.NEW_SECTION_CONTENT && (React.createElement("li", { className: `push-bottom-narrow ${(snapshot === null || snapshot === void 0 ? void 0 : snapshot.isDragging) ? 'list-flat tc-drag' : ''}` },
|
|
253
279
|
isArrangingContent && (React.createElement(Icon, { size: "sm" },
|
|
254
280
|
React.createElement(GripVerticalIcon, { style: { cursor: 'move' }, title: t('Drag'), color: "#06c", className: "pf-v5-u-mr-sm" }))),
|
|
255
281
|
!isArrangingContent ? (React.createElement(React.Fragment, null,
|
|
256
282
|
React.createElement(TopContentSingleItemLink, { url: getTopContentUrl(content.contentUrl), title: content.contentTitle, contentId: content.topContentId, needsAttention: content.isAttentionNeeded, lastModifiedBy: lastModifiedBy, selectedVersion: selectedVersion }),
|
|
257
283
|
' ',
|
|
258
284
|
React.createElement(Button, { variant: "link", isInline: true, icon: React.createElement(EditAltIcon, null), onClick: editToggle, title: 'Edit' }))) : (content.contentTitle),
|
|
259
|
-
React.createElement("div", null, lastModifiedBy)
|
|
285
|
+
React.createElement("div", null, lastModifiedBy),
|
|
286
|
+
React.createElement("div", null, (content.tags || []).map((tag) => (React.createElement(Label, { isCompact: true, className: "pf-v5-u-mr-xs pf-v5-u-mt-sm", key: tag.id }, tag.tagName)))))),
|
|
260
287
|
(!isPreview || content.mode === ContentMode.ADD || content.mode === ContentMode.NEW_SECTION_CONTENT) && (React.createElement("form", { noValidate: true, onSubmit: onSubmit, className: "card card-light push-bottom" },
|
|
261
288
|
content.mode === ContentMode.NEW_SECTION_CONTENT && (React.createElement(AddNewCategoryDropDown, { onCategoryChange: onAddedNewCategoryChange })),
|
|
262
289
|
React.createElement("div", { className: "form-group" },
|
|
@@ -282,6 +309,11 @@ export const TopContentSingleItem = ({ isArrangingContent, category, snapshot, i
|
|
|
282
309
|
" Duplicate url. This url is already added in ",
|
|
283
310
|
formatDuplicateWarning(duplicatUrlErrorArray),
|
|
284
311
|
"."))),
|
|
312
|
+
React.createElement(Flex, { className: "pf-v5-u-my-lg" },
|
|
313
|
+
React.createElement(FlexItem, { flex: { default: 'flex_1' } },
|
|
314
|
+
React.createElement(FormGroup, { label: t('Tags') },
|
|
315
|
+
React.createElement("div", { className: "pf-v5-c-form-control" },
|
|
316
|
+
React.createElement(TagsSelector, { tagOptions: tagOptions, onChange: handleLocalTagChange, selectedTags: localSelectedTags }))))),
|
|
285
317
|
React.createElement("span", { className: "top-content-single-item-footer" },
|
|
286
318
|
React.createElement("span", null,
|
|
287
319
|
React.createElement(Button, { variant: "primary", onClick: onSave, isDisabled: isSaveButtonDisabled || isSaving, isLoading: isSaving },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TopContentEditor.d.ts","sourceRoot":"","sources":["../../../../../src/components/TopContentManagement/TopContentEditor/TopContentEditor.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TopContentEditor.d.ts","sourceRoot":"","sources":["../../../../../src/components/TopContentManagement/TopContentEditor/TopContentEditor.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAA2D,MAAM,OAAO,CAAC;AA+BhF,wBAAgB,gBAAgB,sBA4V/B"}
|
|
@@ -8,14 +8,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { Accordion, Alert, AlertVariant, Bullseye, Button, EmptyState, EmptyStateVariant, Spinner, Tooltip, } from '@patternfly/react-core';
|
|
11
|
-
import { ToastNotification, TopContentSearch } from '@rh-support/components';
|
|
11
|
+
import { TagsSelector, ToastNotification, TopContentSearch } from '@rh-support/components';
|
|
12
12
|
import { getVersion, isRegularVersion } from '@rh-support/utils';
|
|
13
13
|
import isEmpty from 'lodash/isEmpty';
|
|
14
|
-
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
14
|
+
import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
15
15
|
import { DragDropContext, Draggable, Droppable } from 'react-beautiful-dnd';
|
|
16
16
|
import { Trans, useTranslation } from 'react-i18next';
|
|
17
17
|
import { CATEGORY_LIMIT } from '../../../constants/TopContent';
|
|
18
|
+
import { TagManagementDispatchContext, TagManagementStateContext } from '../../../context/TagManagementContextProvider';
|
|
18
19
|
import { useTopContentContext, useTopContentDispatchContext } from '../../../context/TopContentProvider';
|
|
20
|
+
import { fetchTopContentTags } from '../../../reducers/TagManagmentReducer';
|
|
19
21
|
import { flagContentUsage, isMajorOrNamedVersion } from '../../../reducers/TopContentHelpers';
|
|
20
22
|
import { CategoryMode, fetchTopContent, reArrangeCategory, resetChangeInCategory, resetContentWithSelectedProduct, resetDuplicatUrls, setAddNewSection, setIsAddingCategory, setIsSearchModeEnabled, setTopContentArrangingCategory, setTopContentArrangingContent, } from '../../../reducers/TopContentReducer';
|
|
21
23
|
import CategoryLimit from '../CategoryLimit/CategoryLimit';
|
|
@@ -33,10 +35,13 @@ export function TopContentEditor() {
|
|
|
33
35
|
const [newCategoryVersion, setNewCategoryVersion] = useState(undefined);
|
|
34
36
|
const [searchQuery, setSearchQuery] = useState('');
|
|
35
37
|
const topContentResultsRef = useRef(null);
|
|
38
|
+
const [filteredTags, setFilteredTags] = useState([]);
|
|
36
39
|
const { topContentResponse, topContentEditState, isAddingCategory, isCatOnlyForMajorVersion, isSearchModeEnabled, selectedProduct, selectedVersion, categoryUsage, } = useTopContentContext();
|
|
40
|
+
const { tags } = useContext(TagManagementStateContext);
|
|
37
41
|
const topContentDispatch = useTopContentDispatchContext();
|
|
42
|
+
const tagManagerDispatch = useContext(TagManagementDispatchContext);
|
|
38
43
|
const flagContentEditState = useMemo(() => flagContentUsage(topContentEditState, categoryUsage, selectedVersion), [topContentEditState, categoryUsage, selectedVersion]);
|
|
39
|
-
const [
|
|
44
|
+
const [filteredByQueryTC, setFilteredByQueryTC] = useState(flagContentEditState);
|
|
40
45
|
const onProductChange = (selectedProduct) => {
|
|
41
46
|
resetContentWithSelectedProduct(topContentDispatch, selectedProduct);
|
|
42
47
|
};
|
|
@@ -48,10 +53,27 @@ export function TopContentEditor() {
|
|
|
48
53
|
return;
|
|
49
54
|
fetchTopContent(topContentDispatch, selectedProduct, selectedVersion);
|
|
50
55
|
};
|
|
56
|
+
const filteredTC = useMemo(() => {
|
|
57
|
+
if (isEmpty(filteredTags))
|
|
58
|
+
return filteredByQueryTC;
|
|
59
|
+
const filteredTagsIds = filteredTags.map((tag) => tag.id);
|
|
60
|
+
//filter top contents on basis of tags
|
|
61
|
+
const filteredData = filteredByQueryTC.flatMap((item) => {
|
|
62
|
+
const contents = item.content.filter((content) => (content.tags || []).some((tag) => filteredTagsIds.includes(tag.id)));
|
|
63
|
+
if (!isEmpty(contents))
|
|
64
|
+
return [Object.assign(Object.assign({}, item), { content: contents })];
|
|
65
|
+
return [];
|
|
66
|
+
});
|
|
67
|
+
return filteredData;
|
|
68
|
+
}, [filteredByQueryTC, filteredTags]);
|
|
51
69
|
useEffect(() => {
|
|
52
|
-
!isSearchModeEnabled &&
|
|
70
|
+
!isSearchModeEnabled && setFilteredByQueryTC(flagContentEditState);
|
|
53
71
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
54
72
|
}, [flagContentEditState]);
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
fetchTopContentTags(tagManagerDispatch);
|
|
75
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
76
|
+
}, []);
|
|
55
77
|
const onAddCategory = (isMajorVersionOnly, isCreatingNewSet = false, version, hasMajorContentCreatingMinorContent) => {
|
|
56
78
|
hasMajorContentCreatingMinorContent && resetDuplicatUrls(topContentDispatch);
|
|
57
79
|
setCategoryToOpen(null);
|
|
@@ -97,7 +119,8 @@ export function TopContentEditor() {
|
|
|
97
119
|
!isAddingCategory &&
|
|
98
120
|
selectedVersion &&
|
|
99
121
|
flagContentEditState.length !== 0 &&
|
|
100
|
-
!isSearchModeEnabled
|
|
122
|
+
!isSearchModeEnabled &&
|
|
123
|
+
isEmpty(filteredTags);
|
|
101
124
|
const isContentOnlyForMajorVersion = !topContentResponse.isFetching &&
|
|
102
125
|
flagContentEditState.length !== 0 &&
|
|
103
126
|
isRegularVersion(selectedVersion) &&
|
|
@@ -105,7 +128,7 @@ export function TopContentEditor() {
|
|
|
105
128
|
!isAddingCategory;
|
|
106
129
|
const onSearch = (searchTerm, searchResults) => {
|
|
107
130
|
setIsSearchModeEnabled(topContentDispatch, searchTerm ? true : false);
|
|
108
|
-
|
|
131
|
+
setFilteredByQueryTC(searchResults);
|
|
109
132
|
};
|
|
110
133
|
const minorSelectedNoMinorContentButAvailableMajorContent = isContentOnlyForMajorVersion && getVersion(selectedVersion).minor && flagContentEditState.length !== 0;
|
|
111
134
|
const isCategoryLimitReached = filteredTC.length >= CATEGORY_LIMIT.MAX;
|
|
@@ -113,9 +136,14 @@ export function TopContentEditor() {
|
|
|
113
136
|
React.createElement(TopContentHeader, null),
|
|
114
137
|
!topContentResponse.isFetching && topContentResponse.isError && (React.createElement(Alert, { isInline: true, variant: AlertVariant.danger, title: React.createElement(Trans, null, "Error loading Top Content") })),
|
|
115
138
|
React.createElement(TopContentProductVersionSelector, { selectedProduct: selectedProduct, selectedVersion: selectedVersion, onProductChange: onProductChange, onVersionChange: onVersionChange }),
|
|
116
|
-
!topContentResponse.isFetching && (React.createElement(
|
|
139
|
+
!topContentResponse.isFetching && (React.createElement("div", { className: "toolbar" },
|
|
140
|
+
React.createElement(TopContentSearch, { dataTrackingId: "top-content-filter-manage", topContentData: flagContentEditState, onSearch: onSearch, topContentResultsWrapperRef: topContentResultsRef, searchQuery: searchQuery, setSearchQuery: setSearchQuery, className: "toolbar-content" }),
|
|
141
|
+
React.createElement("div", { className: "toolbar-content pf-v5-u-ml-md" },
|
|
142
|
+
React.createElement("label", { htmlFor: 'tag-selector' },
|
|
143
|
+
React.createElement(Trans, null, "All tags")),
|
|
144
|
+
React.createElement(TagsSelector, { tagOptions: tags, onChange: setFilteredTags, selectedTags: filteredTags })))),
|
|
117
145
|
React.createElement("div", { className: "top-content-manage-wrapper pf-v5-u-pt-md" },
|
|
118
|
-
!topContentResponse.isFetching &&
|
|
146
|
+
!topContentResponse.isFetching && React.createElement(TopContentSuggestion, { searchQuery: searchQuery }),
|
|
119
147
|
topContentResponse.isFetching ? (React.createElement(Bullseye, null,
|
|
120
148
|
React.createElement(EmptyState, { variant: EmptyStateVariant.full },
|
|
121
149
|
React.createElement(Spinner, { size: "lg" })))) : (!topContentResponse.isFetching &&
|
|
@@ -131,7 +159,8 @@ export function TopContentEditor() {
|
|
|
131
159
|
category.catMode === CategoryMode.EXISTING_SECTION && (React.createElement(Draggable, { draggableId: `c${category.id}`, index: i, isDragDisabled: !isArrangingCats, key: `c-${i}-${category.id}` }, (provided, snapshot) => category.helperText ? (React.createElement(Tooltip, { content: React.createElement("div", null, category.helperText) },
|
|
132
160
|
React.createElement(TopContentCategory, { isExpanded: isSearchModeEnabled
|
|
133
161
|
? true
|
|
134
|
-
: category.id === categoryToOpen, category: category, provided: provided, innerRef: provided.innerRef, isArrangingCats: isArrangingCats, snapshot: snapshot }))) : (React.createElement(TopContentCategory, { isExpanded: isSearchModeEnabled
|
|
162
|
+
: category.id === categoryToOpen, category: category, provided: provided, innerRef: provided.innerRef, isArrangingCats: isArrangingCats, snapshot: snapshot }))) : (React.createElement(TopContentCategory, { isExpanded: isSearchModeEnabled ||
|
|
163
|
+
!isEmpty(filteredTags)
|
|
135
164
|
? true
|
|
136
165
|
: category.id === categoryToOpen, category: category, provided: provided, innerRef: provided.innerRef, isArrangingCats: isArrangingCats, snapshot: snapshot })))),
|
|
137
166
|
category.catMode === CategoryMode.NEW_SECTION && (React.createElement(TopContentCategoryNew, { category: category, key: 'new-section', version: newCategoryVersion }))))),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TopContentSuggestion.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestion.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TopContentSuggestion.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestion.tsx"],"names":[],"mappings":"AAIA,OAAc,EAAE,EAAE,EAAwC,MAAM,OAAO,CAAC;AAWxE,UAAU,MAAM;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,eAAO,MAAM,oBAAoB,EAAE,EAAE,CAAC,MAAM,CA8E3C,CAAC"}
|
|
@@ -1,30 +1,55 @@
|
|
|
1
1
|
import { ExpandableSection, Panel, PanelMain, PanelMainBody, Title } from '@patternfly/react-core';
|
|
2
|
+
import { useSearchDocument } from '@rh-support/components';
|
|
2
3
|
import isEmpty from 'lodash/isEmpty';
|
|
3
|
-
import
|
|
4
|
+
import Mark from 'mark.js';
|
|
5
|
+
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
4
6
|
import { Trans } from 'react-i18next';
|
|
5
7
|
import { useTopContentContext, useTopContentDispatchContext } from '../../../../context/TopContentProvider';
|
|
6
|
-
import { fetchTopContentSuggestions } from '../../../../reducers/TopContentReducer';
|
|
8
|
+
import { fetchTopContentSuggestions, } from '../../../../reducers/TopContentReducer';
|
|
7
9
|
import { TopContentSuggestionHint } from './TopContentSuggestionHint';
|
|
8
|
-
export const TopContentSuggestion = () => {
|
|
9
|
-
var _a;
|
|
10
|
+
export const TopContentSuggestion = ({ searchQuery = '' }) => {
|
|
10
11
|
const [isExpanded, setExpanded] = useState(false);
|
|
12
|
+
const ref = useRef(null);
|
|
11
13
|
const onToggle = () => setExpanded((previousExpandedState) => !previousExpandedState);
|
|
12
14
|
const { selectedProduct, selectedVersion, suggestion, topContentResponse } = useTopContentContext();
|
|
13
15
|
const topContentDispatch = useTopContentDispatchContext();
|
|
14
|
-
const topContent = topContentResponse.data.reduce((ret, category) => {
|
|
16
|
+
const topContent = useMemo(() => topContentResponse.data.reduce((ret, category) => {
|
|
15
17
|
return [...ret, ...category.content];
|
|
16
|
-
}, []);
|
|
17
|
-
const filteredSuggestion = (
|
|
18
|
+
}, []), [topContentResponse.data]);
|
|
19
|
+
const filteredSuggestion = useMemo(() => {
|
|
20
|
+
var _a;
|
|
21
|
+
return (_a = suggestion.linkedResources) === null || _a === void 0 ? void 0 : _a.filter((resource) => !topContent.some((content) => content.contentUrl === resource.resourceViewUri));
|
|
22
|
+
}, [suggestion.linkedResources, topContent]);
|
|
18
23
|
useEffect(() => {
|
|
19
24
|
if ((selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.name) && selectedVersion) {
|
|
20
25
|
fetchTopContentSuggestions(topContentDispatch, selectedProduct.name, selectedVersion);
|
|
21
26
|
}
|
|
22
27
|
}, [topContentDispatch, selectedProduct, selectedVersion]);
|
|
23
|
-
|
|
28
|
+
const searchedContent = useSearchDocument(filteredSuggestion || [], searchQuery, {
|
|
29
|
+
indexKey: 'id',
|
|
30
|
+
strategy: (doc) => doc.resourceTitle,
|
|
31
|
+
});
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
var _a;
|
|
34
|
+
if (ref.current == null)
|
|
35
|
+
return;
|
|
36
|
+
setExpanded(!isEmpty(searchQuery));
|
|
37
|
+
const containers = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll('div.pf-v5-c-card');
|
|
38
|
+
const markInstance = new Mark(containers);
|
|
39
|
+
markInstance.unmark({
|
|
40
|
+
done: () => {
|
|
41
|
+
if (isEmpty(searchQuery))
|
|
42
|
+
return;
|
|
43
|
+
markInstance.mark(searchQuery, { separateWordSearch: true });
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
}, [searchedContent, searchQuery]);
|
|
47
|
+
if (isEmpty(searchedContent))
|
|
24
48
|
return React.createElement(React.Fragment, null);
|
|
25
|
-
return (React.createElement(Panel, { variant: "raised", className: "pf-v5-u-mx-md pf-v5-u-p-md top-content-panel" },
|
|
49
|
+
return (React.createElement(Panel, { variant: "raised", className: "pf-v5-u-mx-md pf-v5-u-p-md top-content-panel", ref: ref },
|
|
26
50
|
React.createElement(PanelMain, null,
|
|
27
51
|
React.createElement(PanelMainBody, null,
|
|
28
52
|
React.createElement(ExpandableSection, { onToggle: onToggle, isExpanded: isExpanded, toggleContent: React.createElement(Title, { headingLevel: "h6", className: "accordion_title" },
|
|
29
|
-
React.createElement(Trans, null, " Suggested top content resources")), id: "top-content-suggestion" },
|
|
53
|
+
React.createElement(Trans, null, " Suggested top content resources")), id: "top-content-suggestion" }, !isEmpty(searchedContent) &&
|
|
54
|
+
(searchedContent === null || searchedContent === void 0 ? void 0 : searchedContent.map((resources) => (React.createElement(TopContentSuggestionHint, { key: resources.id, resources: resources })))))))));
|
|
30
55
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TopContentManagement.d.ts","sourceRoot":"","sources":["../../../../src/components/TopContentManagement/TopContentManagement.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"TopContentManagement.d.ts","sourceRoot":"","sources":["../../../../src/components/TopContentManagement/TopContentManagement.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,UAAU,MAAM;CAAG;AAEnB,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,qBAYjD"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { ErrorBoundary } from '@rh-support/components';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import { TagManagementContextProvider } from '../../context/TagManagementContextProvider';
|
|
4
5
|
import { TopContentContextProvider } from '../../context/TopContentProvider';
|
|
5
6
|
import { TopContentEditor } from './TopContentEditor/TopContentEditor';
|
|
6
7
|
export function TopContentManagement(props) {
|
|
7
8
|
const { t } = useTranslation();
|
|
8
|
-
return (React.createElement(
|
|
9
|
-
React.createElement(
|
|
10
|
-
React.createElement(
|
|
9
|
+
return (React.createElement(ErrorBoundary, { errorMsgInfo: { message: t('There was an error loading suggestions') } },
|
|
10
|
+
React.createElement(TopContentContextProvider, null,
|
|
11
|
+
React.createElement(TagManagementContextProvider, null,
|
|
11
12
|
React.createElement(TopContentEditor, null)))));
|
|
12
13
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ITagManagementState, TagManagementDisptachType } from '../reducers/TagManagmentReducer';
|
|
3
|
+
export declare const TagManagementStateContext: React.Context<ITagManagementState>;
|
|
4
|
+
export declare const TagManagementDispatchContext: React.Context<TagManagementDisptachType>;
|
|
5
|
+
export declare function TagManagementContextProvider({ children }: {
|
|
6
|
+
children: any;
|
|
7
|
+
}): React.JSX.Element;
|
|
8
|
+
//# sourceMappingURL=TagManagementContextProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TagManagementContextProvider.d.ts","sourceRoot":"","sources":["../../../src/context/TagManagementContextProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,OAAO,EAEH,mBAAmB,EACnB,yBAAyB,EAE5B,MAAM,iCAAiC,CAAC;AAGzC,eAAO,MAAM,yBAAyB,oCAAsE,CAAC;AAC7G,eAAO,MAAM,4BAA4B,0CAA8C,CAAC;AAExF,wBAAgB,4BAA4B,CAAC,EAAE,QAAQ,EAAE;;CAAA,qBAOxD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React, { useReducer } from 'react';
|
|
2
|
+
import { initialTagManagementState, TagManagementReducer, } from '../reducers/TagManagmentReducer';
|
|
3
|
+
const initialDispatchContext = null;
|
|
4
|
+
export const TagManagementStateContext = React.createContext(initialTagManagementState);
|
|
5
|
+
export const TagManagementDispatchContext = React.createContext(initialDispatchContext);
|
|
6
|
+
export function TagManagementContextProvider({ children }) {
|
|
7
|
+
const [tagManagementState, dispatch] = useReducer(TagManagementReducer, initialTagManagementState);
|
|
8
|
+
return (React.createElement(TagManagementStateContext.Provider, { value: Object.assign({}, tagManagementState) },
|
|
9
|
+
React.createElement(TagManagementDispatchContext.Provider, { value: dispatch }, children)));
|
|
10
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ITag, ITagPostBody, ITagPutBody, ITopContentUpdateTagBodyItem } from '@cee-eng/hydrajs/@types/models/tagModels';
|
|
2
|
+
import { IAction, IApiResponseDetails } from '@rh-support/types/shared';
|
|
3
|
+
export declare enum TagManagementReducerConstants {
|
|
4
|
+
getAllTags = "getAllTags",
|
|
5
|
+
createNewTag = "createNewTag",
|
|
6
|
+
updateTag = "updateTag",
|
|
7
|
+
deleteTag = "deleteTag",
|
|
8
|
+
resetTags = "resetTags"
|
|
9
|
+
}
|
|
10
|
+
interface ITagItemState extends ITag {
|
|
11
|
+
numberOfLinkedContents?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface ITagManagementState {
|
|
14
|
+
tagResponse: IApiResponseDetails<ITag[]>;
|
|
15
|
+
tags: ITagItemState[];
|
|
16
|
+
}
|
|
17
|
+
export declare const initialTagManagementState: ITagManagementState;
|
|
18
|
+
type IActionType = IAction<TagManagementReducerConstants, ITagManagementState>;
|
|
19
|
+
export type TagManagementDisptachType = (value: IActionType) => void;
|
|
20
|
+
export declare const TagManagementReducer: (state: ITagManagementState, action: IActionType) => ITagManagementState;
|
|
21
|
+
export declare const fetchTopContentTags: (dispatch: TagManagementDisptachType) => Promise<void>;
|
|
22
|
+
export declare const createNewTags: (dispatch: TagManagementDisptachType, tags: ITagPostBody[]) => Promise<void>;
|
|
23
|
+
export declare const updateTag: (dispatch: TagManagementDisptachType, tag: ITagPutBody, tagsState: ITagItemState[]) => Promise<void>;
|
|
24
|
+
export declare const deleteTag: (dispatch: TagManagementDisptachType, deletedTag: ITag, tagManagementState: ITagManagementState) => Promise<void>;
|
|
25
|
+
export declare const updateTopContentWithTags: (dispatch: TagManagementDisptachType, content: ITopContentUpdateTagBodyItem, tagManagementState: ITagManagementState) => Promise<void>;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=TagManagmentReducer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TagManagmentReducer.d.ts","sourceRoot":"","sources":["../../../src/reducers/TagManagmentReducer.ts"],"names":[],"mappings":"AACA,OAAO,EACH,IAAI,EACJ,YAAY,EACZ,WAAW,EACX,4BAA4B,EAC/B,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAGxE,oBAAY,6BAA6B;IACrC,UAAU,eAAe;IACzB,YAAY,iBAAiB;IAC7B,SAAS,cAAc;IACvB,SAAS,cAAc;IACvB,SAAS,cAAc;CAC1B;AAED,UAAU,aAAc,SAAQ,IAAI;IAChC,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACnC;AACD,MAAM,WAAW,mBAAmB;IAChC,WAAW,EAAE,mBAAmB,CAAC,IAAI,EAAE,CAAC,CAAC;IACzC,IAAI,EAAE,aAAa,EAAE,CAAC;CACzB;AAED,eAAO,MAAM,yBAAyB,EAAE,mBAGvC,CAAC;AAEF,KAAK,WAAW,GAAG,OAAO,CAAC,6BAA6B,EAAE,mBAAmB,CAAC,CAAC;AAC/E,MAAM,MAAM,yBAAyB,GAAG,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;AAErE,eAAO,MAAM,oBAAoB,UAAW,mBAAmB,0BAAwB,mBAsBtF,CAAC;AAEF,eAAO,MAAM,mBAAmB,aAAoB,yBAAyB,kBAuC5E,CAAC;AAEF,eAAO,MAAM,aAAa,aAAoB,yBAAyB,QAAQ,YAAY,EAAE,kBAU5F,CAAC;AAEF,eAAO,MAAM,SAAS,aAAoB,yBAAyB,OAAO,WAAW,aAAa,aAAa,EAAE,kBAYhH,CAAC;AAEF,eAAO,MAAM,SAAS,aACR,yBAAyB,cACvB,IAAI,sBACI,mBAAmB,kBAc1C,CAAC;AAEF,eAAO,MAAM,wBAAwB,aACvB,yBAAyB,WAC1B,4BAA4B,sBACjB,mBAAmB,kBAO1C,CAAC"}
|
|
@@ -0,0 +1,127 @@
|
|
|
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 { pcm } from '@cee-eng/hydrajs';
|
|
11
|
+
import { getApiResourceObject } from '@rh-support/utils';
|
|
12
|
+
export var TagManagementReducerConstants;
|
|
13
|
+
(function (TagManagementReducerConstants) {
|
|
14
|
+
TagManagementReducerConstants["getAllTags"] = "getAllTags";
|
|
15
|
+
TagManagementReducerConstants["createNewTag"] = "createNewTag";
|
|
16
|
+
TagManagementReducerConstants["updateTag"] = "updateTag";
|
|
17
|
+
TagManagementReducerConstants["deleteTag"] = "deleteTag";
|
|
18
|
+
TagManagementReducerConstants["resetTags"] = "resetTags";
|
|
19
|
+
})(TagManagementReducerConstants || (TagManagementReducerConstants = {}));
|
|
20
|
+
export const initialTagManagementState = {
|
|
21
|
+
tagResponse: getApiResourceObject([]),
|
|
22
|
+
tags: [],
|
|
23
|
+
};
|
|
24
|
+
export const TagManagementReducer = (state, action) => {
|
|
25
|
+
var _a, _b, _c, _d, _e;
|
|
26
|
+
switch (action.type) {
|
|
27
|
+
case TagManagementReducerConstants.resetTags: {
|
|
28
|
+
return initialTagManagementState;
|
|
29
|
+
}
|
|
30
|
+
case TagManagementReducerConstants.getAllTags: {
|
|
31
|
+
return Object.assign(Object.assign({}, state), { tagResponse: (_a = action === null || action === void 0 ? void 0 : action.payload) === null || _a === void 0 ? void 0 : _a.tagResponse, tags: (_b = action === null || action === void 0 ? void 0 : action.payload) === null || _b === void 0 ? void 0 : _b.tags });
|
|
32
|
+
}
|
|
33
|
+
case TagManagementReducerConstants.createNewTag: {
|
|
34
|
+
return Object.assign(Object.assign({}, state), { tags: [...state.tags, ...(_c = action === null || action === void 0 ? void 0 : action.payload) === null || _c === void 0 ? void 0 : _c.tags], tagResponse: getApiResourceObject([...state.tags, ...(_d = action === null || action === void 0 ? void 0 : action.payload) === null || _d === void 0 ? void 0 : _d.tags]) });
|
|
35
|
+
}
|
|
36
|
+
case TagManagementReducerConstants.updateTag: {
|
|
37
|
+
return Object.assign(Object.assign({}, state), { tags: (_e = action === null || action === void 0 ? void 0 : action.payload) === null || _e === void 0 ? void 0 : _e.tags });
|
|
38
|
+
}
|
|
39
|
+
default: {
|
|
40
|
+
return state;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
export const fetchTopContentTags = (dispatch) => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
+
try {
|
|
46
|
+
dispatch({
|
|
47
|
+
type: TagManagementReducerConstants.getAllTags,
|
|
48
|
+
payload: {
|
|
49
|
+
tagResponse: getApiResourceObject([], true),
|
|
50
|
+
tags: [],
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
const [tagsResponse, tagsWithLinkedContentCount] = yield Promise.all([
|
|
54
|
+
pcm.topContentTag.getTopContentTags({}),
|
|
55
|
+
pcm.topContentTag.getAllLinkedTags(),
|
|
56
|
+
]);
|
|
57
|
+
const tags = tagsResponse.map((tag) => {
|
|
58
|
+
const contentCount = tagsWithLinkedContentCount.find((t) => t.tagId === tag.id);
|
|
59
|
+
return Object.assign(Object.assign({}, tag), { numberOfLinkedContents: contentCount ? contentCount.numberOfLinkedContents : 0 });
|
|
60
|
+
});
|
|
61
|
+
dispatch({
|
|
62
|
+
type: TagManagementReducerConstants.getAllTags,
|
|
63
|
+
payload: {
|
|
64
|
+
tagResponse: getApiResourceObject(tags, false),
|
|
65
|
+
tags,
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
dispatch({
|
|
71
|
+
type: TagManagementReducerConstants.getAllTags,
|
|
72
|
+
payload: {
|
|
73
|
+
tagResponse: getApiResourceObject([], false, true, err.message),
|
|
74
|
+
tags: [],
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
export const createNewTags = (dispatch, tags) => __awaiter(void 0, void 0, void 0, function* () {
|
|
80
|
+
try {
|
|
81
|
+
const response = yield pcm.topContentTag.postTopContentTags(tags);
|
|
82
|
+
dispatch({
|
|
83
|
+
type: TagManagementReducerConstants.createNewTag,
|
|
84
|
+
payload: { tags: response.tags },
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
dispatch({ type: TagManagementReducerConstants.createNewTag, payload: { tags: [] } });
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
export const updateTag = (dispatch, tag, tagsState) => __awaiter(void 0, void 0, void 0, function* () {
|
|
92
|
+
try {
|
|
93
|
+
const { tags: editedTags } = yield pcm.topContentTag.patchTopContentTag([tag]);
|
|
94
|
+
const updatedTag = editedTags[0];
|
|
95
|
+
const updatedTagsState = tagsState.map((tag) => (tag.id === updatedTag.id ? Object.assign(Object.assign({}, tag), updatedTag) : tag));
|
|
96
|
+
dispatch({
|
|
97
|
+
type: TagManagementReducerConstants.updateTag,
|
|
98
|
+
payload: { tags: updatedTagsState, tagResponse: getApiResourceObject(updatedTagsState) },
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
catch (err) {
|
|
102
|
+
console.log(err);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
export const deleteTag = (dispatch, deletedTag, tagManagementState) => __awaiter(void 0, void 0, void 0, function* () {
|
|
106
|
+
try {
|
|
107
|
+
yield pcm.topContentTag.deleteTopContentTag(deletedTag.id);
|
|
108
|
+
const updatedTags = tagManagementState.tags.filter((t) => t.id !== deletedTag.id);
|
|
109
|
+
dispatch({
|
|
110
|
+
type: TagManagementReducerConstants.updateTag,
|
|
111
|
+
payload: {
|
|
112
|
+
tags: updatedTags,
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
catch (err) {
|
|
117
|
+
console.log(err);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
export const updateTopContentWithTags = (dispatch, content, tagManagementState) => __awaiter(void 0, void 0, void 0, function* () {
|
|
121
|
+
try {
|
|
122
|
+
yield pcm.topContentTag.updateTagsOfTopContent({ topContents: [content] });
|
|
123
|
+
}
|
|
124
|
+
catch (err) {
|
|
125
|
+
console.log(err);
|
|
126
|
+
}
|
|
127
|
+
});
|