Files
supabase/apps/studio/state/database-settings.tsx
T
Joshen Lim 401d6ad6e8 Chore/update connection string settings kaizen (#20658)
* Add pooling mode dropdown to toggle between ports

* Fix

* Default pooling mode to the one thats configured

* Update based on feedback

* Fix

* Update pooling modes modal copy

* Small update

* Small copy update

* Small copy update

* Another one

* One final one
2024-01-23 20:12:20 +07:00

37 lines
1.0 KiB
TypeScript

import { PropsWithChildren, createContext, useContext } from 'react'
import { proxy, useSnapshot } from 'valtio'
import { useConstant } from 'common'
export function createDatabaseSettingsState() {
const state = proxy({
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)
}