mirror of
https://github.com/supabase/supabase.git
synced 2026-10-15 14:19:11 +03:00
* Start
* Add join org logic
* Regenerate the API types and add RQ hooks.
* Various fixes to the UI for SSO config.
* Refactor the components to use RHF.
* Fix the loading/error states in the main file.
* fix: minor changes to SSO UI
* Expanded default attribute mapping preset for `Okta` to include `user_name`, `first_name`, and `last_name` to match our docs.
* Normalized role casing in the "Join Organization on Signup" dropdown to match the roles expected by the backend (`Owner`, `Administrator`, `Developer`).
* Added the role (`Read-only`) to the selectable roles for auto-join.
* Call update mutation when an `ssoConfig` has been retrieved.
* Treats `404` as a valid "create" flow state rather than an error.
* Conditionally renders the SSO config form when config is successfully loaded *or* when the provider is not found, allowing users to onboard from scratch and disable the provider.
* chore: prettier
* feat: add a button linking to SSO setup docs
* Revert "feat: add a button linking to SSO setup docs"
This will be included in a separate docs pr.
This reverts commit 0b616fdd2e.
* General clean up
* Nit copy
* Add empty state for SSO
* Smol change
* One last tweak
---------
Co-authored-by: Chris Stockton <180184+cstockton@users.noreply.github.com>
Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
Co-authored-by: Chris Stockton <chris.stockton@supabase.io>
Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
55 lines
1.7 KiB
TypeScript
55 lines
1.7 KiB
TypeScript
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
|
|
|
|
import { get, handleError } from 'data/fetchers'
|
|
import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
|
|
import { IS_PLATFORM } from 'lib/constants'
|
|
import type { ResponseError } from 'types'
|
|
import { orgSSOKeys } from './keys'
|
|
|
|
export type OrgSSOConfigVariables = {
|
|
orgSlug?: string
|
|
}
|
|
|
|
export async function getOrgSSOConfig({ orgSlug }: OrgSSOConfigVariables, signal?: AbortSignal) {
|
|
if (!orgSlug) throw new Error('Organization slug is required')
|
|
|
|
const { data, error } = await get('/platform/organizations/{slug}/sso', {
|
|
params: { path: { slug: orgSlug } },
|
|
signal,
|
|
})
|
|
|
|
if (error) {
|
|
const ssoNotSetUp =
|
|
(error as any)?.code === 404 &&
|
|
(error as any)?.message?.includes('Failed to find an existing SSO Provider')
|
|
|
|
if (ssoNotSetUp) {
|
|
return null
|
|
} else {
|
|
handleError(error)
|
|
}
|
|
}
|
|
return data
|
|
}
|
|
|
|
export type OrgSSOConfigData = Awaited<ReturnType<typeof getOrgSSOConfig>>
|
|
export type OrgSSOConfigError = ResponseError
|
|
|
|
export const useOrgSSOConfigQuery = <TData = OrgSSOConfigData>(
|
|
{ orgSlug }: OrgSSOConfigVariables,
|
|
{ enabled = true, ...options }: UseQueryOptions<OrgSSOConfigData, OrgSSOConfigError, TData> = {}
|
|
) => {
|
|
const { data: organization } = useSelectedOrganizationQuery()
|
|
const plan = organization?.plan.id
|
|
const canSetupSSOConfig = ['team', 'enterprise'].includes(plan ?? '')
|
|
|
|
return useQuery<OrgSSOConfigData, OrgSSOConfigError, TData>(
|
|
orgSSOKeys.orgSSOConfig(orgSlug),
|
|
({ signal }) => getOrgSSOConfig({ orgSlug }, signal),
|
|
{
|
|
enabled: enabled && IS_PLATFORM && typeof orgSlug !== 'undefined' && canSetupSSOConfig,
|
|
...options,
|
|
}
|
|
)
|
|
}
|