mirror of
https://github.com/supabase/supabase.git
synced 2026-10-15 06:09:08 +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.6 KiB
TypeScript
55 lines
1.6 KiB
TypeScript
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
|
|
import { toast } from 'sonner'
|
|
|
|
import type { components } from 'data/api'
|
|
import { handleError, post } from 'data/fetchers'
|
|
import type { ResponseError } from 'types'
|
|
import { orgSSOKeys } from './keys'
|
|
|
|
export type SSOConfigCreateVariables = {
|
|
slug: string
|
|
config: components['schemas']['CreateSSOProviderBody']
|
|
}
|
|
|
|
export async function createSSOConfig({ slug, config }: SSOConfigCreateVariables) {
|
|
const { data, error } = await post('/platform/organizations/{slug}/sso', {
|
|
params: { path: { slug } },
|
|
body: config,
|
|
})
|
|
|
|
if (error) handleError(error)
|
|
return data
|
|
}
|
|
|
|
type SSOConfigCreateData = Awaited<ReturnType<typeof createSSOConfig>>
|
|
|
|
export const useSSOConfigCreateMutation = ({
|
|
onSuccess,
|
|
onError,
|
|
...options
|
|
}: Omit<
|
|
UseMutationOptions<SSOConfigCreateData, ResponseError, SSOConfigCreateVariables>,
|
|
'mutationFn'
|
|
> = {}) => {
|
|
const queryClient = useQueryClient()
|
|
|
|
return useMutation<SSOConfigCreateData, ResponseError, SSOConfigCreateVariables>(
|
|
(vars) => createSSOConfig(vars),
|
|
{
|
|
async onSuccess(data, variables, context) {
|
|
const { slug } = variables
|
|
await queryClient.invalidateQueries(orgSSOKeys.orgSSOConfig(slug))
|
|
await onSuccess?.(data, variables, context)
|
|
},
|
|
async onError(data, variables, context) {
|
|
if (onError === undefined) {
|
|
toast.error(`Failed to create SSO configuration: ${data.message}`)
|
|
} else {
|
|
onError(data, variables, context)
|
|
}
|
|
},
|
|
...options,
|
|
}
|
|
)
|
|
}
|