From 63d23f551079fb4d960583386e187dac5186509a Mon Sep 17 00:00:00 2001 From: MK Fain Date: Wed, 3 Dec 2025 13:25:35 -0600 Subject: [PATCH] Add project labels feature similar to Gmail labels Features: - Create and manage labels with customizable colors (18 color options) - Assign multiple labels to projects via Project Details dialog - Display settings in Preferences (only shown when labels exist): - Colored folder icons: Show project folder icons in label color - Group by label: Organize sidebar projects into collapsible groups - Labels work alongside existing favorites (starred) system: - Favorites still sort to top within label groups - Star indicator remains visible in all display modes - Collapsible label groups in sidebar (state persists) - Unlabeled projects shown at bottom when grouping is enabled - No UI changes for users without labels (settings hidden until first label) Technical: - useLabels hook: Manage labels CRUD and display settings - useProjectLabels hook: Manage project-label assignments - LabelSelector component: Assign labels to projects - LabelsManageDialog: Create, edit, delete labels - Full i18n support for EN, PT, ZH, HA, YO, IG --- src/components/ProjectDetailsDialog.tsx | 11 + src/components/ProjectSidebar.tsx | 193 +++++++++++++- src/components/labels/LabelSelector.tsx | 152 +++++++++++ src/components/labels/LabelsManageDialog.tsx | 251 +++++++++++++++++++ src/components/labels/index.ts | 2 + src/hooks/useLabels.ts | 118 +++++++++ src/hooks/useProjectLabels.ts | 83 ++++++ src/locales/en.json | 21 +- src/locales/ha.json | 21 +- src/locales/ig.json | 21 +- src/locales/pt.json | 21 +- src/locales/yo.json | 21 +- src/locales/zh.json | 21 +- src/pages/Preferences.tsx | 84 ++++++- 14 files changed, 1009 insertions(+), 11 deletions(-) create mode 100644 src/components/labels/LabelSelector.tsx create mode 100644 src/components/labels/LabelsManageDialog.tsx create mode 100644 src/components/labels/index.ts create mode 100644 src/hooks/useLabels.ts create mode 100644 src/hooks/useProjectLabels.ts diff --git a/src/components/ProjectDetailsDialog.tsx b/src/components/ProjectDetailsDialog.tsx index 6ce4a5fe..106f35f1 100644 --- a/src/components/ProjectDetailsDialog.tsx +++ b/src/components/ProjectDetailsDialog.tsx @@ -36,10 +36,12 @@ import { DollarSign, ExternalLink, FileCode, + Tag, } from 'lucide-react'; import JSZip from 'jszip'; import { Separator } from './ui/separator'; import { DotAI } from '@/lib/DotAI'; +import { LabelSelector } from '@/components/labels/LabelSelector'; interface ProjectDetailsDialogProps { project: Project; @@ -283,6 +285,15 @@ export function ProjectDetailsDialog({ project, open, onOpenChange, onProjectDel )} + {/* Labels */} +
+ + +
+ {/* Project Name */}
diff --git a/src/components/ProjectSidebar.tsx b/src/components/ProjectSidebar.tsx index f2cd9c7d..ff68dca7 100644 --- a/src/components/ProjectSidebar.tsx +++ b/src/components/ProjectSidebar.tsx @@ -1,15 +1,18 @@ import React, { useEffect, useState, useMemo } from 'react'; import { useNavigate } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; -import { Plus, Folder, GitBranch, Loader2, ChevronDown, Star, Columns2, X, Settings, HelpCircle, Search } from 'lucide-react'; +import { Plus, Folder, GitBranch, Loader2, ChevronDown, ChevronRight, Star, Columns2, X, Settings, HelpCircle, Search } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Skeleton } from '@/components/ui/skeleton'; import { Input } from '@/components/ui/input'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '@/components/ui/dropdown-menu'; +import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible'; import { useProjects } from '@/hooks/useProjects'; import { useProjectSessionStatus } from '@/hooks/useProjectSessionStatus'; import { useLocalStorage } from '@/hooks/useLocalStorage'; import { useIsMobile } from '@/hooks/useIsMobile'; +import { useLabels, getLabelColor } from '@/hooks/useLabels'; +import { useProjectLabels } from '@/hooks/useProjectLabels'; import type { Project } from '@/lib/ProjectsManager'; import { cn } from '@/lib/utils'; import { useQueryClient } from '@tanstack/react-query'; @@ -20,9 +23,18 @@ interface ProjectItemProps { isSelected: boolean; onSelect: (project: Project) => void; isFavorite?: boolean; + labelColor?: string; + showColoredIcon?: boolean; } -const ProjectItem: React.FC = ({ project, isSelected, onSelect, isFavorite }) => { +const ProjectItem: React.FC = ({ + project, + isSelected, + onSelect, + isFavorite, + labelColor, + showColoredIcon = false, +}) => { const navigate = useNavigate(); const { hasRunningSessions } = useProjectSessionStatus(project.id); @@ -31,6 +43,15 @@ const ProjectItem: React.FC = ({ project, isSelected, onSelect navigate(`/project/${project.id}`); }; + // Determine folder icon color + const getFolderColorClass = () => { + if (showColoredIcon && labelColor) { + const colorConfig = getLabelColor(labelColor as Parameters[0]); + return colorConfig.text; + } + return 'text-primary'; + }; + return (
= ({ project, isSelected, onSelect {hasRunningSessions ? ( ) : ( - + )}
@@ -75,6 +96,41 @@ const ProjectItem: React.FC = ({ project, isSelected, onSelect ProjectItem.displayName = 'ProjectItem'; +/** Label group header component */ +interface LabelGroupHeaderProps { + labelName: string; + labelColor: string; + isCollapsed: boolean; + onToggle: () => void; + projectCount: number; +} + +const LabelGroupHeader: React.FC = ({ + labelName, + labelColor, + isCollapsed, + onToggle, + projectCount, +}) => { + const colorConfig = getLabelColor(labelColor as Parameters[0]); + + return ( + + ); +}; + interface ProjectSidebarProps { selectedProject: Project | null; onSelectProject: (project: Project | null) => void; @@ -95,10 +151,15 @@ export function ProjectSidebar({ const { data: projects = [], isLoading, error } = useProjects(); const [favorites] = useLocalStorage('project-favorites', []); const [searchQuery, setSearchQuery] = useState(''); + const { labels, displaySettings, toggleLabelCollapsed } = useLabels(); + const { getProjectLabels, hasAnyLabels } = useProjectLabels(); const isMobile = useIsMobile(); const navigate = useNavigate(); + // Determine if we should show grouped view + const showGroupedView = displaySettings.groupByLabel && labels.length > 0 && hasAnyLabels(); + // Fast in-memory search filtering const filteredProjects = useMemo(() => { if (!searchQuery.trim()) { @@ -112,6 +173,65 @@ export function ProjectSidebar({ ); }, [projects, searchQuery]); + // Group projects by label for grouped view + const groupedProjects = useMemo(() => { + if (!showGroupedView) return null; + + const groups: Map = new Map(); + const unlabeled: Project[] = []; + + // Initialize groups for each label in order + for (const label of labels) { + groups.set(label.id, []); + } + + // Sort projects into groups + for (const project of filteredProjects) { + const projectLabelIds = getProjectLabels(project.id); + if (projectLabelIds.length === 0) { + unlabeled.push(project); + } else { + // Add project to the first label group (primary label) + const primaryLabelId = projectLabelIds[0]; + const group = groups.get(primaryLabelId); + if (group) { + group.push(project); + } else { + // Label might have been deleted + unlabeled.push(project); + } + } + } + + // Sort each group: favorites first, then by lastModified + const sortGroup = (projectList: Project[]) => { + return projectList.sort((a, b) => { + const aIsFavorite = favorites.includes(a.id); + const bIsFavorite = favorites.includes(b.id); + if (aIsFavorite && !bIsFavorite) return -1; + if (!aIsFavorite && bIsFavorite) return 1; + return b.lastModified.getTime() - a.lastModified.getTime(); + }); + }; + + for (const [labelId, projectList] of groups) { + groups.set(labelId, sortGroup(projectList)); + } + + return { + groups, + unlabeled: sortGroup(unlabeled), + }; + }, [showGroupedView, labels, filteredProjects, getProjectLabels, favorites]); + + // Get the first label color for a project (for colored icon display) + const getProjectLabelColor = (projectId: string): string | undefined => { + const projectLabelIds = getProjectLabels(projectId); + if (projectLabelIds.length === 0) return undefined; + const label = labels.find(l => l.id === projectLabelIds[0]); + return label?.color; + }; + // Custom navigate function that closes sidebar on mobile const navigateAndClose = (path: string) => { navigate(path); @@ -249,7 +369,72 @@ export function ProjectSidebar({

{t('noProjectsFound')}

{t('tryDifferentSearch')}

+ ) : showGroupedView && groupedProjects ? ( + // Grouped view by labels +
+ {/* Render each label group */} + {labels.map((label) => { + const groupProjects = groupedProjects.groups.get(label.id) || []; + if (groupProjects.length === 0) return null; + + return ( + toggleLabelCollapsed(label.id)} + > + +
+ toggleLabelCollapsed(label.id)} + projectCount={groupProjects.length} + /> +
+
+ +
+ {groupProjects.map((project) => ( + + ))} +
+
+
+ ); + })} + + {/* Unlabeled projects */} + {groupedProjects.unlabeled.length > 0 && ( +
+ {labels.some(l => (groupedProjects.groups.get(l.id)?.length || 0) > 0) && ( +
+ {t('unlabeled')} +
+ )} + {groupedProjects.unlabeled.map((project) => ( + + ))} +
+ )} +
) : ( + // Flat view (default)
{filteredProjects.map((project) => ( ))}
diff --git a/src/components/labels/LabelSelector.tsx b/src/components/labels/LabelSelector.tsx new file mode 100644 index 00000000..cec82beb --- /dev/null +++ b/src/components/labels/LabelSelector.tsx @@ -0,0 +1,152 @@ +import { useState } from 'react'; +import { useTranslation } from 'react-i18next'; +import { Check, Plus, Tag } from 'lucide-react'; +import { Button } from '@/components/ui/button'; +import { + Popover, + PopoverContent, + PopoverTrigger, +} from '@/components/ui/popover'; +import { ScrollArea } from '@/components/ui/scroll-area'; +import { Separator } from '@/components/ui/separator'; +import { useLabels, getLabelColor, type Label } from '@/hooks/useLabels'; +import { useProjectLabels } from '@/hooks/useProjectLabels'; +import { LabelsManageDialog } from './LabelsManageDialog'; +import { cn } from '@/lib/utils'; + +interface LabelSelectorProps { + projectId: string; + /** Render as a compact badge list (for inline display) */ + compact?: boolean; +} + +export function LabelSelector({ projectId, compact }: LabelSelectorProps) { + const { t } = useTranslation(); + const { labels } = useLabels(); + const { getProjectLabels, addLabelToProject, removeLabelFromProject } = useProjectLabels(); + const [open, setOpen] = useState(false); + const [manageDialogOpen, setManageDialogOpen] = useState(false); + + const projectLabelIds = getProjectLabels(projectId); + const projectLabels = labels.filter(label => projectLabelIds.includes(label.id)); + + const handleToggleLabel = (label: Label) => { + if (projectLabelIds.includes(label.id)) { + removeLabelFromProject(projectId, label.id); + } else { + addLabelToProject(projectId, label.id); + } + }; + + if (compact) { + return ( +
+ {projectLabels.map((label) => { + const colorConfig = getLabelColor(label.color); + return ( + + {label.name} + + ); + })} +
+ ); + } + + return ( + <> + + + + + +
+

+ {t('selectLabels')} +

+
+ + {labels.length > 0 ? ( + +
+ {labels.map((label) => { + const colorConfig = getLabelColor(label.color); + const isSelected = projectLabelIds.includes(label.id); + return ( + + ); + })} +
+
+ ) : ( +
+ {t('noLabelsCreated')} +
+ )} + + + +
+ +
+
+
+ + + + ); +} diff --git a/src/components/labels/LabelsManageDialog.tsx b/src/components/labels/LabelsManageDialog.tsx new file mode 100644 index 00000000..db5e08dd --- /dev/null +++ b/src/components/labels/LabelsManageDialog.tsx @@ -0,0 +1,251 @@ +import { useState } from 'react'; +import { useTranslation } from 'react-i18next'; +import { Plus, Trash2, GripVertical, Pencil, Check, X } from 'lucide-react'; +import { + Dialog, + DialogContent, + DialogHeader, + DialogTitle, +} from '@/components/ui/dialog'; +import { Button } from '@/components/ui/button'; +import { Input } from '@/components/ui/input'; +import { Label } from '@/components/ui/label'; +import { ScrollArea } from '@/components/ui/scroll-area'; +import { + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, +} from '@/components/ui/alert-dialog'; +import { useLabels, LABEL_COLORS, getLabelColor, type LabelColorName, type Label as LabelType } from '@/hooks/useLabels'; +import { useProjectLabels } from '@/hooks/useProjectLabels'; +import { cn } from '@/lib/utils'; + +interface LabelsManageDialogProps { + open: boolean; + onOpenChange: (open: boolean) => void; +} + +interface LabelItemProps { + label: LabelType; + onEdit: (label: LabelType) => void; + onDelete: (label: LabelType) => void; + projectCount: number; +} + +function LabelItem({ label, onEdit, onDelete, projectCount }: LabelItemProps) { + const colorConfig = getLabelColor(label.color); + + return ( +
+ +
+ {label.name} + + {projectCount} {projectCount === 1 ? 'project' : 'projects'} + + + +
+ ); +} + +interface LabelFormProps { + initialName?: string; + initialColor?: LabelColorName; + onSave: (name: string, color: LabelColorName) => void; + onCancel: () => void; + isEditing?: boolean; +} + +function LabelForm({ initialName = '', initialColor = 'blue', onSave, onCancel, isEditing }: LabelFormProps) { + const { t } = useTranslation(); + const [name, setName] = useState(initialName); + const [color, setColor] = useState(initialColor); + + const handleSubmit = (e: React.FormEvent) => { + e.preventDefault(); + if (name.trim()) { + onSave(name.trim(), color); + } + }; + + return ( +
+
+ + setName(e.target.value)} + placeholder={t('enterLabelName')} + autoFocus + /> +
+ +
+ +
+ {LABEL_COLORS.map((colorOption) => ( +
+
+ +
+ + +
+
+ ); +} + +export function LabelsManageDialog({ open, onOpenChange }: LabelsManageDialogProps) { + const { t } = useTranslation(); + const { labels, createLabel, updateLabel, deleteLabel } = useLabels(); + const { getProjectsByLabel, removeLabel: removeLabelFromProjects } = useProjectLabels(); + + const [showCreateForm, setShowCreateForm] = useState(false); + const [editingLabel, setEditingLabel] = useState(null); + const [deletingLabel, setDeletingLabel] = useState(null); + + const handleCreateLabel = (name: string, color: LabelColorName) => { + createLabel(name, color); + setShowCreateForm(false); + }; + + const handleUpdateLabel = (name: string, color: LabelColorName) => { + if (editingLabel) { + updateLabel(editingLabel.id, { name, color }); + setEditingLabel(null); + } + }; + + const handleConfirmDelete = () => { + if (deletingLabel) { + // Remove label from all projects first + removeLabelFromProjects(deletingLabel.id); + // Then delete the label itself + deleteLabel(deletingLabel.id); + setDeletingLabel(null); + } + }; + + return ( + <> + + + + + {t('manageLabels')} + + + +
+ {/* Create new label button/form */} + {showCreateForm ? ( + setShowCreateForm(false)} + /> + ) : editingLabel ? ( + setEditingLabel(null)} + isEditing + /> + ) : ( + + )} + + {/* Labels list */} + {labels.length > 0 ? ( + +
+ {labels.map((label) => ( + + ))} +
+
+ ) : !showCreateForm && ( +
+

{t('noLabelsYet')}

+

{t('createLabelToOrganize')}

+
+ )} +
+
+
+ + {/* Delete confirmation dialog */} + setDeletingLabel(null)}> + + + {t('deleteLabel')} + + {t('deleteLabelConfirmation', { name: deletingLabel?.name })} + + + + {t('cancel')} + + {t('delete')} + + + + + + ); +} diff --git a/src/components/labels/index.ts b/src/components/labels/index.ts new file mode 100644 index 00000000..ce8a2a70 --- /dev/null +++ b/src/components/labels/index.ts @@ -0,0 +1,2 @@ +export { LabelsManageDialog } from './LabelsManageDialog'; +export { LabelSelector } from './LabelSelector'; diff --git a/src/hooks/useLabels.ts b/src/hooks/useLabels.ts new file mode 100644 index 00000000..ff9787f7 --- /dev/null +++ b/src/hooks/useLabels.ts @@ -0,0 +1,118 @@ +import { useLocalStorage } from '@/hooks/useLocalStorage'; + +/** Predefined label colors */ +export const LABEL_COLORS = [ + { name: 'red', bg: 'bg-red-500', text: 'text-red-500', hover: 'hover:bg-red-500/20' }, + { name: 'orange', bg: 'bg-orange-500', text: 'text-orange-500', hover: 'hover:bg-orange-500/20' }, + { name: 'amber', bg: 'bg-amber-500', text: 'text-amber-500', hover: 'hover:bg-amber-500/20' }, + { name: 'yellow', bg: 'bg-yellow-500', text: 'text-yellow-500', hover: 'hover:bg-yellow-500/20' }, + { name: 'lime', bg: 'bg-lime-500', text: 'text-lime-500', hover: 'hover:bg-lime-500/20' }, + { name: 'green', bg: 'bg-green-500', text: 'text-green-500', hover: 'hover:bg-green-500/20' }, + { name: 'emerald', bg: 'bg-emerald-500', text: 'text-emerald-500', hover: 'hover:bg-emerald-500/20' }, + { name: 'teal', bg: 'bg-teal-500', text: 'text-teal-500', hover: 'hover:bg-teal-500/20' }, + { name: 'cyan', bg: 'bg-cyan-500', text: 'text-cyan-500', hover: 'hover:bg-cyan-500/20' }, + { name: 'sky', bg: 'bg-sky-500', text: 'text-sky-500', hover: 'hover:bg-sky-500/20' }, + { name: 'blue', bg: 'bg-blue-500', text: 'text-blue-500', hover: 'hover:bg-blue-500/20' }, + { name: 'indigo', bg: 'bg-indigo-500', text: 'text-indigo-500', hover: 'hover:bg-indigo-500/20' }, + { name: 'violet', bg: 'bg-violet-500', text: 'text-violet-500', hover: 'hover:bg-violet-500/20' }, + { name: 'purple', bg: 'bg-purple-500', text: 'text-purple-500', hover: 'hover:bg-purple-500/20' }, + { name: 'fuchsia', bg: 'bg-fuchsia-500', text: 'text-fuchsia-500', hover: 'hover:bg-fuchsia-500/20' }, + { name: 'pink', bg: 'bg-pink-500', text: 'text-pink-500', hover: 'hover:bg-pink-500/20' }, + { name: 'rose', bg: 'bg-rose-500', text: 'text-rose-500', hover: 'hover:bg-rose-500/20' }, + { name: 'gray', bg: 'bg-gray-500', text: 'text-gray-500', hover: 'hover:bg-gray-500/20' }, +] as const; + +export type LabelColorName = typeof LABEL_COLORS[number]['name']; + +export interface Label { + id: string; + name: string; + color: LabelColorName; + order: number; + collapsed?: boolean; +} + +export interface LabelDisplaySettings { + /** Show colored folder icons for labeled projects */ + showColoredIcons: boolean; + /** Group projects by label in sidebar */ + groupByLabel: boolean; +} + +const DEFAULT_DISPLAY_SETTINGS: LabelDisplaySettings = { + showColoredIcons: false, + groupByLabel: false, +}; + +/** Get the color config for a label color name */ +export function getLabelColor(colorName: LabelColorName) { + return LABEL_COLORS.find(c => c.name === colorName) || LABEL_COLORS[0]; +} + +/** Generate a unique label ID */ +function generateLabelId(): string { + return `label-${Date.now()}-${Math.random().toString(36).substring(2, 7)}`; +} + +/** + * Hook for managing labels (creating, editing, deleting labels) + */ +export function useLabels() { + const [labels, setLabels] = useLocalStorage('project-labels', []); + const [displaySettings, setDisplaySettings] = useLocalStorage( + 'project-labels-display', + DEFAULT_DISPLAY_SETTINGS + ); + + const createLabel = (name: string, color: LabelColorName): Label => { + const maxOrder = labels.length > 0 ? Math.max(...labels.map(l => l.order)) : -1; + const newLabel: Label = { + id: generateLabelId(), + name, + color, + order: maxOrder + 1, + }; + setLabels([...labels, newLabel]); + return newLabel; + }; + + const updateLabel = (labelId: string, updates: Partial>) => { + setLabels(labels.map(label => + label.id === labelId ? { ...label, ...updates } : label + )); + }; + + const deleteLabel = (labelId: string) => { + setLabels(labels.filter(label => label.id !== labelId)); + }; + + const reorderLabels = (orderedIds: string[]) => { + setLabels(labels.map(label => ({ + ...label, + order: orderedIds.indexOf(label.id), + })).sort((a, b) => a.order - b.order)); + }; + + const toggleLabelCollapsed = (labelId: string) => { + setLabels(labels.map(label => + label.id === labelId ? { ...label, collapsed: !label.collapsed } : label + )); + }; + + const updateDisplaySettings = (updates: Partial) => { + setDisplaySettings({ ...displaySettings, ...updates }); + }; + + const sortedLabels = [...labels].sort((a, b) => a.order - b.order); + + return { + labels: sortedLabels, + displaySettings, + createLabel, + updateLabel, + deleteLabel, + reorderLabels, + toggleLabelCollapsed, + updateDisplaySettings, + }; +} diff --git a/src/hooks/useProjectLabels.ts b/src/hooks/useProjectLabels.ts new file mode 100644 index 00000000..97cccbaa --- /dev/null +++ b/src/hooks/useProjectLabels.ts @@ -0,0 +1,83 @@ +import { useLocalStorage } from '@/hooks/useLocalStorage'; + +/** Map of project IDs to their assigned label IDs */ +type ProjectLabelsMap = Record; + +/** + * Hook for managing project-label associations + */ +export function useProjectLabels() { + const [projectLabels, setProjectLabels] = useLocalStorage('project-label-assignments', {}); + + const getProjectLabels = (projectId: string): string[] => { + return projectLabels[projectId] || []; + }; + + const addLabelToProject = (projectId: string, labelId: string) => { + const currentLabels = projectLabels[projectId] || []; + if (!currentLabels.includes(labelId)) { + setProjectLabels({ + ...projectLabels, + [projectId]: [...currentLabels, labelId], + }); + } + }; + + const removeLabelFromProject = (projectId: string, labelId: string) => { + const currentLabels = projectLabels[projectId] || []; + const newLabels = currentLabels.filter(id => id !== labelId); + if (newLabels.length === 0) { + const { [projectId]: _, ...rest } = projectLabels; + setProjectLabels(rest); + } else { + setProjectLabels({ + ...projectLabels, + [projectId]: newLabels, + }); + } + }; + + const setProjectLabelsList = (projectId: string, labelIds: string[]) => { + if (labelIds.length === 0) { + const { [projectId]: _, ...rest } = projectLabels; + setProjectLabels(rest); + } else { + setProjectLabels({ + ...projectLabels, + [projectId]: labelIds, + }); + } + }; + + const getProjectsByLabel = (labelId: string): string[] => { + return Object.entries(projectLabels) + .filter(([_, labels]) => labels.includes(labelId)) + .map(([projectId]) => projectId); + }; + + const hasAnyLabels = (): boolean => { + return Object.keys(projectLabels).length > 0; + }; + + const removeLabel = (labelId: string) => { + const newProjectLabels: ProjectLabelsMap = {}; + for (const [projectId, labels] of Object.entries(projectLabels)) { + const filtered = labels.filter(id => id !== labelId); + if (filtered.length > 0) { + newProjectLabels[projectId] = filtered; + } + } + setProjectLabels(newProjectLabels); + }; + + return { + projectLabels, + getProjectLabels, + addLabelToProject, + removeLabelFromProject, + setProjectLabelsList, + getProjectsByLabel, + hasAnyLabels, + removeLabel, + }; +} diff --git a/src/locales/en.json b/src/locales/en.json index 3de166bf..b29fa215 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -524,5 +524,24 @@ "templateDeleted": "Template Deleted", "templateDeletedDescription": "Project template '{{name}}' has been deleted.", "noTemplatesConfigured": "No project templates configured yet. Add a template to get started.", - "atLeastOneTemplateRequired": "At least one template is required" + "atLeastOneTemplateRequired": "At least one template is required", + "projectLabels": "Project Labels", + "manageLabels": "Manage Labels", + "createLabel": "Create Label", + "labelName": "Label Name", + "enterLabelName": "Enter label name", + "labelColor": "Color", + "deleteLabel": "Delete Label", + "deleteLabelConfirmation": "Are you sure you want to delete the label \"{{name}}\"? This will remove the label from all projects.", + "noLabelsYet": "No labels yet", + "createLabelToOrganize": "Create a label to organize your projects", + "addLabel": "Add label", + "selectLabels": "Select labels", + "noLabelsCreated": "No labels created yet", + "createNewLabel": "Create new label", + "showColoredIcons": "Colored folder icons", + "showColoredIconsDescription": "Show the folder icon in the label's color for labeled projects.", + "groupByLabel": "Group by label", + "groupByLabelDescription": "Organize projects into collapsible groups based on their labels.", + "unlabeled": "Unlabeled" } diff --git a/src/locales/ha.json b/src/locales/ha.json index 0e1f8494..1ea6f6e2 100644 --- a/src/locales/ha.json +++ b/src/locales/ha.json @@ -431,5 +431,24 @@ "modified": "An Canza", "restoreToDefault": "Mayar da asali", "restoredToDefault": "An Mayar da Asali", - "terminal": "Terminal" + "terminal": "Terminal", + "projectLabels": "Lakabi na Aiki", + "manageLabels": "Sarrafa Lakabi", + "createLabel": "Ƙirƙiri Lakabi", + "labelName": "Sunan Lakabi", + "enterLabelName": "Shigar da sunan lakabi", + "labelColor": "Launi", + "deleteLabel": "Goge Lakabi", + "deleteLabelConfirmation": "Ka tabbata kana son goge lakabi \"{{name}}\"? Wannan zai cire lakabi daga duk ayyuka.", + "noLabelsYet": "Babu lakabi tukuna", + "createLabelToOrganize": "Ƙirƙiri lakabi don tsara ayyukanka", + "addLabel": "Ƙara lakabi", + "selectLabels": "Zaɓi lakabi", + "noLabelsCreated": "Ba a ƙirƙiri lakabi tukuna ba", + "createNewLabel": "Ƙirƙiri sabon lakabi", + "showColoredIcons": "Alamomin fayil masu launi", + "showColoredIconsDescription": "Nuna alamar fayil a launin lakabi don ayyukan da aka yi musu lakabi.", + "groupByLabel": "Haɗa da lakabi", + "groupByLabelDescription": "Tsara ayyuka cikin ƙungiyoyi masu rufewa dangane da lakabin su.", + "unlabeled": "Babu lakabi" } diff --git a/src/locales/ig.json b/src/locales/ig.json index bb561264..9447e0c1 100644 --- a/src/locales/ig.json +++ b/src/locales/ig.json @@ -428,5 +428,24 @@ "modified": "Gbanwere", "restoreToDefault": "Weghachi na nke mbụ", "restoredToDefault": "Weghachiri na Nke Mbụ", - "terminal": "Terminal" + "terminal": "Terminal", + "projectLabels": "Akara Ọrụ", + "manageLabels": "Jikwaa Akara", + "createLabel": "Mepụta Akara", + "labelName": "Aha Akara", + "enterLabelName": "Tinye aha akara", + "labelColor": "Agba", + "deleteLabel": "Hichapụ Akara", + "deleteLabelConfirmation": "Ị jiri n'ezie chọrọ ihichapụ akara \"{{name}}\"? Nke a ga-ewepụ akara ahụ n'ọrụ niile.", + "noLabelsYet": "Enweghị akara ugbu a", + "createLabelToOrganize": "Mepụta akara iji hazie ọrụ gị", + "addLabel": "Tinye akara", + "selectLabels": "Họrọ akara", + "noLabelsCreated": "Emepụtaghị akara ọ bụla", + "createNewLabel": "Mepụta akara ọhụrụ", + "showColoredIcons": "Akara nchekwa nwere agba", + "showColoredIconsDescription": "Gosi akara nchekwa n'agba akara maka ọrụ nwere akara.", + "groupByLabel": "Kekọta site n'akara", + "groupByLabelDescription": "Hazie ọrụ n'ime otu ndị a pụrụ imechi dabere n'akara ha.", + "unlabeled": "Enweghị akara" } diff --git a/src/locales/pt.json b/src/locales/pt.json index 0e178635..0623c62b 100644 --- a/src/locales/pt.json +++ b/src/locales/pt.json @@ -440,5 +440,24 @@ "modified": "Modificado", "restoreToDefault": "Restaurar para padrão", "restoredToDefault": "Restaurado para Padrão", - "terminal": "Terminal" + "terminal": "Terminal", + "projectLabels": "Etiquetas de Projeto", + "manageLabels": "Gerenciar Etiquetas", + "createLabel": "Criar Etiqueta", + "labelName": "Nome da Etiqueta", + "enterLabelName": "Digite o nome da etiqueta", + "labelColor": "Cor", + "deleteLabel": "Excluir Etiqueta", + "deleteLabelConfirmation": "Tem certeza de que deseja excluir a etiqueta \"{{name}}\"? Isso removerá a etiqueta de todos os projetos.", + "noLabelsYet": "Nenhuma etiqueta ainda", + "createLabelToOrganize": "Crie uma etiqueta para organizar seus projetos", + "addLabel": "Adicionar etiqueta", + "selectLabels": "Selecionar etiquetas", + "noLabelsCreated": "Nenhuma etiqueta criada ainda", + "createNewLabel": "Criar nova etiqueta", + "showColoredIcons": "Ícones de pasta coloridos", + "showColoredIconsDescription": "Mostrar o ícone da pasta na cor da etiqueta para projetos etiquetados.", + "groupByLabel": "Agrupar por etiqueta", + "groupByLabelDescription": "Organizar projetos em grupos recolhíveis com base em suas etiquetas.", + "unlabeled": "Sem etiqueta" } diff --git a/src/locales/yo.json b/src/locales/yo.json index 9941194d..d3c28ec1 100644 --- a/src/locales/yo.json +++ b/src/locales/yo.json @@ -428,5 +428,24 @@ "modified": "Ti Yipada", "restoreToDefault": "Pada si atilẹwa", "restoredToDefault": "Ti Pada si Atilẹwa", - "terminal": "Terminal" + "terminal": "Terminal", + "projectLabels": "Àmì Ìṣẹ́", + "manageLabels": "Ṣàkóso Àmì", + "createLabel": "Ṣẹ̀dá Àmì", + "labelName": "Orúkọ Àmì", + "enterLabelName": "Tẹ orúkọ àmì", + "labelColor": "Àwọ̀", + "deleteLabel": "Pa Àmì rẹ́", + "deleteLabelConfirmation": "Ṣé o dá a lójú pé o fẹ́ pa àmì \"{{name}}\" rẹ́? Èyí yóò yọ àmì náà kúrò nínú gbogbo iṣẹ́.", + "noLabelsYet": "Kò sí àmì síbẹ̀", + "createLabelToOrganize": "Ṣẹ̀dá àmì láti ṣètò àwọn iṣẹ́ rẹ", + "addLabel": "Fi àmì kún", + "selectLabels": "Yan àmì", + "noLabelsCreated": "A kò tí ì ṣẹ̀dá àmì kankan", + "createNewLabel": "Ṣẹ̀dá àmì tuntun", + "showColoredIcons": "Àwọn ìkọ́ fáìlì oníàwọ̀", + "showColoredIconsDescription": "Fi ìkọ́ fáìlì hàn ní àwọ̀ àmì fún àwọn iṣẹ́ tí wọ́n ní àmì.", + "groupByLabel": "Ṣàkójọ nípa àmì", + "groupByLabelDescription": "Ṣètò àwọn iṣẹ́ sí ẹgbẹ́ tí wọ́n lè pa mọ́ dà lórí àmì wọn.", + "unlabeled": "Kò ní àmì" } diff --git a/src/locales/zh.json b/src/locales/zh.json index 6977a6ed..6f7c984b 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -440,5 +440,24 @@ "modified": "已修改", "restoreToDefault": "恢复默认值", "restoredToDefault": "已恢复默认值", - "terminal": "终端" + "terminal": "终端", + "projectLabels": "项目标签", + "manageLabels": "管理标签", + "createLabel": "创建标签", + "labelName": "标签名称", + "enterLabelName": "输入标签名称", + "labelColor": "颜色", + "deleteLabel": "删除标签", + "deleteLabelConfirmation": "确定要删除标签 \"{{name}}\" 吗?这将从所有项目中移除该标签。", + "noLabelsYet": "暂无标签", + "createLabelToOrganize": "创建标签来组织您的项目", + "addLabel": "添加标签", + "selectLabels": "选择标签", + "noLabelsCreated": "尚未创建标签", + "createNewLabel": "创建新标签", + "showColoredIcons": "彩色文件夹图标", + "showColoredIconsDescription": "为有标签的项目显示标签颜色的文件夹图标。", + "groupByLabel": "按标签分组", + "groupByLabelDescription": "根据标签将项目组织成可折叠的分组。", + "unlabeled": "无标签" } diff --git a/src/pages/Preferences.tsx b/src/pages/Preferences.tsx index 7e4935fb..c2d2e5cf 100644 --- a/src/pages/Preferences.tsx +++ b/src/pages/Preferences.tsx @@ -1,7 +1,8 @@ -import { Settings2, ArrowLeft } from "lucide-react"; +import { useState } from "react"; +import { Settings2, ArrowLeft, Tag } from "lucide-react"; import { useTranslation } from 'react-i18next'; import { Button } from "@/components/ui/button"; -import { Card, CardContent } from "@/components/ui/card"; +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { ThemePicker } from "@/components/ThemePicker"; import { LanguagePicker } from "@/components/LanguagePicker"; import { Switch } from "@/components/ui/switch"; @@ -9,12 +10,21 @@ import { Label } from "@/components/ui/label"; import { useIsMobile } from "@/hooks/useIsMobile"; import { useNavigate } from "react-router-dom"; import { useAppContext } from "@/hooks/useAppContext"; +import { useLabels } from "@/hooks/useLabels"; +import { useProjectLabels } from "@/hooks/useProjectLabels"; +import { LabelsManageDialog } from "@/components/labels/LabelsManageDialog"; export function Preferences() { const { t } = useTranslation(); const isMobile = useIsMobile(); const navigate = useNavigate(); const { config, updateConfig } = useAppContext(); + const { labels, displaySettings, updateDisplaySettings } = useLabels(); + const { hasAnyLabels } = useProjectLabels(); + const [labelsDialogOpen, setLabelsDialogOpen] = useState(false); + + // Only show label settings if user has created labels or assigned labels to projects + const showLabelSettings = labels.length > 0 || hasAnyLabels(); return (
@@ -101,6 +111,76 @@ export function Preferences() {
+ + {/* Labels Settings - Only shown when user has labels */} + {showLabelSettings && ( + + + + + {t('projectLabels')} + + + +
+
+
+
+ +
+ { + updateDisplaySettings({ showColoredIcons: checked }); + }} + /> +
+

+ {t('showColoredIconsDescription')} +

+
+ +
+
+
+ +
+ { + updateDisplaySettings({ groupByLabel: checked }); + }} + /> +
+

+ {t('groupByLabelDescription')} +

+
+ +
+ +
+
+
+
+ )} + +
); }