@rh-support/manage 2.1.94 → 2.1.96
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/ManageTabs.d.ts.map +1 -1
- package/lib/esm/ManageTabs.js +11 -1
- package/lib/esm/Routes.d.ts +1 -0
- package/lib/esm/Routes.d.ts.map +1 -1
- package/lib/esm/Routes.js +6 -0
- package/lib/esm/components/ManageBookmarkedAccountsTab/BookmarkAccountSelector.d.ts.map +1 -1
- package/lib/esm/components/ManageBookmarkedAccountsTab/BookmarkAccountSelector.js +6 -1
- package/lib/esm/components/ManageExpiredContents/ExpiredContentCategory.d.ts +9 -0
- package/lib/esm/components/ManageExpiredContents/ExpiredContentCategory.d.ts.map +1 -0
- package/lib/esm/components/ManageExpiredContents/ExpiredContentCategory.js +18 -0
- package/lib/esm/components/ManageExpiredContents/ExpiredContentHeader.d.ts +3 -0
- package/lib/esm/components/ManageExpiredContents/ExpiredContentHeader.d.ts.map +1 -0
- package/lib/esm/components/ManageExpiredContents/ExpiredContentHeader.js +9 -0
- package/lib/esm/components/ManageExpiredContents/ExpiredContentManagement.d.ts +3 -0
- package/lib/esm/components/ManageExpiredContents/ExpiredContentManagement.d.ts.map +1 -0
- package/lib/esm/components/ManageExpiredContents/ExpiredContentManagement.js +13 -0
- package/lib/esm/components/ManageExpiredContents/ExpiredContentManager.d.ts +3 -0
- package/lib/esm/components/ManageExpiredContents/ExpiredContentManager.d.ts.map +1 -0
- package/lib/esm/components/ManageExpiredContents/ExpiredContentManager.js +70 -0
- package/lib/esm/components/ManageExpiredContents/ExpiredContentSingleItem.d.ts +9 -0
- package/lib/esm/components/ManageExpiredContents/ExpiredContentSingleItem.d.ts.map +1 -0
- package/lib/esm/components/ManageExpiredContents/ExpiredContentSingleItem.js +77 -0
- package/lib/esm/components/ManageExpiredContents/ExpiredContentSingleItemView.d.ts +14 -0
- package/lib/esm/components/ManageExpiredContents/ExpiredContentSingleItemView.d.ts.map +1 -0
- package/lib/esm/components/ManageExpiredContents/ExpiredContentSingleItemView.js +141 -0
- package/lib/esm/components/ManageExpiredContents/index.d.ts +2 -0
- package/lib/esm/components/ManageExpiredContents/index.d.ts.map +1 -0
- package/lib/esm/components/ManageExpiredContents/index.js +1 -0
- package/lib/esm/components/ManageTags/TagsManager.d.ts.map +1 -1
- package/lib/esm/components/ManageTags/TagsManager.js +20 -7
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/TopContentSingleItem.d.ts +2 -0
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/TopContentSingleItem.d.ts.map +1 -1
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/TopContentSingleItem.js +75 -20
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentEditor.d.ts.map +1 -1
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentEditor.js +7 -5
- package/lib/esm/context/ExpiredContentContextProvider.d.ts +8 -0
- package/lib/esm/context/ExpiredContentContextProvider.d.ts.map +1 -0
- package/lib/esm/context/ExpiredContentContextProvider.js +10 -0
- package/lib/esm/context/TopContentProvider.d.ts.map +1 -1
- package/lib/esm/context/TopContentProvider.js +1 -0
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.d.ts.map +1 -1
- package/lib/esm/index.js +1 -0
- package/lib/esm/reducers/ExpiredContentReducer.d.ts +35 -0
- package/lib/esm/reducers/ExpiredContentReducer.d.ts.map +1 -0
- package/lib/esm/reducers/ExpiredContentReducer.js +190 -0
- package/lib/esm/reducers/TopContentReducer.d.ts +5 -1
- package/lib/esm/reducers/TopContentReducer.d.ts.map +1 -1
- package/lib/esm/reducers/TopContentReducer.js +23 -7
- package/package.json +8 -8
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ISolrArticle, ISolrSolution } from '@cee-eng/hydrajs/@types/models/solr/solr';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { DraggableStateSnapshot } from 'react-beautiful-dnd';
|
|
3
4
|
import { ITopContentEditState } from '../../../../reducers/TopContentReducer';
|
|
@@ -8,6 +9,7 @@ interface IProps {
|
|
|
8
9
|
i: number;
|
|
9
10
|
}
|
|
10
11
|
export declare function formatDuplicateWarning(arr: any): any;
|
|
12
|
+
export declare function getDocsFromUrl(url: string): Promise<(ISolrSolution | ISolrArticle)[]>;
|
|
11
13
|
export declare const TopContentSingleItem: ({ isArrangingContent, category, snapshot, i }: IProps) => React.JSX.Element;
|
|
12
14
|
export {};
|
|
13
15
|
//# 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,EAAE,YAAY,EAAiB,aAAa,EAAE,MAAM,0CAA0C,CAAC;AA8BtG,OAAO,KAAmD,MAAM,OAAO,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAM7D,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,wBAAsB,cAAc,CAAC,GAAG,EAAE,MAAM,6CA2B/C;AAED,eAAO,MAAM,oBAAoB,kDAAmD,MAAM,sBA+ezF,CAAC"}
|
|
@@ -8,12 +8,12 @@ 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, Flex, FlexItem, FormGroup, Icon, Label, TextInput, ValidatedOptions } from '@patternfly/react-core';
|
|
11
|
+
import { Button, DatePicker, 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
15
|
import { TagsSelector, ToastNotification, useDebounce } from '@rh-support/components';
|
|
16
|
-
import { formatDate, getDrupalResIdIfTypeFromUrl, getText, isValidUrl } from '@rh-support/utils';
|
|
16
|
+
import { formatDate, getDrupalResIdIfTypeFromUrl, getText, isFutureDate, isValidDate, isValidUrl, } from '@rh-support/utils';
|
|
17
17
|
import { differenceBy, isEqual } from 'lodash';
|
|
18
18
|
import cloneDeep from 'lodash/cloneDeep';
|
|
19
19
|
import findIndex from 'lodash/findIndex';
|
|
@@ -37,7 +37,36 @@ export function formatDuplicateWarning(arr) {
|
|
|
37
37
|
return [...str, ' and ', arr.slice(-1)];
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
+
export function getDocsFromUrl(url) {
|
|
41
|
+
var _a;
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
try {
|
|
44
|
+
const nodeId = getDrupalResIdIfTypeFromUrl(url);
|
|
45
|
+
if (!nodeId)
|
|
46
|
+
return [];
|
|
47
|
+
const queryParam = {
|
|
48
|
+
q: '*:*',
|
|
49
|
+
start: 0,
|
|
50
|
+
rows: 1,
|
|
51
|
+
};
|
|
52
|
+
const expression = {
|
|
53
|
+
fq: ['documentKind:("Solution" OR "Article")', `id:${nodeId}`],
|
|
54
|
+
fl: 'id, allTitle, publishedTitle',
|
|
55
|
+
};
|
|
56
|
+
const response = yield search.solrSearchV2(queryParam, 'kcs', expression);
|
|
57
|
+
const docs = ((_a = response === null || response === void 0 ? void 0 : response.response) === null || _a === void 0 ? void 0 : _a.docs) || [];
|
|
58
|
+
if (docs.length == 0) {
|
|
59
|
+
throw new Error('');
|
|
60
|
+
}
|
|
61
|
+
return docs;
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
throw err;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
40
68
|
export const TopContentSingleItem = ({ isArrangingContent, category, snapshot, i }) => {
|
|
69
|
+
var _a, _b, _c;
|
|
41
70
|
const [isPreview, setIsPreview] = useState(true);
|
|
42
71
|
const [isFetchingSolrSearch, setIsFetchingSolrSearch] = useState(false);
|
|
43
72
|
const editToggle = () => {
|
|
@@ -45,13 +74,14 @@ export const TopContentSingleItem = ({ isArrangingContent, category, snapshot, i
|
|
|
45
74
|
};
|
|
46
75
|
const content = category.content && category.content[i];
|
|
47
76
|
const { t } = useTranslation();
|
|
48
|
-
const { topContentEditState, isCatOnlyForMajorVersion, selectedProduct, selectedVersion, contentUrls } = useTopContentContext();
|
|
77
|
+
const { topContentEditState, isCatOnlyForMajorVersion, selectedProduct, selectedVersion, contentUrls, filteredTags, } = useTopContentContext();
|
|
49
78
|
const tagManagementEditState = useContext(TagManagementStateContext);
|
|
50
79
|
const { tags: tagOptions } = tagManagementEditState;
|
|
51
80
|
const topContentDispatch = useTopContentDispatchContext();
|
|
52
81
|
const [localContentUrl, setLocalContentUrl] = useState(content.contentUrl);
|
|
53
82
|
const [localContentTitle, setLocalContentTitle] = useState(content.contentTitle);
|
|
54
83
|
const [localSelectedTags, setLocalSelectedTags] = useState(content.tags || []);
|
|
84
|
+
const [localExpiryDate, setLocalExpiryDate] = useState((content === null || content === void 0 ? void 0 : content.expiryDate) || '');
|
|
55
85
|
const [newCategory, setNewCategory] = useState(undefined);
|
|
56
86
|
const [contentTitleIsValid, setContentTitleIsValid] = useState(true);
|
|
57
87
|
const [contentUrlIsValid, setContentUrlIsValid] = useState(true);
|
|
@@ -71,7 +101,7 @@ export const TopContentSingleItem = ({ isArrangingContent, category, snapshot, i
|
|
|
71
101
|
setLocalSelectedTags(tags);
|
|
72
102
|
};
|
|
73
103
|
const updateContentTitleFromUrl = (contentUrl) => __awaiter(void 0, void 0, void 0, function* () {
|
|
74
|
-
var
|
|
104
|
+
var _d, _e;
|
|
75
105
|
// throws toast warning and clears it after 4 seconds
|
|
76
106
|
const throwWarningMessage = () => {
|
|
77
107
|
const message = getText('Unable to automatically fetch title. Please enter manually');
|
|
@@ -81,18 +111,8 @@ export const TopContentSingleItem = ({ isArrangingContent, category, snapshot, i
|
|
|
81
111
|
const nodeId = getDrupalResIdIfTypeFromUrl(contentUrl);
|
|
82
112
|
if (!nodeId)
|
|
83
113
|
return;
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
start: 0,
|
|
87
|
-
rows: 1,
|
|
88
|
-
};
|
|
89
|
-
const expression = {
|
|
90
|
-
fq: ['documentKind:("Solution" OR "Article")', `id:${nodeId}`],
|
|
91
|
-
fl: 'id, allTitle, publishedTitle',
|
|
92
|
-
};
|
|
93
|
-
const response = yield search.solrSearchV2(queryParam, 'kcs', expression);
|
|
94
|
-
const docs = ((_a = response === null || response === void 0 ? void 0 : response.response) === null || _a === void 0 ? void 0 : _a.docs) || [];
|
|
95
|
-
const contentTitle = ((_b = docs[0]) === null || _b === void 0 ? void 0 : _b.publishedTitle) || ((_c = docs[0]) === null || _c === void 0 ? void 0 : _c.allTitle);
|
|
114
|
+
const docs = yield getDocsFromUrl(contentUrl);
|
|
115
|
+
const contentTitle = ((_d = docs[0]) === null || _d === void 0 ? void 0 : _d.publishedTitle) || ((_e = docs[0]) === null || _e === void 0 ? void 0 : _e.allTitle);
|
|
96
116
|
if (docs.length > 0 && docs[0].id === nodeId + '' && contentTitle) {
|
|
97
117
|
setLocalContentTitle(contentTitle);
|
|
98
118
|
setContentTitleIsValid(true);
|
|
@@ -158,6 +178,9 @@ export const TopContentSingleItem = ({ isArrangingContent, category, snapshot, i
|
|
|
158
178
|
const onSaveAddContentToCategory = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
159
179
|
try {
|
|
160
180
|
const newContent = Object.assign(Object.assign({}, content), { contentTitle: localContentTitle, contentUrl: localContentUrl, tagList: localSelectedTags.map((t) => t.id), tags: localSelectedTags.map((t) => ({ id: t.id, tagName: t.tagName })) });
|
|
181
|
+
if (!isEmpty(localExpiryDate)) {
|
|
182
|
+
newContent.expiryDate = localExpiryDate;
|
|
183
|
+
}
|
|
161
184
|
setIsSaving(true);
|
|
162
185
|
yield saveAddToTopContent(topContentDispatch, topContentEditState, category.id, category.categoryId, newContent, i);
|
|
163
186
|
ToastNotification.addSuccessMessage(t('Content added successfully'));
|
|
@@ -175,6 +198,9 @@ export const TopContentSingleItem = ({ isArrangingContent, category, snapshot, i
|
|
|
175
198
|
const deletedTags = differenceBy(oldTagsIds, localTagsIds);
|
|
176
199
|
try {
|
|
177
200
|
const updatedContent = Object.assign(Object.assign({}, content), { contentTitle: localContentTitle, contentUrl: localContentUrl, tagList: newTags, tags: localSelectedTags.map((t) => ({ id: t.id, tagName: t.tagName })) });
|
|
201
|
+
if (!isEmpty(localExpiryDate)) {
|
|
202
|
+
updatedContent.expiryDate = localExpiryDate;
|
|
203
|
+
}
|
|
178
204
|
setIsSaving(true);
|
|
179
205
|
yield saveChangeInCategoryContent(topContentDispatch, topContentEditState, category.categoryId, updatedContent, deletedTags);
|
|
180
206
|
editToggle();
|
|
@@ -190,6 +216,9 @@ export const TopContentSingleItem = ({ isArrangingContent, category, snapshot, i
|
|
|
190
216
|
const onSaveCreateNewCategory = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
191
217
|
try {
|
|
192
218
|
const newContent = Object.assign(Object.assign({}, content), { contentTitle: localContentTitle, contentUrl: localContentUrl, tagList: localSelectedTags.map((t) => t.id), tags: localSelectedTags.map((t) => ({ id: t.id, tagName: t.tagName })) });
|
|
219
|
+
if (!isEmpty(localExpiryDate)) {
|
|
220
|
+
newContent.expiryDate = localExpiryDate;
|
|
221
|
+
}
|
|
193
222
|
setIsSaving(true);
|
|
194
223
|
yield saveAddedNewSectionContents(topContentDispatch, topContentEditState, newCategory, selectedProduct, selectedVersion, isCatOnlyForMajorVersion, newContent);
|
|
195
224
|
ToastNotification.addSuccessMessage(t('Category created successfully'));
|
|
@@ -221,6 +250,7 @@ export const TopContentSingleItem = ({ isArrangingContent, category, snapshot, i
|
|
|
221
250
|
setNewCategory(category);
|
|
222
251
|
};
|
|
223
252
|
const onCancel = () => {
|
|
253
|
+
var _a;
|
|
224
254
|
if (content.mode === ContentMode.NEW_SECTION_CONTENT) {
|
|
225
255
|
fetchTopContent(topContentDispatch, selectedProduct, selectedVersion);
|
|
226
256
|
}
|
|
@@ -237,6 +267,17 @@ export const TopContentSingleItem = ({ isArrangingContent, category, snapshot, i
|
|
|
237
267
|
setContentUrlIsValid(true);
|
|
238
268
|
setIsAddingCategory(topContentDispatch, false);
|
|
239
269
|
setLocalSelectedTags(content.tags);
|
|
270
|
+
setLocalExpiryDate((_a = content.expiryDate) !== null && _a !== void 0 ? _a : '');
|
|
271
|
+
};
|
|
272
|
+
const expiryDateValidator = (date) => {
|
|
273
|
+
const today = new Date();
|
|
274
|
+
today.setHours(0, 0, 0, 0);
|
|
275
|
+
if (date < today)
|
|
276
|
+
return t('Invalid expiry date');
|
|
277
|
+
return '';
|
|
278
|
+
};
|
|
279
|
+
const onExpiryDateChange = (event, str, date) => {
|
|
280
|
+
setLocalExpiryDate(str);
|
|
240
281
|
};
|
|
241
282
|
useDebounce(() => {
|
|
242
283
|
onLocalContentUrlChange();
|
|
@@ -246,20 +287,28 @@ export const TopContentSingleItem = ({ isArrangingContent, category, snapshot, i
|
|
|
246
287
|
setIsPreview(true);
|
|
247
288
|
}, [isArrangingContent]);
|
|
248
289
|
useEffect(() => {
|
|
290
|
+
var _a;
|
|
249
291
|
setLocalContentTitle(content.contentTitle);
|
|
250
292
|
setLocalContentUrl(content.contentUrl);
|
|
251
293
|
setLocalSelectedTags(content.tags || []);
|
|
294
|
+
setLocalExpiryDate((_a = content.expiryDate) !== null && _a !== void 0 ? _a : '');
|
|
252
295
|
}, [content]);
|
|
253
296
|
// To check if input has spaces
|
|
254
297
|
const doesInputHasSpaces = isEmpty(localContentTitle.trim());
|
|
255
298
|
// To disable save button if empty depending on spaces
|
|
256
299
|
const isSaveButtonDisabled = doesInputHasSpaces ||
|
|
257
300
|
isDuplicateTitle ||
|
|
258
|
-
!(contentTitleIsValid &&
|
|
301
|
+
!(contentTitleIsValid &&
|
|
302
|
+
contentUrlIsValid &&
|
|
303
|
+
localContentTitle &&
|
|
304
|
+
localContentUrl &&
|
|
305
|
+
((isValidDate(localExpiryDate) && isEmpty(expiryDateValidator(new Date(localExpiryDate)))) ||
|
|
306
|
+
(isEmpty(localExpiryDate) && isEmpty((_a = content.expiryDate) !== null && _a !== void 0 ? _a : '')))) ||
|
|
259
307
|
(!newCategory && content.mode === ContentMode.NEW_SECTION_CONTENT) ||
|
|
260
308
|
(localContentUrl === content.contentUrl &&
|
|
261
309
|
localContentTitle === content.contentTitle &&
|
|
262
|
-
isEqual(localTagsIds, oldTagsIds)
|
|
310
|
+
isEqual(localTagsIds, oldTagsIds) &&
|
|
311
|
+
isEqual(localExpiryDate.split('T')[0], ((_b = content.expiryDate) === null || _b === void 0 ? void 0 : _b.split('T')[0]) || ''));
|
|
263
312
|
const lastModifiedBy = t(`Last modified {{created}} by {{by}}`, {
|
|
264
313
|
created: formatDate(content.updatedOn || content.createdOn),
|
|
265
314
|
by: content.updatedBy || content.createdBy,
|
|
@@ -273,7 +322,10 @@ export const TopContentSingleItem = ({ isArrangingContent, category, snapshot, i
|
|
|
273
322
|
' ',
|
|
274
323
|
React.createElement(Button, { variant: "link", isInline: true, icon: React.createElement(EditAltIcon, null), onClick: editToggle, title: 'Edit' }))) : (content.contentTitle),
|
|
275
324
|
React.createElement("div", null, lastModifiedBy),
|
|
276
|
-
React.createElement("div", null,
|
|
325
|
+
React.createElement("div", null,
|
|
326
|
+
(content.tags || []).map((tag) => (React.createElement(Label, { isCompact: true, className: "pf-v5-u-mr-xs pf-v5-u-mt-sm", key: tag.id, color: filteredTags.some((t) => t.id === tag.id) ? 'gold' : 'grey' }, tag.tagName))),
|
|
327
|
+
!isEmpty((_c = content.expiryDate) !== null && _c !== void 0 ? _c : '') && !isFutureDate(content.expiryDate) && (React.createElement(Label, { isCompact: true, className: "pf-v5-u-mr-xs pf-v5-u-mt-sm", color: "red" },
|
|
328
|
+
React.createElement(Trans, null, "Outdated Content")))))),
|
|
277
329
|
(!isPreview || content.mode === ContentMode.ADD || content.mode === ContentMode.NEW_SECTION_CONTENT) && (React.createElement("form", { noValidate: true, onSubmit: onSubmit, className: "card card-light push-bottom" },
|
|
278
330
|
content.mode === ContentMode.NEW_SECTION_CONTENT && (React.createElement(AddNewCategoryDropDown, { onCategoryChange: onAddedNewCategoryChange })),
|
|
279
331
|
React.createElement("div", { className: "form-group" },
|
|
@@ -303,7 +355,10 @@ export const TopContentSingleItem = ({ isArrangingContent, category, snapshot, i
|
|
|
303
355
|
React.createElement(FlexItem, { flex: { default: 'flex_1' } },
|
|
304
356
|
React.createElement(FormGroup, { label: t('Tags') },
|
|
305
357
|
React.createElement("div", { className: "pf-v5-c-form-control" },
|
|
306
|
-
React.createElement(TagsSelector, { tagOptions: tagOptions, onChange: handleLocalTagChange, selectedTags: localSelectedTags, placeholder: t('Select tags to improve discoverability') }))))
|
|
358
|
+
React.createElement(TagsSelector, { tagOptions: tagOptions, onChange: handleLocalTagChange, selectedTags: localSelectedTags, placeholder: t('Select tags to improve discoverability') })))),
|
|
359
|
+
React.createElement(FlexItem, null,
|
|
360
|
+
React.createElement(FormGroup, { label: t('Expiry date') },
|
|
361
|
+
React.createElement(DatePicker, { onBlur: onExpiryDateChange, onChange: onExpiryDateChange, value: !isEmpty(localExpiryDate) ? localExpiryDate.split('T')[0] : '', validators: [expiryDateValidator] })))),
|
|
307
362
|
React.createElement("span", { className: "top-content-single-item-footer" },
|
|
308
363
|
React.createElement("span", null,
|
|
309
364
|
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":"AAgBA,OAAO,KAA2D,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"TopContentEditor.d.ts","sourceRoot":"","sources":["../../../../../src/components/TopContentManagement/TopContentEditor/TopContentEditor.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAA2D,MAAM,OAAO,CAAC;AAgChF,wBAAgB,gBAAgB,sBA+W/B"}
|
|
@@ -19,7 +19,7 @@ import { TagManagementDispatchContext, TagManagementStateContext } from '../../.
|
|
|
19
19
|
import { useTopContentContext, useTopContentDispatchContext } from '../../../context/TopContentProvider';
|
|
20
20
|
import { fetchTopContentTags } from '../../../reducers/TagManagmentReducer';
|
|
21
21
|
import { flagContentUsage, isMajorOrNamedVersion } from '../../../reducers/TopContentHelpers';
|
|
22
|
-
import { CategoryMode, fetchTopContent, reArrangeCategory, resetChangeInCategory, resetContentWithSelectedProduct, resetDuplicatUrls, setAddNewSection, setIsAddingCategory, setIsSearchModeEnabled, setTopContentArrangingCategory, setTopContentArrangingContent, } from '../../../reducers/TopContentReducer';
|
|
22
|
+
import { CategoryMode, fetchTopContent, reArrangeCategory, resetChangeInCategory, resetContentWithSelectedProduct, resetDuplicatUrls, setAddNewSection, setFilteredTags, setIsAddingCategory, setIsSearchModeEnabled, setTopContentArrangingCategory, setTopContentArrangingContent, } from '../../../reducers/TopContentReducer';
|
|
23
23
|
import CategoryLimit from '../CategoryLimit/CategoryLimit';
|
|
24
24
|
import { VersionPerformanceMetrics } from '../ContentUsage/VersionPerformanceMetrics';
|
|
25
25
|
import { NoTopContentFound } from '../NoTopContentFound';
|
|
@@ -35,8 +35,7 @@ export function TopContentEditor() {
|
|
|
35
35
|
const [newCategoryVersion, setNewCategoryVersion] = useState(undefined);
|
|
36
36
|
const [searchQuery, setSearchQuery] = useState('');
|
|
37
37
|
const topContentResultsRef = useRef(null);
|
|
38
|
-
const
|
|
39
|
-
const { topContentResponse, topContentEditState, isAddingCategory, isCatOnlyForMajorVersion, isSearchModeEnabled, selectedProduct, selectedVersion, categoryUsage, } = useTopContentContext();
|
|
38
|
+
const { topContentResponse, topContentEditState, isAddingCategory, isCatOnlyForMajorVersion, isSearchModeEnabled, selectedProduct, selectedVersion, categoryUsage, filteredTags, } = useTopContentContext();
|
|
40
39
|
const { tags } = useContext(TagManagementStateContext);
|
|
41
40
|
const topContentDispatch = useTopContentDispatchContext();
|
|
42
41
|
const tagManagerDispatch = useContext(TagManagementDispatchContext);
|
|
@@ -138,6 +137,9 @@ export function TopContentEditor() {
|
|
|
138
137
|
setIsSearchModeEnabled(topContentDispatch, searchTerm ? true : false);
|
|
139
138
|
setFilteredByQueryTC(searchResults);
|
|
140
139
|
};
|
|
140
|
+
const onTagFilterChange = (tags) => {
|
|
141
|
+
setFilteredTags(topContentDispatch, tags);
|
|
142
|
+
};
|
|
141
143
|
const minorSelectedNoMinorContentButAvailableMajorContent = isContentOnlyForMajorVersion && getVersion(selectedVersion).minor && flagContentEditState.length !== 0;
|
|
142
144
|
const isCategoryLimitReached = filteredTC.length >= CATEGORY_LIMIT.MAX;
|
|
143
145
|
return (React.createElement(React.Fragment, null,
|
|
@@ -145,11 +147,11 @@ export function TopContentEditor() {
|
|
|
145
147
|
!topContentResponse.isFetching && topContentResponse.isError && (React.createElement(Alert, { isInline: true, variant: AlertVariant.danger, title: React.createElement(Trans, null, "Error loading Top Content") })),
|
|
146
148
|
React.createElement(TopContentProductVersionSelector, { selectedProduct: selectedProduct, selectedVersion: selectedVersion, onProductChange: onProductChange, onVersionChange: onVersionChange }),
|
|
147
149
|
!topContentResponse.isFetching && (React.createElement("div", { className: "toolbar" },
|
|
148
|
-
React.createElement(TopContentSearch, { dataTrackingId: "top-content-filter-manage", topContentData: flagContentEditState, onSearch: onSearch, topContentResultsWrapperRef: topContentResultsRef, searchQuery: searchQuery, setSearchQuery: setSearchQuery, className: "toolbar-content" }),
|
|
150
|
+
React.createElement(TopContentSearch, { dataTrackingId: "top-content-filter-manage", topContentData: flagContentEditState, onSearch: onSearch, topContentResultsWrapperRef: topContentResultsRef, searchQuery: searchQuery, setSearchQuery: setSearchQuery, className: "toolbar-content", isDisabled: isEmpty(flagContentEditState) }),
|
|
149
151
|
React.createElement("div", { className: "toolbar-content pf-v5-u-ml-md" },
|
|
150
152
|
React.createElement("label", { htmlFor: 'tag-selector' },
|
|
151
153
|
React.createElement(Trans, null, "All tags")),
|
|
152
|
-
React.createElement(TagsSelector, { tagOptions: tags, onChange:
|
|
154
|
+
React.createElement(TagsSelector, { tagOptions: tags, onChange: onTagFilterChange, selectedTags: filteredTags, disabled: isEmpty(flagContentEditState) })))),
|
|
153
155
|
React.createElement("div", { className: "top-content-manage-wrapper pf-v5-u-pt-md" },
|
|
154
156
|
!topContentResponse.isFetching && React.createElement(TopContentSuggestion, { searchQuery: searchQuery }),
|
|
155
157
|
topContentResponse.isFetching ? (React.createElement(Bullseye, null,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ExpiredContentDispatchType, IExpiredContentState } from '../reducers/ExpiredContentReducer';
|
|
3
|
+
export declare const ExpiredContentStateContext: React.Context<IExpiredContentState>;
|
|
4
|
+
export declare const ExpiredContentDispatchContext: React.Context<ExpiredContentDispatchType>;
|
|
5
|
+
export declare function ExpiredContentContextProvider({ children }: {
|
|
6
|
+
children: any;
|
|
7
|
+
}): React.JSX.Element;
|
|
8
|
+
//# sourceMappingURL=ExpiredContentContextProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpiredContentContextProvider.d.ts","sourceRoot":"","sources":["../../../src/context/ExpiredContentContextProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,OAAO,EACH,0BAA0B,EAE1B,oBAAoB,EAEvB,MAAM,mCAAmC,CAAC;AAG3C,eAAO,MAAM,0BAA0B,qCAAmE,CAAC;AAC3G,eAAO,MAAM,6BAA6B,2CAA8C,CAAC;AAEzF,wBAAgB,6BAA6B,CAAC,EAAE,QAAQ,EAAE;;CAAA,qBAOzD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React, { useReducer } from 'react';
|
|
2
|
+
import { ExpiredContentReducer, initialExpiredContent, } from '../reducers/ExpiredContentReducer';
|
|
3
|
+
const initialDispatchContext = null;
|
|
4
|
+
export const ExpiredContentStateContext = React.createContext(initialExpiredContent);
|
|
5
|
+
export const ExpiredContentDispatchContext = React.createContext(initialDispatchContext);
|
|
6
|
+
export function ExpiredContentContextProvider({ children }) {
|
|
7
|
+
const [expiredContentState, dispatch] = useReducer(ExpiredContentReducer, initialExpiredContent);
|
|
8
|
+
return (React.createElement(ExpiredContentStateContext.Provider, { value: Object.assign({}, expiredContentState) },
|
|
9
|
+
React.createElement(ExpiredContentDispatchContext.Provider, { value: dispatch }, children)));
|
|
10
|
+
}
|
|
@@ -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,
|
|
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,gBAerC,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,qBAOrD"}
|
|
@@ -15,6 +15,7 @@ export const intialTopContentContext = {
|
|
|
15
15
|
isSearchModeEnabled: false,
|
|
16
16
|
categoryUsage: {},
|
|
17
17
|
suggestion: {},
|
|
18
|
+
filteredTags: [],
|
|
18
19
|
};
|
|
19
20
|
const initalDispatchContext = null;
|
|
20
21
|
export const TopContentStateContext = React.createContext(intialTopContentContext);
|
package/lib/esm/index.d.ts
CHANGED
package/lib/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC"}
|
package/lib/esm/index.js
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ITag } from '@cee-eng/hydrajs/@types/models/tagModels';
|
|
2
|
+
import { ITopContent, ITopContentList } from '@cee-eng/hydrajs/@types/models/topContent/topContentModel';
|
|
3
|
+
import { IAction, IApiResponseDetails } from '@rh-support/types/shared';
|
|
4
|
+
export interface IExpiredContent extends ITopContent {
|
|
5
|
+
tagList?: (number | string)[];
|
|
6
|
+
product?: string;
|
|
7
|
+
majorVersion?: string;
|
|
8
|
+
minorVersion?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface IExpiredContentEditState extends Omit<ITopContentList, 'content' | 'productId' | 'majorVersion' | 'minorVersion'> {
|
|
11
|
+
content: IExpiredContent[];
|
|
12
|
+
}
|
|
13
|
+
export interface IExpiredContentState {
|
|
14
|
+
expiredContentResponse: IApiResponseDetails<IExpiredContentEditState[]>;
|
|
15
|
+
expiredContentEditState: IExpiredContentEditState[];
|
|
16
|
+
filteredTags: ITag[];
|
|
17
|
+
}
|
|
18
|
+
export declare const initialExpiredContent: IExpiredContentState;
|
|
19
|
+
export declare enum ExpiredContentReducerConstants {
|
|
20
|
+
getExpiredContent = "getExpiredContent",
|
|
21
|
+
filterExpiredContent = "filterExpiredContent",
|
|
22
|
+
resetExpiredContent = "resetExpiredContent",
|
|
23
|
+
updateExpiredContentState = "updateExpiredContentState",
|
|
24
|
+
updateFilteredTags = "updateFilteredTags"
|
|
25
|
+
}
|
|
26
|
+
type IActionType = IAction<ExpiredContentReducerConstants, IExpiredContentState>;
|
|
27
|
+
export type ExpiredContentDispatchType = (value: IActionType) => void;
|
|
28
|
+
export declare const ExpiredContentReducer: (state: IExpiredContentState, action: IActionType) => IExpiredContentState;
|
|
29
|
+
export declare const isContentExpired: (expiryDate: string | undefined) => boolean;
|
|
30
|
+
export declare const fetchExpiredContent: (dispatch: ExpiredContentDispatchType, fetchApproachingExpiry?: boolean) => Promise<void>;
|
|
31
|
+
export declare const updateExpiredContent: (dispatch: ExpiredContentDispatchType, expiredContentEditState: IExpiredContentEditState[], categoryId: number, content: IExpiredContent, deletedTags?: any[]) => Promise<void>;
|
|
32
|
+
export declare const deleteExpiredContent: (dispatch: ExpiredContentDispatchType, expiredContentEditState: IExpiredContentEditState[], categoryId: number, topContentId: number) => Promise<never>;
|
|
33
|
+
export declare const setExpiredContentFilteredTags: (dispatch: ExpiredContentDispatchType, tags: ITag[]) => void;
|
|
34
|
+
export {};
|
|
35
|
+
//# sourceMappingURL=ExpiredContentReducer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpiredContentReducer.d.ts","sourceRoot":"","sources":["../../../src/reducers/ExpiredContentReducer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,0CAA0C,CAAC;AAChE,OAAO,EACH,WAAW,EACX,eAAe,EAElB,MAAM,2DAA2D,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAMxE,MAAM,WAAW,eAAgB,SAAQ,WAAW;IAChD,OAAO,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,wBACb,SAAQ,IAAI,CAAC,eAAe,EAAE,SAAS,GAAG,WAAW,GAAG,cAAc,GAAG,cAAc,CAAC;IACxF,OAAO,EAAE,eAAe,EAAE,CAAC;CAC9B;AAED,MAAM,WAAW,oBAAoB;IACjC,sBAAsB,EAAE,mBAAmB,CAAC,wBAAwB,EAAE,CAAC,CAAC;IACxE,uBAAuB,EAAE,wBAAwB,EAAE,CAAC;IACpD,YAAY,EAAE,IAAI,EAAE,CAAC;CACxB;AAED,eAAO,MAAM,qBAAqB,EAAE,oBAInC,CAAC;AAEF,oBAAY,8BAA8B;IACtC,iBAAiB,sBAAsB;IACvC,oBAAoB,yBAAyB;IAC7C,mBAAmB,wBAAwB;IAC3C,yBAAyB,8BAA8B;IACvD,kBAAkB,uBAAuB;CAC5C;AAED,KAAK,WAAW,GAAG,OAAO,CAAC,8BAA8B,EAAE,oBAAoB,CAAC,CAAC;AACjF,MAAM,MAAM,0BAA0B,GAAG,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;AAEtE,eAAO,MAAM,qBAAqB,UAAW,oBAAoB,0BAAwB,oBAgCxF,CAAC;AAEF,eAAO,MAAM,gBAAgB,eAAgB,MAAM,GAAG,SAAS,YAM9D,CAAC;AASF,eAAO,MAAM,mBAAmB,aAClB,0BAA0B,2BACZ,OAAO,kBA2ElC,CAAC;AAEF,eAAO,MAAM,oBAAoB,aACnB,0BAA0B,2BACX,wBAAwB,EAAE,cACvC,MAAM,WACT,eAAe,gBACV,GAAG,EAAE,kBAmDtB,CAAC;AAEF,eAAO,MAAM,oBAAoB,aACnB,0BAA0B,2BACX,wBAAwB,EAAE,cACvC,MAAM,gBACJ,MAAM,mBAsBvB,CAAC;AAEF,eAAO,MAAM,6BAA6B,aAAc,0BAA0B,QAAQ,IAAI,EAAE,SAK/F,CAAC"}
|
|
@@ -0,0 +1,190 @@
|
|
|
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, products as productsApi } from '@cee-eng/hydrajs';
|
|
11
|
+
import { getApiResourceObject } from '@rh-support/utils';
|
|
12
|
+
import cloneDeep from 'lodash/cloneDeep';
|
|
13
|
+
import isEmpty from 'lodash/isEmpty';
|
|
14
|
+
import isUndefined from 'lodash/isUndefined';
|
|
15
|
+
export const initialExpiredContent = {
|
|
16
|
+
expiredContentResponse: getApiResourceObject([]),
|
|
17
|
+
expiredContentEditState: [],
|
|
18
|
+
filteredTags: [],
|
|
19
|
+
};
|
|
20
|
+
export var ExpiredContentReducerConstants;
|
|
21
|
+
(function (ExpiredContentReducerConstants) {
|
|
22
|
+
ExpiredContentReducerConstants["getExpiredContent"] = "getExpiredContent";
|
|
23
|
+
ExpiredContentReducerConstants["filterExpiredContent"] = "filterExpiredContent";
|
|
24
|
+
ExpiredContentReducerConstants["resetExpiredContent"] = "resetExpiredContent";
|
|
25
|
+
ExpiredContentReducerConstants["updateExpiredContentState"] = "updateExpiredContentState";
|
|
26
|
+
ExpiredContentReducerConstants["updateFilteredTags"] = "updateFilteredTags";
|
|
27
|
+
})(ExpiredContentReducerConstants || (ExpiredContentReducerConstants = {}));
|
|
28
|
+
export const ExpiredContentReducer = (state, action) => {
|
|
29
|
+
var _a, _b, _c, _d, _e, _f;
|
|
30
|
+
switch (action.type) {
|
|
31
|
+
case ExpiredContentReducerConstants.resetExpiredContent: {
|
|
32
|
+
return initialExpiredContent;
|
|
33
|
+
}
|
|
34
|
+
case ExpiredContentReducerConstants.getExpiredContent: {
|
|
35
|
+
return Object.assign(Object.assign({}, state), { expiredContentEditState: [...(_a = action.payload) === null || _a === void 0 ? void 0 : _a.expiredContentEditState], expiredContentResponse: (_b = action.payload) === null || _b === void 0 ? void 0 : _b.expiredContentResponse });
|
|
36
|
+
}
|
|
37
|
+
case ExpiredContentReducerConstants.filterExpiredContent: {
|
|
38
|
+
return Object.assign(Object.assign({}, state), { expiredContentEditState: (_c = action.payload) === null || _c === void 0 ? void 0 : _c.expiredContentEditState });
|
|
39
|
+
}
|
|
40
|
+
case ExpiredContentReducerConstants.updateExpiredContentState: {
|
|
41
|
+
return Object.assign(Object.assign({}, state), { expiredContentEditState: (_d = action.payload) === null || _d === void 0 ? void 0 : _d.expiredContentEditState, expiredContentResponse: (_e = action.payload) === null || _e === void 0 ? void 0 : _e.expiredContentResponse });
|
|
42
|
+
}
|
|
43
|
+
case ExpiredContentReducerConstants.updateFilteredTags: {
|
|
44
|
+
return Object.assign(Object.assign({}, state), { filteredTags: (_f = action.payload) === null || _f === void 0 ? void 0 : _f.filteredTags });
|
|
45
|
+
}
|
|
46
|
+
default: {
|
|
47
|
+
return state;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
export const isContentExpired = (expiryDate) => {
|
|
52
|
+
if (isUndefined(expiryDate))
|
|
53
|
+
return false;
|
|
54
|
+
const now = new Date();
|
|
55
|
+
const expiry = new Date(expiryDate);
|
|
56
|
+
return expiry <= now;
|
|
57
|
+
};
|
|
58
|
+
function formatDate(date) {
|
|
59
|
+
const year = date.getFullYear();
|
|
60
|
+
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
61
|
+
const day = String(date.getDate()).padStart(2, '0');
|
|
62
|
+
return `${year}-${month}-${day}`;
|
|
63
|
+
}
|
|
64
|
+
export const fetchExpiredContent = (dispatch, fetchApproachingExpiry = false) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65
|
+
try {
|
|
66
|
+
let expiryTimeLimit = new Date();
|
|
67
|
+
if (fetchApproachingExpiry) {
|
|
68
|
+
// Add 7 days to the current date
|
|
69
|
+
expiryTimeLimit.setDate(expiryTimeLimit.getDate() + 7);
|
|
70
|
+
}
|
|
71
|
+
dispatch({
|
|
72
|
+
type: ExpiredContentReducerConstants.getExpiredContent,
|
|
73
|
+
payload: {
|
|
74
|
+
expiredContentResponse: getApiResourceObject([], true),
|
|
75
|
+
expiredContentEditState: [],
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
const [products, expiredContents] = yield Promise.all([
|
|
79
|
+
productsApi.getProducts(),
|
|
80
|
+
pcm.topContent.getTopContent({
|
|
81
|
+
startDate: '1970-01-01',
|
|
82
|
+
endDate: `${formatDate(expiryTimeLimit)}`,
|
|
83
|
+
}),
|
|
84
|
+
]);
|
|
85
|
+
const productIdToName = new Map();
|
|
86
|
+
products.forEach((p) => {
|
|
87
|
+
productIdToName.set(p.productId, p.name);
|
|
88
|
+
});
|
|
89
|
+
const categoryIndexMap = new Map();
|
|
90
|
+
const resultGroupedByCategory = expiredContents.reduce((accumulator, cat) => {
|
|
91
|
+
const existingCategoryIndex = categoryIndexMap.get(cat.categoryName);
|
|
92
|
+
cat.content.forEach((content) => {
|
|
93
|
+
var _a;
|
|
94
|
+
content.product = productIdToName.get((_a = cat.productId) !== null && _a !== void 0 ? _a : '') || cat.productId;
|
|
95
|
+
content.majorVersion = cat.majorVersion;
|
|
96
|
+
content.minorVersion = cat.minorVersion;
|
|
97
|
+
});
|
|
98
|
+
if (isUndefined(existingCategoryIndex)) {
|
|
99
|
+
accumulator.push(cat);
|
|
100
|
+
categoryIndexMap.set(cat.categoryName, accumulator.length - 1);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
accumulator[existingCategoryIndex].content = [].concat.apply([], [accumulator[existingCategoryIndex].content, cat.content]);
|
|
104
|
+
}
|
|
105
|
+
return accumulator;
|
|
106
|
+
}, []);
|
|
107
|
+
dispatch({
|
|
108
|
+
type: ExpiredContentReducerConstants.getExpiredContent,
|
|
109
|
+
payload: {
|
|
110
|
+
expiredContentResponse: getApiResourceObject(cloneDeep(resultGroupedByCategory)),
|
|
111
|
+
expiredContentEditState: resultGroupedByCategory,
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
catch (err) {
|
|
116
|
+
dispatch({
|
|
117
|
+
type: ExpiredContentReducerConstants.getExpiredContent,
|
|
118
|
+
payload: {
|
|
119
|
+
expiredContentResponse: getApiResourceObject([], false, true, err.message),
|
|
120
|
+
expiredContentEditState: [],
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
export const updateExpiredContent = (dispatch, expiredContentEditState, categoryId, content, deletedTags) => __awaiter(void 0, void 0, void 0, function* () {
|
|
126
|
+
const toUpdate = {
|
|
127
|
+
id: content.topContentId,
|
|
128
|
+
contentTitle: content.contentTitle,
|
|
129
|
+
contentUrl: content.contentUrl,
|
|
130
|
+
contentRank: content.contentRank,
|
|
131
|
+
tagList: content.tagList, // list of new tagIds which needs to be added in content
|
|
132
|
+
expiryDate: content.expiryDate,
|
|
133
|
+
isActive: 1,
|
|
134
|
+
};
|
|
135
|
+
try {
|
|
136
|
+
if (deletedTags && !isEmpty(deletedTags)) {
|
|
137
|
+
yield Promise.all(deletedTags.map((t) => pcm.topContentTag.deleteTagFromTopContent(content.topContentId, t)));
|
|
138
|
+
}
|
|
139
|
+
const updatedContent = yield pcm.topContent.patchTopContent({ topContents: [toUpdate] });
|
|
140
|
+
expiredContentEditState.forEach((cat) => {
|
|
141
|
+
if (cat.categoryId === categoryId) {
|
|
142
|
+
const index = cat.content.findIndex((c) => c.topContentId === content.topContentId);
|
|
143
|
+
if (index !== -1) {
|
|
144
|
+
cat.content[index] = Object.assign(Object.assign({}, cat.content[index]), { contentTitle: content.contentTitle, contentUrl: content.contentUrl, updatedBy: updatedContent.topContents[0].updatedBy, updatedOn: updatedContent.topContents[0].updatedOn, tags: content.tags, expiryDate: content.expiryDate });
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
// We need to clone deep current state to re-render
|
|
149
|
+
const clonedExpiredContentEditState = cloneDeep(expiredContentEditState);
|
|
150
|
+
dispatch({
|
|
151
|
+
type: ExpiredContentReducerConstants.updateExpiredContentState,
|
|
152
|
+
payload: {
|
|
153
|
+
expiredContentResponse: getApiResourceObject(cloneDeep(clonedExpiredContentEditState)),
|
|
154
|
+
expiredContentEditState: clonedExpiredContentEditState,
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
catch (e) {
|
|
159
|
+
console.log(e);
|
|
160
|
+
Promise.reject(e);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
export const deleteExpiredContent = (dispatch, expiredContentEditState, categoryId, topContentId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
164
|
+
try {
|
|
165
|
+
yield pcm.topContent.deleteTopContent(topContentId);
|
|
166
|
+
expiredContentEditState.forEach((cat) => {
|
|
167
|
+
if (cat.id === categoryId) {
|
|
168
|
+
cat.content = cat.content.filter((item) => item.topContentId !== topContentId);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
const expiredContent = expiredContentEditState.filter((cat) => cat.content.length !== 0);
|
|
172
|
+
dispatch({
|
|
173
|
+
type: ExpiredContentReducerConstants.updateExpiredContentState,
|
|
174
|
+
payload: {
|
|
175
|
+
expiredContentResponse: getApiResourceObject(cloneDeep(expiredContent)),
|
|
176
|
+
expiredContentEditState: expiredContent,
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
catch (e) {
|
|
181
|
+
console.log(e);
|
|
182
|
+
return Promise.reject(e);
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
export const setExpiredContentFilteredTags = (dispatch, tags) => {
|
|
186
|
+
dispatch({
|
|
187
|
+
type: ExpiredContentReducerConstants.updateFilteredTags,
|
|
188
|
+
payload: { filteredTags: tags },
|
|
189
|
+
});
|
|
190
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IProduct as IHydraProduct, IProduct } from '@cee-eng/hydrajs/@types/models/product';
|
|
2
|
+
import { ITag } from '@cee-eng/hydrajs/@types/models/tagModels';
|
|
2
3
|
import { ITopContent, ITopContentCategory, ITopContentList, ITopContentResourceUsagesResponse } from '@cee-eng/hydrajs/@types/models/topContent/topContentModel';
|
|
3
4
|
import { IAction, IApiResponseDetails } from '@rh-support/types/shared';
|
|
4
5
|
export interface ITopContentItemState extends ITopContent {
|
|
@@ -53,6 +54,7 @@ export interface ITopContentState {
|
|
|
53
54
|
isSearchModeEnabled: boolean;
|
|
54
55
|
categoryUsage: ITopContentResourceUsagesResponse;
|
|
55
56
|
suggestion: ITopContentSuggestion;
|
|
57
|
+
filteredTags: ITag[];
|
|
56
58
|
}
|
|
57
59
|
export declare enum ContentMode {
|
|
58
60
|
INITIAL = "initial",
|
|
@@ -76,7 +78,8 @@ export declare enum TopContentReducerConstants {
|
|
|
76
78
|
setIsSearchModeEnabled = "setIsSearchModeEnabled",
|
|
77
79
|
resetDuplicatUrls = "resetDuplicatUrls",
|
|
78
80
|
getTopContentResourceUsage = "getTopContentResourceUsage",
|
|
79
|
-
setTopContentSuggestions = "setTopContentSuggestions"
|
|
81
|
+
setTopContentSuggestions = "setTopContentSuggestions",
|
|
82
|
+
updateFilteredTags = "updateFilteredTags"
|
|
80
83
|
}
|
|
81
84
|
type IActionType = IAction<TopContentReducerConstants, ITopContentState>;
|
|
82
85
|
export type TopContentReducerDispatchType = (value: IActionType) => void;
|
|
@@ -101,6 +104,7 @@ export declare const reArrangeCategory: (dispatch: TopContentReducerDispatchType
|
|
|
101
104
|
export declare const fetchCategories: (dispatch: TopContentReducerDispatchType) => Promise<never>;
|
|
102
105
|
export declare const setIsSearchModeEnabled: (dispatch: TopContentReducerDispatchType, isSearchModeEnabled: boolean) => void;
|
|
103
106
|
export declare const resetDuplicatUrls: (dispatch: TopContentReducerDispatchType) => void;
|
|
107
|
+
export declare const setFilteredTags: (dispatch: TopContentReducerDispatchType, tags: ITag[]) => void;
|
|
104
108
|
/**
|
|
105
109
|
* This function is used for to get top content suggestions from server
|
|
106
110
|
* @param dispatch TopContentReducerDispatchType
|
|
@@ -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,EAEpC,MAAM,2DAA2D,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAE,MA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