From b9057f6d56b7943f3d83020710a02d6378c0f5b2 Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Thu, 16 Oct 2025 11:16:44 +0200 Subject: [PATCH] frontend: separate views --- frontend/src/index.jsx | 35 +++++++++++++++++++-- frontend/src/sidebar/Sidebar.jsx | 52 +------------------------------- frontend/src/styles.css | 41 +++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 53 deletions(-) diff --git a/frontend/src/index.jsx b/frontend/src/index.jsx index 0248042..3a5b0a1 100644 --- a/frontend/src/index.jsx +++ b/frontend/src/index.jsx @@ -17,6 +17,7 @@ import { Outlet, useLocation, useNavigate, + useMatch, matchPath, } from 'react-router-dom'; import './styles.css'; @@ -397,6 +398,13 @@ const AppLayout = () => { const [searchQuery, setSearchQuery] = useState(''); const [activeTagFilters, setActiveTagFilters] = useState([]); const [activeCorrespondentFilters, setActiveCorrespondentFilters] = useState([]); + const documentsRouteMatch = useMatch('/documents'); + const documentsFolderRouteMatch = useMatch('/documents/folder/:folderId'); + const tagsRouteMatch = useMatch('/tags'); + const correspondentsRouteMatch = useMatch('/correspondents'); + const isDocumentsRoute = Boolean(documentsRouteMatch || documentsFolderRouteMatch); + const isTagsRoute = Boolean(tagsRouteMatch); + const isCorrespondentsRoute = Boolean(correspondentsRouteMatch); const toggleTagFilter = useCallback((tagId) => { if (!tagId) return; setActiveTagFilters((previous) => @@ -4239,11 +4247,9 @@ const AppLayout = () => { onFolderDragStart: handleFolderDragStart, onFolderDragEnd: handleFolderDragEnd, draggedFolderId, - onShowTags: () => navigate('/tags'), tags, activeTagIds: activeTagFilters, onToggleTagFilter: toggleTagFilter, - onShowCorrespondents: () => navigate('/correspondents'), correspondents, activeCorrespondentIds: activeCorrespondentFilters, onToggleCorrespondentFilter: toggleCorrespondentFilter, @@ -4489,6 +4495,31 @@ const AppLayout = () => { )}
+
+ + + +
{status && (
diff --git a/frontend/src/sidebar/Sidebar.jsx b/frontend/src/sidebar/Sidebar.jsx index 22a44e6..d31c5b8 100644 --- a/frontend/src/sidebar/Sidebar.jsx +++ b/frontend/src/sidebar/Sidebar.jsx @@ -1,13 +1,5 @@ import React, { useCallback, useMemo } from 'react'; -import { useMatch } from 'react-router-dom'; -import { - ChevronIcon, - FolderIcon, - TagIcon, - TrashIcon, - CorrespondentIcon, - EditIcon, -} from '../ui/icons'; +import { ChevronIcon, FolderIcon, TrashIcon, EditIcon } from '../ui/icons'; import { getTagColorStyle } from '../utils/colors'; const FolderNode = ({ @@ -137,21 +129,13 @@ const Sidebar = ({ onFolderDragStart, onFolderDragEnd, draggedFolderId, - onShowTags, tags = [], activeTagIds = [], onToggleTagFilter, - onShowCorrespondents, correspondents = [], activeCorrespondentIds = [], onToggleCorrespondentFilter, }) => { - const handleShowTags = onShowTags || (() => {}); - const tagsRouteMatch = useMatch('/tags'); - const isTagsRoute = Boolean(tagsRouteMatch); - const handleShowCorrespondents = onShowCorrespondents || (() => {}); - const correspondentsRouteMatch = useMatch('/correspondents'); - const isCorrespondentsRoute = Boolean(correspondentsRouteMatch); const sortedCorrespondents = useMemo( () => [...correspondents].sort((a, b) => @@ -224,21 +208,6 @@ const Sidebar = ({

Tags

{tags.length}
- { - if (event.key === 'Enter' || event.key === ' ') { - event.preventDefault(); - handleShowTags(); - } - }} - > - - All tags -
{tags.length ? ( tags.map((tag) => { @@ -269,25 +238,6 @@ const Sidebar = ({

Correspondents

{correspondents.length}
- { - onToggleCorrespondentFilter?.(null); - handleShowCorrespondents(); - }} - onKeyDown={(event) => { - if (event.key === 'Enter' || event.key === ' ') { - event.preventDefault(); - onToggleCorrespondentFilter?.(null); - handleShowCorrespondents(); - } - }} - > - - All correspondents -