Stubbed out global commands helper

This commit is contained in:
Gregory Schier
2024-03-16 09:46:11 -07:00
parent 40f8a41a8d
commit 49da0e5aa8
8 changed files with 104 additions and 59 deletions

View File

@@ -0,0 +1,31 @@
import { invoke } from '@tauri-apps/api';
import { useAppRoutes } from './useAppRoutes';
import { useRegisterCommand } from './useCommands';
import { usePrompt } from './usePrompt';
export function useGlobalCommands() {
const prompt = usePrompt();
const routes = useAppRoutes();
useRegisterCommand('workspace.create', {
name: 'New Workspace',
track: ['workspace', 'create'],
onSuccess: async (workspace) => {
routes.navigate('workspace', { workspaceId: workspace.id });
},
mutationFn: async ({ name: patchName }) => {
const name =
patchName ??
(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 });
},
});
}