Skip to content

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

add history for files, folders and edited files, extending the settings (#1711)

Stanimir7745448f9963
diff --git a/app/components/EntryContainer.tsx b/app/components/EntryContainer.tsx
index eeb186184..f8a7098cb 100644
--- a/app/components/EntryContainer.tsx
+++ b/app/components/EntryContainer.tsx
@@ -76,11 +76,17 @@ import {
OpenedEntry,
NotificationTypes,
isReadOnlyMode,
- actions as AppActions
+ actions as AppActions,
+ getCurrentLocationId
} from '-/reducers/app';
import useEventListener from '-/utils/useEventListener';
import { TS } from '-/tagspaces.namespace';
import FileView from '-/components/FileView';
+import { Pro } from '-/pro';
+import {
+ historyKeys,
+ saveHistory
+} from '../../extensions/tagspacespro/modules/history';
const defaultSplitSize = '7.86%'; // '7.2%'; // 103;
// const openedSplitSize = AppConfig.isElectron ? 560 : 360;
@@ -171,6 +177,7 @@ interface Props {
currentDirectoryPath: string | null;
isDesktopMode: boolean;
tileServer: TS.MapTileServer;
+ currentLocationId: string;
}
function EntryContainer(props: Props) {
@@ -491,6 +498,15 @@ function EntryContainer(props: Props) {
i18n.t('core:fileSavedSuccessfully'),
NotificationTypes.default
);
+ if (Pro) {
+ saveHistory(
+ historyKeys.fileEditKey,
+ openedFile.path,
+ openedFile.url,
+ props.currentLocationId,
+ props.settings[historyKeys.fileEditKey]
+ );
+ }
return result;
})
.catch(error => {
@@ -508,6 +524,7 @@ function EntryContainer(props: Props) {
editMode: true,
shouldReload: undefined
});
+
// setFileView(renderFileView());
};
@@ -1190,7 +1207,8 @@ function mapStateToProps(state) {
keyBindings: getKeyBindingObject(state),
isDesktopMode: isDesktopMode(state),
tileServer: getMapTileServer(state),
- language: getCurrentLanguage(state)
+ language: getCurrentLanguage(state),
+ currentLocationId: getCurrentLocationId(state)
};
}
diff --git a/app/components/SearchPopover.tsx b/app/components/SearchPopover.tsx
index bbedcc6a3..092aef5e5 100644
--- a/app/components/SearchPopover.tsx
+++ b/app/components/SearchPopover.tsx
@@ -1034,7 +1034,7 @@ function SearchPopover(props: Props) {
{SaveSearchDialog && saveSearchDialogOpened !== undefined && (
<SaveSearchDialog
- open={saveSearchDialogOpened !== undefined}
+ open={true}
onClose={(searchQuery: TS.SearchQuery) => {
setSaveSearchDialogOpened(undefined);
if (searchQuery) {
diff --git a/app/components/StoredSearches.tsx b/app/components/StoredSearches.tsx
index 5c9aa19c2..df8df09ac 100644
--- a/app/components/StoredSearches.tsx
+++ b/app/components/StoredSearches.tsx
@@ -16,13 +16,15 @@
*
*/
-import React, { useRef, useState } from 'react';
+import React, { useReducer, useRef, useState } from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import IconButton from '@mui/material/IconButton';
import Button from '@mui/material/Button';
import Grid from '@mui/material/Grid';
import EditIcon from '@mui/icons-material/Edit';
+import DeleteIcon from '@mui/icons-material/RemoveCircleOutline';
+import RefreshIcon from '@mui/icons-material/Refresh';
import MenuIcon from '@mui/icons-material/MoreVert';
import SearchIcon from '@mui/icons-material/Search';
import ArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
@@ -42,7 +44,21 @@ import { Pro } from '../pro';
import { actions as SearchActions, getSearches } from '-/reducers/searches';
import { TS } from '-/tagspaces.namespace';
import SearchMenu from '-/components/menus/SearchMenu';
-import { actions as AppActions } from '-/reducers/app';
+import { actions as AppActions, getCurrentLocationId } from '-/reducers/app';
+import {
+ delAllHistory,
+ delHistory,
+ getHistory,
+ historyKeys
+} from '../../extensions/tagspacespro/modules/history';
+import { getAllPropertiesPromise } from '-/services/utils-io';
+import { Tooltip } from '@mui/material';
+import {
+ extractFileName,
+ extractDirectoryName
+} from '@tagspaces/tagspaces-platforms/paths';
+import PlatformIO from '-/services/platform-facade';
+import HistoryMenu from '-/components/menus/HistoryMenu';
interface Props {
style?: any;
@@ -55,6 +71,10 @@ interface Props {
addSearches: (searches: Array<TS.SearchQuery>) => void;
openURLExternally: (url: string) => void;
reduceHeightBy: number;
+ openFsEntry: (fsEntry: TS.FileSystemEntry) => void;
+ openLink: (url: string, options: any) => void;
+ openLocationById: (locationId: string) => void;
+ currentLocationId: string;
}
const SaveSearchDialog = Pro && Pro.UI ? Pro.UI.SaveSearchDialog : false;
@@ -66,10 +86,17 @@ function StoredSearches(props: Props) {
const [storedSearchesVisible, setStoredSearchesVisible] = useState<boolean>(
true
);
+ const [fileOpenHistory, setFileOpenHistory] = useState<boolean>(true);
+ const [folderOpenHistory, setFolderOpenHistory] = useState<boolean>(true);
+ const [fileEditHistory, setFileEditHistory] = useState<boolean>(true);
const [
searchMenuAnchorEl,
setSearchMenuAnchorEl
] = useState<null | HTMLElement>(null);
+ const [
+ historyMenuAnchorEl,
+ setHistoryMenuAnchorEl
+ ] = useState<null | HTMLElement>(null);
const [
isExportSearchesDialogOpened,
@@ -78,6 +105,8 @@ function StoredSearches(props: Props) {
const [importFile, setImportFile] = useState<File>(undefined);
const fileInputRef = useRef<HTMLInputElement>(null);
+ const menuHistoryKey = useRef<string>(undefined);
+ const [ignored, forceUpdate] = useReducer(x => x + 1, 0);
const ExportSearchesDialog =
Pro && Pro.UI ? Pro.UI.ExportSearchesDialog : false;
@@ -138,6 +167,102 @@ function StoredSearches(props: Props) {
const { reduceHeightBy } = props;
+ const fileOpenHistoryItems: Array<TS.HistoryItem> = getHistory(
+ historyKeys.fileOpenKey
+ );
+ const fileEditHistoryItems: Array<TS.HistoryItem> = getHistory(
+ historyKeys.fileEditKey
+ );
+ const folderOpenHistoryItems: Array<TS.HistoryItem> = getHistory(
+ historyKeys.folderOpenKey
+ );
+
+ const renderHistory = (historyKey, items: Array<TS.HistoryItem>) => (
+ <Grid container direction="row">
+ {items &&
+ items.map(history => (
+ <React.Fragment key={history.creationTimeStamp}>
+ <Grid item xs={10} style={{ display: 'flex' }}>
+ <Tooltip
+ arrow
+ title={
+ <span style={{ fontSize: 14 }}>
+ <b>Path:</b> {history.path}
+ <br />
+ <b>Opened on: </b>{' '}
+ {new Date(history.creationTimeStamp)
+ .toISOString()
+ .substring(0, 19)
+ .split('T')
+ .join(' ')}
+ </span>
+ }
+ >
+ <Button
+ style={{
+ textTransform: 'none',
+ fontWeight: 'normal',
+ marginLeft: 5,
+ width: '240px',
+ justifyContent: 'start',
+ whiteSpace: 'nowrap',
+ textOverflow: 'ellipsis',
+ overflow: 'hidden'
+ }}
+ onClick={() => {
+ if (history.url) {
+ props.openLink(history.url, { fullWidth: false });
+ } else {
+ PlatformIO.disableObjectStoreSupport();
+ if (history.lid !== props.currentLocationId) {
+ props.openLocationById(history.lid);
+ }
+ getAllPropertiesPromise(history.path)
+ .then((fsEntry: TS.FileSystemEntry) => {
+ props.openFsEntry(fsEntry);
+ return true;
+ })
+ .catch(error =>
+ console.warn(
+ 'Error getting properties for entry: ' +
+ history.path +
+ ' - ' +
+ error
+ )
+ );
+ }
+ }}
+ >
+ {history.path.endsWith(PlatformIO.getDirSeparator())
+ ? extractDirectoryName(
+ history.path,
+ PlatformIO.getDirSeparator()
+ )
+ : extractFileName(
+ history.path,
+ PlatformIO.getDirSeparator()
+ )}
+ </Button>
+ </Tooltip>
+ </Grid>
+ <Grid item xs={2} style={{ display: 'flex' }}>
+ <IconButton
+ aria-label={i18n.t('core:searchEditBtn')}
+ onClick={() => {
+ delHistory(historyKey, history.creationTimeStamp);
+ forceUpdate();
+ }}
+ data-tid="editSearchTID"
+ size="small"
+ >
+ <DeleteIcon />
+ </IconButton>
+ </Grid>
+ </React.Fragment>
+ ))}
+ </Grid>
+ );
+
return (
<div
style={{
@@ -160,7 +285,7 @@ function StoredSearches(props: Props) {
<Typography
variant="inherit"
// className={props.classes.header}
- style={{ textTransform: 'uppercase', display: 'inline' }}
+ style={{ display: 'inline' }}
noWrap
onClick={() => setStoredSearchesVisible(!storedSearchesVisible)}
>
@@ -221,7 +346,7 @@ function StoredSearches(props: Props) {
aria-label={i18n.t('core:searchEditBtn')}
onClick={() => editSearch(search.uuid)}
data-tid="editSearchTID"
- size="large"
+ size="small"
>
<EditIcon />
</IconButton>
@@ -229,9 +354,119 @@ function StoredSearches(props: Props) {
</React.Fragment>
))}
</Grid>
+ <Grid container direction="row">
+ <Grid item xs={10} style={{ alignSelf: 'center' }}>
+ <IconButton
+ style={{ minWidth: 'auto', padding: 7 }}
+ onClick={() => setFileOpenHistory(!fileOpenHistory)}
+ size="large"
+ >
+ {fileOpenHistory ? <ArrowDownIcon /> : <ArrowRightIcon />}
+ </IconButton>
+ <Typography
+ variant="inherit"
+ style={{ display: 'inline' }}
+ noWrap
+ onClick={() => setFileOpenHistory(!fileOpenHistory)}
+ >
+ {i18n.t('core:fileOpenHistory')}
+ </Typography>
+ </Grid>
+ <Grid item xs={2} style={{ alignSelf: 'center' }}>
+ <IconButton
+ style={{ minWidth: 'auto', padding: 7 }}
+ onClick={(event: any) => {
+ menuHistoryKey.current = historyKeys.fileOpenKey;
+ setHistoryMenuAnchorEl(event.currentTarget);
+ }}
+ size="large"
+ >
+ <MenuIcon />
+ </IconButton>
+ </Grid>
+ </Grid>
+ {fileOpenHistory &&
+ renderHistory(historyKeys.fileOpenKey, fileOpenHistoryItems)}
+ <Grid container direction="row">
+ <Grid item xs={10} style={{ alignSelf: 'center' }}>
+ <IconButton
+ style={{ minWidth: 'auto', padding: 7 }}
+ onClick={() => setFileEditHistory(!fileEditHistory)}
+ size="large"
+ >
+ {fileEditHistory ? <ArrowDownIcon /> : <ArrowRightIcon />}
+ </IconButton>
+ <Typography
+ variant="inherit"
+ // className={props.classes.header}
+ style={{ display: 'inline' }}
+ noWrap
+ onClick={() => setFileEditHistory(!fileEditHistory)}
+ >
+ {i18n.t('core:fileEditHistory')}
+ </Typography>
+ </Grid>
+ <Grid item xs={2} style={{ alignSelf: 'center' }}>
+ <IconButton
+ style={{ minWidth: 'auto', padding: 7 }}
+ onClick={(event: any) => {
+ menuHistoryKey.current = historyKeys.fileEditKey;
+ setHistoryMenuAnchorEl(event.currentTarget);
+ }}
+ size="large"
+ >
+ <MenuIcon />
+ </IconButton>
+ </Grid>
+ </Grid>
+ {fileEditHistory &&
+ renderHistory(historyKeys.fileEditKey, fileEditHistoryItems)}
+ <Grid container direction="row">
+ <Grid item xs={10} style={{ alignSelf: 'center' }}>
+ <IconButton
+ style={{ minWidth: 'auto', padding: 7 }}
+ onClick={() => setFolderOpenHistory(!folderOpenHistory)}
+ size="large"
+ >
+ {folderOpenHistory ? <ArrowDownIcon /> : <ArrowRightIcon />}
+ </IconButton>
+ <Typography
+ variant="inherit"
+ style={{ display: 'inline' }}
+ noWrap
+ onClick={() => setFolderOpenHistory(!folderOpenHistory)}
+ >
+ {i18n.t('core:folderOpenHistory')}
+ </Typography>
+ </Grid>
+ <Grid item xs={2} style={{ alignSelf: 'center' }}>
+ <IconButton
+ style={{ minWidth: 'auto', padding: 7 }}
+ onClick={(event: any) => {
+ menuHistoryKey.current = historyKeys.folderOpenKey;
+ setHistoryMenuAnchorEl(event.currentTarget);
+ }}
+ size="large"
+ >
+ <MenuIcon />
+ </IconButton>
+ </Grid>
+ </Grid>
+ <HistoryMenu
+ anchorEl={historyMenuAnchorEl}
+ open={Boolean(historyMenuAnchorEl)}
+ onClose={() => setHistoryMenuAnchorEl(null)}
+ refreshHistory={() => forceUpdate()}
+ clearAll={() => {
+ delAllHistory(menuHistoryKey.current); //historyKeys.fileOpenKey);
+ forceUpdate();
+ }}
+ />
+ {folderOpenHistory &&
+ renderHistory(historyKeys.folderOpenKey, folderOpenHistoryItems)}
{SaveSearchDialog && saveSearchDialogOpened !== undefined && (
<SaveSearchDialog
- open={saveSearchDialogOpened !== undefined}
+ open={true}
onClose={(searchQuery: TS.SearchQuery) => {
setSaveSearchDialogOpened(undefined);
if (searchQuery) {
@@ -289,7 +524,8 @@ function mapStateToProps(state) {
language: getCurrentLanguage(state),
searchQuery: getSearchQuery(state),
searches: getSearches(state),
- showUnixHiddenEntries: getShowUnixHiddenEntries(state)
+ showUnixHiddenEntries: getShowUnixHiddenEntries(state),
+ currentLocationId: getCurrentLocationId(state)
};
}
@@ -300,7 +536,10 @@ function mapDispatchToProps(dispatch) {
setSearchQuery: LocationIndexActions.setSearchQuery,
// searchAllLocations: LocationIndexActions.searchAllLocations,
// searchLocationIndex: LocationIndexActions.searchLocationIndex,
- openURLExternally: AppActions.openURLExternally
+ openURLExternally: AppActions.openURLExternally,
+ openFsEntry: AppActions.openFsEntry,
+ openLink: AppActions.openLink,
+ openLocationById: AppActions.openLocationById
},
dispatch
);
diff --git a/app/components/dialogs/settings/SettingsAdvanced.tsx b/app/components/dialogs/settings/SettingsAdvanced.tsx
index 00e94c4a2..24d725c82 100644
--- a/app/components/dialogs/settings/SettingsAdvanced.tsx
+++ b/app/components/dialogs/settings/SettingsAdvanced.tsx
@@ -46,6 +46,7 @@ import MapTileServerDialog from '-/components/dialogs/settings/MapTileServerDial
import { Pro } from '-/pro';
import { ProLabel } from '-/components/HelperComponents';
import InfoIcon from '-/components/InfoIcon';
+import { historyKeys } from '../../../../extensions/tagspacespro/modules/history';
const styles: any = {
root: {
@@ -76,6 +77,7 @@ interface Props {
showResetSettings: (showDialog: boolean) => void;
tileServers: Array<TS.MapTileServer>;
setGeoTaggingFormat: (geoTaggingFormat: string) => void;
+ setHistory: (key: string, value: number) => void;
}
function SettingsAdvanced(props: Props) {
@@ -117,7 +119,6 @@ function SettingsAdvanced(props: Props) {
{i18n.t('core:reloadApplication')}
</Button>
</ListItem>
-
<ListItem className={classes.listItem}>
<ListItemText primary={i18n.t('enableMobileMode')} />
<Switch
@@ -147,6 +148,57 @@ function SettingsAdvanced(props: Props) {
checked={props.settings.warningOpeningFilesExternally}
/>
</ListItem>
+ <ListItem className={classes.listItem}>
+ <ListItemText primary={i18n.t('core:fileOpenHistory')} />
+ <Select
+ data-tid="fileOpenTID"
+ title={i18n.t('core:fileOpenHistoryTitle')}
+ value={props.settings[historyKeys.fileOpenKey]}
+ onChange={(event: any) =>
+ props.setHistory(historyKeys.fileOpenKey, event.target.value)
+ }
+ input={<Input id="fileOpenSelector" />}
+ >
+ <MenuItem value={0}>{i18n.t('core:disabled')}</MenuItem>
+ <MenuItem value={10}>10</MenuItem>
+ <MenuItem value={50}>50</MenuItem>
+ <MenuItem value={100}>100</MenuItem>
+ </Select>
+ </ListItem>
+ <ListItem className={classes.listItem}>
+ <ListItemText primary={i18n.t('core:folderOpenHistory')} />
+ <Select
+ data-tid="folderOpenTID"
+ title={i18n.t('core:folderOpenHistoryTitle')}
+ value={props.settings[historyKeys.folderOpenKey]}
+ onChange={(event: any) =>
+ props.setHistory(historyKeys.folderOpenKey, event.target.value)
+ }
+ input={<Input id="folderOpenSelector" />}
+ >
+ <MenuItem value={0}>{i18n.t('core:disabled')}</MenuItem>
+ <MenuItem value={10}>10</MenuItem>
+ <MenuItem value={50}>50</MenuItem>
+ <MenuItem value={100}>100</MenuItem>
+ </Select>
+ </ListItem>
+ <ListItem className={classes.listItem}>
+ <ListItemText primary={i18n.t('core:fileEditHistory')} />
+ <Select
+ data-tid="fileEditTID"
+ title={i18n.t('core:fileEditHistoryTitle')}
+ value={props.settings[historyKeys.fileEditKey]}
+ onChange={(event: any) =>
+ props.setHistory(historyKeys.fileEditKey, event.target.value)
+ }
+ input={<Input id="fileEditSelector" />}
+ >
+ <MenuItem value={0}>{i18n.t('core:disabled')}</MenuItem>
+ <MenuItem value={10}>10</MenuItem>
+ <MenuItem value={50}>50</MenuItem>
+ <MenuItem value={100}>100</MenuItem>
+ </Select>
+ </ListItem>
<ListItem className={classes.listItem}>
<ListItemText
primary={
@@ -282,7 +334,8 @@ function mapActionCreatorsToProps(dispatch) {
setDesktopMode: SettingsActions.setDesktopMode,
setEnableWS: SettingsActions.setEnableWS,
setSaveTagInLocation: SettingsActions.setSaveTagInLocation,
- setGeoTaggingFormat: SettingsActions.setGeoTaggingFormat
+ setGeoTaggingFormat: SettingsActions.setGeoTaggingFormat,
+ setHistory: SettingsActions.setHistory
},
dispatch
);
diff --git a/app/components/menus/HistoryMenu.tsx b/app/components/menus/HistoryMenu.tsx
new file mode 100644
index 000000000..8d480284e
--- /dev/null
+++ b/app/components/menus/HistoryMenu.tsx
@@ -0,0 +1,82 @@
+/**
+ * TagSpaces - universal file and folder organizer
+ * Copyright (C) 2017-present TagSpaces UG (haftungsbeschraenkt)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License (version 3) as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+import React from 'react';
+import ListItemText from '@mui/material/ListItemText';
+import ListItemIcon from '@mui/material/ListItemIcon';
+import Menu from '@mui/material/Menu';
+import MenuItem from '@mui/material/MenuItem';
+import RefreshIcon from '@mui/icons-material/Refresh';
+import DeleteIcon from '@mui/icons-material/Delete';
+import i18n from '-/services/i18n';
+import { Pro } from '../../pro';
+
+interface Props {
+ classes?: any;
+ open: boolean;
+ anchorEl: Element;
+ onClose: () => void;
+ refreshHistory: () => void;
+ clearAll: () => void;
+}
+
+function HistoryMenu(props: Props) {
+ const menuItems = [];
+ menuItems.push(
+ <MenuItem
+ disabled={!Pro}
+ key="refreshHistoryTID"
+ data-tid="refreshHistoryTID"
+ onClick={() => {
+ props.onClose();
+ props.refreshHistory();
+ }}
+ >
+ <ListItemIcon>
+ <RefreshIcon />
+ </ListItemIcon>
+ <ListItemText primary={<>{i18n.t('core:refreshHistory')}</>} />
+ </MenuItem>
+ );
+ menuItems.push(
+ <MenuItem
+ disabled={!Pro}
+ key="clearHistoryTID"
+ data-tid="clearHistoryTID"
+ onClick={() => {
+ props.onClose();
+ props.clearAll();
+ }}
+ >
+ <ListItemIcon>
+ <DeleteIcon />
+ </ListItemIcon>
+ <ListItemText primary={<>{i18n.t('core:deleteHistory')}</>} />
+ </MenuItem>
+ );
+
+ return (
+ <div style={{ overflowY: 'hidden' }}>
+ <Menu anchorEl={props.anchorEl} open={props.open} onClose={props.onClose}>
+ {menuItems}
+ </Menu>
+ </div>
+ );
+}
+
+export default HistoryMenu;
diff --git a/app/locales/en/core.json b/app/locales/en/core.json
index 381941e01..91525e3d9 100644
--- a/app/locales/en/core.json
+++ b/app/locales/en/core.json
@@ -663,5 +663,10 @@
"byFirstTag": "By First Tag",
"byExtension": "By Extension",
"rename": "Rename",
+ "fileOpenHistory": "Last opened files history",
+ "folderOpenHistory": "Last opened folders history",
+ "fileEditHistory": "Last edited files history",
+ "refreshHistory": "Refresh History",
+ "deleteHistory": "Delete History",
"-": "-"
}
diff --git a/app/reducers/app.ts b/app/reducers/app.ts
index 782ae5f64..338d63907 100644
--- a/app/reducers/app.ts
+++ b/app/reducers/app.ts
@@ -32,7 +32,8 @@ import {
extractTagsAsObjects,
normalizePath,
extractContainingDirectoryPath,
- getMetaFileLocationForDir
+ getMetaFileLocationForDir,
+ generateSharingLink
} from '@tagspaces/tagspaces-platforms/paths';
import {
getURLParameter,
@@ -63,6 +64,10 @@ import {
} from '-/reducers/settings';
import { TS } from '-/tagspaces.namespace';
import { PerspectiveIDs } from '-/perspectives';
+import {
+ historyKeys,
+ saveHistory
+} from '../../extensions/tagspacespro/modules/history';
export const types = {
DEVICE_ONLINE: 'APP/DEVICE_ONLINE',
@@ -1796,6 +1801,7 @@ export const actions = {
}
let entryForOpening: OpenedEntry;
const { openedFiles } = getState().app;
+
/**
* check for editMode in order to show save changes dialog (shouldReload: false)
*/
@@ -1865,6 +1871,32 @@ export const actions = {
updateHistory(currentLocation, currentDirectoryPath, fsEntry.path);
dispatch(actions.addToEntryContainer(entryForOpening));
+ /**
+ * save in history
+ */
+ if (Pro) {
+ if (fsEntry.isFile) {
+ saveHistory(
+ historyKeys.fileOpenKey,
+ fsEntry.path,
+ entryForOpening.url
+ ? generateSharingLink(currentLocation.uuid, fsEntry.path)
+ : undefined,
+ currentLocation.uuid,
+ getState().settings[historyKeys.fileOpenKey]
+ );
+ } else {
+ saveHistory(
+ historyKeys.folderOpenKey,
+ fsEntry.path,
+ entryForOpening.url
+ ? generateSharingLink(currentLocation.uuid, undefined, fsEntry.path)
+ : undefined,
+ currentLocation.uuid,
+ getState().settings[historyKeys.folderOpenKey]
+ );
+ }
+ }
},
toggleEntryFullWidth: () => ({
type: types.TOGGLE_ENTRY_FULLWIDTH
@@ -2130,7 +2162,7 @@ export const actions = {
PlatformIO.openFile(selectedFile, warningOpeningFilesExternally);
}
},
- openLink: (url: string) => (
+ openLink: (url: string, options = { fullWidth: true }) => (
dispatch: (action) => void,
getState: () => any
) => {
@@ -2177,30 +2209,34 @@ export const actions = {
}
setTimeout(() => {
if (isCloudLocation) {
- if (directoryPath && directoryPath.length > 0) {
- const dirFullPath = directoryPath;
- dispatch(actions.loadDirectoryContent(dirFullPath, false));
- }
+ PlatformIO.enableObjectStoreSupport(targetLocation).then(() => {
+ if (directoryPath && directoryPath.length > 0) {
+ const dirFullPath = directoryPath;
+ dispatch(actions.loadDirectoryContent(dirFullPath, false));
+ }
- if (entryPath) {
- getAllPropertiesPromise(entryPath)
- .then((fsEntry: TS.FileSystemEntry) => {
- if (fsEntry) {
- dispatch(actions.openFsEntry(fsEntry));
- dispatch(actions.setEntryFullWidth(true));
- }
- return true;
- })
- .catch(() =>
- dispatch(
- actions.showNotification(
- i18n.t('core:invalidLink'),
- 'warning',
- true
+ if (entryPath) {
+ getAllPropertiesPromise(entryPath)
+ .then((fsEntry: TS.FileSystemEntry) => {
+ if (fsEntry) {
+ dispatch(actions.openFsEntry(fsEntry));
+ if (options.fullWidth) {
+ dispatch(actions.setEntryFullWidth(true));
+ }
+ }
+ return true;
+ })
+ .catch(() =>
+ dispatch(
+ actions.showNotification(
+ i18n.t('core:invalidLink'),
+ 'warning',
+ true
+ )
)
- )
- );
- }
+ );
+ }
+ });
} else {
// local files case
const locationPath = PlatformIO.getLocationPath(targetLocation);
@@ -2240,7 +2276,9 @@ export const actions = {
.then((fsEntry: TS.FileSystemEntry) => {
if (fsEntry) {
dispatch(actions.openFsEntry(fsEntry));
- dispatch(actions.setEntryFullWidth(true));
+ if (options.fullWidth) {
+ dispatch(actions.setEntryFullWidth(true));
+ }
}
return true;
})
diff --git a/app/reducers/settings-default.ts b/app/reducers/settings-default.ts
index 0c2e35fa3..fddb37551 100644
--- a/app/reducers/settings-default.ts
+++ b/app/reducers/settings-default.ts
@@ -178,6 +178,9 @@ export default {
mainVSplitSize: '50%',
supportedGeoTagging: ['pluscodes', 'mgrs'],
supportedThemes: ['light', 'dark'],
+ tsLastOpenedFilesHistory: 10,
+ tsLastOpenedFoldersHistory: 10,
+ tsLastEditedFilesHistory: 10,
supportedLanguages: [
{
iso: 'en',
diff --git a/app/reducers/settings.ts b/app/reducers/settings.ts
index 62ba116e0..05e69a130 100644
--- a/app/reducers/settings.ts
+++ b/app/reducers/settings.ts
@@ -62,6 +62,7 @@ export const types = {
SET_TAGTEXTCOLOR: 'SETTINGS/SET_TAGTEXTCOLOR',
SET_CURRENTTHEME: 'SETTINGS/SET_CURRENTTHEME',
SET_GEO_TAGGING_FORMAT: 'SETTINGS/SET_GEO_TAGGING_FORMAT',
+ SET_HISTORY: 'SETTINGS/SET_HISTORY',
SWITCH_THEME: 'SETTINGS/SWITCH_THEME',
SET_KEYBINDING: 'SETTINGS/SET_KEYBINDING',
SET_GLOBAL_KEYBINDING: 'SETTINGS/SET_GLOBAL_KEYBINDING',
@@ -243,6 +244,9 @@ export default (state: any = defaultSettings, action: any) => {
case types.SET_GEO_TAGGING_FORMAT: {
return { ...state, geoTaggingFormat: action.geoTaggingFormat };
}
+ case types.SET_HISTORY: {
+ return { ...state, [action.key]: action.value };
+ }
case types.SWITCH_THEME: {
let currentTheme = 'dark';
if (state.currentTheme === 'dark') {
@@ -519,7 +523,10 @@ export const actions = {
type: types.SET_USETEXTEXTRACTION,
useTextExtraction
}),
- setAppDataPath: (path: string) => ({ type: types.SET_APPDATAPATH, path }),
+ setAppDataPath: (path: string) => ({
+ type: types.SET_APPDATAPATH,
+ path
+ }),
setContentHash: (contentHash: string) => ({
type: types.SET_CONTENTHASH,
contentHash
@@ -529,7 +536,10 @@ export const actions = {
setZoomResetApp: () => ({ type: types.SET_ZOOM_RESET }),
setZoomInApp: () => ({ type: types.SET_ZOOM_IN }),
setZoomOutApp: () => ({ type: types.SET_ZOOM_OUT }),
- setTagColor: (tagColor: string) => ({ type: types.SET_TAGCOLOR, tagColor }),
+ setTagColor: (tagColor: string) => ({
+ type: types.SET_TAGCOLOR,
+ tagColor
+ }),
setTagTextColor: (tagTextColor: string) => ({
type: types.SET_TAGTEXTCOLOR,
tagTextColor
@@ -542,6 +552,11 @@ export const actions = {
type: types.SET_GEO_TAGGING_FORMAT,
geoTaggingFormat
}),
+ setHistory: (key: string, value: number) => ({
+ type: types.SET_HISTORY,
+ key,
+ value
+ }),
switchTheme: () => ({ type: types.SWITCH_THEME }),
setKeyBinding: (keyBindingName: string, keyBindingCommand: string) => ({
type: types.SET_KEYBINDING,
diff --git a/app/tagspaces.namespace.d.ts b/app/tagspaces.namespace.d.ts
index 05c56c0fa..4536c8b15 100644
--- a/app/tagspaces.namespace.d.ts
+++ b/app/tagspaces.namespace.d.ts
@@ -143,6 +143,12 @@ export namespace TS {
dirs?: Array<FileSystemEntry>;
perspectiveSettings?: PerspectiveSettings;
}
+ interface HistoryItem {
+ path: string;
+ url: string;
+ lid: string;
+ creationTimeStamp: number;
+ }
interface PerspectiveSettings {
grid?: FolderSettings;