Fix workspace deletion

This commit is contained in:
Gregory Schier
2023-03-21 09:32:15 -07:00
parent 362d9f8e59
commit 50f92bcfab
7 changed files with 21 additions and 7 deletions

Binary file not shown.

View File

@@ -162,6 +162,16 @@
},
"query": "\n SELECT\n id,\n model,\n workspace_id,\n created_at,\n updated_at,\n name,\n url,\n method,\n body,\n body_type,\n sort_priority,\n headers AS \"headers!: sqlx::types::Json<Vec<HttpRequestHeader>>\"\n FROM http_requests\n WHERE workspace_id = ?\n "
},
"84be2b954870ab181738656ecd4d03fca2ff21012947014c79626abfce8e999b": {
"describe": {
"columns": [],
"nullable": [],
"parameters": {
"Right": 1
}
},
"query": "\n DELETE FROM workspaces\n WHERE id = ?\n "
},
"a83698dcf9a815b881097133edb31a34ba25e7c6c114d463c495342a85371639": {
"describe": {
"columns": [],

View File

@@ -148,7 +148,7 @@ pub async fn delete_workspace(id: &str, pool: &Pool<Sqlite>) -> Result<Workspace
.expect("Failed to get request to delete");
let _ = sqlx::query!(
r#"
DELETE FROM http_requests
DELETE FROM workspaces
WHERE id = ?
"#,
id,

View File

@@ -47,7 +47,7 @@ export function GraphQLEditor({ defaultValue, onChange, ...extraEditorProps }: P
};
return (
<div className="pb-1 h-full grid grid-rows-[minmax(0,100%)_auto_auto_minmax(0,auto)]">
<div className="pb-2 h-full grid grid-rows-[minmax(0,100%)_auto_auto_minmax(0,auto)]">
<Editor
key={queryKey.key}
heightMode="auto"

View File

@@ -277,7 +277,7 @@ const _SidebarItem = forwardRef(function SidebarItem(
return (
<li
ref={ref}
className={classnames(className, 'block group/item px-2 pb-1')}
className={classnames(className, 'block group/item px-2 pb-0.5')}
style={itemStyles}
>
<div className="relative w-full">

View File

@@ -1,6 +1,5 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { invoke } from '@tauri-apps/api';
import { useNavigate } from 'react-router-dom';
import { useActiveWorkspaceId } from './useActiveWorkspaceId';
import { useRoutes } from './useRoutes';
import { workspacesQueryKey } from './useWorkspaces';
@@ -18,7 +17,7 @@ export function useDeleteWorkspace(id: string | null) {
if (id === null) return;
await queryClient.invalidateQueries(workspacesQueryKey());
if (id === activeWorkspaceId) {
routes.navigate('workspace', { workspaceId: id });
routes.navigate('workspaces');
}
},
});

View File

@@ -1,3 +1,5 @@
import { useNavigate } from 'react-router-dom';
export type RouteParamsWorkspace = {
workspaceId: string;
};
@@ -24,15 +26,18 @@ export const routePaths = {
};
export function useRoutes() {
const navigate = useNavigate();
return {
navigate<T extends keyof typeof routePaths>(
path: T,
params: Parameters<(typeof routePaths)[T]>[0],
...params: Parameters<(typeof routePaths)[T]>
) {
// Not sure how to make TS work here, but it's good from the
// outside caller perspective.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
routePaths[path](params as any);
const resolvedPath = routePaths[path](...(params as any));
console.log('NAVIGATE TO', resolvedPath, 'WITH PARAMS', params, 'AND PATH', path);
navigate(resolvedPath);
},
paths: routePaths,
};