From 28d6dd9a097be3f76ede22f63c6c68a78607aec8 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sat, 22 Sep 2018 14:43:35 +0200 Subject: move fetch functionality into fileviweer --- app/client/common/browser.component.js | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'app/client/common/browser.component.js') diff --git a/app/client/common/browser.component.js b/app/client/common/browser.component.js index 50b31cf..19cd0f6 100644 --- a/app/client/common/browser.component.js +++ b/app/client/common/browser.component.js @@ -11,19 +11,23 @@ class Browser extends Component { state = { dir: '/', files: [], + file: null, loading: true } + componentDidMount() { this.fetch(this.state.dir) } + handlePick(file) { console.log(file) if (file.dir) { this.fetch([this.state.dir, file.name].join('/').replace('//','/')) } else { - this.fetchFile([this.state.dir, file.name].join('/').replace('//','/')) + this.setState({ file: { ...file, path: this.state.dir } }) } } + fetch(dir) { console.log('fetch', dir) const { tool: module } = this.props.app @@ -33,15 +37,7 @@ class Browser extends Component { this.setState({ dir, files, loading: false }) }) } - fetchFile(fn) { - console.log('fetch file', fn) - const { tool: module } = this.props.app - this.setState({ file: null, loadingFile: true }) - actions.socket.read_file({ module, fn }).then(file => { - console.log(file) - this.setState({ file, loadingFile: false }) - }) - } + render() { const { app } = this.props const { @@ -68,7 +64,7 @@ class Browser extends Component { }} onClickParent={e => { console.log('navigate up') - this.fetch(this.state.dir.split('/').slice(0, -1).join('/') || '/') + this.fetch(dir.split('/').slice(0, -1).join('/') || '/') }} /> {loadingFile && } -- cgit v1.2.3-70-g09d2