allow custom labels in file-selector

This commit is contained in:
Travis Eden 2018-04-02 09:59:23 -04:00 committed by Sean Yesmunt
parent c7a91340dc
commit de8f116709

View file

@ -9,6 +9,8 @@ type Props = {
type: string, type: string,
currentPath: ?string, currentPath: ?string,
onFileChosen: (string, string) => void, onFileChosen: (string, string) => void,
fileLabel: ?string,
directoryLabel: ?string,
}; };
class FileSelector extends React.PureComponent<Props> { class FileSelector extends React.PureComponent<Props> {
@ -47,15 +49,14 @@ class FileSelector extends React.PureComponent<Props> {
input: ?HTMLInputElement; input: ?HTMLInputElement;
render() { render() {
const { type, currentPath } = this.props; const { type, currentPath, fileLabel, directoryLabel } = this.props;
const label =
type === 'file' ? fileLabel || __('Choose File') : directoryLabel || __('Choose Directory');
return ( return (
<FormRow verticallyCentered padded> <FormRow verticallyCentered padded>
<Button <Button button="primary" onClick={() => this.handleButtonClick()} label={label} />
button="primary"
onClick={() => this.handleButtonClick()}
label={type === 'file' ? __('Choose File') : __('Choose Directory')}
/>
<input <input
webkitdirectory="true" webkitdirectory="true"
className="input-copyable" className="input-copyable"