CreateImageWizard: support edit mode on premise
The way the on premise wizard is initialized needed to be tweaked to make it work for isEdit. Let's assume that the host distro and host architecture are already correct in the blueprint.
This commit is contained in:
parent
0204bcced5
commit
52a43b0f2d
6 changed files with 36 additions and 5 deletions
|
|
@ -207,11 +207,10 @@ const CreateImageWizard = ({ isEdit }: CreateImageWizardProps) => {
|
|||
dispatch(changeArchitecture(arch));
|
||||
};
|
||||
|
||||
if (process.env.IS_ON_PREMISE) {
|
||||
if (process.env.IS_ON_PREMISE && !isEdit) {
|
||||
if (!searchParams.get('release')) {
|
||||
initializeHostDistro();
|
||||
}
|
||||
|
||||
initializeHostArch();
|
||||
}
|
||||
// This useEffect hook should run *only* on mount and therefore has an empty
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ import {
|
|||
FlexItem,
|
||||
} from '@patternfly/react-core';
|
||||
|
||||
import { useUpdateBlueprintMutation } from '../../../../../store/backendApi';
|
||||
import {
|
||||
CreateBlueprintRequest,
|
||||
useComposeBlueprintMutation,
|
||||
useUpdateBlueprintMutation,
|
||||
} from '../../../../../store/imageBuilderApi';
|
||||
|
||||
type EditDropdownProps = {
|
||||
|
|
|
|||
|
|
@ -15,8 +15,10 @@ import { useNavigate, useParams } from 'react-router-dom';
|
|||
import { CreateSaveAndBuildBtn, CreateSaveButton } from './CreateDropdown';
|
||||
import { EditSaveAndBuildBtn, EditSaveButton } from './EditDropdown';
|
||||
|
||||
import { useCreateBlueprintMutation } from '../../../../../store/backendApi';
|
||||
import { useUpdateBlueprintMutation } from '../../../../../store/imageBuilderApi';
|
||||
import {
|
||||
useCreateBlueprintMutation,
|
||||
useUpdateBlueprintMutation,
|
||||
} from '../../../../../store/backendApi';
|
||||
import { resolveRelPath } from '../../../../../Utilities/path';
|
||||
import { mapRequestFromState } from '../../../utilities/requestMapper';
|
||||
import { useIsBlueprintValid } from '../../../utilities/useValidation';
|
||||
|
|
|
|||
|
|
@ -23,6 +23,10 @@ export const useCreateBlueprintMutation = process.env.IS_ON_PREMISE
|
|||
? cockpitQueries.useCreateBlueprintMutation
|
||||
: serviceQueries.useCreateBlueprintMutation;
|
||||
|
||||
export const useUpdateBlueprintMutation = process.env.IS_ON_PREMISE
|
||||
? cockpitQueries.useUpdateBlueprintMutation
|
||||
: serviceQueries.useUpdateBlueprintMutation;
|
||||
|
||||
export const useDeleteBlueprintMutation = process.env.IS_ON_PREMISE
|
||||
? cockpitQueries.useDeleteBlueprintMutation
|
||||
: serviceQueries.useDeleteBlueprintMutation;
|
||||
|
|
|
|||
|
|
@ -45,6 +45,8 @@ import {
|
|||
CreateBlueprintApiResponse,
|
||||
CreateBlueprintApiArg,
|
||||
ComposeResponse,
|
||||
UpdateBlueprintApiResponse,
|
||||
UpdateBlueprintApiArg,
|
||||
} from '../service/imageBuilderApi';
|
||||
|
||||
const getBlueprintsPath = async () => {
|
||||
|
|
@ -246,6 +248,26 @@ export const cockpitApi = contentSourcesApi.injectEndpoints({
|
|||
}
|
||||
},
|
||||
}),
|
||||
updateBlueprint: builder.mutation<
|
||||
UpdateBlueprintApiResponse,
|
||||
UpdateBlueprintApiArg
|
||||
>({
|
||||
queryFn: async ({ id: id, createBlueprintRequest: blueprintReq }) => {
|
||||
try {
|
||||
const blueprintsDir = await getBlueprintsPath();
|
||||
await cockpit
|
||||
.file(path.join(blueprintsDir, id, `${id}.json`))
|
||||
.replace(JSON.stringify(blueprintReq));
|
||||
return {
|
||||
data: {
|
||||
id: id,
|
||||
},
|
||||
};
|
||||
} catch (error) {
|
||||
return { error };
|
||||
}
|
||||
},
|
||||
}),
|
||||
deleteBlueprint: builder.mutation<
|
||||
DeleteBlueprintApiResponse,
|
||||
DeleteBlueprintApiArg
|
||||
|
|
@ -456,6 +478,7 @@ export const {
|
|||
useGetBlueprintsQuery,
|
||||
useLazyGetBlueprintsQuery,
|
||||
useCreateBlueprintMutation,
|
||||
useUpdateBlueprintMutation,
|
||||
useDeleteBlueprintMutation,
|
||||
useGetOscapProfilesQuery,
|
||||
useComposeBlueprintMutation,
|
||||
|
|
|
|||
|
|
@ -15,6 +15,9 @@ const enhancedApi = cockpitApi.enhanceEndpoints({
|
|||
createBlueprint: {
|
||||
invalidatesTags: [{ type: 'Blueprints' }],
|
||||
},
|
||||
updateBlueprint: {
|
||||
invalidatesTags: [{ type: 'Blueprints' }],
|
||||
},
|
||||
deleteBlueprint: {
|
||||
invalidatesTags: [{ type: 'Blueprints' }],
|
||||
onQueryStarted: async (_, { dispatch, queryFulfilled }) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue