summaryrefslogtreecommitdiff
path: root/app/client/common/browser.component.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/client/common/browser.component.js')
-rw-r--r--app/client/common/browser.component.js18
1 files changed, 7 insertions, 11 deletions
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 && <Loading />}