- Enhanced FileSearchService to implement parallel subdirectory traversal, improving efficiency in file collection. - Refactored ProjectFileService to reuse directory stats, reducing unnecessary file system calls. - Updated multiple components (EditorStatusBar, EditorTabBar, EditorToolbar, GitStatusBadge, QuickOpenDialog, SearchInFilesPanel) to utilize Zustand's shallow comparison for improved state management and performance. - Introduced a module-level cache for QuickOpenDialog to minimize redundant API calls and enhance user experience. - Added cache invalidation logic in editorSlice to ensure fresh data on file system changes.
47 lines
1.5 KiB
TypeScript
47 lines
1.5 KiB
TypeScript
/**
|
|
* Git status badge for file tree entries.
|
|
*
|
|
* Shows single-letter indicators:
|
|
* - M (modified) — orange
|
|
* - U (untracked) — green
|
|
* - A (staged/added) — green
|
|
* - D (deleted) — red
|
|
* - C (conflict) — red, bold
|
|
* - R (renamed) — cyan
|
|
*/
|
|
|
|
import React from 'react';
|
|
|
|
import type { GitFileStatusType } from '@shared/types/editor';
|
|
|
|
// =============================================================================
|
|
// Badge config
|
|
// =============================================================================
|
|
|
|
const STATUS_CONFIG: Record<GitFileStatusType, { letter: string; color: string }> = {
|
|
modified: { letter: 'M', color: 'text-orange-400' },
|
|
untracked: { letter: 'U', color: 'text-green-400' },
|
|
staged: { letter: 'A', color: 'text-green-400' },
|
|
deleted: { letter: 'D', color: 'text-red-400' },
|
|
conflict: { letter: 'C', color: 'text-red-400 font-bold' },
|
|
renamed: { letter: 'R', color: 'text-cyan-400' },
|
|
};
|
|
|
|
// =============================================================================
|
|
// Component
|
|
// =============================================================================
|
|
|
|
interface GitStatusBadgeProps {
|
|
status: GitFileStatusType;
|
|
}
|
|
|
|
export const GitStatusBadge = React.memo(function GitStatusBadge({
|
|
status,
|
|
}: GitStatusBadgeProps): React.ReactElement {
|
|
const config = STATUS_CONFIG[status];
|
|
return (
|
|
<span className={`ml-auto shrink-0 text-[10px] leading-none ${config.color}`} title={status}>
|
|
{config.letter}
|
|
</span>
|
|
);
|
|
});
|