diff --git a/frontend/src/Components/FileBrowser/FileBrowserModalContentConnector.js b/frontend/src/Components/FileBrowser/FileBrowserModalContentConnector.js index fe577b896..da5ae2ab8 100644 --- a/frontend/src/Components/FileBrowser/FileBrowserModalContentConnector.js +++ b/frontend/src/Components/FileBrowser/FileBrowserModalContentConnector.js @@ -42,8 +42,8 @@ function createMapStateToProps() { } const mapDispatchToProps = { - fetchPaths, - clearPaths + dispatchFetchPaths: fetchPaths, + dispatchClearPaths: clearPaths }; class FileBrowserModalContentConnector extends Component { @@ -51,9 +51,16 @@ class FileBrowserModalContentConnector extends Component { // Lifecycle componentDidMount() { - this.props.fetchPaths({ - path: this.props.value, - allowFoldersWithoutTrailingSlashes: true + const { + value, + includeFiles, + dispatchFetchPaths + } = this.props; + + dispatchFetchPaths({ + path: value, + allowFoldersWithoutTrailingSlashes: true, + includeFiles }); } @@ -61,18 +68,24 @@ class FileBrowserModalContentConnector extends Component { // Listeners onFetchPaths = (path) => { - this.props.fetchPaths({ + const { + includeFiles, + dispatchFetchPaths + } = this.props; + + dispatchFetchPaths({ path, - allowFoldersWithoutTrailingSlashes: true + allowFoldersWithoutTrailingSlashes: true, + includeFiles }); } onClearPaths = () => { - // this.props.clearPaths(); + // this.props.dispatchClearPaths(); } onModalClose = () => { - this.props.clearPaths(); + this.props.dispatchClearPaths(); this.props.onModalClose(); } @@ -93,9 +106,14 @@ class FileBrowserModalContentConnector extends Component { FileBrowserModalContentConnector.propTypes = { value: PropTypes.string, - fetchPaths: PropTypes.func.isRequired, - clearPaths: PropTypes.func.isRequired, + includeFiles: PropTypes.bool.isRequired, + dispatchFetchPaths: PropTypes.func.isRequired, + dispatchClearPaths: PropTypes.func.isRequired, onModalClose: PropTypes.func.isRequired }; +FileBrowserModalContentConnector.defaultProps = { + includeFiles: false +}; + export default connect(createMapStateToProps, mapDispatchToProps)(FileBrowserModalContentConnector); diff --git a/frontend/src/Components/Form/PathInput.js b/frontend/src/Components/Form/PathInput.js index b62ba0555..5451844cf 100644 --- a/frontend/src/Components/Form/PathInput.js +++ b/frontend/src/Components/Form/PathInput.js @@ -111,6 +111,7 @@ class PathInput extends Component { value, placeholder, paths, + includeFiles, hasError, hasWarning, hasFileBrowser, @@ -171,6 +172,7 @@ class PathInput extends Component { isOpen={this.state.isFileBrowserModalOpen} name={name} value={value} + includeFiles={includeFiles} onChange={onChange} onModalClose={this.onFileBrowserModalClose} /> @@ -188,6 +190,7 @@ PathInput.propTypes = { value: PropTypes.string, placeholder: PropTypes.string, paths: PropTypes.array.isRequired, + includeFiles: PropTypes.bool.isRequired, hasError: PropTypes.bool, hasWarning: PropTypes.bool, hasFileBrowser: PropTypes.bool, diff --git a/frontend/src/Components/Form/PathInputConnector.js b/frontend/src/Components/Form/PathInputConnector.js index 4916daec8..38ea37065 100644 --- a/frontend/src/Components/Form/PathInputConnector.js +++ b/frontend/src/Components/Form/PathInputConnector.js @@ -28,8 +28,8 @@ function createMapStateToProps() { } const mapDispatchToProps = { - fetchPaths, - clearPaths + dispatchFetchPaths: fetchPaths, + dispatchClearPaths: clearPaths }; class PathInputConnector extends Component { @@ -38,11 +38,19 @@ class PathInputConnector extends Component { // Listeners onFetchPaths = (path) => { - this.props.fetchPaths({ path }); + const { + includeFiles, + dispatchFetchPaths + } = this.props; + + dispatchFetchPaths({ + path, + includeFiles + }); } onClearPaths = () => { - this.props.clearPaths(); + this.props.dispatchClearPaths(); } // @@ -60,8 +68,13 @@ class PathInputConnector extends Component { } PathInputConnector.propTypes = { - fetchPaths: PropTypes.func.isRequired, - clearPaths: PropTypes.func.isRequired + includeFiles: PropTypes.bool.isRequired, + dispatchFetchPaths: PropTypes.func.isRequired, + dispatchClearPaths: PropTypes.func.isRequired +}; + +PathInputConnector.defaultProps = { + includeFiles: false }; export default connect(createMapStateToProps, mapDispatchToProps)(PathInputConnector); diff --git a/frontend/src/Components/Form/ProviderFieldFormGroup.js b/frontend/src/Components/Form/ProviderFieldFormGroup.js index 98922dae4..84268806f 100644 --- a/frontend/src/Components/Form/ProviderFieldFormGroup.js +++ b/frontend/src/Components/Form/ProviderFieldFormGroup.js @@ -20,6 +20,8 @@ function getType(type) { return inputTypes.NUMBER; case 'path': return inputTypes.PATH; + case 'filepath': + return inputTypes.PATH; case 'select': return inputTypes.SELECT; case 'tag': @@ -84,7 +86,7 @@ function ProviderFieldFormGroup(props) { errors={errors} warnings={warnings} pending={pending} - hasFileBrowser={false} + includeFiles={type === 'filepath' ? true : undefined} onChange={onChange} {...otherProps} /> diff --git a/frontend/src/Store/Actions/pathActions.js b/frontend/src/Store/Actions/pathActions.js index 56b741867..139ab9e23 100644 --- a/frontend/src/Store/Actions/pathActions.js +++ b/frontend/src/Store/Actions/pathActions.js @@ -46,14 +46,16 @@ export const actionHandlers = handleThunks({ const { path, - allowFoldersWithoutTrailingSlashes = false + allowFoldersWithoutTrailingSlashes = false, + includeFiles = false } = payload; const promise = createAjaxRequest({ url: '/filesystem', data: { path, - allowFoldersWithoutTrailingSlashes + allowFoldersWithoutTrailingSlashes, + includeFiles } }).request;