Skip to content

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

TSN548 - changes needed for the Kanban perspective (#1764)

Stanimir00cc26e77a18
diff --git a/app/components/EntryProperties.tsx b/app/components/EntryProperties.tsx
index 63b4f97b0..28853d10f 100644
--- a/app/components/EntryProperties.tsx
+++ b/app/components/EntryProperties.tsx
@@ -65,7 +65,8 @@ import {
enhanceOpenedEntry,
convertMarkDown,
fileNameValidation,
- dirNameValidation
+ dirNameValidation,
+ normalizeUrl
} from '-/services/utils-io';
import { parseGeoLocation } from '-/utils/geo';
import { Pro } from '../pro';
@@ -532,18 +533,7 @@ function EntryProperties(props: Props) {
PlatformIO.getDirSeparator()
);
}
- /**
- * normalize path for URL is always '/'
- * TODO move this in common module
- */
- function normalizeUrl(url: string) {
- if (PlatformIO.getDirSeparator() !== '/') {
- if (url) {
- return url.replaceAll(PlatformIO.getDirSeparator(), '/');
- }
- }
- return url;
- }
+
let url;
let bgndUrl;
if (PlatformIO.haveObjectStoreSupport() || PlatformIO.haveWebDavSupport()) {
diff --git a/app/perspectives/common/main-container.tsx b/app/perspectives/common/main-container.tsx
new file mode 100644
index 000000000..7160e9449
--- /dev/null
+++ b/app/perspectives/common/main-container.tsx
@@ -0,0 +1,300 @@
+import { TS } from '-/tagspaces.namespace';
+import FileSourceDnd from '-/components/FileSourceDnd';
+import TargetMoveFileBox from '-/components/TargetMoveFileBox';
+import DragItemTypes from '-/components/DragItemTypes';
+import React from 'react';
+import { locationType } from '@tagspaces/tagspaces-platforms/misc';
+import PlatformIO from '-/services/platform-facade';
+import AppConfig from '@tagspaces/tagspaces-platforms/AppConfig';
+import i18n from '-/services/i18n';
+
+export const fileOperationsEnabled = selectedEntries => {
+ let selectionContainsDirectories = false;
+ if (selectedEntries && selectedEntries.length > 0) {
+ selectionContainsDirectories = selectedEntries.some(
+ entry => entry !== undefined && !entry.isFile
+ );
+ return !selectionContainsDirectories;
+ }
+ return false;
+};
+
+export const folderOperationsEnabled = selectedEntries => {
+ let selectionContainsFiles = false;
+ if (selectedEntries && selectedEntries.length > 0) {
+ selectionContainsFiles = selectedEntries.some(
+ entry => entry !== undefined && entry.isFile
+ );
+ }
+ return !selectionContainsFiles;
+};
+
+export const renderCell = (
+ fsEntry: TS.FileSystemEntry,
+ index: number,
+ cellContent: (
+ fsEntry: TS.FileSystemEntry,
+ index: number,
+ handleGridContextMenu,
+ handleGridCellClick,
+ handleGridCellDblClick,
+ isLast?: boolean
+ ) => any,
+ classes,
+ theme,
+ showDirectories: boolean,
+ isReadOnlyMode: boolean,
+ desktopMode: boolean,
+ singleClickAction: string,
+ currentLocation,
+ selectedEntries,
+ setSelectedEntries,
+ lastSelectedEntry,
+ directoryContent,
+ openFsEntry,
+ openFileNatively,
+ loadDirectoryContent,
+ setFileContextMenuAnchorEl,
+ setDirContextMenuAnchorEl,
+ showNotification: (
+ text: string,
+ notificationType: string,
+ autohide: boolean
+ ) => void,
+ moveFiles: (files: Array<string>, destination: string) => Promise<boolean>,
+ clearSelection: () => void,
+ isLast?: boolean
+) => {
+ if (!fsEntry.isFile && !showDirectories) {
+ return;
+ }
+
+ const handleGridContextMenu = (event, fsEntry: TS.FileSystemEntry) => {
+ event.preventDefault();
+ event.stopPropagation();
+ // setMouseX(event.clientX);
+ // setMouseY(event.clientY);
+ const isEntryExist = selectedEntries.some(
+ entry => entry.uuid === fsEntry.uuid
+ );
+ if (fsEntry.isFile) {
+ if (!desktopMode) {
+ if (!isEntryExist) {
+ if (selectedEntries.length > 0) {
+ setSelectedEntries([...selectedEntries, fsEntry]);
+ } else {
+ setSelectedEntries([fsEntry]);
+ }
+ }
+ } else if (
+ selectedEntries.length === 0 ||
+ !fileOperationsEnabled(selectedEntries)
+ ) {
+ setSelectedEntries([fsEntry]);
+ } else if (event.ctrlKey) {
+ if (!isEntryExist) {
+ setSelectedEntries([...selectedEntries, fsEntry]);
+ }
+ } else if (isEntryExist) {
+ // update selected entry
+ setSelectedEntries([
+ ...selectedEntries.filter(entry => entry.uuid !== fsEntry.uuid),
+ fsEntry
+ ]);
+ } else {
+ setSelectedEntries([fsEntry]);
+ }
+ setFileContextMenuAnchorEl(event.currentTarget);
+ } else {
+ if (
+ selectedEntries.length === 0 ||
+ !folderOperationsEnabled(selectedEntries)
+ ) {
+ setSelectedEntries([fsEntry]);
+ } else if (isEntryExist) {
+ // update selected entry
+ setSelectedEntries([
+ ...selectedEntries.filter(entry => entry.uuid !== fsEntry.uuid),
+ fsEntry
+ ]);
+ } else {
+ setSelectedEntries([fsEntry]);
+ }
+ setDirContextMenuAnchorEl(event.currentTarget);
+ }
+ };
+
+ const openLocation = (fsEntry: TS.FileSystemEntry) => {
+ if (fsEntry.isFile) {
+ setSelectedEntries([fsEntry]);
+ openFsEntry(fsEntry);
+ } else {
+ console.log('Handle Grid cell db click, selected path : ', fsEntry.path);
+ loadDirectoryContent(fsEntry.path, true, true);
+ }
+ };
+
+ const handleGridCellDblClick = (event, fsEntry: TS.FileSystemEntry) => {
+ setSelectedEntries([]);
+ if (currentLocation.type === locationType.TYPE_CLOUD) {
+ PlatformIO.enableObjectStoreSupport(currentLocation)
+ .then(() => {
+ openLocation(fsEntry);
+ return true;
+ })
+ .catch(error => {
+ console.log('enableObjectStoreSupport', error);
+ });
+ } else if (currentLocation.type === locationType.TYPE_WEBDAV) {
+ PlatformIO.enableWebdavSupport(currentLocation);
+ openLocation(fsEntry);
+ } else if (currentLocation.type === locationType.TYPE_LOCAL) {
+ PlatformIO.disableObjectStoreSupport();
+ PlatformIO.disableWebdavSupport();
+ openLocation(fsEntry);
+ }
+ };
+
+ const handleGridCellClick = (event, fsEntry: TS.FileSystemEntry) => {
+ /*const {
+ selectedEntries,
+ directoryContent,
+ lastSelectedEntry,
+ setSelectedEntries
+ } = props;*/
+ const selectHelperKey = AppConfig.isMacLike ? event.metaKey : event.ctrlKey;
+ if (event.shiftKey) {
+ let lastSelectedIndex;
+ if (lastSelectedEntry) {
+ lastSelectedIndex = directoryContent.findIndex(
+ entry => entry.path === lastSelectedEntry.path
+ );
+ }
+ const currentSelectedIndex = directoryContent.findIndex(
+ entry => entry.path === fsEntry.path
+ );
+ if (lastSelectedIndex < 0) {
+ lastSelectedIndex = currentSelectedIndex;
+ }
+
+ let entriesToSelect;
+ // console.log('lastSelectedIndex: ' + lastSelectedIndex + ' currentSelectedIndex: ' + currentSelectedIndex);
+ if (currentSelectedIndex > lastSelectedIndex) {
+ entriesToSelect = directoryContent.slice(
+ lastSelectedIndex,
+ currentSelectedIndex + 1
+ );
+ } else if (currentSelectedIndex < lastSelectedIndex) {
+ entriesToSelect = directoryContent
+ .slice(currentSelectedIndex, lastSelectedIndex + 1)
+ .reverse();
+ } else if (currentSelectedIndex === lastSelectedIndex) {
+ entriesToSelect = [fsEntry];
+ }
+
+ setSelectedEntries(entriesToSelect);
+ } else if (event.type === 'drag') {
+ if (
+ selectedEntries &&
+ selectedEntries.some(entry => entry.path === fsEntry.path)
+ ) {
+ } else {
+ const currentSelectedEntry = directoryContent.find(
+ entry => entry.path === fsEntry.path
+ );
+ if (currentSelectedEntry) {
+ // in KanBan directoryContent not content dragging entry from subfolder
+ setSelectedEntries([currentSelectedEntry]);
+ }
+ }
+ } else if (selectHelperKey) {
+ if (
+ selectedEntries &&
+ selectedEntries.some(entry => entry.path === fsEntry.path)
+ ) {
+ setSelectedEntries(
+ selectedEntries.filter(entry => entry.path !== fsEntry.path)
+ ); // deselect selected entry
+ } else {
+ setSelectedEntries([...selectedEntries, fsEntry]);
+ }
+ } else {
+ setSelectedEntries([fsEntry]);
+ if (fsEntry.isFile) {
+ if (singleClickAction === 'openInternal') {
+ openFsEntry(fsEntry);
+ } else if (singleClickAction === 'openExternal') {
+ openFileNatively(fsEntry.path);
+ }
+ }
+ }
+ };
+
+ const handleFileMoveDrop = (item, monitor) => {
+ if (isReadOnlyMode) {
+ showNotification(i18n.t('core:dndDisabledReadOnlyMode'), 'error', true);
+ return;
+ }
+ if (monitor) {
+ const mItem = monitor.getItem();
+ let arrPath;
+ if (mItem.selectedEntries && mItem.selectedEntries.length > 0) {
+ const arrSelected = mItem.selectedEntries
+ .map(entry => entry.path)
+ // remove target folder selection
+ .filter(epath => epath !== item.path);
+ if (arrSelected.length > 0) {
+ arrPath = arrSelected;
+ } else {
+ arrPath = [mItem.path];
+ }
+ } else {
+ arrPath = [mItem.path];
+ }
+ console.log('Dropped files: ' + item.path);
+ moveFiles(arrPath, item.path);
+ clearSelection();
+ }
+ };
+
+ const key = fsEntry.path;
+
+ if (fsEntry.isFile) {
+ return (
+ <FileSourceDnd key={key}>
+ {cellContent(
+ fsEntry,
+ index,
+ handleGridContextMenu,
+ handleGridCellClick,
+ handleGridCellDblClick,
+ isLast
+ )}
+ </FileSourceDnd>
+ );
+ }
+
+ return (
+ <div
+ style={{
+ position: 'relative'
+ }}
+ key={key}
+ >
+ <TargetMoveFileBox
+ accepts={[DragItemTypes.FILE]}
+ path={fsEntry.path}
+ onDrop={handleFileMoveDrop}
+ >
+ {cellContent(
+ fsEntry,
+ index,
+ handleGridContextMenu,
+ handleGridCellClick,
+ handleGridCellDblClick,
+ isLast
+ )}
+ </TargetMoveFileBox>
+ </div>
+ );
+};
diff --git a/app/perspectives/grid-perspective/components/GridPagination.tsx b/app/perspectives/grid-perspective/components/GridPagination.tsx
index 6ef77197d..8dba5320e 100644
--- a/app/perspectives/grid-perspective/components/GridPagination.tsx
+++ b/app/perspectives/grid-perspective/components/GridPagination.tsx
@@ -18,7 +18,6 @@
import React, { useEffect, useRef } from 'react';
import { connect } from 'react-redux';
-import { alpha } from '@mui/material/styles';
import Typography from '@mui/material/Typography';
import Tooltip from '-/components/Tooltip';
import Grid from '@mui/material/Grid';
@@ -50,27 +49,43 @@ import EntryIcon from '-/components/EntryIcon';
import TagsPreview from '-/components/TagsPreview';
import TagContainer from '-/components/TagContainer';
import { TS } from '-/tagspaces.namespace';
-import { getMetaForEntry, getDescriptionPreview } from '-/services/utils-io';
+import {
+ getMetaForEntry,
+ getDescriptionPreview,
+ normalizeUrl
+} from '-/services/utils-io';
import PlatformIO from '-/services/platform-facade';
import { MilkdownEditor } from '@tagspaces/tagspaces-md';
+import { renderCell } from '-/perspectives/common/main-container';
interface Props {
isMetaLoaded: boolean;
setIsMetaLoaded: (isLoaded: boolean) => void;
style?: any;
+ classes: any;
theme: any;
// gridRef: Object;
directories: Array<TS.FileSystemEntry>;
showDirectories: boolean;
showDetails: boolean;
showDescription: boolean;
+ isReadOnlyMode: boolean;
+ layoutType: string;
showTags: boolean;
+ desktopMode: boolean;
currentDirectoryDescription: string;
thumbnailMode: string;
entrySize: string;
files: Array<TS.FileSystemEntry>;
// pageEntries: Array<TS.FileSystemEntry>;
- renderCell: (entry: TS.FileSystemEntry, isLast?: boolean) => void;
+ getCellContent: (
+ fsEntry: TS.FileSystemEntry,
+ index: number,
+ handleGridContextMenu,
+ handleGridCellClick,
+ handleGridCellDblClick,
+ isLast?: boolean
+ ) => void;
currentDirectoryColor: string;
currentDirectoryTags: Array<TS.Tag>;
isAppLoading: boolean;
@@ -89,6 +104,28 @@ interface Props {
selectedEntries; // cache only
// setMetaForCurrentDir: (metaFiles: Array<any>) => void;
lastBackgroundImageChange: number;
+ setSelectedEntries: (selectedEntries: Array<TS.FileSystemEntry>) => void;
+ singleClickAction: string;
+ currentLocation: TS.Location;
+ lastSelectedEntry: any;
+ directoryContent: Array<TS.FileSystemEntry>;
+ supportedFileTypes: Array<any>;
+ openFsEntry: (fsEntry?: TS.FileSystemEntry) => void;
+ openFileNatively: (path?: string) => void;
+ loadDirectoryContent: (
+ path: string,
+ generateThumbnails: boolean,
+ loadDirMeta?: boolean
+ ) => void;
+ setFileContextMenuAnchorEl: (HTMLElement) => void;
+ setDirContextMenuAnchorEl: (HTMLElement) => void;
+ showNotification: (
+ text: string,
+ notificationType: string,
+ autohide: boolean
+ ) => void;
+ moveFiles: (files: Array<string>, destination: string) => Promise<boolean>;
+ clearSelection: () => void;
}
function GridPagination(props: Props) {
@@ -100,7 +137,7 @@ function GridPagination(props: Props) {
showDetails,
showDescription,
showTags,
- renderCell,
+ getCellContent,
isAppLoading,
currentDirectoryColor,
currentDirectoryTags,
@@ -305,19 +342,6 @@ function GridPagination(props: Props) {
PlatformIO.getDirSeparator()
);
- /**
- * normalize path for URL is always '/'
- * TODO move this in common module
- */
- function normalizeUrl(url: string) {
- if (PlatformIO.getDirSeparator() !== '/') {
- if (url) {
- return url.replaceAll(PlatformIO.getDirSeparator(), '/');
- }
- }
- return url;
- }
-
let folderTmbPath = getThumbFileLocationForDirectory(
currentDirectoryPath,
PlatformIO.getDirSeparator()
@@ -522,9 +546,59 @@ function GridPagination(props: Props) {
)}
</Grid>
<div style={style} data-tid="perspectiveGridFileTable">
- {page.current === 1 && directories.map(entry => renderCell(entry))}
+ {page.current === 1 &&
+ directories.map((entry, index) =>
+ renderCell(
+ entry,
+ index,
+ getCellContent,
+ props.classes,
+ theme,
+ showDirectories,
+ props.isReadOnlyMode,
+ props.desktopMode,
+ props.singleClickAction,
+ props.currentLocation,
+ props.selectedEntries,
+ props.setSelectedEntries,
+ props.lastSelectedEntry,
+ props.directoryContent,
+ props.openFsEntry,
+ props.openFileNatively,
+ props.loadDirectoryContent,
+ props.setFileContextMenuAnchorEl,
+ props.setDirContextMenuAnchorEl,
+ props.showNotification,
+ props.moveFiles,
+ props.clearSelection
+ )
+ )}
{pageFiles.map((entry, index, dArray) =>
- renderCell(entry, index === dArray.length - 1)
+ renderCell(
+ entry,
+ index,
+ getCellContent,
+ props.classes,
+ theme,
+ showDirectories,
+ props.isReadOnlyMode,
+ props.desktopMode,
+ props.singleClickAction,
+ props.currentLocation,
+ props.selectedEntries,
+ props.setSelectedEntries,
+ props.lastSelectedEntry,
+ props.directoryContent,
+ props.openFsEntry,
+ props.openFileNatively,
+ props.loadDirectoryContent,
+ props.setFileContextMenuAnchorEl,
+ props.setDirContextMenuAnchorEl,
+ props.showNotification,
+ props.moveFiles,
+ props.clearSelection,
+ index === dArray.length - 1
+ )
)}
{!isAppLoading && pageFiles.length < 1 && directories.length < 1 && (
<div style={{ textAlign: 'center' }}>
diff --git a/app/perspectives/grid-perspective/components/MainContainer.tsx b/app/perspectives/grid-perspective/components/MainContainer.tsx
index bf1a35adb..b71a81a0f 100644
--- a/app/perspectives/grid-perspective/components/MainContainer.tsx
+++ b/app/perspectives/grid-perspective/components/MainContainer.tsx
@@ -70,6 +70,7 @@ import { Pro } from '-/pro';
import Links from '-/links';
import { defaultSettings } from '../index';
import { PerspectiveIDs } from '-/perspectives';
+import { fileOperationsEnabled } from '-/perspectives/common/main-container';
interface Props {
classes: any;
@@ -100,7 +101,7 @@ interface Props {
removeTags: (paths: Array<string>, tags: Array<TS.Tag>) => void;
removeAllTags: () => void;
directoryContent: Array<TS.FileSystemEntry>;
- moveFiles: (files: Array<string>, destination: string) => void;
+ moveFiles: (files: Array<string>, destination: string) => Promise<boolean>;
keyBindings: any;
showNotification: (
text: string,
@@ -230,6 +231,14 @@ function GridPerspective(props: Props) {
const isDefaultSetting = useRef<boolean>(undefined);
const [ignored, forceUpdate] = useReducer(x => x + 1, 0);
+ const {
+ classes,
+ selectedEntries,
+ loadParentDirectoryContent,
+ theme,
+ currentDirectoryPath
+ } = props;
+
useEffect(() => {
if (props.selectedEntries.length === 1) {
makeFirstSelectedEntryVisible();
@@ -329,25 +338,6 @@ function GridPerspective(props: Props) {
gridPageLimit.current
]);
- const fileOperationsEnabled = () => {
- let selectionContainsDirectories = false;
- if (props.selectedEntries && props.selectedEntries.length > 0) {
- selectionContainsDirectories = selectedEntries.some(
- entry => !entry.isFile
- );
- return !selectionContainsDirectories;
- }
- return false;
- };
-
- const folderOperationsEnabled = () => {
- let selectionContainsFiles = false;
- if (props.selectedEntries && props.selectedEntries.length > 0) {
- selectionContainsFiles = selectedEntries.some(entry => entry.isFile);
- }
- return !selectionContainsFiles;
- };
-
const sortedDirContentMemoized = useMemo(
() =>
sortByCriteria(props.directoryContent, sortBy.current, orderBy.current),
@@ -355,7 +345,6 @@ function GridPerspective(props: Props) {
);
const makeFirstSelectedEntryVisible = () => {
- const { selectedEntries } = props;
if (selectedEntries && selectedEntries.length > 0) {
const firstSelectedElement = document.querySelector(
'[data-entry-id="' + selectedEntries[0].uuid + '"]'
@@ -400,91 +389,11 @@ function GridPerspective(props: Props) {
}
};
- const handleGridCellClick = (event, fsEntry: TS.FileSystemEntry) => {
- const {
- selectedEntries,
- directoryContent,
- lastSelectedEntry,
- setSelectedEntries
- } = props;
- const selectHelperKey = AppConfig.isMacLike ? event.metaKey : event.ctrlKey;
- if (event.shiftKey) {
- let lastSelectedIndex;
- if (lastSelectedEntry) {
- lastSelectedIndex = directoryContent.findIndex(
- entry => entry.path === lastSelectedEntry.path
- );
- }
- const currentSelectedIndex = directoryContent.findIndex(
- entry => entry.path === fsEntry.path
- );
- if (lastSelectedIndex < 0) {
- lastSelectedIndex = currentSelectedIndex;
- }
-
- let entriesToSelect;
- // console.log('lastSelectedIndex: ' + lastSelectedIndex + ' currentSelectedIndex: ' + currentSelectedIndex);
- if (currentSelectedIndex > lastSelectedIndex) {
- entriesToSelect = directoryContent.slice(
- lastSelectedIndex,
- currentSelectedIndex + 1
- );
- } else if (currentSelectedIndex < lastSelectedIndex) {
- entriesToSelect = directoryContent
- .slice(currentSelectedIndex, lastSelectedIndex + 1)
- .reverse();
- } else if (currentSelectedIndex === lastSelectedIndex) {
- entriesToSelect = [fsEntry];
- }
-
- setSelectedEntries(entriesToSelect);
- } else if (event.type === 'drag') {
- if (
- selectedEntries &&
- selectedEntries.some(entry => entry.path === fsEntry.path)
- ) {
- } else {
- const currentSelectedEntry = directoryContent.find(
- entry => entry.path === fsEntry.path
- );
- setSelectedEntries([currentSelectedEntry]);
- }
- } else if (selectHelperKey) {
- if (
- selectedEntries &&
- selectedEntries.some(entry => entry.path === fsEntry.path)
- ) {
- setSelectedEntries(
- selectedEntries.filter(entry => entry.path !== fsEntry.path)
- ); // deselect selected entry
- } else {
- setSelectedEntries([...selectedEntries, fsEntry]);
- }
- } else {
- setSelectedEntries([fsEntry]);
- if (fsEntry.isFile) {
- if (singleClickAction.current === 'openInternal') {
- props.openFsEntry(fsEntry);
- } else if (singleClickAction.current === 'openExternal') {
- props.openFileNatively(fsEntry.path);
- }
- }
- }
- };
-
const clearSelection = () => {
props.setSelectedEntries([]);
selectedEntryPath.current = undefined;
};
- const {
- classes,
- selectedEntries,
- loadParentDirectoryContent,
- theme,
- currentDirectoryPath
- } = props;
-
const someFileSelected = selectedEntries.length > 1;
const toggleSelectAllFiles = () => {
@@ -547,103 +456,6 @@ function GridPerspective(props: Props) {
setIsGridSettingsDialogOpened(true);
};
- const handleGridCellDblClick = (event, fsEntry: TS.FileSystemEntry) => {
- props.setSelectedEntries([]);
- if (props.currentLocation.type === locationType.TYPE_CLOUD) {
- PlatformIO.enableObjectStoreSupport(props.currentLocation)
- .then(() => {
- openLocation(fsEntry);
- return true;
- })
- .catch(error => {
- console.log('enableObjectStoreSupport', error);
- });
- } else if (props.currentLocation.type === locationType.TYPE_WEBDAV) {
- PlatformIO.enableWebdavSupport(props.currentLocation);
- openLocation(fsEntry);
- } else if (props.currentLocation.type === locationType.TYPE_LOCAL) {
- PlatformIO.disableObjectStoreSupport();
- PlatformIO.disableWebdavSupport();
- openLocation(fsEntry);
- }
- };
-
- const openLocation = (fsEntry: TS.FileSystemEntry) => {
- if (fsEntry.isFile) {
- props.setSelectedEntries([fsEntry]);
- props.openFsEntry(fsEntry);
- } else {
- console.log('Handle Grid cell db click, selected path : ', fsEntry.path);
- props.loadDirectoryContent(fsEntry.path, true, true);
- }
- };
-
- const handleGridContextMenu = (event, fsEntry: TS.FileSystemEntry) => {
- event.preventDefault();
- event.stopPropagation();
- setMouseX(event.clientX);
- setMouseY(event.clientY);
- const { desktopMode } = props;
- const isEntryExist = selectedEntries.some(
- entry => entry.uuid === fsEntry.uuid
- );
- if (fsEntry.isFile) {
- if (!desktopMode) {
- if (!isEntryExist) {
- if (selectedEntries.length > 0) {
- props.setSelectedEntries([...selectedEntries, fsEntry]);
- } else {
- props.setSelectedEntries([fsEntry]);
- }
- }
- } else if (
- props.selectedEntries.length === 0 ||
- !fileOperationsEnabled()
- ) {
- props.setSelectedEntries([fsEntry]);
- } else if (event.ctrlKey) {
- if (!isEntryExist) {
- props.setSelectedEntries([...selectedEntries, fsEntry]);
- }
- } else if (isEntryExist) {
- // update selected entry
- props.setSelectedEntries([
- ...selectedEntries.filter(entry => entry.uuid !== fsEntry.uuid),
- fsEntry
- ]);
- } else {
- props.setSelectedEntries([fsEntry]);
- }
- setFileContextMenuAnchorEl(event.currentTarget);
- } else {
- if (props.selectedEntries.length === 0 || !folderOperationsEnabled()) {
- props.setSelectedEntries([fsEntry]);
- } else if (isEntryExist) {
- // update selected entry
- props.setSelectedEntries([
- ...selectedEntries.filter(entry => entry.uuid !== fsEntry.uuid),
- fsEntry
- ]);
- } else {
- props.setSelectedEntries([fsEntry]);
- }
- setDirContextMenuAnchorEl(event.currentTarget);
- }
- };
-
- const selectEntry = (fsEntry: TS.FileSystemEntry) => {
- const { setSelectedEntries } = props;
- setSelectedEntries([...selectedEntries, fsEntry]);
- };
-
- const deselectEntry = (fsEntry: TS.FileSystemEntry) => {
- const { setSelectedEntries } = props;
- const newSelection = selectedEntries.filter(
- data => data.path !== fsEntry.path
- );
- setSelectedEntries(newSelection);
- };
-
const handleTagMenu = (
event: React.ChangeEvent<HTMLInputElement>,
tag: TS.Tag,
@@ -673,108 +485,6 @@ function GridPerspective(props: Props) {
setIsAddRemoveTagsDialogOpened(true);
};
- const handleFileMoveDrop = (item, monitor) => {
- if (props.isReadOnlyMode) {
- props.showNotification(
- i18n.t('core:dndDisabledReadOnlyMode'),
- 'error',
- true
- );
- return;
- }
- if (monitor) {
- const mItem = monitor.getItem();
- let arrPath;
- if (mItem.selectedEntries && mItem.selectedEntries.length > 0) {
- const arrSelected = mItem.selectedEntries
- .map(entry => entry.path)
- // remove target folder selection
- .filter(epath => epath !== item.path);
- if (arrSelected.length > 0) {
- arrPath = arrSelected;
- } else {
- arrPath = [mItem.path];
- }
- } else {
- arrPath = [mItem.path];
- }
- console.log('Dropped files: ' + item.path);
- props.moveFiles(arrPath, item.path);
- clearSelection();
- }
- };
-
- const renderCell = (fsEntry: TS.FileSystemEntry, isLast?: boolean) => {
- const { addTags, addTag, supportedFileTypes, openFsEntry } = props;
- if (!fsEntry.isFile && !showDirectories.current) {
- return;
- }
-
- let selected = false;
- if (
- selectedEntries &&
- selectedEntries.some(entry => entry.path === fsEntry.path)
- ) {
- selected = true;
- }
-
- const cellContent: any = (
- <TagDropContainer
- entryPath={fsEntry.path} // TODO remove entryPath it is already included in selectedEntries
- selectedEntries={
- selectedEntries.length > 0 ? selectedEntries : [fsEntry]
- }
- >
- <CellContent
- selected={selected}
- fsEntry={fsEntry}
- entrySize={entrySize.current}
- classes={classes}
- isLast={isLast}
- theme={theme}
- supportedFileTypes={supportedFileTypes}
- thumbnailMode={thumbnailMode.current}
- addTags={addTags}
- addTag={addTag}
- selectedEntries={selectedEntries}
- selectEntry={selectEntry}
- deselectEntry={deselectEntry}
- isReadOnlyMode={props.isReadOnlyMode}
- handleTagMenu={handleTagMenu}
- layoutType={layoutType.current}
- showTags={showTags.current}
- openFsEntry={openFsEntry}
- handleGridContextMenu={handleGridContextMenu}
- handleGridCellDblClick={handleGridCellDblClick}
- handleGridCellClick={handleGridCellClick}
- />
- </TagDropContainer>
- );
-
- const key = fsEntry.path;
-
- if (fsEntry.isFile) {
- return <FileSourceDnd key={key}>{cellContent}</FileSourceDnd>;
- }
-
- return (
- <div
- style={{
- position: 'relative'
- }}
- key={key}
- >
- <TargetMoveFileBox
- accepts={[DragItemTypes.FILE]}
- path={fsEntry.path}
- onDrop={handleFileMoveDrop}
- >
- {cellContent}
- </TargetMoveFileBox>
- </div>
- );
- };
-
const keyMap = {
nextDocument: props.keyBindings.nextDocument,
prevDocument: props.keyBindings.prevDocument,
@@ -815,7 +525,7 @@ function GridPerspective(props: Props) {
prevDocument: () => props.openPrevFile(),
selectAll: () => toggleSelectAllFiles(),
deleteDocument: () => {
- if (fileOperationsEnabled()) {
+ if (fileOperationsEnabled(props.selectedEntries)) {
openDeleteFileDialog();
}
},
@@ -857,6 +567,65 @@ function GridPerspective(props: Props) {
entryWidth = 300;
}
+ const getCellContent = (
+ fsEntry: TS.FileSystemEntry,
+ index: number,
+ handleGridContextMenu,
+ handleGridCellClick,
+ handleGridCellDblClick,
+ isLast?: boolean
+ ) => {
+ let selected = false;
+ if (
+ selectedEntries &&
+ selectedEntries.some(entry => entry.path === fsEntry.path)
+ ) {
+ selected = true;
+ }
+ const selectEntry = (fsEntry: TS.FileSystemEntry) => {
+ props.setSelectedEntries([...selectedEntries, fsEntry]);
+ };
+
+ const deselectEntry = (fsEntry: TS.FileSystemEntry) => {
+ const newSelection = selectedEntries.filter(
+ data => data.path !== fsEntry.path
+ );
+ props.setSelectedEntries(newSelection);
+ };
+ return (
+ <TagDropContainer
+ entryPath={fsEntry.path} // TODO remove entryPath it is already included in selectedEntries
+ selectedEntries={
+ selectedEntries.length > 0 ? selectedEntries : [fsEntry]
+ }
+ >
+ <CellContent
+ selected={selected}
+ fsEntry={fsEntry}
+ entrySize={entrySize.current}
+ classes={classes}
+ isLast={isLast}
+ theme={theme}
+ supportedFileTypes={props.supportedFileTypes}
+ thumbnailMode={thumbnailMode.current}
+ addTags={props.addTags}
+ addTag={props.addTag}
+ selectedEntries={selectedEntries}
+ selectEntry={selectEntry}
+ deselectEntry={deselectEntry}
+ isReadOnlyMode={props.isReadOnlyMode}
+ handleTagMenu={handleTagMenu}
+ layoutType={layoutType.current}
+ showTags={showTags.current}
+ openFsEntry={props.openFsEntry}
+ handleGridContextMenu={handleGridContextMenu}
+ handleGridCellDblClick={handleGridCellDblClick}
+ handleGridCellClick={handleGridCellClick}
+ />
+ </TagDropContainer>
+ );
+ };
+
return (
<div
style={{
@@ -874,7 +643,7 @@ function GridPerspective(props: Props) {
someFileSelected={someFileSelected}
handleLayoutSwitch={handleLayoutSwitch}
openAddRemoveTagsDialog={openAddRemoveTagsDialog}
- fileOperationsEnabled={fileOperationsEnabled()}
+ fileOperationsEnabled={fileOperationsEnabled(props.selectedEntries)}
openMoveCopyFilesDialog={openMoveCopyFilesDialog}
openDeleteFileDialog={openDeleteFileDialog}
openFsEntry={props.openFsEntry}
@@ -899,17 +668,21 @@ function GridPerspective(props: Props) {
gridTemplateColumns:
'repeat(auto-fit,minmax(' + entryWidth + 'px,1fr))'
}}
+ classes={classes}
theme={theme}
directories={sortedDirectories}
showDetails={showDetails.current}
showDescription={showDescription.current}
showDirectories={showDirectories.current}
+ isReadOnlyMode={props.isReadOnlyMode}
+ layoutType={layoutType.current}
+ desktopMode={props.desktopMode}
openRenameEntryDialog={props.openRenameEntryDialog}
showTags={showTags.current}
thumbnailMode={thumbnailMode.current}
entrySize={entrySize.current}
files={sortedFiles}
- renderCell={renderCell}
+ getCellContent={getCellContent}
currentPage={1}
currentLocationPath={locationPath}
currentDirectoryPath={props.currentDirectoryPath}
@@ -917,6 +690,20 @@ function GridPerspective(props: Props) {
onContextMenu={onContextMenu}
settings={settings}
selectedEntries={props.selectedEntries}
+ setSelectedEntries={props.setSelectedEntries}
+ singleClickAction={singleClickAction.current}
+ currentLocation={props.currentLocation}
+ lastSelectedEntry={props.lastSelectedEntry}
+ directoryContent={props.directoryContent}
+ supportedFileTypes={props.supportedFileTypes}
+ openFsEntry={props.openFsEntry}
+ openFileNatively={props.openFileNatively}
+ loadDirectoryContent={props.loadDirectoryContent}
+ setFileContextMenuAnchorEl={setFileContextMenuAnchorEl}
+ setDirContextMenuAnchorEl={setDirContextMenuAnchorEl}
+ showNotification={props.showNotification}
+ moveFiles={props.moveFiles}
+ clearSelection={clearSelection}
/>
</GlobalHotKeys>
{isAddRemoveTagsDialogOpened && (
diff --git a/app/perspectives/list/components/MainContainer.tsx b/app/perspectives/list/components/MainContainer.tsx
index 456cb69c7..a5e39171d 100644
--- a/app/perspectives/list/components/MainContainer.tsx
+++ b/app/perspectives/list/components/MainContainer.tsx
@@ -70,6 +70,7 @@ import { Pro } from '-/pro';
import Links from '-/links';
import { defaultSettings } from '../index';
import { PerspectiveIDs } from '-/perspectives';
+import { fileOperationsEnabled } from '-/perspectives/common/main-container';
interface Props {
classes: any;
@@ -100,7 +101,7 @@ interface Props {
removeTags: (paths: Array<string>, tags: Array<TS.Tag>) => void;
removeAllTags: () => void;
directoryContent: Array<TS.FileSystemEntry>;
- moveFiles: (files: Array<string>, destination: string) => void;
+ moveFiles: (files: Array<string>, destination: string) => Promise<boolean>;
keyBindings: any;
showNotification: (
text: string,
@@ -330,25 +331,6 @@ function GridPerspective(props: Props) {
gridPageLimit.current
]);
- const fileOperationsEnabled = () => {
- let selectionContainsDirectories = false;
- if (props.selectedEntries && props.selectedEntries.length > 0) {
- selectionContainsDirectories = selectedEntries.some(
- entry => !entry.isFile
- );
- return !selectionContainsDirectories;
- }
- return false;
- };
-
- const folderOperationsEnabled = () => {
- let selectionContainsFiles = false;
- if (props.selectedEntries && props.selectedEntries.length > 0) {
- selectionContainsFiles = selectedEntries.some(entry => entry.isFile);
- }
- return !selectionContainsFiles;
- };
-
const sortedDirContentMemoized = useMemo(
() =>
sortByCriteria(props.directoryContent, sortBy.current, orderBy.current),
@@ -377,7 +359,6 @@ function GridPerspective(props: Props) {
const handleGridPageLimit = (limit: number) => {
gridPageLimit.current = limit;
- // setIsGridSettingsDialogOpened(false);
// forceUpdate();
};
@@ -402,78 +383,6 @@ function GridPerspective(props: Props) {
}
};
- const handleGridCellClick = (event, fsEntry: TS.FileSystemEntry) => {
- const {
- selectedEntries,
- directoryContent,
- lastSelectedEntry,
- setSelectedEntries
- } = props;
- const selectHelperKey = AppConfig.isMacLike ? event.metaKey : event.ctrlKey;
- if (event.shiftKey) {
- let lastSelectedIndex;
- if (lastSelectedEntry) {
- lastSelectedIndex = directoryContent.findIndex(
- entry => entry.path === lastSelectedEntry.path
- );
- }
- const currentSelectedIndex = directoryContent.findIndex(
- entry => entry.path === fsEntry.path
- );
- if (lastSelectedIndex < 0) {
- lastSelectedIndex = currentSelectedIndex;
- }
-
- let entriesToSelect;
- // console.log('lastSelectedIndex: ' + lastSelectedIndex + ' currentSelectedIndex: ' + currentSelectedIndex);
- if (currentSelectedIndex > lastSelectedIndex) {
- entriesToSelect = directoryContent.slice(
- lastSelectedIndex,
- currentSelectedIndex + 1
- );
- } else if (currentSelectedIndex < lastSelectedIndex) {
- entriesToSelect = directoryContent
- .slice(currentSelectedIndex, lastSelectedIndex + 1)
- .reverse();
- } else if (currentSelectedIndex === lastSelectedIndex) {
- entriesToSelect = [fsEntry];
- }
-
- setSelectedEntries(entriesToSelect);
- } else if (event.type === 'drag') {
- if (
- selectedEntries &&
- selectedEntries.some(entry => entry.path === fsEntry.path)
- ) {
- } else {
- const currentSelectedEntry = directoryContent.find(
- entry => entry.path === fsEntry.path
- );
- setSelectedEntries([currentSelectedEntry]);
- }
- } else if (selectHelperKey) {
- if (
- selectedEntries &&
- selectedEntries.some(entry => entry.path === fsEntry.path)
- ) {
- setSelectedEntries(
- selectedEntries.filter(entry => entry.path !== fsEntry.path)
- ); // deselect selected entry
- } else {
- setSelectedEntries([...selectedEntries, fsEntry]);
- }
- } else {
- setSelectedEntries([fsEntry]);
- if (fsEntry.isFile) {
- if (singleClickAction.current === 'openInternal') {
- props.openFsEntry(fsEntry);
- } else if (singleClickAction.current === 'openExternal') {
- props.openFileNatively(fsEntry.path);
- }
- }
- }
- };
-
const clearSelection = () => {
props.setSelectedEntries([]);
selectedEntryPath.current = undefined;
@@ -549,103 +458,6 @@ function GridPerspective(props: Props) {
setIsGridSettingsDialogOpened(true);
};
- const handleGridCellDblClick = (event, fsEntry: TS.FileSystemEntry) => {
- props.setSelectedEntries([]);
- if (props.currentLocation.type === locationType.TYPE_CLOUD) {
- PlatformIO.enableObjectStoreSupport(props.currentLocation)
- .then(() => {
- doubleClickAction(fsEntry);
- return true;
- })
- .catch(error => {
- console.log('enableObjectStoreSupport', error);
- });
- } else if (props.currentLocation.type === locationType.TYPE_WEBDAV) {
- PlatformIO.enableWebdavSupport(props.currentLocation);
- doubleClickAction(fsEntry);
- } else if (props.currentLocation.type === locationType.TYPE_LOCAL) {
- PlatformIO.disableObjectStoreSupport();
- doubleClickAction(fsEntry);
- }
- };
-
- const doubleClickAction = (fsEntry: TS.FileSystemEntry) => {
- if (fsEntry.isFile) {
- props.setSelectedEntries([fsEntry]);
- // props.openFileNatively(fsEntry.path);
- props.openFsEntry(fsEntry);
- } else {
- console.log('Handle Grid cell db click, selected path : ', fsEntry.path);
- props.loadDirectoryContent(fsEntry.path, true, true);
- }
- };
-
- const handleGridContextMenu = (event, fsEntry: TS.FileSystemEntry) => {
- event.preventDefault();
- event.stopPropagation();
- setMouseX(event.clientX);
- setMouseY(event.clientY);
- const { desktopMode } = props;
- const isEntryExist = selectedEntries.some(
- entry => entry.uuid === fsEntry.uuid
- );
- if (fsEntry.isFile) {
- if (!desktopMode) {
- if (!isEntryExist) {
- if (selectedEntries.length > 0) {
- props.setSelectedEntries([...selectedEntries, fsEntry]);
- } else {
- props.setSelectedEntries([fsEntry]);
- }
- }
- } else if (
- props.selectedEntries.length === 0 ||
- !fileOperationsEnabled()
- ) {
- props.setSelectedEntries([fsEntry]);
- } else if (event.ctrlKey) {
- if (!isEntryExist) {
- props.setSelectedEntries([...selectedEntries, fsEntry]);
- }
- } else if (isEntryExist) {
- // update selected entry
- props.setSelectedEntries([
- ...selectedEntries.filter(entry => entry.uuid !== fsEntry.uuid),
- fsEntry
- ]);
- } else {
- props.setSelectedEntries([fsEntry]);
- }
- setFileContextMenuAnchorEl(event.currentTarget);
- } else {
- if (props.selectedEntries.length === 0 || !folderOperationsEnabled()) {
- props.setSelectedEntries([fsEntry]);
- } else if (isEntryExist) {
- // update selected entry
- props.setSelectedEntries([
- ...selectedEntries.filter(entry => entry.uuid !== fsEntry.uuid),
- fsEntry
- ]);
- } else {
- props.setSelectedEntries([fsEntry]);
- }
- setDirContextMenuAnchorEl(event.currentTarget);
- }
- };
-
- const selectEntry = (fsEntry: TS.FileSystemEntry) => {
- const { setSelectedEntries } = props;
- setSelectedEntries([...selectedEntries, fsEntry]);
- };
-
- const deselectEntry = (fsEntry: TS.FileSystemEntry) => {
- const { setSelectedEntries } = props;
- const newSelection = selectedEntries.filter(
- data => data.path !== fsEntry.path
- );
- setSelectedEntries(newSelection);
- };
-
const handleTagMenu = (
event: React.ChangeEvent<HTMLInputElement>,
tag: TS.Tag,
@@ -675,116 +487,6 @@ function GridPerspective(props: Props) {
setIsAddRemoveTagsDialogOpened(true);
};
- const handleFileMoveDrop = (item, monitor) => {
- if (props.isReadOnlyMode) {
- props.showNotification(
- i18n.t('core:dndDisabledReadOnlyMode'),
- 'error',
- true
- );
- return;
- }
- if (monitor) {
- const mItem = monitor.getItem();
- let arrPath;
- if (mItem.selectedEntries && mItem.selectedEntries.length > 0) {
- const arrSelected = mItem.selectedEntries
- .map(entry => entry.path)
- // remove target folder selection
- .filter(epath => epath !== mItem.path);
- if (arrSelected.length > 0) {
- arrPath = arrSelected;
- } else {
- arrPath = [mItem.path];
- }
- } else {
- arrPath = [mItem.path];
- }
- console.log('Dropped files: ' + item.path);
- props.moveFiles(arrPath, item.path);
- clearSelection();
- }
- };
-
- const renderCell = (fsEntry: TS.FileSystemEntry, isLast?: boolean) => {
- const {
- // classes,
- // theme,
- // selectedEntries,
- addTags,
- addTag,
- supportedFileTypes,
- openFsEntry
- } = props;
- if (!fsEntry.isFile && !showDirectories.current) {
- return;
- }
-
- let selected = false;
- if (
- selectedEntries &&
- selectedEntries.some(entry => entry.path === fsEntry.path)
- ) {
- selected = true;
- }
-
- const cellContent: any = (
- <TagDropContainer
- entryPath={fsEntry.path} // TODO remove entryPath it is already included in selectedEntries
- selectedEntries={
- selectedEntries.length > 0 ? selectedEntries : [fsEntry]
- }
- >
- <CellContent
- selected={selected}
- fsEntry={fsEntry}
- entrySize={entrySize.current}
- classes={classes}
- isLast={isLast}
- theme={theme}
- supportedFileTypes={supportedFileTypes}
- thumbnailMode={thumbnailMode.current}
- addTags={addTags}
- addTag={addTag}
- selectedEntries={selectedEntries}
- selectEntry={selectEntry}
- deselectEntry={deselectEntry}
- isReadOnlyMode={props.isReadOnlyMode}
- handleTagMenu={handleTagMenu}
- layoutType={layoutType.current}
- showTags={showTags.current}
- openFsEntry={openFsEntry}
- handleGridContextMenu={handleGridContextMenu}
- handleGridCellDblClick={handleGridCellDblClick}
- handleGridCellClick={handleGridCellClick}
- />
- </TagDropContainer>
- );
-
- const key = fsEntry.path;
-
- if (fsEntry.isFile) {
- return <FileSourceDnd key={key}>{cellContent}</FileSourceDnd>;
- }
-
- return (
- <div
- style={{
- position: 'relative'
- }}
- key={key}
- >
- <TargetMoveFileBox
- accepts={[DragItemTypes.FILE]}
- path={fsEntry.path}
- onDrop={handleFileMoveDrop}
- >
- {cellContent}
- </TargetMoveFileBox>
- </div>
- );
- };
-
const keyMap = {
nextDocument: props.keyBindings.nextDocument,
prevDocument: props.keyBindings.prevDocument,
@@ -825,7 +527,7 @@ function GridPerspective(props: Props) {
prevDocument: () => props.openPrevFile(),
selectAll: () => toggleSelectAllFiles(),
deleteDocument: () => {
- if (fileOperationsEnabled()) {
+ if (fileOperationsEnabled(props.selectedEntries)) {
openDeleteFileDialog();
}
},
@@ -867,6 +569,65 @@ function GridPerspective(props: Props) {
entryWidth = 300;
}
+ const getCellContent = (
+ fsEntry: TS.FileSystemEntry,
+ index: number,
+ handleGridContextMenu,
+ handleGridCellClick,
+ handleGridCellDblClick,
+ isLast?: boolean
+ ) => {
+ let selected = false;
+ if (
+ selectedEntries &&
+ selectedEntries.some(entry => entry.path === fsEntry.path)
+ ) {
+ selected = true;
+ }
+ const selectEntry = (fsEntry: TS.FileSystemEntry) => {
+ props.setSelectedEntries([...selectedEntries, fsEntry]);
+ };
+
+ const deselectEntry = (fsEntry: TS.FileSystemEntry) => {
+ const newSelection = selectedEntries.filter(
+ data => data.path !== fsEntry.path
+ );
+ props.setSelectedEntries(newSelection);
+ };
+ return (
+ <TagDropContainer
+ entryPath={fsEntry.path} // TODO remove entryPath it is already included in selectedEntries
+ selectedEntries={
+ selectedEntries.length > 0 ? selectedEntries : [fsEntry]
+ }
+ >
+ <CellContent
+ selected={selected}
+ fsEntry={fsEntry}
+ entrySize={entrySize.current}
+ classes={classes}
+ isLast={isLast}
+ theme={theme}
+ supportedFileTypes={props.supportedFileTypes}
+ thumbnailMode={thumbnailMode.current}
+ addTags={props.addTags}
+ addTag={props.addTag}
+ selectedEntries={selectedEntries}
+ selectEntry={selectEntry}
+ deselectEntry={deselectEntry}
+ isReadOnlyMode={props.isReadOnlyMode}
+ handleTagMenu={handleTagMenu}
+ layoutType={layoutType.current}
+ showTags={showTags.current}
+ openFsEntry={props.openFsEntry}
+ handleGridContextMenu={handleGridContextMenu}
+ handleGridCellDblClick={handleGridCellDblClick}
+ handleGridCellClick={handleGridCellClick}
+ />
+ </TagDropContainer>
+ );
+ };
+
return (
<div
style={{
@@ -884,7 +645,7 @@ function GridPerspective(props: Props) {
someFileSelected={someFileSelected}
handleLayoutSwitch={handleLayoutSwitch}
openAddRemoveTagsDialog={openAddRemoveTagsDialog}
- fileOperationsEnabled={fileOperationsEnabled()}
+ fileOperationsEnabled={fileOperationsEnabled(props.selectedEntries)}
openMoveCopyFilesDialog={openMoveCopyFilesDialog}
openDeleteFileDialog={openDeleteFileDialog}
openFsEntry={props.openFsEntry}
@@ -906,17 +667,21 @@ function GridPerspective(props: Props) {
paddingLeft: 4,
gridTemplateColumns: 'none'
}}
+ classes={classes}
theme={theme}
directories={sortedDirectories}
showDetails={showDetails.current}
showDescription={showDescription.current}
showDirectories={showDirectories.current}
+ isReadOnlyMode={props.isReadOnlyMode}
+ layoutType={layoutType.current}
+ desktopMode={props.desktopMode}
openRenameEntryDialog={props.openRenameEntryDialog}
showTags={showTags.current}
thumbnailMode={thumbnailMode.current}
entrySize={entrySize.current}
files={sortedFiles}
- renderCell={renderCell}
+ getCellContent={getCellContent}
currentPage={1}
currentLocationPath={locationPath}
currentDirectoryPath={props.currentDirectoryPath}
@@ -924,6 +689,20 @@ function GridPerspective(props: Props) {
onContextMenu={onContextMenu}
settings={settings}
selectedEntries={props.selectedEntries}
+ setSelectedEntries={props.setSelectedEntries}
+ singleClickAction={singleClickAction.current}
+ currentLocation={props.currentLocation}
+ lastSelectedEntry={props.lastSelectedEntry}
+ directoryContent={props.directoryContent}
+ supportedFileTypes={props.supportedFileTypes}
+ openFsEntry={props.openFsEntry}
+ openFileNatively={props.openFileNatively}
+ loadDirectoryContent={props.loadDirectoryContent}
+ setFileContextMenuAnchorEl={setFileContextMenuAnchorEl}
+ setDirContextMenuAnchorEl={setDirContextMenuAnchorEl}
+ showNotification={props.showNotification}
+ moveFiles={props.moveFiles}
+ clearSelection={clearSelection}
/>
</GlobalHotKeys>
{isAddRemoveTagsDialogOpened && (
diff --git a/app/reducers/app.ts b/app/reducers/app.ts
index ef47f5abf..c3c1a4943 100644
--- a/app/reducers/app.ts
+++ b/app/reducers/app.ts
@@ -565,12 +565,16 @@ export default (state: any = initialState, action: any) => {
) {
return {
...state,
+ editedEntryPaths: [action.path],
currentDirectoryEntries: newDirectoryEntries,
openedFiles: newOpenedFiles,
isEntryInFullWidth: false
};
}
- return state;
+ return {
+ ...state,
+ editedEntryPaths: [action.path]
+ };
}
case types.REFLECT_CREATE_ENTRY: {
// Prevent adding entry twice e.g. by the watcher
@@ -588,13 +592,17 @@ export default (state: any = initialState, action: any) => {
) {
return {
...state,
+ editedEntryPaths: [action.newEntry.path],
currentDirectoryEntries: [
...state.currentDirectoryEntries,
action.newEntry
]
};
}
- return state;
+ return {
+ ...state,
+ editedEntryPaths: [action.newEntry.path]
+ };
}
case types.REFLECT_RENAME_ENTRY: {
const extractedTags = extractTagsAsObjects(
@@ -605,6 +613,7 @@ export default (state: any = initialState, action: any) => {
return {
...state,
+ editedEntryPaths: [action.path, action.newPath],
currentDirectoryEntries: state.currentDirectoryEntries.map(entry => {
if (entry.path !== action.path) {
return entry;
@@ -1899,6 +1908,8 @@ export const actions = {
const { currentDirectoryPath } = getState().app;
updateHistory(currentLocation, currentDirectoryPath, fsEntry.path);
+ document.title = fsEntry.name + ' | ' + 'TagSpaces'; // TODO get it later from app config
+
dispatch(actions.addToEntryContainer(entryForOpening));
/**
* save in history
@@ -1968,7 +1979,11 @@ export const actions = {
dispatch(actions.setSelectedEntries([prevFile]));
}
},
- closeAllFiles: () => ({ type: types.CLOSE_ALL_FILES }),
+ closeAllFiles: () => (dispatch: (action) => void) => {
+ document.title = 'TagSpaces'; // TODO move to AppConfig
+ dispatch(actions.closeAllFilesInt());
+ },
+ closeAllFilesInt: () => ({ type: types.CLOSE_ALL_FILES }),
reflectDeleteEntryInt: (path: string) => ({
type: types.REFLECT_DELETE_ENTRY,
path
@@ -2388,6 +2403,7 @@ export const getIsMetaLoaded = (state: any) => state.app.isMetaLoaded;
export const getDirectoryContent = (state: any) =>
state.app.currentDirectoryEntries;
// export const getPageEntries = (state: any) => state.app.pageEntries;
+export const getEditedEntryPaths = (state: any) => state.app.editedEntryPaths;
export const getCurrentDirectoryFiles = (state: any) =>
state.app.currentDirectoryFiles;
export const getCurrentDirectoryDirs = (state: any) =>
diff --git a/app/reducers/io-actions.ts b/app/reducers/io-actions.ts
index 97da5f447..24e26296a 100644
--- a/app/reducers/io-actions.ts
+++ b/app/reducers/io-actions.ts
@@ -94,7 +94,7 @@ const actions = {
);
const moveMetaJobs = [];
moveJobs.map(job => {
- dispatch(AppActions.reflectDeleteEntry(job[0])); // TODO moved files should be added to the index, if the target dir in index
+ dispatch(AppActions.reflectRenameEntry(job[0], job[1])); // TODO moved files should be added to the index, if the target dir in index
moveMetaJobs.push([
getMetaFileLocationForFile(job[0], PlatformIO.getDirSeparator()),
getMetaFileLocationForFile(job[1], PlatformIO.getDirSeparator())
@@ -170,9 +170,11 @@ const actions = {
copyFilesPromise(copyMetaJobs)
.then(() => {
console.log('Copy meta and thumbs successful');
+ dispatch(AppActions.reflectCreateEntry(job[1], true));
return true;
})
.catch(err => {
+ dispatch(AppActions.reflectCreateEntry(job[1], true));
console.warn('At least one meta or thumb was not copied ' + err);
});
return true;
diff --git a/app/services/utils-io.ts b/app/services/utils-io.ts
index 5253385b8..91f334afb 100644
--- a/app/services/utils-io.ts
+++ b/app/services/utils-io.ts
@@ -1230,3 +1230,15 @@ export function fileNameValidation(fileName): boolean {
}
return true;
}
+
+/**
+ * normalize path for URL is always '/'
+ */
+export function normalizeUrl(url: string) {
+ if (PlatformIO.getDirSeparator() !== '/') {
+ if (url) {
+ return url.replaceAll(PlatformIO.getDirSeparator(), '/');
+ }
+ }
+ return url;
+}
diff --git a/app/tagspaces.namespace.d.ts b/app/tagspaces.namespace.d.ts
index cbb4706a0..fa39bc2e3 100644
--- a/app/tagspaces.namespace.d.ts
+++ b/app/tagspaces.namespace.d.ts
@@ -170,6 +170,10 @@ export namespace TS {
showTags?: boolean;
showDetails?: boolean;
showDescription?: boolean;
+ showFolderContent?: boolean; // KanBan
+ pageLimit?: number; // KanBan
+ pageOffset?: number; // KanBan
+ filesLimit?: number; // KanBan
layoutType?: string;
orderBy?: boolean;
sortBy?: string;
diff --git a/configs/webpack.config.main.prod.babel.js b/configs/webpack.config.main.prod.babel.js
index a47f1e85e..2a88a8664 100644
--- a/configs/webpack.config.main.prod.babel.js
+++ b/configs/webpack.config.main.prod.babel.js
@@ -33,10 +33,11 @@ export default merge(baseConfig, {
? []
: [
new TerserPlugin({
- parallel: true,
- sourceMap: true,
- cache: true
- })
+ parallel: true
+ // sourceMap: true,
+ // cache: true
+ }),
+ '...' // '...' can be used in optimization.minimizer to access the defaults.
]
},
diff --git a/package-lock.json b/package-lock.json
index 708da43be..cb52990ab 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -65,6 +65,7 @@
"react-hotkeys": "^2.0.0",
"react-i18next": "^4.6.1",
"react-image-gallery": "^1.2.7",
+ "react-infinite-scroller": "^1.2.6",
"react-leaflet": "^2.8.0",
"react-redux": "^8.0.2",
"react-swipeable-views": "0.14.0",
@@ -41409,6 +41410,17 @@
"react": "^16.0.0 || ^17.0.0 || ^18.0.0"
}
},
+ "node_modules/react-infinite-scroller": {
+ "version": "1.2.6",
+ "resolved": "https://registry.npmjs.org/react-infinite-scroller/-/react-infinite-scroller-1.2.6.tgz",
+ "integrity": "sha512-mGdMyOD00YArJ1S1F3TVU9y4fGSfVVl6p5gh/Vt4u99CJOptfVu/q5V/Wlle72TMgYlBwIhbxK5wF0C/R33PXQ==",
+ "dependencies": {
+ "prop-types": "^15.5.8"
+ },
+ "peerDependencies": {
+ "react": "^0.14.9 || ^15.3.0 || ^16.0.0 || ^17.0.0 || ^18.0.0"
+ }
+ },
"node_modules/react-is": {
"version": "18.2.0",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz",
@@ -80549,6 +80561,14 @@
"integrity": "sha512-YLMCdNSCf3YPhRmnjEOdEZGEXghTMx4o3dlAqd0rz0nAyebUvTz/xJnIHPActbPSHCvVJgt5A09EPHYbGqw++w==",
"requires": {}
},
+ "react-infinite-scroller": {
+ "version": "1.2.6",
+ "resolved": "https://registry.npmjs.org/react-infinite-scroller/-/react-infinite-scroller-1.2.6.tgz",
+ "integrity": "sha512-mGdMyOD00YArJ1S1F3TVU9y4fGSfVVl6p5gh/Vt4u99CJOptfVu/q5V/Wlle72TMgYlBwIhbxK5wF0C/R33PXQ==",
+ "requires": {
+ "prop-types": "^15.5.8"
+ }
+ },
"react-is": {
"version": "18.2.0",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz",
diff --git a/package.json b/package.json
index c6eba82fe..f8e46f412 100644
--- a/package.json
+++ b/package.json
@@ -202,6 +202,7 @@
"react-hotkeys": "^2.0.0",
"react-i18next": "^4.6.1",
"react-image-gallery": "^1.2.7",
+ "react-infinite-scroller": "^1.2.6",
"react-leaflet": "^2.8.0",
"react-redux": "^8.0.2",
"react-swipeable-views": "0.14.0",