Added root folder for share functionality (#1005)

main
Boris Sekachev 6 years ago committed by Nikita Manovich
parent 337f7a0018
commit d24dd740e6

@ -216,11 +216,13 @@ export default class FileManager extends React.PureComponent<Props, State> {
public render(): JSX.Element { public render(): JSX.Element {
const { withRemote } = this.props; const { withRemote } = this.props;
const { active } = this.state;
return ( return (
<> <>
<Tabs <Tabs
type='card' type='card'
activeKey={active}
tabBarGutter={5} tabBarGutter={5}
onChange={ onChange={
(activeKey: string): void => this.setState({ (activeKey: string): void => this.setState({

@ -26,10 +26,10 @@ interface DispatchToProps {
function mapStateToProps(state: CombinedState): StateToProps { function mapStateToProps(state: CombinedState): StateToProps {
function convert(items: ShareItem[], path?: string): TreeNodeNormal[] { function convert(items: ShareItem[], path?: string): TreeNodeNormal[] {
return items.map((item): TreeNodeNormal => { return items.map((item): TreeNodeNormal => {
const key = `${path}/${item.name}`.replace(/\/+/g, '/'); // // => / const key = `${path}${item.name}/`;
return { return {
key, key,
title: item.name, title: item.name || 'root',
isLeaf: item.type !== 'DIR', isLeaf: item.type !== 'DIR',
children: convert(item.children, key), children: convert(item.children, key),
}; };
@ -38,7 +38,7 @@ function mapStateToProps(state: CombinedState): StateToProps {
const { root } = state.share; const { root } = state.share;
return { return {
treeData: convert(root.children, root.name), treeData: convert([root], ''),
}; };
} }

@ -10,7 +10,7 @@ import {
const defaultState: ShareState = { const defaultState: ShareState = {
root: { root: {
name: '/', name: '',
type: 'DIR', type: 'DIR',
children: [], children: [],
}, },

Loading…
Cancel
Save