@rh-support/manage 1.0.301-beta.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/esm/ManageTab.d.ts.map +1 -1
- package/lib/esm/ManageTab.js +3 -2
- package/lib/esm/ManageTabs.d.ts.map +1 -1
- package/lib/esm/ManageTabs.js +4 -21
- package/lib/esm/Routes.d.ts +0 -1
- package/lib/esm/Routes.d.ts.map +1 -1
- package/lib/esm/Routes.js +0 -6
- package/lib/esm/components/Configs/ConfigInLineEdit.js +1 -1
- package/lib/esm/components/Groups/GroupUserPermissionsSelect/GroupUserPermissionsSelect.js +1 -1
- package/lib/esm/components/Groups/ManageGroupUsers/ManageGroupUsers.d.ts.map +1 -1
- package/lib/esm/components/Groups/ManageGroupUsers/ManageGroupUsers.js +9 -0
- package/lib/esm/components/ManageBookmarkedAccountsTab/AddEditBookmarkModal.d.ts.map +1 -1
- package/lib/esm/components/ManageBookmarkedAccountsTab/AddEditBookmarkModal.js +24 -11
- package/lib/esm/components/ManageBookmarkedAccountsTab/BookmarkAccountSelector.d.ts.map +1 -1
- package/lib/esm/components/ManageBookmarkedAccountsTab/BookmarkAccountSelector.js +4 -4
- package/lib/esm/components/ManageBookmarkedAccountsTab/BookmarkGroupSelector.d.ts +3 -0
- package/lib/esm/components/ManageBookmarkedAccountsTab/BookmarkGroupSelector.d.ts.map +1 -1
- package/lib/esm/components/ManageBookmarkedAccountsTab/BookmarkGroupSelector.js +9 -23
- package/lib/esm/components/ManageBookmarkedAccountsTab/ManageGroupedBookmarkedAccountsTab.d.ts.map +1 -1
- package/lib/esm/components/ManageBookmarkedAccountsTab/ManageGroupedBookmarkedAccountsTab.js +45 -30
- package/lib/esm/components/ManagePreferences/sections/PreferencesCaseCreate.d.ts.map +1 -1
- package/lib/esm/components/ManagePreferences/sections/PreferencesCaseCreate.js +63 -54
- package/lib/esm/components/ManageTable/ManageTable.d.ts +0 -1
- package/lib/esm/components/ManageTable/ManageTable.d.ts.map +1 -1
- package/lib/esm/components/ManageTable/ManageTable.js +3 -4
- package/lib/esm/components/NotificationEmails/NotificationEmailsModal.d.ts.map +1 -1
- package/lib/esm/components/NotificationEmails/NotificationEmailsModal.js +1 -0
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/AddNewCategoryDropDown.d.ts.map +1 -1
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/AddNewCategoryDropDown.js +29 -10
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentEditor.d.ts.map +1 -1
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentEditor.js +3 -1
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestion.d.ts +6 -0
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestion.d.ts.map +1 -0
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestion.js +30 -0
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestionHint.d.ts +8 -0
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestionHint.d.ts.map +1 -0
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestionHint.js +64 -0
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestionHintAccept.d.ts +9 -0
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestionHintAccept.d.ts.map +1 -0
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestionHintAccept.js +142 -0
- package/lib/esm/components/TopContentManagement/TopContentProductVersionSelector.d.ts.map +1 -1
- package/lib/esm/components/TopContentManagement/TopContentProductVersionSelector.js +31 -30
- package/lib/esm/context/TopContentProvider.d.ts.map +1 -1
- package/lib/esm/context/TopContentProvider.js +1 -0
- package/lib/esm/reducers/TopContentReducer.d.ts +32 -2
- package/lib/esm/reducers/TopContentReducer.d.ts.map +1 -1
- package/lib/esm/reducers/TopContentReducer.js +82 -13
- package/lib/esm/scss/_main.scss +8 -0
- package/lib/esm/scss/_pf4-overrides.scss +22 -0
- package/package.json +10 -10
- package/lib/esm/components/ManagePartnerships/NonOrgCustomerInfoModal.d.ts +0 -2
- package/lib/esm/components/ManagePartnerships/NonOrgCustomerInfoModal.d.ts.map +0 -1
- package/lib/esm/components/ManagePartnerships/NonOrgCustomerInfoModal.js +0 -15
- package/lib/esm/components/ManagePartnerships/PartnerLinkNameForm.d.ts +0 -12
- package/lib/esm/components/ManagePartnerships/PartnerLinkNameForm.d.ts.map +0 -1
- package/lib/esm/components/ManagePartnerships/PartnerLinkNameForm.js +0 -21
- package/lib/esm/components/ManagePartnerships/PartnershipsList.d.ts +0 -2
- package/lib/esm/components/ManagePartnerships/PartnershipsList.d.ts.map +0 -1
- package/lib/esm/components/ManagePartnerships/PartnershipsList.js +0 -164
- package/lib/esm/components/ManagePartnerships/PartnershipsTermsModal.d.ts +0 -2
- package/lib/esm/components/ManagePartnerships/PartnershipsTermsModal.d.ts.map +0 -1
- package/lib/esm/components/ManagePartnerships/PartnershipsTermsModal.js +0 -97
- package/lib/esm/components/ManagePartnerships/PendingRequests.d.ts +0 -3
- package/lib/esm/components/ManagePartnerships/PendingRequests.d.ts.map +0 -1
- package/lib/esm/components/ManagePartnerships/PendingRequests.js +0 -190
- package/lib/esm/components/ManagePartnerships/RequestCollaborationModal.d.ts +0 -8
- package/lib/esm/components/ManagePartnerships/RequestCollaborationModal.d.ts.map +0 -1
- package/lib/esm/components/ManagePartnerships/RequestCollaborationModal.js +0 -130
- package/lib/esm/components/ManagePartnerships/index.d.ts +0 -2
- package/lib/esm/components/ManagePartnerships/index.d.ts.map +0 -1
- package/lib/esm/components/ManagePartnerships/index.js +0 -27
- package/lib/esm/context/ManagePartnershipsProvider.d.ts +0 -11
- package/lib/esm/context/ManagePartnershipsProvider.d.ts.map +0 -1
- package/lib/esm/context/ManagePartnershipsProvider.js +0 -26
- package/lib/esm/reducers/ManagePartnershipsReducer.d.ts +0 -16
- package/lib/esm/reducers/ManagePartnershipsReducer.d.ts.map +0 -1
- package/lib/esm/reducers/ManagePartnershipsReducer.js +0 -30
|
@@ -7,37 +7,62 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
import { publicApi } from '@cee-eng/hydrajs';
|
|
10
11
|
import { Card, CardBody, CardHeader, SelectOption } from '@patternfly/react-core';
|
|
11
|
-
import { ToastNotification } from '@rh-support/components';
|
|
12
|
-
import {
|
|
12
|
+
import { ToastNotification, useFetch } from '@rh-support/components';
|
|
13
|
+
import { fetchLanguageMetadata, GlobalMetadataDispatchContext, GlobalMetadataStateContext, } from '@rh-support/react-context';
|
|
13
14
|
import { haventLoadedMetadata, PreferredLanguages } from '@rh-support/utils';
|
|
14
|
-
import invert from 'lodash/invert';
|
|
15
15
|
import isEmpty from 'lodash/isEmpty';
|
|
16
16
|
import map from 'lodash/map';
|
|
17
17
|
import React, { useContext, useEffect, useState } from 'react';
|
|
18
18
|
import { Trans, useTranslation } from 'react-i18next';
|
|
19
|
+
import { useLocation } from 'react-router-dom';
|
|
19
20
|
import { useUserPreferences } from '../../../hooks/useUserPreferences';
|
|
20
21
|
import { PreferenceSelect } from '../components/PreferenceSelect';
|
|
21
22
|
export function PreferencesCaseCreate(props) {
|
|
22
23
|
const { t } = useTranslation();
|
|
23
|
-
const
|
|
24
|
+
const location = useLocation();
|
|
25
|
+
const { globalMetadataState: { caseGroups, caseLanguages, loggedInUserJwtToken, loggedInUserRights, loggedInUsersAccount, }, } = useContext(GlobalMetadataStateContext);
|
|
24
26
|
const dispatchToGlobalMetadataReducer = useContext(GlobalMetadataDispatchContext);
|
|
25
27
|
const languageConst = caseLanguages.data;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
const getDefaultGroupFetch = useFetch(publicApi.caseGroups.getCaseGroupsForSSO, {
|
|
29
|
+
propgateErrors: true,
|
|
30
|
+
});
|
|
31
|
+
const toggleDefaultGroupFetch = useFetch(publicApi.caseGroups.toggleDefaultGroup, {
|
|
32
|
+
propgateErrors: true,
|
|
33
|
+
});
|
|
34
|
+
const grabDefaultGroupList = (ssoUser) => __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
try {
|
|
36
|
+
let list = yield getDefaultGroupFetch.request(ssoUser);
|
|
37
|
+
setUserDefaultGroupList(list);
|
|
38
|
+
let filteredDefaultGroup = (list ? list : []).filter((group) => group.isDefault === true);
|
|
39
|
+
if (!isEmpty(filteredDefaultGroup)) {
|
|
40
|
+
setOriginalDefaultGroup(filteredDefaultGroup[0].name);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
setOriginalDefaultGroup('Ungrouped Case');
|
|
44
|
+
}
|
|
29
45
|
}
|
|
30
|
-
|
|
31
|
-
|
|
46
|
+
catch (error) {
|
|
47
|
+
console.log(error);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
const updateDefaultGroupPref = (groupNum) => __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
try {
|
|
52
|
+
yield toggleDefaultGroupFetch.request(groupNum, loggedInUserRights.data.getSSOUsername(), true, loggedInUsersAccount.data.secureSupport);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
console.log(error);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
32
58
|
const languagesList = map(languageConst, (cl) => ({
|
|
33
59
|
label: PreferredLanguages.languagesMap[cl] || cl,
|
|
34
60
|
value: cl,
|
|
35
61
|
}));
|
|
36
62
|
const [originalPreferredLanguage, setOriginalPreferredLanguage] = useState('');
|
|
37
63
|
const [originalDefaultGroup, setOriginalDefaultGroup] = useState('');
|
|
38
|
-
const [
|
|
39
|
-
const
|
|
40
|
-
const { getPreferredLanguage, updatePreferredLanguage, updateDefaultGroup, getDefaultGroup } = useUserPreferences();
|
|
64
|
+
const [userDefaultGroupList, setUserDefaultGroupList] = useState();
|
|
65
|
+
const { getPreferredLanguage, updatePreferredLanguage } = useUserPreferences();
|
|
41
66
|
const preferredLangTitleId = 'preferred-language-select';
|
|
42
67
|
const defaultGroupTitleId = 'default-group-select';
|
|
43
68
|
const getLanguageKey = (selection) => {
|
|
@@ -60,53 +85,21 @@ export function PreferencesCaseCreate(props) {
|
|
|
60
85
|
}
|
|
61
86
|
});
|
|
62
87
|
const onDefaultGroupSelect = (event, selection, isPlaceholder) => __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
const selectionKey = invert(groupDictionary)[selection];
|
|
64
88
|
try {
|
|
65
|
-
|
|
66
|
-
|
|
89
|
+
if (selection === 'Ungrouped Case') {
|
|
90
|
+
updateDefaultGroupPref('-1');
|
|
91
|
+
}
|
|
92
|
+
if (!isEmpty(userDefaultGroupList)) {
|
|
93
|
+
let filteredGroupSelect = userDefaultGroupList.filter((group) => group.name === selection);
|
|
94
|
+
yield updateDefaultGroupPref(filteredGroupSelect[0].groupNum);
|
|
95
|
+
setOriginalDefaultGroup(filteredGroupSelect[0].name);
|
|
96
|
+
}
|
|
67
97
|
}
|
|
68
98
|
catch (error) {
|
|
69
99
|
console.log(error);
|
|
70
100
|
}
|
|
71
101
|
});
|
|
72
|
-
const createCaseGroupStruct = (caseGroups) => {
|
|
73
|
-
const defaultGroupDictionary = {};
|
|
74
|
-
for (let i = 0; i < caseGroups.data.length; i++) {
|
|
75
|
-
defaultGroupDictionary[caseGroups.data[i].groupNum] = caseGroups.data[i].name;
|
|
76
|
-
}
|
|
77
|
-
return defaultGroupDictionary;
|
|
78
|
-
};
|
|
79
|
-
//Set user default group after group obj built
|
|
80
|
-
useEffect(() => {
|
|
81
|
-
const userOriginalDefaultGroup = () => __awaiter(this, void 0, void 0, function* () {
|
|
82
|
-
try {
|
|
83
|
-
const retrievedGroupId = yield getDefaultGroup();
|
|
84
|
-
setOriginalDefaultGroup(groupDictionary[retrievedGroupId]);
|
|
85
|
-
}
|
|
86
|
-
catch (e) {
|
|
87
|
-
ToastNotification.addWarningMessage(t('Failed to fetch original preference'));
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
userOriginalDefaultGroup();
|
|
91
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
92
|
-
}, [groupDictionary]);
|
|
93
|
-
// used to build the groups object and fetch pref language
|
|
94
102
|
useEffect(() => {
|
|
95
|
-
const refreshParsedGroups = () => __awaiter(this, void 0, void 0, function* () {
|
|
96
|
-
var _a;
|
|
97
|
-
if (haventLoadedMetadata(caseGroups, (data) => data === undefined)) {
|
|
98
|
-
yield fetchCaseGroupsForSSO(dispatchToGlobalMetadataReducer, loggedInUserJwtToken.username);
|
|
99
|
-
}
|
|
100
|
-
if (!isEmpty(caseGroups) && ((_a = caseGroups === null || caseGroups === void 0 ? void 0 : caseGroups.data) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
101
|
-
let updatedDictionary = createCaseGroupStruct(caseGroups);
|
|
102
|
-
setGroupDictionary(updatedDictionary);
|
|
103
|
-
const parsedDefaultGroupNames = [];
|
|
104
|
-
for (let groupId in updatedDictionary) {
|
|
105
|
-
parsedDefaultGroupNames.push(updatedDictionary[groupId]);
|
|
106
|
-
}
|
|
107
|
-
setUserDefaultGroupList(parsedDefaultGroupNames);
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
103
|
const userOriginalPreferredLanguage = () => __awaiter(this, void 0, void 0, function* () {
|
|
111
104
|
try {
|
|
112
105
|
const retrievedLanguage = yield getPreferredLanguage();
|
|
@@ -117,10 +110,26 @@ export function PreferencesCaseCreate(props) {
|
|
|
117
110
|
ToastNotification.addWarningMessage(t('Failed to fetch original preference'));
|
|
118
111
|
}
|
|
119
112
|
});
|
|
120
|
-
refreshParsedGroups();
|
|
121
113
|
userOriginalPreferredLanguage();
|
|
122
114
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
123
115
|
}, [caseLanguages, caseGroups, dispatchToGlobalMetadataReducer, loggedInUserJwtToken]);
|
|
116
|
+
useEffect(() => {
|
|
117
|
+
grabDefaultGroupList(loggedInUserRights.data.getSSOUsername());
|
|
118
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
119
|
+
}, [loggedInUserRights, caseGroups]);
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
if (location.pathname !== '/manage/preferences') {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
grabDefaultGroupList(loggedInUserRights.data.getSSOUsername());
|
|
125
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
126
|
+
}, [location.pathname]);
|
|
127
|
+
useEffect(() => {
|
|
128
|
+
if (haventLoadedMetadata(caseLanguages)) {
|
|
129
|
+
fetchLanguageMetadata(dispatchToGlobalMetadataReducer);
|
|
130
|
+
}
|
|
131
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
132
|
+
}, [caseLanguages]);
|
|
124
133
|
return (React.createElement(Card, { className: "preference-card" },
|
|
125
134
|
React.createElement(CardHeader, null,
|
|
126
135
|
React.createElement("h3", null,
|
|
@@ -132,5 +141,5 @@ export function PreferencesCaseCreate(props) {
|
|
|
132
141
|
React.createElement("p", { className: "form-instructions" },
|
|
133
142
|
React.createElement(Trans, null, "Preferred language will impact future cases, not existing ones."))),
|
|
134
143
|
React.createElement("div", { className: "form-group" },
|
|
135
|
-
React.createElement(PreferenceSelect, { label: "Default group", id: defaultGroupTitleId, onSelect: onDefaultGroupSelect, selections: originalDefaultGroup }, userDefaultGroupList.map((option, index) => (React.createElement(SelectOption, { key: index, value: option })))))))));
|
|
144
|
+
React.createElement(PreferenceSelect, { label: "Default group", id: defaultGroupTitleId, onSelect: onDefaultGroupSelect, selections: originalDefaultGroup }, (userDefaultGroupList ? userDefaultGroupList : []).map((option, index) => (React.createElement(SelectOption, { key: index, value: option.name })))))))));
|
|
136
145
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ManageTable.d.ts","sourceRoot":"","sources":["../../../../src/components/ManageTable/ManageTable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGH,YAAY,EAQf,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC1F,OAAO,EAAE,OAAO,EAAE,SAAS,EAAmC,MAAM,wBAAwB,CAAC;AAC7F,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,UAAU,MAAM;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,SAAS,CAAC;IAGrB,cAAc,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,OAAO,EAAE,OAAO,CAAC;IAEjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,0BAA0B,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ManageTable.d.ts","sourceRoot":"","sources":["../../../../src/components/ManageTable/ManageTable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGH,YAAY,EAQf,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC1F,OAAO,EAAE,OAAO,EAAE,SAAS,EAAmC,MAAM,wBAAwB,CAAC;AAC7F,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,UAAU,MAAM;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,SAAS,CAAC;IAGrB,cAAc,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,OAAO,EAAE,OAAO,CAAC;IAEjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,0BAA0B,CAAC,EAAE,OAAO,CAAC;IAErC,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,kBAAkB,CAAC,EAAE,mBAAmB,CAAC;IACzC,cAAc,CAAC,EAAE,gBAAgB,CAAC;IAElC,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AA0BD,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,eA4CxC"}
|
|
@@ -31,13 +31,12 @@ const noResultFoundRow = (noResultString = '') => [
|
|
|
31
31
|
},
|
|
32
32
|
];
|
|
33
33
|
export function ManageTable(props) {
|
|
34
|
-
const { ariaLabel, errorComponent, errorTitle, errorVariant, isError, isFetching, sortInfo, actions, keepPageNumberOnDataChange, areActionsDisabled, actionResolver
|
|
35
|
-
const pagination = () => (props.pagination !== undefined ? props.pagination : true);
|
|
34
|
+
const { ariaLabel, errorComponent, errorTitle, errorVariant, isError, isFetching, sortInfo, actions, keepPageNumberOnDataChange, areActionsDisabled, actionResolver } = props, tableProps = __rest(props, ["ariaLabel", "errorComponent", "errorTitle", "errorVariant", "isError", "isFetching", "sortInfo", "actions", "keepPageNumberOnDataChange", "areActionsDisabled", "actionResolver"]);
|
|
36
35
|
return (React.createElement("div", { className: "table-wrapper" },
|
|
37
36
|
isError && (React.createElement(React.Fragment, null,
|
|
38
37
|
React.createElement(Alert, { variant: errorVariant, title: errorTitle, actionClose: React.createElement(AlertActionCloseButton, null) }, errorComponent))),
|
|
39
38
|
React.createElement(Table, Object.assign({}, tableProps),
|
|
40
|
-
React.createElement(PFTable, { sortInfo: sortInfo, "aria-label": ariaLabel, pagination:
|
|
41
|
-
tableProps.data.length > 0 &&
|
|
39
|
+
React.createElement(PFTable, { sortInfo: sortInfo, "aria-label": ariaLabel, pagination: true, emptyStateRow: noResultFoundRow(props.noResultText), actions: actions, areActionsDisabled: areActionsDisabled, actionResolver: actionResolver, isLoading: isFetching, keepPageNumberOnDataChange: keepPageNumberOnDataChange }),
|
|
40
|
+
tableProps.data.length > 0 && (React.createElement("footer", null,
|
|
42
41
|
React.createElement(TablePagination, { variant: PaginationVariant.bottom }))))));
|
|
43
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationEmailsModal.d.ts","sourceRoot":"","sources":["../../../../src/components/NotificationEmails/NotificationEmailsModal.tsx"],"names":[],"mappings":"AAiBA,UAAU,MAAM;IACZ,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACzE,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACtE,yBAAyB,EAAE,GAAG,CAAC;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,yBAAyB,EAAE,OAAO,CAAC;IACnC,UAAU,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,eAAO,MAAM,uBAAuB,UAAW,MAAM,
|
|
1
|
+
{"version":3,"file":"NotificationEmailsModal.d.ts","sourceRoot":"","sources":["../../../../src/components/NotificationEmails/NotificationEmailsModal.tsx"],"names":[],"mappings":"AAiBA,UAAU,MAAM;IACZ,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACzE,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACtE,yBAAyB,EAAE,GAAG,CAAC;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,yBAAyB,EAAE,OAAO,CAAC;IACnC,UAAU,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,eAAO,MAAM,uBAAuB,UAAW,MAAM,gBA8LpD,CAAC"}
|
|
@@ -36,6 +36,7 @@ export const NotificationEmailsModal = (props) => {
|
|
|
36
36
|
setSaveButtonIsClicked(false);
|
|
37
37
|
setIsEmailDuplicate(false);
|
|
38
38
|
};
|
|
39
|
+
// To check if email is valid
|
|
39
40
|
const checkEmailIsValid = (email) => !isEmpty(email) && isEmailValid(email);
|
|
40
41
|
const save = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
42
|
setSaveButtonIsClicked(true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AddNewCategoryDropDown.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/AddNewCategoryDropDown.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2DAA2D,CAAC;
|
|
1
|
+
{"version":3,"file":"AddNewCategoryDropDown.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/AddNewCategoryDropDown.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2DAA2D,CAAC;AAShG,UAAU,MAAM;IACZ,gBAAgB,EAAE,CAAC,GAAG,EAAE,mBAAmB,KAAK,IAAI,CAAC;CACxD;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,eA4EnD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import React, { useEffect } from 'react';
|
|
1
|
+
import { Select, SelectOption, SelectVariant } from '@patternfly/react-core';
|
|
2
|
+
import { ToastNotification } from '@rh-support/components';
|
|
3
|
+
import React, { useEffect, useState } from 'react';
|
|
4
4
|
import { Trans, useTranslation } from 'react-i18next';
|
|
5
5
|
import { useTopContentContext, useTopContentDispatchContext } from '../../../../context/TopContentProvider';
|
|
6
6
|
import { fetchCategories } from '../../../../reducers/TopContentReducer';
|
|
@@ -10,11 +10,29 @@ export function AddNewCategoryDropDown(props) {
|
|
|
10
10
|
const topContentDispatch = useTopContentDispatchContext();
|
|
11
11
|
const allAddedCategories = topContentEditState.map((cat) => cat.categoryName);
|
|
12
12
|
const availableCategories = categories.data.filter((category) => !(allAddedCategories || []).includes(category.categoryName));
|
|
13
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
14
|
+
const [selected, setSelected] = useState();
|
|
15
|
+
const getCategoryOptions = (options) => {
|
|
16
|
+
return options.map((category, id) => (React.createElement(SelectOption, { key: id, value: category }, category.categoryName)));
|
|
17
|
+
};
|
|
18
|
+
const onFilter = (_, value) => {
|
|
19
|
+
if (!value)
|
|
20
|
+
return getCategoryOptions(availableCategories);
|
|
21
|
+
const input = new RegExp(value, 'i');
|
|
22
|
+
const newOptions = availableCategories.filter((c) => input.test(c.categoryName));
|
|
23
|
+
return getCategoryOptions(newOptions);
|
|
24
|
+
};
|
|
25
|
+
const onToggle = (isExpanded) => {
|
|
26
|
+
setIsOpen(isExpanded);
|
|
27
|
+
};
|
|
28
|
+
const onSelect = (event, selection, isPlaceholder) => {
|
|
29
|
+
setSelected(selection);
|
|
30
|
+
props.onCategoryChange(selection);
|
|
31
|
+
onToggle(false);
|
|
32
|
+
};
|
|
13
33
|
const onClearCategory = () => {
|
|
14
34
|
props.onCategoryChange(undefined);
|
|
15
|
-
|
|
16
|
-
const onCategoryChange = (selectedItem) => {
|
|
17
|
-
props.onCategoryChange(selectedItem.value);
|
|
35
|
+
setSelected(undefined);
|
|
18
36
|
};
|
|
19
37
|
useEffect(() => {
|
|
20
38
|
try {
|
|
@@ -25,8 +43,9 @@ export function AddNewCategoryDropDown(props) {
|
|
|
25
43
|
}
|
|
26
44
|
}, [topContentDispatch, t]);
|
|
27
45
|
return (React.createElement("div", { className: "form-group add-new-category" },
|
|
28
|
-
React.createElement(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
46
|
+
React.createElement("label", { htmlFor: "new-category" },
|
|
47
|
+
React.createElement(Trans, null, "Category"),
|
|
48
|
+
' ',
|
|
49
|
+
React.createElement("span", { className: "form-required", "aria-hidden": true }, "*")),
|
|
50
|
+
React.createElement(Select, Object.assign({ variant: SelectVariant.typeahead, onToggle: onToggle, isOpen: isOpen, onClear: onClearCategory, onSelect: onSelect, onFilter: onFilter, selections: selected === null || selected === void 0 ? void 0 : selected.categoryName, placeholderText: t('Select an option or enter a new category') }, (categories.isFetching && { loadingVariant: 'spinner' }), { id: "new-category", "data-tracking-id": "new-category" }), getCategoryOptions(availableCategories))));
|
|
32
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"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":"AA4CA,wBAAgB,gBAAgB,gBAuT/B"}
|
|
@@ -25,6 +25,7 @@ import { TopContentHeader } from '../TopContentHeader';
|
|
|
25
25
|
import { TopContentProductVersionSelector } from '../TopContentProductVersionSelector';
|
|
26
26
|
import { TopContentCategory } from './TopContentCategoryContent/TopContentCategory';
|
|
27
27
|
import { TopContentCategoryNew } from './TopContentCategoryContent/TopContentCategoryNew';
|
|
28
|
+
import { TopContentSuggestion } from './TopContentSuggestion/TopContentSuggestion';
|
|
28
29
|
export function TopContentEditor() {
|
|
29
30
|
const { t } = useTranslation();
|
|
30
31
|
const [categoryToOpen, setCategoryToOpen] = useState(null);
|
|
@@ -112,7 +113,8 @@ export function TopContentEditor() {
|
|
|
112
113
|
!topContentResponse.isFetching && topContentResponse.isError && (React.createElement(Alert, { isInline: true, variant: AlertVariant.danger, title: React.createElement(Trans, null, "Error loading Top Content") })),
|
|
113
114
|
React.createElement(TopContentProductVersionSelector, { selectedProduct: selectedProduct, selectedVersion: selectedVersion, onProductChange: onProductChange, onVersionChange: onVersionChange }),
|
|
114
115
|
!topContentResponse.isFetching && (React.createElement(TopContentSearch, { dataTrackingId: "top-content-filter-manage", topContentData: flagContentEditState, onSearch: onSearch, topContentResultsWrapperRef: topContentResultsRef })),
|
|
115
|
-
React.createElement("div", { className: "top-content-manage-wrapper" },
|
|
116
|
+
React.createElement("div", { className: "top-content-manage-wrapper pf-u-pt-md" },
|
|
117
|
+
!topContentResponse.isFetching && !!filteredTC.length && React.createElement(TopContentSuggestion, null),
|
|
116
118
|
topContentResponse.isFetching ? (React.createElement(Bullseye, null,
|
|
117
119
|
React.createElement(EmptyState, { variant: EmptyStateVariant.full },
|
|
118
120
|
React.createElement(Spinner, { size: "lg" })))) : (!topContentResponse.isFetching &&
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TopContentSuggestion.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestion.tsx"],"names":[],"mappings":"AAEA,OAAc,EAAE,EAAE,EAAuB,MAAM,OAAO,CAAC;AAOvD,UAAU,MAAM;CAAG;AAEnB,eAAO,MAAM,oBAAoB,EAAE,EAAE,CAAC,MAAM,CA6C3C,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ExpandableSection, Panel, PanelMain, PanelMainBody, Title } from '@patternfly/react-core';
|
|
2
|
+
import { isEmpty } from 'lodash';
|
|
3
|
+
import React, { useEffect, useState } from 'react';
|
|
4
|
+
import { Trans } from 'react-i18next';
|
|
5
|
+
import { useTopContentContext, useTopContentDispatchContext } from '../../../../context/TopContentProvider';
|
|
6
|
+
import { fetchTopContentSuggestions } from '../../../../reducers/TopContentReducer';
|
|
7
|
+
import { TopContentSuggestionHint } from './TopContentSuggestionHint';
|
|
8
|
+
export const TopContentSuggestion = () => {
|
|
9
|
+
var _a;
|
|
10
|
+
const [isExpanded, setExpanded] = useState(false);
|
|
11
|
+
const onToggle = () => setExpanded((previousExpandedState) => !previousExpandedState);
|
|
12
|
+
const { selectedProduct, selectedVersion, suggestion, topContentResponse } = useTopContentContext();
|
|
13
|
+
const topContentDispatch = useTopContentDispatchContext();
|
|
14
|
+
const topContent = topContentResponse.data.reduce((ret, category) => {
|
|
15
|
+
return [...ret, ...category.content];
|
|
16
|
+
}, []);
|
|
17
|
+
const filteredSuggestion = (_a = suggestion.linkedResources) === null || _a === void 0 ? void 0 : _a.filter((resource) => !topContent.some((content) => content.contentUrl === resource.resourceViewUri));
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if ((selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.name) && selectedVersion) {
|
|
20
|
+
fetchTopContentSuggestions(topContentDispatch, selectedProduct.name, selectedVersion);
|
|
21
|
+
}
|
|
22
|
+
}, [topContentDispatch, selectedProduct, selectedVersion]);
|
|
23
|
+
if (isEmpty(filteredSuggestion))
|
|
24
|
+
return React.createElement(React.Fragment, null);
|
|
25
|
+
return (React.createElement(Panel, { variant: "raised", className: "pf-u-mx-md pf-u-p-md top-content-panel" },
|
|
26
|
+
React.createElement(PanelMain, null,
|
|
27
|
+
React.createElement(PanelMainBody, null,
|
|
28
|
+
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" }, filteredSuggestion === null || filteredSuggestion === void 0 ? void 0 : filteredSuggestion.map((resources) => (React.createElement(TopContentSuggestionHint, { key: resources.id, resources: resources }))))))));
|
|
30
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ITopContentResource } from '@cee-eng/hydrajs/@types/models/topContent/topContentModel';
|
|
2
|
+
import { FC } from 'react';
|
|
3
|
+
interface IProps {
|
|
4
|
+
resources: ITopContentResource;
|
|
5
|
+
}
|
|
6
|
+
export declare const TopContentSuggestionHint: FC<IProps>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=TopContentSuggestionHint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TopContentSuggestionHint.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestionHint.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2DAA2D,CAAC;AAGhG,OAAc,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AAM5C,UAAU,MAAM;IACZ,SAAS,EAAE,mBAAmB,CAAC;CAClC;AAED,eAAO,MAAM,wBAAwB,EAAE,EAAE,CAAC,MAAM,CAuE/C,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { Button, ButtonVariant, Card, CardBody, Truncate } from '@patternfly/react-core';
|
|
11
|
+
import { ToastNotification, useConfirmation } from '@rh-support/components';
|
|
12
|
+
import React, { useState } from 'react';
|
|
13
|
+
import { Trans, useTranslation } from 'react-i18next';
|
|
14
|
+
import { useTopContentContext, useTopContentDispatchContext } from '../../../../context/TopContentProvider';
|
|
15
|
+
import { deleteTopContentSuggestion } from '../../../../reducers/TopContentReducer';
|
|
16
|
+
import { TopContentSuggestionHintAccept } from './TopContentSuggestionHintAccept';
|
|
17
|
+
export const TopContentSuggestionHint = ({ resources }) => {
|
|
18
|
+
const { t } = useTranslation();
|
|
19
|
+
const [isAccepted, setAccepted] = useState(false);
|
|
20
|
+
const [isRemoving, setIsRemoving] = useState(false);
|
|
21
|
+
const confirmation = useConfirmation();
|
|
22
|
+
const { suggestion } = useTopContentContext();
|
|
23
|
+
const topContentDispatch = useTopContentDispatchContext();
|
|
24
|
+
const ignoreModalContent = (React.createElement(React.Fragment, null,
|
|
25
|
+
React.createElement("h2", null,
|
|
26
|
+
React.createElement(Trans, null, "Are you sure?")),
|
|
27
|
+
React.createElement("p", null,
|
|
28
|
+
React.createElement(Trans, null, "Removing this suggestion will permanently delete it."))));
|
|
29
|
+
const onIgnore = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
+
try {
|
|
31
|
+
try {
|
|
32
|
+
yield confirmation({
|
|
33
|
+
catchOnCancel: true,
|
|
34
|
+
confirmText: t('Yes, I am sure'),
|
|
35
|
+
confirmButtonVariant: ButtonVariant.danger,
|
|
36
|
+
description: ignoreModalContent,
|
|
37
|
+
});
|
|
38
|
+
setIsRemoving(true);
|
|
39
|
+
yield deleteTopContentSuggestion(topContentDispatch, suggestion, resources.id);
|
|
40
|
+
ToastNotification.addSuccessMessage(t('Suggestion successfully removed'));
|
|
41
|
+
}
|
|
42
|
+
catch (_a) {
|
|
43
|
+
// user didn't confirm the ignore action
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch (_b) {
|
|
47
|
+
ToastNotification.addDangerMessage(t('Failed to remove suggestion'));
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
setIsRemoving(false);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
return !isAccepted ? (React.createElement(Card, { className: "pf-u-m-sm card-hint" },
|
|
54
|
+
React.createElement(CardBody, { className: "card-body" },
|
|
55
|
+
React.createElement("span", { className: "hint-title", "data-testid": "suggestion-content-title" },
|
|
56
|
+
React.createElement(Truncate, { content: resources === null || resources === void 0 ? void 0 : resources.resourceTitle })),
|
|
57
|
+
React.createElement("span", { className: "pf-u-float-right" },
|
|
58
|
+
React.createElement(Button, { variant: "link", isInline: true, className: "pf-u-mr-xl", onClick: () => setAccepted(true), title: "Accept" },
|
|
59
|
+
React.createElement("b", null,
|
|
60
|
+
React.createElement(Trans, null, "Accept"))),
|
|
61
|
+
React.createElement(Button, { variant: "link", isInline: true, onClick: onIgnore, isDisabled: isRemoving },
|
|
62
|
+
React.createElement("b", null,
|
|
63
|
+
React.createElement(Trans, null, "Ignore"))))))) : (React.createElement(TopContentSuggestionHintAccept, { onCancel: setAccepted, resources: resources }));
|
|
64
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ITopContentResource } from '@cee-eng/hydrajs/@types/models/topContent/topContentModel';
|
|
2
|
+
import { FC } from 'react';
|
|
3
|
+
interface IProps {
|
|
4
|
+
onCancel: (isAccepted: boolean) => void;
|
|
5
|
+
resources: ITopContentResource;
|
|
6
|
+
}
|
|
7
|
+
export declare const TopContentSuggestionHintAccept: FC<IProps>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=TopContentSuggestionHintAccept.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TopContentSuggestionHintAccept.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestionHintAccept.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAuB,mBAAmB,EAAE,MAAM,2DAA2D,CAAC;AAkBrH,OAAc,EAAE,EAAE,EAAgC,MAAM,OAAO,CAAC;AAgBhE,UAAU,MAAM;IACZ,QAAQ,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,SAAS,EAAE,mBAAmB,CAAC;CAClC;AAED,eAAO,MAAM,8BAA8B,EAAE,EAAE,CAAC,MAAM,CAkPrD,CAAC"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { Button, Card, CardBody, Form, FormGroup, Select, SelectOption, SelectVariant, TextInput, Tooltip, ValidatedOptions, } from '@patternfly/react-core';
|
|
11
|
+
import PencilAltIcon from '@patternfly/react-icons/dist/js/icons/pencil-alt-icon';
|
|
12
|
+
import { ToastNotification } from '@rh-support/components';
|
|
13
|
+
import { getVersion, isRegularVersion, isValidUrl } from '@rh-support/utils';
|
|
14
|
+
import { isEmpty, isUndefined, trim } from 'lodash';
|
|
15
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
16
|
+
import { Trans, useTranslation } from 'react-i18next';
|
|
17
|
+
import { CATEGORY_LIMIT } from '../../../../constants/TopContent';
|
|
18
|
+
import { useTopContentContext, useTopContentDispatchContext } from '../../../../context/TopContentProvider';
|
|
19
|
+
import { flagContentUsage } from '../../../../reducers/TopContentHelpers';
|
|
20
|
+
import { ContentMode, deleteTopContentSuggestion, fetchCategories, saveAddedNewSectionContents, saveAddToTopContent, } from '../../../../reducers/TopContentReducer';
|
|
21
|
+
import CategoryLimit from '../../CategoryLimit/CategoryLimit';
|
|
22
|
+
export const TopContentSuggestionHintAccept = ({ onCancel, resources }) => {
|
|
23
|
+
const { t } = useTranslation();
|
|
24
|
+
const { categories, topContentResponse, topContentEditState, selectedProduct, selectedVersion, isCatOnlyForMajorVersion, isAddingCategory, suggestion, categoryUsage, } = useTopContentContext();
|
|
25
|
+
const topContentDispatch = useTopContentDispatchContext();
|
|
26
|
+
const [isSelectOpen, setSelectOpen] = useState(false);
|
|
27
|
+
const [selected, setSelected] = useState();
|
|
28
|
+
const [isSaving, setIsSaving] = useState(false);
|
|
29
|
+
const [resourceTitle, setResourceTitle] = useState('');
|
|
30
|
+
const [linkToContent, setLinkToContent] = useState('');
|
|
31
|
+
const [isEditClicked, setIsEditClicked] = useState(false);
|
|
32
|
+
const categoryToSave = useMemo(() => topContentEditState.find((category) => category.categoryId === (selected === null || selected === void 0 ? void 0 : selected.id)), [topContentEditState, selected]);
|
|
33
|
+
const flagContentEditState = useMemo(() => flagContentUsage(topContentEditState, categoryUsage, selectedVersion), [topContentEditState, categoryUsage, selectedVersion]);
|
|
34
|
+
const isMajorVersionOnly = isUndefined(getVersion(selectedVersion).minor);
|
|
35
|
+
const minorSelectedNoMinorContentButAvailableMajorContent = !topContentResponse.isFetching &&
|
|
36
|
+
!isEmpty(topContentResponse.data) &&
|
|
37
|
+
getVersion(selectedVersion).minor &&
|
|
38
|
+
isRegularVersion(selectedVersion) &&
|
|
39
|
+
isCatOnlyForMajorVersion &&
|
|
40
|
+
!isAddingCategory;
|
|
41
|
+
const isCategoryLimitReached = (minorSelectedNoMinorContentButAvailableMajorContent ? [] : flagContentEditState).length >= CATEGORY_LIMIT.MAX;
|
|
42
|
+
const isCategoryInList = flagContentEditState.some((c) => c.categoryId === (selected === null || selected === void 0 ? void 0 : selected.id));
|
|
43
|
+
const onToggle = () => {
|
|
44
|
+
setSelectOpen((previousToggleState) => !previousToggleState);
|
|
45
|
+
};
|
|
46
|
+
const onSelect = (event, selection, isPlaceholder) => {
|
|
47
|
+
setSelected(selection);
|
|
48
|
+
onToggle();
|
|
49
|
+
};
|
|
50
|
+
const isDisabled = isEmpty(linkToContent) ||
|
|
51
|
+
isEmpty(trim(resourceTitle)) ||
|
|
52
|
+
isUndefined(selected) ||
|
|
53
|
+
!isValidUrl(linkToContent) ||
|
|
54
|
+
(isCategoryLimitReached && !isCategoryInList);
|
|
55
|
+
const addContentToCategory = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
56
|
+
try {
|
|
57
|
+
setIsSaving(true);
|
|
58
|
+
const newContent = {
|
|
59
|
+
contentTitle: resourceTitle,
|
|
60
|
+
contentRank: categoryToSave === null || categoryToSave === void 0 ? void 0 : categoryToSave.content.length,
|
|
61
|
+
contentUrl: linkToContent,
|
|
62
|
+
mode: ContentMode.ADD,
|
|
63
|
+
};
|
|
64
|
+
yield saveAddToTopContent(topContentDispatch, topContentEditState, categoryToSave.id, categoryToSave === null || categoryToSave === void 0 ? void 0 : categoryToSave.categoryId, newContent, -1);
|
|
65
|
+
yield deleteTopContentSuggestion(topContentDispatch, suggestion, resources.id);
|
|
66
|
+
ToastNotification.addSuccessMessage(t('Content has been successfully added'));
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
ToastNotification.addDangerMessage(t('Failed to save top content'));
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
setIsSaving(false);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
const addContentToNewCategory = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
76
|
+
try {
|
|
77
|
+
setIsSaving(true);
|
|
78
|
+
const newContent = {
|
|
79
|
+
contentTitle: resourceTitle,
|
|
80
|
+
contentUrl: linkToContent,
|
|
81
|
+
isAttentionNeeded: false,
|
|
82
|
+
mode: ContentMode.NEW_SECTION_CONTENT,
|
|
83
|
+
};
|
|
84
|
+
yield saveAddedNewSectionContents(topContentDispatch, topContentEditState, selected, selectedProduct, selectedVersion, isMajorVersionOnly, newContent, minorSelectedNoMinorContentButAvailableMajorContent);
|
|
85
|
+
yield deleteTopContentSuggestion(topContentDispatch, suggestion, resources.id);
|
|
86
|
+
ToastNotification.addSuccessMessage(t('Content has been successfully added'));
|
|
87
|
+
}
|
|
88
|
+
catch (e) {
|
|
89
|
+
ToastNotification.addDangerMessage(t('Failed to save top content'));
|
|
90
|
+
}
|
|
91
|
+
finally {
|
|
92
|
+
setIsSaving(false);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
const onSaveContent = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
96
|
+
if (minorSelectedNoMinorContentButAvailableMajorContent || isUndefined(categoryToSave)) {
|
|
97
|
+
// if top contents are available for major version only or if selected category is not present
|
|
98
|
+
// for this version then create a new category
|
|
99
|
+
addContentToNewCategory();
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
//otherwise get and push to existing category
|
|
103
|
+
addContentToCategory();
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
setResourceTitle(resources.resourceTitle);
|
|
108
|
+
setLinkToContent(resources.resourceViewUri);
|
|
109
|
+
}, [resources.resourceTitle, resources.resourceViewUri]);
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
try {
|
|
112
|
+
fetchCategories(topContentDispatch);
|
|
113
|
+
}
|
|
114
|
+
catch (_a) {
|
|
115
|
+
ToastNotification.addDangerMessage(t('There was an error loading top content categories'));
|
|
116
|
+
}
|
|
117
|
+
}, [topContentDispatch, t]);
|
|
118
|
+
return (React.createElement(Card, { className: "pf-u-m-sm" },
|
|
119
|
+
React.createElement(CardBody, { className: "card-hint" },
|
|
120
|
+
React.createElement(Form, null,
|
|
121
|
+
isEditClicked ? (React.createElement(React.Fragment, null,
|
|
122
|
+
React.createElement(FormGroup, { label: t('Link to content'), isRequired: true, fieldId: "top-content-link" },
|
|
123
|
+
React.createElement(TextInput, { isRequired: true, type: "text", id: "top-content-resource-link", name: "top-content-resource-link", "data-tracking-id": "top-content-resource-link", value: linkToContent, onChange: setLinkToContent, validated: isEmpty(linkToContent) || !isValidUrl(linkToContent)
|
|
124
|
+
? ValidatedOptions.error
|
|
125
|
+
: ValidatedOptions.default })),
|
|
126
|
+
React.createElement(FormGroup, { label: t('Headline'), isRequired: true, fieldId: "simple-form-email-01" },
|
|
127
|
+
React.createElement(TextInput, { isRequired: true, type: "text", id: "top-content-headline-category", name: "top-content-headline-category", "data-tracking-id": "top-content-headline-category", value: resourceTitle, onChange: setResourceTitle, validated: isEmpty(trim(resourceTitle)) ? ValidatedOptions.error : ValidatedOptions.default })))) : (React.createElement("span", null,
|
|
128
|
+
React.createElement(Button, { variant: "link", isInline: true },
|
|
129
|
+
React.createElement("u", null,
|
|
130
|
+
React.createElement("a", { className: "hint-title pf-u-font-size-md", target: "_blank", href: linkToContent, rel: "noreferrer" }, resources.resourceTitle))),
|
|
131
|
+
React.createElement(Tooltip, { content: t('Edit Link to content and Headline'), position: "top" },
|
|
132
|
+
React.createElement(Button, { variant: "link", icon: React.createElement(PencilAltIcon, null), onClick: () => setIsEditClicked((pre) => !pre) })))),
|
|
133
|
+
React.createElement(FormGroup, { label: t('Category'), isRequired: true, fieldId: "simple-form-email-01" },
|
|
134
|
+
React.createElement(Select, Object.assign({ variant: SelectVariant.single, id: "category-selection", name: "category-selection", "data-testid": "category-selection", placeholderText: "Select a category", onToggle: onToggle, isOpen: isSelectOpen, onSelect: onSelect, selections: selected === null || selected === void 0 ? void 0 : selected.categoryName, isDisabled: categories.isError, loadingVariant: 'spinner' }, (categories.isFetching && { loadingVariant: 'spinner' })), categories.data.map((category, id) => (React.createElement(SelectOption, { key: id, value: category },
|
|
135
|
+
React.createElement("div", null, category.categoryName)))))),
|
|
136
|
+
React.createElement("div", { className: "pf-u-mt-sm" },
|
|
137
|
+
isCategoryLimitReached && !isCategoryInList && !isUndefined(selected) && React.createElement(CategoryLimit, null),
|
|
138
|
+
React.createElement(Button, { variant: "primary", onClick: onSaveContent, isDisabled: isSaving || isDisabled, isLoading: isSaving, "data-tracking-id": "suggested-content-save-button" },
|
|
139
|
+
React.createElement(Trans, null, "Save")),
|
|
140
|
+
React.createElement(Button, { variant: "link", onClick: () => onCancel(false) },
|
|
141
|
+
React.createElement(Trans, null, "Cancel")))))));
|
|
142
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TopContentProductVersionSelector.d.ts","sourceRoot":"","sources":["../../../../src/components/TopContentManagement/TopContentProductVersionSelector.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"TopContentProductVersionSelector.d.ts","sourceRoot":"","sources":["../../../../src/components/TopContentManagement/TopContentProductVersionSelector.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAGnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAS5D,UAAU,MAAO,SAAQ,gBAAgB;IACrC,eAAe,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IACxC,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC;IAC3D,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,SAAS,EAAE,MAAM,CAAC;CACrB;AAQD,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,aAAa,CAAC,MAAM,EAAE,CAAC,2BAG1E;AAqBD,iBAAS,gCAAgC,CAAC,KAAK,EAAE,MAAM,eAsItD;kBAtIQ,gCAAgC;;;AAyIzC,OAAO,EAAE,gCAAgC,EAAE,CAAC"}
|