mirror of
https://github.com/supabase/supabase.git
synced 2026-12-05 16:09:06 +00:00
## Context Deploys the trusted partner changes from the following PRs: - https://github.com/supabase/supabase/pull/54006 - https://github.com/supabase/supabase/pull/53583 - https://github.com/supabase/supabase/pull/53705 - https://github.com/supabase/supabase/pull/53917 - https://github.com/supabase/supabase/pull/54507 - https://github.com/supabase/supabase/pull/54506 --------- Co-authored-by: Danny White <3104761+dnywh@users.noreply.github.com>
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
import { PermissionAction } from '@supabase/shared-types/out/constants'
|
|
import { useQuery } from '@tanstack/react-query'
|
|
|
|
import { oauthProjectDatabaseAccessQueryOptions } from '@/data/oauth-apps/oauth-apps-project-database-access-query'
|
|
import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
|
|
import { IS_PLATFORM } from '@/lib/constants'
|
|
|
|
/**
|
|
* The OAuth apps that rely on database token access for a project, which must be known before
|
|
* token access can be turned on or off.
|
|
*/
|
|
export function useAuthorizedAppsReview({
|
|
slug,
|
|
projectRef,
|
|
parentProjectRef,
|
|
}: {
|
|
slug?: string
|
|
projectRef?: string
|
|
parentProjectRef?: string | null
|
|
}) {
|
|
const { can: canReadApps, isLoading: isLoadingAppPermissions } = useAsyncCheckPermissions(
|
|
PermissionAction.READ,
|
|
'approved_oauth_apps'
|
|
)
|
|
const appsQuery = useQuery({
|
|
...oauthProjectDatabaseAccessQueryOptions({ slug, projectRef }),
|
|
enabled:
|
|
IS_PLATFORM &&
|
|
!parentProjectRef &&
|
|
canReadApps &&
|
|
!isLoadingAppPermissions &&
|
|
Boolean(slug && projectRef),
|
|
})
|
|
|
|
const isCheckingApps =
|
|
IS_PLATFORM &&
|
|
(isLoadingAppPermissions || (canReadApps && (appsQuery.isPending || appsQuery.isFetching)))
|
|
|
|
return {
|
|
apps: appsQuery.data ?? [],
|
|
error: appsQuery.error,
|
|
isError: appsQuery.isError,
|
|
canReadApps,
|
|
isCheckingApps,
|
|
}
|
|
}
|