mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
## Context We've got a `useUrlState` hook that was written a long time ago, which is now deprecated and can be replaced with nuqs' `useQueryState` - so this PR cleans that up and deletes the hook. ## To test Just 2 surfaces in the dashboard that's affected - Project -> Settings -> Addons - [ ] Verify that opening/closing the addon panels toggle the panel URL param accordingly - Table Editor filters and sorts - [ ] Verify that landing on the editor with `?create=table` URL param opens the new table panel + removes the URL param - [ ] Verify that filter and sorts still work + including refreshing the browser should land back on the same state - [ ] Verify that renaming a column while there's a filter/sort applied for that column will also update the URL param
29 lines
670 B
TypeScript
29 lines
670 B
TypeScript
import { parseAsStringLiteral, useQueryState } from 'nuqs'
|
|
|
|
export const ADDONS_PANEL_KEYS_ARRAY = ['pitr', 'customDomain', 'ipv4'] as const
|
|
|
|
export type ADDONS_PANEL_KEYS = undefined | (typeof ADDONS_PANEL_KEYS_ARRAY)[number]
|
|
|
|
export function useAddonsPagePanel() {
|
|
const [panelParam, setPanelParam] = useQueryState(
|
|
'panel',
|
|
parseAsStringLiteral(ADDONS_PANEL_KEYS_ARRAY).withOptions({ history: 'replace' })
|
|
)
|
|
|
|
const panel = panelParam ?? undefined
|
|
|
|
const setPanel = (panel: ADDONS_PANEL_KEYS) => {
|
|
setPanelParam(panel ?? null)
|
|
}
|
|
|
|
const closePanel = () => {
|
|
setPanelParam(null)
|
|
}
|
|
|
|
return {
|
|
panel,
|
|
setPanel,
|
|
closePanel,
|
|
}
|
|
}
|