feat: handle long file names in ImportFlowDialog
This commit is contained in:
@@ -17,6 +17,7 @@ const VisuallyHiddenInput = styled('input')({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export default function FileUploadInput(props) {
|
export default function FileUploadInput(props) {
|
||||||
|
const { onChange, children, ...rest } = props;
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
component="label"
|
component="label"
|
||||||
@@ -24,10 +25,11 @@ export default function FileUploadInput(props) {
|
|||||||
variant="contained"
|
variant="contained"
|
||||||
tabIndex={-1}
|
tabIndex={-1}
|
||||||
startIcon={<AttachFileIcon />}
|
startIcon={<AttachFileIcon />}
|
||||||
|
{...rest}
|
||||||
>
|
>
|
||||||
{props.children}
|
{children}
|
||||||
|
|
||||||
<VisuallyHiddenInput type="file" onChange={props.onChange} />
|
<VisuallyHiddenInput type="file" onChange={onChange} />
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import DialogContentText from '@mui/material/DialogContentText';
|
|||||||
import DialogTitle from '@mui/material/DialogTitle';
|
import DialogTitle from '@mui/material/DialogTitle';
|
||||||
import Typography from '@mui/material/Typography';
|
import Typography from '@mui/material/Typography';
|
||||||
import UploadIcon from '@mui/icons-material/Upload';
|
import UploadIcon from '@mui/icons-material/Upload';
|
||||||
|
import Tooltip from '@mui/material/Tooltip';
|
||||||
|
import Box from '@mui/material/Box';
|
||||||
|
|
||||||
import * as URLS from 'config/urls';
|
import * as URLS from 'config/urls';
|
||||||
import useFormatMessage from 'hooks/useFormatMessage';
|
import useFormatMessage from 'hooks/useFormatMessage';
|
||||||
@@ -80,24 +82,27 @@ function ImportFlowDialog(props) {
|
|||||||
<DialogContent>
|
<DialogContent>
|
||||||
<DialogContentText>
|
<DialogContentText>
|
||||||
{formatMessage('importFlowDialog.description')}
|
{formatMessage('importFlowDialog.description')}
|
||||||
|
|
||||||
<Stack direction="row" alignItems="center" spacing={2} mt={4}>
|
|
||||||
<FileUploadInput
|
|
||||||
onChange={handleFileSelection}
|
|
||||||
data-test="import-flow-dialog-button"
|
|
||||||
>
|
|
||||||
{formatMessage('importFlowDialog.selectFile')}
|
|
||||||
</FileUploadInput>
|
|
||||||
|
|
||||||
{selectedFile && (
|
|
||||||
<Typography>
|
|
||||||
{formatMessage('importFlowDialog.selectedFileInformation', {
|
|
||||||
fileName: selectedFile.name,
|
|
||||||
})}
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
</Stack>
|
|
||||||
</DialogContentText>
|
</DialogContentText>
|
||||||
|
<Stack direction="row" alignItems="center" spacing={2} mt={4}>
|
||||||
|
<FileUploadInput
|
||||||
|
onChange={handleFileSelection}
|
||||||
|
data-test="import-flow-dialog-button"
|
||||||
|
sx={{ flexShrink: 0 }}
|
||||||
|
>
|
||||||
|
{formatMessage('importFlowDialog.selectFile')}
|
||||||
|
</FileUploadInput>
|
||||||
|
|
||||||
|
{selectedFile && (
|
||||||
|
<Box overflow="hidden">
|
||||||
|
<Typography>
|
||||||
|
{formatMessage('importFlowDialog.selectedFileInformation')}
|
||||||
|
</Typography>
|
||||||
|
<Tooltip title={selectedFile.name}>
|
||||||
|
<Typography noWrap>{selectedFile.name}</Typography>
|
||||||
|
</Tooltip>
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|
||||||
<DialogActions sx={{ mb: 1 }}>
|
<DialogActions sx={{ mb: 1 }}>
|
||||||
|
|||||||
@@ -329,7 +329,7 @@
|
|||||||
"importFlowDialog.selectFile": "Select file",
|
"importFlowDialog.selectFile": "Select file",
|
||||||
"importFlowDialog.close": "Close",
|
"importFlowDialog.close": "Close",
|
||||||
"importFlowDialog.import": "Import",
|
"importFlowDialog.import": "Import",
|
||||||
"importFlowDialog.selectedFileInformation": "Selected file: {fileName}",
|
"importFlowDialog.selectedFileInformation": "Selected file:",
|
||||||
"importFlowDialog.successfullyImportedFlow": "The flow has been successfully imported. You can view it <link>here</link>.",
|
"importFlowDialog.successfullyImportedFlow": "The flow has been successfully imported. You can view it <link>here</link>.",
|
||||||
"folders.allFlows": "All flows",
|
"folders.allFlows": "All flows",
|
||||||
"folders.unassignedFlows": "Uncategorized flows",
|
"folders.unassignedFlows": "Uncategorized flows",
|
||||||
|
|||||||
Reference in New Issue
Block a user