V2Wizard: fix remove partition funtionallity (HMS-3753)

this commit add the remove partition functionlity to file system step
This commit is contained in:
Michal Gold 2024-03-10 16:20:46 +02:00 committed by Klara Simickova
parent 918d02707f
commit 0d2735fe0f
2 changed files with 17 additions and 2 deletions

View file

@ -26,6 +26,7 @@ import {
changePartitionMinSize,
changePartitionMountpoint,
selectImageTypes,
removePartition,
selectPartitions,
} from '../../../../store/wizardSlice';
import UsrSubDirectoriesDisabled from '../../UsrSubDirectoriesDisabled';
@ -163,6 +164,11 @@ const getSuffix = (mountpoint: string) => {
const Row = ({ partition }: RowPropTypes) => {
const [units, setUnits] = useState<Units>('MiB');
const dispatch = useAppDispatch();
const handleRemovePartition = (id: string) => {
dispatch(removePartition(id));
};
return (
<Tr>
@ -184,9 +190,9 @@ const Row = ({ partition }: RowPropTypes) => {
<Button
variant="link"
icon={<MinusCircleIcon />}
onClick={() => {}}
onClick={() => handleRemovePartition(partition.id)}
data-testid="remove-mount-point"
isDisabled={true}
isDisabled={partition.mountpoint === '/'}
/>
</Td>
</Tr>

View file

@ -383,6 +383,14 @@ export const wizardSlice = createSlice({
addPartition: (state, action: PayloadAction<Partition>) => {
state.fileSystem.partitions.push(action.payload);
},
removePartition: (state, action: PayloadAction<Partition['id']>) => {
state.fileSystem.partitions.splice(
state.fileSystem.partitions.findIndex(
(partition) => partition.id === action.payload
),
1
);
},
changePartitionMountpoint: (
state,
action: PayloadAction<{ id: string; mountpoint: string }>
@ -465,6 +473,7 @@ export const {
changeEnabledServices,
changeFileSystemPartitionMode,
addPartition,
removePartition,
changePartitionMountpoint,
changePartitionMinSize,
changeCustomRepositories,