CreateImageWizard: refactor oscap availability
Refactor the OpenSCAP on-premise availability check. Add the check to the component so we run the check everytime the step is loaded. The benefits to this is that if the user installs the packages, they won't need to reload the page to use the OpenSCAP step. The downside is that the check is not very quick, so a spinner was added just to indicate that the check is running.
This commit is contained in:
parent
20447f753a
commit
e5a513a4cb
4 changed files with 58 additions and 33 deletions
|
|
@ -0,0 +1,18 @@
|
|||
import React from 'react';
|
||||
|
||||
import { Form, FormGroup, Spinner, Title } from '@patternfly/react-core';
|
||||
|
||||
const OscapOnPremSpinner = () => {
|
||||
return (
|
||||
<Form>
|
||||
<Title headingLevel="h1" size="xl">
|
||||
OpenSCAP profile
|
||||
</Title>
|
||||
<FormGroup>
|
||||
<Spinner size="xl" />
|
||||
</FormGroup>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default OscapOnPremSpinner;
|
||||
|
|
@ -10,6 +10,8 @@ import {
|
|||
} from '@patternfly/react-core';
|
||||
import { ExternalLinkAltIcon } from '@patternfly/react-icons';
|
||||
|
||||
import OscapOnPremSpinner from './OnPremSpinner';
|
||||
import OscapOnPremWarning from './OnPremWarning';
|
||||
import { Oscap, removeBetaFromRelease } from './Oscap';
|
||||
|
||||
import {
|
||||
|
|
@ -36,8 +38,9 @@ import {
|
|||
clearKernelAppend,
|
||||
} from '../../../../store/wizardSlice';
|
||||
import { useFlag } from '../../../../Utilities/useGetEnvironment';
|
||||
import { useOnPremOpenSCAPAvailable } from '../../../../Utilities/useOnPremOpenSCAP';
|
||||
|
||||
const OscapStep = () => {
|
||||
const OscapContent = () => {
|
||||
const dispatch = useAppDispatch();
|
||||
const complianceEnabled = useFlag('image-builder.compliance.enabled');
|
||||
const complianceType = useAppSelector(selectComplianceType);
|
||||
|
|
@ -159,4 +162,20 @@ const OscapStep = () => {
|
|||
);
|
||||
};
|
||||
|
||||
const OnPremOscapStep = () => {
|
||||
const [onPremOpenSCAPAvailable, isLoading] = useOnPremOpenSCAPAvailable();
|
||||
|
||||
if (isLoading) {
|
||||
return <OscapOnPremSpinner />;
|
||||
}
|
||||
|
||||
if (!onPremOpenSCAPAvailable) {
|
||||
return <OscapOnPremWarning />;
|
||||
}
|
||||
|
||||
return <OscapContent />;
|
||||
};
|
||||
|
||||
const OscapStep = process.env.IS_ON_PREMISE ? OnPremOscapStep : OscapContent;
|
||||
|
||||
export default OscapStep;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue