TagSpaces is an offline, open source, document manager with tagging support
fix DnD to leaf nodes
stanimir44de71225df0
diff --git a/app/assets/rc-table.css b/app/assets/rc-table.cssindex 75c524d86..7173d287a 100644--- a/app/assets/rc-table.css+++ b/app/assets/rc-table.css@@ -15,3 +15,25 @@padding: 8px;background: transparent !important;}++.rc-table tr.dropzone td {+ /*margin: 5px;*/+ /*background-color: #1dd19f40; overriden with transparent from .rc-table !important*/+ border: 3px dashed white;+ /*font-size: 20px;*/+ /*font-weight: bold;*/+ /*color: white;*/+}++.rc-table tr.dropzone td span {+ white-space: nowrap;+ overflow: hidden;+}+.rc-table tr.dropzone td::before {+ content: "Move files here...";+ /*position: absolute;+ top: 0;+ left: 0;+ right: 0;+ bottom: 0;*/+}diff --git a/app/components/LocationManager.tsx b/app/components/LocationManager.tsxindex 0f2a869fc..0b36331bf 100644--- a/app/components/LocationManager.tsx+++ b/app/components/LocationManager.tsx@@ -75,6 +75,7 @@ import i18n from '../services/i18n';import AppConfig from '../config';import PlatformIO from '../services/platform-io';import TargetMoveFileBox from './TargetMoveFileBox';+import TargetTableMoveFileBox from './TargetTableMoveFileBox';import DragItemTypes from './DragItemTypes';import IOActions from '../reducers/io-actions';@@ -611,8 +612,11 @@ class LocationManager extends React.Component<Props, State> {);return;}- const targetPath = item.path;+ let targetPath = item.path;const targetLocation = item.location;+ if(targetPath === undefined){+ targetPath = targetLocation.path;+ }/*if (item.children && item.children.props && item.children.props.path) {targetPath = item.children.props.path;} else {@@ -622,10 +626,9 @@ class LocationManager extends React.Component<Props, State> {// TODO handle monitor -> isOver and change folder iconconsole.log('Dropped files: ' + path);if (targetLocation && targetLocation.type === locationType.TYPE_CLOUD) {- PlatformIO.enableObjectStoreSupport(targetLocation)- .then(() => {- this.props.uploadFiles(arrPath, targetPath);- });+ PlatformIO.enableObjectStoreSupport(targetLocation).then(() => {+ this.props.uploadFiles(arrPath, targetPath);+ });} else {//if (targetLocationType === locationType.TYPE_LOCAL) {this.props.moveFiles(arrPath, targetPath);@@ -634,7 +637,7 @@ class LocationManager extends React.Component<Props, State> {}};- renderBodyCell = props => (+ /*renderBodyCell = props => (<td {...props} style={{ position: 'relative' }}><TargetMoveFileBox// @ts-ignore@@ -651,6 +654,15 @@ class LocationManager extends React.Component<Props, State> {{props.children}</TargetMoveFileBox></td>+ );*/+ renderBodyRow = props => (+ <TargetTableMoveFileBox+ // @ts-ignore+ accepts={[DragItemTypes.FILE]}+ onDrop={this.handleFileMoveDrop}+ location={props.location}+ {...props}+ />);// <Tooltip id="tooltip-icon" title={i18n.t('core:moreOperations')} placement="bottom"></Tooltip>@@ -674,7 +686,7 @@ class LocationManager extends React.Component<Props, State> {// className={classes.locationListArea}components={{// header: { cell: this.renderHeaderRow },- body: { cell: this.renderBodyCell }+ body: { row: this.renderBodyRow }}}showHeader={false}// className="table"@@ -683,12 +695,16 @@ class LocationManager extends React.Component<Props, State> {columns={columns}indentSize={20}// expandedRowRender={this.expandedRowRender}- onExpand={this.onExpand}+ expandable={{ onExpand: this.onExpand }}// expandIcon={this.CustomExpandIcon}// expandIconAsCell/* onRow={(record, index) => ({onClick: this.onRowClick.bind(null, record, index),})} */+ onRow={(record, index) => ({+ index,+ location: record+ })}/>);}@@ -741,24 +757,24 @@ class LocationManager extends React.Component<Props, State> {</Typography></div>) : (- <TargetMoveFileBox- accepts={[DragItemTypes.FILE]}- onDrop={this.handleFileMoveDrop}- path={location.paths[0]}- location={location}+ <TargetMoveFileBox+ accepts={[DragItemTypes.FILE]}+ onDrop={this.handleFileMoveDrop}+ path={location.paths[0]}+ location={location}>- <div style={{ maxWidth: 250 }} >- <Typography- variant="inherit"- style={{ paddingLeft: 5, paddingRight: 5 }}- className={this.props.classes.header}- data-tid="locationTitleElement"- noWrap- >- {location.name}- </Typography>- </div>- </TargetMoveFileBox>+ <div style={{ maxWidth: 250 }}>+ <Typography+ variant="inherit"+ style={{ paddingLeft: 5, paddingRight: 5 }}+ className={this.props.classes.header}+ data-tid="locationTitleElement"+ noWrap+ >+ {location.name}+ </Typography>+ </div>+ </TargetMoveFileBox>)}{!isLocationsReadOnly && (<ListItemSecondaryAction>diff --git a/app/components/TargetTableMoveFileBox.tsx b/app/components/TargetTableMoveFileBox.tsxnew file mode 100644index 000000000..ffbc049cf--- /dev/null+++ b/app/components/TargetTableMoveFileBox.tsx@@ -0,0 +1,72 @@+/**+ * TagSpaces - universal file and folder organizer+ * Copyright (C) 2017-present TagSpaces UG (haftungsbeschraenkt)+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License (version 3) as+ * published by the Free Software Foundation.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ */++import React from 'react';+import { DropTarget } from 'react-dnd';++/* const styles: any = () => ({+ dropzone: {+ margin: 5,+ position: 'absolute',+ top: 0,+ left: 0,+ right: 0,+ bottom: 0,+ backgroundColor: '#1dd19f40',+ zIndex: 1000,+ border: '3px dashed white',+ display: 'flex',+ justifyContent: 'center',+ alignItems: 'center',+ textAlign: 'center',+ fontSize: '20px',+ fontWeight: 'bold',+ color: 'white'+ }+}); */++const boxTarget = {+ drop(props, monitor) {+ return props.onDrop(props, monitor);+ }+};++interface Props {+ canDrop: boolean;+ isOver: boolean;+ connectDropTarget: any;+ className: string;+}++const TargetTableMoveFileBox = (props: Props) => {+ const { canDrop, isOver, connectDropTarget, ...restProps } = props;+ if (canDrop && isOver) {+ restProps.className += ' dropzone';+ }+ return connectDropTarget(<tr {...restProps} />);+};++export default DropTarget(+ props => props.accepts,+ boxTarget,+ (connect, monitor) => ({+ connectDropTarget: connect.dropTarget(),+ isOver: monitor.isOver(),+ canDrop: monitor.canDrop()+ })+ )(TargetTableMoveFileBox);