Skip to content

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

add bookmark funktionality (#1727)

Stanimira6ce70144b6b
diff --git a/app/components/EntryContainer.tsx b/app/components/EntryContainer.tsx
index bb38bb9d3..af330e389 100644
--- a/app/components/EntryContainer.tsx
+++ b/app/components/EntryContainer.tsx
@@ -31,6 +31,8 @@ import fscreen from 'fscreen';
import Button from '@mui/material/Button';
import Tooltip from '@mui/material/Tooltip';
import IconButton from '@mui/material/IconButton';
+import BookmarkIcon from '@mui/icons-material/BookmarkTwoTone';
+import BookmarkAddIcon from '@mui/icons-material/BookmarkAddTwoTone';
import SaveIcon from '@mui/icons-material/Save';
import CloseIcon from '@mui/icons-material/Close';
import BackIcon from '@mui/icons-material/RemoveRedEye';
@@ -56,8 +58,10 @@ import {
extractFileExtension,
baseName,
extractFileName,
- extractDirectoryName
+ extractDirectoryName,
+ generateSharingLink
} from '@tagspaces/tagspaces-platforms/paths';
+import { ProTooltip } from '-/components/HelperComponents';
import EntryProperties from '-/components/EntryProperties';
import TagsPreview from '-/components/TagsPreview';
import ConfirmDialog from '-/components/dialogs/ConfirmDialog';
@@ -211,7 +215,6 @@ function EntryContainer(props: Props) {
const fileViewerContainer: MutableRefObject<HTMLDivElement> = useRef<
HTMLDivElement
>(null);
-
const fileChanged = useRef<boolean>(false);
useEventListener('message', e => {
@@ -322,6 +325,27 @@ function EntryContainer(props: Props) {
openedFile.editingExtensionId !== undefined &&
openedFile.editingExtensionId.length > 3;
+ const haveBookmark =
+ Pro && Pro.bookmarks && Pro.bookmarks.haveBookmark(openedFile.path);
+
+ let sharingLink = '';
+ if (window.location.href.indexOf('?') > 0) {
+ const sharingURL = new URL(window.location.href);
+ const params = new URLSearchParams(sharingURL.search);
+ if (params.has('tslid')) {
+ const locationId = params.get('tslid');
+ if (openedFile.isFile && params.has('tsepath')) {
+ const entryPath = params.get('tsepath');
+ sharingLink = generateSharingLink(locationId, entryPath);
+ } else if (!openedFile.isFile) {
+ const dirPath = params.has('tsepath')
+ ? params.get('tsepath')
+ : openedFile.path;
+ sharingLink = generateSharingLink(locationId, undefined, dirPath);
+ }
+ }
+ }
+
const handleMessage = (data: any) => {
let message;
let textFilePath;
@@ -967,7 +991,6 @@ function EntryContainer(props: Props) {
>
<Box className={classes.flexLeft} style={{ paddingRight: 20 }}>
<div
- title={openedFile.url || openedFile.path}
style={{
paddingLeft: 10,
display: 'flex',
@@ -977,33 +1000,40 @@ function EntryContainer(props: Props) {
color: 'inherit !important'
}}
>
- <Box
- style={{
- color: props.theme.palette.text.primary,
- display: 'inline',
- fontSize: 17
- }}
- >
- {openedFile.isFile && fileChanged.current // openedFile.editMode && openedFile.changed
- ? String.fromCharCode(0x25cf) + ' '
- : ''}
- {fileTitle}
- </Box>
- {openedFile.isFile ? (
- <span
- className={classes.fileBadge}
- title={i18n.t('core:toggleEntryProperties')}
+ <Tooltip title={openedFile.url || openedFile.path}>
+ <Box
style={{
- backgroundColor: openedFile.color,
- textTransform: 'uppercase'
+ color: props.theme.palette.text.primary,
+ display: 'inline',
+ fontSize: 17
}}
>
- {'.' +
- extractFileExtension(
- openedFile.path,
- PlatformIO.getDirSeparator()
- )}
- </span>
+ {fileTitle}
+ </Box>
+ </Tooltip>
+ {openedFile.isFile ? (
+ <>
+ {fileChanged.current ? (
+ <Tooltip title="File changed">
+ <span>{' ' + String.fromCharCode(0x25cf)}</span>
+ </Tooltip>
+ ) : (
+ ''
+ )}
+ <span
+ className={classes.fileBadge}
+ style={{
+ backgroundColor: openedFile.color,
+ textTransform: 'uppercase'
+ }}
+ >
+ {'.' +
+ extractFileExtension(
+ openedFile.path,
+ PlatformIO.getDirSeparator()
+ )}
+ </span>
+ </>
) : (
<span
className={classes.fileBadge}
@@ -1016,6 +1046,39 @@ function EntryContainer(props: Props) {
</span>
)}
</div>
+ <ProTooltip tooltip={i18n.t('core:toggleBookmark')}>
+ <IconButton
+ aria-label="bookmark"
+ size="small"
+ onClick={() => {
+ if (Pro) {
+ if (haveBookmark) {
+ Pro.bookmarks.delBookmark(openedFile.path);
+ } else {
+ Pro.bookmarks.setBookmark(
+ openedFile.path,
+ openedFile.url ? sharingLink : undefined
+ );
+ }
+ forceUpdate();
+ }
+ }}
+ >
+ {haveBookmark ? (
+ <BookmarkIcon
+ style={{
+ color: theme.palette.primary.main
+ }}
+ />
+ ) : (
+ <BookmarkAddIcon
+ style={{
+ color: theme.palette.text.secondary
+ }}
+ />
+ )}
+ </IconButton>
+ </ProTooltip>
<TagsPreview tags={openedFile.tags} />
</Box>
<div className={classes.entryCloseSection}>
@@ -1098,6 +1161,7 @@ function EntryContainer(props: Props) {
isReadOnlyMode={props.isReadOnlyMode}
currentDirectoryPath={props.currentDirectoryPath}
tileServer={props.tileServer}
+ sharingLink={sharingLink}
/>
</div>
);
diff --git a/app/components/EntryProperties.tsx b/app/components/EntryProperties.tsx
index c4fc74fb1..1d4ac36d9 100644
--- a/app/components/EntryProperties.tsx
+++ b/app/components/EntryProperties.tsx
@@ -16,7 +16,13 @@
*
*/
-import React, { ChangeEvent, useEffect, useRef, useState } from 'react';
+import React, {
+ ChangeEvent,
+ useEffect,
+ useReducer,
+ useRef,
+ useState
+} from 'react';
import { useStateWithCallbackLazy } from 'use-state-with-callback';
import { Theme } from '@mui/material/styles';
import { v1 as uuidv1 } from 'uuid';
@@ -54,8 +60,7 @@ import {
getThumbFileLocationForFile,
getThumbFileLocationForDirectory,
extractFileName,
- extractDirectoryName,
- generateSharingLink
+ extractDirectoryName
} from '@tagspaces/tagspaces-platforms/paths';
import AppConfig from '@tagspaces/tagspaces-platforms/AppConfig';
import TagDropContainer from './TagDropContainer';
@@ -150,6 +155,7 @@ interface Props {
isReadOnlyMode: boolean;
// currentDirectoryPath: string | null;
tagDelimiter: string;
+ sharingLink: string;
tileServer: TS.MapTileServer;
}
@@ -434,7 +440,7 @@ function EntryProperties(props: Props) {
}
};
- const { classes, isReadOnlyMode, theme } = props;
+ const { classes, isReadOnlyMode, theme, sharingLink } = props;
if (!currentEntry || !currentEntry.path || currentEntry.path === '') {
return <div />;
@@ -528,24 +534,6 @@ function EntryProperties(props: Props) {
const geoLocation: any = getGeoLocation(currentEntry.tags);
- let sharingLink = '';
- if (window.location.href.indexOf('?') > 0) {
- const sharingURL = new URL(window.location.href);
- const params = new URLSearchParams(sharingURL.search);
- if (params.has('tslid')) {
- const locationId = params.get('tslid');
- if (currentEntry.isFile && params.has('tsepath')) {
- const entryPath = params.get('tsepath');
- sharingLink = generateSharingLink(locationId, entryPath);
- } else if (!currentEntry.isFile) {
- const dirPath = params.has('tsepath')
- ? params.get('tsepath')
- : currentEntry.path;
- sharingLink = generateSharingLink(locationId, undefined, dirPath);
- }
- }
- }
-
const isCloudLocation = currentEntry.url && currentEntry.url.length > 5;
function generateCopySharingURL() {
diff --git a/app/components/StoredSearches.tsx b/app/components/StoredSearches.tsx
index 50567dcfa..561a6f6f4 100644
--- a/app/components/StoredSearches.tsx
+++ b/app/components/StoredSearches.tsx
@@ -27,10 +27,10 @@ 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 BookmarkTwoToneIcon from '@mui/icons-material/BookmarkTwoTone';
import MenuIcon from '@mui/icons-material/MoreVert';
-import SearchIcon from '@mui/icons-material/Search';
-import HistoryIcon from '@mui/icons-material/ExitToApp';
+import SearchIcon from '@mui/icons-material/FilterAltTwoTone';
+import HistoryIcon from '@mui/icons-material/ChangeHistoryTwoTone';
import ArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
import ArrowRightIcon from '@mui/icons-material/KeyboardArrowRight';
import Typography from '@mui/material/Typography';
@@ -40,8 +40,14 @@ import {
getSearchQuery
} from '-/reducers/location-index';
import {
+ actions as SettingsActions,
getCurrentLanguage,
- getShowUnixHiddenEntries
+ getFileEditHistory,
+ getFileOpenHistory,
+ getFolderOpenHistory,
+ getShowBookmarks,
+ getShowUnixHiddenEntries,
+ getStoredSearchesVisible
} from '-/reducers/settings';
import i18n from '../services/i18n';
import { Pro } from '../pro';
@@ -57,6 +63,7 @@ import {
} from '@tagspaces/tagspaces-platforms/paths';
import PlatformIO from '-/services/platform-facade';
import HistoryMenu from '-/components/menus/HistoryMenu';
+import BookmarksMenu from '-/components/menus/BookmarksMenu';
interface Props {
style?: any;
@@ -74,6 +81,16 @@ interface Props {
openLink: (url: string, options: any) => void;
openLocationById: (locationId: string) => void;
currentLocationId: string;
+ storedSearchesVisible: boolean;
+ showBookmarks: boolean;
+ fileOpenHistory: boolean;
+ folderOpenHistory: boolean;
+ fileEditHistory: boolean;
+ setStoredSearchesVisible: (value: boolean) => void;
+ setShowBookmarks: (value: boolean) => void;
+ setFileOpenHistory: (value: boolean) => void;
+ setFolderOpenHistory: (value: boolean) => void;
+ setFileEditHistory: (value: boolean) => void;
}
const SaveSearchDialog = Pro && Pro.UI ? Pro.UI.SaveSearchDialog : false;
@@ -83,12 +100,6 @@ function StoredSearches(props: Props) {
const [saveSearchDialogOpened, setSaveSearchDialogOpened] = useState<
TS.SearchQuery
>(undefined);
- 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
@@ -98,6 +109,11 @@ function StoredSearches(props: Props) {
setHistoryMenuAnchorEl
] = useState<null | HTMLElement>(null);
+ const [
+ bookmarksMenuAnchorEl,
+ setBookmarksMenuAnchorEl
+ ] = useState<null | HTMLElement>(null);
+
const [
isExportSearchesDialogOpened,
setExportSearchesDialogOpened
@@ -167,6 +183,9 @@ function StoredSearches(props: Props) {
const { reduceHeightBy, classes } = props;
+ const bookmarkItems: Array<TS.BookmarkItem> = Pro
+ ? Pro.bookmarks.getBookmarks()
+ : undefined;
const fileOpenHistoryItems: Array<TS.HistoryItem> = Pro
? Pro.history.getHistory(historyKeys.fileOpenKey)
: undefined;
@@ -177,11 +196,14 @@ function StoredSearches(props: Props) {
? Pro.history.getHistory(historyKeys.folderOpenKey)
: undefined;
- const renderHistory = (historyKey, items: Array<TS.HistoryItem>) => (
+ const renderItem = (
+ key,
+ items: Array<TS.HistoryItem> | Array<TS.BookmarkItem>
+ ) => (
<Grid container direction="row">
{items &&
- items.map(history => (
- <React.Fragment key={history.creationTimeStamp}>
+ items.map(item => (
+ <React.Fragment key={item.creationTimeStamp}>
<Grid item xs={10} style={{ display: 'flex' }}>
<Button
style={{
@@ -194,14 +216,14 @@ function StoredSearches(props: Props) {
overflow: 'hidden'
}}
onClick={() => {
- if (history.url) {
- props.openLink(history.url, { fullWidth: false });
+ if (item.url) {
+ props.openLink(item.url, { fullWidth: false });
} else {
PlatformIO.disableObjectStoreSupport();
- if (history.lid !== props.currentLocationId) {
- props.openLocationById(history.lid);
+ if (item.lid !== props.currentLocationId) {
+ props.openLocationById(item.lid);
}
- getAllPropertiesPromise(history.path)
+ getAllPropertiesPromise(item.path)
.then((fsEntry: TS.FileSystemEntry) => {
props.openFsEntry(fsEntry);
return true;
@@ -209,7 +231,7 @@ function StoredSearches(props: Props) {
.catch(error =>
console.warn(
'Error getting properties for entry: ' +
- history.path +
+ item.path +
' - ' +
error
)
@@ -221,10 +243,11 @@ function StoredSearches(props: Props) {
arrow
title={
<span style={{ fontSize: 14 }}>
- <b>Path:</b> {history.path}
+ <b>Path:</b> {item.path}
+ <br />
<br />
<b>Opened on: </b>{' '}
- {new Date(history.creationTimeStamp)
+ {new Date(item.creationTimeStamp)
.toISOString()
.substring(0, 19)
.split('T')
@@ -232,26 +255,31 @@ function StoredSearches(props: Props) {
</span>
}
>
- <HistoryIcon fontSize="small" />
+ {key === Pro.bookmarks.bookmarksKey ? (
+ <BookmarkTwoToneIcon fontSize="small" />
+ ) : (
+ <HistoryIcon fontSize="small" />
+ )}
</Tooltip>
&nbsp;
- {history.path.endsWith(PlatformIO.getDirSeparator())
+ {item.path.endsWith(PlatformIO.getDirSeparator())
? extractDirectoryName(
- history.path,
+ item.path,
PlatformIO.getDirSeparator()
)
- : extractFileName(history.path, PlatformIO.getDirSeparator())}
+ : extractFileName(item.path, PlatformIO.getDirSeparator())}
</Button>
</Grid>
<Grid item xs={2} style={{ display: 'flex' }}>
<IconButton
- aria-label={i18n.t('core:deleteHistory')}
+ aria-label={i18n.t('core:clearHistory')}
onClick={() => {
if (Pro) {
- Pro.history.delHistory(
- historyKey,
- history.creationTimeStamp
- );
+ if (key === Pro.bookmarks.bookmarksKey) {
+ Pro.bookmarks.delBookmark(item.path);
+ } else {
+ Pro.history.delHistory(key, item.creationTimeStamp);
+ }
}
forceUpdate();
}}
@@ -296,17 +324,25 @@ function StoredSearches(props: Props) {
<Grid item xs={10} style={{ alignSelf: 'center' }}>
<IconButton
style={{ minWidth: 'auto', padding: 7 }}
- onClick={() => setStoredSearchesVisible(!storedSearchesVisible)}
+ onClick={() =>
+ props.setStoredSearchesVisible(!props.storedSearchesVisible)
+ }
size="large"
>
- {storedSearchesVisible ? <ArrowDownIcon /> : <ArrowRightIcon />}
+ {props.storedSearchesVisible ? (
+ <ArrowDownIcon />
+ ) : (
+ <ArrowRightIcon />
+ )}
</IconButton>
<Typography
variant="inherit"
// className={props.classes.header}
style={{ display: 'inline' }}
noWrap
- onClick={() => setStoredSearchesVisible(!storedSearchesVisible)}
+ onClick={() =>
+ props.setStoredSearchesVisible(!props.storedSearchesVisible)
+ }
>
{i18n.t('core:savedSearchesTitle')}
</Typography>
@@ -334,14 +370,14 @@ function StoredSearches(props: Props) {
</Grid>
</Grid>
<Grid container direction="row">
- {storedSearchesVisible && noSearchesFound && (
+ {props.storedSearchesVisible && noSearchesFound && (
<Grid item xs={12} style={{ display: 'flex', padding: 10 }}>
{i18n.t('noSavedSearches')}
</Grid>
)}
</Grid>
<Grid container direction="row">
- {storedSearchesVisible &&
+ {props.storedSearchesVisible &&
props.searches.map(search => (
<React.Fragment key={search.uuid}>
<Grid item xs={10} style={{ display: 'flex' }}>
@@ -376,16 +412,50 @@ function StoredSearches(props: Props) {
<Grid item xs={10} style={{ alignSelf: 'center' }}>
<IconButton
style={{ minWidth: 'auto', padding: 7 }}
- onClick={() => setFileOpenHistory(!fileOpenHistory)}
+ onClick={() => props.setShowBookmarks(!props.showBookmarks)}
size="large"
>
- {fileOpenHistory ? <ArrowDownIcon /> : <ArrowRightIcon />}
+ {props.showBookmarks ? <ArrowDownIcon /> : <ArrowRightIcon />}
</IconButton>
<Typography
variant="inherit"
style={{ display: 'inline' }}
noWrap
- onClick={() => setFileOpenHistory(!fileOpenHistory)}
+ onClick={() => props.setShowBookmarks(!props.showBookmarks)}
+ >
+ {i18n.t('core:showBookmarks')}
+ </Typography>
+ </Grid>
+ <Grid item xs={2} style={{ alignSelf: 'center' }}>
+ <IconButton
+ style={{ minWidth: 'auto', padding: 7 }}
+ onClick={(event: any) => {
+ menuHistoryKey.current = historyKeys.fileOpenKey;
+ setBookmarksMenuAnchorEl(event.currentTarget);
+ }}
+ size="large"
+ >
+ <MenuIcon />
+ </IconButton>
+ </Grid>
+ </Grid>
+ {Pro &&
+ props.showBookmarks &&
+ renderItem(Pro.bookmarks.bookmarksKey, bookmarkItems)}
+ <Grid container direction="row">
+ <Grid item xs={10} style={{ alignSelf: 'center' }}>
+ <IconButton
+ style={{ minWidth: 'auto', padding: 7 }}
+ onClick={() => props.setFileOpenHistory(!props.fileOpenHistory)}
+ size="large"
+ >
+ {props.fileOpenHistory ? <ArrowDownIcon /> : <ArrowRightIcon />}
+ </IconButton>
+ <Typography
+ variant="inherit"
+ style={{ display: 'inline' }}
+ noWrap
+ onClick={() => props.setFileOpenHistory(!props.fileOpenHistory)}
>
{i18n.t('core:fileOpenHistory')}
</Typography>
@@ -403,23 +473,23 @@ function StoredSearches(props: Props) {
</IconButton>
</Grid>
</Grid>
- {fileOpenHistory &&
- renderHistory(historyKeys.fileOpenKey, fileOpenHistoryItems)}
+ {props.fileOpenHistory &&
+ renderItem(historyKeys.fileOpenKey, fileOpenHistoryItems)}
<Grid container direction="row">
<Grid item xs={10} style={{ alignSelf: 'center' }}>
<IconButton
style={{ minWidth: 'auto', padding: 7 }}
- onClick={() => setFileEditHistory(!fileEditHistory)}
+ onClick={() => props.setFileEditHistory(!props.fileEditHistory)}
size="large"
>
- {fileEditHistory ? <ArrowDownIcon /> : <ArrowRightIcon />}
+ {props.fileEditHistory ? <ArrowDownIcon /> : <ArrowRightIcon />}
</IconButton>
<Typography
variant="inherit"
// className={props.classes.header}
style={{ display: 'inline' }}
noWrap
- onClick={() => setFileEditHistory(!fileEditHistory)}
+ onClick={() => props.setFileEditHistory(!props.fileEditHistory)}
>
{i18n.t('core:fileEditHistory')}
</Typography>
@@ -437,22 +507,26 @@ function StoredSearches(props: Props) {
</IconButton>
</Grid>
</Grid>
- {fileEditHistory &&
- renderHistory(historyKeys.fileEditKey, fileEditHistoryItems)}
+ {props.fileEditHistory &&
+ renderItem(historyKeys.fileEditKey, fileEditHistoryItems)}
<Grid container direction="row">
<Grid item xs={10} style={{ alignSelf: 'center' }}>
<IconButton
style={{ minWidth: 'auto', padding: 7 }}
- onClick={() => setFolderOpenHistory(!folderOpenHistory)}
+ onClick={() =>
+ props.setFolderOpenHistory(!props.folderOpenHistory)
+ }
size="large"
>
- {folderOpenHistory ? <ArrowDownIcon /> : <ArrowRightIcon />}
+ {props.folderOpenHistory ? <ArrowDownIcon /> : <ArrowRightIcon />}
</IconButton>
<Typography
variant="inherit"
style={{ display: 'inline' }}
noWrap
- onClick={() => setFolderOpenHistory(!folderOpenHistory)}
+ onClick={() =>
+ props.setFolderOpenHistory(!props.folderOpenHistory)
+ }
>
{i18n.t('core:folderOpenHistory')}
</Typography>
@@ -482,8 +556,20 @@ function StoredSearches(props: Props) {
forceUpdate();
}}
/>
- {folderOpenHistory &&
- renderHistory(historyKeys.folderOpenKey, folderOpenHistoryItems)}
+ <BookmarksMenu
+ anchorEl={bookmarksMenuAnchorEl}
+ open={Boolean(bookmarksMenuAnchorEl)}
+ onClose={() => setBookmarksMenuAnchorEl(null)}
+ refresh={() => forceUpdate()}
+ clearAll={() => {
+ if (Pro) {
+ Pro.bookmarks.delAllBookmarks();
+ } //historyKeys.fileOpenKey);
+ forceUpdate();
+ }}
+ />
+ {props.folderOpenHistory &&
+ renderItem(historyKeys.folderOpenKey, folderOpenHistoryItems)}
{SaveSearchDialog && saveSearchDialogOpened !== undefined && (
<SaveSearchDialog
open={true}
@@ -546,7 +632,12 @@ function mapStateToProps(state) {
searchQuery: getSearchQuery(state),
searches: getSearches(state),
showUnixHiddenEntries: getShowUnixHiddenEntries(state),
- currentLocationId: getCurrentLocationId(state)
+ currentLocationId: getCurrentLocationId(state),
+ storedSearchesVisible: getStoredSearchesVisible(state),
+ showBookmarks: getShowBookmarks(state),
+ fileOpenHistory: getFileOpenHistory(state),
+ folderOpenHistory: getFolderOpenHistory(state),
+ fileEditHistory: getFileEditHistory(state)
};
}
@@ -560,13 +651,23 @@ function mapDispatchToProps(dispatch) {
openURLExternally: AppActions.openURLExternally,
openFsEntry: AppActions.openFsEntry,
openLink: AppActions.openLink,
- openLocationById: AppActions.openLocationById
+ openLocationById: AppActions.openLocationById,
+ setStoredSearchesVisible: SettingsActions.setStoredSearchesVisible,
+ setShowBookmarks: SettingsActions.setShowBookmarks,
+ setFileOpenHistory: SettingsActions.setFileOpenHistory,
+ setFolderOpenHistory: SettingsActions.setFolderOpenHistory,
+ setFileEditHistory: SettingsActions.setFileEditHistory
},
dispatch
);
}
const areEqual = (prevProp, nextProp) =>
+ nextProp.storedSearchesVisible === prevProp.storedSearchesVisible &&
+ nextProp.showBookmarks === prevProp.showBookmarks &&
+ nextProp.fileOpenHistory === prevProp.fileOpenHistory &&
+ nextProp.folderOpenHistory === prevProp.folderOpenHistory &&
+ nextProp.fileEditHistory === prevProp.fileEditHistory &&
nextProp.language === prevProp.language &&
nextProp.indexing === prevProp.indexing &&
nextProp.searchQuery === prevProp.searchQuery &&
diff --git a/app/components/menus/BookmarksMenu.tsx b/app/components/menus/BookmarksMenu.tsx
new file mode 100644
index 000000000..8cb60a55d
--- /dev/null
+++ b/app/components/menus/BookmarksMenu.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;
+ refresh: () => void;
+ clearAll: () => void;
+}
+
+function BookmarksMenu(props: Props) {
+ const menuItems = [];
+ menuItems.push(
+ <MenuItem
+ disabled={!Pro}
+ key="refreshBookmarks"
+ data-tid="refreshBookmarksTID"
+ onClick={() => {
+ props.onClose();
+ props.refresh();
+ }}
+ >
+ <ListItemIcon>
+ <RefreshIcon />
+ </ListItemIcon>
+ <ListItemText primary={<>{i18n.t('core:refresh')}</>} />
+ </MenuItem>
+ );
+ menuItems.push(
+ <MenuItem
+ disabled={!Pro}
+ key="clearBookmarksTID"
+ data-tid="clearBookmarksTID"
+ onClick={() => {
+ props.onClose();
+ props.clearAll();
+ }}
+ >
+ <ListItemIcon>
+ <DeleteIcon />
+ </ListItemIcon>
+ <ListItemText primary={<>{i18n.t('core:deleteBookmarks')}</>} />
+ </MenuItem>
+ );
+
+ return (
+ <div style={{ overflowY: 'hidden' }}>
+ <Menu anchorEl={props.anchorEl} open={props.open} onClose={props.onClose}>
+ {menuItems}
+ </Menu>
+ </div>
+ );
+}
+
+export default BookmarksMenu;
diff --git a/app/components/menus/HistoryMenu.tsx b/app/components/menus/HistoryMenu.tsx
index 8d480284e..c120a07ff 100644
--- a/app/components/menus/HistoryMenu.tsx
+++ b/app/components/menus/HistoryMenu.tsx
@@ -50,7 +50,7 @@ function HistoryMenu(props: Props) {
<ListItemIcon>
<RefreshIcon />
</ListItemIcon>
- <ListItemText primary={<>{i18n.t('core:refreshHistory')}</>} />
+ <ListItemText primary={<>{i18n.t('core:refresh')}</>} />
</MenuItem>
);
menuItems.push(
@@ -66,7 +66,7 @@ function HistoryMenu(props: Props) {
<ListItemIcon>
<DeleteIcon />
</ListItemIcon>
- <ListItemText primary={<>{i18n.t('core:deleteHistory')}</>} />
+ <ListItemText primary={<>{i18n.t('core:clearHistory')}</>} />
</MenuItem>
);
diff --git a/app/locales/en/core.json b/app/locales/en/core.json
index 47c8e182e..808411ca2 100644
--- a/app/locales/en/core.json
+++ b/app/locales/en/core.json
@@ -667,11 +667,14 @@
"fileOpenHistory": "Recently Opened Files",
"folderOpenHistory": "Recently Opened Folders",
"fileEditHistory": "Recently Edited Files",
- "refreshHistory": "Refresh History",
- "deleteHistory": "Delete History",
+ "clearHistory": "Clear History",
+ "showBookmarks": "Bookmarks",
+ "refresh": "Refresh",
+ "deleteBookmarks": "Delete All Bookmarks",
"quickAccess": "Quick access",
"resetLocalSettings": "Reset Custom Settings",
"folderWithCustomPerspectiveSetting": "Current folder has custom settings for this perspective",
"cancelSubscription": "Cancel Subscription",
+ "toggleBookmark": "Toggle Bookmark",
"-": "-"
}
diff --git a/app/package.json b/app/package.json
index 387f61fef..82db55519 100644
--- a/app/package.json
+++ b/app/package.json
@@ -13,11 +13,11 @@
"license": "AGPL-3.0",
"scripts": {},
"webDependencies": {
- "@tagspaces/extensions": "1.0.31"
+ "@tagspaces/extensions": "1.0.32"
},
"nodeDependencies": {
"@tagspaces/tagspaces-ws": "2.0.15",
- "@tagspaces/extensions": "1.0.31",
+ "@tagspaces/extensions": "1.0.32",
"sharp": "^0.30.7"
}
}
diff --git a/app/reducers/location-index.ts b/app/reducers/location-index.ts
index 568ee1c8f..4f6ad4ad1 100644
--- a/app/reducers/location-index.ts
+++ b/app/reducers/location-index.ts
@@ -68,7 +68,9 @@ export default (state: any = initialState, action: any) => {
}
case types.INDEX_DIRECTORY_CLEAR: {
// GlobalSearch.index.length = 0;
- GlobalSearch.index.splice(0, GlobalSearch.index.length);
+ if (GlobalSearch.index) {
+ GlobalSearch.index.splice(0, GlobalSearch.index.length);
+ }
GlobalSearch.indexLoadedOn = undefined;
return {
...state,
@@ -94,7 +96,7 @@ export default (state: any = initialState, action: any) => {
};
}
case types.REFLECT_DELETE_ENTRY: {
- if (GlobalSearch.index.length < 1) {
+ if (!GlobalSearch.index || GlobalSearch.index.length < 1) {
return state;
}
for (let i = 0; i < GlobalSearch.index.length; i += 1) {
@@ -106,7 +108,7 @@ export default (state: any = initialState, action: any) => {
return state;
}
case types.REFLECT_CREATE_ENTRY: {
- if (GlobalSearch.index.length < 1) {
+ if (!GlobalSearch.index || GlobalSearch.index.length < 1) {
return state;
}
let entryFound = false;
@@ -122,7 +124,7 @@ export default (state: any = initialState, action: any) => {
return state;
}
case types.REFLECT_RENAME_ENTRY: {
- if (GlobalSearch.index.length < 1) {
+ if (!GlobalSearch.index || GlobalSearch.index.length < 1) {
return state;
}
for (let i = 0; i < GlobalSearch.index.length; i += 1) {
diff --git a/app/reducers/settings-default.ts b/app/reducers/settings-default.ts
index fddb37551..c3fcf53dc 100644
--- a/app/reducers/settings-default.ts
+++ b/app/reducers/settings-default.ts
@@ -181,6 +181,11 @@ export default {
tsLastOpenedFilesHistory: 10,
tsLastOpenedFoldersHistory: 10,
tsLastEditedFilesHistory: 10,
+ storedSearchesVisible: true,
+ showBookmarks: true,
+ fileOpenHistory: false,
+ folderOpenHistory: false,
+ fileEditHistory: false,
supportedLanguages: [
{
iso: 'en',
diff --git a/app/reducers/settings.ts b/app/reducers/settings.ts
index 05e69a130..e583d183e 100644
--- a/app/reducers/settings.ts
+++ b/app/reducers/settings.ts
@@ -78,7 +78,12 @@ export const types = {
TOGGLE_TAGGROUP: 'TOGGLE_TAGGROUP',
ADD_MAPTILE_SERVER: 'SET_MAPTILE_SERVER',
EDIT_MAPTILE_SERVER: 'EDIT_MAPTILE_SERVER',
- DELETE_MAPTILE_SERVER: 'DELETE_MAPTILE_SERVER'
+ DELETE_MAPTILE_SERVER: 'DELETE_MAPTILE_SERVER',
+ SET_STORED_SEARCHES_VISIBLE: 'SET_STORED_SEARCHES_VISIBLE',
+ SET_SHOW_BOOKMARKS: 'SET_SHOW_BOOKMARKS',
+ SET_FILE_OPEN_HISTORY: 'SET_FILE_OPEN_HISTORY',
+ SET_FOLDER_OPEN_HISTORY: 'SET_FOLDER_OPEN_HISTORY',
+ SET_FILE_EDIT_HISTORY: 'SET_FILE_EDIT_HISTORY'
};
export default (state: any = defaultSettings, action: any) => {
@@ -332,6 +337,36 @@ export default (state: any = defaultSettings, action: any) => {
lastPublishedVersion: action.lastPublishedVersion
};
}
+ case types.SET_STORED_SEARCHES_VISIBLE: {
+ return {
+ ...state,
+ storedSearchesVisible: action.storedSearchesVisible
+ };
+ }
+ case types.SET_SHOW_BOOKMARKS: {
+ return {
+ ...state,
+ showBookmarks: action.showBookmarks
+ };
+ }
+ case types.SET_FILE_OPEN_HISTORY: {
+ return {
+ ...state,
+ fileOpenHistory: action.fileOpenHistory
+ };
+ }
+ case types.SET_FOLDER_OPEN_HISTORY: {
+ return {
+ ...state,
+ folderOpenHistory: action.folderOpenHistory
+ };
+ }
+ case types.SET_FILE_EDIT_HISTORY: {
+ return {
+ ...state,
+ fileEditHistory: action.fileEditHistory
+ };
+ }
case types.TOGGLE_TAGGROUP: {
let tagGroupCollapsed;
if (state.tagGroupCollapsed) {
@@ -590,6 +625,26 @@ export const actions = {
type: types.SET_LAST_PUBLISHED_VERSION,
lastPublishedVersion
}),
+ setStoredSearchesVisible: (storedSearchesVisible: boolean) => ({
+ type: types.SET_STORED_SEARCHES_VISIBLE,
+ storedSearchesVisible
+ }),
+ setShowBookmarks: (showBookmarks: boolean) => ({
+ type: types.SET_SHOW_BOOKMARKS,
+ showBookmarks
+ }),
+ setFileOpenHistory: (fileOpenHistory: boolean) => ({
+ type: types.SET_FILE_OPEN_HISTORY,
+ fileOpenHistory
+ }),
+ setFolderOpenHistory: (folderOpenHistory: boolean) => ({
+ type: types.SET_FOLDER_OPEN_HISTORY,
+ folderOpenHistory
+ }),
+ setFileEditHistory: (fileEditHistory: boolean) => ({
+ type: types.SET_FILE_EDIT_HISTORY,
+ fileEditHistory
+ }),
checkForUpdate: () => (
dispatch: (actions: Object) => void
// getState: () => any
@@ -728,6 +783,15 @@ export const getTagDelimiter = (state: any) => state.settings.tagDelimiter;
export const getMaxSearchResults = (state: any) =>
state.settings.maxSearchResult;
export const isDesktopMode = (state: any) => state.settings.desktopMode;
+export const getStoredSearchesVisible = (state: any) =>
+ state.settings.storedSearchesVisible;
+export const getShowBookmarks = (state: any) => state.settings.showBookmarks;
+export const getFileOpenHistory = (state: any) =>
+ state.settings.fileOpenHistory;
+export const getFolderOpenHistory = (state: any) =>
+ state.settings.folderOpenHistory;
+export const getFileEditHistory = (state: any) =>
+ state.settings.fileEditHistory;
export const isFirstRun = (state: any) => {
if (typeof window.ExtIsFirstRun === 'undefined') {
return state.settings.firstRun;
diff --git a/app/tagspaces.namespace.d.ts b/app/tagspaces.namespace.d.ts
index 138abd92c..06a1eec71 100644
--- a/app/tagspaces.namespace.d.ts
+++ b/app/tagspaces.namespace.d.ts
@@ -150,6 +150,12 @@ export namespace TS {
creationTimeStamp: number;
}
+ interface BookmarkItem {
+ path: string;
+ url: string;
+ creationTimeStamp: number;
+ }
+
interface PerspectiveSettings {
grid?: FolderSettings;
list?: FolderSettings;