mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Add uncategorized collapsable labels section
This commit is contained in:
7 files changed
+77
-23
No files matched your search
@@ -1,7 +1,7 @@
|
||||
import React, { useEffect, useState, useMemo } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Plus, Folder, GitBranch, Loader2, ChevronDown, ChevronRight, Star, Columns2, X, Settings, HelpCircle, Search, Tag } from 'lucide-react';
|
||||
import { Plus, Folder, GitBranch, Loader2, ChevronDown, ChevronRight, Star, Columns2, X, Settings, HelpCircle, Search, Tag, Folders } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { Input } from '@/components/ui/input';
|
||||
@@ -131,6 +131,40 @@ const LabelGroupHeader: React.FC<LabelGroupHeaderProps> = ({
|
||||
);
|
||||
};
|
||||
|
||||
/** Other projects group header component */
|
||||
interface OtherProjectsGroupHeaderProps {
|
||||
isCollapsed: boolean;
|
||||
onToggle: () => void;
|
||||
projectCount?: number;
|
||||
}
|
||||
|
||||
const OtherProjectsGroupHeader: React.FC<OtherProjectsGroupHeaderProps> = ({
|
||||
isCollapsed,
|
||||
onToggle,
|
||||
projectCount = 0,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<button
|
||||
onClick={onToggle}
|
||||
className="w-full flex items-center gap-2 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors"
|
||||
>
|
||||
<Folders className="h-3.5 w-3.5 text-primary" />
|
||||
<span className="flex-1 text-left truncate">{t('otherProjects')}</span>
|
||||
{isCollapsed && projectCount > 0 && (
|
||||
<span className="text-xs text-muted-foreground/70">
|
||||
{projectCount}
|
||||
</span>
|
||||
)}
|
||||
<ChevronRight className={cn(
|
||||
"h-3.5 w-3.5 transition-transform duration-200",
|
||||
!isCollapsed && "rotate-90"
|
||||
)} />
|
||||
</button>
|
||||
);
|
||||
};
|
||||
|
||||
interface ProjectSidebarProps {
|
||||
selectedProject: Project | null;
|
||||
onSelectProject: (project: Project | null) => void;
|
||||
@@ -151,6 +185,7 @@ export function ProjectSidebar({
|
||||
const { data: projects = [], isLoading, error } = useProjects();
|
||||
const [favorites] = useLocalStorage<string[]>('project-favorites', []);
|
||||
const [searchQuery, setSearchQuery] = useState('');
|
||||
const [otherProjectsCollapsed, setOtherProjectsCollapsed] = useLocalStorage<boolean>('other-projects-collapsed', false);
|
||||
const { labels, toggleLabelCollapsed } = useLabels();
|
||||
const { getProjectLabels, hasAnyLabels } = useProjectLabels();
|
||||
|
||||
@@ -416,23 +451,36 @@ export function ProjectSidebar({
|
||||
);
|
||||
})}
|
||||
|
||||
{/* Unlabeled projects */}
|
||||
{/* Other projects (unlabeled) */}
|
||||
{groupedProjects.unlabeled.length > 0 && (
|
||||
<div className="space-y-0.5 mt-2">
|
||||
{labels.some(l => (groupedProjects.groups.get(l.id)?.length || 0) > 0) && (
|
||||
<div className="px-3 py-1.5">
|
||||
<Separator />
|
||||
</div>
|
||||
)}
|
||||
{groupedProjects.unlabeled.map((project) => (
|
||||
<ProjectItem
|
||||
key={project.id}
|
||||
project={project}
|
||||
isSelected={selectedProject?.id === project.id}
|
||||
onSelect={onSelectProject}
|
||||
isFavorite={favorites.includes(project.id)}
|
||||
/>
|
||||
))}
|
||||
<div className="mt-2">
|
||||
<Collapsible
|
||||
open={!otherProjectsCollapsed}
|
||||
onOpenChange={() => setOtherProjectsCollapsed(!otherProjectsCollapsed)}
|
||||
>
|
||||
<CollapsibleTrigger asChild>
|
||||
<div>
|
||||
<OtherProjectsGroupHeader
|
||||
isCollapsed={otherProjectsCollapsed}
|
||||
onToggle={() => setOtherProjectsCollapsed(!otherProjectsCollapsed)}
|
||||
projectCount={groupedProjects.unlabeled.length}
|
||||
/>
|
||||
</div>
|
||||
</CollapsibleTrigger>
|
||||
<CollapsibleContent>
|
||||
<div className="space-y-0.5">
|
||||
{groupedProjects.unlabeled.map((project) => (
|
||||
<ProjectItem
|
||||
key={project.id}
|
||||
project={project}
|
||||
isSelected={selectedProject?.id === project.id}
|
||||
onSelect={onSelectProject}
|
||||
isFavorite={favorites.includes(project.id)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</CollapsibleContent>
|
||||
</Collapsible>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
+2
-1
@@ -538,5 +538,6 @@
|
||||
"addLabel": "Add label",
|
||||
"selectLabels": "Select labels",
|
||||
"noLabelsCreated": "No labels created yet",
|
||||
"createNewLabel": "Create new label"
|
||||
"createNewLabel": "Create new label",
|
||||
"otherProjects": "Other projects"
|
||||
}
|
||||
+2
-1
@@ -445,5 +445,6 @@
|
||||
"addLabel": "Ƙara lakabi",
|
||||
"selectLabels": "Zaɓi lakabi",
|
||||
"noLabelsCreated": "Ba a ƙirƙiri lakabi tukuna ba",
|
||||
"createNewLabel": "Ƙirƙiri sabon lakabi"
|
||||
"createNewLabel": "Ƙirƙiri sabon lakabi",
|
||||
"otherProjects": "Sauran ayyuka"
|
||||
}
|
||||
+2
-1
@@ -442,5 +442,6 @@
|
||||
"addLabel": "Tinye akara",
|
||||
"selectLabels": "Họrọ akara",
|
||||
"noLabelsCreated": "Emepụtaghị akara ọ bụla",
|
||||
"createNewLabel": "Mepụta akara ọhụrụ"
|
||||
"createNewLabel": "Mepụta akara ọhụrụ",
|
||||
"otherProjects": "Ọrụ ndị ọzọ"
|
||||
}
|
||||
+2
-1
@@ -454,5 +454,6 @@
|
||||
"addLabel": "Adicionar etiqueta",
|
||||
"selectLabels": "Selecionar etiquetas",
|
||||
"noLabelsCreated": "Nenhuma etiqueta criada ainda",
|
||||
"createNewLabel": "Criar nova etiqueta"
|
||||
"createNewLabel": "Criar nova etiqueta",
|
||||
"otherProjects": "Outros projetos"
|
||||
}
|
||||
+2
-1
@@ -442,5 +442,6 @@
|
||||
"addLabel": "Fi àmì kún",
|
||||
"selectLabels": "Yan àmì",
|
||||
"noLabelsCreated": "A kò tí ì ṣẹ̀dá àmì kankan",
|
||||
"createNewLabel": "Ṣẹ̀dá àmì tuntun"
|
||||
"createNewLabel": "Ṣẹ̀dá àmì tuntun",
|
||||
"otherProjects": "Àwọn iṣẹ́ mìíràn"
|
||||
}
|
||||
+2
-1
@@ -454,5 +454,6 @@
|
||||
"addLabel": "添加标签",
|
||||
"selectLabels": "选择标签",
|
||||
"noLabelsCreated": "尚未创建标签",
|
||||
"createNewLabel": "创建新标签"
|
||||
"createNewLabel": "创建新标签",
|
||||
"otherProjects": "其他项目"
|
||||
}
|
||||
Reference in new issue
Block a user