V2Wizrad: fix validation at file system step (HMS-3733)

this commit fix validation when usr choose duplicate mount point
andwhen there is no root partition
This commit is contained in:
Michal Gold 2024-03-17 13:02:33 +02:00 committed by Lucas Garfield
parent 92fbb8babf
commit 698d21df42
5 changed files with 117 additions and 4 deletions

View file

@ -1,3 +1,5 @@
import { Partition } from './steps/FileSystem/FileSystemConfiguration';
export const isAwsAccountIdValid = (awsAccountId: string | undefined) => {
return (
awsAccountId !== undefined &&
@ -38,3 +40,23 @@ export const isBlueprintNameValid = (blueprintName: string) =>
export const isBlueprintDescriptionValid = (blueprintDescription: string) => {
return blueprintDescription.length <= 250;
};
export const isFileSystemConfigValid = (partitions: Partition[]) => {
const duplicates = getDuplicateMountPoints(partitions);
return duplicates.length === 0;
};
export const getDuplicateMountPoints = (partitions: Partition[]): string[] => {
const mountPointSet: Set<string> = new Set();
const duplicates: string[] = [];
if (!partitions) {
return [];
}
for (const partition of partitions) {
const mountPoint = partition.mountpoint;
if (mountPointSet.has(mountPoint)) {
duplicates.push(mountPoint);
} else {
mountPointSet.add(mountPoint);
}
}
return duplicates;
};