Skip to content

Commit 55cd68f

Browse files
authored
refactor(HMS 4849): Remove/update features to support new content templates (#1208)
* chore(deps): Updating FEC and related packages * Feedback from review * HMS 4849: Remove/update features to support new content templates * Add content/templates redirect
1 parent e4e70f6 commit 55cd68f

File tree

13 files changed

+157
-144
lines changed

13 files changed

+157
-144
lines changed

src/Routes.js

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,17 @@ const PackageDetail = lazy(() =>
6060
)
6161
);
6262

63-
const Templates = lazy(() =>
64-
import(
65-
/* webpackChunkName: "Templates" */ './SmartComponents/PatchSet/PatchSet'
66-
)
67-
);
68-
69-
const TemplateDetail = lazy(() =>
70-
import(
71-
/* webpackChunkName: "TemplateDetail" */ './SmartComponents/PatchSetDetail/PatchSetDetail'
72-
)
73-
);
63+
// const Templates = lazy(() =>
64+
// import(
65+
// /* webpackChunkName: "Templates" */ './SmartComponents/PatchSet/PatchSet'
66+
// )
67+
// );
68+
69+
// const TemplateDetail = lazy(() =>
70+
// import(
71+
// /* webpackChunkName: "TemplateDetail" */ './SmartComponents/PatchSetDetail/PatchSetDetail'
72+
// )
73+
// );
7474

