Skip to content

Commit 87ebf14

Browse files
committed
use helper text with input directory for 'include files' checkbox
1 parent 1d8887a commit 87ebf14

File tree

1 file changed

+27
-11
lines changed

1 file changed

+27
-11
lines changed
Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,46 @@
11
import React, { ChangeEvent } from 'react';
2+
import { useTranslator } from '../hooks';
23

3-
import { Box, Checkbox, FormControlLabel, FormGroup } from '@mui/material';
4-
import FolderIcon from '@mui/icons-material/Folder';
4+
import {
5+
Checkbox,
6+
FormControlLabel,
7+
FormGroup,
8+
FormHelperText
9+
} from '@mui/material';
510

611
export function PackageInputFolderControl(props: {
712
onChange: (event: ChangeEvent<HTMLInputElement>) => void;
813
inputFile: string;
914
}): JSX.Element {
15+
const trans = useTranslator('jupyterlab');
1016
const inputFilePath = props.inputFile.split('/');
1117
inputFilePath.pop();
12-
const inputFolder = inputFilePath.join('/');
18+
19+
let helperText: string;
20+
if (inputFilePath.length) {
21+
const inputFolder = `/${inputFilePath.join('/')}`;
22+
helperText = trans.__(
23+
'Make all files under %1 available to input file when this job runs',
24+
inputFolder
25+
);
26+
} else {
27+
helperText = trans.__(
28+
'Make all files under input file’s folder available to input file when this job runs'
29+
);
30+
}
31+
1332
return (
1433
<FormGroup>
1534
<FormControlLabel
1635
control={
1736
<Checkbox onChange={props.onChange} name={'packageInputFolder'} />
1837
}
19-
label={
20-
<Box display="flex" alignItems="center" gap={1}>
21-
<span>Include all files under</span>
22-
<FolderIcon fontSize="small" sx={{ color: 'action.active' }} />
23-
<span>/</span>
24-
<span>{inputFolder}</span>
25-
</Box>
26-
}
38+
label={trans.__('Package input folder')}
39+
aria-describedby="jp-package-input-folder-helper-text"
2740
/>
41+
<FormHelperText id="jp-package-input-folder-helper-text">
42+
{helperText}
43+
</FormHelperText>
2844
</FormGroup>
2945
);
3046
}

0 commit comments

Comments
 (0)