import { h, Component } from 'preact' import { bindActionCreators } from 'redux' import { connect } from 'react-redux' import { Route, Link } from 'react-router-dom' import { Loading, FileList, FileViewer } from '../../../common' import actions from '../../../actions' class SequenceEditor extends Component { state = { dir: '/', files: [], loading: true } componentDidMount() { this.fetch(this.props.dataset) } componentDidUpdate(prevProps) { if (this.props.dataset !== prevProps.dataset) { this.fetch(this.props.dataset) } } 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('//','/')) } } fetch(dir) { console.log('fetch', dir) const { name: module } = this.props.module.name this.setState({ dir, file: null, loading: true }) actions.socket.list_directory({ module, dir }).then(files => { console.log(files) this.setState({ dir, files, loading: false }) }) } render() { const { app } = this.props const { loading, dir, files, loadingFile, file, } = this.state console.log(this.props, this.state) return (