Merge branch '1.3.x_branch' of bitbucket.org:blockstorage/repertory-ui into 1.3.x_branch

This commit is contained in:
2020-12-22 12:33:20 -06:00
2 changed files with 18 additions and 8 deletions

View File

@@ -34,7 +34,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(class extends IPCCon
state = { state = {
active_directory: '/', active_directory: '/',
items: [], items: [],
previous_directory: '', previous: [],
} }
componentDidMount() { componentDidMount() {
@@ -89,11 +89,16 @@ export default connect(mapStateToProps, mapDispatchToProps)(class extends IPCCon
<div key={'dir_' + idx} style={{...style}}> <div key={'dir_' + idx} style={{...style}}>
<Button buttonStyles={{textAlign: 'left'}} <Button buttonStyles={{textAlign: 'left'}}
clicked={() => { clicked={() => {
const current_path = path === '..' ? '' : this.state.active_directory; const previous = [...this.state.previous];
if (path === '..') {
path = previous.pop();
} else {
previous.push(this.state.active_directory);
}
this.setState({ this.setState({
items: [], items: [],
active_directory: path === '..' ? this.state.previous_directory : path, active_directory: path,
previous_directory: current_path, previous,
}, () => { }, () => {
this.grabDirectoryItems(); this.grabDirectoryItems();
}); });

View File

@@ -3,10 +3,15 @@ const fs = require('fs');
const helpers = require('../../helpers'); const helpers = require('../../helpers');
const path = require('path'); const path = require('path');
const getDirectories = source => const getDirectories = source => {
fs.readdirSync(source, {withFileTypes: true}) try {
return fs.readdirSync(source, {withFileTypes: true})
.filter(dirent => dirent.isDirectory()) .filter(dirent => dirent.isDirectory())
.map(dirent => dirent.name) .map(dirent => dirent.name);
} catch {
return [];
}
}
const addListeners = ipcMain => { const addListeners = ipcMain => {
ipcMain.on(Constants.IPC_Get_State, event => { ipcMain.on(Constants.IPC_Get_State, event => {