mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-05-30 08:15:31 +08:00
refactor(command-palette): extract groups into declarative registry
This commit is contained in:
28
src/components/command-palette/registry/groups/commits.tsx
Normal file
28
src/components/command-palette/registry/groups/commits.tsx
Normal file
@@ -0,0 +1,28 @@
|
||||
import { GitCommit } from 'lucide-react';
|
||||
|
||||
import { useCommitsSource } from '../../sources/useCommitsSource';
|
||||
import type { GroupConfig } from '../types';
|
||||
|
||||
export const commitsGroup: GroupConfig = {
|
||||
id: 'commits',
|
||||
heading: 'Commits',
|
||||
modes: ['mixed', 'commits'],
|
||||
prefix: { char: '#', mode: 'commits' },
|
||||
requiresProject: true,
|
||||
useItems: (ctx) => {
|
||||
const { items: commits } = useCommitsSource(ctx.projectId, ctx.enabled);
|
||||
return commits.map((c) => ({
|
||||
key: `commit-${c.hash}`,
|
||||
value: `${c.shortHash} ${c.message} ${c.author}`,
|
||||
onSelect: () => ctx.run(() => ctx.onShowTab?.('git')),
|
||||
node: (
|
||||
<>
|
||||
<GitCommit className="h-4 w-4 shrink-0 text-muted-foreground" aria-hidden />
|
||||
<span className="font-mono text-xs text-muted-foreground">{c.shortHash}</span>
|
||||
<span className="flex-1 truncate">{c.message}</span>
|
||||
<span className="truncate text-xs text-muted-foreground">{c.author}</span>
|
||||
</>
|
||||
),
|
||||
}));
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user