Skip to content
Snippets Groups Projects
Commit becd6c98919b authored by Arnaud Vergnet's avatar Arnaud Vergnet :sun_with_face:
Browse files

chore(frontend): improve file upload input semantics

parent 524d4a50ec3c
No related branches found
No related tags found
1 merge request!51feat(frontend): use real name for file downloads
...@@ -48,12 +48,29 @@ ...@@ -48,12 +48,29 @@
const filePresent = value?.downloadUrl || value?.data; const filePresent = value?.downloadUrl || value?.data;
return ( return (
<> <ButtonGroup variant={filePresent ? "outlined" : "text"}>
<input <Button
type="file" fullWidth
style={{ display: "none" }} startIcon={<FileUploadIcon />}
ref={ref} disabled={disabled}
onChange={onFileChange} onClick={chooseFile}
/> component="label"
<ButtonGroup variant={filePresent ? "outlined" : "text"}> role={undefined}
>
{label}
{filePresent
? ` (${getFileName()}): Modifier le fichier`
: " : Choisir un fichier"}
<input
type="file"
style={{ display: "none" }}
ref={ref}
onChange={onFileChange}
/>
</Button>
<ButtonTooltip
title={
filePresent ? "Télécharger le fichier" : "Aucun fichier en ligne"
}
>
<Button <Button
...@@ -59,6 +76,6 @@ ...@@ -59,6 +76,6 @@
<Button <Button
fullWidth startIcon={<Visibility />}
startIcon={<FileUploadIcon />} disabled={disabled || !filePresent}
disabled={disabled} href={getFileDownloadUrl(value)}
onClick={chooseFile} download={getFileName()}
> >
...@@ -64,6 +81,3 @@ ...@@ -64,6 +81,3 @@
> >
{label} Voir
{filePresent
? ` (${getFileName()}): Modifier le fichier`
: " : Choisir un fichier"}
</Button> </Button>
...@@ -69,19 +83,5 @@ ...@@ -69,19 +83,5 @@
</Button> </Button>
<ButtonTooltip </ButtonTooltip>
title={ </ButtonGroup>
filePresent ? "Télécharger le fichier" : "Aucun fichier en ligne"
}
>
<Button
startIcon={<Visibility />}
disabled={disabled || !filePresent}
href={getFileDownloadUrl(value)}
download={getFileName()}
>
Voir
</Button>
</ButtonTooltip>
</ButtonGroup>
</>
); );
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment