Skip to content

Commit

Permalink
v2Wizrd: add kernel and services data
Browse files Browse the repository at this point in the history
this commit adds kernel arguments and enabled/disabled services to Oscap step.
and also add to Review step.
  • Loading branch information
mgold1234 committed Feb 1, 2024
1 parent 43bf692 commit cc720b2
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Components/CreateImageWizardV2/steps/Oscap/Oscap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ import {
} from '../../../../store/imageBuilderApi';
import {
changeOscapProfile,
changeKernel,
selectDistribution,
selectProfile,
selectKernel,
} from '../../../../store/wizardSlice';

const ProfileSelector = () => {
const oscapProfile = useAppSelector((state) => selectProfile(state));
let kernel = useAppSelector((state) => selectKernel(state));
const release = useAppSelector((state) => selectDistribution(state));
const dispatch = useAppDispatch();
const [profileName, setProfileName] = useState<string | undefined>('None');
Expand All @@ -56,6 +59,7 @@ const ProfileSelector = () => {
skip: !oscapProfile,
}
);
kernel = data?.kernel?.append;

useEffect(() => {
if (
Expand All @@ -76,6 +80,7 @@ const ProfileSelector = () => {

const handleClear = () => {
dispatch(changeOscapProfile(undefined));
dispatch(changeKernel(undefined));
setProfileName(undefined);
};

Expand All @@ -84,6 +89,7 @@ const ProfileSelector = () => {
selection: DistributionProfileItem
) => {
dispatch(changeOscapProfile(selection));
dispatch(changeKernel(kernel));
setIsOpen(false);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from 'react';

import {
CodeBlock,
CodeBlockCode,
Spinner,
TextContent,
TextList,
Expand Down Expand Up @@ -36,6 +38,16 @@ const OscapProfileInformation = (): JSX.Element => {
}
);

const enabledServices = oscapProfileInfo?.services?.enabled;
const enabledServicesDisplayString = enabledServices?.reduce(
(accumulator, currentValue) => accumulator + ' ' + currentValue,
''
);
const disableServices = oscapProfileInfo?.services?.disabled;
const disableServicesDisplayString = disableServices?.reduce(
(accumulator, currentValue) => accumulator + ' ' + currentValue,
''
);
return (
<>
{isFetchingOscapProfileInfo && <Spinner size="lg" />}
Expand Down Expand Up @@ -74,6 +86,46 @@ const OscapProfileInformation = (): JSX.Element => {
<TextListItem component={TextListItemVariants.dd}>
{oscapProfileInfo.openscap?.profile_id}
</TextListItem>
<TextListItem
component={TextListItemVariants.dt}
className="pf-u-min-width"
>
Kernel:
</TextListItem>
<TextListItem component={TextListItemVariants.dd}>
<CodeBlock>
<CodeBlockCode id="code-content">
{oscapProfileInfo?.kernel?.append}
</CodeBlockCode>
</CodeBlock>
</TextListItem>
<TextListItem
component={TextListItemVariants.dt}
className="pf-u-min-width"
>
Disabled Services:
</TextListItem>
<TextListItem component={TextListItemVariants.dd}>
<CodeBlock>
<CodeBlockCode id="code-content">
{disableServicesDisplayString}
</CodeBlockCode>
</CodeBlock>
</TextListItem>

<TextListItem
component={TextListItemVariants.dt}
className="pf-u-min-width"
>
Enabled Services:
</TextListItem>
<TextListItem component={TextListItemVariants.dd}>
<CodeBlock>
<CodeBlockCode id="code-content">
{enabledServicesDisplayString}
</CodeBlockCode>
</CodeBlock>
</TextListItem>
</TextList>
</TextContent>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React, { useEffect, useState } from 'react';

import {
CodeBlock,
CodeBlockCode,
Alert,
Button,
Popover,
Expand Down Expand Up @@ -473,6 +475,10 @@ export const OscapList = () => {
skip: !oscapProfile,
}
);
const enabledServicesDisplayString = data?.services?.enabled?.join(' ');
console.log(`'${enabledServicesDisplayString}'`);
const disableServicesDisplayString = data?.services?.disabled?.join(' ');

return (
<TextContent>
<TextList component={TextListVariants.dl}>
Expand Down Expand Up @@ -507,6 +513,45 @@ export const OscapList = () => {
<TextListItem component={TextListItemVariants.dd}>
{oscapProfile}
</TextListItem>
<TextListItem
component={TextListItemVariants.dt}
className="pf-u-min-width"
>
Kernel:
</TextListItem>
<TextListItem component={TextListItemVariants.dd}>
<CodeBlock>
<CodeBlockCode id="code-content">
{data?.kernel?.append}
</CodeBlockCode>
</CodeBlock>
</TextListItem>
<TextListItem
component={TextListItemVariants.dt}
className="pf-u-min-width"
>
Disabled Services:
</TextListItem>
<TextListItem component={TextListItemVariants.dd}>
<CodeBlock>
<CodeBlockCode id="code-content">
{disableServicesDisplayString}
</CodeBlockCode>
</CodeBlock>
</TextListItem>
<TextListItem
component={TextListItemVariants.dt}
className="pf-u-min-width"
>
Enabled Services:
</TextListItem>
<TextListItem component={TextListItemVariants.dd}>
<CodeBlock>
<CodeBlockCode id="code-content">
{enabledServicesDisplayString}
</CodeBlockCode>
</CodeBlock>
</TextListItem>
</TextList>
<br />
</TextContent>
Expand Down
19 changes: 19 additions & 0 deletions src/store/wizardSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
Distributions,
ImageRequest,
ImageTypes,
Kernel,
} from './imageBuilderApi';
import { ActivationKeys } from './rhsmApi';

Expand Down Expand Up @@ -46,6 +47,9 @@ type wizardState = {
openScap: {
profile: DistributionProfileItem | undefined;
};
kernel: {
kernelAppend: Kernel['append'] | undefined;
};
repositories: {
customRepositories: CustomRepository[];
};
Expand Down Expand Up @@ -80,6 +84,9 @@ const initialState: wizardState = {
openScap: {
profile: undefined,
},
kernel: {
kernelAppend: '',
},
repositories: {
customRepositories: [],
},
Expand Down Expand Up @@ -147,6 +154,10 @@ export const selectProfile = (state: RootState) => {
return state.wizard.openScap.profile;
};

export const selectKernel = (state: RootState) => {
return state.wizard.kernel.kernelAppend;
};

export const selectCustomRepositories = (state: RootState) => {
return state.wizard.repositories.customRepositories;
};
Expand Down Expand Up @@ -238,6 +249,13 @@ export const wizardSlice = createSlice({
) => {
state.openScap.profile = action.payload;
},

changeKernel: (
state,
action: PayloadAction<Kernel['append'] | undefined>
) => {
state.kernel.kernelAppend = action.payload;
},
changeCustomRepositories: (
state,
action: PayloadAction<CustomRepository[]>
Expand Down Expand Up @@ -271,6 +289,7 @@ export const {
changeRegistrationType,
changeActivationKey,
changeOscapProfile,
changeKernel,
changeCustomRepositories,
changeBlueprintName,
changeBlueprintDescription,
Expand Down

0 comments on commit cc720b2

Please sign in to comment.