7575
const PatchRoutes = () => {
7676
const generalPermissions = ['patch:*:*', 'patch:*:read'];
@@ -121,8 +121,16 @@ const PatchRoutes = () => {
121121
<Route path='/packages/:packageName' element={<PackageDetail />} />
122122
<Route path='/packages/:packageName/:inventoryId'
123123
element={<NavigateToSystem />} />
124-
<Route path='/templates' element={<Templates />} />
125-
<Route path='/templates/:templateName' element={<TemplateDetail />} />
124+
<Route path='/templates' >
125+
<Route path='' element={
126+
<Navigate relative="route" to={'/insights/content/templates'} replace />
127+
} />
128+
<Route path='*' element={
129+
<Navigate relative="route" to={'/insights/content/templates'} replace /> }
130+
/>
131+
</Route>
132+
{/* <Route path='/templates' element={<Templates />} />
133+
<Route path='/templates/:templateName' element={<TemplateDetail />} /> */}
126134
<Route path='*' element={<Navigate to="advisories" />} />
127135
</Route>
128136
</Routes>

src/SmartComponents/AdvisorySystems/AdvisorySystemsTable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ const AdvisorySystemsTable = ({
125125
}}
126126
getEntities={getEntites}
127127
tableProps={{
128-
actionResolver: (row) => systemsRowActions(activateRemediationModal, undefined, undefined, row),
128+
actionResolver: (row) => systemsRowActions(activateRemediationModal, row),
129129
canSelectAll: false,
130130
variant: TableVariant.compact, className: 'patchCompactInventory', isStickyHeader: true
131131
}}

src/SmartComponents/Modals/Helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const filterChosenSystems = (urlFilter, systemsIDs, fetchBatched, totalItems) =>
2626
};
2727

2828
export const filterSystemsWithoutSets = (systemsIDs, fetchBatched, totalItems) => {
29-
const urlFilter = { 'filter[baseline_name]': 'neq:' };
29+
const urlFilter = { 'filter[template_name]': 'neq:' };
3030
return filterChosenSystems(urlFilter, systemsIDs, fetchBatched, totalItems);
3131
};
3232

src/SmartComponents/PatchSetWizard/WizardAssets.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const reviewSystemColumns = [{
2525
transforms: [sortable]
2626
},
2727
{
28-
key: 'baseline_name',
28+
key: 'template_name',
2929
title: 'Template',
3030
props: {
3131
width: 20

src/SmartComponents/SystemDetail/InventoryDetail.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,21 @@ import { useParams } from 'react-router-dom';
1717
import SystemDetail from './SystemDetail';
1818
import { useChrome } from '@redhat-cloud-services/frontend-components/useChrome';
1919
import { InsightsLink } from '@redhat-cloud-services/frontend-components/InsightsLink';
20-
import { usePermissionsWithContext } from '@redhat-cloud-services/frontend-components-utilities/RBACHook';
2120

2221
const InventoryDetail = () => {
2322
const { inventoryId } = useParams();
2423
const store = useStore();
2524
const dispatch = useDispatch();
2625

27-
const { hasThirdPartyRepo, satelliteManaged, patchSetName, patchSetId } = useSelector(
26+
const { hasThirdPartyRepo, satelliteManaged, patchSetName, templateUUID } = useSelector(
2827
({ SystemDetailStore }) => SystemDetailStore
2928
);
3029

3130
const { display_name: displayName } = useSelector(
3231
({ entityDetails }) => entityDetails?.entity ?? {}
3332
);
3433

35-
const { patchSetState, setPatchSetState, openAssignSystemsModal, openUnassignSystemsModal } = usePatchSetState();
34+
const { patchSetState, setPatchSetState /*,openAssignSystemsModal, openUnassignSystemsModal */ } = usePatchSetState();
3635

3736
useEffect(() => {
3837
dispatch(fetchSystemDetailsAction(inventoryId));
@@ -53,10 +52,10 @@ const InventoryDetail = () => {
5352
displayName && chrome.updateDocumentTitle(`${displayName} - Systems - Patch | RHEL`, true);
5453
}, [chrome, displayName]);
5554

56-
const { hasAccess: hasTemplateAccess } = usePermissionsWithContext([
57-
'patch:*:*',
58-
'patch:template:write'
59-
]);
55+
// const { hasAccess: hasTemplateAccess } = usePermissionsWithContext([
56+
// 'patch:*:*',
57+
// 'patch:template:write'
58+
// ]);
6059

6160
return (
6261
<DetailWrapper
@@ -89,27 +88,28 @@ const InventoryDetail = () => {
8988
showTags
9089
inventoryId={inventoryId}
9190
actions={[
92-
{
93-
title: intl.formatMessage(messages.titlesTemplateAssign),
94-
key: 'assign-to-template',
95-
isDisabled: !hasTemplateAccess || satelliteManaged,
96-
onClick: () => openAssignSystemsModal({ [inventoryId]: true })
97-
},
98-
{
99-
title: intl.formatMessage(messages.titlesTemplateRemoveMultipleButton),
100-
key: 'remove-from-template',
101-
isDisabled: !hasTemplateAccess || !patchSetName || satelliteManaged,
102-
onClick: () => openUnassignSystemsModal([inventoryId])
103-
}]}
91+
// {
92+
// title: intl.formatMessage(messages.titlesTemplateAssign),
93+
// key: 'assign-to-template',
94+
// isDisabled: !hasTemplateAccess || satelliteManaged,
95+
// onClick: () => openAssignSystemsModal({ [inventoryId]: true })
96+
// },
97+
// {
98+
// title: intl.formatMessage(messages.titlesTemplateRemoveMultipleButton),
99+
// key: 'remove-from-template',
100+
// isDisabled: !hasTemplateAccess || !patchSetName || satelliteManaged,
101+
// onClick: () => openUnassignSystemsModal([inventoryId])
102+
// }
103+
]}
104104
//FIXME: remove this prop after inventory detail gets rid of activeApps in redux
105105
appList={[]}
106106
>
107107
<Grid>
108108
{patchSetName && <GridItem>
109109
<TextContent>
110110
<Text>
111-
{intl.formatMessage(messages.labelsColumnsTemplate)}:
112-
<InsightsLink to={`/templates/${patchSetId}`} className="pf-v5-u-ml-xs">
111+
{intl.formatMessage(messages.labelsColumnsTemplate)}:{' '}
112+
<InsightsLink app="content" to={{ pathname: `/templates/${templateUUID}/details` }}>
113113
{patchSetName}
114114
</InsightsLink>
115115
</Text>

src/SmartComponents/Systems/SystemListAssets.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ describe('SystemListAssets.js', () => {
6767
});
6868
it('Should disable "Apply all applicable advisories" action when there is no applicable advisories ', () => {
6969
const testRow = { applicable_advisories: [0, 0, 0, 0] };
70-
const actions = systemsRowActions(null, null, null, testRow);
70+
const actions = systemsRowActions(null, testRow);
7171
expect(actions).toEqual(
7272
[{ isDisabled: true, onClick: expect.any(Function), title: 'Apply all applicable advisories' }]
7373
);

src/SmartComponents/Systems/SystemTable.test.js

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -181,36 +181,36 @@ describe('SystemsTable', () => {
181181
));
182182
});
183183

184-
it('should provide actions config', async () => {
185-
await renderComponent(mockState);
186-
expect(InventoryTable).toHaveBeenCalledWith(
187-
expect.objectContaining({
188-
actionsConfig: {
189-
actions: [
190-
//Remdiation button
191-
expect.anything(),
192-
{
193-
key: 'assign-multiple-systems',
194-
label: 'Assign to a template',
195-
onClick: expect.any(Function),
196-
props: {
197-
isDisabled: true
198-
}
199-
},
200-
{
201-
key: 'remove-multiple-systems',
202-
label: 'Remove from a template',
203-
onClick: expect.any(Function),
204-
props: {
205-
isDisabled: true
206-
}
207-
}
208-
]
209-
}
210-
}),
211-
{}
212-
);
213-
});
184+
// it('should provide actions config', async () => {
185+
// await renderComponent(mockState);
186+
// expect(InventoryTable).toHaveBeenCalledWith(
187+
// expect.objectContaining({
188+
// actionsConfig: {
189+
// actions: [
190+
// //Remdiation button
191+
// expect.anything(),
192+
// {
193+
// key: 'assign-multiple-systems',
194+
// label: 'Assign to a template',
195+
// onClick: expect.any(Function),
196+
// props: {
197+
// isDisabled: true
198+
// }
199+
// },
200+
// {
201+
// key: 'remove-multiple-systems',
202+
// label: 'Remove from a template',
203+
// onClick: expect.any(Function),
204+
// props: {
205+
// isDisabled: true
206+
// }
207+
// }
208+
// ]
209+
// }
210+
// }),
211+
// {}
212+
// );
213+
// });
214214

215215
it('should provide activeFilters config', async () => {
216216
await renderComponent(mockState);

src/SmartComponents/Systems/SystemsListAssets.js

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@ export const systemsListColumns = () => [
3131
}
3232
},
3333
{
34-
key: 'baseline_name',
34+
key: 'template_name',
3535
title: 'Template',
3636
renderFunc: (value, _, row) =>
3737
row.satellite_managed
3838
? <ManagedBySatelliteCell />
3939
: value
40-
? <InsightsLink to={{ pathname: `/templates/${row.baseline_id}` }}>{value}</InsightsLink>
40+
? <InsightsLink app="content" to={{ pathname: `/templates/${row.template_uuid}/details` }}>
41+
{value}
42+
</InsightsLink>
4143
: 'No template',
4244
props: {
4345
width: 5
@@ -71,13 +73,15 @@ export const advisorySystemsColumns = () => [
7173
}
7274
},
7375
{
74-
key: 'baseline_name',
76+
key: 'template_name',
7577
title: 'Template',
7678
renderFunc: (value, _, row) =>
7779
row.satellite_managed
7880
? <ManagedBySatelliteCell />
7981
: value
80-
? <InsightsLink to={{ pathname: `/templates/${row.baseline_id}` }}>{value}</InsightsLink>
82+
? <InsightsLink app="content" to={{ pathname: `/templates/${row.template_uuid}/details` }}>
83+
{value}
84+
</InsightsLink>
8185
: 'No template',
8286
props: {
8387
width: 5
@@ -104,13 +108,15 @@ export const packageSystemsColumns = [
104108
}
105109
},
106110
{
107-
key: 'baseline_name',
111+
key: 'template_name',
108112
title: 'Template',
109113
renderFunc: (value, _, row) =>
110114
row.satellite_managed
111115
? <ManagedBySatelliteCell />
112116
: value
113-
? <InsightsLink to={{ pathname: `/templates/${row.baseline_id}` }}>{value}</InsightsLink>
117+
? <InsightsLink app="content" to={{ pathname: `/templates/${row.template_uuid}/details` }}>
118+
{value}
119+
</InsightsLink>
114120
: 'No template',
115121
props: {
116122
width: 5
@@ -147,10 +153,10 @@ const isRemediationDisabled = (row) => {
147153
return (applicableAdvisories && applicableAdvisories.every(typeSum => typeSum === 0)) || (status === 'Applicable');
148154
};
149155

150-
const isPatchSetRemovalDisabled = (row) => {
151-
const { baseline_name: baselineName } = row || {};
152-
return !baselineName || (typeof baselineName === 'string' && baselineName === '');
153-
};
156+
// const isPatchSetRemovalDisabled = (row) => {
157+
// const { template_name: templateName } = row || {};
158+
// return !templateName || (typeof templateName === 'string' && templateName === '');
159+
// };
154160

155161
export const useActivateRemediationModal = (setRemediationIssues, setRemediationOpen) => {
156162
const { fetchBatched } = useFetchBatched();
@@ -190,10 +196,10 @@ export const useActivateRemediationModal = (setRemediationIssues, setRemediation
190196

191197
export const systemsRowActions = (
192198
activateRemediationModal,
193-
showTemplateAssignSystemsModal,
194-
openUnassignSystemsModal,
195-
row,
196-
hasTemplateAccess
199+
// showTemplateAssignSystemsModal,
200+
// openUnassignSystemsModal,
201+
row
202+
// hasTemplateAccess
197203
) => {
198204
return [
199205
{
@@ -202,22 +208,22 @@ export const systemsRowActions = (
202208
onClick: (event, rowId, rowData) => {
203209
activateRemediationModal(rowData);
204210
}
205-
},
206-
...(showTemplateAssignSystemsModal ? [{
207-
title: 'Assign to a template',
208-
isDisabled: !hasTemplateAccess || row.satellite_managed,
209-
onClick: (event, rowId, rowData) => {
210-
showTemplateAssignSystemsModal({ [rowData.id]: true });
211-
}
212-
},
213-
{
214-
title: 'Remove from a template',
215-
isDisabled: !hasTemplateAccess || isPatchSetRemovalDisabled(row) || row.satellite_managed,
216-
onClick: (event, rowId, rowData) => {
217-
openUnassignSystemsModal([rowData.id]);
218-
}
219211
}
220-
] : [])
212+
// ...(showTemplateAssignSystemsModal ? [{
213+
// title: 'Assign to a template',
214+
// isDisabled: !hasTemplateAccess || row.satellite_managed,
215+
// onClick: (event, rowId, rowData) => {
216+
// showTemplateAssignSystemsModal({ [rowData.id]: true });
217+
// }
218+
// },
219+
// {
220+
// title: 'Remove from a template',
221+
// isDisabled: !hasTemplateAccess || isPatchSetRemovalDisabled(row) || row.satellite_managed,
222+
// onClick: (event, rowId, rowData) => {
223+
// openUnassignSystemsModal([rowData.id]);
224+
// }
225+
// }
226+
// ] : [])
221227
];
222228
};
223229

src/SmartComponents/Systems/SystemsMainContent.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const SystemsMainContent = () => {
4343
}, []);
4444

4545
const {
46-
patchSetState, setPatchSetState, openUnassignSystemsModal, openAssignSystemsModal
46+
patchSetState, setPatchSetState// openUnassignSystemsModal, openAssignSystemsModal
4747
} = usePatchSetState(selectedRows);
4848

4949
const activateRemediationModal = useActivateRemediationModal(
@@ -75,8 +75,8 @@ const SystemsMainContent = () => {
7575
<SystemsTable
7676
apply={apply}
7777
patchSetState={patchSetState}
78-
openAssignSystemsModal={openAssignSystemsModal}
79-
openUnassignSystemsModal={openUnassignSystemsModal}
78+
// openAssignSystemsModal={openAssignSystemsModal}
79+
// openUnassignSystemsModal={openUnassignSystemsModal}
8080
setSearchParams={setSearchParams}
8181
activateRemediationModal={activateRemediationModal}
8282
decodedParams={decodeQueryparams}

0 commit comments

Comments
 (0)