mirror of
https://github.com/supabase/supabase.git
synced 2026-07-06 19:44:24 +08:00
* Add validation for max replicas check * Small UI fixes * Add useMemo for edges * Fix nodes not shwoing up when switching between map and flow view * Fix logs explorer copy button * Add edge changes to useEffect * Bump wait duration when creating replica * Sync database selector and use pooler checkbox states across panels on settings database * Fix InstanceConfiguration not showing any nodes * Sort databases in DatabaseSelector to have primary first * Logs explorer border fotter * Add database selector for edge logs * Make buttons more concise in logs * Clean up * Fix * Fix home page empty empty state * Attempt to support pooler logs * minor qol fix for database selector * Update shared-data pgbouncer to supavisor * small fix
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import { PropsWithChildren, createContext, useContext } from 'react'
|
|
import { proxy, useSnapshot } from 'valtio'
|
|
|
|
import { useConstant } from 'common'
|
|
|
|
export function createDatabaseSettingsState() {
|
|
const state = proxy({
|
|
usePoolerConnection: true,
|
|
setUsePoolerConnection: (value: boolean) => {
|
|
state.usePoolerConnection = value
|
|
},
|
|
showPoolingModeHelper: false,
|
|
setShowPoolingModeHelper: (value: boolean) => {
|
|
state.showPoolingModeHelper = value
|
|
},
|
|
})
|
|
|
|
return state
|
|
}
|
|
|
|
export type DatabaseSettingsState = ReturnType<typeof createDatabaseSettingsState>
|
|
|
|
export const DatabaseSettingsStateContext = createContext<DatabaseSettingsState>(
|
|
createDatabaseSettingsState()
|
|
)
|
|
|
|
export const DatabaseSettingsStateContextProvider = ({ children }: PropsWithChildren) => {
|
|
const state = useConstant(createDatabaseSettingsState)
|
|
|
|
return (
|
|
<DatabaseSettingsStateContext.Provider value={state}>
|
|
{children}
|
|
</DatabaseSettingsStateContext.Provider>
|
|
)
|
|
}
|
|
|
|
export function useDatabaseSettingsStateSnapshot(options?: Parameters<typeof useSnapshot>[1]) {
|
|
const state = useContext(DatabaseSettingsStateContext)
|
|
return useSnapshot(state, options)
|
|
}
|