Skip to content

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

chore: moving bookmark button to entry navigation

Ilian Sapundshievc0ecffdb9eae
diff --git a/src/renderer/components/EntryContainerNav.tsx b/src/renderer/components/EntryContainerNav.tsx
index e655cb589..ff0510701 100644
--- a/src/renderer/components/EntryContainerNav.tsx
+++ b/src/renderer/components/EntryContainerNav.tsx
@@ -1,16 +1,22 @@
import {
CloseIcon,
+ EntryBookmarkAddIcon,
+ EntryBookmarkIcon,
NextDocumentIcon,
PrevDocumentIcon,
} from '-/components/CommonIcons';
import TsIconButton from '-/components/TsIconButton';
+import { useNotificationContext } from '-/hooks/useNotificationContext';
+import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';
import { usePerspectiveActionsContext } from '-/hooks/usePerspectiveActionsContext';
+import { Pro } from '-/pro';
import { getKeyBindingObject } from '-/reducers/settings';
import { TS } from '-/tagspaces.namespace';
import { Box } from '@mui/material';
-import { useTheme } from '@mui/material/styles';
+import { useContext, useReducer } from 'react';
import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';
+import { ProTooltip } from './HelperComponents';
interface Props {
isFile: boolean;
@@ -22,8 +28,31 @@ function EntryContainerNav(props: Props) {
const { isFile, startClosingEntry, smallScreen } = props;
const { setActions } = usePerspectiveActionsContext();
const keyBindings = useSelector(getKeyBindingObject);
+ const { openedEntry, sharingLink, fileChanged } = useOpenedEntryContext();
+ const { showNotification } = useNotificationContext();
const { t } = useTranslation();
- const theme = useTheme();
+ const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);
+
+ const bookmarksContext = Pro?.contextProviders?.BookmarksContext
+ ? useContext<TS.BookmarksContextData>(Pro.contextProviders.BookmarksContext)
+ : undefined;
+
+ const bookmarkClick = () => {
+ if (Pro && bookmarksContext) {
+ if (bookmarksContext.haveBookmark(openedEntry.path)) {
+ bookmarksContext.delBookmark(openedEntry.path);
+ } else {
+ bookmarksContext.setBookmark(openedEntry.path, sharingLink);
+ }
+ forceUpdate();
+ } else {
+ showNotification(
+ t('core:toggleBookmark') +
+ ' - ' +
+ t('thisFunctionalityIsAvailableInPro'),
+ );
+ }
+ };
return (
<Box
@@ -36,6 +65,33 @@ function EntryContainerNav(props: Props) {
alignItems: 'center',
}}
>
+ <ProTooltip tooltip={t('core:toggleBookmark')}>
+ <TsIconButton
+ data-tid="toggleBookmarkTID"
+ aria-label="bookmark"
+ onClick={bookmarkClick}
+ sx={
+ {
+ WebkitAppRegion: 'no-drag',
+ } as React.CSSProperties & { WebkitAppRegion?: string }
+ }
+ >
+ {bookmarksContext &&
+ bookmarksContext.haveBookmark(openedEntry.path) ? (
+ <EntryBookmarkIcon
+ sx={{
+ color: 'primary.main',
+ }}
+ />
+ ) : (
+ <EntryBookmarkAddIcon
+ sx={{
+ color: 'text.secondary',
+ }}
+ />
+ )}
+ </TsIconButton>
+ </ProTooltip>
{isFile && (
<>
<TsIconButton
diff --git a/src/renderer/components/EntryContainerTitle.tsx b/src/renderer/components/EntryContainerTitle.tsx
index 097ad63b0..0a9c1895a 100644
--- a/src/renderer/components/EntryContainerTitle.tsx
+++ b/src/renderer/components/EntryContainerTitle.tsx
@@ -20,25 +20,19 @@ import AppConfig from '-/AppConfig';
import {
ArrowBackIcon,
EncryptedIcon,
- EntryBookmarkAddIcon,
- EntryBookmarkIcon,
FolderIcon,
MoreMenuIcon,
} from '-/components/CommonIcons';
import EntryContainerMenu from '-/components/EntryContainerMenu';
import FileExtBadge from '-/components/FileExtBadge';
-import { ProTooltip } from '-/components/HelperComponents';
import TagsPreview from '-/components/TagsPreview';
import Tooltip from '-/components/Tooltip';
import TsIconButton from '-/components/TsIconButton';
import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
-import { useNotificationContext } from '-/hooks/useNotificationContext';
import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';
-import { Pro } from '-/pro';
import { getSupportedFileTypes, getTagDelimiter } from '-/reducers/settings';
import { dataTidFormat } from '-/services/test';
import { findColorForEntry, getAllTags } from '-/services/utils-io';
-import { TS } from '-/tagspaces.namespace';
import Box from '@mui/material/Box';
import { useTheme } from '@mui/material/styles';
import {
@@ -47,7 +41,7 @@ import {
extractFileName,
extractTitle,
} from '@tagspaces/tagspaces-common/paths';
-import React, { useContext, useReducer } from 'react';
+import React from 'react';
import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';
@@ -73,36 +67,16 @@ function EntryContainerTitle(props: Props) {
const theme = useTheme();
const { openedEntry, sharingLink, fileChanged } = useOpenedEntryContext();
const { findLocation } = useCurrentLocationContext();
- const { showNotification } = useNotificationContext();
+
//const locations = useSelector(getLocations);
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
- const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);
+
const supportedFileTypes = useSelector(getSupportedFileTypes);
const tagDelimiter: string = useSelector(getTagDelimiter);
const fileSystemEntryColor = findColorForEntry(
openedEntry,
supportedFileTypes,
);
- const bookmarksContext = Pro?.contextProviders?.BookmarksContext
- ? useContext<TS.BookmarksContextData>(Pro.contextProviders.BookmarksContext)
- : undefined;
-
- const bookmarkClick = () => {
- if (Pro && bookmarksContext) {
- if (bookmarksContext.haveBookmark(openedEntry.path)) {
- bookmarksContext.delBookmark(openedEntry.path);
- } else {
- bookmarksContext.setBookmark(openedEntry.path, sharingLink);
- }
- forceUpdate();
- } else {
- showNotification(
- t('core:toggleBookmark') +
- ' - ' +
- t('thisFunctionalityIsAvailableInPro'),
- );
- }
- };
const currentLocation = findLocation(openedEntry.locationID);
let fileTitle: string = openedEntry.path
@@ -136,7 +110,7 @@ function EntryContainerTitle(props: Props) {
const addMacMargin =
AppConfig.isMacLike && desktopMode && (smallScreen || isEntryInFullWidth);
- const rightMargin = smallScreen ? '35px' : '70px';
+ const rightMargin = smallScreen ? '60px' : '95px';
return (
<Box
@@ -176,7 +150,7 @@ function EntryContainerTitle(props: Props) {
{fileChanged ? (
<Tooltip title={t('core:fileChanged')}>
<Box
- style={{
+ sx={{
color: theme.palette.text.primary,
margin: '3px',
}}
@@ -239,12 +213,12 @@ function EntryContainerTitle(props: Props) {
<Tooltip title={openedEntry.isFile && fileName}>
<Box
data-tid={'OpenedTID' + dataTidFormat(fileName)}
- style={{
+ sx={{
color: theme.palette.text.primary,
display: 'inline',
- fontSize: 17,
- marginLeft: 5,
- maxHeight: 40,
+ fontSize: '17px',
+ marginLeft: '5px',
+ maxHeight: '40px',
overflowY: 'auto',
overflowX: 'hidden',
}}
@@ -252,33 +226,6 @@ function EntryContainerTitle(props: Props) {
{fileTitle}
</Box>
</Tooltip>
- <ProTooltip tooltip={t('core:toggleBookmark')}>
- <TsIconButton
- data-tid="toggleBookmarkTID"
- aria-label="bookmark"
- onClick={bookmarkClick}
- sx={
- {
- WebkitAppRegion: 'no-drag',
- } as React.CSSProperties & { WebkitAppRegion?: string }
- }
- >
- {bookmarksContext &&
- bookmarksContext.haveBookmark(openedEntry.path) ? (
- <EntryBookmarkIcon
- sx={{
- color: 'primary.main',
- }}
- />
- ) : (
- <EntryBookmarkAddIcon
- sx={{
- color: 'text.secondary',
- }}
- />
- )}
- </TsIconButton>
- </ProTooltip>
<TagsPreview tags={getAllTags(openedEntry, tagDelimiter)} />
{openedEntry.isEncrypted && (
<Tooltip title={t('core:encryptedTooltip')}>
diff --git a/src/renderer/perspectives/index.tsx b/src/renderer/perspectives/index.tsx
index 91a16f448..659ba2160 100644
--- a/src/renderer/perspectives/index.tsx
+++ b/src/renderer/perspectives/index.tsx
@@ -85,7 +85,7 @@ export const FolderVizPerspectiveMeta = {
id: PerspectiveIDs.FOLDERVIZ,
key: 'openFolderVizPerspective',
pro: true,
- beta: false,
+ beta: true,
icon: <FolderVizPerspectiveIcon />,
title: 'FolderViz Perspective',
};