Skip to content

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

Grid and list perspective redesign (#2024)

Ilianf7f6ae6fd803
diff --git a/src/renderer/components/EntryIcon.tsx b/src/renderer/components/EntryIcon.tsx
index b56237bd5..ed8e0a4ff 100644
--- a/src/renderer/components/EntryIcon.tsx
+++ b/src/renderer/components/EntryIcon.tsx
@@ -81,18 +81,10 @@ function EntryIcon(props: Props) {
return (
<svg
- style={{
- width: '60%',
- position: 'absolute',
- top: '50%',
- left: '50%',
- transform: 'translate(-50%, -50%)',
- height: 150,
- }}
+ width="100%"
+ height="auto"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
- width="24"
- height="24"
fill="#bbbbbb22"
>
{iconSVGPath}
diff --git a/src/renderer/components/ZoomComponent.tsx b/src/renderer/components/ZoomComponent.tsx
new file mode 100644
index 000000000..7ab4bae9e
--- /dev/null
+++ b/src/renderer/components/ZoomComponent.tsx
@@ -0,0 +1,103 @@
+/**
+ * TagSpaces - universal file and folder organizer
+ * Copyright (C) 2023-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 * as React from 'react';
+import { useTheme } from '@mui/material/styles';
+import Box from '@mui/material/Box';
+import ZoomOutIcon from '@mui/icons-material/RemoveCircleOutline';
+import ZoomInIcon from '@mui/icons-material/ControlPoint';
+import Typography from '@mui/material/Typography';
+import IconButton from '@mui/material/IconButton';
+
+interface Props {
+ entrySize: EntrySizes;
+ changeEntrySize: (entrySize: EntrySizes) => void;
+}
+
+export enum EntrySizes {
+ huge = 'huge',
+ big = 'big',
+ normal = 'normal',
+ small = 'small',
+ tiny = 'tiny',
+}
+
+function mapEntrySizeToPercent(entrySize: EntrySizes) {
+ if (entrySize === EntrySizes.huge) {
+ return '120%';
+ } else if (entrySize === EntrySizes.big) {
+ return '110%';
+ } else if (entrySize === EntrySizes.normal) {
+ return '100%';
+ } else if (entrySize === EntrySizes.small) {
+ return '90%';
+ } else if (entrySize === EntrySizes.tiny) {
+ return '80%';
+ }
+}
+
+export default function ZoomComponent(props: Props) {
+ const { changeEntrySize, entrySize } = props;
+ const theme = useTheme();
+ const entrySizePercent = mapEntrySizeToPercent(entrySize);
+
+ function zoomIn() {
+ if (entrySize === EntrySizes.huge) {
+ // changeEntrySize(EntrySizes.tiny);
+ } else if (entrySize === EntrySizes.big) {
+ changeEntrySize(EntrySizes.huge);
+ } else if (entrySize === EntrySizes.normal) {
+ changeEntrySize(EntrySizes.big);
+ } else if (entrySize === EntrySizes.small) {
+ changeEntrySize(EntrySizes.normal);
+ } else if (entrySize === EntrySizes.tiny) {
+ changeEntrySize(EntrySizes.small);
+ }
+ }
+
+ function zoomOut() {
+ if (entrySize === EntrySizes.huge) {
+ changeEntrySize(EntrySizes.big);
+ } else if (entrySize === EntrySizes.big) {
+ changeEntrySize(EntrySizes.normal);
+ } else if (entrySize === EntrySizes.normal) {
+ changeEntrySize(EntrySizes.small);
+ } else if (entrySize === EntrySizes.small) {
+ changeEntrySize(EntrySizes.tiny);
+ } else if (entrySize === EntrySizes.tiny) {
+ // changeEntrySize(EntrySizes.small);
+ }
+ }
+
+ return (
+ <Box sx={{ display: 'flex' }}>
+ <IconButton onClick={zoomOut}>
+ <ZoomOutIcon />
+ </IconButton>
+ <Typography
+ variant="overline"
+ style={{ color: theme.palette.text.primary, marginTop: 4 }}
+ >
+ {entrySizePercent}
+ </Typography>
+ <IconButton onClick={zoomIn}>
+ <ZoomInIcon />
+ </IconButton>
+ </Box>
+ );
+}
diff --git a/src/renderer/hooks/DirectoryContentContextProvider.tsx b/src/renderer/hooks/DirectoryContentContextProvider.tsx
index 16712a537..63f2189ec 100644
--- a/src/renderer/hooks/DirectoryContentContextProvider.tsx
+++ b/src/renderer/hooks/DirectoryContentContextProvider.tsx
@@ -570,10 +570,6 @@ export const DirectoryContentContextProvider = ({
//OPEN ISTRUNCATED dialog
dispatch(AppActions.toggleTruncatedConfirmDialog());
}
- updateHistory(
- { ...currentLocation, path: currentLocationPath.current },
- directoryPath,
- );
if (results !== undefined) {
// console.debug('app listDirectoryPromise resolved:' + results.length);
return loadDirectorySuccess(
@@ -683,6 +679,10 @@ export const DirectoryContentContextProvider = ({
//}
setCurrentDirectoryEntries(directoryContent);
currentDirectoryPath.current = directoryPath;
+ updateHistory(
+ { ...currentLocation, path: currentLocationPath.current },
+ directoryPath,
+ );
return directoryContent;
}
diff --git a/src/renderer/perspectives/grid-perspective/components/GridCell.tsx b/src/renderer/perspectives/grid-perspective/components/GridCell.tsx
new file mode 100644
index 000000000..122791eaf
--- /dev/null
+++ b/src/renderer/perspectives/grid-perspective/components/GridCell.tsx
@@ -0,0 +1,516 @@
+/**
+ * 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, { useMemo } from 'react';
+import { useSelector, useDispatch } from 'react-redux';
+import { useTheme, styled } from '@mui/material/styles';
+import { useTranslation } from 'react-i18next';
+import classNames from 'classnames';
+import Typography from '@mui/material/Typography';
+import Paper from '@mui/material/Paper';
+import Box from '@mui/material/Box';
+import Card from '@mui/material/Card';
+import CardHeader from '@mui/material/CardHeader';
+import CardMedia from '@mui/material/CardMedia';
+import CardContent from '@mui/material/CardContent';
+import CardActions from '@mui/material/CardActions';
+import Tooltip from '-/components/Tooltip';
+import FolderOpenIcon from '@mui/icons-material/FolderOpen';
+import IconButton from '@mui/material/IconButton';
+import {
+ SelectedIcon,
+ UnSelectedIcon,
+ MoreMenuIcon,
+} from '-/components/CommonIcons';
+import {
+ formatFileSize,
+ formatDateTime,
+} from '@tagspaces/tagspaces-common/misc';
+import {
+ extractTagsAsObjects,
+ extractTitle,
+} from '@tagspaces/tagspaces-common/paths';
+import AppConfig from '-/AppConfig';
+import {
+ findBackgroundColorForFolder,
+ findColorForEntry,
+ getDescriptionPreview,
+} from '-/services/utils-io';
+import TagContainerDnd from '-/components/TagContainerDnd';
+import TagContainer from '-/components/TagContainer';
+import TagsPreview from '-/components/TagsPreview';
+import PlatformIO from '-/services/platform-facade';
+import EntryIcon from '-/components/EntryIcon';
+import { TS } from '-/tagspaces.namespace';
+import {
+ actions as AppActions,
+ AppDispatch,
+ getLastThumbnailImageChange,
+} from '-/reducers/app';
+import { dataTidFormat } from '-/services/test';
+import {
+ getSupportedFileTypes,
+ isDesktopMode,
+ isReorderTags,
+} from '-/reducers/settings';
+import { defaultSettings } from '../index';
+import { useTaggingActionsContext } from '-/hooks/useTaggingActionsContext';
+import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
+import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';
+import { EntrySizes } from '-/components/ZoomComponent';
+
+export function urlGetDelim(url) {
+ return url.indexOf('?') > 0 ? '&' : '?';
+}
+
+export function calculateEntryWitdth(entrySize: EntrySizes) {
+ let entryWidth = 200;
+ if (entrySize === EntrySizes.tiny) {
+ entryWidth = 100;
+ } else if (entrySize === EntrySizes.small) {
+ entryWidth = 150;
+ } else if (entrySize === EntrySizes.normal) {
+ entryWidth = 200;
+ } else if (entrySize === EntrySizes.big) {
+ entryWidth = 250;
+ } else if (entrySize === EntrySizes.huge) {
+ entryWidth = 300;
+ }
+ return entryWidth;
+}
+
+export function calculateEntryHeight(entrySize: EntrySizes) {
+ let entryHeight = 200;
+ if (entrySize === EntrySizes.tiny) {
+ entryHeight = 100;
+ } else if (entrySize === EntrySizes.small) {
+ entryHeight = 150;
+ } else if (entrySize === EntrySizes.normal) {
+ entryHeight = 200;
+ } else if (entrySize === EntrySizes.big) {
+ entryHeight = 250;
+ } else if (entrySize === EntrySizes.huge) {
+ entryHeight = 300;
+ }
+ return entryHeight;
+}
+
+const PREFIX = 'GridStyles';
+export const classes = {
+ gridCell: `${PREFIX}-gridCell`,
+ selectedGridCell: `${PREFIX}-selectedGridCell`,
+ gridCellTitle: `${PREFIX}-gridCellTitle`,
+ // gridCellTags: `${PREFIX}-gridCellTags`,
+ gridCellDescription: `${PREFIX}-gridCellDescription`,
+ gridFileExtension: `${PREFIX}-gridFileExtension`,
+ gridSizeDate: `${PREFIX}-gridSizeDate`,
+ gridDetails: `${PREFIX}-gridDetails`,
+ gridFolder: `${PREFIX}-gridFolder`,
+};
+
+export const GridPaper = styled(Card)(({ theme }) => ({
+ [`& .${classes.gridCell}`]: {
+ border: '2px solid transparent',
+ marginTop: 1,
+ marginLeft: 2,
+ marginBottom: 1,
+ marginRight: 1,
+ },
+ [`& .${classes.selectedGridCell}`]: {
+ border: '2px solid' + theme.palette.primary.main,
+ backgroundColor: theme.palette.primary.light + ' !important',
+ },
+ [`& .${classes.gridCellTitle}`]: {
+ padding: '0px 5px 0 5px',
+ minHeight: 45,
+ display: '-webkit-box',
+ WebkitLineClamp: 2,
+ WebkitBoxOrient: 'vertical',
+ textOverflow: 'ellipsis',
+ overflow: 'hidden',
+ },
+ // [`& .${classes.gridCellTags}`]: {
+ // padding: 0,
+ // paddingTop: 2,
+ // height: 100,
+ // overflowY: 'auto',
+ // overflowX: 'hidden',
+ // position: 'relative',
+ // },
+ [`& .${classes.gridCellDescription}`]: {
+ padding: 2,
+ margin: 2,
+ backgroundColor: theme.palette.background.paper,
+ borderRadius: 5,
+ opacity: 0.6,
+ wordBreak: 'break-word',
+ display: 'block',
+ },
+ [`& .${classes.gridFileExtension}`]: {
+ paddingTop: 1,
+ paddingBottom: 7,
+ paddingLeft: 3,
+ paddingRight: 3,
+ fontSize: 13,
+ marginRight: 5,
+ minWidth: 35,
+ height: 16,
+ color: 'white',
+ borderRadius: 3,
+ textAlign: 'center',
+ },
+}));
+
+interface Props {
+ selected: boolean;
+ isLast?: boolean;
+ fsEntry: TS.FileSystemEntry;
+ entrySize: EntrySizes;
+ style?: any;
+ thumbnailMode: any;
+ selectEntry: (fsEntry: TS.FileSystemEntry) => void;
+ deselectEntry: (fsEntry: TS.FileSystemEntry) => void;
+ selectionMode: boolean;
+ showTags: boolean;
+ handleTagMenu: (event: Object, tag: TS.Tag, entryPath: string) => void;
+ handleGridContextMenu: (event: Object, fsEntry: TS.FileSystemEntry) => void;
+ handleGridCellDblClick: (event: Object, fsEntry: TS.FileSystemEntry) => void;
+ handleGridCellClick: (event: Object, fsEntry: TS.FileSystemEntry) => void;
+ showEntriesDescription?: boolean;
+}
+
+function GridCell(props: Props) {
+ const {
+ selected,
+ fsEntry,
+ entrySize,
+ thumbnailMode,
+ handleTagMenu,
+ handleGridContextMenu,
+ handleGridCellDblClick,
+ handleGridCellClick,
+ showEntriesDescription,
+ showTags,
+ selectEntry,
+ deselectEntry,
+ selectionMode,
+ isLast,
+ } = props;
+
+ const { t } = useTranslation();
+ const theme = useTheme();
+ const { selectedEntries } = useSelectedEntriesContext();
+ const { addTags, editTagForEntry } = useTaggingActionsContext();
+ const { readOnlyMode } = useCurrentLocationContext();
+ const supportedFileTypes = useSelector(getSupportedFileTypes);
+ const reorderTags: boolean = useSelector(isReorderTags);
+ const lastThumbnailImageChange = useSelector(getLastThumbnailImageChange);
+ const desktopMode = useSelector(isDesktopMode);
+ const dispatch: AppDispatch = useDispatch();
+
+ const handleEditTag = (path: string, tag: TS.Tag, newTagTitle?: string) => {
+ editTagForEntry(path, tag, newTagTitle);
+ };
+ const handleAddTags = (
+ paths: Array<string>,
+ tags: Array<TS.Tag>,
+ updateIndex?,
+ ) => {
+ addTags(paths, tags, updateIndex);
+ };
+
+ const handleAddTag = (tag: TS.Tag, parentTagGroupUuid: TS.Uuid) => {
+ dispatch(AppActions.addTag(tag, parentTagGroupUuid));
+ };
+
+ // remove isNewFile on Cell click it will open file in editMode
+ const fSystemEntry: TS.FileSystemEntry = (({ isNewFile, ...o }) => o)(
+ fsEntry,
+ );
+
+ const entryTitle = extractTitle(
+ fSystemEntry.name,
+ !fSystemEntry.isFile,
+ PlatformIO.getDirSeparator(),
+ );
+
+ let description;
+ if (showEntriesDescription) {
+ description = fSystemEntry.description;
+ if (
+ description &&
+ description.length > defaultSettings.maxDescriptionPreviewLength
+ ) {
+ description = getDescriptionPreview(
+ description,
+ defaultSettings.maxDescriptionPreviewLength,
+ );
+ }
+ }
+
+ const fileSystemEntryColor = findColorForEntry(
+ fSystemEntry,
+ supportedFileTypes,
+ );
+ const fileSystemEntryBgColor = findBackgroundColorForFolder(fSystemEntry);
+
+ let fileNameTags = [];
+ if (fSystemEntry.isFile) {
+ fileNameTags = extractTagsAsObjects(
+ fSystemEntry.name,
+ AppConfig.tagDelimiter,
+ PlatformIO.getDirSeparator(),
+ );
+ }
+
+ const fileSystemEntryTags = fSystemEntry.tags ? fSystemEntry.tags : [];
+ const sideCarTagsTitles = fileSystemEntryTags.map((tag) => tag.title);
+ const entryTags = [
+ ...fileSystemEntryTags,
+ ...fileNameTags.filter((tag) => !sideCarTagsTitles.includes(tag.title)),
+ ];
+
+ const entryPath = fSystemEntry.path;
+ const isSmall = entrySize === EntrySizes.tiny; // || entrySize === EntrySizes.small;
+
+ const renderTags = useMemo(() => {
+ let sideCarLength = 0;
+ return entryTags.map((tag: TS.Tag, index) => {
+ const tagContainer = readOnlyMode ? (
+ <TagContainer
+ tag={tag}
+ key={entryPath + tag.title}
+ entryPath={entryPath}
+ addTags={handleAddTags}
+ handleTagMenu={handleTagMenu}
+ />
+ ) : (
+ <TagContainerDnd
+ tag={tag}
+ index={tag.type === 'sidecar' ? index : index - sideCarLength}
+ key={entryPath + tag.title}
+ entryPath={entryPath}
+ addTags={handleAddTags}
+ addTag={handleAddTag}
+ handleTagMenu={handleTagMenu}
+ selectedEntries={selectedEntries}
+ editTagForEntry={handleEditTag}
+ reorderTags={reorderTags}
+ />
+ );
+
+ if (tag.type === 'sidecar') {
+ sideCarLength = index + 1;
+ }
+ return tagContainer;
+ });
+ }, [entryTags, readOnlyMode, reorderTags, entryPath]);
+
+ const maxHeight = calculateEntryHeight(entrySize);
+
+ function generateCardHeader() {
+ return (
+ !isSmall &&
+ fSystemEntry.isFile &&
+ fSystemEntry.lmdt && (
+ <>
+ <Tooltip
+ title={
+ t('core:modifiedDate') +
+ ': ' +
+ formatDateTime(fSystemEntry.lmdt, true)
+ }
+ >
+ {formatDateTime(fSystemEntry.lmdt, false)}
+ </Tooltip>
+ <Tooltip title={fSystemEntry.size + ' ' + t('core:sizeInBytes')}>
+ <span>{' | ' + formatFileSize(fSystemEntry.size)}</span>
+ </Tooltip>
+ </>
+ )
+ );
+ }
+
+ function generateAvatar() {
+ return selectionMode ? (
+ <IconButton
+ style={{
+ opacity: selected ? 1 : 0.5,
+ padding: desktopMode ? 5 : 8,
+ }}
+ size="small"
+ onMouseLeave={(e) => {
+ //@ts-ignore
+ e.target.style.opacity = selected ? 1 : 0.5;
+ }}
+ onMouseOver={(e) => {
+ //@ts-ignore
+ e.target.style.opacity = 1;
+ }}
+ onClick={(e) => {
+ e.stopPropagation();
+ if (selected) {
+ deselectEntry(fSystemEntry);
+ } else {
+ selectEntry(fSystemEntry);
+ }
+ }}
+ >
+ {selected ? (
+ <SelectedIcon
+ style={{
+ opacity: 1,
+ borderRadius: 15,
+ backgroundColor: '#d7d7d7',
+ }}
+ />
+ ) : (
+ <UnSelectedIcon
+ style={{
+ opacity: 0.7,
+ borderRadius: 15,
+ backgroundColor: 'd7d7d7',
+ }}
+ />
+ )}
+ </IconButton>
+ ) : (
+ <Tooltip title={fSystemEntry.path}>
+ <Typography
+ className={classes.gridFileExtension}
+ style={{
+ display: 'inline',
+ backgroundColor: fileSystemEntryColor,
+ textShadow: '1px 1px #8f8f8f',
+ textOverflow: 'unset',
+ maxWidth: fSystemEntry.isFile ? 50 : 100,
+ }}
+ noWrap={true}
+ variant="button"
+ onClick={(e) => {
+ e.stopPropagation();
+ selectEntry(fSystemEntry);
+ }}
+ >
+ {fSystemEntry.isFile ? fSystemEntry.extension : <FolderOpenIcon />}
+ </Typography>
+ </Tooltip>
+ );
+ }
+
+ return (
+ <GridPaper
+ data-entry-id={fSystemEntry.uuid}
+ data-tid={'fsEntryName_' + dataTidFormat(fSystemEntry.name)}
+ // className={classNames(
+ // classes.gridCell,
+ // selected && classes.selectedGridCell,
+ // )}
+ style={{
+ height: maxHeight,
+ minHeight: maxHeight,
+ maxHeight: maxHeight,
+ marginBottom: isLast ? 40 : 'auto',
+ background: fileSystemEntryBgColor && theme.palette.background.default,
+ }}
+ onContextMenu={(event) => handleGridContextMenu(event, fSystemEntry)}
+ onDoubleClick={(event) => {
+ handleGridCellDblClick(event, fSystemEntry);
+ }}
+ onClick={(event) => {
+ event.stopPropagation();
+ AppConfig.isCordovaiOS // TODO DoubleClick not fired in Cordova IOS
+ ? handleGridCellDblClick(event, fSystemEntry)
+ : handleGridCellClick(event, fSystemEntry);
+ }}
+ onDrag={(event) => {
+ handleGridCellClick(event, fSystemEntry);
+ }}
+ >
+ <CardHeader
+ style={{ padding: 5 }}
+ sx={{
+ '.MuiCardHeader-avatar': {
+ margin: 0,
+ alignSelf: 'flex-start',
+ },
+ '.MuiCardHeader-subheader': {
+ fontSize: 12,
+ },
+ // '.MuiCardHeader-header': {
+ // fontSize: 12,
+ // },
+ }}
+ title={entryTitle}
+ subheader={generateCardHeader()}
+ action={
+ <IconButton
+ aria-label="entry context menu"
+ size="small"
+ onClick={(event) => handleGridContextMenu(event, fSystemEntry)}
+ >
+ <MoreMenuIcon />
+ </IconButton>
+ }
+ avatar={generateAvatar()}
+ ></CardHeader>
+
+ <CardContent sx={{ width: 'auto', padding: 0, height: maxHeight - 30 }}>
+ {fSystemEntry.thumbPath ? (
+ <img
+ alt="thumbnail"
+ style={{
+ backgroundRepeat: 'no-repeat',
+ backgroundPosition: 'center',
+ objectFit: thumbnailMode,
+ width: '100%',
+ height: '100%',
+ }}
+ src={
+ fSystemEntry.thumbPath +
+ (lastThumbnailImageChange &&
+ lastThumbnailImageChange.thumbPath === fSystemEntry.thumbPath &&
+ !PlatformIO.haveObjectStoreSupport() &&
+ !PlatformIO.haveWebDavSupport()
+ ? urlGetDelim(fSystemEntry.thumbPath) +
+ lastThumbnailImageChange.dt
+ : '')
+ }
+ // @ts-ignore
+ onError={(i) => (i.target.style.display = 'none')}
+ loading="lazy"
+ />
+ ) : (
+ <Box style={{ width: '50%', margin: '0 auto' }}>
+ <EntryIcon
+ isFile={fSystemEntry.isFile}
+ fileExtension={fSystemEntry.extension}
+ />
+ </Box>
+ )}
+ {showTags && entryTags && !isSmall ? (
+ renderTags
+ ) : (
+ <TagsPreview tags={entryTags} />
+ )}
+ </CardContent>
+ </GridPaper>
+ );
+}
+
+export default GridCell;
diff --git a/src/renderer/perspectives/grid-perspective/components/GridPagination.tsx b/src/renderer/perspectives/grid-perspective/components/GridPagination.tsx
index 4e7c3c80b..20b3c21aa 100644
--- a/src/renderer/perspectives/grid-perspective/components/GridPagination.tsx
+++ b/src/renderer/perspectives/grid-perspective/components/GridPagination.tsx
@@ -60,7 +60,6 @@ interface Props {
showDirectories: boolean;
showDetails: boolean;
showDescription: boolean;
- layoutType: string;
showTags: boolean;
desktopMode: boolean;
thumbnailMode: string;
@@ -498,7 +497,6 @@ function mapStateToProps(state) {
}
const areEqual = (prevProp: Props, nextProp: Props) =>
- // nextProp.theme === prevProp.theme &&
JSON.stringify(nextProp.lastBackgroundImageChange) ===
JSON.stringify(prevProp.lastBackgroundImageChange) &&
JSON.stringify(nextProp.lastThumbnailImageChange) ===
diff --git a/src/renderer/perspectives/grid-perspective/components/GridSettingsDialog.tsx b/src/renderer/perspectives/grid-perspective/components/GridSettingsDialog.tsx
index bfb14951c..28e6087a8 100644
--- a/src/renderer/perspectives/grid-perspective/components/GridSettingsDialog.tsx
+++ b/src/renderer/perspectives/grid-perspective/components/GridSettingsDialog.tsx
@@ -34,6 +34,7 @@ import {
FormHelperText,
Typography,
TextField,
+ Box,
} from '@mui/material';
import ListItemIcon from '@mui/material/ListItemIcon';
import ListItemText from '@mui/material/ListItemText';
@@ -46,23 +47,7 @@ import { Pro } from '-/pro';
import { useTheme } from '@mui/material/styles';
import { useTranslation } from 'react-i18next';
import { useSortedDirContext } from '-/perspectives/grid-perspective/hooks/useSortedDirContext';
-
-/*const styles: any = {
- root: {
- overflowX: 'hidden'
- },
- listItem: {
- paddingLeft: 0,
- paddingRight: 0
- },
- pro: {
- backgroundColor: '#1DD19F'
- },
- colorChooserButton: {
- minHeight: 30,
- border: '1px solid lightgray'
- }
-};*/
+import ZoomComponent, { EntrySizes } from '-/components/ZoomComponent';
interface Props {
open: boolean;
@@ -82,14 +67,13 @@ interface Props {
toggleThumbnailsMode: () => string;
thumbnailMode: string;
changeEntrySize: (entrySize: string) => void;
- entrySize: string;
+ entrySize: EntrySizes;
changeSingleClickAction: (actionType: string) => void;
singleClickAction: string;
openHelpWebPage: () => void;
handleSortingMenu: (event) => void;
isLocal: boolean;
resetLocalSettings: () => void;
- // setShowDirectories: (check: boolean) => void;
}
function GridSettingsDialog(props: Props) {
@@ -97,7 +81,7 @@ function GridSettingsDialog(props: Props) {
const { sortBy, orderBy } = useSortedDirContext();
const [ignored, forceUpdate] = useReducer((x: number) => x + 1, 0, undefined);
const thumbnailMode = useRef<string>(props.thumbnailMode);
- const entrySize = useRef<string>(props.entrySize);
+ const entrySize = useRef<EntrySizes>(props.entrySize);
const singleClickAction = useRef<string>(props.singleClickAction);
const theme = useTheme();
@@ -144,12 +128,12 @@ function GridSettingsDialog(props: Props) {
}
return (
- <Dialog open={open} onClose={() => onClose()} keepMounted scroll="paper">
+ <Dialog open={open} onClose={onClose} keepMounted scroll="paper">
<DialogTitle>
{t('core:perspectiveSettingsTitle')}
<DialogCloseButton
testId="closePerspectiveSettingsTID"
- onClose={() => onClose()}
+ onClose={onClose}
/>
</DialogTitle>
<DialogContent>
@@ -174,8 +158,27 @@ function GridSettingsDialog(props: Props) {
</Button>
</>
)}
+ <Divider />
+ <Box style={{ display: 'flex' }}>
+ <ZoomComponent
+ entrySize={entrySize.current}
+ changeEntrySize={(eSize: EntrySizes) => {
+ changeEntrySize(eSize);
+ entrySize.current = eSize;
+ forceUpdate();
+ }}
+ />
+ <Typography
+ style={{ color: theme.palette.text.primary, alignSelf: 'center' }}
+ variant="body1"
+ >
+ {t('Size of the entries')}
+ </Typography>
+ </Box>
+ <Divider />
<FormGroup>
<FormControlLabel
+ // labelPlacement="start"
control={
<Switch
data-tid="gridPerspectiveToggleShowDirectories"
@@ -188,6 +191,7 @@ function GridSettingsDialog(props: Props) {
label={t('core:showHideDirectories')}
/>
<FormControlLabel
+ // labelPlacement="start"
control={
<Switch
data-tid="gridPerspectiveToggleShowTags"
@@ -200,6 +204,7 @@ function GridSettingsDialog(props: Props) {
label={t('core:showTags')}
/>
<FormControlLabel
+ // labelPlacement="start"
control={
<Switch
data-tid="gridPerspectiveToggleShowEntriesDescription"
@@ -277,14 +282,13 @@ function GridSettingsDialog(props: Props) {
}
/>
</MenuItem>
- <Divider />
- <MenuItem
+ {/* <MenuItem
data-tid="gridPerspectiveEntrySizeSmall"
title={t('core:entrySizeSmall')}
aria-label={t('core:entrySizeSmall')}
onClick={() => {
changeEntrySize('small');
- entrySize.current = 'small';
+ entrySize.current = EntrySizes.small;
forceUpdate();
}}
>
@@ -303,7 +307,7 @@ function GridSettingsDialog(props: Props) {
aria-label={t('core:entrySizeNormal')}
onClick={() => {
changeEntrySize('normal');
- entrySize.current = 'normal';
+ entrySize.current = EntrySizes.normal;
forceUpdate();
}}
>
@@ -322,7 +326,7 @@ function GridSettingsDialog(props: Props) {
aria-label={t('core:entrySizeBig')}
onClick={() => {
changeEntrySize('big');
- entrySize.current = 'big';
+ entrySize.current = EntrySizes.big;
forceUpdate();
}}
>
@@ -334,7 +338,7 @@ function GridSettingsDialog(props: Props) {
)}
</ListItemIcon>
<ListItemText primary={t('core:entrySizeBig')} />
- </MenuItem>
+ </MenuItem> */}
<Divider />
<MenuItem
data-tid="gridPerspectiveSingleClickOpenInternally"
diff --git a/src/renderer/perspectives/grid-perspective/components/MainContainer.tsx b/src/renderer/perspectives/grid-perspective/components/MainContainer.tsx
index 8cac442d7..d50546e83 100644
--- a/src/renderer/perspectives/grid-perspective/components/MainContainer.tsx
+++ b/src/renderer/perspectives/grid-perspective/components/MainContainer.tsx
@@ -29,14 +29,18 @@ import AddRemoveTagsDialog from '-/components/dialogs/AddRemoveTagsDialog';
import MoveCopyFilesDialog from '-/components/dialogs/MoveCopyFilesDialog';
import TagDropContainer from '-/components/TagDropContainer';
import { actions as AppActions, AppDispatch } from '-/reducers/app';
-import CellContent from './CellContent';
-import MainToolbar from './MainToolbar';
-import SortingMenu from './SortingMenu';
-import GridOptionsMenu from './GridOptionsMenu';
+import GridCell, {
+ calculateEntryHeight,
+ calculateEntryWitdth,
+} from './GridCell';
+import MainToolbar from '-/perspectives/grid-perspective/components/MainToolbar';
+import SortingMenu from '-/perspectives/grid-perspective/components/SortingMenu';
+import GridOptionsMenu from '-/perspectives/grid-perspective/components/GridOptionsMenu';
import PlatformIO from '-/services/platform-facade';
import GridPagination from '-/perspectives/grid-perspective/components/GridPagination';
import GridSettingsDialog from '-/perspectives/grid-perspective/components/GridSettingsDialog';
import AddTagToTagGroupDialog from '-/components/dialogs/AddTagToTagGroupDialog';
+import { EntrySizes } from '-/components/ZoomComponent';
import { TS } from '-/tagspaces.namespace';
import { Pro } from '-/pro';
import Links from 'assets/links';
@@ -88,10 +92,6 @@ function GridPerspective(props: Props) {
const { selectedEntries, setSelectedEntries, lastSelectedEntryPath } =
useSelectedEntriesContext();
const keyBindings = useSelector(getKeyBindingObject);
- //const searchFilter: string = useSelector(getSearchFilter);
- /*const editedEntryPaths: Array<TS.EditedEntryPath> = useSelector(
- getEditedEntryPaths
- );*/
// Create functions that dispatch actions
const handleSetSelectedEntries = (entries: Array<TS.FileSystemEntry>) => {
@@ -128,25 +128,12 @@ function GridPerspective(props: Props) {
useState<null | HTMLElement>(null);
const [isAddTagDialogOpened, setIsAddTagDialogOpened] =
useState<TS.Tag>(undefined);
- /*const sortBy = useRef<string>(
- settings && settings.sortBy ? settings.sortBy : defaultSettings.sortBy
- );
- const orderBy = useRef<null | boolean>(
- settings && typeof settings.orderBy !== 'undefined'
- ? settings.orderBy
- : defaultSettings.orderBy
- );*/
- const layoutType = useRef<string>(
- settings && settings.layoutType
- ? settings.layoutType
- : defaultSettings.layoutType,
- );
const singleClickAction = useRef<string>(
settings && settings.singleClickAction
? settings.singleClickAction
: defaultSettings.singleClickAction,
);
- const entrySize = useRef<string>(
+ const entrySize = useRef<EntrySizes>(
settings && settings.entrySize
? settings.entrySize
: defaultSettings.entrySize,
@@ -229,7 +216,6 @@ function GridPerspective(props: Props) {
perspectiveSettings && perspectiveSettings.showTags !== undefined
? perspectiveSettings.showTags
: defaultSettings.showTags;
- layoutType.current = defaultSettings.layoutType;
setOrderBy(
perspectiveSettings && perspectiveSettings.orderBy !== undefined
? perspectiveSettings.orderBy
@@ -269,7 +255,6 @@ function GridPerspective(props: Props) {
showEntriesDescription: showEntriesDescription.current,
showDetails: showDetails.current,
showTags: showTags.current,
- layoutType: layoutType.current,
orderBy: orderBy,
sortBy: sortBy,
singleClickAction: singleClickAction.current,
@@ -301,7 +286,6 @@ function GridPerspective(props: Props) {
showEntriesDescription.current,
showDetails.current,
showTags.current,
- layoutType.current,
orderBy,
sortBy,
singleClickAction.current,
@@ -310,13 +294,6 @@ function GridPerspective(props: Props) {
gridPageLimit.current,
]);
- /*if ( // for debugging skip first re-renders
- directoryContent.length > 0 &&
- !directoryContent[0].path.startsWith(currentDirectoryPath)
- ) {
- return null;
- }*/
-
const makeFirstSelectedEntryVisible = () => {
if (selectedEntries && selectedEntries.length > 0) {
try {
@@ -335,11 +312,6 @@ function GridPerspective(props: Props) {
}
};
- /*const handleLayoutSwitch = (type: string) => {
- layoutType.current = type;
- // forceUpdate();
- };*/
-
const handleGridPageLimit = (limit: number) => {
gridPageLimit.current = limit;
// forceUpdate();
@@ -432,7 +404,7 @@ function GridPerspective(props: Props) {
const openHelpWebPage = () => {
closeOptionsMenu();
- openURLExternally(Links.documentationLinks.defaultPerspective);
+ openURLExternally(Links.documentationLinks.defaultPerspective, true);
};
const openSettings = () => {
@@ -546,11 +518,6 @@ function GridPerspective(props: Props) {
const entry = selectedEntries[0];
openFileNatively(entry.path);
}
- // if (lastSelectedEntryPath) {
- // openFileNatively(lastSelectedEntryPath);
- // } else if (currentDirectoryPath) {
- // openFileNatively(currentDirectoryPath);
- // }
},
openEntryDetails: () => {
if (selectedEntries && selectedEntries.length === 1) {
@@ -572,15 +539,6 @@ function GridPerspective(props: Props) {
const sortedDirectories = sortedDirContent.filter((entry) => !entry.isFile);
const sortedFiles = sortedDirContent.filter((entry) => entry.isFile);
- let entryWidth = 200;
- if (entrySize.current === 'small') {
- entryWidth = 150;
- } else if (entrySize.current === 'normal') {
- entryWidth = 200;
- } else if (entrySize.current === 'big') {
- entryWidth = 300;
- }
-
const getCellContent = (
fsEntry: TS.FileSystemEntry,
selectedEntries: Array<TS.FileSystemEntry>,
@@ -610,6 +568,8 @@ function GridPerspective(props: Props) {
);
handleSetSelectedEntries(newSelection);
};
+
+ const selectionMode = selectedEntries.length > 0;
return (
<TagDropContainer
entryPath={fsEntry.path} // TODO remove entryPath it is already included in selectedEntries
@@ -617,7 +577,7 @@ function GridPerspective(props: Props) {
selectedEntries.length > 0 ? selectedEntries : [fsEntry]
}
>
- <CellContent
+ <GridCell
selected={selected}
fsEntry={fsEntry}
showEntriesDescription={showEntriesDescription.current}
@@ -625,9 +585,9 @@ function GridPerspective(props: Props) {
isLast={isLast}
thumbnailMode={thumbnailMode.current}
selectEntry={selectEntry}
+ selectionMode={selectionMode}
deselectEntry={deselectEntry}
handleTagMenu={handleTagMenu}
- layoutType={layoutType.current}
showTags={showTags.current}
handleGridContextMenu={(
event: React.MouseEvent<HTMLDivElement>,
@@ -658,6 +618,8 @@ function GridPerspective(props: Props) {
openMoveCopyFilesDialog={openMoveCopyFilesDialog}
handleSortingMenu={handleSortingMenu}
handleExportCsvMenu={handleExportCsvMenu}
+ changeEntrySize={changeEntrySize}
+ entrySize={entrySize.current}
openSettings={openSettings}
openShareFilesDialog={
PlatformIO.haveObjectStoreSupport() ? openShareFilesDialog : undefined
@@ -677,13 +639,18 @@ function GridPerspective(props: Props) {
padding: 5,
paddingBottom: 70,
gridTemplateColumns:
- 'repeat(auto-fit,minmax(' + entryWidth + 'px,1fr))',
+ 'repeat(auto-fit,minmax(' +
+ calculateEntryWitdth(entrySize.current) +
+ 'px,1fr))',
+ gridTemplateRows:
+ 'repeat(auto-fit,minmax(' +
+ calculateEntryHeight(entrySize.current) +
+ 'px,1fr))',
}}
directories={sortedDirectories}
showDetails={showDetails.current}
showDescription={showDescription.current}
showDirectories={showDirectories.current}
- layoutType={layoutType.current}
desktopMode={desktopMode}
openRenameEntryDialog={openRenameEntryDialog}
showTags={showTags.current}
@@ -788,7 +755,6 @@ function GridPerspective(props: Props) {
}
/>
)}
- {/* {Boolean(dirContextMenuAnchorEl) && ( // todo move dialogs from DirectoryMenu */}
<DirectoryMenu
open={Boolean(dirContextMenuAnchorEl)}
onClose={() => {
diff --git a/src/renderer/perspectives/grid-perspective/components/MainToolbar.tsx b/src/renderer/perspectives/grid-perspective/components/MainToolbar.tsx
index 7c9b6316e..af2f9ceb2 100644
--- a/src/renderer/perspectives/grid-perspective/components/MainToolbar.tsx
+++ b/src/renderer/perspectives/grid-perspective/components/MainToolbar.tsx
@@ -17,8 +17,9 @@
*/
import React from 'react';
+import { alpha, useTheme } from '@mui/material/styles';
import { useDispatch, useSelector } from 'react-redux';
-import { Toolbar, Box } from '@mui/material/';
+import { Toolbar, Box, Divider } from '@mui/material/';
import Tooltip from '-/components/Tooltip';
import IconButton from '@mui/material/IconButton';
import SortingIcon from '@mui/icons-material/SwapVerticalCircle';
@@ -36,12 +37,9 @@ import {
import AppConfig from '-/AppConfig';
import { Pro } from '-/pro';
import { ProTooltip } from '-/components/HelperComponents';
+import ZoomSlider, { EntrySizes } from '-/components/ZoomComponent';
import { getKeyBindingObject } from '-/reducers/settings';
import { actions as AppActions, AppDispatch } from '-/reducers/app';
-import {
- classes,
- GridStyles,
-} from '-/perspectives/grid-perspective/components/styles.css';
import { useTranslation } from 'react-i18next';
import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';
import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
@@ -54,6 +52,8 @@ interface Props {
openAddRemoveTagsDialog: () => void;
openMoveCopyFilesDialog: () => void;
handleSortingMenu: (event: Object) => void;
+ changeEntrySize: (entrySize: EntrySizes) => void;
+ entrySize: EntrySizes;
handleExportCsvMenu: () => void;
openSettings: () => void;
openShareFilesDialog?: () => void;
@@ -69,9 +69,12 @@ function MainToolbar(props: Props) {
handleExportCsvMenu,
openSettings,
openShareFilesDialog,
+ entrySize,
+ changeEntrySize,
} = props;
const { t } = useTranslation();
+ const theme = useTheme();
const { openEntry } = useOpenedEntryContext();
const { loadParentDirectoryContent, currentDirectoryPath } =
useDirectoryContentContext();
@@ -85,162 +88,179 @@ function MainToolbar(props: Props) {
}
return (
- <GridStyles>
- <Toolbar
- className={classes.topToolbar}
- data-tid={prefixDataTID + 'perspectiveToolbar'}
+ <Toolbar
+ style={{
+ paddingLeft: 5,
+ paddingRight: 5,
+ position: 'absolute',
+ zIndex: 1,
+ background:
+ 'linear-gradient(0deg, ' +
+ alpha(theme.palette.background.default, 0.67) +
+ ' 0%, ' +
+ theme.palette.background.default +
+ ' 99%)',
+ backdropFilter: 'blur(5px)',
+ // borderBottom: '1px solid ' + theme.palette.divider,
+ width: 'calc(100% - 10px)',
+ overflowX: 'auto',
+ overflowY: 'hidden',
+ }}
+ variant="dense"
+ data-tid={prefixDataTID + 'perspectiveToolbar'}
+ >
+ <Tooltip
+ title={t('core:navigateToParentDirectory')}
+ keyBinding={keyBindings['openParentDirectory']}
>
- <Tooltip
- title={t('core:navigateToParentDirectory')}
- keyBinding={keyBindings['openParentDirectory']}
+ <IconButton
+ aria-label={t('core:navigateToParentDirectory')}
+ data-tid={prefixDataTID + 'PerspectiveOnBackButton'}
+ onClick={() => {
+ loadParentDirectoryContent();
+ }}
+ // size="large"
>
- <IconButton
- aria-label={t('core:navigateToParentDirectory')}
- data-tid={prefixDataTID + 'PerspectiveOnBackButton'}
- onClick={() => {
- /*if (searchQuery && Object.keys(searchQuery).length > 0) {
- dispatch(LocationIndexActions.setSearchQuery({}));
- openCurrentDirectory();
- } else {*/
- loadParentDirectoryContent();
- }}
- size="large"
- >
- <ParentFolderIcon />
- </IconButton>
- </Tooltip>
- <Tooltip
- title={t('core:toggleSelectAllFiles')}
- keyBinding={keyBindings['selectAll']}
+ <ParentFolderIcon />
+ </IconButton>
+ </Tooltip>
+ <Tooltip
+ title={t('core:toggleSelectAllFiles')}
+ keyBinding={keyBindings['selectAll']}
+ >
+ <IconButton
+ data-tid={prefixDataTID + 'PerspectiveSelectAllFiles'}
+ onClick={toggleSelectAllFiles}
+ // size="large"
>
- <IconButton
- data-tid={prefixDataTID + 'PerspectiveSelectAllFiles'}
- onClick={toggleSelectAllFiles}
- size="large"
+ {selectedEntries.length > 1 ? <SelectedIcon /> : <UnSelectedIcon />}
+ </IconButton>
+ </Tooltip>
+ <Tooltip title={t('core:directoryPropertiesTitle')}>
+ <IconButton
+ aria-label={t('core:directoryPropertiesTitle')}
+ data-tid="openFolderProperties"
+ onClick={showProperties}
+ // size="large"
+ >
+ <FolderPropertiesIcon />
+ </IconButton>
+ </Tooltip>
+ <Divider flexItem orientation="vertical" sx={{ mx: 0.5, my: 1 }} />
+ <Box sx={{ display: selectedEntries.length < 1 ? 'none' : 'flex' }}>
+ {!readOnlyMode && (
+ <Tooltip
+ title={t('core:tagSelectedEntries')}
+ keyBinding={keyBindings['addRemoveTags']}
>
- {selectedEntries.length > 1 ? <SelectedIcon /> : <UnSelectedIcon />}
- </IconButton>
- </Tooltip>
- <Tooltip title={t('core:directoryPropertiesTitle')}>
- <IconButton
- aria-label={t('core:directoryPropertiesTitle')}
- data-tid="openFolderProperties"
- onClick={showProperties}
- size="large"
+ <span>
+ <IconButton
+ aria-label={t('core:tagSelectedEntries')}
+ data-tid={prefixDataTID + 'PerspectiveAddRemoveTags'}
+ onClick={openAddRemoveTagsDialog}
+ // size="large"
+ >
+ <TagIcon />
+ </IconButton>
+ </span>
+ </Tooltip>
+ )}
+ {!readOnlyMode && (
+ <Tooltip
+ title={t('core:copyMoveSelectedEntries')}
+ keyBinding={keyBindings['copyMoveSelectedEntries']}
>
- <FolderPropertiesIcon />
- </IconButton>
- </Tooltip>
- <Box sx={{ display: selectedEntries.length < 1 ? 'none' : 'flex' }}>
- {!readOnlyMode && (
- <Tooltip
- title={t('core:tagSelectedEntries')}
- keyBinding={keyBindings['addRemoveTags']}
- >
- <span>
- <IconButton
- aria-label={t('core:tagSelectedEntries')}
- data-tid={prefixDataTID + 'PerspectiveAddRemoveTags'}
- onClick={openAddRemoveTagsDialog}
- size="large"
- >
- <TagIcon />
- </IconButton>
- </span>
- </Tooltip>
- )}
- {!readOnlyMode && (
- <Tooltip
- title={t('core:copyMoveSelectedEntries')}
- keyBinding={keyBindings['copyMoveSelectedEntries']}
- >
- <span>
- <IconButton
- aria-label={t('core:copyMoveSelectedEntries')}
- data-tid={prefixDataTID + 'PerspectiveCopySelectedFiles'}
- onClick={openMoveCopyFilesDialog}
- size="large"
- >
- <CopyIcon />
- </IconButton>
- </span>
- </Tooltip>
- )}
- {!readOnlyMode && (
- <Tooltip
- title={t('core:deleteSelectedEntries')}
- keyBinding={keyBindings['deleteDocument']}
- >
- <span>
- <IconButton
- aria-label={t('core:deleteSelectedEntries')}
- data-tid={prefixDataTID + 'PerspectiveDeleteMultipleFiles'}
- onClick={() =>
- dispatch(AppActions.toggleDeleteMultipleEntriesDialog())
- }
- size="large"
- >
- <DeleteIcon />
- </IconButton>
- </span>
- </Tooltip>
- )}
- {openShareFilesDialog && (
- <ProTooltip tooltip={t('core:shareFiles')}>
- <span>
- <IconButton
- aria-label={t('core:shareFiles')}
- data-tid={prefixDataTID + 'PerspectiveShareFiles'}
- onClick={openShareFilesDialog}
- disabled={selectedEntries.length < 1}
- size="large"
- >
- <ShareIcon />
- </IconButton>
- </span>
- </ProTooltip>
- )}
- </Box>
- <Tooltip title={t('core:sort')}>
- <IconButton
- // title={t('core:sort')}
- aria-label={t('core:sort')}
- data-tid={prefixDataTID + 'PerspectiveSortMenu'}
- onClick={(e) => {
- handleSortingMenu(e);
- }}
- size="large"
+ <span>
+ <IconButton
+ aria-label={t('core:copyMoveSelectedEntries')}
+ data-tid={prefixDataTID + 'PerspectiveCopySelectedFiles'}
+ onClick={openMoveCopyFilesDialog}
+ // size="large"
+ >
+ <CopyIcon />
+ </IconButton>
+ </span>
+ </Tooltip>
+ )}
+ {!readOnlyMode && (
+ <Tooltip
+ title={t('core:deleteSelectedEntries')}
+ keyBinding={keyBindings['deleteDocument']}
>
- <SortingIcon />
- </IconButton>
- </Tooltip>
- {Pro &&
- !AppConfig.isCordovaAndroid && ( // https://trello.com/c/z6ESlqxz/697-exports-to-json-or-csv-do-not-work-on-android
- <Tooltip title={t('core:exportCsv')}>
+ <span>
<IconButton
- data-tid={prefixDataTID + 'PerspectiveExportCsvMenuTID'}
- onClick={handleExportCsvMenu}
- style={{ transform: 'scale(-1, 1)' }}
- size="large"
+ aria-label={t('core:deleteSelectedEntries')}
+ data-tid={prefixDataTID + 'PerspectiveDeleteMultipleFiles'}
+ onClick={() =>
+ dispatch(AppActions.toggleDeleteMultipleEntriesDialog())
+ }
+ // </span>size="large"
>
- <ExportIcon />
+ <DeleteIcon />
</IconButton>
- </Tooltip>
- )}
- <Box sx={{ flexGrow: 1 }} />
- <Box sx={{ display: 'flex' }}>
- <Tooltip title={t('core:perspectiveSettingsTitle')}>
+ </span>
+ </Tooltip>
+ )}
+ {openShareFilesDialog && (
+ <ProTooltip tooltip={t('core:shareFiles')}>
+ <span>
+ <IconButton
+ aria-label={t('core:shareFiles')}
+ data-tid={prefixDataTID + 'PerspectiveShareFiles'}
+ onClick={openShareFilesDialog}
+ disabled={selectedEntries.length < 1}
+ // size="large"
+ >
+ <ShareIcon />
+ </IconButton>
+ </span>
+ </ProTooltip>
+ )}
+ <Divider flexItem orientation="vertical" sx={{ mx: 0.5, my: 1 }} />
+ </Box>
+ <Tooltip title={t('core:sort')}>
+ <IconButton
+ aria-label={t('core:sort')}
+ data-tid={prefixDataTID + 'PerspectiveSortMenu'}
+ onClick={(e) => {
+ handleSortingMenu(e);
+ }}
+ // size="large"
+ >
+ <SortingIcon />
+ </IconButton>
+ </Tooltip>
+ {Pro &&
+ !AppConfig.isCordovaAndroid && ( // SaveAs do not worlk on Android
+ <Tooltip title={t('core:exportCsv')}>
<IconButton
- data-tid={prefixDataTID + 'PerspectiveOptionsMenu'}
- onClick={openSettings}
- size="large"
+ data-tid={prefixDataTID + 'PerspectiveExportCsvMenuTID'}
+ onClick={handleExportCsvMenu}
+ style={{ transform: 'scale(-1, 1)' }}
+ // size="large"
>
- <PerspectiveSettingsIcon />
+ <ExportIcon />
</IconButton>
</Tooltip>
- </Box>
- </Toolbar>
- </GridStyles>
+ )}
+ <Divider flexItem orientation="vertical" sx={{ mx: 0.5, my: 1 }} />
+ <Box sx={{ display: { xs: 'none', sm: 'flex' } }}>
+ <ZoomSlider entrySize={entrySize} changeEntrySize={changeEntrySize} />
+ <Divider flexItem orientation="vertical" sx={{ mx: 0.5, my: 1 }} />
+ </Box>
+ <Box sx={{ flexGrow: 1 }} />
+ <Box sx={{ display: 'flex' }}>
+ <Tooltip title={t('core:perspectiveSettingsTitle')}>
+ <IconButton
+ data-tid={prefixDataTID + 'PerspectiveOptionsMenu'}
+ onClick={openSettings}
+ // size="large"
+ >
+ <PerspectiveSettingsIcon />
+ </IconButton>
+ </Tooltip>
+ </Box>
+ </Toolbar>
);
}
diff --git a/src/renderer/perspectives/grid-perspective/components/styles.css.tsx b/src/renderer/perspectives/grid-perspective/components/styles.css.tsx
deleted file mode 100644
index aa3d72b50..000000000
--- a/src/renderer/perspectives/grid-perspective/components/styles.css.tsx
+++ /dev/null
@@ -1,158 +0,0 @@
-/**
- * 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 { alpha, styled } from '@mui/material/styles';
-
-const PREFIX = 'GridStyles';
-export const classes = {
- gridCell: `${PREFIX}-gridCell`,
- rowCell: `${PREFIX}-rowCell`,
- rowHover: `${PREFIX}-rowHover`,
- selectedGridCell: `${PREFIX}-selectedGridCell`,
- selectedRowCell: `${PREFIX}-selectedRowCell`,
- gridCellThumb: `${PREFIX}-gridCellThumb`,
- gridCellTitle: `${PREFIX}-gridCellTitle`,
- gridCellTags: `${PREFIX}-gridCellTags`,
- gridCellDescription: `${PREFIX}-gridCellDescription`,
- gridFileExtension: `${PREFIX}-gridFileExtension`,
- gridSizeDate: `${PREFIX}-gridSizeDate`,
- gridDetails: `${PREFIX}-gridDetails`,
- gridFolder: `${PREFIX}-gridFolder`,
- topToolbar: `${PREFIX}-topToolbar`,
-};
-
-export const GridStyles = styled('div')(({ theme }) => ({
- // rowContainer: {
- // display: 'grid',
- // gridGap: '0px 0px',
- // padding: 0,
- // margin: 0,
- // paddingBottom: 10
- // },
- [`& .${classes.gridCell}`]: {
- border: '2px solid transparent',
- marginTop: 1,
- marginLeft: 2,
- marginBottom: 1,
- marginRight: 1,
- },
- [`& .${classes.rowCell}`]: {
- boxShadow: 'none',
- borderLeft: '1px solid transparent',
- borderRight: '1px solid transparent',
- borderTop: '1px solid transparent',
- borderBottom: '1px solid ' + theme.palette.divider,
- margin: 0,
- marginTop: 0,
- marginBottom: 0,
- },
- [`& .${classes.rowHover}`]: {
- '&:hover': {
- backgroundColor: theme.palette.divider + ' !important',
- },
- },
- [`& .${classes.selectedGridCell}`]: {
- border: '2px solid' + theme.palette.primary.main,
- backgroundColor: theme.palette.primary.light + ' !important',
- },
- [`& .${classes.selectedRowCell}`]: {
- border: '1px solid' + theme.palette.primary.main + ' !important',
- },
- [`& .${classes.gridCellThumb}`]: {
- backgroundRepeat: 'no-repeat',
- backgroundPosition: 'center',
- borderRadius: 5,
- marginBottom: 5,
- },
- [`& .${classes.gridCellTitle}`]: {
- padding: '0px 5px 0 5px',
- minHeight: 45,
- display: '-webkit-box',
- WebkitLineClamp: 2,
- WebkitBoxOrient: 'vertical',
- textOverflow: 'ellipsis',
- overflow: 'hidden',
- },
- [`& .${classes.gridCellTags}`]: {
- padding: 0,
- paddingTop: 2,
- height: 100,
- overflowY: 'auto',
- overflowX: 'hidden',
- position: 'relative',
- },
- [`& .${classes.gridCellDescription}`]: {
- padding: 2,
- margin: 2,
- backgroundColor: theme.palette.background.paper,
- borderRadius: 5,
- opacity: 0.6,
- wordBreak: 'break-word',
- display: 'block',
- },
- [`& .${classes.gridFileExtension}`]: {
- paddingTop: 1,
- paddingBottom: 7,
- paddingLeft: 3,
- paddingRight: 3,
- fontSize: 13,
- marginRight: 5,
- marginTop: 7,
- minWidth: 35,
- height: 16,
- color: 'white',
- borderRadius: 3,
- textAlign: 'center',
- },
- [`& .${classes.gridSizeDate}`]: {
- overflow: 'hidden',
- whiteSpace: 'nowrap',
- marginRight: 5,
- marginLeft: 'auto',
- paddingTop: 12,
- },
- [`& .${classes.gridDetails}`]: {
- display: 'flex',
- whiteSpace: 'nowrap',
- },
- [`& .${classes.gridFolder}`]: {
- color: 'white',
- padding: 5,
- minHeight: 15,
- height: 20,
- borderRadius: 3,
- },
- [`& .${classes.topToolbar}`]: {
- paddingLeft: 5,
- paddingRight: 5,
- minHeight: 40,
- height: 53,
- position: 'absolute',
- zIndex: 1,
- background:
- 'linear-gradient(0deg, ' +
- alpha(theme.palette.background.default, 0.67) +
- ' 0%, ' +
- theme.palette.background.default +
- ' 99%)',
- backdropFilter: 'blur(5px)',
- // borderBottom: '1px solid ' + theme.palette.divider,
- width: 'calc(100% - 10px)',
- overflowX: 'auto',
- overflowY: 'hidden',
- },
-}));
diff --git a/src/renderer/perspectives/grid-perspective/index.tsx b/src/renderer/perspectives/grid-perspective/index.tsx
index 8d91eb0eb..863e0a63b 100644
--- a/src/renderer/perspectives/grid-perspective/index.tsx
+++ b/src/renderer/perspectives/grid-perspective/index.tsx
@@ -1,6 +1,6 @@
import React from 'react';
-
export { default } from './components/MainContainer';
+import { EntrySizes } from '-/components/ZoomComponent';
// interface PerspectiveSettings {
// settingsKey: string;
@@ -21,7 +21,7 @@ export const defaultSettings = {
sortBy: 'byName',
layoutType: 'grid', // list grid
singleClickAction: 'openInternal', // openInternal openExternal
- entrySize: 'small', // small, normal, big
+ entrySize: EntrySizes.small,
thumbnailMode: 'contain', // cover contain
showDirectories: true,
showDetails: true,
@@ -29,4 +29,5 @@ export const defaultSettings = {
showEntriesDescription: true,
showTags: true,
gridPageLimit: 100,
+ maxDescriptionPreviewLength: 100,
};
diff --git a/src/renderer/perspectives/list/components/MainContainer.tsx b/src/renderer/perspectives/list/components/MainContainer.tsx
index e12ee7199..f6e24c83d 100644
--- a/src/renderer/perspectives/list/components/MainContainer.tsx
+++ b/src/renderer/perspectives/list/components/MainContainer.tsx
@@ -29,7 +29,8 @@ import AddRemoveTagsDialog from '-/components/dialogs/AddRemoveTagsDialog';
import MoveCopyFilesDialog from '-/components/dialogs/MoveCopyFilesDialog';
import TagDropContainer from '-/components/TagDropContainer';
import { actions as AppActions, AppDispatch } from '-/reducers/app';
-import CellContent from '-/perspectives/grid-perspective/components/CellContent';
+import RowCell from '-/perspectives/list/components/RowCell';
+import { EntrySizes } from '-/components/ZoomComponent';
import MainToolbar from '-/perspectives/grid-perspective/components/MainToolbar';
import SortingMenu from '-/perspectives/grid-perspective/components/SortingMenu';
import GridOptionsMenu from '-/perspectives/grid-perspective/components/GridOptionsMenu';
@@ -136,17 +137,12 @@ function ListPerspective(props: Props) {
? settings.orderBy
: defaultSettings.orderBy
);*/
- const layoutType = useRef<string>(
- settings && settings.layoutType
- ? settings.layoutType
- : defaultSettings.layoutType,
- );
const singleClickAction = useRef<string>(
settings && settings.singleClickAction
? settings.singleClickAction
: defaultSettings.singleClickAction,
);
- const entrySize = useRef<string>(
+ const entrySize = useRef<EntrySizes>(
settings && settings.entrySize
? settings.entrySize
: defaultSettings.entrySize,
@@ -229,7 +225,6 @@ function ListPerspective(props: Props) {
perspectiveSettings && perspectiveSettings.showTags !== undefined
? perspectiveSettings.showTags
: defaultSettings.showTags;
- layoutType.current = defaultSettings.layoutType;
setOrderBy(
perspectiveSettings && perspectiveSettings.orderBy !== undefined
? perspectiveSettings.orderBy
@@ -269,7 +264,6 @@ function ListPerspective(props: Props) {
showEntriesDescription: showEntriesDescription.current,
showDetails: showDetails.current,
showTags: showTags.current,
- layoutType: layoutType.current,
orderBy: orderBy,
sortBy: sortBy,
singleClickAction: singleClickAction.current,
@@ -301,7 +295,6 @@ function ListPerspective(props: Props) {
showEntriesDescription.current,
showDetails.current,
showTags.current,
- layoutType.current,
orderBy,
sortBy,
singleClickAction.current,
@@ -328,11 +321,6 @@ function ListPerspective(props: Props) {
}
};
- /*const handleLayoutSwitch = (type: string) => {
- layoutType.current = type;
- // forceUpdate();
- };*/
-
const handleGridPageLimit = (limit: number) => {
gridPageLimit.current = limit;
// forceUpdate();
@@ -539,11 +527,6 @@ function ListPerspective(props: Props) {
const entry = selectedEntries[0];
openFileNatively(entry.path);
}
- // if (lastSelectedEntryPath) {
- // openFileNatively(lastSelectedEntryPath);
- // } else if (currentDirectoryPath) {
- // openFileNatively(currentDirectoryPath);
- // }
},
openEntryDetails: () => {
if (selectedEntries && selectedEntries.length === 1) {
@@ -610,7 +593,7 @@ function ListPerspective(props: Props) {
selectedEntries.length > 0 ? selectedEntries : [fsEntry]
}
>
- <CellContent
+ <RowCell
selected={selected}
fsEntry={fsEntry}
showEntriesDescription={showEntriesDescription.current}
@@ -620,7 +603,6 @@ function ListPerspective(props: Props) {
selectEntry={selectEntry}
deselectEntry={deselectEntry}
handleTagMenu={handleTagMenu}
- layoutType={layoutType.current}
showTags={showTags.current}
handleGridContextMenu={(
event: React.MouseEvent<HTMLDivElement>,
@@ -651,6 +633,8 @@ function ListPerspective(props: Props) {
openMoveCopyFilesDialog={openMoveCopyFilesDialog}
handleSortingMenu={handleSortingMenu}
handleExportCsvMenu={handleExportCsvMenu}
+ changeEntrySize={changeEntrySize}
+ entrySize={entrySize.current}
openSettings={openSettings}
openShareFilesDialog={
PlatformIO.haveObjectStoreSupport() ? openShareFilesDialog : undefined
@@ -674,7 +658,6 @@ function ListPerspective(props: Props) {
showDetails={showDetails.current}
showDescription={showDescription.current}
showDirectories={showDirectories.current}
- layoutType={layoutType.current}
desktopMode={desktopMode}
openRenameEntryDialog={openRenameEntryDialog}
showTags={showTags.current}
diff --git a/src/renderer/perspectives/grid-perspective/components/CellContent.tsx b/src/renderer/perspectives/list/components/RowCell.tsx
similarity index 59%
rename from src/renderer/perspectives/grid-perspective/components/CellContent.tsx
rename to src/renderer/perspectives/list/components/RowCell.tsx
index f149b7e72..f8b27f38e 100644
--- a/src/renderer/perspectives/grid-perspective/components/CellContent.tsx
+++ b/src/renderer/perspectives/list/components/RowCell.tsx
@@ -18,14 +18,12 @@
import React, { useMemo } from 'react';
import { useSelector, useDispatch } from 'react-redux';
-import { useTheme } from '@mui/material/styles';
+import { useTheme, styled } from '@mui/material/styles';
import classNames from 'classnames';
import Grid from '@mui/material/Grid';
import Typography from '@mui/material/Typography';
import Paper from '@mui/material/Paper';
import Tooltip from '-/components/Tooltip';
-import FolderOpenIcon from '@mui/icons-material/FolderOpen';
-import IconButton from '@mui/material/IconButton';
import { SelectedIcon, UnSelectedIcon } from '-/components/CommonIcons';
import {
formatFileSize,
@@ -45,7 +43,6 @@ import TagContainerDnd from '-/components/TagContainerDnd';
import TagContainer from '-/components/TagContainer';
import TagsPreview from '-/components/TagsPreview';
import PlatformIO from '-/services/platform-facade';
-import EntryIcon from '-/components/EntryIcon';
import { TS } from '-/tagspaces.namespace';
import {
actions as AppActions,
@@ -53,49 +50,83 @@ import {
getLastThumbnailImageChange,
} from '-/reducers/app';
import { FolderIcon } from '-/components/CommonIcons';
-import { dataTidFormat } from '-/services/test';
-import {
- getSupportedFileTypes,
- isDesktopMode,
- isReorderTags,
-} from '-/reducers/settings';
-import {
- classes,
- GridStyles,
-} from '-/perspectives/grid-perspective/components/styles.css';
+import { EntrySizes } from '-/components/ZoomComponent';
+import { getSupportedFileTypes, isReorderTags } from '-/reducers/settings';
+import { defaultSettings } from '../index';
import { useTranslation } from 'react-i18next';
import { useTaggingActionsContext } from '-/hooks/useTaggingActionsContext';
import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';
-const maxDescriptionPreviewLength = 100;
+const PREFIX = 'RowStyles';
+export const classes = {
+ rowCell: `${PREFIX}-rowCell`,
+ rowHover: `${PREFIX}-rowHover`,
+ selectedRowCell: `${PREFIX}-selectedRowCell`,
+};
+
+export const RowPaper = styled(Paper)(({ theme }) => ({
+ [`& .${classes.rowCell}`]: {
+ boxShadow: 'none',
+ borderLeft: '1px solid transparent',
+ borderRight: '1px solid transparent',
+ borderTop: '1px solid transparent',
+ borderBottom: '1px solid ' + theme.palette.divider,
+ margin: 0,
+ marginTop: 0,
+ marginBottom: 0,
+ },
+ [`& .${classes.rowHover}`]: {
+ '&:hover': {
+ backgroundColor: theme.palette.divider + ' !important',
+ },
+ },
+ [`& .${classes.selectedRowCell}`]: {
+ border: '1px solid' + theme.palette.primary.main + ' !important',
+ },
+}));
interface Props {
selected: boolean;
isLast?: boolean;
fsEntry: TS.FileSystemEntry;
- entrySize: string;
+ entrySize: EntrySizes;
style?: any;
thumbnailMode: any;
selectEntry: (fsEntry: TS.FileSystemEntry) => void;
deselectEntry: (fsEntry: TS.FileSystemEntry) => void;
+ // selectionMode: boolean;
showTags: boolean;
handleTagMenu: (event: Object, tag: TS.Tag, entryPath: string) => void;
- layoutType: string;
handleGridContextMenu: (event: Object, fsEntry: TS.FileSystemEntry) => void;
handleGridCellDblClick: (event: Object, fsEntry: TS.FileSystemEntry) => void;
handleGridCellClick: (event: Object, fsEntry: TS.FileSystemEntry) => void;
showEntriesDescription?: boolean;
}
-function CellContent(props: Props) {
+export function calculateEntryHeight(entrySize: EntrySizes) {
+ let entryHeight = 200;
+ if (entrySize === EntrySizes.tiny) {
+ entryHeight = 30;
+ } else if (entrySize === EntrySizes.small) {
+ entryHeight = 70;
+ } else if (entrySize === EntrySizes.normal) {
+ entryHeight = 90;
+ } else if (entrySize === EntrySizes.big) {
+ entryHeight = 120;
+ } else if (entrySize === EntrySizes.huge) {
+ entryHeight = 150;
+ }
+ return entryHeight;
+}
+
+function RowCell(props: Props) {
const {
selected,
fsEntry,
entrySize,
thumbnailMode,
handleTagMenu,
- layoutType,
handleGridContextMenu,
handleGridCellDblClick,
handleGridCellClick,
@@ -114,8 +145,6 @@ function CellContent(props: Props) {
const supportedFileTypes = useSelector(getSupportedFileTypes);
const reorderTags: boolean = useSelector(isReorderTags);
const lastThumbnailImageChange = useSelector(getLastThumbnailImageChange);
- const desktopMode = useSelector(isDesktopMode);
-
const dispatch: AppDispatch = useDispatch();
// You can use the dispatch function to dispatch actions
@@ -148,14 +177,17 @@ function CellContent(props: Props) {
let description;
if (showEntriesDescription) {
description = fSystemEntry.description;
- if (description && description.length > maxDescriptionPreviewLength) {
+ if (
+ description &&
+ description.length > defaultSettings.maxDescriptionPreviewLength
+ ) {
description = getDescriptionPreview(
description,
- maxDescriptionPreviewLength,
+ defaultSettings.maxDescriptionPreviewLength,
);
}
- if (description && layoutType === 'row' && fSystemEntry.isFile) {
+ if (description && fSystemEntry.isFile) {
description = ' | ' + description;
}
}
@@ -189,16 +221,6 @@ function CellContent(props: Props) {
fSystemEntry.lmdt &&
formatDateTime(fSystemEntry.lmdt, true);
- let tmbSize = 85;
- const isSmall = entrySize === 'small';
- if (isSmall) {
- tmbSize = 30;
- } else if (entrySize === 'normal') {
- tmbSize = 70;
- } else if (entrySize === 'big') {
- tmbSize = 100;
- }
-
let tagTitles = '';
if (entryTags) {
entryTags.map((tag) => {
@@ -213,158 +235,76 @@ function CellContent(props: Props) {
return url.indexOf('?') > 0 ? '&' : '?';
}
- function renderGridCell() {
- return (
- <div
- data-tid={'fsEntryName_' + dataTidFormat(fSystemEntry.name)}
- style={{
- background: fileSystemEntryBgColor,
- borderRadius: 5,
- // opacity: fileSystemEntry.isIgnored ? 0.3 : 1
- }}
- >
- <div
- className={classes.gridCellThumb}
- style={{
- position: 'relative',
- height: 150,
- }}
- >
- {fSystemEntry.thumbPath ? (
- <img
- alt="thumbnail"
- className={classes.gridCellThumb}
- src={
- fSystemEntry.thumbPath +
- (lastThumbnailImageChange &&
- lastThumbnailImageChange.thumbPath === fSystemEntry.thumbPath &&
- !PlatformIO.haveObjectStoreSupport() &&
- !PlatformIO.haveWebDavSupport()
- ? urlGetDelim(fSystemEntry.thumbPath) +
- lastThumbnailImageChange.dt
- : '')
- }
- // @ts-ignore
- onError={(i) => (i.target.style.display = 'none')}
- loading="lazy"
- style={{
- objectFit: thumbnailMode,
- position: 'absolute',
- width: '100%',
- height: 150,
- }}
- />
- ) : (
- <EntryIcon
- isFile={fSystemEntry.isFile}
- fileExtension={fSystemEntry.extension}
- />
- )}
- <div id="gridCellTags" className={classes.gridCellTags}>
- <IconButton
- style={{
- opacity: selected ? 1 : 0.5,
- padding: desktopMode ? 5 : 8,
- }}
- onMouseLeave={(e) => {
- //@ts-ignore
- e.target.style.opacity = selected ? 1 : 0.5;
- }}
- onMouseOver={(e) => {
- //@ts-ignore
- e.target.style.opacity = 1;
- }}
- onClick={(e) => {
- e.stopPropagation();
- if (selected) {
- deselectEntry(fSystemEntry);
- } else {
- selectEntry(fSystemEntry);
- }
- }}
- >
- {selected ? (
- <SelectedIcon
- style={{
- opacity: 1,
- borderRadius: 15,
- backgroundColor: '#d7d7d7',
- }}
- />
- ) : (
- <UnSelectedIcon
- style={{
- opacity: 0.7,
- borderRadius: 15,
- backgroundColor: 'd7d7d7',
- }}
- />
- )}
- </IconButton>
- {showTags && entryTags ? renderTags : tagPlaceholder}
- </div>
- {description && (
- <Tooltip title={t('core:entryDescription')}>
- <Typography
- data-tid="gridCellDescription"
- className={classes.gridCellDescription}
- variant="caption"
- >
- {description}
- </Typography>
- </Tooltip>
- )}
- </div>
- <Typography className={classes.gridCellTitle} variant="body1">
- {entryTitle}
- </Typography>
- <div className={classes.gridDetails}>
- <Tooltip title={fSystemEntry.path}>
- <Typography
- className={classes.gridFileExtension}
- style={{
- backgroundColor: fileSystemEntryColor,
- textShadow: '1px 1px #8f8f8f',
- textOverflow: 'unset',
- maxWidth: fSystemEntry.isFile ? 50 : 100,
- }}
- noWrap={true}
- variant="button"
- >
- {fSystemEntry.isFile ? (
- fSystemEntry.extension
- ) : (
- <FolderOpenIcon />
- )}
- </Typography>
- </Tooltip>
- {fSystemEntry.isFile && fSystemEntry.lmdt && (
- <Typography className={classes.gridSizeDate} variant="caption">
- <Tooltip
- title={
- t('core:modifiedDate') +
- ': ' +
- formatDateTime(fSystemEntry.lmdt, true)
- }
- >
- <span>{formatDateTime(fSystemEntry.lmdt, false)}</span>
- </Tooltip>
- <Tooltip title={fSystemEntry.size + ' ' + t('core:sizeInBytes')}>
- <span>{' | ' + formatFileSize(fSystemEntry.size)}</span>
- </Tooltip>
- </Typography>
- )}
- </div>
- </div>
- );
- }
+ const entryPath = fSystemEntry.path;
+
+ const renderTags = useMemo(() => {
+ let sideCarLength = 0;
+ return entryTags.map((tag: TS.Tag, index) => {
+ const tagContainer = readOnlyMode ? (
+ <TagContainer
+ tag={tag}
+ key={entryPath + tag.title}
+ entryPath={entryPath}
+ addTags={handleAddTags}
+ handleTagMenu={handleTagMenu}
+ />
+ ) : (
+ <TagContainerDnd
+ tag={tag}
+ index={tag.type === 'sidecar' ? index : index - sideCarLength}
+ key={entryPath + tag.title}
+ entryPath={entryPath}
+ addTags={handleAddTags}
+ addTag={handleAddTag}
+ handleTagMenu={handleTagMenu}
+ selectedEntries={selectedEntries}
+ editTagForEntry={handleEditTag}
+ reorderTags={reorderTags}
+ />
+ );
+
+ if (tag.type === 'sidecar') {
+ sideCarLength = index + 1;
+ }
+ return tagContainer;
+ });
+ }, [entryTags, readOnlyMode, reorderTags, entryPath]);
+
+ const entryHeight = calculateEntryHeight(entrySize);
+ const isSmall =
+ entrySize === EntrySizes.tiny || entrySize === EntrySizes.small;
- function renderRowCell() {
- const backgroundColor = selected
- ? theme.palette.primary.light
- : fileSystemEntryBgColor;
+ const backgroundColor = selected
+ ? theme.palette.primary.light
+ : fileSystemEntryBgColor;
- return (
+ return (
+ <RowPaper
+ elevation={2}
+ data-entry-id={fSystemEntry.uuid}
+ className={classNames(
+ classes.rowCell,
+ selected && classes.selectedRowCell,
+ )}
+ style={{
+ minHeight: entryHeight,
+ marginBottom: isLast ? 40 : 'auto',
+ backgroundColor: theme.palette.background.default,
+ }}
+ onContextMenu={(event) => handleGridContextMenu(event, fSystemEntry)}
+ onDoubleClick={(event) => {
+ handleGridCellDblClick(event, fSystemEntry);
+ }}
+ onClick={(event) => {
+ event.stopPropagation();
+ AppConfig.isCordovaiOS // TODO DoubleClick not fired in Cordova IOS
+ ? handleGridCellDblClick(event, fSystemEntry)
+ : handleGridCellClick(event, fSystemEntry);
+ }}
+ onDrag={(event) => {
+ handleGridCellClick(event, fSystemEntry);
+ }}
+ >
<Grid
container
wrap="nowrap"
@@ -481,7 +421,6 @@ function CellContent(props: Props) {
<Grid item style={{ display: 'flex', alignItems: 'center' }}>
<img
alt="thumbnail"
- className={classes.gridCellThumb}
src={
fSystemEntry.thumbPath +
(lastThumbnailImageChange &&
@@ -496,98 +435,22 @@ function CellContent(props: Props) {
onError={(i) => (i.target.style.display = 'none')}
loading="lazy"
style={{
+ backgroundRepeat: 'no-repeat',
+ backgroundPosition: 'center',
+ borderRadius: 5,
+ marginBottom: 5,
objectFit: thumbnailMode,
paddingRight: 4,
paddingTop: 4,
- height: tmbSize,
- width: tmbSize,
+ height: entryHeight,
+ width: entryHeight,
}}
/>
</Grid>
)}
</Grid>
- );
- }
-
- const entryPath = fSystemEntry.path;
-
- const renderTags = useMemo(() => {
- let sideCarLength = 0;
- return entryTags.map((tag: TS.Tag, index) => {
- const tagContainer = readOnlyMode ? (
- <TagContainer
- tag={tag}
- key={entryPath + tag.title}
- entryPath={entryPath}
- addTags={handleAddTags}
- handleTagMenu={handleTagMenu}
- />
- ) : (
- <TagContainerDnd
- tag={tag}
- index={tag.type === 'sidecar' ? index : index - sideCarLength}
- key={entryPath + tag.title}
- entryPath={entryPath}
- addTags={handleAddTags}
- addTag={handleAddTag}
- handleTagMenu={handleTagMenu}
- selectedEntries={selectedEntries}
- editTagForEntry={handleEditTag}
- reorderTags={reorderTags}
- />
- );
-
- if (tag.type === 'sidecar') {
- sideCarLength = index + 1;
- }
- return tagContainer;
- });
- }, [entryTags, readOnlyMode, reorderTags, entryPath]);
-
- let entryHeight = 130;
- if (entrySize === 'small') {
- entryHeight = 35;
- } else if (entrySize === 'normal') {
- entryHeight = 70;
- } else if (entrySize === 'big') {
- entryHeight = 100;
- }
-
- return (
- <GridStyles>
- <Paper
- elevation={2}
- data-entry-id={fSystemEntry.uuid}
- className={classNames(
- layoutType === 'grid' && classes.gridCell,
- layoutType === 'row' && classes.rowCell,
- selected && layoutType === 'grid' && classes.selectedGridCell,
- selected && layoutType === 'row' && classes.selectedRowCell,
- )}
- style={{
- minHeight: layoutType === 'row' ? entryHeight : 'auto',
- marginBottom: isLast ? 40 : 'auto',
- backgroundColor: theme.palette.background.default,
- }}
- onContextMenu={(event) => handleGridContextMenu(event, fSystemEntry)}
- onDoubleClick={(event) => {
- handleGridCellDblClick(event, fSystemEntry);
- }}
- onClick={(event) => {
- event.stopPropagation();
- AppConfig.isCordovaiOS // TODO DoubleClick not fired in Cordova IOS
- ? handleGridCellDblClick(event, fSystemEntry)
- : handleGridCellClick(event, fSystemEntry);
- }}
- onDrag={(event) => {
- handleGridCellClick(event, fSystemEntry);
- }}
- >
- {layoutType === 'grid' && renderGridCell()}
- {layoutType === 'row' && renderRowCell()}
- </Paper>
- </GridStyles>
+ </RowPaper>
);
}
-export default CellContent;
+export default RowCell;
diff --git a/src/renderer/perspectives/list/index.tsx b/src/renderer/perspectives/list/index.tsx
index d583525aa..dd08efe9d 100644
--- a/src/renderer/perspectives/list/index.tsx
+++ b/src/renderer/perspectives/list/index.tsx
@@ -29,4 +29,5 @@ export const defaultSettings = {
showEntriesDescription: true,
showTags: true,
gridPageLimit: 100,
+ maxDescriptionPreviewLength: 100,
};
diff --git a/src/renderer/tagspaces.namespace.d.ts b/src/renderer/tagspaces.namespace.d.ts
index 409df7c1f..02bc4ce8e 100644
--- a/src/renderer/tagspaces.namespace.d.ts
+++ b/src/renderer/tagspaces.namespace.d.ts
@@ -233,7 +233,7 @@ export namespace TS {
orderBy?: boolean;
sortBy?: string;
singleClickAction?: string;
- entrySize?: string;
+ entrySize?: EntrySizes;
thumbnailMode?: string;
gridPageLimit?: number;
// isLocal?: boolean;
diff --git a/src/renderer/utils/dom.ts b/src/renderer/utils/dom.ts
index 701abca63..4841b0d61 100644
--- a/src/renderer/utils/dom.ts
+++ b/src/renderer/utils/dom.ts
@@ -85,7 +85,8 @@ export function updateHistory(
if (diffLocation || diffEntryPath || diffFolderPath) {
window.history.pushState(null, null, urlParams);
- // console.log('>>> href updated with: ' + urlParams);
+ // console.log('>>> new href: ' + window.location.href);
+ // console.log('>>> url param: ' + urlParams);
}
}
}