mirror of
https://github.com/supabase/supabase.git
synced 2026-10-19 16:19:10 +03:00
* fix: update Permission params * fix: upgrade check permission hook to support project level role * fix: usePermissionsLoaded * fix: Permission params can be undefined * Scaffold new access management UI * Add validation * Update roles view * Add tooltip * Add button to apply role to all projects * Update UI to select projects first instead of roles * Merge master update UI * Midway trying to implementation project level perms API * First pass implementating updating project level permissions * Add client side validation for assigning/removing roles * Midway implementing new invites * Integrate most of the project level permissions functionality * fix: filter out org-level permissions before checking * Add relevant UI guards in org level pages for project role POV * Minor refactors * Small refactors * More fixes * Moar refactors * More fixes * More fixes * Refactor update role logic and smack some test cases on it * Fixes * Fix type issue * Fix type * more fixes, refactors, adding checks... * MORE fixes * Add perms checking for replicas * Add ButtonTooltip component and use them to prevent repetition of pointer events auto for buttons with tooltips * Convert all buttons with tooltips to use ButtonTooltip * refactor * PRettier * Small fix * Remove commented out code in organization-invitation-accept-mutation * fix: switch to use the platform oauth authorizations routes * Add perms checking for org audit logs and org oauth apps * PRettier * Fix incorrect URL for oauth app flow * Fix incorrect URL for oauth app flow * Fix * Add perms checking for warehouse related UI * Update roles helper icon * remove unused lib * Update package lock... again * Update package lock... again * Smalllll update * Update some checks * Add gate for project level permissions * Last fix * update codegen * Update warehouse endpoint routes * Fix --------- Co-authored-by: phamhieu <phamhieu1998@gmail.com> Co-authored-by: Alaister Young <a@alaisteryoung.com>
51 lines
1.4 KiB
TypeScript
51 lines
1.4 KiB
TypeScript
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
|
|
import { get, handleError } from 'data/fetchers'
|
|
import { analyticsKeys } from './keys'
|
|
import { ResponseError } from 'types'
|
|
|
|
export type WarehouseQueryVariables = {
|
|
ref: string
|
|
sql: string
|
|
}
|
|
|
|
export async function getWarehouseQuery(
|
|
{ ref, sql }: WarehouseQueryVariables,
|
|
signal?: AbortSignal
|
|
) {
|
|
if (!sql) {
|
|
throw new Error('SQL must be provided')
|
|
}
|
|
|
|
const { data, error } = await get(`/v1/projects/{ref}/analytics/warehouse/query`, {
|
|
params: { path: { ref: ref }, query: { bq_sql: sql } },
|
|
signal,
|
|
} as any)
|
|
|
|
if (error) {
|
|
handleError(error)
|
|
}
|
|
|
|
// TODO!: Remove type assertion when we have a proper type for the response
|
|
return data as { result: any[] }
|
|
}
|
|
|
|
export type WarehouseQueryData = Awaited<ReturnType<typeof getWarehouseQuery>>
|
|
export type WarehouseQueryError = ResponseError
|
|
|
|
export const useWarehouseQueryQuery = <TData = WarehouseQueryData>(
|
|
{ ref, sql }: WarehouseQueryVariables,
|
|
{ enabled, ...options }: UseQueryOptions<WarehouseQueryData, WarehouseQueryError, TData> = {}
|
|
) =>
|
|
useQuery<WarehouseQueryData, WarehouseQueryError, TData>(
|
|
analyticsKeys.warehouseQuery(ref, sql),
|
|
({ signal }) => getWarehouseQuery({ ref, sql }, signal),
|
|
{
|
|
enabled,
|
|
staleTime: Infinity,
|
|
cacheTime: 15 * 60 * 1000, // 15 mins cache time
|
|
refetchOnMount: false,
|
|
refetchInterval: false,
|
|
...options,
|
|
}
|
|
)
|