Cmd Palette Improvements (#50)

- Fuzzy matching
- Show hotkeys
- Add actions
This commit is contained in:
Gregory Schier
2024-06-10 21:37:41 -07:00
committed by GitHub
parent f0c7a83134
commit 47fcb8bad4
11 changed files with 308 additions and 123 deletions

View File

@@ -0,0 +1,27 @@
import { useMutation } from '@tanstack/react-query';
import { invoke } from '@tauri-apps/api/core';
import type { Workspace } from '../lib/models';
import { useAppRoutes } from './useAppRoutes';
import { usePrompt } from './usePrompt';
export function useCreateWorkspace() {
const routes = useAppRoutes();
const prompt = usePrompt();
return useMutation<Workspace, void, void>({
mutationFn: async () => {
const name = await prompt({
id: 'new-workspace',
name: 'name',
label: 'Name',
defaultValue: 'My Workspace',
title: 'New Workspace',
confirmLabel: 'Create',
placeholder: 'My Workspace',
});
return invoke('cmd_create_workspace', { name });
},
onSuccess: async (workspace) => {
routes.navigate('workspace', { workspaceId: workspace.id });
},
});
}