V2Wizard: change the default of file system table when user choose manual cunfiguration

this commit change the default table when user choose manual configuration at file system step
This commit is contained in:
Michal Gold 2024-03-12 18:41:34 +02:00 committed by Klara Simickova
parent 9020392969
commit 0b6cf44bbc
2 changed files with 20 additions and 8 deletions

View file

@ -1,16 +1,19 @@
import React from 'react';
import { FormGroup, Label, Radio } from '@patternfly/react-core';
import { v4 as uuidv4 } from 'uuid';
import { useAppDispatch, useAppSelector } from '../../../../store/hooks';
import {
changeFileSystemConfiguration,
changeFileSystemPartitionMode,
selectFileSystemPartitionMode,
} from '../../../../store/wizardSlice';
const FileSystemPartition = () => {
const id = uuidv4();
const dispatch = useAppDispatch();
const fileSystemPartition = useAppSelector((state) =>
const fileSystemPartitionMode = useAppSelector((state) =>
selectFileSystemPartitionMode(state)
);
return (
@ -27,9 +30,10 @@ const FileSystemPartition = () => {
}
name="sc-radio-automatic"
description="Automatically partition your image to what is best, depending on the target environment(s)"
isChecked={fileSystemPartition === 'automatic'}
isChecked={fileSystemPartitionMode === 'automatic'}
onChange={() => {
dispatch(changeFileSystemPartitionMode('automatic'));
dispatch(changeFileSystemConfiguration([]));
}}
/>
<Radio
@ -37,9 +41,14 @@ const FileSystemPartition = () => {
label="Manually configure partitions"
name="fsc-radio-manual"
description="Manually configure the file system of your image by adding, removing, and editing partitions"
isChecked={fileSystemPartition === 'manual'}
isChecked={fileSystemPartitionMode === 'manual'}
onChange={() => {
dispatch(changeFileSystemPartitionMode('manual'));
dispatch(
changeFileSystemConfiguration([
{ id: id, mountpoint: '/', min_size: '500' },
])
);
}}
/>
</FormGroup>

View file

@ -126,11 +126,7 @@ const initialState: wizardState = {
},
fileSystem: {
mode: 'automatic',
partitions: [
{ id: '1', mountpoint: '/', min_size: '500' },
{ id: '2', mountpoint: '/home', min_size: '500' },
{ id: '3', mountpoint: '/home/var', min_size: '500' },
],
partitions: [],
},
repositories: {
customRepositories: [],
@ -374,6 +370,12 @@ export const wizardSlice = createSlice({
) => {
state.openScap.services.enabled = action.payload;
},
changeFileSystemConfiguration: (
state,
action: PayloadAction<Partition[]>
) => {
state.fileSystem.partitions = action.payload;
},
changeFileSystemPartitionMode: (
state,
action: PayloadAction<FileSystemPartitionMode>
@ -471,6 +473,7 @@ export const {
changeKernel,
changeDisabledServices,
changeEnabledServices,
changeFileSystemConfiguration,
changeFileSystemPartitionMode,
addPartition,
removePartition,