Skip to content

Commit

Permalink
store/cockpitApi: add create blueprint mutation
Browse files Browse the repository at this point in the history
  • Loading branch information
kingsleyzissou authored and croissanne committed Jan 28, 2025
1 parent c104f30 commit 94f24ce
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import {
import useChrome from '@redhat-cloud-services/frontend-components/useChrome';

import { AMPLITUDE_MODULE_NAME } from '../../../../../constants';
import { useCreateBlueprintMutation } from '../../../../../store/backendApi';
import { setBlueprintId } from '../../../../../store/BlueprintSlice';
import { useAppDispatch, useAppSelector } from '../../../../../store/hooks';
import {
CreateBlueprintRequest,
useComposeBlueprintMutation,
useCreateBlueprintMutation,
} from '../../../../../store/imageBuilderApi';
import { selectPackages } from '../../../../../store/wizardSlice';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ import { useNavigate, useParams } from 'react-router-dom';
import { CreateSaveAndBuildBtn, CreateSaveButton } from './CreateDropdown';
import { EditSaveAndBuildBtn, EditSaveButton } from './EditDropdown';

import {
useCreateBlueprintMutation,
useUpdateBlueprintMutation,
} from '../../../../../store/imageBuilderApi';
import { useCreateBlueprintMutation } from '../../../../../store/backendApi';
import { useUpdateBlueprintMutation } from '../../../../../store/imageBuilderApi';
import { resolveRelPath } from '../../../../../Utilities/path';
import { mapRequestFromState } from '../../../utilities/requestMapper';
import { useIsBlueprintValid } from '../../../utilities/useValidation';
Expand Down
4 changes: 4 additions & 0 deletions src/store/backendApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export const useLazyGetBlueprintsQuery = process.env.IS_ON_PREMISE
? cockpitQueries.useLazyGetBlueprintsQuery
: imageBuilderQueries.useLazyGetBlueprintsQuery;

export const useCreateBlueprintMutation = process.env.IS_ON_PREMISE
? cockpitQueries.useCreateBlueprintMutation
: imageBuilderQueries.useCreateBlueprintMutation;

export const useDeleteBlueprintMutation = process.env.IS_ON_PREMISE
? cockpitQueries.useDeleteBlueprintMutation
: imageBuilderQueries.useDeleteBlueprintMutation;
Expand Down
20 changes: 20 additions & 0 deletions src/store/cockpitApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import {
GetOscapProfilesApiResponse,
GetBlueprintApiResponse,
GetBlueprintApiArg,
CreateBlueprintApiResponse,
CreateBlueprintApiArg,
} from './imageBuilderApi';

import { mapOnPremToHosted } from '../Components/Blueprints/helpers/onPremToHostedBlueprintMapper';
Expand Down Expand Up @@ -183,6 +185,23 @@ export const cockpitApi = emptyCockpitApi.injectEndpoints({
}
},
}),
createBlueprint: builder.mutation<
CreateBlueprintApiResponse,
CreateBlueprintApiArg
>({
queryFn: async () => {
// TODO: actually save the result to file
try {
return {
data: {
id: '',
},
};
} catch (error) {
return { error };
}
},
}),
deleteBlueprint: builder.mutation<
DeleteBlueprintApiResponse,
DeleteBlueprintApiArg
Expand Down Expand Up @@ -239,6 +258,7 @@ export const {
useGetBlueprintQuery,
useGetBlueprintsQuery,
useLazyGetBlueprintsQuery,
useCreateBlueprintMutation,
useDeleteBlueprintMutation,
useGetOscapProfilesQuery,
useListSnapshotsByDateMutation,
Expand Down

0 comments on commit 94f24ce

Please sign in to comment.