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:
David Lechner
2022-03-19 18:21:00 -05:00
parent 9de4227ec1
commit 1802bcf796
4 changed files with 25 additions and 29 deletions
+1 -3
View File
@@ -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;
}