mirror of
https://github.com/portainer/portainer.git
synced 2025-07-19 13:29:41 +02:00
refactor(settings): migrate helm cert panel to react [EE-5505] (#9132)
This commit is contained in:
parent
c452de82b7
commit
f293ea41d3
19 changed files with 268 additions and 70 deletions
|
@ -22,3 +22,24 @@ export function withFileSize(fileValidation: FileSchema, maxSize: number) {
|
|||
return file.size <= maxSize;
|
||||
}
|
||||
}
|
||||
|
||||
export function withFileExtension(
|
||||
fileValidation: FileSchema,
|
||||
allowedExtensions: string[]
|
||||
) {
|
||||
return fileValidation.test(
|
||||
'fileExtension',
|
||||
'Selected file has invalid extension.',
|
||||
validateFileExtension
|
||||
);
|
||||
|
||||
function validateFileExtension(file?: File) {
|
||||
if (!file) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const fileExtension = file.name.split('.').pop();
|
||||
|
||||
return allowedExtensions.includes(fileExtension || '');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue