store/backendApi: create a useBackendPrefetch hook
Create a helper hook for RTK prefetch queries. This wrapper function is needed since the imagebuilderApi and cockpitApi aren't at parity yet.
This commit is contained in:
parent
5a70e31d5a
commit
6e9bd89b08
3 changed files with 8 additions and 7 deletions
|
|
@ -17,7 +17,7 @@ import {
|
|||
COMPLIANCE_PROD_URL,
|
||||
COMPLIANCE_STAGE_URL,
|
||||
} from '../../../../constants';
|
||||
import { imageBuilderApi } from '../../../../store/enhancedImageBuilderApi';
|
||||
import { useBackendPrefetch } from '../../../../store/backendApi';
|
||||
import { useAppDispatch, useAppSelector } from '../../../../store/hooks';
|
||||
import { useGetOscapCustomizationsQuery } from '../../../../store/imageBuilderApi';
|
||||
import {
|
||||
|
|
@ -44,10 +44,7 @@ const OscapStep = () => {
|
|||
const complianceEnabled = useFlag('image-builder.compliance.enabled');
|
||||
const complianceType = useAppSelector(selectComplianceType);
|
||||
const profileID = useAppSelector(selectComplianceProfileID);
|
||||
const prefetchOscapProfile = imageBuilderApi.usePrefetch(
|
||||
'getOscapProfiles',
|
||||
{}
|
||||
);
|
||||
const prefetchOscapProfile = useBackendPrefetch('getOscapProfiles', {});
|
||||
const { isProd } = useGetEnvironment();
|
||||
const release = removeBetaFromRelease(useAppSelector(selectDistribution));
|
||||
const { data: currentProfileData } = useGetOscapCustomizationsQuery(
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ import {
|
|||
CREATING_IMAGES_WITH_IB_SERVICE_URL,
|
||||
OSBUILD_SERVICE_ARCHITECTURE_URL,
|
||||
} from '../../constants';
|
||||
import { useBackendPrefetch } from '../../store/backendApi';
|
||||
import { useAppSelector } from '../../store/hooks';
|
||||
import { imageBuilderApi } from '../../store/imageBuilderApi';
|
||||
import { selectDistribution } from '../../store/wizardSlice';
|
||||
import { resolveRelPath } from '../../Utilities/path';
|
||||
import './ImageBuilderHeader.scss';
|
||||
|
|
@ -99,7 +99,7 @@ export const ImageBuilderHeader = ({
|
|||
const navigate = useNavigate();
|
||||
|
||||
const distribution = useAppSelector(selectDistribution);
|
||||
const prefetchTargets = imageBuilderApi.usePrefetch('getArchitectures');
|
||||
const prefetchTargets = useBackendPrefetch('getArchitectures');
|
||||
|
||||
const importExportFlag = useFlagWithEphemDefault(
|
||||
'image-builder.import.enabled'
|
||||
|
|
|
|||
|
|
@ -41,6 +41,10 @@ export const useGetOscapProfilesQuery = process.env.IS_ON_PREMISE
|
|||
? useCockpitGetOscapProfilesQuery
|
||||
: useImageBuilderGetOscapProfilesQuery;
|
||||
|
||||
export const useBackendPrefetch = process.env.IS_ON_PREMISE
|
||||
? cockpitApi.usePrefetch
|
||||
: imageBuilderApi.usePrefetch;
|
||||
|
||||
export const backendApi = process.env.IS_ON_PREMISE
|
||||
? cockpitApi
|
||||
: imageBuilderApi;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue