Files
supabase/apps/studio/state/addons-page.ts
Joshen Lim 7e92210d31 Replace useUrlState with useQueryState, and deprecate (#53726)
## 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
2026-11-23 10:58:18 +07:00

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,
}
}