Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Added query parameter setting on query submission

TzeYiingf948d7dc987a
diff --git a/studio/pages/project/[ref]/settings/logs/[type].tsx b/studio/pages/project/[ref]/settings/logs/[type].tsx
index e9e66a30cdb..f1ee2c2f87b 100644
--- a/studio/pages/project/[ref]/settings/logs/[type].tsx
+++ b/studio/pages/project/[ref]/settings/logs/[type].tsx
@@ -32,7 +32,6 @@ import Flag from 'components/ui/Flag/Flag'
export const LogPage: NextPage = () => {
const router = useRouter()
const { ref, type, q, s, ts } = router.query
-
const [editorId, setEditorId] = useState<string>(uuidv4())
const [editorValue, setEditorValue] = useState('')
const [mode, setMode] = useState<'simple' | 'custom'>('simple')
@@ -154,11 +153,28 @@ export const LogPage: NextPage = () => {
}
const handleEditorSubmit = () => {
setParams((prev) => ({ ...prev, where: editorValue }))
+ router.push({
+ pathname: router.pathname,
+ query: {
+ ...router.query,
+ q: editorValue,
+ },
+ })
}
const handleSearch = (v: string) => {
setParams((prev) => ({ ...prev, search_query: v || '' }))
+
+ router.push({
+ pathname: router.pathname,
+ query: {
+ ...router.query,
+ s: v || '',
+ },
+ })
}
+
+
return (
<SettingsLayout title={title}>
<div className="h-full flex flex-col flex-grow">
diff --git a/studio/tests/pages/projects/logs.test.js b/studio/tests/pages/projects/logs.test.js
index 0468288cedf..15879dd78f3 100644
--- a/studio/tests/pages/projects/logs.test.js
+++ b/studio/tests/pages/projects/logs.test.js
@@ -18,6 +18,7 @@ import { useRouter } from 'next/router'
const router = jest.fn()
router.query = { ref: '123', type: 'auth' }
router.push = jest.fn()
+router.pathname = 'logs/path'
useRouter.mockReturnValue(router)
// mock monaco editor
@@ -226,8 +227,9 @@ test('where clause will trigger a log refresh', async () => {
})
test('s= query param will populate the search bar', async () => {
- useRouter.mockReturnValue({
+ useRouter.mockReturnValueOnce({
query: { ref: '123', type: 'api', s: 'someSearch' },
+ push: jest.fn()
})
render(<LogPage />)
// should populate search input with the search param
@@ -238,8 +240,10 @@ test('s= query param will populate the search bar', async () => {
})
test('q= query param will populate the query input', async () => {
- useRouter.mockReturnValue({
+ useRouter.mockReturnValueOnce({
query: { ref: '123', type: 'api', q: 'some_query', s: 'someSearch' },
+ push: jest.fn()
+
})
render(<LogPage />)
// should populate editor with the query param
@@ -252,8 +256,9 @@ test('q= query param will populate the query input', async () => {
})
test('ts= query param will set the timestamp_start param', async () => {
- useRouter.mockReturnValue({
+ useRouter.mockReturnValueOnce({
query: { ref: '123', type: 'api', ts: 123456 },
+ push: jest.fn()
})
render(<LogPage />)