feat(skills): add skill deletion and improve UI/UX

- Add skill deletion functionality with confirmation dialog
- Protect builtin skills from deletion
- Optimize skill card layout (badge and enable button near menu)
- Change enable button to icon-only with theme color
- Improve card selection and hover states
- Fix skill hub installation state tracking (per-skill)
- Add proper i18n for delete feature (en/zh)
- Add loading states to delete confirmation dialog
- Remove manual refetch calls (use query invalidation)
This commit is contained in:
catlog22
2026-02-24 21:06:34 +08:00
parent 6c9ad9a9f3
commit 33e12a31ac
6 changed files with 219 additions and 24 deletions

View File

@@ -215,15 +215,53 @@ export function useToggleSkill(): UseToggleSkillReturn {
};
}
/**
* Hook for deleting a skill
*/
export function useDeleteSkill() {
const queryClient = useQueryClient();
const mutation = useMutation({
mutationFn: async ({
skillName,
location,
projectPath,
cliType,
}: {
skillName: string;
location: 'project' | 'user';
projectPath?: string;
cliType: 'claude' | 'codex';
}) => {
const { deleteSkill } = await import('@/lib/api');
return deleteSkill(skillName, location, projectPath, cliType);
},
onSuccess: () => {
// Invalidate skills queries to refresh the list
queryClient.invalidateQueries({ queryKey: skillsKeys.all });
},
});
return {
deleteSkill: (skillName: string, location: 'project' | 'user', projectPath?: string, cliType: 'claude' | 'codex' = 'claude') =>
mutation.mutateAsync({ skillName, location, projectPath, cliType }),
isDeleting: mutation.isPending,
error: mutation.error,
};
}
/**
* Combined hook for all skill mutations
*/
export function useSkillMutations() {
const toggle = useToggleSkill();
const deleteSkillHook = useDeleteSkill();
return {
toggleSkill: toggle.toggleSkill,
isToggling: toggle.isToggling,
isMutating: toggle.isToggling,
deleteSkill: deleteSkillHook.deleteSkill,
isDeleting: deleteSkillHook.isDeleting,
isMutating: toggle.isToggling || deleteSkillHook.isDeleting,
};
}