Skip to content

TagSpaces is an offline, open source, document manager with tagging support

fixes

stanimirf22dab246f33
diff --git a/app/components/DirectoryTreeView.tsx b/app/components/DirectoryTreeView.tsx
index 25ce80492..ce5d09734 100644
--- a/app/components/DirectoryTreeView.tsx
+++ b/app/components/DirectoryTreeView.tsx
@@ -20,10 +20,10 @@ import React, { useState, forwardRef, useImperativeHandle } from 'react';
import Table from 'rc-table';
import FolderIcon from '@material-ui/icons/FolderOpen';
import { Location } from '-/reducers/locations';
-import TargetMoveFileBox from './TargetMoveFileBox';
import DragItemTypes from '-/components/DragItemTypes';
import AppConfig from '-/config';
import PlatformIO from '-/services/platform-io';
+import TargetTableMoveFileBox from '-/components/TargetTableMoveFileBox';
interface Props {
classes: any;
@@ -67,7 +67,7 @@ const DirectoryTreeView = forwardRef((props: Props, ref) => {
setData(dirsTree);
};*/
- const renderBodyCell = props => (
+ /*const renderBodyCell = props => (
<td {...props}>
<TargetMoveFileBox
// @ts-ignore
@@ -77,6 +77,16 @@ const DirectoryTreeView = forwardRef((props: Props, ref) => {
{props.children}
</TargetMoveFileBox>
</td>
+ );*/
+
+ const renderBodyRow = props => (
+ <TargetTableMoveFileBox
+ // @ts-ignore
+ accepts={[DragItemTypes.FILE]}
+ onDrop={props.handleFileMoveDrop}
+ location={props.location}
+ {...props}
+ />
);
const renderNameColumnAction = field => {
@@ -107,13 +117,13 @@ const DirectoryTreeView = forwardRef((props: Props, ref) => {
} */
});
- /*const onExpand = (expanded, record) => {
+ const onExpand = (expanded, record) => {
// console.log('onExpand', expanded + JSON.stringify(record));
if (expanded) {
// this.onRowClick(record);
loadSubDirectories(record, 1);
}
- };*/
+ };
const onRowClick = subDir => {
loadSubDirectories(subDir, 1);
@@ -290,29 +300,30 @@ const DirectoryTreeView = forwardRef((props: Props, ref) => {
};
if (isExpanded && data != undefined) {
+ // @ts-ignore
return (
- // @ts-ignore
<Table
- //key={props.location.uuid}
// defaultExpandAllRows
// className={classes.locationListArea}
components={{
// header: { cell: this.renderHeaderRow },
- body: { cell: renderBodyCell }
+ body: { row: renderBodyRow }
}}
showHeader={false}
// className="table"
rowKey="path"
data={data[props.location.uuid]}
columns={columns}
- className="table"
- // expandedRowRender={this.expandedRowRender}
- //onExpand={onExpand}
+ indentSize={20}
+ expandable={{ onExpand: onExpand }}
// expandIcon={this.CustomExpandIcon}
// expandIconAsCell
- /* onRow={(record, index) => ({
- onClick: this.onRowClick.bind(null, record, index),
- })} */
+ // @ts-ignore
+ onRow={(record, index) => ({
+ index,
+ location: record,
+ handleFileMoveDrop: props.handleFileMoveDrop
+ })}
/>
);
}
diff --git a/app/components/LocationManager.tsx b/app/components/LocationManager.tsx
index f8276d336..f3d66817a 100644
--- a/app/components/LocationManager.tsx
+++ b/app/components/LocationManager.tsx
@@ -253,10 +253,10 @@ class LocationManager extends React.Component<Props, State> {
if (this.state.selectedLocation && this.state.selectedLocation.uuid) {
this.props.closeLocation(this.state.selectedLocation.uuid);
this.directoryTreeRef[this.state.selectedLocation.uuid] = undefined;
- //this.directoryTreeRef[this.state.selectedLocation.uuid].closeLocation();
- /*this.setState({
+ // this.directoryTreeRef[this.state.selectedLocation.uuid].closeLocation();
+ /* this.setState({
dirs: {}
- });*/
+ }); */
}
};
@@ -338,15 +338,15 @@ class LocationManager extends React.Component<Props, State> {
});
};
- //todo https://stackoverflow.com/questions/37949981/call-child-method-from-parent
- //const directoryTreeRef = useRef();
+ // todo https://stackoverflow.com/questions/37949981/call-child-method-from-parent
+ // const directoryTreeRef = useRef();
handleLocationClick = (location: Location) => {
this.directoryTreeRef[location.uuid].changeLocation(location);
if (location.uuid === this.props.currentLocationId) {
this.props.loadDirectoryContent(location.paths[0]);
} else {
- //this.directoryTreeRef[location.uuid].loadSubDir(location, 1);
+ // this.directoryTreeRef[location.uuid].loadSubDir(location, 1);
this.props.setSelectedEntries([]);
this.props.openLocation(location);
this.state.locationRootPath = location.paths[0];
@@ -376,7 +376,7 @@ class LocationManager extends React.Component<Props, State> {
});
};
- /*renderNameColumnAction = field => {
+ /* renderNameColumnAction = field => {
const children = (
<span style={{fontSize: 15, marginLeft: 5}} title={field}>
<FolderIcon
@@ -390,17 +390,17 @@ class LocationManager extends React.Component<Props, State> {
children,
props: {}
};
- };*/
+ }; */
- /*handleCellClick = (record, index) => ({
+ /* handleCellClick = (record, index) => ({
onClick: () => {
this.onRowClick(record);
}
- });*/
+ }); */
- /*onExpand = (expanded, record) => {
+ /* onExpand = (expanded, record) => {
// console.log('onExpand', expanded + JSON.stringify(record));
if (expanded) {
// this.onRowClick(record);
@@ -411,7 +411,7 @@ class LocationManager extends React.Component<Props, State> {
onRowClick = subDir => {
this.loadSubDirectories(subDir, 1);
this.props.loadDirectoryContent(subDir.path);
- };*/
+ }; */
/**
* https://github.com/react-component/table/blob/master/examples/react-dnd.js
@@ -457,27 +457,30 @@ class LocationManager extends React.Component<Props, State> {
if (targetPath === undefined) {
targetPath = targetLocation.path;
}
- /*if (item.children && item.children.props && item.children.props.path) {
+ /* if (item.children && item.children.props && item.children.props.path) {
targetPath = item.children.props.path;
} else {
targetPath = item.children[1].props.record.path;
- }*/
- if (monitor && targetPath != undefined) {
+ } */
+ if (monitor && targetPath !== undefined) {
// TODO handle monitor -> isOver and change folder icon
console.log('Dropped files: ' + path);
if (targetLocation && targetLocation.type === locationType.TYPE_CLOUD) {
PlatformIO.enableObjectStoreSupport(targetLocation).then(() => {
this.props.uploadFiles(arrPath, targetPath);
+ return true;
+ }).catch(error => {
+ console.log('enableObjectStoreSupport', error);
});
} else {
- //if (targetLocationType === locationType.TYPE_LOCAL) {
+ // if (targetLocationType === locationType.TYPE_LOCAL) {
this.props.moveFiles(arrPath, targetPath);
}
this.props.setSelectedEntries([]);
}
};
- renderBodyRow = props => (
+ /* renderBodyRow = props => (
<TargetTableMoveFileBox
// @ts-ignore
accepts={[DragItemTypes.FILE]}
@@ -485,13 +488,13 @@ class LocationManager extends React.Component<Props, State> {
location={props.location}
{...props}
/>
- );
+ ); */
// <Tooltip id="tooltip-icon" title={i18n.t('core:moreOperations')} placement="bottom"></Tooltip>
renderLocation = (location: Location) => {
/* if (this.directoryTreeRef[location.uuid] === undefined) {
this.directoryTreeRef[location.uuid] = React.createRef();
- }*/
+ } */
const isCloudLocation = location.type === locationType.TYPE_CLOUD;
/* if (this.state.dirs[location.uuid] !== undefined) {
const columns = [
@@ -621,7 +624,9 @@ class LocationManager extends React.Component<Props, State> {
)}
</ListItem>
<DirectoryTreeView
- ref={dirTree => (this.directoryTreeRef[location.uuid] = dirTree)}
+ ref={dirTree => {
+ this.directoryTreeRef[location.uuid] = dirTree;
+ }}
classes={this.props.classes}
loadDirectoryContent={this.props.loadDirectoryContent}
location={location}
@@ -719,8 +724,8 @@ class LocationManager extends React.Component<Props, State> {
this.props.removeLocation(this.state.selectedLocation);
}
}}
- cancelDialogTID={'cancelDeleteLocationDialog'}
- confirmDialogTID={'confirmDeleteLocationDialog'}
+ cancelDialogTID="cancelDeleteLocationDialog"
+ confirmDialogTID="confirmDeleteLocationDialog"
/>
<SelectDirectoryDialog
open={this.state.isSelectDirectoryDialogOpened}