store/backendApi: export the relevant store api
Since the implementation of the cockpitApi and imageBuilderApi are different, we should make sure to export the correct one depending on the environment we are in.
This commit is contained in:
parent
79532e4ac5
commit
3e6985988a
5 changed files with 29 additions and 15 deletions
|
|
@ -3,6 +3,7 @@ import React from 'react';
|
|||
import { Pagination, PaginationVariant } from '@patternfly/react-core';
|
||||
import { OnSetPage } from '@patternfly/react-core/dist/esm/components/Pagination/Pagination';
|
||||
|
||||
import { useGetBlueprintsQuery } from '../../store/backendApi';
|
||||
import {
|
||||
selectBlueprintSearchInput,
|
||||
selectLimit,
|
||||
|
|
@ -11,10 +12,7 @@ import {
|
|||
setBlueprintsOffset,
|
||||
} from '../../store/BlueprintSlice';
|
||||
import { useAppDispatch, useAppSelector } from '../../store/hooks';
|
||||
import {
|
||||
useGetBlueprintsQuery,
|
||||
GetBlueprintsApiArg,
|
||||
} from '../../store/imageBuilderApi';
|
||||
import { GetBlueprintsApiArg } from '../../store/imageBuilderApi';
|
||||
|
||||
const BlueprintsPagination = () => {
|
||||
const blueprintSearchInput = useAppSelector(selectBlueprintSearchInput);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,11 @@ import {
|
|||
} from '@patternfly/react-core';
|
||||
|
||||
import { PAGINATION_LIMIT, PAGINATION_OFFSET } from '../../constants';
|
||||
import {
|
||||
backendApi,
|
||||
useDeleteBlueprintMutation,
|
||||
useGetBlueprintsQuery,
|
||||
} from '../../store/backendApi';
|
||||
import {
|
||||
selectBlueprintSearchInput,
|
||||
selectLimit,
|
||||
|
|
@ -15,13 +20,8 @@ import {
|
|||
selectSelectedBlueprintId,
|
||||
setBlueprintId,
|
||||
} from '../../store/BlueprintSlice';
|
||||
import { imageBuilderApi } from '../../store/enhancedImageBuilderApi';
|
||||
import { useAppDispatch, useAppSelector } from '../../store/hooks';
|
||||
import {
|
||||
GetBlueprintsApiArg,
|
||||
useDeleteBlueprintMutation,
|
||||
useGetBlueprintsQuery,
|
||||
} from '../../store/imageBuilderApi';
|
||||
import { GetBlueprintsApiArg } from '../../store/imageBuilderApi';
|
||||
|
||||
interface DeleteBlueprintModalProps {
|
||||
setShowDeleteModal: React.Dispatch<React.SetStateAction<boolean>>;
|
||||
|
|
@ -62,7 +62,7 @@ export const DeleteBlueprintModal: React.FunctionComponent<
|
|||
setShowDeleteModal(false);
|
||||
await deleteBlueprint({ id: selectedBlueprintId });
|
||||
dispatch(setBlueprintId(undefined));
|
||||
dispatch(imageBuilderApi.util.invalidateTags([{ type: 'Blueprints' }]));
|
||||
dispatch(backendApi.util.invalidateTags([{ type: 'Blueprints' }]));
|
||||
}
|
||||
};
|
||||
const onDeleteClose = () => {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import {
|
|||
Title,
|
||||
} from '@patternfly/react-core';
|
||||
|
||||
import { useGetBlueprintsQuery } from '../../store/backendApi';
|
||||
import {
|
||||
selectSelectedBlueprintId,
|
||||
selectBlueprintSearchInput,
|
||||
|
|
@ -18,7 +19,6 @@ import {
|
|||
import { useAppSelector } from '../../store/hooks';
|
||||
import {
|
||||
BlueprintItem,
|
||||
useGetBlueprintsQuery,
|
||||
useGetBlueprintComposesQuery,
|
||||
Distributions,
|
||||
GetBlueprintComposesApiArg,
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import {
|
|||
MODAL_ANCHOR,
|
||||
SEARCH_INPUT,
|
||||
} from '../../constants';
|
||||
import { useGetBlueprintsQuery } from '../../store/backendApi';
|
||||
import {
|
||||
selectSelectedBlueprintId,
|
||||
selectBlueprintSearchInput,
|
||||
|
|
@ -33,7 +34,6 @@ import {
|
|||
import { useAppSelector } from '../../store/hooks';
|
||||
import {
|
||||
BlueprintItem,
|
||||
useGetBlueprintsQuery,
|
||||
ComposesResponseItem,
|
||||
ComposeStatus,
|
||||
ImageTypes,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,22 @@
|
|||
import { useGetBlueprintsQuery as useCockpitGetBlueprintsQuery } from './cockpitApi';
|
||||
import { useGetBlueprintsQuery as useImageBuilderGetBlueprintsQuery } from './imageBuilderApi';
|
||||
import {
|
||||
useGetBlueprintsQuery as useCockpitGetBlueprintsQuery,
|
||||
useDeleteBlueprintMutation as useCockpitDeleteMutation,
|
||||
} from './cockpitApi';
|
||||
import { cockpitApi } from './enhancedCockpitApi';
|
||||
import { imageBuilderApi } from './enhancedImageBuilderApi';
|
||||
import {
|
||||
useGetBlueprintsQuery as useImageBuilderGetBlueprintsQuery,
|
||||
useDeleteBlueprintMutation as useImageBuilderDeleteMutation,
|
||||
} from './imageBuilderApi';
|
||||
|
||||
export const useGetBlueprintsQuery = process.env.IS_ON_PREMISE
|
||||
? useCockpitGetBlueprintsQuery
|
||||
: useImageBuilderGetBlueprintsQuery;
|
||||
|
||||
export const useDeleteBlueprintMutation = process.env.IS_ON_PREMISE
|
||||
? useCockpitDeleteMutation
|
||||
: useImageBuilderDeleteMutation;
|
||||
|
||||
export const backendApi = process.env.IS_ON_PREMISE
|
||||
? cockpitApi
|
||||
: imageBuilderApi;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue