Environment deletion and better actions menu

This commit is contained in:
Gregory Schier
2023-10-26 16:18:47 -07:00
parent f8584f1537
commit 356eaf1713
7 changed files with 138 additions and 60 deletions

View File

@@ -3,11 +3,9 @@ import { invoke } from '@tauri-apps/api';
import type { Environment } from '../lib/models';
import { environmentsQueryKey } from './useEnvironments';
import { useActiveWorkspaceId } from './useActiveWorkspaceId';
import { useActiveEnvironmentId } from './useActiveEnvironmentId';
import { useAppRoutes } from './useAppRoutes';
export function useCreateEnvironment() {
const environmentId = useActiveEnvironmentId();
const workspaceId = useActiveWorkspaceId();
const queryClient = useQueryClient();
const routes = useAppRoutes();
@@ -18,7 +16,7 @@ export function useCreateEnvironment() {
},
onSuccess: async (environment) => {
if (workspaceId == null) return;
routes.navigate('workspace', { workspaceId, environmentId });
routes.setEnvironment(environment);
queryClient.setQueryData<Environment[]>(
environmentsQueryKey({ workspaceId }),
(environments) => [...(environments ?? []), environment],