TagSpaces is an offline, open source, document manager with tagging support
TSN417 - Per directory perspective (#1211)
Stanimir244580483a20
diff --git a/app/components/EntryContainer.tsx b/app/components/EntryContainer.tsxindex ef9e4259a..12a4ba55e 100644--- a/app/components/EntryContainer.tsx+++ b/app/components/EntryContainer.tsx@@ -45,7 +45,7 @@ import ConfirmDialog from '-/components/dialogs/ConfirmDialog';import AppConfig from '-/config';import PlatformIO from '-/services/platform-io';import AddRemoveTagsDialog from '-/components/dialogs/AddRemoveTagsDialog';-import { FileSystemEntry } from '-/services/utils-io';+import { FileSystemEntry, FileSystemEntryMeta } from '-/services/utils-io';import i18n from '-/services/i18n';import {extractContainingDirectoryPath,@@ -146,6 +146,7 @@ const styles: any = (theme: any) => ({minWidth: 20,height: 44,justifyContent: 'unset',+ color: 'inherit !important',whiteSpace: 'nowrap'},entryCloseSection: {@@ -175,7 +176,7 @@ interface Props {renameDirectory: () => void;addTags: () => void;removeTags: () => void;- editTagForEntry: () => void;+ // editTagForEntry: () => void;openFile: (filePath: string) => void;getNextFile: (path: string) => string;getPrevFile: (path: string) => string;@@ -192,11 +193,17 @@ interface Props {isReadOnlyMode: boolean;setEntryPropertiesSplitSize: (size: number) => void;entryPropertiesSplitSize?: number;- reflectUpdateSidecarMeta: (path: string, entryMeta: Object) => void;+ updateOpenedFile: (+ entryPath: string,+ fsEntryMeta: FileSystemEntryMeta,+ isFile: boolean+ ) => void;+ // reflectUpdateSidecarMeta: (path: string, entryMeta: Object) => void;updateThumbnailUrl: (path: string, thumbUrl: string) => void;setLastSelectedEntry: (path: string) => void;setSelectedEntries: (selectedEntries: Array<Object>) => void;directoryContent: Array<Object>;+ currentDirectoryPath: string | null;}const EntryContainer = (props: Props) => {@@ -480,9 +487,13 @@ const EntryContainer = (props: Props) => {// }// } elseif (fileViewer) {- // @ts-ignore- const textContent = fileViewer.current.contentWindow.getContent();- saveFile(textContent);+ try {+ // @ts-ignore+ const textContent = fileViewer.current.contentWindow.getContent();+ saveFile(textContent);+ } catch (e) {+ console.debug('function getContent not exist for video file:', e);+ }}};@@ -1080,7 +1091,8 @@ const EntryContainer = (props: Props) => {<div className={classes.flexLeft}>{openedFile.isFile ? (<Button- onClick={togglePanel}+ // onClick={togglePanel}+ disabledtitle={openedFile.url || openedFile.path}aria-label={i18n.t('core:toggleEntryProperties')}className={classes.entryNameButton}@@ -1103,7 +1115,8 @@ const EntryContainer = (props: Props) => {</Button>) : (<Button- onClick={togglePanel}+ disabled+ // onClick={togglePanel}title={openedFile.url || openedFile.path}aria-label={i18n.t('core:toggleEntryProperties')}className={classes.entryNameButton}@@ -1196,21 +1209,23 @@ const EntryContainer = (props: Props) => {// resetState={this.resetState}// setPropertiesEditMode={this.setPropertiesEditMode}entryPath={openedFile.path}+ perspective={openedFile.perspective}// entryURL={currentEntry.url}// openedEntry={openEntry}// shouldReload={reload}renameFile={props.renameFile}renameDirectory={props.renameDirectory}- editTagForEntry={props.editTagForEntry}+ // editTagForEntry={props.editTagForEntry}// shouldCopyFile={shouldCopyFile}// normalizeShouldCopyFile={() => setShouldCopyFile(false)}addTags={props.addTags}removeTags={props.removeTags}removeAllTags={props.removeAllTags}- reflectUpdateSidecarMeta={props.reflectUpdateSidecarMeta}+ updateOpenedFile={props.updateOpenedFile}updateThumbnailUrl={props.updateThumbnailUrl}showNotification={props.showNotification}isReadOnlyMode={props.isReadOnlyMode}+ currentDirectoryPath={props.currentDirectoryPath}/></div></div>@@ -1266,8 +1281,8 @@ function mapActionCreatorsToProps(dispatch) {addTags: TaggingActions.addTags,removeTags: TaggingActions.removeTags,removeAllTags: TaggingActions.removeAllTags,- editTagForEntry: TaggingActions.editTagForEntry,- reflectUpdateSidecarMeta: AppActions.reflectUpdateSidecarMeta,+ // editTagForEntry: TaggingActions.editTagForEntry,+ updateOpenedFile: AppActions.updateOpenedFile,updateThumbnailUrl: AppActions.updateThumbnailUrl,setLastSelectedEntry: AppActions.setLastSelectedEntry,setSelectedEntries: AppActions.setSelectedEntriesdiff --git a/app/components/EntryProperties.tsx b/app/components/EntryProperties.tsxindex 63fcb5830..9e37c4852 100644--- a/app/components/EntryProperties.tsx+++ b/app/components/EntryProperties.tsx@@ -30,12 +30,26 @@ import InputAdornment from '@material-ui/core/InputAdornment';import LocationIcon from '@material-ui/icons/WorkOutline';import CloudLocationIcon from '@material-ui/icons/CloudQueue';import DOMPurify from 'dompurify';+import Select from '@material-ui/core/Select';+import Input from '@material-ui/core/Input';+import MenuItem from '@material-ui/core/MenuItem';+import ListItemIcon from '@material-ui/core/ListItemIcon';+import DefaultPerspectiveIcon from '@material-ui/icons/GridOn';+import LayersClearIcon from '@material-ui/icons/LayersClear';+import ListItemText from '@material-ui/core/ListItemText';+import GalleryPerspectiveIcon from '@material-ui/icons/Camera';+import MapiquePerspectiveIcon from '@material-ui/icons/Map';+import KanBanPerspectiveIcon from '@material-ui/icons/Dashboard';import TagDropContainer from './TagDropContainer';// import EntryTagMenu from './menus/EntryTagMenu';import ColorPickerDialog from './dialogs/ColorPickerDialog';import MoveCopyFilesDialog from './dialogs/MoveCopyFilesDialog';import i18n from '../services/i18n';-import { FileSystemEntry, getAllPropertiesPromise } from '-/services/utils-io';+import {+ FileSystemEntry,+ FileSystemEntryMeta,+ getAllPropertiesPromise+} from '-/services/utils-io';import { formatFileSize } from '-/utils/misc';import {extractContainingDirectoryPath,@@ -52,7 +66,8 @@ import {getThumbnailURLPromise} from '-/services/thumbsgenerator';import { Tag } from '-/reducers/taglibrary';-import { OpenedEntry } from '-/reducers/app';+import { perspectives } from '-/reducers/app';+import { savePerspective } from '-/utils/metaoperations';const ThumbnailChooserDialog =Pro && Pro.UI ? Pro.UI.ThumbnailChooserDialog : false;@@ -156,15 +171,21 @@ interface Props {theme: any;// openedEntry: OpenedEntry;entryPath: string;+ perspective: string;// entryURL: string;// shouldReload: boolean | null;// shouldCopyFile: boolean;- editTagForEntry: () => void;+ // editTagForEntry: () => void;renameFile: (path: string, nextPath: string) => void;renameDirectory: (path: string, nextPath: string) => void;// normalizeShouldCopyFile: () => void;showNotification: (message: string) => void;- reflectUpdateSidecarMeta: (path: string, entryMeta: Object) => void;+ updateOpenedFile: (+ entryPath: string,+ fsEntryMeta: FileSystemEntryMeta,+ isFile: boolean+ ) => void;+ // reflectUpdateSidecarMeta: (path: string, entryMeta: Object) => void;updateThumbnailUrl: (path: string, thumbUrl: string) => void;addTags: (paths: Array<string>, tags: Array<Tag>) => void;removeTags: (paths: Array<string>, tags: Array<Tag>) => void;@@ -172,6 +193,7 @@ interface Props {// resetState: (stateName: string) => void;isReadOnlyMode: boolean;// setPropertiesEditMode: (editMode: boolean) => void;+ currentDirectoryPath: string | null;}const EntryProperties = (props: Props) => {@@ -179,7 +201,7 @@ const EntryProperties = (props: Props) => {const fileDescription = useRef<HTMLInputElement>(null);let newName = '';- const tagMenuAnchorEl = null;+ // const tagMenuAnchorEl = null;// const [name, setName] = useState<string>('');// const [originalName, setOriginalName] = useState<string>('');// const [description, setDescription] = useState<string>('');@@ -190,7 +212,7 @@ const EntryProperties = (props: Props) => {// const [tags, setTags] = useState<Array<Tag>>([]);const [currentEntry, setCurrentEntry] = useState<FileSystemEntry>(undefined);// const [tagMenuAnchorEl, setTagMenuAnchorEl] = useState<boolean | null>(null);- const [tagMenuOpened, setTagMenuOpened] = useState<boolean | null>(false);+ // const [tagMenuOpened, setTagMenuOpened] = useState<boolean | null>(false);// const [selectedTag, setSelectedTag] = useState<Tag>(null); // TODO enable selected Tag menuconst [isEditName, setEditName] = useState<boolean>(false);const [isEditDescription, setEditDescription] = useState<boolean>(false);@@ -350,7 +372,11 @@ const EntryProperties = (props: Props) => {).then(entryMeta => {setEditDescription(false);- props.reflectUpdateSidecarMeta(currentEntry.path, entryMeta);+ props.updateOpenedFile(+ currentEntry.path,+ entryMeta,+ currentEntry.isFile+ );return true;}).catch(error => {@@ -445,8 +471,15 @@ const EntryProperties = (props: Props) => {const handleChangeColor = color => {Pro.MetaOperations.saveColor(currentEntry.path, color).then(entryMeta => {- props.reflectUpdateSidecarMeta(currentEntry.path, entryMeta);- setCurrentEntry({ ...currentEntry, color });+ // if (props.entryPath === props.currentDirectoryPath) {+ props.updateOpenedFile(+ currentEntry.path,+ entryMeta,+ currentEntry.isFile+ );+ /* } else {+ setCurrentEntry({ ...currentEntry, color });+ } */return true;}).catch(error => {@@ -467,7 +500,7 @@ const EntryProperties = (props: Props) => {}); *!/}; */- const handleCloseTagMenu = () => setTagMenuOpened(false); // this.setState({ tagMenuOpened: false });+ // const handleCloseTagMenu = () => setTagMenuOpened(false); // this.setState({ tagMenuOpened: false });const handleFileNameChange = (event: ChangeEvent<HTMLInputElement>) => {const { target } = event;@@ -546,7 +579,7 @@ const EntryProperties = (props: Props) => {}};- const { classes, removeTags, isReadOnlyMode } = props;+ const { classes, isReadOnlyMode } = props;if (!currentEntry || !currentEntry.path || currentEntry.path === '') {return <div />;@@ -581,6 +614,75 @@ const EntryProperties = (props: Props) => {.join(' '): '';+ const changePerspective = (event: any) => {+ // console.log(perspective);+ const perspective = event.target.value;+ savePerspective(currentEntry.path, perspective)+ .then((entryMeta: FileSystemEntryMeta) => {+ // if (props.entryPath === props.currentDirectoryPath) {+ props.updateOpenedFile(+ currentEntry.path,+ entryMeta,+ currentEntry.isFile+ );+ /* } else {+ setCurrentEntry({ ...currentEntry, perspective });+ } */+ return true;+ })+ .catch(error => {+ console.warn('Error saving perspective for folder ' + error);+ props.showNotification(i18n.t('Error saving perspective for folder'));+ });+ };++ let perspectiveDefault;+ if (currentEntry.perspective) {+ perspectiveDefault = currentEntry.perspective;+ } else if (props.perspective) {+ perspectiveDefault = props.perspective;+ } else {+ perspectiveDefault = 'unspecified'; // perspectives.DEFAULT;+ }++ function getMenuItem(perspective) {+ let icon;+ if (perspective === perspectives.DEFAULT) {+ icon = (+ <ListItemIcon>+ <DefaultPerspectiveIcon />+ </ListItemIcon>+ );+ } else if (perspective === perspectives.GALLERY) {+ icon = (+ <ListItemIcon>+ <GalleryPerspectiveIcon />+ </ListItemIcon>+ );+ } else if (perspective === perspectives.MAPIQUE) {+ icon = (+ <ListItemIcon>+ <MapiquePerspectiveIcon />+ </ListItemIcon>+ );+ } else if (perspective === perspectives.KANBAN) {+ icon = (+ <ListItemIcon>+ <KanBanPerspectiveIcon />+ </ListItemIcon>+ );+ }+ return (+ <MenuItem key={perspective} value={perspective}>+ {icon}+ <ListItemText+ primary={perspective.charAt(0).toUpperCase() + perspective.slice(1)}+ />+ </MenuItem>+ );+ }++ // @ts-ignorereturn (<div className={classes.entryProperties}><Grid container spacing={1}>@@ -769,13 +871,18 @@ const EntryProperties = (props: Props) => {<div className={classes.entryItem}><div className={[classes.fluidGrid, classes.ellipsisText].join(' ')}>- <div className="grid-item" style={{ width: '50%' }}>+ <div+ className="grid-item"+ style={{ width: '50%', alignSelf: 'baseline' }}+ ><Typographyvariant="caption"className={classes.header}style={{ display: 'block' }}>- {i18n.t('core:fileLDTM') + ': ' + ldtm}+ {i18n.t('core:fileLDTM')}+ <br />+ <strong>{ldtm}</strong></Typography>{/* <FormControl fullWidth={true} className={classes.formControl}><TextField@@ -798,9 +905,9 @@ const EntryProperties = (props: Props) => {className={classes.header}style={{ display: 'block' }}>- {i18n.t('core:fileSize') +- ': ' +- formatFileSize(currentEntry.size)}+ {i18n.t('core:fileSize')}+ <br />+ <strong>{formatFileSize(currentEntry.size)}</strong></Typography>{/* <FormControlfullWidth={true}@@ -921,6 +1028,42 @@ const EntryProperties = (props: Props) => {</FormControl></div>+ {!currentEntry.isFile && (+ <div className={classes.entryItem}>+ <div className={classes.fluidGrid}>+ <Typography+ variant="caption"+ className={classNames(classes.header)}+ style={{ display: 'block' }}+ >+ {i18n.t('core:choosePerspective')}+ </Typography>+ </div>+ <FormControl fullWidth={true} className={classes.formControl}>+ <Select+ data-tid="changePerspectiveTID"+ defaultValue={perspectiveDefault}+ onChange={changePerspective}+ input={<Input id="changePerspectiveId" />}+ >+ <MenuItem key="unspecified" value="unspecified">+ <ListItemIcon>+ <LayersClearIcon />+ </ListItemIcon>+ <ListItemText primary={i18n.t('core:unspecified')} />+ </MenuItem>+ {Object.values(perspectives).map(perspective =>+ getMenuItem(perspective)+ )}+ {/* {Pro &&+ Object.values(+ Pro.Perspectives.AvailablePerspectives+ ).map(perspective => getMenuItem(perspective))} */}+ </Select>+ </FormControl>+ </div>+ )}+<div className={classes.entryItem}><div className={classes.fluidGrid}><Typographydiff --git a/app/components/FolderContainer.tsx b/app/components/FolderContainer.tsxindex 46b1b6585..6d8f6ad93 100644--- a/app/components/FolderContainer.tsx+++ b/app/components/FolderContainer.tsx@@ -16,7 +16,7 @@**/-import React from 'react';+import React, { useEffect, useState } from 'react';import { connect } from 'react-redux';import { bindActionCreators } from 'redux';import Button from '@material-ui/core/Button';@@ -34,21 +34,24 @@ import {getPerspectives,getMaxSearchResults,getDesktopMode-} from '../reducers/settings';+} from '-/reducers/settings';import {actions as AppActions,getDirectoryContent,- getDirectoryPath,getLastSelectedEntry,getSearchResultCount,isReadOnlyMode,- getCurrentLocationPath+ getCurrentLocationPath,+ getCurrentDirectoryPerspective,+ OpenedEntry} from '../reducers/app';import TaggingActions from '../reducers/tagging-actions';-import { normalizePath, extractShortDirectoryName } from '../utils/paths';+import { normalizePath, extractShortDirectoryName } from '-/utils/paths';import PlatformIO from '../services/platform-io';import LoadingLazy from '../components/LoadingLazy';import { Pro } from '../pro';+import { savePerspective } from '-/utils/metaoperations';+import { FileSystemEntryMeta } from '-/services/utils-io';const GridPerspective = React.lazy(() =>import(@@ -64,6 +67,7 @@ const GridPerspectiveAsync = props => (let GalleryPerspective = React.Fragment;if (Pro && Pro.Perspectives && Pro.Perspectives.GalleryPerspective) {// GalleryPerspective = React.lazy(() => import(/* webpackChunkName: "GalleryPerspective" */ '../node_modules/@tagspaces/pro/modules/perspectives/gallery'));+ // eslint-disable-next-line prefer-destructuringGalleryPerspective = Pro.Perspectives.GalleryPerspective;}const GalleryPerspectiveAsync = props => (@@ -75,6 +79,7 @@ const GalleryPerspectiveAsync = props => (let MapiquePerspective = React.Fragment;if (Pro && Pro.Perspectives && Pro.Perspectives.MapiquePerspective) {// MapiquePerspective = React.lazy(() => import(/* webpackChunkName: "MapiquePerspective" */ '../node_modules/@tagspaces/pro/modules/perspectives/mapique'));+ // eslint-disable-next-line prefer-destructuringMapiquePerspective = Pro.Perspectives.MapiquePerspective;}const MapiquePerspectiveAsync = props => (@@ -86,6 +91,7 @@ const MapiquePerspectiveAsync = props => (let TreeVizPerspective = React.Fragment;if (Pro && Pro.Perspectives && Pro.Perspectives.TreeVizPerspective) {// TreeVizPerspective = React.lazy(() => import(/* webpackChunkName: "TreeVizPerspective" */ '../node_modules/@tagspaces/pro/modules/perspectives/treeviz'));+ // eslint-disable-next-line prefer-destructuringTreeVizPerspective = Pro.Perspectives.TreeVizPerspective;}const TreeVizPerspectiveAsync = props => (@@ -96,6 +102,7 @@ const TreeVizPerspectiveAsync = props => (let KanBanPerspective = React.Fragment;if (Pro && Pro.Perspectives && Pro.Perspectives.KanBanPerspective) {+ // eslint-disable-next-line prefer-destructuringKanBanPerspective = Pro.Perspectives.KanBanPerspective;}const KanBanPerspectiveAsync = props => (@@ -209,58 +216,45 @@ interface Props {showNotification: (content: string) => void;openSearchPanel: () => void;showDrawer: () => void;+ setCurrentDirectoryPerspective: (perspective: string) => void;maxSearchResults: number;+ currentDirectoryPerspective: string;+ currentLocationPath: string;+ openedFiles: Array<OpenedEntry>;+ updateCurrentDirEntry: (path: string, entry: Object) => void;+ setCurrentDirectoryColor: (color: string) => void;}-interface State {- currentPerspective: string;- currentPath?: string;- pathParts?: Array<string>;- // isPropertiesPanelVisible?: boolean;- locationChooserMenuOpened?: boolean;- locationChooserMenuAnchorEl?: null | Object;- directoryMenuOpened?: boolean;- directoryMenuAnchorEl?: null | Object;- perspectiveChooserMenuOpened?: boolean;- perspectiveChooserMenuAnchorEl?: null | Object;- directoryContextMenuOpened: boolean;- directoryContextMenuAnchorEl: null | Object;- perspectiveCommand?: null | Object;-}+const FolderContainer = (props: Props) => {+ // const [isDirectoryMenuOpened, setDirectoryMenuOpened] = useState<boolean>(false);+ /* const [directoryContextMenuOpened, setDirectoryContextMenuOpened] = useState<+ boolean+ >(false); */+ const [+ directoryContextMenuAnchorEl,+ setDirectoryContextMenuAnchorEl+ ] = useState<null | HTMLElement>(null);+ // const [perspectiveChooserMenuOpened,setPerspectiveChooserMenuOpened] = useState<boolean>(false);-class FolderContainer extends React.Component<Props, State> {- state = {- currentPerspective: window.ExtDefaultPerspective || 'default',- currentPath: '',- pathParts: [],- // isPropertiesPanelVisible: false,- isDirectoryMenuOpened: false,- directoryContextMenuOpened: false,- directoryContextMenuAnchorEl: null,- perspectiveChooserMenuOpened: false,- perspectiveChooserMenuAnchorEl: null,- perspectiveCommand: null- };+ let pathParts: Array<string> = [];- static getDerivedStateFromProps(nextProps, prevState) {- if (- nextProps.currentDirectoryPath &&- prevState.currentPath !== nextProps.currentDirectoryPath- ) {- let currentLocationPath = '';- if (nextProps.currentLocationPath) {- currentLocationPath = nextProps.currentLocationPath;- }+ useEffect(() => {+ if (props.currentDirectoryPath) {// Make the path unix like ending always with /const addSlash = PlatformIO.haveObjectStoreSupport() ? '//' : '/';let normalizedCurrentPath =addSlash +- normalizePath(nextProps.currentDirectoryPath.split('\\').join('/'));- const normalizedCurrentLocationPath =- addSlash + normalizePath(currentLocationPath.split('\\').join('/'));+ normalizePath(props.currentDirectoryPath.split('\\').join('/'));++ let normalizedCurrentLocationPath = '';+ if (props.currentLocationPath) {+ normalizedCurrentLocationPath =+ addSlash ++ normalizePath(props.currentLocationPath.split('\\').join('/'));+ }// console.log('Current path : ' + normalizedCurrentPath);// console.log('Current location path : ' + normalizedCurrentLocationPath);- let pathParts = [];+while (normalizedCurrentPath.lastIndexOf('/') > 0 &&normalizedCurrentPath.startsWith(normalizedCurrentLocationPath)@@ -283,272 +277,294 @@ class FolderContainer extends React.Component<Props, State> {if (pathParts.length > 2) {pathParts = pathParts.slice(pathParts.length - 2, pathParts.length); // leave only the last 2 dirs in the path}- return {- ...prevState,- currentPath: nextProps.currentDirectoryPath,- pathParts- };}- return null;- }+ }, [props.currentDirectoryPath]);- openDirectoryMenu = (event: any) => {- this.setState({- directoryContextMenuOpened: true,- directoryContextMenuAnchorEl: event ? event.currentTarget : null- });+ useEffect(() => {+ if (props.openedFiles.length > 0) {+ const openedFile = props.openedFiles[0];+ if (openedFile.path === props.currentDirectoryPath) {+ if (openedFile.color) {+ props.setCurrentDirectoryColor(openedFile.color);+ }+ if (openedFile.perspective) {+ props.setCurrentDirectoryPerspective(openedFile.perspective);+ }+ } else {+ // TODO check if file is loaded+ props.updateCurrentDirEntry(openedFile.path, openedFile);+ }+ }+ }, [props.openedFiles]);++ const openDirectoryMenu = (event: React.MouseEvent<HTMLButtonElement>) => {+ setDirectoryContextMenuAnchorEl(event.currentTarget);+ // setDirectoryContextMenuOpened(true);};- closeDirectoryMenu = () => {- this.setState({- directoryContextMenuOpened: false,- directoryContextMenuAnchorEl: null- });+ const closeDirectoryMenu = () => {+ setDirectoryContextMenuAnchorEl(null);+ // setDirectoryContextMenuOpened(false);};- switchPerspective = (perspectiveId: string) => {- if (!Pro) {- this.props.showNotification(i18n.t('core:needProVersion'));+ const switchPerspective = (perspectiveId: string) => {+ /* if (!Pro) {+ props.showNotification(i18n.t('core:needProVersion'));return;- }- this.setState({- currentPerspective: perspectiveId || 'default'- });+ } */+ savePerspective(props.currentDirectoryPath, perspectiveId || 'default')+ .then((entryMeta: FileSystemEntryMeta) => {+ props.setCurrentDirectoryPerspective(entryMeta.perspective);+ return true;+ })+ .catch(error => {+ console.warn('Error saving perspective for folder ' + error);+ props.showNotification(i18n.t('Error saving perspective for folder'));+ });};- togglePerspectiveChooserClose = (event?: any) => {- this.setState({- perspectiveChooserMenuOpened: !this.state.perspectiveChooserMenuOpened,- perspectiveChooserMenuAnchorEl: event ? event.currentTarget : null- });- };+ /* const togglePerspectiveChooserClose = (event?: any) => {+ perspectiveChooserMenuAnchorEl = event ? event.currentTarget : null;+ setPerspectiveChooserMenuOpened(!perspectiveChooserMenuOpened);+ }; */- renderPerspective() {- if (- !this.props.currentDirectoryPath &&- this.props.directoryContent.length < 1- ) {+ const renderPerspective = () => {+ if (!props.currentDirectoryPath && props.directoryContent.length < 1) {return <WelcomePanelAsync />;}- if (this.state.currentPerspective === 'gallery') {+ if (+ Pro &&+ props.currentDirectoryPerspective ===+ Pro.Perspectives.AvailablePerspectives.GALLERY+ ) {return (<GalleryPerspectiveAsync- directoryContent={this.props.directoryContent}- currentDirectoryPath={this.props.currentDirectoryPath}- windowWidth={this.props.windowWidth}- switchPerspective={this.switchPerspective}+ directoryContent={props.directoryContent}+ currentDirectoryPath={props.currentDirectoryPath}+ windowWidth={props.windowWidth}+ switchPerspective={switchPerspective}/>);}- if (this.state.currentPerspective === 'treeviz') {+ if (+ Pro &&+ props.currentDirectoryPerspective ===+ Pro.Perspectives.AvailablePerspectives.TREEVIZ+ ) {return (<TreeVizPerspectiveAsync- directoryContent={this.props.directoryContent}- currentDirectoryPath={this.props.currentDirectoryPath}- windowWidth={this.props.windowWidth}- switchPerspective={this.switchPerspective}+ directoryContent={props.directoryContent}+ currentDirectoryPath={props.currentDirectoryPath}+ windowWidth={props.windowWidth}+ switchPerspective={switchPerspective}/>);}- if (this.state.currentPerspective === 'mapique') {+ if (+ Pro &&+ props.currentDirectoryPerspective ===+ Pro.Perspectives.AvailablePerspectives.MAPIQUE+ ) {return (<MapiquePerspectiveAsync- directoryContent={this.props.directoryContent}- currentDirectoryPath={this.props.currentDirectoryPath}- windowWidth={this.props.windowWidth}- switchPerspective={this.switchPerspective}+ directoryContent={props.directoryContent}+ currentDirectoryPath={props.currentDirectoryPath}+ windowWidth={props.windowWidth}+ switchPerspective={switchPerspective}/>);}- if (this.state.currentPerspective === 'kanban') {+ if (+ Pro &&+ props.currentDirectoryPerspective ===+ Pro.Perspectives.AvailablePerspectives.KANBAN+ ) {return (<KanBanPerspectiveAsync- directoryContent={this.props.directoryContent}- loadDirectoryContent={this.props.loadDirectoryContent}- openFile={this.props.openFile}- loadParentDirectoryContent={this.props.loadParentDirectoryContent}- deleteFile={this.props.deleteFile}- renameFile={this.props.renameFile}- openDirectory={this.props.openDirectory}- showInFileManager={this.props.showInFileManager}- currentDirectoryPath={this.props.currentDirectoryPath}- setLastSelectedEntry={this.props.setLastSelectedEntry}- perspectiveCommand={this.state.perspectiveCommand}- addTags={this.props.addTags}- editTagForEntry={this.props.editTagForEntry}- deleteDirectory={this.props.deleteDirectory}- removeTags={this.props.removeTags}- removeAllTags={this.props.removeAllTags}- windowWidth={this.props.windowWidth}- switchPerspective={this.switchPerspective}+ directoryContent={props.directoryContent}+ loadDirectoryContent={props.loadDirectoryContent}+ openFile={props.openFile}+ loadParentDirectoryContent={props.loadParentDirectoryContent}+ deleteFile={props.deleteFile}+ renameFile={props.renameFile}+ openDirectory={props.openDirectory}+ showInFileManager={props.showInFileManager}+ currentDirectoryPath={props.currentDirectoryPath}+ setLastSelectedEntry={props.setLastSelectedEntry}+ addTags={props.addTags}+ editTagForEntry={props.editTagForEntry}+ deleteDirectory={props.deleteDirectory}+ removeTags={props.removeTags}+ removeAllTags={props.removeAllTags}+ windowWidth={props.windowWidth}+ switchPerspective={switchPerspective}/>);}// else if (this.state.currentPerspective === 'default') {return (<GridPerspectiveAsync- directoryContent={this.props.directoryContent}- loadDirectoryContent={this.props.loadDirectoryContent}- openFile={this.props.openFile}- loadParentDirectoryContent={this.props.loadParentDirectoryContent}- deleteFile={this.props.deleteFile}- renameFile={this.props.renameFile}- openDirectory={this.props.openDirectory}- showInFileManager={this.props.showInFileManager}- currentDirectoryPath={this.props.currentDirectoryPath}- setLastSelectedEntry={this.props.setLastSelectedEntry}- perspectiveCommand={this.state.perspectiveCommand}- addTags={this.props.addTags}- editTagForEntry={this.props.editTagForEntry}- deleteDirectory={this.props.deleteDirectory}- removeTags={this.props.removeTags}- removeAllTags={this.props.removeAllTags}- windowWidth={this.props.windowWidth}+ directoryContent={props.directoryContent}+ loadDirectoryContent={props.loadDirectoryContent}+ openFile={props.openFile}+ loadParentDirectoryContent={props.loadParentDirectoryContent}+ deleteFile={props.deleteFile}+ renameFile={props.renameFile}+ openDirectory={props.openDirectory}+ showInFileManager={props.showInFileManager}+ currentDirectoryPath={props.currentDirectoryPath}+ setLastSelectedEntry={props.setLastSelectedEntry}+ addTags={props.addTags}+ editTagForEntry={props.editTagForEntry}+ deleteDirectory={props.deleteDirectory}+ removeTags={props.removeTags}+ removeAllTags={props.removeAllTags}+ windowWidth={props.windowWidth}/>);- }+ };- render() {- const {- currentDirectoryPath = '',- loadDirectoryContent,- searchResultCount,- classes,- maxSearchResults,- openSearchPanel,- showDrawer,- isDesktopMode,- theme,- loadParentDirectoryContent- } = this.props;- const normalizedCurrentDirPath = normalizePath(- currentDirectoryPath.split('\\').join('/')- );- let searchResultCounterText = searchResultCount + ' ' + i18n.t('entries');- if (searchResultCount >= maxSearchResults) {- searchResultCounterText =- 'Max. search count reached, showing only the first ' +- searchResultCount +- ' entries.';- }- return (- <div>- <div className={classes.mainPanel}>- <div className={classes.topPanel}>- <div className={classes.toolbar}>- {isDesktopMode ? (- <LocationMenu />- ) : (- <Button- id="mobileMenuButton"- style={{ marginLeft: -8 }}- onClick={showDrawer}- >- <MenuIcon />- </Button>+ const {+ currentDirectoryPath = '',+ loadDirectoryContent,+ searchResultCount,+ classes,+ maxSearchResults,+ openSearchPanel,+ showDrawer,+ isDesktopMode,+ theme,+ loadParentDirectoryContent+ } = props;+ const normalizedCurrentDirPath = normalizePath(+ currentDirectoryPath.split('\\').join('/')+ );+ let searchResultCounterText = searchResultCount + ' ' + i18n.t('entries');+ if (searchResultCount >= maxSearchResults) {+ searchResultCounterText =+ 'Max. search count reached, showing only the first ' ++ searchResultCount ++ ' entries.';+ }+ return (+ <div>+ <div className={classes.mainPanel}>+ <div className={classes.topPanel}>+ <div className={classes.toolbar}>+ {isDesktopMode ? (+ <LocationMenu />+ ) : (+ <Button+ id="mobileMenuButton"+ style={{ marginLeft: -8 }}+ onClick={showDrawer}+ >+ <MenuIcon />+ </Button>+ )}+ <CounterBadge+ showZero={true}+ title={searchResultCounterText}+ badgeContent={searchResultCount}+ color="secondary"+ max={maxSearchResults - 1}+ onClick={() => {+ openSearchPanel();+ }}+ />+ <div className={classes.flexMiddle} />+ <React.Fragment>+ {isDesktopMode &&+ pathParts.length > 0 &&+ pathParts.map(pathPart => (+ <Button+ key={pathPart}+ onClick={() => loadDirectoryContent(pathPart)}+ title={'Navigate to: ' + pathPart}+ style={{+ paddingLeft: 3,+ paddingRight: 0,+ minWidth: 10,+ lineHeight: '17px',+ overflow: 'hidden',+ backgroundColor: theme.palette.background.default+ }}+ >+ {extractShortDirectoryName(pathPart, '/')}+ <FolderSeparatorIcon />+ </Button>+ ))}+ {!isDesktopMode && pathParts.length > 0 && (+ <React.Fragment>+ <IconButton+ onClick={loadParentDirectoryContent}+ data-tid="openParentDirectory"+ size="small"+ style={{+ overflow: 'hidden',+ backgroundColor: theme.palette.background.default+ }}+ title={i18n.t('core:navigateToParentDirectory')}+ >+ <BackButtonIcon />+ </IconButton>+ </React.Fragment>)}- <CounterBadge- showZero={true}- title={searchResultCounterText}- badgeContent={searchResultCount}- color="secondary"- max={maxSearchResults - 1}- onClick={() => {- openSearchPanel();- }}- />- <div className={classes.flexMiddle} />- <React.Fragment>- {isDesktopMode &&- this.state.pathParts &&- this.state.pathParts.map(pathPart => (- <Button- key={pathPart}- onClick={() => loadDirectoryContent(pathPart)}- title={'Navigate to: ' + pathPart}- style={{- paddingLeft: 3,- paddingRight: 0,- minWidth: 10,- lineHeight: '17px',- overflow: 'hidden',- backgroundColor: theme.palette.background.default- }}- >- {extractShortDirectoryName(pathPart, '/')}- <FolderSeparatorIcon />- </Button>- ))}- {!isDesktopMode &&- this.state.pathParts &&- this.state.pathParts.length > 0 && (- <React.Fragment>- <IconButton- onClick={loadParentDirectoryContent}- data-tid="openParentDirectory"- size="small"- style={{- overflow: 'hidden',- backgroundColor: theme.palette.background.default- }}- title={i18n.t('core:navigateToParentDirectory')}- >- <BackButtonIcon />- </IconButton>- </React.Fragment>- )}- <Button- data-tid="folderContainerOpenDirMenu"- title={- i18n.t('core:openDirectoryMenu') +- ' - ' +- (currentDirectoryPath || '')- }- className={classes.folderButton}- onClick={this.openDirectoryMenu}- onContextMenu={this.openDirectoryMenu}- >- {extractShortDirectoryName(- normalizePath(normalizedCurrentDirPath),- '/'- )}- <MoreVertIcon />- </Button>- <DirectoryMenu- open={this.state.directoryContextMenuOpened}- onClose={this.closeDirectoryMenu}- anchorEl={this.state.directoryContextMenuAnchorEl}- directoryPath={currentDirectoryPath}- loadDirectoryContent={this.props.loadDirectoryContent}- openDirectory={this.props.openDirectory}- reflectCreateEntry={this.props.reflectCreateEntry}- openFile={this.props.openFile}- toggleCreateFileDialog={this.props.toggleCreateFileDialog}- deleteDirectory={this.props.deleteDirectory}- switchPerspective={this.switchPerspective}- isReadOnlyMode={this.props.isReadOnlyMode}- />- </React.Fragment>- </div>- </div>- <div- className={classes.centerPanel}- style={{ height: this.props.windowHeight }}- >- {this.renderPerspective()}+ {props.currentDirectoryPath && (+ <React.Fragment>+ <Button+ data-tid="folderContainerOpenDirMenu"+ title={+ i18n.t('core:openDirectoryMenu') ++ ' - ' ++ (currentDirectoryPath || '')+ }+ className={classes.folderButton}+ onClick={openDirectoryMenu}+ onContextMenu={openDirectoryMenu}+ >+ {extractShortDirectoryName(+ normalizePath(normalizedCurrentDirPath),+ '/'+ )}+ <MoreVertIcon />+ </Button>+ <DirectoryMenu+ open={Boolean(directoryContextMenuAnchorEl)}+ onClose={closeDirectoryMenu}+ anchorEl={directoryContextMenuAnchorEl}+ directoryPath={currentDirectoryPath}+ loadDirectoryContent={props.loadDirectoryContent}+ openDirectory={props.openDirectory}+ reflectCreateEntry={props.reflectCreateEntry}+ openFile={props.openFile}+ toggleCreateFileDialog={props.toggleCreateFileDialog}+ deleteDirectory={props.deleteDirectory}+ switchPerspective={switchPerspective}+ isReadOnlyMode={props.isReadOnlyMode}+ />+ </React.Fragment>+ )}+ </React.Fragment></div></div>+ <div+ className={classes.centerPanel}+ style={{ height: props.windowHeight }}+ >+ {renderPerspective()}+ </div></div>- );- }-}+ </div>+ );+};function mapStateToProps(state) {return {- currentDirectoryPath: getDirectoryPath(state),lastSelectedEntry: getLastSelectedEntry(state),perspectives: getPerspectives(state),directoryContent: getDirectoryContent(state),+ currentDirectoryPerspective: getCurrentDirectoryPerspective(state),searchResultCount: getSearchResultCount(state),currentLocationPath: getCurrentLocationPath(state),maxSearchResults: getMaxSearchResults(state),@@ -579,7 +595,10 @@ function mapActionCreatorsToProps(dispatch) {loadParentDirectoryContent: AppActions.loadParentDirectoryContent,setLastSelectedEntry: AppActions.setLastSelectedEntry,showNotification: AppActions.showNotification,- openSearchPanel: AppActions.openSearchPanel+ openSearchPanel: AppActions.openSearchPanel,+ setCurrentDirectoryPerspective: AppActions.setCurrentDirectoryPerspective,+ updateCurrentDirEntry: AppActions.updateCurrentDirEntry,+ setCurrentDirectoryColor: AppActions.setCurrentDirectoryColor},dispatch);diff --git a/app/components/dialogs/OnboardingDialog.tsx b/app/components/dialogs/OnboardingDialog.tsxindex fff26b197..1ab3d7d84 100644--- a/app/components/dialogs/OnboardingDialog.tsx+++ b/app/components/dialogs/OnboardingDialog.tsx@@ -95,7 +95,13 @@ const OnboardingDialog = (props: Props) => {<DialogTitle style={{ justifyContent: 'center', textAlign: 'center' }}>Welcome to TagSpaces</DialogTitle>- <DialogContent style={{ marginTop: 20 }}>+ <DialogContent+ style={{+ marginTop: 20,+ // @ts-ignore+ overflowY: AppConfig.isFirefox ? 'auto' : 'overlay'+ }}+ ><SwipeableViewsindex={activeStep}onChangeIndex={handleStepChange}@@ -132,7 +138,7 @@ const OnboardingDialog = (props: Props) => {textAlign: 'center'}}>- <Typography variant="h5">Understand main app navigation</Typography>+ <Typography variant="h5">Navigation in the app</Typography><imgstyle={{ marginTop: 15, maxHeight: 500 }}src={NavigationV3}diff --git a/app/components/dialogs/settings/SettingsGeneral.tsx b/app/components/dialogs/settings/SettingsGeneral.tsxindex 945b87acd..4650bb8a3 100644--- a/app/components/dialogs/settings/SettingsGeneral.tsx+++ b/app/components/dialogs/settings/SettingsGeneral.tsx@@ -34,7 +34,9 @@ import ColorPickerDialog from '../ColorPickerDialog';import TransparentBackground from '../../TransparentBackground';const styles = theme => ({- root: {},+ root: {+ overflowX: 'hidden'+ },listItem: {paddingLeft: 0,paddingRight: 0@@ -252,7 +254,7 @@ class SettingsGeneral extends React.Component<Props, State> {/></ListItem><ListItem className={classes.listItem}>- <ListItemText primary="Mobile Mode (experimental)" />+ <ListItemText primary="Enable mobile (small screen) mode" /><Switchdata-tid="settingsSetDesktopMode"disabled={!(typeof window.ExtDisplayMode === 'undefined')}diff --git a/app/components/menus/DirectoryMenu.tsx b/app/components/menus/DirectoryMenu.tsxindex fbb8bc361..20a9526d3 100644--- a/app/components/menus/DirectoryMenu.tsx+++ b/app/components/menus/DirectoryMenu.tsx@@ -55,7 +55,7 @@ import {} from '-/utils/paths';import PlatformIO from '-/services/platform-io';import { formatDateTime4Tag } from '-/utils/misc';-import { actions as AppActions } from '-/reducers/app';+import { actions as AppActions, perspectives } from '-/reducers/app';import IOActions from '-/reducers/io-actions';import { Tag } from '-/reducers/taglibrary';import TaggingActions from '-/reducers/tagging-actions';@@ -135,7 +135,15 @@ const DirectoryMenu = (props: Props) => {function switchPerspective(perspectiveId) {props.onClose();- props.switchPerspective(perspectiveId);+ if (Pro) {+ props.switchPerspective(perspectiveId);+ } else {+ props.showNotification(+ 'Perspectives are part of TagSpaces PRO',+ 'default',+ true+ );+ }}function showDeleteDirectoryDialog() {@@ -496,7 +504,7 @@ const DirectoryMenu = (props: Props) => {<div><MenuItemdata-tid="openDefaultPerspective"- onClick={() => switchPerspective('default')}+ onClick={() => switchPerspective(perspectives.DEFAULT)}title="Switch to default perspective"><ListItemIcon>@@ -506,7 +514,7 @@ const DirectoryMenu = (props: Props) => {</MenuItem><MenuItemdata-tid="openGalleryPerspective"- onClick={() => switchPerspective('gallery')}+ onClick={() => switchPerspective(perspectives.GALLERY)}title="Switch to gallery perspective"><ListItemIcon>@@ -516,7 +524,7 @@ const DirectoryMenu = (props: Props) => {</MenuItem><MenuItemdata-tid="openMapiquePerspective"- onClick={() => switchPerspective('mapique')}+ onClick={() => switchPerspective(perspectives.MAPIQUE)}title="Switch to mapique perspective"><ListItemIcon>@@ -530,16 +538,16 @@ const DirectoryMenu = (props: Props) => {</ListItemIcon><ListItemText primary="TreeViz Perspective" /></MenuItem> */}- <MenuItem+ {/* <MenuItemdata-tid="openTreeVizPerspective"- onClick={() => switchPerspective('kanban')}- title="Switch to kanban visualization perspective"+ onClick={() => switchPerspective(perspectives.KANBAN)}+ title="Switch to kanban perspective"><ListItemIcon><KanBanPerspectiveIcon /></ListItemIcon>- <ListItemText primary="KanBan Perspective" />- </MenuItem>+ <ListItemText primary="KanBan Perspective - Alpha" />+ </MenuItem> */}<Divider /></div>)}diff --git a/app/containers/MainPage.tsx b/app/containers/MainPage.tsxindex e1cd771c2..647a959a0 100644--- a/app/containers/MainPage.tsx+++ b/app/containers/MainPage.tsx@@ -881,8 +881,13 @@ class MainPage extends Component<Props, State> {<FolderContainerwindowHeight={this.state.height}windowWidth={this.state.width}+ openedFiles={this.props.openedFiles}+ currentDirectoryPath={this.props.directoryPath}+ />+ <EntryContainer+ openedFiles={this.props.openedFiles}+ currentDirectoryPath={this.props.directoryPath}/>- <EntryContainer openedFiles={this.props.openedFiles} /></SplitPane></SplitPane></TargetFileBox>@@ -920,8 +925,13 @@ class MainPage extends Component<Props, State> {windowHeight={this.state.height}windowWidth={this.state.width}showDrawer={this.showDrawer}+ openedFiles={this.props.openedFiles}+ currentDirectoryPath={this.props.directoryPath}+ />+ <EntryContainer+ openedFiles={this.props.openedFiles}+ currentDirectoryPath={this.props.directoryPath}/>- <EntryContainer openedFiles={this.props.openedFiles} /></SplitPane></React.Fragment>)}diff --git a/app/locales/en/core.json b/app/locales/en/core.jsonindex ca3f7a06c..b35cf35a5 100644--- a/app/locales/en/core.json+++ b/app/locales/en/core.json@@ -93,7 +93,7 @@"showMainMenu": "Show main menu (restart needed)","useDefaultLocation": "Use default location as a startup location","enablingUsingMetaFolder": "Enable the use of a hidden folder(.ts) for storing meta data and thumbnails",- "persistTagsInSidecarFile": "Use sidecar files for file tagging",+ "persistTagsInSidecarFile": "Do not rename files on tagging (use sidecar files)","addTagsToLibrary": "Collect new tags in the tag library","useTrashCan": "Move deleted files or folders to trash bin","invalidImportFile": "The imported file has invalid format",@@ -475,5 +475,9 @@"unlimited": "Unlimited","pageLimit": "Page Limit","pageLimitHelp": "Set number of files per page",+ "unspecified": "Unspecified",+ "choosePerspective": "Choose Perspective",+ "folderLimit": "Max. folders to be displayed",+ "filesLimit": "Max. files to be displayed in a folder","-": "-"}diff --git a/app/perspectives/grid-perspective/components/MainContainer.tsx b/app/perspectives/grid-perspective/components/MainContainer.tsxindex 9b270486d..90ccbf0d4 100644--- a/app/perspectives/grid-perspective/components/MainContainer.tsx+++ b/app/perspectives/grid-perspective/components/MainContainer.tsx@@ -91,7 +91,6 @@ interface Props {addTags: () => void;removeTags: () => void;removeAllTags: () => void;- perspectiveCommand: any;directoryContent: Array<FileSystemEntry>;moveFiles: (files: Array<string>, destination: string) => void;keyBindings: any;diff --git a/app/reducers/app.ts b/app/reducers/app.tsindex 8c00bc859..f5885dba1 100644--- a/app/reducers/app.ts+++ b/app/reducers/app.ts@@ -25,8 +25,9 @@ import {deleteFilesPromise,loadMetaDataPromise,renameFilesPromise,- enhanceDirectoryContent-} from '../services/utils-io';+ enhanceDirectoryContent,+ FileSystemEntryMeta+} from '-/services/utils-io';import {extractFileExtension,extractDirectoryName,@@ -36,8 +37,8 @@ import {extractParentDirectoryPath,extractTagsAsObjects,normalizePath-} from '../utils/paths';-import { formatDateTime4Tag, getURLParameter } from '../utils/misc';+} from '-/utils/paths';+import { formatDateTime4Tag, getURLParameter } from '-/utils/misc';import i18n from '../services/i18n';import { Pro } from '../pro';// import { getThumbnailURLPromise } from '../services/thumbsgenerator';@@ -69,6 +70,7 @@ export const types = {SET_NEW_VERSION_AVAILABLE: 'APP/SET_NEW_VERSION_AVAILABLE',SET_CURRENLOCATIONID: 'APP/SET_CURRENLOCATIONID',SET_CURRENDIRECTORYCOLOR: 'APP/SET_CURRENDIRECTORYCOLOR',+ SET_CURRENDIRECTORYPERSPECTIVE: 'APP/SET_CURRENDIRECTORYPERSPECTIVE',SET_LAST_SELECTED_ENTRY: 'APP/SET_LAST_SELECTED_ENTRY',SET_SELECTED_ENTRIES: 'APP/SET_SELECTED_ENTRIES',SET_FILEDRAGGED: 'APP/SET_FILEDRAGGED',@@ -95,8 +97,16 @@ export const types = {REFLECT_DELETE_ENTRY: 'APP/REFLECT_DELETE_ENTRY',REFLECT_RENAME_ENTRY: 'APP/REFLECT_RENAME_ENTRY',REFLECT_CREATE_ENTRY: 'APP/REFLECT_CREATE_ENTRY',- REFLECT_UPDATE_SIDECARTAGS: 'APP/REFLECT_UPDATE_SIDECARTAGS',- REFLECT_UPDATE_SIDECARMETA: 'APP/REFLECT_UPDATE_SIDECARMETA'+ // REFLECT_UPDATE_SIDECARTAGS: 'APP/REFLECT_UPDATE_SIDECARTAGS',+ REFLECT_UPDATE_SIDECARMETA: 'APP/REFLECT_UPDATE_SIDECARMETA',+ UPDATE_CURRENTDIR_ENTRY: 'APP/UPDATE_CURRENTDIR_ENTRY'+};+export const perspectives = {+ DEFAULT: 'default',+ GALLERY: 'gallery',+ // TREEVIZ: 'treeviz',+ MAPIQUE: 'mapique',+ KANBAN: 'kanban'};export const NotificationTypes = {@@ -113,6 +123,8 @@ export type OpenedEntry = {editingExtensionId?: string;isFile?: boolean;color?: string;+ description?: string;+ perspective?: string;editMode?: boolean;changed?: boolean;shouldReload?: boolean;@@ -221,6 +233,12 @@ export default (state: any = initialState, action: any) => {return {...state,currentDirectoryEntries: action.directoryContent,+ currentDirectoryColor: action.directoryMeta+ ? action.directoryMeta.color || ''+ : '',+ currentDirectoryPerspective: action.directoryMeta+ ? action.directoryMeta.perspective+ : undefined,currentDirectoryPath: action.directoryPath,isLoading: action.showIsLoading || false};@@ -249,7 +267,16 @@ export default (state: any = initialState, action: any) => {return { ...state, selectedEntries: action.selectedEntries };}case types.SET_CURRENDIRECTORYCOLOR: {- return { ...state, currentDirectoryColor: action.color };+ if (state.currentDirectoryColor !== action.color) {+ return { ...state, currentDirectoryColor: action.color };+ }+ return state;+ }+ case types.SET_CURRENDIRECTORYPERSPECTIVE: {+ if (state.currentDirectoryPerspective !== action.perspective) {+ return { ...state, currentDirectoryPerspective: action.perspective };+ }+ return state;}case types.TOGGLE_EDIT_TAG_DIALOG: {return {@@ -481,7 +508,7 @@ export default (state: any = initialState, action: any) => {})};}- case types.REFLECT_UPDATE_SIDECARTAGS: {+ /* case types.REFLECT_UPDATE_SIDECARTAGS: {return {...state,currentDirectoryEntries: state.currentDirectoryEntries.map(entry => {@@ -506,6 +533,30 @@ export default (state: any = initialState, action: any) => {};})};+ } */+ case types.UPDATE_CURRENTDIR_ENTRY: {+ return {+ ...state,+ currentDirectoryEntries: state.currentDirectoryEntries.map(entry => {+ if (entry.path !== action.path) {+ return entry;+ }+ if (action.entry.tags && action.entry.tags.length > 0) {+ return {+ ...entry,+ ...action.entry,+ tags: [+ ...entry.tags.filter(tag => tag.type === 'plain'),+ ...action.entry.tags+ ]+ };+ }+ return {+ ...entry,+ ...action.entry+ };+ })+ };}case types.REFLECT_UPDATE_SIDECARMETA: {return {@@ -739,54 +790,73 @@ export const actions = {const { settings } = getState();window.walkCanceled = false;+ function loadDirectoryContentInt(fsEntryMeta?: FileSystemEntryMeta) {+ // Uncomment the following line will to clear all content before loading new dir content+ dispatch(actions.loadDirectorySuccessInt(directoryPath, [], true)); // this is to reset directoryContent (it will reset color too)+ // dispatch(actions.setCurrentDirectoryColor('')); // this is to reset color only+ dispatch(actions.showNotification(i18n.t('core:loading'), 'info', false));+ PlatformIO.listDirectoryPromise(directoryPath, false)+ .then(results => {+ prepareDirectoryContent(+ results,+ directoryPath,+ settings,+ dispatch,+ getState,+ fsEntryMeta+ );+ return true;+ })+ .catch(error => {+ console.timeEnd('listDirectoryPromise');+ dispatch(actions.loadDirectoryFailure(error)); // Currently this is never called, due the promise always resolve+ });+ }+loadMetaDataPromise(normalizePath(directoryPath) + PlatformIO.getDirSeparator()).then(fsEntryMeta => {- if (fsEntryMeta.color) {+ loadDirectoryContentInt(fsEntryMeta);+ /* if (fsEntryMeta.color) { // TODO rethink this states changes are expensivedispatch(actions.setCurrentDirectoryColor(fsEntryMeta.color));}- return true;- })- .catch(err => {- console.log('Error loading color of the current folder' + err);- });+ if (fsEntryMeta.perspective) {+ dispatch(actions.setCurrentDirPerspective(fsEntryMeta.perspective));+ } */- // Uncomment the following line will to clear all content before loading new dir content- dispatch(actions.loadDirectorySuccessInt(directoryPath, [], true));- dispatch(actions.setCurrentDirectoryColor(''));- dispatch(actions.showNotification(i18n.t('core:loading'), 'info', false));- PlatformIO.listDirectoryPromise(directoryPath, false)- .then(results => {- prepareDirectoryContent(- results,- directoryPath,- settings,- dispatch,- getState- );return true;})- .catch(error => {- console.timeEnd('listDirectoryPromise');- dispatch(actions.loadDirectoryFailure(error)); // Currently this is never called, due the promise always resolve+ .catch(err => {+ console.log('Error loading meta of the current folder' + err);+ loadDirectoryContentInt();});},loadDirectorySuccess: (directoryPath: string,- directoryContent: Array<Object>+ directoryContent: Array<Object>,+ directoryMeta?: FileSystemEntryMeta) => (dispatch: (actions: Object) => void) => {dispatch(actions.hideNotifications());- dispatch(actions.loadDirectorySuccessInt(directoryPath, directoryContent));+ dispatch(+ actions.loadDirectorySuccessInt(+ directoryPath,+ directoryContent,+ false,+ directoryMeta+ )+ );},loadDirectorySuccessInt: (directoryPath: string,directoryContent: Array<Object>,- showIsLoading?: boolean+ showIsLoading?: boolean,+ directoryMeta?: FileSystemEntryMeta) => ({type: types.LOAD_DIRECTORY_SUCCESS,directoryPath: directoryPath || PlatformIO.getDirSeparator(),directoryContent,+ directoryMeta,showIsLoading}),loadDirectoryFailure: (directoryPath: string, error?: any) => (@@ -824,6 +894,10 @@ export const actions = {type: types.SET_CURRENDIRECTORYCOLOR,color}),+ setCurrentDirectoryPerspective: (perspective: string) => ({+ type: types.SET_CURRENDIRECTORYPERSPECTIVE,+ perspective+ }),setSelectedEntries: (selectedEntries: Array<Object>) => ({type: types.SET_SELECTED_ENTRIES,selectedEntries@@ -1183,6 +1257,28 @@ export const actions = {type: types.SET_READONLYMODE,isReadOnlyMode}),+ updateOpenedFile: (+ entryPath: string,+ fsEntryMeta: FileSystemEntryMeta,+ isFile: boolean = true+ ) => (dispatch: (actions: Object) => void, getState: () => any) => {+ const { supportedFileTypes } = getState().settings;+ const entryForOpening: OpenedEntry = findExtensionsForEntry(+ supportedFileTypes,+ entryPath,+ isFile+ );+ if (fsEntryMeta.color) {+ entryForOpening.color = fsEntryMeta.color;+ }+ if (fsEntryMeta.description) {+ entryForOpening.description = fsEntryMeta.description;+ }+ if (fsEntryMeta.perspective) {+ entryForOpening.perspective = fsEntryMeta.perspective;+ }+ dispatch(actions.addToEntryContainer(entryForOpening));+ },openFile: (entryPath: string,isFile: boolean = true,@@ -1198,8 +1294,13 @@ export const actions = {const currentEntry = currentDirectoryEntries.find(entry => entry.path === entryPath);- if (currentEntry && currentEntry.url) {- entryForOpening.url = currentEntry.url;+ if (currentEntry) {+ if (currentEntry.url) {+ entryForOpening.url = currentEntry.url;+ }+ if (currentEntry.perspective) {+ entryForOpening.perspective = currentEntry.perspective;+ }}if (editMode &&@@ -1331,11 +1432,27 @@ export const actions = {dispatch(actions.reflectRenameEntryInt(path, newPath));dispatch(LocationIndexActions.reflectRenameEntry(path, newPath));},- reflectUpdateSidecarTagsInt: (path: string, tags: Array<Tag>) => ({- type: types.REFLECT_UPDATE_SIDECARTAGS,+ updateCurrentDirEntry: (path: string, entry: Object) => ({+ type: types.UPDATE_CURRENTDIR_ENTRY,path,- tags+ entry}),+ /**+ * @deprecated use updateCurrentDirEntry instead+ * @param path+ * @param entryMeta+ */+ reflectUpdateSidecarMeta: (path: string, entryMeta: Object) => (+ dispatch: (actions: Object) => void+ ) => {+ dispatch(actions.reflectUpdateSidecarMetaInt(path, entryMeta));+ dispatch(LocationIndexActions.reflectUpdateSidecarMeta(path, entryMeta));+ },+ /**+ * @deprecated use updateCurrentDirEntry instead+ * @param path+ * @param entryMeta+ */reflectUpdateSidecarMetaInt: (path: string, entryMeta: Object) => ({type: types.REFLECT_UPDATE_SIDECARMETA,path,@@ -1346,17 +1463,17 @@ export const actions = {tags: Array<Tag>,updateIndex: boolean = true) => (dispatch: (actions: Object) => void) => {- dispatch(actions.reflectUpdateSidecarTagsInt(path, tags));+ dispatch(actions.updateCurrentDirEntry(path, { tags }));+ // dispatch(actions.reflectUpdateSidecarTagsInt(path, tags));if (updateIndex) {dispatch(LocationIndexActions.reflectUpdateSidecarTags(path, tags));}},- reflectUpdateSidecarMeta: (path: string, entryMeta: Object) => (- dispatch: (actions: Object) => void- ) => {- dispatch(actions.reflectUpdateSidecarMetaInt(path, entryMeta));- dispatch(LocationIndexActions.reflectUpdateSidecarMeta(path, entryMeta));- },+ /* reflectUpdateSidecarTagsInt: (path: string, tags: Array<Tag>) => ({+ type: types.REFLECT_UPDATE_SIDECARTAGS,+ path,+ tags+ }), */deleteFile: (filePath: string) => (dispatch: (actions: Object) => void,getState: () => any@@ -1493,7 +1610,8 @@ function prepareDirectoryContent(directoryPath,settings,dispatch,- getState+ getState,+ dirEntryMeta) {const currentLocation: Location = getLocation(getState(),@@ -1557,7 +1675,9 @@ function prepareDirectoryContent(}console.log('Dir ' + directoryPath + ' contains ' + directoryContent.length);- dispatch(actions.loadDirectorySuccess(directoryPath, directoryContent));+ dispatch(+ actions.loadDirectorySuccess(directoryPath, directoryContent, dirEntryMeta)+ );}function findExtensionPathForId(extensionId: string): string {@@ -1587,9 +1707,9 @@ function findExtensionsForEntry(supportedFileTypes.map(fileType => {if (fileType.viewer && fileType.type.toLowerCase() === fileExtension) {fileForOpening.viewingExtensionId = fileType.viewer;- if (fileType.color) {+ /* if (fileType.color) {fileForOpening.color = fileType.color;- }+ } */fileForOpening.viewingExtensionPath = findExtensionPathForId(fileType.viewer);@@ -1692,6 +1812,10 @@ export function findAvailableExtensions() {// Selectorsexport const getDirectoryContent = (state: any) =>state.app.currentDirectoryEntries;+export const getCurrentDirectoryColor = (state: any) =>+ state.app.currentDirectoryColor;+export const getCurrentDirectoryPerspective = (state: any) =>+ state.app.currentDirectoryPerspective;export const getDirectoryPath = (state: any) => state.app.currentDirectoryPath;export const getProgress = (state: any) => state.app.progress;export const getCurrentLocationPath = (state: any) => {@@ -1749,8 +1873,6 @@ export const isProgressOpened = (state: any) => state.app.progressDialogOpened;export const getOpenedFiles = (state: any) => state.app.openedFiles;export const getNotificationStatus = (state: any) =>state.app.notificationStatus;-export const getCurrentDirectoryColor = (state: any) =>- state.app.currentDirectoryColor;export const getSearchResults = (state: any) =>state.app.currentDirectoryEntries;export const getSearchResultCount = (state: any) =>diff --git a/app/services/utils-io.ts b/app/services/utils-io.tsindex 63b933fb7..4f289b363 100644--- a/app/services/utils-io.ts+++ b/app/services/utils-io.ts@@ -41,6 +41,7 @@ export interface FileSystemEntry {extension: string;thumbPath?: string;color?: string;+ perspective?: string;textContent?: string;description?: string;tags?: Array<Tag>;@@ -55,6 +56,7 @@ export interface FileSystemEntryMeta {description: string;tags: Array<Tag>;color?: string;+ perspective?: string;appVersionCreated: string;appName: string;appVersionUpdated: string;@@ -129,12 +131,14 @@ export function enhanceEntry(entry: any): FileSystemEntry {PlatformIO.getDirSeparator());}- let sidecarDescription = '';- let sidecarColor = '';+ let sidecarDescription;+ let sidecarColor;+ let sidecarPerspective;let sidecarTags = [];if (entry.meta) {- sidecarDescription = entry.meta.description || '';- sidecarColor = entry.meta.color || '';+ sidecarDescription = entry.meta.description;+ sidecarColor = entry.meta.color;+ sidecarPerspective = entry.meta.perspective;sidecarTags = entry.meta.tags || [];sidecarTags.map(tag => {tag.type = 'sidecar';@@ -171,6 +175,9 @@ export function enhanceEntry(entry: any): FileSystemEntry {if (sidecarColor) {enhancedEntry.color = sidecarColor;}+ if (sidecarPerspective) {+ enhancedEntry.perspective = sidecarPerspective;+ }// console.log('Enhancing ' + entry.path); console.log(enhancedEntry);return enhancedEntry;}@@ -536,6 +543,7 @@ export async function loadMetaDataPromise(id: metaData.id || uuidv1(),description: metaData.description || '',color: metaData.color || '',+ perspective: metaData.perspective || '',tags: metaData.tags || [],appVersionCreated: metaData.appVersionCreated || '',appName: metaData.appName || '',diff --git a/app/utils/metaoperations.ts b/app/utils/metaoperations.tsnew file mode 100644index 000000000..2da6b1892--- /dev/null+++ b/app/utils/metaoperations.ts@@ -0,0 +1,61 @@+import {+ FileSystemEntryMeta,+ loadMetaDataPromise,+ saveMetaDataPromise+} from '-/services/utils-io';++// eslint-disable-next-line import/prefer-default-export+export function savePerspective(+ path: string,+ perspective: string+): Promise<FileSystemEntryMeta> {+ return new Promise((resolve, reject) => {+ loadMetaDataPromise(path)+ .then((fsEntryMeta: FileSystemEntryMeta) => {+ let updatedFsEntryMeta: FileSystemEntryMeta;+ if (perspective && perspective !== 'unspecified') {+ updatedFsEntryMeta = {+ ...fsEntryMeta,+ perspective+ };+ } else {+ const { perspective: remove, ...rest } = fsEntryMeta;+ updatedFsEntryMeta = rest;+ }+ saveMetaDataPromise(path, updatedFsEntryMeta)+ .then(() => {+ resolve(updatedFsEntryMeta);+ return true;+ })+ .catch(err => {+ console.warn(+ 'Error adding perspective for ' + path + ' with ' + err+ );+ reject();+ });+ return true;+ })+ .catch(() => {+ const newFsEntryMeta: FileSystemEntryMeta = {+ appName: '',+ appVersionCreated: '',+ appVersionUpdated: '',+ description: '',+ lastUpdated: '',+ tags: undefined,+ perspective+ };+ saveMetaDataPromise(path, newFsEntryMeta)+ .then(() => {+ resolve(newFsEntryMeta);+ return true;+ })+ .catch(error => {+ console.warn(+ 'Error adding perspective for ' + path + ' with ' + error+ );+ reject();+ });+ });+ });+}