CreateImageWizard: on-prem prefetch
The openscap customizatoins endpoint for on-prem is quite slow since it has to call the run the oscap tool to generate the customization options. Running this request lazily, as we do for the service, is too slow, so we can just prefetch the customizations for on-prem.
This commit is contained in:
parent
18c329be2a
commit
20447f753a
1 changed files with 14 additions and 0 deletions
|
|
@ -29,6 +29,7 @@ import {
|
|||
useGetOscapProfilesQuery,
|
||||
useGetOscapCustomizationsQuery,
|
||||
useLazyGetOscapCustomizationsQuery,
|
||||
useBackendPrefetch,
|
||||
} from '../../../../store/backendApi';
|
||||
import { usePoliciesQuery, PolicyRead } from '../../../../store/complianceApi';
|
||||
import { useAppDispatch, useAppSelector } from '../../../../store/hooks';
|
||||
|
|
@ -99,6 +100,7 @@ const ProfileSelector = () => {
|
|||
const dispatch = useAppDispatch();
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const complianceType = useAppSelector(selectComplianceType);
|
||||
const prefetchProfile = useBackendPrefetch('getOscapCustomizations');
|
||||
|
||||
const {
|
||||
data: profiles,
|
||||
|
|
@ -139,6 +141,18 @@ const ProfileSelector = () => {
|
|||
|
||||
const [trigger] = useLazyGetOscapCustomizationsQuery();
|
||||
|
||||
// prefetch the profiles customizations for on-prem
|
||||
// and save the results to the cache, since the request
|
||||
// is quite slow
|
||||
if (process.env.IS_ON_PREMISE) {
|
||||
profiles?.forEach((profile) => {
|
||||
prefetchProfile({
|
||||
distribution: release,
|
||||
profile: profile,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!policies || policies.data === undefined) {
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue