From 3c3ca3537a2ca0de11b8a21e25586343979f3f34 Mon Sep 17 00:00:00 2001 From: Ondrej Ezr Date: Mon, 8 Apr 2024 22:01:00 +0200 Subject: [PATCH] WizardV2: Filesystem partitioning suffix --- .../steps/FileSystem/FileSystemConfiguration.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Components/CreateImageWizardV2/steps/FileSystem/FileSystemConfiguration.tsx b/src/Components/CreateImageWizardV2/steps/FileSystem/FileSystemConfiguration.tsx index 53bf164f..eb30e83a 100644 --- a/src/Components/CreateImageWizardV2/steps/FileSystem/FileSystemConfiguration.tsx +++ b/src/Components/CreateImageWizardV2/steps/FileSystem/FileSystemConfiguration.tsx @@ -179,12 +179,17 @@ type RowPropTypes = { onDragStart?: (event: React.DragEvent) => void; }; +const normalizeSuffix = (rawSuffix: string) => { + const suffix = rawSuffix.replace(/^\/+/g, '') + return suffix.length > 0 ? '/' + suffix : '' +}; + const getPrefix = (mountpoint: string) => { return mountpoint.split('/')[1] ? '/' + mountpoint.split('/')[1] : '/'; }; const getSuffix = (mountpoint: string) => { const prefix = getPrefix(mountpoint); - return mountpoint.substring(prefix.length); + return normalizeSuffix(mountpoint.substring(prefix.length)); }; export const Row = ({ @@ -284,7 +289,7 @@ const MountpointPrefix = ({ partition }: MountpointPrefixPropTypes) => { const onSelect = (event: React.MouseEvent, selection: string) => { setIsOpen(false); - const mountpoint = selection + suffix; + const mountpoint = selection + (suffix.length > 0 ? '/' + suffix : ''); dispatch( changePartitionMountpoint({ id: partition.id, mountpoint: mountpoint }) ); @@ -319,8 +324,8 @@ const MountpointSuffix = ({ partition }: MountpointSuffixPropTypes) => { { - const mountpoint = prefix + suffix; + onChange={(event: React.FormEvent, newValue) => { + const mountpoint = prefix + normalizeSuffix(newValue); dispatch( changePartitionMountpoint({ id: partition.id,