Wizard: Add kernel append input
This adds the kernel append input. New arguments can be added by pressing the "Add" button or hitting Enter after the argument. The kernel arguments linked to a selected OpenSCAP profile are rendered in a category marked as "Required by OpenSCAP" and are read only.
This commit is contained in:
parent
199dd3d5d7
commit
1b21852518
13 changed files with 305 additions and 40 deletions
|
|
@ -2,8 +2,57 @@ import React from 'react';
|
|||
|
||||
import { FormGroup } from '@patternfly/react-core';
|
||||
|
||||
import { useAppSelector } from '../../../../../store/hooks';
|
||||
import { useGetOscapCustomizationsQuery } from '../../../../../store/imageBuilderApi';
|
||||
import {
|
||||
addKernelArg,
|
||||
removeKernelArg,
|
||||
selectComplianceProfileID,
|
||||
selectDistribution,
|
||||
selectKernel,
|
||||
} from '../../../../../store/wizardSlice';
|
||||
import ChippingInput from '../../../ChippingInput';
|
||||
import { isKernelArgumentValid } from '../../../validators';
|
||||
|
||||
const KernelArguments = () => {
|
||||
return <FormGroup isRequired={false} label="Append"></FormGroup>;
|
||||
const kernelAppend = useAppSelector(selectKernel).append;
|
||||
|
||||
const release = useAppSelector(selectDistribution);
|
||||
const complianceProfileID = useAppSelector(selectComplianceProfileID);
|
||||
|
||||
const { data: oscapProfileInfo } = useGetOscapCustomizationsQuery(
|
||||
{
|
||||
distribution: release,
|
||||
// @ts-ignore if complianceProfileID is undefined the query is going to get skipped, so it's safe here to ignore the linter here
|
||||
profile: complianceProfileID,
|
||||
},
|
||||
{
|
||||
skip: !complianceProfileID,
|
||||
}
|
||||
);
|
||||
|
||||
const requiredByOpenSCAP = kernelAppend.filter((arg) =>
|
||||
oscapProfileInfo?.kernel?.append?.split(' ').includes(arg)
|
||||
);
|
||||
|
||||
const notRequiredByOpenSCAP = kernelAppend.filter(
|
||||
(arg) => !oscapProfileInfo?.kernel?.append?.split(' ').includes(arg)
|
||||
);
|
||||
|
||||
return (
|
||||
<FormGroup isRequired={false} label="Append">
|
||||
<ChippingInput
|
||||
ariaLabel="Add kernel argument"
|
||||
placeholder="Add kernel argument"
|
||||
validator={isKernelArgumentValid}
|
||||
list={notRequiredByOpenSCAP}
|
||||
requiredList={requiredByOpenSCAP}
|
||||
item="Kernel argument"
|
||||
addAction={addKernelArg}
|
||||
removeAction={removeKernelArg}
|
||||
/>
|
||||
</FormGroup>
|
||||
);
|
||||
};
|
||||
|
||||
export default KernelArguments;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue