mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 17:45:22 +00:00
explorer: push file name validation to parents
This gets rid of the weird unknown state and other problems of trying to push state from a child back to a parent.
This commit is contained in:
@@ -12,8 +12,6 @@ export const pythonFileMimeType = 'text/x-python';
|
||||
|
||||
/** File name validation results. */
|
||||
export enum FileNameValidationResult {
|
||||
/** The result is not yet known. */
|
||||
Unknown,
|
||||
/** The file name is acceptable. */
|
||||
IsOk,
|
||||
/** The file name is an empty string. */
|
||||
@@ -42,7 +40,7 @@ export function validateFileName(
|
||||
fileName: string,
|
||||
extension: string,
|
||||
existingFiles: ReadonlyArray<string>,
|
||||
): Exclude<FileNameValidationResult, FileNameValidationResult.Unknown> {
|
||||
): FileNameValidationResult {
|
||||
if (existingFiles.includes(`${fileName}${extension}`)) {
|
||||
return FileNameValidationResult.AlreadyExists;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user