fix(dashboard): refresh table list after running a SQL stmt using the editor (#2549)

fixes https://github.com/nhost/projects/issues/52
This commit is contained in:
Hassan Ben Jobrane
2024-02-20 13:40:46 +01:00
committed by GitHub
parent 3c4dd55045
commit 3db2999f60
2 changed files with 19 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
'@nhost/dashboard': patch
---
fix: refresh table list after running SQL using the editor

View File

@@ -1,10 +1,12 @@
import { useDatabaseQuery } from '@/features/database/dataGrid/hooks/useDatabaseQuery';
import { useCurrentWorkspaceAndProject } from '@/features/projects/common/hooks/useCurrentWorkspaceAndProject';
import { generateAppServiceUrl } from '@/features/projects/common/utils/generateAppServiceUrl';
import { getToastStyleProps } from '@/utils/constants/settings';
import { getHasuraAdminSecret } from '@/utils/env';
import { parseIdentifiersFromSQL } from '@/utils/sql';
import toast from 'react-hot-toast';
import { useRouter } from 'next/router';
import { useState } from 'react';
import toast from 'react-hot-toast';
export default function useRunSQL(
sqlCode: string,
@@ -22,6 +24,14 @@ export default function useRunSQL(
const [columns, setColumns] = useState<string[]>([]);
const [rows, setRows] = useState<string[][]>([[]]);
const router = useRouter();
const {
query: { dataSourceSlug },
} = router;
const { refetch } = useDatabaseQuery([dataSourceSlug as string]);
const appUrl = generateAppServiceUrl(
currentProject?.subdomain,
currentProject?.region,
@@ -269,6 +279,9 @@ export default function useRunSQL(
}
}
// refresh the table list after running the sql
await refetch();
setLoading(false);
};