diff --git a/.cursor/rules/studio-ui.mdc b/.cursor/rules/studio-ui.mdc new file mode 100644 index 0000000000000..67db62a0ba1f6 --- /dev/null +++ b/.cursor/rules/studio-ui.mdc @@ -0,0 +1,253 @@ +--- +description: How to generate pages and interfaces in Studio, a web interface for managing Supabase projects +globs: +alwaysApply: true +--- + +## Project Structure + +- Next.js app using pages router +- Pages go in @apps/studio/pages + - Project related pages go in @apps/studio/pages/projects/[ref] + - Organization related pages go in @apps/studio/pages/org/[slug] +- Studio specific components go in @apps/studio/components + - Studio specific generic UI components go in @apps/studio/components/ui + - Studio specific components related to individual pages go in @apps/studio/components/interfaces e.g. @apps/studio/components/interfaces/Auth +- Generic helper functions go in @apps/studio/lib +- Generic hooks go in @apps/studio/hooks + +## Component system + +Our primitive component system is in @packages/ui and is based off shadcn/ui components. These components can be shared across all @apps e.g. studio and docs. Do not introduce new ui components unless asked to. + +- UI components are imported from this package across apps e.g. import { Button, Badge } from 'ui' +- Some components have a _Shadcn_ namespace appended to component name e.g. import { Input*Shadcn* } from 'ui' +- We should be using _Shadcn_ components where possible +- Before composing interfaces, read @packages/ui/index.tsx file for a full list of available components + +## Styling + +We use Tailwind for styling. + +- You should never use tailwind classes for colours and instead use classes we've defined ourselves + - Backgrounds // most of the time you will not need to define a background + - 'bg' used for main app surface background + - 'bg-muted' for elevating content // you can use Card instead + - 'bg-warning' for highlighting information that needs to be acted on + - 'bg-destructive' for highlighting issues + - Text + - 'text-foreground' for primary text like headings + - 'text-foreground-light' for body text + - 'text-foreground-lighter' for subtle text + - 'text-warning' for calling out information that needs action + - 'text-destructive' for calling out when something went wrong +- When needing to apply typography styles, read @apps/studio/styles/typography.scss and use one of the available classes instead of hard coding classes e.g. use "heading-default" instead of "text-sm font-medium" + +## Page structure + +When creating a new page follow these steps: + +- Create the page in @apps/studio/pages +- Use the PageLayout component that has the following props + + ```jsx + export interface NavigationItem { + id?: string + label: string + href?: string + icon?: ReactNode + onClick?: () => void + badge?: string + active?: boolean + } + + interface PageLayoutProps { + children?: ReactNode + title?: string | ReactNode + subtitle?: string | ReactNode + icon?: ReactNode + breadcrumbs?: Array<{ + label?: string + href?: string + element?: ReactNode + }> + primaryActions?: ReactNode + secondaryActions?: ReactNode + navigationItems?: NavigationItem[] + className?: string + size?: 'default' | 'full' | 'large' | 'small' + isCompact?: boolean + } + ``` + +- If a page has page related actions, add them to primary and secondary action props e.g. Users page has "Create new user" action +- If a page is within an existing section (e.g. Auth), you should use the related layout component e.g. AuthLayout +- Create a new component in @apps/studio/components/interfaces for the contents of the page +- Use ScaffoldContainer if the page should be center aligned in a container +- Use ScaffoldSection, ScaffoldSectionTitle, ScaffoldSectionDescription if the page has multiple sections + +### Page example + +```jsx +import { MyPageComponent } from 'components/interfaces/MyPage/MyPageComponent' +import AuthLayout from './AuthLayout' +import DefaultLayout from 'components/layouts/DefaultLayout' +import { ScaffoldContainer } from 'components/layouts/Scaffold' +import type { NextPageWithLayout } from 'types' + +const MyPage: NextPageWithLayout = () => { + return ( + + + + ) +} + +MyPage.getLayout = (page) => ( + + {page} + +) + +export default MyPage + +export const MyPageComponent = () => ( + +
+ My page section + A brief description of the purpose of the page +
+ // Content goes here +
+) +``` + +## Forms + +- Build forms with `react-hook-form` + `zod`. +- Use our `_Shadcn_` form primitives from `ui` and prefer `FormItemLayout` with layout="flex-row-reverse" for most controls (see `apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GitHubIntegrationConnectionForm.tsx`). +- Keep imports from `ui` with `_Shadcn_` suffixes. +- Forms should generally be wrapped in a Card unless specified + +### Example (single field) + +```tsx +import { zodResolver } from '@hookform/resolvers/zod' +import { useForm } from 'react-hook-form' +import * as z from 'zod' + +import { Button, Form_Shadcn_, FormField_Shadcn_, FormControl_Shadcn_, Input_Shadcn_ } from 'ui' +import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout' + +const profileSchema = z.object({ + username: z.string().min(2, 'Username must be at least 2 characters'), +}) + +export function ProfileForm() { + const form = useForm>({ + resolver: zodResolver(profileSchema), + defaultValues: { username: '' }, + mode: 'onSubmit', + reValidateMode: 'onBlur', + }) + + function onSubmit(values: z.infer) { + // handle values + } + + return ( + +
+ + + ( + + + + + + )} + /> + + + + + +
+
+ ) +} +``` + +## Cards + +- Use cards when needing to group related pieces of information +- Cards can have sections with CardContent +- Use CardFooter for actions +- Only use CardHeader and CardTitle if the card content has not been described by the surrounding content e.g. Page title or ScaffoldSectionTitle +- Use CardHeader and CardTitle when you are using multiple Cards to group related pieces of content e.g. Primary branch, Persistent branches, Preview branches + +## Sheets + +- Use a sheet when needing to reveal more complicated forms or information relating to an object and context switching away to a new page would be disruptive e.g. we list auth providers, clicking an auth provider opens a sheet with information about that provider and a form to enable, user can close sheet to go back to providers list + +## Tables + +- Use the generic ui table components for most tables +- Tables are generally contained witin a card +- If a table has associated actions, they should go above on right hand side +- If a table has associated search or filters, they should go above on left hand side +- If a table is the main content of a page, and it does not have search or filters, you can add table actions to primary and secondary actions of PageLayout +- If a table is the main content of a page section, and it does not have search or filters, you can add table actions to the right of ScaffoldSectionTitle +- For simple lists of objects you can use ResourceList with ResourceListItem instead + +### Table example + +```jsx +import { Table, TableBody, TableCaption, TableCell, TableHead, TableHeader, TableRow } from 'ui' + +; + A list of your recent invoices. + + + Invoice + Status + Method + Amount + + + + + INV001 + Paid + Credit Card + $250.00 + + +
+``` + +## Alerts + +- Use Admonition component to alert users of important actions or restrictions in place +- Place the Admonition either at the top of the contents of the page (below page title) or at the top of the related ScaffoldSection , below ScaffoldTitle +- Use sparingly + +### Alert example + +```jsx + +``` diff --git a/apps/docs/content/guides/auth/social-login/auth-google.mdx b/apps/docs/content/guides/auth/social-login/auth-google.mdx index 520fb9a3a00e2..e73d62e6cf03c 100644 --- a/apps/docs/content/guides/auth/social-login/auth-google.mdx +++ b/apps/docs/content/guides/auth/social-login/auth-google.mdx @@ -540,26 +540,37 @@ Future _nativeGoogleSignIn() async { /// iOS Client ID that you registered with Google Cloud. const iosClientId = 'my-ios.apps.googleusercontent.com'; - final GoogleSignIn googleSignIn = GoogleSignIn( - clientId: iosClientId, + final scopes = ['email', 'profile']; + final googleSignIn = GoogleSignIn.instance; + + await googleSignIn.initialize( serverClientId: webClientId, + clientId: iosClientId, ); - final googleUser = await googleSignIn.signIn(); - final googleAuth = await googleUser!.authentication; - final accessToken = googleAuth.accessToken; - final idToken = googleAuth.idToken; - if (accessToken == null) { - throw 'No Access Token found.'; + final googleUser = await googleSignIn.attemptLightweightAuthentication(); + // or await googleSignIn.authenticate(); which will return a GoogleSignInAccount or throw an exception + + if (googleUser == null) { + throw AuthException('Failed to sign in with Google.'); } + + /// Authorization is required to obtain the access token with the appropriate scopes for Supabase authentication, + /// while also granting permission to access user information. + final authorization = + await googleUser.authorizationClient.authorizationForScopes(scopes) ?? + await googleUser.authorizationClient.authorizeScopes(scopes); + + final idToken = googleUser.authentication.idToken; + if (idToken == null) { - throw 'No ID Token found.'; + throw AuthException('No ID Token found.'); } await supabase.auth.signInWithIdToken( provider: OAuthProvider.google, idToken: idToken, - accessToken: accessToken, + accessToken: authorization.accessToken, ); } ... diff --git a/apps/docs/content/guides/platform/project-transfer.mdx b/apps/docs/content/guides/platform/project-transfer.mdx index 14a2429e6dd04..91fe31b7542bf 100644 --- a/apps/docs/content/guides/platform/project-transfer.mdx +++ b/apps/docs/content/guides/platform/project-transfer.mdx @@ -33,7 +33,10 @@ Target organization - the organization you want to move the project to - You need to be the owner of the source organization. - You need to be at least a member of the target organization you want to move the project to. -- Projects with support tier add-ons cannot be transferred at this point. [Open a support ticket](/dashboard/support/new?category=billing&subject=Transfer%20project). +- No active GitHub integration connection +- No project-scoped roles pointing to the project (Team/Enterprise plan) +- No log drains configured +- Target organization is not managed by Vercel Marketplace (currently unsupported) ## Usage-billing and project add-ons diff --git a/apps/studio/components/grid/components/header/Header.tsx b/apps/studio/components/grid/components/header/Header.tsx index 821a359c06d11..696524f4d2032 100644 --- a/apps/studio/components/grid/components/header/Header.tsx +++ b/apps/studio/components/grid/components/header/Header.tsx @@ -14,7 +14,7 @@ import { ButtonTooltip } from 'components/ui/ButtonTooltip' import { useTableRowsCountQuery } from 'data/table-rows/table-rows-count-query' import { fetchAllTableRows, useTableRowsQuery } from 'data/table-rows/table-rows-query' import { useSendEventMutation } from 'data/telemetry/send-event-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { RoleImpersonationState } from 'lib/role-impersonation' @@ -84,7 +84,7 @@ const DefaultHeader = () => { const snap = useTableEditorTableStateSnapshot() const tableEditorSnap = useTableEditorStateSnapshot() - const { can: canCreateColumns } = useAsyncCheckProjectPermissions( + const { can: canCreateColumns } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_WRITE, 'columns' ) diff --git a/apps/studio/components/interfaces/APIKeys/APIKeyDeleteDialog.tsx b/apps/studio/components/interfaces/APIKeys/APIKeyDeleteDialog.tsx index 7ab3876edeb65..5dbea60499586 100644 --- a/apps/studio/components/interfaces/APIKeys/APIKeyDeleteDialog.tsx +++ b/apps/studio/components/interfaces/APIKeys/APIKeyDeleteDialog.tsx @@ -7,7 +7,7 @@ import { useParams } from 'common/hooks' import { DropdownMenuItemTooltip } from 'components/ui/DropdownMenuItemTooltip' import { useAPIKeyDeleteMutation } from 'data/api-keys/api-key-delete-mutation' import { APIKeysData } from 'data/api-keys/api-keys-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import TextConfirmModal from 'ui-patterns/Dialogs/TextConfirmModal' interface APIKeyDeleteDialogProps { @@ -19,7 +19,7 @@ export const APIKeyDeleteDialog = ({ apiKey, lastSeen }: APIKeyDeleteDialogProps const { ref: projectRef } = useParams() const [isOpen, setIsOpen] = useState(false) - const { can: canDeleteAPIKeys } = useAsyncCheckProjectPermissions( + const { can: canDeleteAPIKeys } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_WRITE, '*' ) diff --git a/apps/studio/components/interfaces/APIKeys/ApiKeyPill.tsx b/apps/studio/components/interfaces/APIKeys/ApiKeyPill.tsx index 9d060f1ff8908..87334a6e5f42b 100644 --- a/apps/studio/components/interfaces/APIKeys/ApiKeyPill.tsx +++ b/apps/studio/components/interfaces/APIKeys/ApiKeyPill.tsx @@ -11,7 +11,7 @@ import CopyButton from 'components/ui/CopyButton' import { useAPIKeyIdQuery } from 'data/api-keys/[id]/api-key-id-query' import { APIKeysData } from 'data/api-keys/api-keys-query' import { apiKeysKeys } from 'data/api-keys/keys' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { Button, cn, Tooltip, TooltipContent, TooltipTrigger } from 'ui' export function ApiKeyPill({ @@ -28,8 +28,10 @@ export function ApiKeyPill({ const isSecret = apiKey.type === 'secret' // Permission check for revealing/copying secret API keys - const { can: canManageSecretKeys, isLoading: isLoadingPermission } = - useAsyncCheckProjectPermissions(PermissionAction.READ, 'service_api_keys') + const { can: canManageSecretKeys, isLoading: isLoadingPermission } = useAsyncCheckPermissions( + PermissionAction.READ, + 'service_api_keys' + ) // This query only runs when show=true (enabled: show) // It fetches the fully revealed API key when needed diff --git a/apps/studio/components/interfaces/APIKeys/PublishableAPIKeys.tsx b/apps/studio/components/interfaces/APIKeys/PublishableAPIKeys.tsx index 779a9b66e7fe9..cd0cda84cca04 100644 --- a/apps/studio/components/interfaces/APIKeys/PublishableAPIKeys.tsx +++ b/apps/studio/components/interfaces/APIKeys/PublishableAPIKeys.tsx @@ -6,16 +6,16 @@ import { useParams } from 'common' import CopyButton from 'components/ui/CopyButton' import { FormHeader } from 'components/ui/Forms/FormHeader' import { useAPIKeysQuery } from 'data/api-keys/api-keys-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { cn, EyeOffIcon, Input_Shadcn_, Skeleton, - WarningIcon, Tooltip, TooltipContent, TooltipTrigger, + WarningIcon, } from 'ui' // to add in later with follow up PR @@ -36,7 +36,7 @@ export const PublishableAPIKeys = () => { [apiKeysData] ) - const { can: canReadAPIKeys, isLoading: isPermissionsLoading } = useAsyncCheckProjectPermissions( + const { can: canReadAPIKeys, isLoading: isPermissionsLoading } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_WRITE, '*' ) @@ -106,7 +106,7 @@ const ApiKeyInput = () => { [apiKeysData] ) - const { can: canReadAPIKeys, isLoading: isPermissionsLoading } = useAsyncCheckProjectPermissions( + const { can: canReadAPIKeys, isLoading: isPermissionsLoading } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_WRITE, '*' ) diff --git a/apps/studio/components/interfaces/APIKeys/SecretAPIKeys.tsx b/apps/studio/components/interfaces/APIKeys/SecretAPIKeys.tsx index 2debd28019afb..94e9523d568f7 100644 --- a/apps/studio/components/interfaces/APIKeys/SecretAPIKeys.tsx +++ b/apps/studio/components/interfaces/APIKeys/SecretAPIKeys.tsx @@ -7,7 +7,7 @@ import AlertError from 'components/ui/AlertError' import { FormHeader } from 'components/ui/Forms/FormHeader' import { APIKeysData, useAPIKeysQuery } from 'data/api-keys/api-keys-query' import useLogsQuery from 'hooks/analytics/useLogsQuery' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { Card, CardContent, EyeOffIcon, Skeleton, cn } from 'ui' import { Table, @@ -58,7 +58,7 @@ export const SecretAPIKeys = () => { isError: isErrorApiKeys, } = useAPIKeysQuery({ projectRef, reveal: false }) - const { can: canReadAPIKeys, isLoading: isLoadingPermissions } = useAsyncCheckProjectPermissions( + const { can: canReadAPIKeys, isLoading: isLoadingPermissions } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_WRITE, '*' ) diff --git a/apps/studio/components/interfaces/APIKeys/hooks/useApiKeysVisibility.ts b/apps/studio/components/interfaces/APIKeys/hooks/useApiKeysVisibility.ts index f2b602522ef06..7cedd8a9f1b44 100644 --- a/apps/studio/components/interfaces/APIKeys/hooks/useApiKeysVisibility.ts +++ b/apps/studio/components/interfaces/APIKeys/hooks/useApiKeysVisibility.ts @@ -3,7 +3,7 @@ import { useMemo } from 'react' import { useParams } from 'common' import { useAPIKeysQuery } from 'data/api-keys/api-keys-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' interface ApiKeysVisibilityState { hasApiKeys: boolean @@ -19,7 +19,7 @@ interface ApiKeysVisibilityState { */ export function useApiKeysVisibility(): ApiKeysVisibilityState { const { ref: projectRef } = useParams() - const { can: canReadAPIKeys } = useAsyncCheckProjectPermissions(PermissionAction.READ, 'api_keys') + const { can: canReadAPIKeys } = useAsyncCheckPermissions(PermissionAction.READ, 'api_keys') const { data: apiKeysData, isLoading } = useAPIKeysQuery({ projectRef, diff --git a/apps/studio/components/interfaces/Auth/AdvancedAuthSettingsForm.tsx b/apps/studio/components/interfaces/Auth/AdvancedAuthSettingsForm.tsx index 9f498c43c16fc..26bd90de84dbf 100644 --- a/apps/studio/components/interfaces/Auth/AdvancedAuthSettingsForm.tsx +++ b/apps/studio/components/interfaces/Auth/AdvancedAuthSettingsForm.tsx @@ -12,7 +12,7 @@ import NoPermission from 'components/ui/NoPermission' import UpgradeToPro from 'components/ui/UpgradeToPro' import { useAuthConfigQuery } from 'data/auth/auth-config-query' import { useAuthConfigUpdateMutation } from 'data/auth/auth-config-update-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { IS_PLATFORM } from 'lib/constants' import { @@ -43,11 +43,11 @@ const FormSchema = z.object({ export const AdvancedAuthSettingsForm = () => { const { ref: projectRef } = useParams() const { data: organization } = useSelectedOrganizationQuery() - const { can: canReadConfig } = useAsyncCheckProjectPermissions( + const { can: canReadConfig } = useAsyncCheckPermissions( PermissionAction.READ, 'custom_config_gotrue' ) - const { can: canUpdateConfig } = useAsyncCheckProjectPermissions( + const { can: canUpdateConfig } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'custom_config_gotrue' ) diff --git a/apps/studio/components/interfaces/Auth/AuditLogsForm.tsx b/apps/studio/components/interfaces/Auth/AuditLogsForm.tsx index eb9ac33b0963f..b3e9ccded3448 100644 --- a/apps/studio/components/interfaces/Auth/AuditLogsForm.tsx +++ b/apps/studio/components/interfaces/Auth/AuditLogsForm.tsx @@ -8,11 +8,10 @@ import { boolean, object } from 'yup' import { useParams } from 'common' import { ScaffoldSection, ScaffoldSectionTitle } from 'components/layouts/Scaffold' import { InlineLink } from 'components/ui/InlineLink' -import { NoPermission } from 'components/ui/NoPermission' import { useAuthConfigQuery } from 'data/auth/auth-config-query' import { useAuthConfigUpdateMutation } from 'data/auth/auth-config-update-mutation' import { useTablesQuery } from 'data/tables/tables-query' -import { useCheckPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { AlertDescription_Shadcn_, @@ -40,8 +39,11 @@ const AUDIT_LOG_ENTRIES_TABLE = 'audit_log_entries' export const AuditLogsForm = () => { const { ref: projectRef } = useParams() const { data: project } = useSelectedProjectQuery() - const canReadConfig = useCheckPermissions(PermissionAction.READ, 'custom_config_gotrue') - const canUpdateConfig = useCheckPermissions(PermissionAction.UPDATE, 'custom_config_gotrue') + + const { can: canUpdateConfig } = useAsyncCheckPermissions( + PermissionAction.UPDATE, + 'custom_config_gotrue' + ) const { data: tables = [] } = useTablesQuery({ projectRef: project?.ref, @@ -91,10 +93,6 @@ export const AuditLogsForm = () => { ) } - if (!canReadConfig) { - return - } - return (
diff --git a/apps/studio/components/interfaces/Auth/AuthProvidersForm/ProviderForm.tsx b/apps/studio/components/interfaces/Auth/AuthProvidersForm/ProviderForm.tsx index 80284a6dec9f4..4a142cab825b9 100644 --- a/apps/studio/components/interfaces/Auth/AuthProvidersForm/ProviderForm.tsx +++ b/apps/studio/components/interfaces/Auth/AuthProvidersForm/ProviderForm.tsx @@ -14,7 +14,7 @@ import type { components } from 'data/api' import { useAuthConfigUpdateMutation } from 'data/auth/auth-config-update-mutation' import { useProjectSettingsV2Query } from 'data/config/project-settings-v2-query' import { useCustomDomainsQuery } from 'data/custom-domains/custom-domains-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { BASE_PATH } from 'lib/constants' import { Button, Form, Input, Sheet, SheetContent, SheetFooter, SheetHeader, SheetTitle } from 'ui' import { Admonition } from 'ui-patterns' @@ -38,7 +38,7 @@ export const ProviderForm = ({ config, provider, isActive }: ProviderFormProps) const [open, setOpen] = useState(false) const { mutate: updateAuthConfig, isLoading: isUpdatingConfig } = useAuthConfigUpdateMutation() - const { can: canUpdateConfig } = useAsyncCheckProjectPermissions( + const { can: canUpdateConfig } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'custom_config_gotrue' ) diff --git a/apps/studio/components/interfaces/Auth/BasicAuthSettingsForm/BasicAuthSettingsForm.tsx b/apps/studio/components/interfaces/Auth/BasicAuthSettingsForm/BasicAuthSettingsForm.tsx index 5ee44c4ba4b7e..af36ff6689b6e 100644 --- a/apps/studio/components/interfaces/Auth/BasicAuthSettingsForm/BasicAuthSettingsForm.tsx +++ b/apps/studio/components/interfaces/Auth/BasicAuthSettingsForm/BasicAuthSettingsForm.tsx @@ -13,7 +13,7 @@ import { InlineLink } from 'components/ui/InlineLink' import NoPermission from 'components/ui/NoPermission' import { useAuthConfigQuery } from 'data/auth/auth-config-query' import { useAuthConfigUpdateMutation } from 'data/auth/auth-config-update-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled' import { AlertDescription_Shadcn_, @@ -54,11 +54,11 @@ export const BasicAuthSettingsForm = () => { } = useAuthConfigQuery({ projectRef }) const { mutate: updateAuthConfig, isLoading: isUpdatingConfig } = useAuthConfigUpdateMutation() - const { can: canReadConfig, isSuccess: isPermissionsLoaded } = useAsyncCheckProjectPermissions( + const { can: canReadConfig, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissions( PermissionAction.READ, 'custom_config_gotrue' ) - const { can: canUpdateConfig } = useAsyncCheckProjectPermissions( + const { can: canUpdateConfig } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'custom_config_gotrue' ) diff --git a/apps/studio/components/interfaces/Auth/EmailTemplates/TemplateEditor.tsx b/apps/studio/components/interfaces/Auth/EmailTemplates/TemplateEditor.tsx index ae576925a302a..0ef99c3b567ed 100644 --- a/apps/studio/components/interfaces/Auth/EmailTemplates/TemplateEditor.tsx +++ b/apps/studio/components/interfaces/Auth/EmailTemplates/TemplateEditor.tsx @@ -11,7 +11,7 @@ import CodeEditor from 'components/ui/CodeEditor/CodeEditor' import { useAuthConfigQuery } from 'data/auth/auth-config-query' import { useAuthConfigUpdateMutation } from 'data/auth/auth-config-update-mutation' import { useValidateSpamMutation, ValidateSpamResponse } from 'data/auth/validate-spam-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import type { FormSchema } from 'types' import { Button, @@ -40,7 +40,7 @@ interface TemplateEditorProps { const TemplateEditor = ({ template }: TemplateEditorProps) => { const { ref: projectRef } = useParams() - const { can: canUpdateConfig } = useAsyncCheckProjectPermissions( + const { can: canUpdateConfig } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'custom_config_gotrue' ) diff --git a/apps/studio/components/interfaces/Auth/Hooks/AddHookDropdown.tsx b/apps/studio/components/interfaces/Auth/Hooks/AddHookDropdown.tsx index 0cb2986486950..ed20cca8654ea 100644 --- a/apps/studio/components/interfaces/Auth/Hooks/AddHookDropdown.tsx +++ b/apps/studio/components/interfaces/Auth/Hooks/AddHookDropdown.tsx @@ -4,7 +4,7 @@ import { ChevronDown } from 'lucide-react' import { useParams } from 'common' import { ButtonTooltip } from 'components/ui/ButtonTooltip' import { useAuthConfigQuery } from 'data/auth/auth-config-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { Button, @@ -33,10 +33,7 @@ export const AddHookDropdown = ({ const { data: organization } = useSelectedOrganizationQuery() const { data: authConfig } = useAuthConfigQuery({ projectRef }) - const { can: canUpdateAuthHook } = useAsyncCheckProjectPermissions( - PermissionAction.AUTH_EXECUTE, - '*' - ) + const { can: canUpdateAuthHook } = useAsyncCheckPermissions(PermissionAction.AUTH_EXECUTE, '*') const hooks: Hook[] = HOOKS_DEFINITIONS.map((definition) => { return { diff --git a/apps/studio/components/interfaces/Auth/Hooks/HookCard.tsx b/apps/studio/components/interfaces/Auth/Hooks/HookCard.tsx index cf5b65112e04a..e09e75bf28001 100644 --- a/apps/studio/components/interfaces/Auth/Hooks/HookCard.tsx +++ b/apps/studio/components/interfaces/Auth/Hooks/HookCard.tsx @@ -3,7 +3,7 @@ import { Check, Webhook } from 'lucide-react' import { ButtonTooltip } from 'components/ui/ButtonTooltip' import { DocsButton } from 'components/ui/DocsButton' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { Badge, Input, copyToClipboard } from 'ui' import { Hook } from './hooks.constants' @@ -13,10 +13,7 @@ interface HookCardProps { } export const HookCard = ({ hook, onSelect }: HookCardProps) => { - const { can: canUpdateAuthHook } = useAsyncCheckProjectPermissions( - PermissionAction.AUTH_EXECUTE, - '*' - ) + const { can: canUpdateAuthHook } = useAsyncCheckPermissions(PermissionAction.AUTH_EXECUTE, '*') return (
diff --git a/apps/studio/components/interfaces/Auth/MfaAuthSettingsForm/MfaAuthSettingsForm.tsx b/apps/studio/components/interfaces/Auth/MfaAuthSettingsForm/MfaAuthSettingsForm.tsx index 678e91226f71a..b6bf44c39bc42 100644 --- a/apps/studio/components/interfaces/Auth/MfaAuthSettingsForm/MfaAuthSettingsForm.tsx +++ b/apps/studio/components/interfaces/Auth/MfaAuthSettingsForm/MfaAuthSettingsForm.tsx @@ -11,7 +11,7 @@ import NoPermission from 'components/ui/NoPermission' import UpgradeToPro from 'components/ui/UpgradeToPro' import { useAuthConfigQuery } from 'data/auth/auth-config-query' import { useAuthConfigUpdateMutation } from 'data/auth/auth-config-update-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { IS_PLATFORM } from 'lib/constants' import { @@ -96,11 +96,11 @@ export const MfaAuthSettingsForm = () => { const [isConfirmationModalVisible, setIsConfirmationModalVisible] = useState(false) - const { can: canReadConfig } = useAsyncCheckProjectPermissions( + const { can: canReadConfig } = useAsyncCheckPermissions( PermissionAction.READ, 'custom_config_gotrue' ) - const { can: canUpdateConfig } = useAsyncCheckProjectPermissions( + const { can: canUpdateConfig } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'custom_config_gotrue' ) diff --git a/apps/studio/components/interfaces/Auth/Policies/PolicyEditorPanel/PolicyDetailsV2.tsx b/apps/studio/components/interfaces/Auth/Policies/PolicyEditorPanel/PolicyDetailsV2.tsx index 57a9340330396..dc48f93087ba8 100644 --- a/apps/studio/components/interfaces/Auth/Policies/PolicyEditorPanel/PolicyDetailsV2.tsx +++ b/apps/studio/components/interfaces/Auth/Policies/PolicyEditorPanel/PolicyDetailsV2.tsx @@ -5,7 +5,7 @@ import { UseFormReturn } from 'react-hook-form' import { useDatabaseRolesQuery } from 'data/database-roles/database-roles-query' import { useTablesQuery } from 'data/tables/tables-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { Button, @@ -62,7 +62,7 @@ export const PolicyDetailsV2 = ({ }: PolicyDetailsV2Props) => { const { data: project } = useSelectedProjectQuery() const [open, setOpen] = useState(false) - const { can: canUpdatePolicies } = useAsyncCheckProjectPermissions( + const { can: canUpdatePolicies } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_WRITE, 'tables' ) diff --git a/apps/studio/components/interfaces/Auth/Policies/PolicyEditorPanel/index.tsx b/apps/studio/components/interfaces/Auth/Policies/PolicyEditorPanel/index.tsx index ac3c2e99e3807..3ee605e2dbc7a 100644 --- a/apps/studio/components/interfaces/Auth/Policies/PolicyEditorPanel/index.tsx +++ b/apps/studio/components/interfaces/Auth/Policies/PolicyEditorPanel/index.tsx @@ -15,7 +15,7 @@ import { ButtonTooltip } from 'components/ui/ButtonTooltip' import { useDatabasePolicyUpdateMutation } from 'data/database-policies/database-policy-update-mutation' import { databasePoliciesKeys } from 'data/database-policies/keys' import { QueryResponseError, useExecuteSqlMutation } from 'data/sql/execute-sql-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { Button, @@ -67,7 +67,7 @@ export const PolicyEditorPanel = memo(function ({ const queryClient = useQueryClient() const { data: selectedProject } = useSelectedProjectQuery() - const { can: canUpdatePolicies } = useAsyncCheckProjectPermissions( + const { can: canUpdatePolicies } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_WRITE, 'tables' ) diff --git a/apps/studio/components/interfaces/Auth/Policies/PolicyTableRow/PolicyRow.tsx b/apps/studio/components/interfaces/Auth/Policies/PolicyTableRow/PolicyRow.tsx index 953d628c44e1b..9f97fe8dc93a6 100644 --- a/apps/studio/components/interfaces/Auth/Policies/PolicyTableRow/PolicyRow.tsx +++ b/apps/studio/components/interfaces/Auth/Policies/PolicyTableRow/PolicyRow.tsx @@ -5,7 +5,7 @@ import { Edit, MoreVertical, Trash } from 'lucide-react' import { DropdownMenuItemTooltip } from 'components/ui/DropdownMenuItemTooltip' import { useAuthConfigQuery } from 'data/auth/auth-config-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { useAiAssistantStateSnapshot } from 'state/ai-assistant-state' import { @@ -37,7 +37,7 @@ export const PolicyRow = ({ onSelectDeletePolicy = noop, }: PolicyRowProps) => { const aiSnap = useAiAssistantStateSnapshot() - const { can: canUpdatePolicies } = useAsyncCheckProjectPermissions( + const { can: canUpdatePolicies } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_WRITE, 'policies' ) diff --git a/apps/studio/components/interfaces/Auth/Policies/PolicyTableRow/PolicyTableRowHeader.tsx b/apps/studio/components/interfaces/Auth/Policies/PolicyTableRow/PolicyTableRowHeader.tsx index a4aa1911705b5..27fd57ac00a90 100644 --- a/apps/studio/components/interfaces/Auth/Policies/PolicyTableRow/PolicyTableRowHeader.tsx +++ b/apps/studio/components/interfaces/Auth/Policies/PolicyTableRow/PolicyTableRowHeader.tsx @@ -5,7 +5,7 @@ import { Lock, Table } from 'lucide-react' import { useParams } from 'common' import { ButtonTooltip } from 'components/ui/ButtonTooltip' import { EditorTablePageLink } from 'data/prefetchers/project.$ref.editor.$id' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useAiAssistantStateSnapshot } from 'state/ai-assistant-state' import { AiIconAnimation, Badge, CardTitle } from 'ui' @@ -35,11 +35,11 @@ export const PolicyTableRowHeader = ({ const { ref } = useParams() const aiSnap = useAiAssistantStateSnapshot() - const { can: canCreatePolicies } = useAsyncCheckProjectPermissions( + const { can: canCreatePolicies } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_WRITE, 'policies' ) - const { can: canToggleRLS } = useAsyncCheckProjectPermissions( + const { can: canToggleRLS } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_WRITE, 'tables' ) diff --git a/apps/studio/components/interfaces/Auth/ProtectionAuthSettingsForm/ProtectionAuthSettingsForm.tsx b/apps/studio/components/interfaces/Auth/ProtectionAuthSettingsForm/ProtectionAuthSettingsForm.tsx index 53bddf2acd937..791d1ccd6f1cf 100644 --- a/apps/studio/components/interfaces/Auth/ProtectionAuthSettingsForm/ProtectionAuthSettingsForm.tsx +++ b/apps/studio/components/interfaces/Auth/ProtectionAuthSettingsForm/ProtectionAuthSettingsForm.tsx @@ -12,7 +12,7 @@ import { InlineLink } from 'components/ui/InlineLink' import NoPermission from 'components/ui/NoPermission' import { useAuthConfigQuery } from 'data/auth/auth-config-query' import { useAuthConfigUpdateMutation } from 'data/auth/auth-config-update-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { AlertDescription_Shadcn_, AlertTitle_Shadcn_, @@ -80,11 +80,11 @@ export const ProtectionAuthSettingsForm = () => { }) const [hidden, setHidden] = useState(true) - const { can: canReadConfig } = useAsyncCheckProjectPermissions( + const { can: canReadConfig } = useAsyncCheckPermissions( PermissionAction.READ, 'custom_config_gotrue' ) - const { can: canUpdateConfig } = useAsyncCheckProjectPermissions( + const { can: canUpdateConfig } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'custom_config_gotrue' ) diff --git a/apps/studio/components/interfaces/Auth/RateLimits/RateLimits.tsx b/apps/studio/components/interfaces/Auth/RateLimits/RateLimits.tsx index ade0bf2464113..82a5a1e14d920 100644 --- a/apps/studio/components/interfaces/Auth/RateLimits/RateLimits.tsx +++ b/apps/studio/components/interfaces/Auth/RateLimits/RateLimits.tsx @@ -13,7 +13,7 @@ import NoPermission from 'components/ui/NoPermission' import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader' import { useAuthConfigQuery } from 'data/auth/auth-config-query' import { useAuthConfigUpdateMutation } from 'data/auth/auth-config-update-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { Button, Card, @@ -32,11 +32,11 @@ import { isSmtpEnabled } from '../SmtpForm/SmtpForm.utils' export const RateLimits = () => { const { ref: projectRef } = useParams() - const { can: canUpdateConfig } = useAsyncCheckProjectPermissions( + const { can: canUpdateConfig } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'custom_config_gotrue' ) - const { can: canReadConfig } = useAsyncCheckProjectPermissions( + const { can: canReadConfig } = useAsyncCheckPermissions( PermissionAction.READ, 'custom_config_gotrue' ) diff --git a/apps/studio/components/interfaces/Auth/RedirectUrls/RedirectUrlList.tsx b/apps/studio/components/interfaces/Auth/RedirectUrls/RedirectUrlList.tsx index fdcf729a56a9d..56b8644e1cb97 100644 --- a/apps/studio/components/interfaces/Auth/RedirectUrls/RedirectUrlList.tsx +++ b/apps/studio/components/interfaces/Auth/RedirectUrls/RedirectUrlList.tsx @@ -3,7 +3,7 @@ import { Globe, Trash } from 'lucide-react' import { ButtonTooltip } from 'components/ui/ButtonTooltip' import { EmptyListState } from 'components/ui/States' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { Button, Checkbox_Shadcn_ } from 'ui' import { ValueContainer } from './ValueContainer' @@ -24,7 +24,7 @@ export const RedirectUrlList = ({ onSelectRemoveURLs, onSelectClearSelection, }: RedirectUrlListProps) => { - const { can: canUpdateConfig } = useAsyncCheckProjectPermissions( + const { can: canUpdateConfig } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'custom_config_gotrue' ) diff --git a/apps/studio/components/interfaces/Auth/SessionsAuthSettingsForm/SessionsAuthSettingsForm.tsx b/apps/studio/components/interfaces/Auth/SessionsAuthSettingsForm/SessionsAuthSettingsForm.tsx index 0074539a98ca6..7ae7a7cc95825 100644 --- a/apps/studio/components/interfaces/Auth/SessionsAuthSettingsForm/SessionsAuthSettingsForm.tsx +++ b/apps/studio/components/interfaces/Auth/SessionsAuthSettingsForm/SessionsAuthSettingsForm.tsx @@ -11,7 +11,7 @@ import NoPermission from 'components/ui/NoPermission' import UpgradeToPro from 'components/ui/UpgradeToPro' import { useAuthConfigQuery } from 'data/auth/auth-config-query' import { useAuthConfigUpdateMutation } from 'data/auth/auth-config-update-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { IS_PLATFORM } from 'lib/constants' import { @@ -68,11 +68,11 @@ export const SessionsAuthSettingsForm = () => { const [isUpdatingRefreshTokens, setIsUpdatingRefreshTokens] = useState(false) const [isUpdatingUserSessions, setIsUpdatingUserSessions] = useState(false) - const { can: canReadConfig } = useAsyncCheckProjectPermissions( + const { can: canReadConfig } = useAsyncCheckPermissions( PermissionAction.READ, 'custom_config_gotrue' ) - const { can: canUpdateConfig } = useAsyncCheckProjectPermissions( + const { can: canUpdateConfig } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'custom_config_gotrue' ) diff --git a/apps/studio/components/interfaces/Auth/SiteUrl/SiteUrl.tsx b/apps/studio/components/interfaces/Auth/SiteUrl/SiteUrl.tsx index fd8a8a5b8d705..b1fe49a1f550e 100644 --- a/apps/studio/components/interfaces/Auth/SiteUrl/SiteUrl.tsx +++ b/apps/studio/components/interfaces/Auth/SiteUrl/SiteUrl.tsx @@ -10,7 +10,7 @@ import { useParams } from 'common' import { ScaffoldSection, ScaffoldSectionTitle } from 'components/layouts/Scaffold' import { useAuthConfigQuery } from 'data/auth/auth-config-query' import { useAuthConfigUpdateMutation } from 'data/auth/auth-config-update-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { AlertDescription_Shadcn_, AlertTitle_Shadcn_, @@ -36,7 +36,7 @@ const SiteUrl = () => { const { mutate: updateAuthConfig } = useAuthConfigUpdateMutation() const [isUpdatingSiteUrl, setIsUpdatingSiteUrl] = useState(false) - const { can: canUpdateConfig } = useAsyncCheckProjectPermissions( + const { can: canUpdateConfig } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'custom_config_gotrue' ) diff --git a/apps/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsx b/apps/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsx index 70d041d7f3f26..01cf200b2c40a 100644 --- a/apps/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsx +++ b/apps/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsx @@ -12,7 +12,7 @@ import { ScaffoldSection } from 'components/layouts/Scaffold' import NoPermission from 'components/ui/NoPermission' import { useAuthConfigQuery } from 'data/auth/auth-config-query' import { useAuthConfigUpdateMutation } from 'data/auth/auth-config-update-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { AlertDescription_Shadcn_, AlertTitle_Shadcn_, @@ -53,11 +53,11 @@ export const SmtpForm = () => { const [enableSmtp, setEnableSmtp] = useState(false) const [hidden, setHidden] = useState(true) - const { can: canReadConfig } = useAsyncCheckProjectPermissions( + const { can: canReadConfig } = useAsyncCheckPermissions( PermissionAction.READ, 'custom_config_gotrue' ) - const { can: canUpdateConfig } = useAsyncCheckProjectPermissions( + const { can: canUpdateConfig } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'custom_config_gotrue' ) diff --git a/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/index.tsx b/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/index.tsx index 456bf706e53b7..3962304fe178f 100644 --- a/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/index.tsx +++ b/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/index.tsx @@ -17,7 +17,7 @@ import { ThirdPartyAuthIntegration, useThirdPartyAuthIntegrationsQuery, } from 'data/third-party-auth/integrations-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { cn } from 'ui' import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal' import { AddIntegrationDropdown } from './AddIntegrationDropdown' @@ -49,7 +49,7 @@ export const ThirdPartyAuthForm = () => { useState() const { mutateAsync: deleteIntegration } = useDeleteThirdPartyAuthIntegrationMutation() - const { can: canUpdateConfig } = useAsyncCheckProjectPermissions( + const { can: canUpdateConfig } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'custom_config_gotrue' ) diff --git a/apps/studio/components/interfaces/Auth/Users/AddUserDropdown.tsx b/apps/studio/components/interfaces/Auth/Users/AddUserDropdown.tsx index 2a7ef3f1bee35..afb88ae48cbfa 100644 --- a/apps/studio/components/interfaces/Auth/Users/AddUserDropdown.tsx +++ b/apps/studio/components/interfaces/Auth/Users/AddUserDropdown.tsx @@ -3,7 +3,7 @@ import { ChevronDown, Mail, UserPlus } from 'lucide-react' import { useState } from 'react' import { DropdownMenuItemTooltip } from 'components/ui/DropdownMenuItemTooltip' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled' import { Button, DropdownMenu, DropdownMenuContent, DropdownMenuTrigger } from 'ui' import CreateUserModal from './CreateUserModal' @@ -12,11 +12,11 @@ import InviteUserModal from './InviteUserModal' export const AddUserDropdown = () => { const showSendInvitation = useIsFeatureEnabled('authentication:show_send_invitation') - const { can: canInviteUsers } = useAsyncCheckProjectPermissions( + const { can: canInviteUsers } = useAsyncCheckPermissions( PermissionAction.AUTH_EXECUTE, 'invite_user' ) - const { can: canCreateUsers } = useAsyncCheckProjectPermissions( + const { can: canCreateUsers } = useAsyncCheckPermissions( PermissionAction.AUTH_EXECUTE, 'create_user' ) diff --git a/apps/studio/components/interfaces/Auth/Users/CreateUserModal.tsx b/apps/studio/components/interfaces/Auth/Users/CreateUserModal.tsx index f2b630c369821..16ab8f410ffa6 100644 --- a/apps/studio/components/interfaces/Auth/Users/CreateUserModal.tsx +++ b/apps/studio/components/interfaces/Auth/Users/CreateUserModal.tsx @@ -7,7 +7,7 @@ import * as z from 'zod' import { useParams } from 'common' import { useUserCreateMutation } from 'data/auth/user-create-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { Button, Checkbox_Shadcn_, @@ -38,7 +38,7 @@ const CreateUserFormSchema = z.object({ const CreateUserModal = ({ visible, setVisible }: CreateUserModalProps) => { const { ref: projectRef } = useParams() - const { can: canCreateUsers } = useAsyncCheckProjectPermissions( + const { can: canCreateUsers } = useAsyncCheckPermissions( PermissionAction.AUTH_EXECUTE, 'create_user' ) diff --git a/apps/studio/components/interfaces/Auth/Users/InviteUserModal.tsx b/apps/studio/components/interfaces/Auth/Users/InviteUserModal.tsx index d25657452053e..0fca24fe1d679 100644 --- a/apps/studio/components/interfaces/Auth/Users/InviteUserModal.tsx +++ b/apps/studio/components/interfaces/Auth/Users/InviteUserModal.tsx @@ -4,7 +4,7 @@ import { toast } from 'sonner' import { useParams } from 'common' import { useUserInviteMutation } from 'data/auth/user-invite-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { Button, Form, Input, Modal } from 'ui' export type InviteUserModalProps = { @@ -22,7 +22,7 @@ const InviteUserModal = ({ visible, setVisible }: InviteUserModalProps) => { setVisible(false) }, }) - const { can: canInviteUsers } = useAsyncCheckProjectPermissions( + const { can: canInviteUsers } = useAsyncCheckPermissions( PermissionAction.AUTH_EXECUTE, 'invite_user' ) diff --git a/apps/studio/components/interfaces/Auth/Users/UserOverview.tsx b/apps/studio/components/interfaces/Auth/Users/UserOverview.tsx index 7737da47b31ba..c0d67fe41931e 100644 --- a/apps/studio/components/interfaces/Auth/Users/UserOverview.tsx +++ b/apps/studio/components/interfaces/Auth/Users/UserOverview.tsx @@ -15,7 +15,7 @@ import { useUserSendMagicLinkMutation } from 'data/auth/user-send-magic-link-mut import { useUserSendOTPMutation } from 'data/auth/user-send-otp-mutation' import { useUserUpdateMutation } from 'data/auth/user-update-mutation' import { User } from 'data/auth/users-infinite-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled' import { BASE_PATH } from 'lib/constants' import { timeout } from 'lib/helpers' @@ -64,24 +64,21 @@ export const UserOverview = ({ user, onDeleteSuccess }: UserOverviewProps) => { } ) - const { can: canUpdateUser } = useAsyncCheckProjectPermissions(PermissionAction.AUTH_EXECUTE, '*') - const { can: canSendMagicLink } = useAsyncCheckProjectPermissions( + const { can: canUpdateUser } = useAsyncCheckPermissions(PermissionAction.AUTH_EXECUTE, '*') + const { can: canSendMagicLink } = useAsyncCheckPermissions( PermissionAction.AUTH_EXECUTE, 'send_magic_link' ) - const { can: canSendRecovery } = useAsyncCheckProjectPermissions( + const { can: canSendRecovery } = useAsyncCheckPermissions( PermissionAction.AUTH_EXECUTE, 'send_recovery' ) - const { can: canSendOtp } = useAsyncCheckProjectPermissions( - PermissionAction.AUTH_EXECUTE, - 'send_otp' - ) - const { can: canRemoveUser } = useAsyncCheckProjectPermissions( + const { can: canSendOtp } = useAsyncCheckPermissions(PermissionAction.AUTH_EXECUTE, 'send_otp') + const { can: canRemoveUser } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_DELETE, 'auth.users' ) - const { can: canRemoveMFAFactors } = useAsyncCheckProjectPermissions( + const { can: canRemoveMFAFactors } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_DELETE, 'auth.mfa_factors' ) diff --git a/apps/studio/components/interfaces/Billing/Payment/PaymentMethods/CurrentPaymentMethod.tsx b/apps/studio/components/interfaces/Billing/Payment/PaymentMethods/CurrentPaymentMethod.tsx index 31480f91c49b8..ca6c338b01556 100644 --- a/apps/studio/components/interfaces/Billing/Payment/PaymentMethods/CurrentPaymentMethod.tsx +++ b/apps/studio/components/interfaces/Billing/Payment/PaymentMethods/CurrentPaymentMethod.tsx @@ -6,7 +6,7 @@ import { useParams } from 'common' import ShimmeringLoader from 'components/ui/ShimmeringLoader' import { useOrganizationPaymentMethodsQuery } from 'data/organizations/organization-payment-methods-query' import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { Button } from 'ui' import CreditCard from './CreditCard' @@ -31,7 +31,7 @@ const CurrentPaymentMethod = () => { const defaultPaymentMethod = paymentMethods?.data.find((pm) => pm.is_default) - const { can: canReadPaymentMethods } = useAsyncCheckProjectPermissions( + const { can: canReadPaymentMethods } = useAsyncCheckPermissions( PermissionAction.BILLING_READ, 'stripe.payment_methods' ) diff --git a/apps/studio/components/interfaces/Billing/Payment/PaymentMethods/PaymentMethods.tsx b/apps/studio/components/interfaces/Billing/Payment/PaymentMethods/PaymentMethods.tsx index 95d7d1b1076f6..e75c4a0ed2480 100644 --- a/apps/studio/components/interfaces/Billing/Payment/PaymentMethods/PaymentMethods.tsx +++ b/apps/studio/components/interfaces/Billing/Payment/PaymentMethods/PaymentMethods.tsx @@ -19,7 +19,7 @@ import PartnerManagedResource from 'components/ui/PartnerManagedResource' import ShimmeringLoader from 'components/ui/ShimmeringLoader' import { useOrganizationPaymentMethodsQuery } from 'data/organizations/organization-payment-methods-query' import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { MANAGED_BY } from 'lib/constants/infrastructure' import { getURL } from 'lib/helpers' @@ -44,9 +44,11 @@ const PaymentMethods = () => { isSuccess, } = useOrganizationPaymentMethodsQuery({ slug }) - const { can: canReadPaymentMethods, isSuccess: isPermissionsLoaded } = - useAsyncCheckProjectPermissions(PermissionAction.BILLING_READ, 'stripe.payment_methods') - const { can: canUpdatePaymentMethods } = useAsyncCheckProjectPermissions( + const { can: canReadPaymentMethods, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissions( + PermissionAction.BILLING_READ, + 'stripe.payment_methods' + ) + const { can: canUpdatePaymentMethods } = useAsyncCheckPermissions( PermissionAction.BILLING_WRITE, 'stripe.payment_methods' ) diff --git a/apps/studio/components/interfaces/BranchManagement/CreateBranchModal.tsx b/apps/studio/components/interfaces/BranchManagement/CreateBranchModal.tsx index 6ca4120b6c9fc..668a627bf0a20 100644 --- a/apps/studio/components/interfaces/BranchManagement/CreateBranchModal.tsx +++ b/apps/studio/components/interfaces/BranchManagement/CreateBranchModal.tsx @@ -27,7 +27,7 @@ import { projectKeys } from 'data/projects/keys' import { DesiredInstanceSize, instanceSizeSpecs } from 'data/projects/new-project.constants' import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query' import { useSendEventMutation } from 'data/telemetry/send-event-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { BASE_PATH, IS_PLATFORM } from 'lib/constants' @@ -72,7 +72,7 @@ export const CreateBranchModal = () => { const gitlessBranching = useIsBranching2Enabled() const allowDataBranching = useFlag('allowDataBranching') - const { can: canCreateBranch } = useAsyncCheckProjectPermissions( + const { can: canCreateBranch } = useAsyncCheckPermissions( PermissionAction.CREATE, 'preview_branches' ) diff --git a/apps/studio/components/interfaces/BranchManagement/Overview.tsx b/apps/studio/components/interfaces/BranchManagement/Overview.tsx index 88257f88afda3..887ada063ae7d 100644 --- a/apps/studio/components/interfaces/BranchManagement/Overview.tsx +++ b/apps/studio/components/interfaces/BranchManagement/Overview.tsx @@ -23,7 +23,7 @@ import { useBranchResetMutation } from 'data/branches/branch-reset-mutation' import { useBranchUpdateMutation } from 'data/branches/branch-update-mutation' import type { Branch } from 'data/branches/branches-query' import { branchKeys } from 'data/branches/keys' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { Button, DropdownMenu, @@ -169,11 +169,11 @@ const PreviewBranchActions = ({ const queryClient = useQueryClient() const projectRef = branch.parent_project_ref ?? branch.project_ref - const { can: canDeleteBranches } = useAsyncCheckProjectPermissions( + const { can: canDeleteBranches } = useAsyncCheckPermissions( PermissionAction.DELETE, 'preview_branches' ) - const { can: canUpdateBranches } = useAsyncCheckProjectPermissions( + const { can: canUpdateBranches } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'preview_branches' ) @@ -387,7 +387,7 @@ const PreviewBranchActions = ({ // Actions for main (production) branch const MainBranchActions = ({ branch, repo }: { branch: Branch; repo: string }) => { const { ref: projectRef } = useParams() - const { can: canUpdateBranches } = useAsyncCheckProjectPermissions( + const { can: canUpdateBranches } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'preview_branches' ) diff --git a/apps/studio/components/interfaces/Connect/Connect.tsx b/apps/studio/components/interfaces/Connect/Connect.tsx index 7a816671e1193..7a6f1e2133358 100644 --- a/apps/studio/components/interfaces/Connect/Connect.tsx +++ b/apps/studio/components/interfaces/Connect/Connect.tsx @@ -9,7 +9,7 @@ import { ButtonTooltip } from 'components/ui/ButtonTooltip' import Panel from 'components/ui/Panel' import { getKeys, useAPIKeysQuery } from 'data/api-keys/api-keys-query' import { useProjectSettingsV2Query } from 'data/config/project-settings-v2-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { PROJECT_STATUS } from 'lib/constants' @@ -99,7 +99,7 @@ export const Connect = () => { ) const { data: settings } = useProjectSettingsV2Query({ projectRef }, { enabled: showConnect }) - const { can: canReadAPIKeys } = useAsyncCheckProjectPermissions( + const { can: canReadAPIKeys } = useAsyncCheckPermissions( PermissionAction.READ, 'service_api_keys' ) diff --git a/apps/studio/components/interfaces/Database/Backups/BackupItem.tsx b/apps/studio/components/interfaces/Database/Backups/BackupItem.tsx index dbe0a9ca5e440..85a69d5680e9b 100644 --- a/apps/studio/components/interfaces/Database/Backups/BackupItem.tsx +++ b/apps/studio/components/interfaces/Database/Backups/BackupItem.tsx @@ -6,7 +6,7 @@ import { ButtonTooltip } from 'components/ui/ButtonTooltip' import { InlineLink } from 'components/ui/InlineLink' import { useBackupDownloadMutation } from 'data/database/backup-download-mutation' import type { DatabaseBackup } from 'data/database/backups-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { Badge, Tooltip, TooltipContent, TooltipTrigger } from 'ui' import { TimestampInfo } from 'ui-patterns' @@ -19,7 +19,7 @@ interface BackupItemProps { export const BackupItem = ({ index, isHealthy, backup, onSelectBackup }: BackupItemProps) => { const { ref: projectRef } = useParams() - const { can: canTriggerScheduledBackups } = useAsyncCheckProjectPermissions( + const { can: canTriggerScheduledBackups } = useAsyncCheckPermissions( PermissionAction.INFRA_EXECUTE, 'queue_job.restore.prepare' ) diff --git a/apps/studio/components/interfaces/Database/Backups/PITR/PITRNotice.tsx b/apps/studio/components/interfaces/Database/Backups/PITR/PITRNotice.tsx index 33a4d11e0b816..05b8faf99466d 100644 --- a/apps/studio/components/interfaces/Database/Backups/PITR/PITRNotice.tsx +++ b/apps/studio/components/interfaces/Database/Backups/PITR/PITRNotice.tsx @@ -6,7 +6,7 @@ import { useParams } from 'common' import { ButtonTooltip } from 'components/ui/ButtonTooltip' import { FormPanel } from 'components/ui/Forms/FormPanel' import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { getPITRRetentionDuration } from './PITR.utils' const PITRNotice = ({}) => { @@ -14,7 +14,7 @@ const PITRNotice = ({}) => { const { data: addonsResponse } = useProjectAddonsQuery({ projectRef }) const retentionPeriod = getPITRRetentionDuration(addonsResponse?.selected_addons ?? []) - const { can: canUpdateSubscription } = useAsyncCheckProjectPermissions( + const { can: canUpdateSubscription } = useAsyncCheckPermissions( PermissionAction.BILLING_WRITE, 'stripe.subscriptions' ) diff --git a/apps/studio/components/interfaces/Database/Backups/PITR/PITRStatus.tsx b/apps/studio/components/interfaces/Database/Backups/PITR/PITRStatus.tsx index 0f77410269344..763ede84c069e 100644 --- a/apps/studio/components/interfaces/Database/Backups/PITR/PITRStatus.tsx +++ b/apps/studio/components/interfaces/Database/Backups/PITR/PITRStatus.tsx @@ -7,7 +7,7 @@ import { ButtonTooltip } from 'components/ui/ButtonTooltip' import { FormPanel } from 'components/ui/Forms/FormPanel' import { useBackupsQuery } from 'data/database/backups-query' import { useReadReplicasQuery } from 'data/read-replicas/replicas-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import type { Timezone } from './PITR.types' import { TimezoneSelection } from './TimezoneSelection' @@ -41,7 +41,7 @@ const PITRStatus = ({ .tz(selectedTimezone?.utc[0]) .format('DD MMM YYYY, HH:mm:ss') - const { can: canTriggerPhysicalBackup } = useAsyncCheckProjectPermissions( + const { can: canTriggerPhysicalBackup } = useAsyncCheckPermissions( PermissionAction.INFRA_EXECUTE, 'queue_job.walg.prepare_restore' ) diff --git a/apps/studio/components/interfaces/Database/Extensions/ExtensionRow.tsx b/apps/studio/components/interfaces/Database/Extensions/ExtensionRow.tsx index 45e3985ef839e..3139f8286e776 100644 --- a/apps/studio/components/interfaces/Database/Extensions/ExtensionRow.tsx +++ b/apps/studio/components/interfaces/Database/Extensions/ExtensionRow.tsx @@ -7,7 +7,7 @@ import { toast } from 'sonner' import { ButtonTooltip } from 'components/ui/ButtonTooltip' import { useDatabaseExtensionDisableMutation } from 'data/database-extensions/database-extension-disable-mutation' import { DatabaseExtension } from 'data/database-extensions/database-extensions-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useIsOrioleDb, useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { extensions } from 'shared-data' import { Button, Switch, TableCell, TableRow, Tooltip, TooltipContent, TooltipTrigger } from 'ui' @@ -28,7 +28,7 @@ export const ExtensionRow = ({ extension }: ExtensionRowProps) => { const [isDisableModalOpen, setIsDisableModalOpen] = useState(false) const [showConfirmEnableModal, setShowConfirmEnableModal] = useState(false) - const { can: canUpdateExtensions } = useAsyncCheckProjectPermissions( + const { can: canUpdateExtensions } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_WRITE, 'extensions' ) diff --git a/apps/studio/components/interfaces/Database/Extensions/Extensions.tsx b/apps/studio/components/interfaces/Database/Extensions/Extensions.tsx index 3e170bcd7f03a..0885380baa284 100644 --- a/apps/studio/components/interfaces/Database/Extensions/Extensions.tsx +++ b/apps/studio/components/interfaces/Database/Extensions/Extensions.tsx @@ -9,7 +9,7 @@ import InformationBox from 'components/ui/InformationBox' import NoSearchResults from 'components/ui/NoSearchResults' import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader' import { useDatabaseExtensionsQuery } from 'data/database-extensions/database-extensions-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { Card, @@ -51,8 +51,10 @@ export const Extensions = () => { (ext) => !isNull(ext.installed_version) ) - const { can: canUpdateExtensions, isSuccess: isPermissionsLoaded } = - useAsyncCheckProjectPermissions(PermissionAction.TENANT_SQL_ADMIN_WRITE, 'extensions') + const { can: canUpdateExtensions, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissions( + PermissionAction.TENANT_SQL_ADMIN_WRITE, + 'extensions' + ) useEffect(() => { if (filter !== undefined) setFilterString(filter as string) diff --git a/apps/studio/components/interfaces/Database/Functions/FunctionsList/FunctionList.tsx b/apps/studio/components/interfaces/Database/Functions/FunctionsList/FunctionList.tsx index 680755b6c3263..b2e7d008db22c 100644 --- a/apps/studio/components/interfaces/Database/Functions/FunctionsList/FunctionList.tsx +++ b/apps/studio/components/interfaces/Database/Functions/FunctionsList/FunctionList.tsx @@ -5,7 +5,7 @@ import { useRouter } from 'next/router' import { ButtonTooltip } from 'components/ui/ButtonTooltip' import { useDatabaseFunctionsQuery } from 'data/database-functions/database-functions-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { useAiAssistantStateSnapshot } from 'state/ai-assistant-state' import { @@ -15,8 +15,8 @@ import { DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, - TableRow, TableCell, + TableRow, } from 'ui' interface FunctionListProps { @@ -51,7 +51,7 @@ const FunctionList = ({ (func) => func.name.toLocaleLowerCase() ) const projectRef = selectedProject?.ref - const { can: canUpdateFunctions } = useAsyncCheckProjectPermissions( + const { can: canUpdateFunctions } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_WRITE, 'functions' ) diff --git a/apps/studio/components/interfaces/Database/Functions/FunctionsList/FunctionsList.tsx b/apps/studio/components/interfaces/Database/Functions/FunctionsList/FunctionsList.tsx index bc8f73b826ac5..82ca681b97347 100644 --- a/apps/studio/components/interfaces/Database/Functions/FunctionsList/FunctionsList.tsx +++ b/apps/studio/components/interfaces/Database/Functions/FunctionsList/FunctionsList.tsx @@ -12,21 +12,20 @@ import SchemaSelector from 'components/ui/SchemaSelector' import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader' import { useDatabaseFunctionsQuery } from 'data/database-functions/database-functions-query' import { useSchemasQuery } from 'data/database/schemas-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useQuerySchemaState } from 'hooks/misc/useSchemaQueryState' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { useIsProtectedSchema } from 'hooks/useProtectedSchemas' import { useAiAssistantStateSnapshot } from 'state/ai-assistant-state' import { AiIconAnimation, + Card, Input, Table, - TableHeader, - TableHead, TableBody, + TableHead, + TableHeader, TableRow, - TableCell, - Card, } from 'ui' import { ProtectedSchemaWarning } from '../../ProtectedSchemaWarning' import FunctionList from './FunctionList' @@ -60,7 +59,7 @@ const FunctionsList = ({ router.push(url) } - const { can: canCreateFunctions } = useAsyncCheckProjectPermissions( + const { can: canCreateFunctions } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_WRITE, 'functions' ) diff --git a/apps/studio/components/interfaces/Database/Hooks/HooksList/HookList.tsx b/apps/studio/components/interfaces/Database/Hooks/HooksList/HookList.tsx index c259acb39d0c5..5ef24ae87f65f 100644 --- a/apps/studio/components/interfaces/Database/Hooks/HooksList/HookList.tsx +++ b/apps/studio/components/interfaces/Database/Hooks/HooksList/HookList.tsx @@ -8,7 +8,7 @@ import { useParams } from 'common' import Table from 'components/to-be-cleaned/Table' import { ButtonTooltip } from 'components/ui/ButtonTooltip' import { useDatabaseHooksQuery } from 'data/database-triggers/database-triggers-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { BASE_PATH } from 'lib/constants' import { @@ -50,7 +50,7 @@ export const HookList = ({ x.schema === schema && x.function_args.length >= 2 ) - const { can: canUpdateWebhook } = useAsyncCheckProjectPermissions( + const { can: canUpdateWebhook } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_WRITE, 'triggers' ) diff --git a/apps/studio/components/interfaces/Database/Hooks/HooksList/HooksList.tsx b/apps/studio/components/interfaces/Database/Hooks/HooksList/HooksList.tsx index a53ac137264b8..7e43bf126ace6 100644 --- a/apps/studio/components/interfaces/Database/Hooks/HooksList/HooksList.tsx +++ b/apps/studio/components/interfaces/Database/Hooks/HooksList/HooksList.tsx @@ -10,7 +10,7 @@ import { DocsButton } from 'components/ui/DocsButton' import NoSearchResults from 'components/ui/NoSearchResults' import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader' import { useDatabaseHooksQuery } from 'data/database-triggers/database-triggers-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { noop } from 'lib/void' import { Input } from 'ui' @@ -46,8 +46,10 @@ export const HooksList = ({ ) const filteredHookSchemas = lodashMap(uniqBy(filteredHooks, 'schema'), 'schema') - const { can: canCreateWebhooks, isSuccess: isPermissionsLoaded } = - useAsyncCheckProjectPermissions(PermissionAction.TENANT_SQL_ADMIN_WRITE, 'triggers') + const { can: canCreateWebhooks, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissions( + PermissionAction.TENANT_SQL_ADMIN_WRITE, + 'triggers' + ) return (
diff --git a/apps/studio/components/interfaces/Database/Publications/PublicationsList.tsx b/apps/studio/components/interfaces/Database/Publications/PublicationsList.tsx index deb947dd863c9..6bb04e304d198 100644 --- a/apps/studio/components/interfaces/Database/Publications/PublicationsList.tsx +++ b/apps/studio/components/interfaces/Database/Publications/PublicationsList.tsx @@ -10,7 +10,7 @@ import InformationBox from 'components/ui/InformationBox' import NoSearchResults from 'components/ui/NoSearchResults' import { useDatabasePublicationsQuery } from 'data/database-publications/database-publications-query' import { useDatabasePublicationUpdateMutation } from 'data/database-publications/database-publications-update-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { Button, @@ -57,8 +57,10 @@ export const PublicationsList = () => { }, }) - const { can: canUpdatePublications, isSuccess: isPermissionsLoaded } = - useAsyncCheckProjectPermissions(PermissionAction.TENANT_SQL_ADMIN_WRITE, 'publications') + const { can: canUpdatePublications, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissions( + PermissionAction.TENANT_SQL_ADMIN_WRITE, + 'publications' + ) const publicationEvents: PublicationEvent[] = [ { event: 'Insert', key: 'publish_insert' }, diff --git a/apps/studio/components/interfaces/Database/Publications/PublicationsTableItem.tsx b/apps/studio/components/interfaces/Database/Publications/PublicationsTableItem.tsx index b7a8425e0026d..c5aec787a996d 100644 --- a/apps/studio/components/interfaces/Database/Publications/PublicationsTableItem.tsx +++ b/apps/studio/components/interfaces/Database/Publications/PublicationsTableItem.tsx @@ -4,7 +4,7 @@ import { useState } from 'react' import { toast } from 'sonner' import { useDatabasePublicationUpdateMutation } from 'data/database-publications/database-publications-update-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { useProtectedSchemas } from 'hooks/useProtectedSchemas' import { Badge, Switch, TableCell, TableRow, Tooltip, TooltipContent, TooltipTrigger } from 'ui' @@ -28,7 +28,7 @@ export const PublicationsTableItem = ({ selectedPublication.tables?.find((x: any) => x.id == table.id) != undefined ) - const { can: canUpdatePublications } = useAsyncCheckProjectPermissions( + const { can: canUpdatePublications } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_WRITE, 'publications' ) diff --git a/apps/studio/components/interfaces/Database/Publications/PublicationsTables.tsx b/apps/studio/components/interfaces/Database/Publications/PublicationsTables.tsx index fe55650d79a6b..48931a50560d1 100644 --- a/apps/studio/components/interfaces/Database/Publications/PublicationsTables.tsx +++ b/apps/studio/components/interfaces/Database/Publications/PublicationsTables.tsx @@ -10,7 +10,7 @@ import { ButtonTooltip } from 'components/ui/ButtonTooltip' import { Loading } from 'components/ui/Loading' import { useDatabasePublicationsQuery } from 'data/database-publications/database-publications-query' import { useTablesQuery } from 'data/tables/tables-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { Card, Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from 'ui' import { Admonition } from 'ui-patterns' @@ -22,8 +22,10 @@ export const PublicationsTables = () => { const { data: project } = useSelectedProjectQuery() const [filterString, setFilterString] = useState('') - const { can: canUpdatePublications, isLoading: isLoadingPermissions } = - useAsyncCheckProjectPermissions(PermissionAction.TENANT_SQL_ADMIN_WRITE, 'publications') + const { can: canUpdatePublications, isLoading: isLoadingPermissions } = useAsyncCheckPermissions( + PermissionAction.TENANT_SQL_ADMIN_WRITE, + 'publications' + ) const { data: publications = [] } = useDatabasePublicationsQuery({ projectRef: project?.ref, diff --git a/apps/studio/components/interfaces/Database/Roles/RolesList.tsx b/apps/studio/components/interfaces/Database/Roles/RolesList.tsx index 1385c807f34a1..f18ec8b90647e 100644 --- a/apps/studio/components/interfaces/Database/Roles/RolesList.tsx +++ b/apps/studio/components/interfaces/Database/Roles/RolesList.tsx @@ -8,7 +8,7 @@ import NoSearchResults from 'components/ui/NoSearchResults' import SparkBar from 'components/ui/SparkBar' import { useDatabaseRolesQuery } from 'data/database-roles/database-roles-query' import { useMaxConnectionsQuery } from 'data/database/max-connections-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { Badge, Button, Input, Tooltip, TooltipContent, TooltipTrigger } from 'ui' import { CreateRolePanel } from './CreateRolePanel' @@ -27,7 +27,7 @@ const RolesList = () => { const [isCreatingRole, setIsCreatingRole] = useState(false) const [selectedRoleToDelete, setSelectedRoleToDelete] = useState() - const { can: canUpdateRoles } = useAsyncCheckProjectPermissions( + const { can: canUpdateRoles } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_WRITE, 'roles' ) diff --git a/apps/studio/components/interfaces/Database/Tables/ColumnList.tsx b/apps/studio/components/interfaces/Database/Tables/ColumnList.tsx index 83aaf0cacef96..a4e9c23bca2e4 100644 --- a/apps/studio/components/interfaces/Database/Tables/ColumnList.tsx +++ b/apps/studio/components/interfaces/Database/Tables/ColumnList.tsx @@ -13,7 +13,7 @@ import { ButtonTooltip } from 'components/ui/ButtonTooltip' import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader' import { useTableEditorQuery } from 'data/table-editor/table-editor-query' import { isTableLike } from 'data/table-editor/table-editor-types' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { useIsProtectedSchema } from 'hooks/useProtectedSchemas' import { @@ -65,7 +65,7 @@ export const ColumnList = ({ : selectedTable?.columns?.filter((column) => column.name.includes(filterString))) ?? [] const { isSchemaLocked } = useIsProtectedSchema({ schema: selectedTable?.schema ?? '' }) - const { can: canUpdateColumns } = useAsyncCheckProjectPermissions( + const { can: canUpdateColumns } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_WRITE, 'columns' ) diff --git a/apps/studio/components/interfaces/Database/Tables/TableList.tsx b/apps/studio/components/interfaces/Database/Tables/TableList.tsx index 5d08596a5218a..a54046da943fb 100644 --- a/apps/studio/components/interfaces/Database/Tables/TableList.tsx +++ b/apps/studio/components/interfaces/Database/Tables/TableList.tsx @@ -32,7 +32,7 @@ import { useMaterializedViewsQuery } from 'data/materialized-views/materialized- import { usePrefetchEditorTablePage } from 'data/prefetchers/project.$ref.editor.$id' import { useTablesQuery } from 'data/tables/tables-query' import { useViewsQuery } from 'data/views/views-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useQuerySchemaState } from 'hooks/misc/useSchemaQueryState' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { useIsProtectedSchema } from 'hooks/useProtectedSchemas' @@ -50,15 +50,15 @@ import { PopoverContent_Shadcn_, PopoverTrigger_Shadcn_, Popover_Shadcn_, - Tooltip, - TooltipContent, - TooltipTrigger, Table, - TableHeader, - TableHead, TableBody, - TableRow, TableCell, + TableHead, + TableHeader, + TableRow, + Tooltip, + TooltipContent, + TooltipTrigger, cn, } from 'ui' import { ProtectedSchemaWarning } from '../ProtectedSchemaWarning' @@ -88,7 +88,7 @@ export const TableList = ({ const [filterString, setFilterString] = useState('') const [visibleTypes, setVisibleTypes] = useState(Object.values(ENTITY_TYPE)) - const { can: canUpdateTables } = useAsyncCheckProjectPermissions( + const { can: canUpdateTables } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_WRITE, 'tables' ) diff --git a/apps/studio/components/interfaces/Database/Triggers/TriggersList/TriggerList.tsx b/apps/studio/components/interfaces/Database/Triggers/TriggersList/TriggerList.tsx index f78e526252bc5..bb2fede7e02d0 100644 --- a/apps/studio/components/interfaces/Database/Triggers/TriggersList/TriggerList.tsx +++ b/apps/studio/components/interfaces/Database/Triggers/TriggersList/TriggerList.tsx @@ -2,10 +2,9 @@ import { PermissionAction } from '@supabase/shared-types/out/constants' import { includes, sortBy } from 'lodash' import { Check, Edit, Edit2, MoreVertical, Trash, X } from 'lucide-react' -import Table from 'components/to-be-cleaned/Table' import { ButtonTooltip } from 'components/ui/ButtonTooltip' import { useDatabaseTriggersQuery } from 'data/database-triggers/database-triggers-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { useAiAssistantStateSnapshot } from 'state/ai-assistant-state' import { @@ -15,11 +14,11 @@ import { DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, + TableCell, + TableRow, Tooltip, TooltipContent, TooltipTrigger, - TableRow, - TableCell, } from 'ui' import { generateTriggerCreateSQL } from './TriggerList.utils' @@ -53,7 +52,7 @@ const TriggerList = ({ filteredTriggers.filter((x) => x.schema == schema), (trigger) => trigger.name.toLocaleLowerCase() ) - const { can: canUpdateTriggers } = useAsyncCheckProjectPermissions( + const { can: canUpdateTriggers } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_WRITE, 'triggers' ) diff --git a/apps/studio/components/interfaces/Database/Triggers/TriggersList/TriggersList.tsx b/apps/studio/components/interfaces/Database/Triggers/TriggersList/TriggersList.tsx index a9097f7190d0a..3d6f2287f0a1b 100644 --- a/apps/studio/components/interfaces/Database/Triggers/TriggersList/TriggersList.tsx +++ b/apps/studio/components/interfaces/Database/Triggers/TriggersList/TriggersList.tsx @@ -12,21 +12,20 @@ import SchemaSelector from 'components/ui/SchemaSelector' import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader' import { useDatabaseTriggersQuery } from 'data/database-triggers/database-triggers-query' import { useTablesQuery } from 'data/tables/tables-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useQuerySchemaState } from 'hooks/misc/useSchemaQueryState' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { useIsProtectedSchema, useProtectedSchemas } from 'hooks/useProtectedSchemas' import { useAiAssistantStateSnapshot } from 'state/ai-assistant-state' import { AiIconAnimation, - Input, Card, + Input, Table, - TableHeader, - TableHead, TableBody, + TableHead, + TableHeader, TableRow, - TableCell, } from 'ui' import { ProtectedSchemaWarning } from '../../ProtectedSchemaWarning' import TriggerList from './TriggerList' @@ -67,7 +66,7 @@ const TriggersList = ({ connectionString: project?.connectionString, }) - const { can: canCreateTriggers } = useAsyncCheckProjectPermissions( + const { can: canCreateTriggers } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_WRITE, 'triggers' ) diff --git a/apps/studio/components/interfaces/DiskManagement/DiskManagementForm.tsx b/apps/studio/components/interfaces/DiskManagement/DiskManagementForm.tsx index 8cb6d6c6ee065..cf0757aee7908 100644 --- a/apps/studio/components/interfaces/DiskManagement/DiskManagementForm.tsx +++ b/apps/studio/components/interfaces/DiskManagement/DiskManagementForm.tsx @@ -25,7 +25,7 @@ import { useProjectAddonUpdateMutation } from 'data/subscriptions/project-addon- import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query' import { AddonVariantId } from 'data/subscriptions/types' import { useResourceWarningsQuery } from 'data/usage/resource-warnings-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { useIsAwsCloudProvider, @@ -80,7 +80,7 @@ export function DiskManagementForm() { const isAwsK8s = useIsAwsK8sCloudProvider() const { can: canUpdateDiskConfiguration, isSuccess: isPermissionsLoaded } = - useAsyncCheckProjectPermissions(PermissionAction.UPDATE, 'projects', { + useAsyncCheckPermissions(PermissionAction.UPDATE, 'projects', { resource: { project_id: project?.id, }, diff --git a/apps/studio/components/interfaces/DiskManagement/DiskManagementReviewAndSubmitDialog.tsx b/apps/studio/components/interfaces/DiskManagement/DiskManagementReviewAndSubmitDialog.tsx index 89512705ff584..ec8d3ef146d6e 100644 --- a/apps/studio/components/interfaces/DiskManagement/DiskManagementReviewAndSubmitDialog.tsx +++ b/apps/studio/components/interfaces/DiskManagement/DiskManagementReviewAndSubmitDialog.tsx @@ -5,7 +5,7 @@ import { UseFormReturn } from 'react-hook-form' import { ButtonTooltip } from 'components/ui/ButtonTooltip' import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { formatCurrency } from 'lib/helpers' @@ -153,7 +153,7 @@ export const DiskManagementReviewAndSubmitDialog = ({ const { formState, getValues } = form - const { can: canUpdateDiskConfiguration } = useAsyncCheckProjectPermissions( + const { can: canUpdateDiskConfiguration } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'projects', { diff --git a/apps/studio/components/interfaces/Docs/Description.tsx b/apps/studio/components/interfaces/Docs/Description.tsx index b2e6176400fdc..06dad2b652a60 100644 --- a/apps/studio/components/interfaces/Docs/Description.tsx +++ b/apps/studio/components/interfaces/Docs/Description.tsx @@ -5,7 +5,7 @@ import { toast } from 'sonner' import AutoTextArea from 'components/to-be-cleaned/forms/AutoTextArea' import { executeSql } from 'data/sql/execute-sql-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { timeout } from 'lib/helpers' import { Loader } from 'lucide-react' @@ -42,7 +42,7 @@ const Description = ({ content, metadata, onChange = noop }: DescrptionProps) => const hasChanged = value != contentText const animateCss = `transition duration-150` - const { can: canUpdateDescription } = useAsyncCheckProjectPermissions( + const { can: canUpdateDescription } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_QUERY, '*' ) diff --git a/apps/studio/components/interfaces/Functions/EdgeFunctionDetails/EdgeFunctionDetails.tsx b/apps/studio/components/interfaces/Functions/EdgeFunctionDetails/EdgeFunctionDetails.tsx index efde692501c20..d4b163cfee413 100644 --- a/apps/studio/components/interfaces/Functions/EdgeFunctionDetails/EdgeFunctionDetails.tsx +++ b/apps/studio/components/interfaces/Functions/EdgeFunctionDetails/EdgeFunctionDetails.tsx @@ -18,7 +18,7 @@ import { useCustomDomainsQuery } from 'data/custom-domains/custom-domains-query' import { useEdgeFunctionQuery } from 'data/edge-functions/edge-function-query' import { useEdgeFunctionDeleteMutation } from 'data/edge-functions/edge-functions-delete-mutation' import { useEdgeFunctionUpdateMutation } from 'data/edge-functions/edge-functions-update-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { Alert_Shadcn_, AlertDescription_Shadcn_, @@ -59,7 +59,7 @@ export const EdgeFunctionDetails = () => { const router = useRouter() const { ref: projectRef, functionSlug } = useParams() const [showDeleteModal, setShowDeleteModal] = useState(false) - const { can: canUpdateEdgeFunction } = useAsyncCheckProjectPermissions( + const { can: canUpdateEdgeFunction } = useAsyncCheckPermissions( PermissionAction.FUNCTIONS_WRITE, '*' ) diff --git a/apps/studio/components/interfaces/Functions/EdgeFunctionSecrets/EdgeFunctionSecret.tsx b/apps/studio/components/interfaces/Functions/EdgeFunctionSecrets/EdgeFunctionSecret.tsx index 16edc741a3f8e..9e9aaf20ecc28 100644 --- a/apps/studio/components/interfaces/Functions/EdgeFunctionSecrets/EdgeFunctionSecret.tsx +++ b/apps/studio/components/interfaces/Functions/EdgeFunctionSecrets/EdgeFunctionSecret.tsx @@ -3,7 +3,7 @@ import { Trash } from 'lucide-react' import { ButtonTooltip } from 'components/ui/ButtonTooltip' import type { ProjectSecret } from 'data/secrets/secrets-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { TableCell, TableRow } from 'ui' import { TimestampInfo } from 'ui-patterns' @@ -13,10 +13,7 @@ interface EdgeFunctionSecretProps { } const EdgeFunctionSecret = ({ secret, onSelectDelete }: EdgeFunctionSecretProps) => { - const { can: canUpdateSecrets } = useAsyncCheckProjectPermissions( - PermissionAction.SECRETS_WRITE, - '*' - ) + const { can: canUpdateSecrets } = useAsyncCheckPermissions(PermissionAction.SECRETS_WRITE, '*') // [Joshen] Following API's validation: // https://github.com/supabase/infrastructure/blob/develop/api/src/routes/v1/projects/ref/secrets/secrets.controller.ts#L106 const isReservedSecret = !!secret.name.match(/^(SUPABASE_).*/) diff --git a/apps/studio/components/interfaces/Functions/EdgeFunctionSecrets/EdgeFunctionSecrets.tsx b/apps/studio/components/interfaces/Functions/EdgeFunctionSecrets/EdgeFunctionSecrets.tsx index 00d859249f969..01938c432b6b7 100644 --- a/apps/studio/components/interfaces/Functions/EdgeFunctionSecrets/EdgeFunctionSecrets.tsx +++ b/apps/studio/components/interfaces/Functions/EdgeFunctionSecrets/EdgeFunctionSecrets.tsx @@ -9,7 +9,7 @@ import NoPermission from 'components/ui/NoPermission' import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader' import { useSecretsDeleteMutation } from 'data/secrets/secrets-delete-mutation' import { ProjectSecret, useSecretsQuery } from 'data/secrets/secrets-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { Badge, Card, Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from 'ui' import { Input } from 'ui-patterns/DataInputs/Input' import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal' @@ -21,14 +21,11 @@ const EdgeFunctionSecrets = () => { const [searchString, setSearchString] = useState('') const [selectedSecret, setSelectedSecret] = useState() - const { can: canReadSecrets, isLoading: isLoadingPermissions } = useAsyncCheckProjectPermissions( + const { can: canReadSecrets, isLoading: isLoadingPermissions } = useAsyncCheckPermissions( PermissionAction.SECRETS_READ, '*' ) - const { can: canUpdateSecrets } = useAsyncCheckProjectPermissions( - PermissionAction.SECRETS_WRITE, - '*' - ) + const { can: canUpdateSecrets } = useAsyncCheckPermissions(PermissionAction.SECRETS_WRITE, '*') const { data, error, isLoading, isSuccess, isError } = useSecretsQuery({ projectRef: projectRef, diff --git a/apps/studio/components/interfaces/GraphQL/GraphiQL.tsx b/apps/studio/components/interfaces/GraphQL/GraphiQL.tsx index c7351a4db71e2..7d64ac69c162c 100644 --- a/apps/studio/components/interfaces/GraphQL/GraphiQL.tsx +++ b/apps/studio/components/interfaces/GraphQL/GraphiQL.tsx @@ -36,7 +36,7 @@ import { AlertTriangle, XIcon } from 'lucide-react' import { MouseEventHandler, useCallback, useEffect, useState } from 'react' import { LOCAL_STORAGE_KEYS } from 'common' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useLocalStorage } from 'hooks/misc/useLocalStorage' import { AlertDescription_Shadcn_, AlertTitle_Shadcn_, Alert_Shadcn_, Button, cn } from 'ui' import { RoleImpersonationSelector } from '../RoleImpersonationSelector' @@ -76,7 +76,7 @@ const GraphiQLInterface = ({ theme }: GraphiQLInterfaceProps) => { const merge = useMergeQuery() const prettify = usePrettifyEditors() - const { can: canReadJWTSecret } = useAsyncCheckProjectPermissions( + const { can: canReadJWTSecret } = useAsyncCheckPermissions( PermissionAction.READ, 'field.jwt_secret' ) diff --git a/apps/studio/components/interfaces/Home/NewProjectPanel/APIKeys.tsx b/apps/studio/components/interfaces/Home/NewProjectPanel/APIKeys.tsx index 438cbd5fd70e6..60298fafa9d9d 100644 --- a/apps/studio/components/interfaces/Home/NewProjectPanel/APIKeys.tsx +++ b/apps/studio/components/interfaces/Home/NewProjectPanel/APIKeys.tsx @@ -9,7 +9,7 @@ import Panel from 'components/ui/Panel' import { getKeys, useAPIKeysQuery } from 'data/api-keys/api-keys-query' import { useJwtSecretUpdatingStatusQuery } from 'data/config/jwt-secret-updating-status-query' import { useProjectSettingsV2Query } from 'data/config/project-settings-v2-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled' import { Input, SimpleCodeBlock } from 'ui' @@ -77,7 +77,7 @@ export const APIKeys = () => { const jwtSecretUpdateStatus = data?.jwtSecretUpdateStatus - const { can: canReadAPIKeys } = useAsyncCheckProjectPermissions( + const { can: canReadAPIKeys } = useAsyncCheckPermissions( PermissionAction.READ, 'service_api_keys' ) diff --git a/apps/studio/components/interfaces/HomeNew/CustomReportSection.tsx b/apps/studio/components/interfaces/HomeNew/CustomReportSection.tsx index 19f479ada64ba..00e487c2052f4 100644 --- a/apps/studio/components/interfaces/HomeNew/CustomReportSection.tsx +++ b/apps/studio/components/interfaces/HomeNew/CustomReportSection.tsx @@ -12,6 +12,7 @@ import dayjs from 'dayjs' import { Plus } from 'lucide-react' import type { CSSProperties, ReactNode } from 'react' import { useCallback, useEffect, useMemo, useState } from 'react' +import { toast } from 'sonner' import { useParams } from 'common' import { SnippetDropdown } from 'components/interfaces/HomeNew/SnippetDropdown' @@ -22,13 +23,12 @@ import { AnalyticsInterval } from 'data/analytics/constants' import { useContentInfiniteQuery } from 'data/content/content-infinite-query' import { Content } from 'data/content/content-query' import { useContentUpsertMutation } from 'data/content/content-upsert-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { uuidv4 } from 'lib/helpers' import { useProfile } from 'lib/profile' import type { Dashboards } from 'types' import { Button } from 'ui' import { Row } from 'ui-patterns' -import { toast } from 'sonner' export function CustomReportSection() { const startDate = dayjs().subtract(7, 'day').toISOString() @@ -50,7 +50,7 @@ export function CustomReportSection() { if (reportContent) setEditableReport(reportContent) }, [reportContent]) - const { can: canUpdateReport } = useAsyncCheckProjectPermissions( + const { can: canUpdateReport } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'user_content', { @@ -63,7 +63,7 @@ export function CustomReportSection() { } ) - const { can: canCreateReport } = useAsyncCheckProjectPermissions( + const { can: canCreateReport } = useAsyncCheckPermissions( PermissionAction.CREATE, 'user_content', { resource: { type: 'report', owner_id: profile?.id }, subject: { id: profile?.id } } diff --git a/apps/studio/components/interfaces/Integrations/CronJobs/CreateCronJobSheet.tsx b/apps/studio/components/interfaces/Integrations/CronJobs/CreateCronJobSheet.tsx index 1d3072b5a9096..e7a42f67760fd 100644 --- a/apps/studio/components/interfaces/Integrations/CronJobs/CreateCronJobSheet.tsx +++ b/apps/studio/components/interfaces/Integrations/CronJobs/CreateCronJobSheet.tsx @@ -17,7 +17,7 @@ import { useDatabaseCronJobCreateMutation } from 'data/database-cron-jobs/databa import { CronJob } from 'data/database-cron-jobs/database-cron-jobs-infinite-query' import { useDatabaseExtensionsQuery } from 'data/database-extensions/database-extensions-query' import { useSendEventMutation } from 'data/telemetry/send-event-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { @@ -223,7 +223,7 @@ export const CreateCronJobSheet = ({ const { mutate: upsertCronJob, isLoading: isUpserting } = useDatabaseCronJobCreateMutation() const isLoading = isLoadingGetCronJob || isUpserting - const { can: canToggleExtensions } = useAsyncCheckProjectPermissions( + const { can: canToggleExtensions } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_WRITE, 'extensions' ) diff --git a/apps/studio/components/interfaces/Integrations/Queues/QueuesSettings.tsx b/apps/studio/components/interfaces/Integrations/Queues/QueuesSettings.tsx index 2b5b6bd079284..eefac54699b47 100644 --- a/apps/studio/components/interfaces/Integrations/Queues/QueuesSettings.tsx +++ b/apps/studio/components/interfaces/Integrations/Queues/QueuesSettings.tsx @@ -21,7 +21,7 @@ import { } from 'data/database-queues/database-queues-toggle-postgrest-mutation' import { useTableUpdateMutation } from 'data/tables/table-update-mutation' import { useTablesQuery } from 'data/tables/tables-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { Button, @@ -39,7 +39,7 @@ import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout' export const QueuesSettings = () => { const { data: project } = useSelectedProjectQuery() - const { can: canUpdatePostgrestConfig } = useAsyncCheckProjectPermissions( + const { can: canUpdatePostgrestConfig } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'custom_config_postgrest' ) diff --git a/apps/studio/components/interfaces/Integrations/Vault/Secrets/SecretRow.tsx b/apps/studio/components/interfaces/Integrations/Vault/Secrets/SecretRow.tsx index d15afd50960b0..b0b738b858e6d 100644 --- a/apps/studio/components/interfaces/Integrations/Vault/Secrets/SecretRow.tsx +++ b/apps/studio/components/interfaces/Integrations/Vault/Secrets/SecretRow.tsx @@ -12,7 +12,7 @@ import { import { DropdownMenuItemTooltip } from 'components/ui/DropdownMenuItemTooltip' import { useVaultSecretDecryptedValueQuery } from 'data/vault/vault-secret-decrypted-value-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { Edit3, Eye, EyeOff, Key, Loader, MoreVertical, Trash } from 'lucide-react' import type { VaultSecret } from 'types' @@ -33,7 +33,7 @@ const SecretRow = ({ row, col, onSelectRemove }: SecretRowProps) => { const [revealSecret, setRevealSecret] = useState(false) const name = row?.name ?? 'No name provided' - const { can: canManageSecrets } = useAsyncCheckProjectPermissions( + const { can: canManageSecrets } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_WRITE, 'tables' ) diff --git a/apps/studio/components/interfaces/Integrations/Vault/Secrets/SecretsManagement.tsx b/apps/studio/components/interfaces/Integrations/Vault/Secrets/SecretsManagement.tsx index 05bd8a8f7264f..7a0575c6da2f3 100644 --- a/apps/studio/components/interfaces/Integrations/Vault/Secrets/SecretsManagement.tsx +++ b/apps/studio/components/interfaces/Integrations/Vault/Secrets/SecretsManagement.tsx @@ -1,26 +1,26 @@ import { PermissionAction } from '@supabase/shared-types/out/constants' -import DataGrid, { Row } from 'react-data-grid' import { sortBy } from 'lodash' -import { Loader, RefreshCw, Search, X } from 'lucide-react' +import { RefreshCw, Search, X } from 'lucide-react' import { useEffect, useMemo, useState } from 'react' +import DataGrid, { Row } from 'react-data-grid' import { useParams } from 'common' import { ButtonTooltip } from 'components/ui/ButtonTooltip' import { DocsButton } from 'components/ui/DocsButton' import { useVaultSecretsQuery } from 'data/vault/vault-secrets-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import type { VaultSecret } from 'types' import { Button, + cn, Input, LoadingLine, - cn, Select_Shadcn_, - SelectTrigger_Shadcn_, - SelectValue_Shadcn_, SelectContent_Shadcn_, SelectItem_Shadcn_, + SelectTrigger_Shadcn_, + SelectValue_Shadcn_, } from 'ui' import AddNewSecretModal from './AddNewSecretModal' import DeleteSecretModal from './DeleteSecretModal' @@ -35,7 +35,7 @@ export const SecretsManagement = () => { const [selectedSecretToRemove, setSelectedSecretToRemove] = useState() const [selectedSort, setSelectedSort] = useState<'updated_at' | 'name'>('updated_at') - const { can: canManageSecrets } = useAsyncCheckProjectPermissions( + const { can: canManageSecrets } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_WRITE, 'tables' ) diff --git a/apps/studio/components/interfaces/Integrations/Webhooks/ListTab.tsx b/apps/studio/components/interfaces/Integrations/Webhooks/ListTab.tsx index 2e87e67a2092d..f5dce7cde94fd 100644 --- a/apps/studio/components/interfaces/Integrations/Webhooks/ListTab.tsx +++ b/apps/studio/components/interfaces/Integrations/Webhooks/ListTab.tsx @@ -6,14 +6,14 @@ import DeleteHookModal from 'components/interfaces/Database/Hooks/DeleteHookModa import { EditHookPanel } from 'components/interfaces/Database/Hooks/EditHookPanel' import { HooksList } from 'components/interfaces/Database/Hooks/HooksList/HooksList' import NoPermission from 'components/ui/NoPermission' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' export const WebhooksListTab = () => { const [selectedHook, setSelectedHook] = useState() const [showCreateHookForm, setShowCreateHookForm] = useState(false) const [showDeleteHookForm, setShowDeleteHookForm] = useState(false) - const { can: canReadWebhooks, isSuccess: isPermissionsLoaded } = useAsyncCheckProjectPermissions( + const { can: canReadWebhooks, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_READ, 'triggers' ) diff --git a/apps/studio/components/interfaces/Integrations/Webhooks/OverviewTab.tsx b/apps/studio/components/interfaces/Integrations/Webhooks/OverviewTab.tsx index a1efc6d7310f9..883823083cc30 100644 --- a/apps/studio/components/interfaces/Integrations/Webhooks/OverviewTab.tsx +++ b/apps/studio/components/interfaces/Integrations/Webhooks/OverviewTab.tsx @@ -7,7 +7,7 @@ import NoPermission from 'components/ui/NoPermission' import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader' import { useHooksEnableMutation } from 'data/database/hooks-enable-mutation' import { useSchemasQuery } from 'data/database/schemas-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { Admonition } from 'ui-patterns' import { IntegrationOverviewTab } from '../Integration/IntegrationOverviewTab' @@ -26,7 +26,7 @@ export const WebhooksOverviewTab = () => { }) const isHooksEnabled = schemas?.some((schema) => schema.name === 'supabase_functions') - const { can: canReadWebhooks, isLoading: isLoadingPermissions } = useAsyncCheckProjectPermissions( + const { can: canReadWebhooks, isLoading: isLoadingPermissions } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_READ, 'triggers' ) diff --git a/apps/studio/components/interfaces/Integrations/Wrappers/OverviewTab.tsx b/apps/studio/components/interfaces/Integrations/Wrappers/OverviewTab.tsx index dd923c8c728e9..6d422b8dfe8aa 100644 --- a/apps/studio/components/interfaces/Integrations/Wrappers/OverviewTab.tsx +++ b/apps/studio/components/interfaces/Integrations/Wrappers/OverviewTab.tsx @@ -5,7 +5,7 @@ import { useState } from 'react' import { useParams } from 'common' import { ButtonTooltip } from 'components/ui/ButtonTooltip' import { useDatabaseExtensionsQuery } from 'data/database-extensions/database-extensions-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { Alert_Shadcn_, @@ -28,7 +28,7 @@ export const WrapperOverviewTab = () => { const [createWrapperShown, setCreateWrapperShown] = useState(false) const [isClosingCreateWrapper, setisClosingCreateWrapper] = useState(false) - const { can: canCreateWrapper } = useAsyncCheckProjectPermissions( + const { can: canCreateWrapper } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_WRITE, 'wrappers' ) diff --git a/apps/studio/components/interfaces/Integrations/Wrappers/WrapperRow.tsx b/apps/studio/components/interfaces/Integrations/Wrappers/WrapperRow.tsx index f64438c7d7d9d..5f830a4acf0b6 100644 --- a/apps/studio/components/interfaces/Integrations/Wrappers/WrapperRow.tsx +++ b/apps/studio/components/interfaces/Integrations/Wrappers/WrapperRow.tsx @@ -7,7 +7,7 @@ import { useState } from 'react' import { useParams } from 'common' import { ButtonTooltip } from 'components/ui/ButtonTooltip' import type { FDW } from 'data/fdw/fdws-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { Badge, Sheet, @@ -29,7 +29,7 @@ interface WrapperRowProps { const WrapperRow = ({ wrapper }: WrapperRowProps) => { const { ref, id } = useParams() - const { can: canManageWrappers } = useAsyncCheckProjectPermissions( + const { can: canManageWrappers } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_WRITE, 'wrappers' ) diff --git a/apps/studio/components/interfaces/Integrations/Wrappers/WrappersTab.tsx b/apps/studio/components/interfaces/Integrations/Wrappers/WrappersTab.tsx index f9669f4a8ab03..3c73661275c12 100644 --- a/apps/studio/components/interfaces/Integrations/Wrappers/WrappersTab.tsx +++ b/apps/studio/components/interfaces/Integrations/Wrappers/WrappersTab.tsx @@ -4,7 +4,7 @@ import { HTMLProps, ReactNode, useCallback, useState } from 'react' import { useParams } from 'common' import { ButtonTooltip } from 'components/ui/ButtonTooltip' import { FDW, useFDWsQuery } from 'data/fdw/fdws-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { Sheet, SheetContent } from 'ui' import { CreateWrapperSheet } from './CreateWrapperSheet' @@ -20,7 +20,7 @@ export const WrappersTab = () => { const [createWrapperShown, setCreateWrapperShown] = useState(false) const [isClosingCreateWrapper, setisClosingCreateWrapper] = useState(false) - const { can: canCreateWrapper } = useAsyncCheckProjectPermissions( + const { can: canCreateWrapper } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_WRITE, 'wrappers' ) diff --git a/apps/studio/components/interfaces/JwtSecrets/jwt-settings.tsx b/apps/studio/components/interfaces/JwtSecrets/jwt-settings.tsx index 0f5a4b34ae057..28458b0b70444 100644 --- a/apps/studio/components/interfaces/JwtSecrets/jwt-settings.tsx +++ b/apps/studio/components/interfaces/JwtSecrets/jwt-settings.tsx @@ -16,7 +16,7 @@ import { useJwtSecretUpdateMutation } from 'data/config/jwt-secret-update-mutati import { useJwtSecretUpdatingStatusQuery } from 'data/config/jwt-secret-updating-status-query' import { useProjectPostgrestConfigQuery } from 'data/config/project-postgrest-config-query' import { useLegacyJWTSigningKeyQuery } from 'data/jwt-signing-keys/legacy-jwt-signing-key-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { uuidv4 } from 'lib/helpers' import { AlertCircle, @@ -73,15 +73,15 @@ const JWTSettings = () => { const [isCreatingKey, setIsCreatingKey] = useState(false) const [isRegeneratingKey, setIsGeneratingKey] = useState(false) - const { can: canReadJWTSecret } = useAsyncCheckProjectPermissions( + const { can: canReadJWTSecret } = useAsyncCheckPermissions( PermissionAction.READ, 'field.jwt_secret' ) - const { can: canGenerateNewJWTSecret } = useAsyncCheckProjectPermissions( + const { can: canGenerateNewJWTSecret } = useAsyncCheckPermissions( PermissionAction.INFRA_EXECUTE, 'queue_job.projects.update_jwt' ) - const { can: canUpdateConfig } = useAsyncCheckProjectPermissions( + const { can: canUpdateConfig } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'custom_config_gotrue' ) diff --git a/apps/studio/components/interfaces/Organization/AuditLogs/AuditLogs.tsx b/apps/studio/components/interfaces/Organization/AuditLogs/AuditLogs.tsx index f6e1fa8bc1779..e4b49eecc6ea5 100644 --- a/apps/studio/components/interfaces/Organization/AuditLogs/AuditLogs.tsx +++ b/apps/studio/components/interfaces/Organization/AuditLogs/AuditLogs.tsx @@ -23,7 +23,7 @@ import { import { useOrganizationMembersQuery } from 'data/organizations/organization-members-query' import { useOrganizationsQuery } from 'data/organizations/organizations-query' import { useProjectsQuery } from 'data/projects/projects-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { AlertDescription_Shadcn_, AlertTitle_Shadcn_, @@ -54,8 +54,10 @@ export const AuditLogs = () => { projects: [], // project_ref[] }) - const { can: canReadAuditLogs, isLoading: isLoadingPermissions } = - useAsyncCheckProjectPermissions(PermissionAction.READ, 'notifications') + const { can: canReadAuditLogs, isLoading: isLoadingPermissions } = useAsyncCheckPermissions( + PermissionAction.READ, + 'notifications' + ) const { data: projectsData } = useProjectsQuery() const projects = projectsData?.projects ?? [] diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/BillingBreakdown/BillingBreakdown.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/BillingBreakdown/BillingBreakdown.tsx index 0195c78d2e931..9bbcfec1b4c75 100644 --- a/apps/studio/components/interfaces/Organization/BillingSettings/BillingBreakdown/BillingBreakdown.tsx +++ b/apps/studio/components/interfaces/Organization/BillingSettings/BillingBreakdown/BillingBreakdown.tsx @@ -13,19 +13,21 @@ import NoPermission from 'components/ui/NoPermission' import ShimmeringLoader from 'components/ui/ShimmeringLoader' import SparkBar from 'components/ui/SparkBar' import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled' -import UpcomingInvoice from './UpcomingInvoice' -import { MANAGED_BY } from 'lib/constants/infrastructure' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' +import { MANAGED_BY } from 'lib/constants/infrastructure' +import UpcomingInvoice from './UpcomingInvoice' const BillingBreakdown = () => { const { slug: orgSlug } = useParams() const { data: selectedOrganization } = useSelectedOrganizationQuery() - const { isSuccess: isPermissionsLoaded, can: canReadSubscriptions } = - useAsyncCheckProjectPermissions(PermissionAction.BILLING_READ, 'stripe.subscriptions') + const { isSuccess: isPermissionsLoaded, can: canReadSubscriptions } = useAsyncCheckPermissions( + PermissionAction.BILLING_READ, + 'stripe.subscriptions' + ) const { data: subscription, diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/BillingCustomerData/BillingCustomerData.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/BillingCustomerData/BillingCustomerData.tsx index 073177cae61dc..3d18d05d427af 100644 --- a/apps/studio/components/interfaces/Organization/BillingSettings/BillingCustomerData/BillingCustomerData.tsx +++ b/apps/studio/components/interfaces/Organization/BillingSettings/BillingCustomerData/BillingCustomerData.tsx @@ -16,7 +16,7 @@ import { useOrganizationCustomerProfileQuery } from 'data/organizations/organiza import { useOrganizationCustomerProfileUpdateMutation } from 'data/organizations/organization-customer-profile-update-mutation' import { useOrganizationTaxIdQuery } from 'data/organizations/organization-tax-id-query' import { useOrganizationTaxIdUpdateMutation } from 'data/organizations/organization-tax-id-update-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { Button, Card, CardFooter, Form_Shadcn_ as Form } from 'ui' import { @@ -31,8 +31,8 @@ export const BillingCustomerData = () => { const { data: selectedOrganization } = useSelectedOrganizationQuery() const { can: canReadBillingCustomerData, isSuccess: isPermissionsLoaded } = - useAsyncCheckProjectPermissions(PermissionAction.BILLING_READ, 'stripe.customer') - const { can: canUpdateBillingCustomerData } = useAsyncCheckProjectPermissions( + useAsyncCheckPermissions(PermissionAction.BILLING_READ, 'stripe.customer') + const { can: canUpdateBillingCustomerData } = useAsyncCheckPermissions( PermissionAction.BILLING_WRITE, 'stripe.customer' ) diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/BillingEmail.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/BillingEmail.tsx index 2864351ff57ef..a1c57c8eee75f 100644 --- a/apps/studio/components/interfaces/Organization/BillingSettings/BillingEmail.tsx +++ b/apps/studio/components/interfaces/Organization/BillingSettings/BillingEmail.tsx @@ -18,7 +18,7 @@ import { FormSection, FormSectionContent } from 'components/ui/Forms/FormSection import NoPermission from 'components/ui/NoPermission' import { useOrganizationCustomerProfileQuery } from 'data/organizations/organization-customer-profile-query' import { useOrganizationUpdateMutation } from 'data/organizations/organization-update-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { FormMessage_Shadcn_, Input_Shadcn_ } from 'ui' import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout' @@ -42,9 +42,11 @@ const BillingEmail = () => { const { name, billing_email } = selectedOrganization ?? {} - const { can: canReadBillingEmail, isSuccess: isPermissionsLoaded } = - useAsyncCheckProjectPermissions(PermissionAction.BILLING_READ, 'stripe.subscriptions') - const { can: canUpdateOrganization } = useAsyncCheckProjectPermissions( + const { can: canReadBillingEmail, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissions( + PermissionAction.BILLING_READ, + 'stripe.subscriptions' + ) + const { can: canUpdateOrganization } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'organizations' ) diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/CostControl/CostControl.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/CostControl/CostControl.tsx index c021252d87fc4..652d796055570 100644 --- a/apps/studio/components/interfaces/Organization/BillingSettings/CostControl/CostControl.tsx +++ b/apps/studio/components/interfaces/Organization/BillingSettings/CostControl/CostControl.tsx @@ -15,7 +15,7 @@ import NoPermission from 'components/ui/NoPermission' import { PARTNER_TO_NAME } from 'components/ui/PartnerManagedResource' import ShimmeringLoader from 'components/ui/ShimmeringLoader' import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { BASE_PATH } from 'lib/constants' import { MANAGED_BY } from 'lib/constants/infrastructure' @@ -33,8 +33,10 @@ const CostControl = ({}: CostControlProps) => { const { resolvedTheme } = useTheme() const { data: selectedOrganization } = useSelectedOrganizationQuery() - const { isSuccess: isPermissionsLoaded, can: canReadSubscriptions } = - useAsyncCheckProjectPermissions(PermissionAction.BILLING_READ, 'stripe.subscriptions') + const { isSuccess: isPermissionsLoaded, can: canReadSubscriptions } = useAsyncCheckPermissions( + PermissionAction.BILLING_READ, + 'stripe.subscriptions' + ) const snap = useOrgSettingsPageStateSnapshot() const projectUpdateDisabled = useFlag('disableProjectCreationAndUpdate') diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/CostControl/SpendCapSidePanel.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/CostControl/SpendCapSidePanel.tsx index 63588dedf5fc8..367a5480ec65e 100644 --- a/apps/studio/components/interfaces/Organization/BillingSettings/CostControl/SpendCapSidePanel.tsx +++ b/apps/studio/components/interfaces/Organization/BillingSettings/CostControl/SpendCapSidePanel.tsx @@ -9,7 +9,7 @@ import { useParams } from 'common' import Table from 'components/to-be-cleaned/Table' import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query' import { useOrgSubscriptionUpdateMutation } from 'data/subscriptions/org-subscription-update-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { BASE_PATH, PRICING_TIER_PRODUCT_IDS } from 'lib/constants' import { ChevronRight, ExternalLink } from 'lucide-react' import { pricing } from 'shared-data/pricing' @@ -43,7 +43,7 @@ const SpendCapSidePanel = () => { const [showUsageCosts, setShowUsageCosts] = useState(false) const [selectedOption, setSelectedOption] = useState<'on' | 'off'>() - const { can: canUpdateSpendCap } = useAsyncCheckProjectPermissions( + const { can: canUpdateSpendCap } = useAsyncCheckPermissions( PermissionAction.BILLING_WRITE, 'stripe.subscriptions' ) diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/CreditBalance.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/CreditBalance.tsx index cfb8a013dfff7..bfc48ccab374e 100644 --- a/apps/studio/components/interfaces/Organization/BillingSettings/CreditBalance.tsx +++ b/apps/studio/components/interfaces/Organization/BillingSettings/CreditBalance.tsx @@ -11,14 +11,16 @@ import { FormPanel } from 'components/ui/Forms/FormPanel' import { FormSection, FormSectionContent } from 'components/ui/Forms/FormSection' import NoPermission from 'components/ui/NoPermission' import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { CreditTopUp } from './CreditTopUp' const CreditBalance = () => { const { slug } = useParams() - const { isSuccess: isPermissionsLoaded, can: canReadSubscriptions } = - useAsyncCheckProjectPermissions(PermissionAction.BILLING_READ, 'stripe.subscriptions') + const { isSuccess: isPermissionsLoaded, can: canReadSubscriptions } = useAsyncCheckPermissions( + PermissionAction.BILLING_READ, + 'stripe.subscriptions' + ) const { data: subscription, diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/CreditTopUp.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/CreditTopUp.tsx index 094f62f63aa5c..75a58613e08bc 100644 --- a/apps/studio/components/interfaces/Organization/BillingSettings/CreditTopUp.tsx +++ b/apps/studio/components/interfaces/Organization/BillingSettings/CreditTopUp.tsx @@ -17,7 +17,7 @@ import { PaymentConfirmation } from 'components/interfaces/Billing/Payment/Payme import { ButtonTooltip } from 'components/ui/ButtonTooltip' import { useOrganizationCreditTopUpMutation } from 'data/organizations/organization-credit-top-up-mutation' import { subscriptionKeys } from 'data/subscriptions/keys' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { STRIPE_PUBLIC_KEY } from 'lib/constants' import { Alert_Shadcn_, @@ -63,7 +63,7 @@ export const CreditTopUp = ({ slug }: { slug: string | undefined }) => { createPaymentMethod: PaymentMethodElementRef['createPaymentMethod'] }>(null) - const { can: canTopUpCredits, isSuccess: isPermissionsLoaded } = useAsyncCheckProjectPermissions( + const { can: canTopUpCredits, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissions( PermissionAction.BILLING_WRITE, 'stripe.subscriptions' ) diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdateSidePanel.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdateSidePanel.tsx index 002dd26dbe0b2..5d1f473e0b1bf 100644 --- a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdateSidePanel.tsx +++ b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdateSidePanel.tsx @@ -18,7 +18,7 @@ import { useOrgPlansQuery } from 'data/subscriptions/org-plans-query' import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query' import type { OrgPlan } from 'data/subscriptions/types' import { useSendEventMutation } from 'data/telemetry/send-event-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { MANAGED_BY } from 'lib/constants/infrastructure' import { formatCurrency } from 'lib/helpers' @@ -60,7 +60,7 @@ const PlanUpdateSidePanel = () => { const [showDowngradeError, setShowDowngradeError] = useState(false) const [selectedTier, setSelectedTier] = useState<'tier_free' | 'tier_pro' | 'tier_team'>() - const { can: canUpdateSubscription } = useAsyncCheckProjectPermissions( + const { can: canUpdateSubscription } = useAsyncCheckPermissions( PermissionAction.BILLING_WRITE, 'stripe.subscriptions' ) diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/Subscription.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/Subscription.tsx index ae9369046dc0a..ca0a81d48bb02 100644 --- a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/Subscription.tsx +++ b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/Subscription.tsx @@ -11,7 +11,7 @@ import AlertError from 'components/ui/AlertError' import NoPermission from 'components/ui/NoPermission' import ShimmeringLoader from 'components/ui/ShimmeringLoader' import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useOrgSettingsPageStateSnapshot } from 'state/organization-settings' import { Alert, Button } from 'ui' import { Admonition } from 'ui-patterns' @@ -24,8 +24,10 @@ const Subscription = () => { const snap = useOrgSettingsPageStateSnapshot() const projectUpdateDisabled = useFlag('disableProjectCreationAndUpdate') - const { isSuccess: isPermissionsLoaded, can: canReadSubscriptions } = - useAsyncCheckProjectPermissions(PermissionAction.BILLING_READ, 'stripe.subscriptions') + const { isSuccess: isPermissionsLoaded, can: canReadSubscriptions } = useAsyncCheckPermissions( + PermissionAction.BILLING_READ, + 'stripe.subscriptions' + ) const { data: subscription, diff --git a/apps/studio/components/interfaces/Organization/Documents/SOC2.tsx b/apps/studio/components/interfaces/Organization/Documents/SOC2.tsx index f08ed28a53e13..86de90ef1f051 100644 --- a/apps/studio/components/interfaces/Organization/Documents/SOC2.tsx +++ b/apps/studio/components/interfaces/Organization/Documents/SOC2.tsx @@ -12,7 +12,7 @@ import { import NoPermission from 'components/ui/NoPermission' import { getDocument } from 'data/documents/document-query' import { useSendEventMutation } from 'data/telemetry/send-event-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { Button } from 'ui' import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal' @@ -23,8 +23,10 @@ export const SOC2 = () => { const slug = organization?.slug const { mutate: sendEvent } = useSendEventMutation() - const { can: canReadSubscriptions, isLoading: isLoadingPermissions } = - useAsyncCheckProjectPermissions(PermissionAction.BILLING_READ, 'stripe.subscriptions') + const { can: canReadSubscriptions, isLoading: isLoadingPermissions } = useAsyncCheckPermissions( + PermissionAction.BILLING_READ, + 'stripe.subscriptions' + ) const currentPlan = organization?.plan diff --git a/apps/studio/components/interfaces/Organization/Documents/SecurityQuestionnaire.tsx b/apps/studio/components/interfaces/Organization/Documents/SecurityQuestionnaire.tsx index 2e165448d95f8..e91c8735f4c4f 100644 --- a/apps/studio/components/interfaces/Organization/Documents/SecurityQuestionnaire.tsx +++ b/apps/studio/components/interfaces/Organization/Documents/SecurityQuestionnaire.tsx @@ -11,7 +11,7 @@ import { import NoPermission from 'components/ui/NoPermission' import { getDocument } from 'data/documents/document-query' import { useSendEventMutation } from 'data/telemetry/send-event-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { Button } from 'ui' import ShimmeringLoader from 'ui-patterns/ShimmeringLoader' @@ -21,8 +21,10 @@ export const SecurityQuestionnaire = () => { const slug = organization?.slug const { mutate: sendEvent } = useSendEventMutation() - const { can: canReadSubscriptions, isLoading: isLoadingPermissions } = - useAsyncCheckProjectPermissions(PermissionAction.BILLING_READ, 'stripe.subscriptions') + const { can: canReadSubscriptions, isLoading: isLoadingPermissions } = useAsyncCheckPermissions( + PermissionAction.BILLING_READ, + 'stripe.subscriptions' + ) const currentPlan = organization?.plan diff --git a/apps/studio/components/interfaces/Organization/GeneralSettings/DataPrivacyForm.tsx b/apps/studio/components/interfaces/Organization/GeneralSettings/DataPrivacyForm.tsx index b90faee201141..fad4e87624bd7 100644 --- a/apps/studio/components/interfaces/Organization/GeneralSettings/DataPrivacyForm.tsx +++ b/apps/studio/components/interfaces/Organization/GeneralSettings/DataPrivacyForm.tsx @@ -3,13 +3,13 @@ import { useEffect } from 'react' import { FormActions } from 'components/ui/Forms/FormActions' import { useAIOptInForm } from 'hooks/forms/useAIOptInForm' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { Card, CardContent, CardFooter, Form_Shadcn_ } from 'ui' import { AIOptInLevelSelector } from './AIOptInLevelSelector' export const DataPrivacyForm = () => { const { form, onSubmit, isUpdating, currentOptInLevel } = useAIOptInForm() - const { can: canUpdateOrganization } = useAsyncCheckProjectPermissions( + const { can: canUpdateOrganization } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'organizations' ) diff --git a/apps/studio/components/interfaces/Organization/GeneralSettings/DeleteOrganizationButton.tsx b/apps/studio/components/interfaces/Organization/GeneralSettings/DeleteOrganizationButton.tsx index 5fd8de703b868..238f25c5829af 100644 --- a/apps/studio/components/interfaces/Organization/GeneralSettings/DeleteOrganizationButton.tsx +++ b/apps/studio/components/interfaces/Organization/GeneralSettings/DeleteOrganizationButton.tsx @@ -6,7 +6,7 @@ import { toast } from 'sonner' import { LOCAL_STORAGE_KEYS } from 'common' import { ButtonTooltip } from 'components/ui/ButtonTooltip' import { useOrganizationDeleteMutation } from 'data/organizations/organization-delete-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { Button, Form, Input, Modal } from 'ui' @@ -24,7 +24,7 @@ export const DeleteOrganizationButton = () => { '' ) - const { can: canDeleteOrganization } = useAsyncCheckProjectPermissions( + const { can: canDeleteOrganization } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'organizations' ) diff --git a/apps/studio/components/interfaces/Organization/GeneralSettings/OrganizationDetailsForm.tsx b/apps/studio/components/interfaces/Organization/GeneralSettings/OrganizationDetailsForm.tsx index 797f791e92ec1..95f3ebaadda23 100644 --- a/apps/studio/components/interfaces/Organization/GeneralSettings/OrganizationDetailsForm.tsx +++ b/apps/studio/components/interfaces/Organization/GeneralSettings/OrganizationDetailsForm.tsx @@ -11,7 +11,7 @@ import CopyButton from 'components/ui/CopyButton' import { FormActions } from 'components/ui/Forms/FormActions' import { useOrganizationUpdateMutation } from 'data/organizations/organization-update-mutation' import { invalidateOrganizationsQuery } from 'data/organizations/organizations-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import type { ResponseError } from 'types' import { @@ -35,7 +35,7 @@ export const OrganizationDetailsForm = () => { const queryClient = useQueryClient() const { data: selectedOrganization } = useSelectedOrganizationQuery() - const { can: canUpdateOrganization } = useAsyncCheckProjectPermissions( + const { can: canUpdateOrganization } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'organizations' ) diff --git a/apps/studio/components/interfaces/Organization/IntegrationSettings/IntegrationSettings.tsx b/apps/studio/components/interfaces/Organization/IntegrationSettings/IntegrationSettings.tsx index 453b0ed4f3102..5ccf2a0111a29 100644 --- a/apps/studio/components/interfaces/Organization/IntegrationSettings/IntegrationSettings.tsx +++ b/apps/studio/components/interfaces/Organization/IntegrationSettings/IntegrationSettings.tsx @@ -19,7 +19,7 @@ import { useGitHubAuthorizationQuery } from 'data/integrations/github-authorizat import { useGitHubConnectionDeleteMutation } from 'data/integrations/github-connection-delete-mutation' import { useGitHubConnectionsQuery } from 'data/integrations/github-connections-query' import type { IntegrationProjectConnection } from 'data/integrations/integrations.types' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { BASE_PATH } from 'lib/constants' @@ -50,12 +50,12 @@ const IntegrationSettings = () => { const showVercelIntegration = useIsFeatureEnabled('integrations:vercel') const { can: canReadGithubConnection, isLoading: isLoadingPermissions } = - useAsyncCheckProjectPermissions(PermissionAction.READ, 'integrations.github_connections') - const { can: canCreateGitHubConnection } = useAsyncCheckProjectPermissions( + useAsyncCheckPermissions(PermissionAction.READ, 'integrations.github_connections') + const { can: canCreateGitHubConnection } = useAsyncCheckPermissions( PermissionAction.CREATE, 'integrations.github_connections' ) - const { can: canUpdateGitHubConnection } = useAsyncCheckProjectPermissions( + const { can: canUpdateGitHubConnection } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'integrations.github_connections' ) diff --git a/apps/studio/components/interfaces/Organization/InvoicesSettings/InvoicesSection.tsx b/apps/studio/components/interfaces/Organization/InvoicesSettings/InvoicesSection.tsx index 673df43cff6c4..eea5037c28399 100644 --- a/apps/studio/components/interfaces/Organization/InvoicesSettings/InvoicesSection.tsx +++ b/apps/studio/components/interfaces/Organization/InvoicesSettings/InvoicesSection.tsx @@ -5,11 +5,11 @@ import { ScaffoldSectionDetail, } from 'components/layouts/Scaffold' import NoPermission from 'components/ui/NoPermission' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import InvoicesSettings from './InvoicesSettings' const InvoicesSection = () => { - const { isSuccess: isPermissionsLoaded, can: canReadInvoices } = useAsyncCheckProjectPermissions( + const { isSuccess: isPermissionsLoaded, can: canReadInvoices } = useAsyncCheckPermissions( PermissionAction.BILLING_READ, 'stripe.subscriptions' ) diff --git a/apps/studio/components/interfaces/Organization/OAuthApps/OAuthAppRow.tsx b/apps/studio/components/interfaces/Organization/OAuthApps/OAuthAppRow.tsx index 08a9259f0636a..83d34da16d604 100644 --- a/apps/studio/components/interfaces/Organization/OAuthApps/OAuthAppRow.tsx +++ b/apps/studio/components/interfaces/Organization/OAuthApps/OAuthAppRow.tsx @@ -4,7 +4,7 @@ import { Edit, MoreVertical, Trash } from 'lucide-react' import Table from 'components/to-be-cleaned/Table' import CopyButton from 'components/ui/CopyButton' import type { OAuthApp } from 'data/oauth/oauth-apps-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { Button, DropdownMenu, @@ -25,11 +25,11 @@ export interface OAuthAppRowProps { } export const OAuthAppRow = ({ app, onSelectEdit, onSelectDelete }: OAuthAppRowProps) => { - const { can: canUpdateOAuthApps } = useAsyncCheckProjectPermissions( + const { can: canUpdateOAuthApps } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'approved_oauth_apps' ) - const { can: canDeleteOAuthApps } = useAsyncCheckProjectPermissions( + const { can: canDeleteOAuthApps } = useAsyncCheckPermissions( PermissionAction.DELETE, 'approved_oauth_apps' ) diff --git a/apps/studio/components/interfaces/Organization/OAuthApps/OAuthApps.tsx b/apps/studio/components/interfaces/Organization/OAuthApps/OAuthApps.tsx index ddeff5064ec9c..8d303c8c2f9ae 100644 --- a/apps/studio/components/interfaces/Organization/OAuthApps/OAuthApps.tsx +++ b/apps/studio/components/interfaces/Organization/OAuthApps/OAuthApps.tsx @@ -13,7 +13,7 @@ import ShimmeringLoader from 'components/ui/ShimmeringLoader' import { AuthorizedApp, useAuthorizedAppsQuery } from 'data/oauth/authorized-apps-query' import { OAuthAppCreateResponse } from 'data/oauth/oauth-app-create-mutation' import { OAuthApp, useOAuthAppsQuery } from 'data/oauth/oauth-apps-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { Button, cn } from 'ui' import { AuthorizedAppRow } from './AuthorizedAppRow' import { DeleteAppModal } from './DeleteAppModal' @@ -34,9 +34,11 @@ export const OAuthApps = () => { const [selectedAppToDelete, setSelectedAppToDelete] = useState() const [selectedAppToRevoke, setSelectedAppToRevoke] = useState() - const { can: canReadOAuthApps, isLoading: isLoadingPermissions } = - useAsyncCheckProjectPermissions(PermissionAction.READ, 'approved_oauth_apps') - const { can: canCreateOAuthApps } = useAsyncCheckProjectPermissions( + const { can: canReadOAuthApps, isLoading: isLoadingPermissions } = useAsyncCheckPermissions( + PermissionAction.READ, + 'approved_oauth_apps' + ) + const { can: canCreateOAuthApps } = useAsyncCheckPermissions( PermissionAction.CREATE, 'approved_oauth_apps' ) diff --git a/apps/studio/components/interfaces/Organization/OAuthApps/OAuthSecrets/OAuthSecrets.tsx b/apps/studio/components/interfaces/Organization/OAuthApps/OAuthSecrets/OAuthSecrets.tsx index 84e003a9e8358..5cc983beeb9b5 100644 --- a/apps/studio/components/interfaces/Organization/OAuthApps/OAuthSecrets/OAuthSecrets.tsx +++ b/apps/studio/components/interfaces/Organization/OAuthApps/OAuthSecrets/OAuthSecrets.tsx @@ -7,7 +7,7 @@ import { InlineLink } from 'components/ui/InlineLink' import { useClientSecretCreateMutation } from 'data/oauth-secrets/client-secret-create-mutation' import { CreatedSecret, useClientSecretsQuery } from 'data/oauth-secrets/client-secrets-query' import { OAuthApp } from 'data/oauth/oauth-apps-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { Alert_Shadcn_, AlertTitle_Shadcn_, InfoIcon } from 'ui' import { SecretRow } from './SecretRow' @@ -18,10 +18,7 @@ interface Props { export const OAuthSecrets = ({ selectedApp }: Props) => { const { slug } = useParams() const [createdSecret, setCreatedSecret] = useState() - const { can: canManageSecrets } = useAsyncCheckProjectPermissions( - PermissionAction.UPDATE, - 'oauth_apps' - ) + const { can: canManageSecrets } = useAsyncCheckPermissions(PermissionAction.UPDATE, 'oauth_apps') const { id: appId } = selectedApp ?? {} diff --git a/apps/studio/components/interfaces/Organization/OAuthApps/OAuthSecrets/SecretRow.tsx b/apps/studio/components/interfaces/Organization/OAuthApps/OAuthSecrets/SecretRow.tsx index 92e3e3a55aa73..1b080b230270e 100644 --- a/apps/studio/components/interfaces/Organization/OAuthApps/OAuthSecrets/SecretRow.tsx +++ b/apps/studio/components/interfaces/Organization/OAuthApps/OAuthSecrets/SecretRow.tsx @@ -10,7 +10,7 @@ import CopyButton from 'components/ui/CopyButton' import { useClientSecretDeleteMutation } from 'data/oauth-secrets/client-secret-delete-mutation' import { Secret, useClientSecretsQuery } from 'data/oauth-secrets/client-secrets-query' import { useOrganizationMembersQuery } from 'data/organizations/organization-members-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { cn } from 'ui' import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal' @@ -22,10 +22,7 @@ export interface SecretRowProps { export const SecretRow = ({ secret, appId }: SecretRowProps) => { const { slug } = useParams() const [showDeleteModal, setShowDeleteModal] = useState(false) - const { can: canManageSecrets } = useAsyncCheckProjectPermissions( - PermissionAction.UPDATE, - 'oauth_apps' - ) + const { can: canManageSecrets } = useAsyncCheckPermissions(PermissionAction.UPDATE, 'oauth_apps') const { data } = useClientSecretsQuery({ slug, appId }) const secrets = data?.client_secrets ?? [] diff --git a/apps/studio/components/interfaces/Organization/SecuritySettings/SecuritySettings.tsx b/apps/studio/components/interfaces/Organization/SecuritySettings/SecuritySettings.tsx index 1dd91caccb024..4254c054a91d9 100644 --- a/apps/studio/components/interfaces/Organization/SecuritySettings/SecuritySettings.tsx +++ b/apps/studio/components/interfaces/Organization/SecuritySettings/SecuritySettings.tsx @@ -16,7 +16,7 @@ import { useOrganizationMembersQuery } from 'data/organizations/organization-mem import { useOrganizationMfaToggleMutation } from 'data/organizations/organization-mfa-mutation' import { useOrganizationMfaQuery } from 'data/organizations/organization-mfa-query' import { useSendEventMutation } from 'data/telemetry/send-event-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { useProfile } from 'lib/profile' import { @@ -48,9 +48,11 @@ export const SecuritySettings = () => { const { data: selectedOrganization } = useSelectedOrganizationQuery() const { data: members } = useOrganizationMembersQuery({ slug }) - const { can: canReadMfaConfig, isLoading: isLoadingPermissions } = - useAsyncCheckProjectPermissions(PermissionAction.READ, 'organizations') - const { can: canUpdateMfaConfig } = useAsyncCheckProjectPermissions( + const { can: canReadMfaConfig, isLoading: isLoadingPermissions } = useAsyncCheckPermissions( + PermissionAction.READ, + 'organizations' + ) + const { can: canUpdateMfaConfig } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'organizations' ) diff --git a/apps/studio/components/interfaces/Organization/TeamSettings/MemberActions.tsx b/apps/studio/components/interfaces/Organization/TeamSettings/MemberActions.tsx index 24b1a8a9fed71..2a2cd9f52dcd1 100644 --- a/apps/studio/components/interfaces/Organization/TeamSettings/MemberActions.tsx +++ b/apps/studio/components/interfaces/Organization/TeamSettings/MemberActions.tsx @@ -16,7 +16,7 @@ import { } from 'data/organizations/organization-members-query' import { usePermissionsQuery } from 'data/permissions/permissions-query' import { useProjectsQuery } from 'data/projects/projects-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { useProfile } from 'lib/profile' @@ -69,14 +69,14 @@ export const MemberActions = ({ member }: MemberActionsProps) => { const roleId = member.role_ids?.[0] ?? -1 const canRemoveMember = member.role_ids.every((id) => rolesRemovable.includes(id)) - const { can: canCreateUserInvites } = useAsyncCheckProjectPermissions( + const { can: canCreateUserInvites } = useAsyncCheckPermissions( PermissionAction.CREATE, 'user_invites', { resource: { role_id: roleId } } ) const canResendInvite = canCreateUserInvites && hasOrgRole - const { can: canDeleteUserInvites } = useAsyncCheckProjectPermissions( + const { can: canDeleteUserInvites } = useAsyncCheckPermissions( PermissionAction.DELETE, 'user_invites', { resource: { role_id: roleId } } diff --git a/apps/studio/components/interfaces/Organization/Usage/Usage.tsx b/apps/studio/components/interfaces/Organization/Usage/Usage.tsx index d26883fc6706f..a5b718bc3ed40 100644 --- a/apps/studio/components/interfaces/Organization/Usage/Usage.tsx +++ b/apps/studio/components/interfaces/Organization/Usage/Usage.tsx @@ -11,7 +11,7 @@ import NoPermission from 'components/ui/NoPermission' import ShimmeringLoader from 'components/ui/ShimmeringLoader' import { useProjectsQuery } from 'data/projects/projects-query' import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { TIME_PERIODS_BILLING, TIME_PERIODS_REPORTS } from 'lib/constants/metrics' import { @@ -43,8 +43,10 @@ export const Usage = () => { const selectedProjectRef = selectedProjectRefInputValue === 'all-projects' ? undefined : selectedProjectRefInputValue - const { can: canReadSubscriptions, isLoading: isLoadingPermissions } = - useAsyncCheckProjectPermissions(PermissionAction.BILLING_READ, 'stripe.subscriptions') + const { can: canReadSubscriptions, isLoading: isLoadingPermissions } = useAsyncCheckPermissions( + PermissionAction.BILLING_READ, + 'stripe.subscriptions' + ) const { data: organization } = useSelectedOrganizationQuery() const { data, isSuccess } = useProjectsQuery() diff --git a/apps/studio/components/interfaces/Realtime/Inspector/Header.tsx b/apps/studio/components/interfaces/Realtime/Inspector/Header.tsx index 08f008921b18e..10d9573184dd1 100644 --- a/apps/studio/components/interfaces/Realtime/Inspector/Header.tsx +++ b/apps/studio/components/interfaces/Realtime/Inspector/Header.tsx @@ -6,7 +6,7 @@ import { useParams } from 'common' import { ButtonTooltip } from 'components/ui/ButtonTooltip' import { getTemporaryAPIKey } from 'data/api-keys/temp-api-keys-query' import { useSendEventMutation } from 'data/telemetry/send-event-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { ChooseChannelPopover } from './ChooseChannelPopover' import { RealtimeFilterPopover } from './RealtimeFilterPopover' @@ -23,7 +23,7 @@ export const Header = ({ config, onChangeConfig }: HeaderProps) => { const { ref } = useParams() const { data: org } = useSelectedOrganizationQuery() - const { can: canReadAPIKeys } = useAsyncCheckProjectPermissions( + const { can: canReadAPIKeys } = useAsyncCheckPermissions( PermissionAction.READ, 'service_api_keys' ) diff --git a/apps/studio/components/interfaces/Realtime/Inspector/MessagesTable.tsx b/apps/studio/components/interfaces/Realtime/Inspector/MessagesTable.tsx index 8f5a24e2d41ea..7fc0eb6271e02 100644 --- a/apps/studio/components/interfaces/Realtime/Inspector/MessagesTable.tsx +++ b/apps/studio/components/interfaces/Realtime/Inspector/MessagesTable.tsx @@ -10,7 +10,7 @@ import { DocsButton } from 'components/ui/DocsButton' import NoPermission from 'components/ui/NoPermission' import ShimmerLine from 'components/ui/ShimmerLine' import { useSendEventMutation } from 'data/telemetry/send-event-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { Button, IconBroadcast, IconDatabaseChanges, IconPresence, cn } from 'ui' import { GenericSkeletonLoader } from 'ui-patterns' @@ -34,7 +34,7 @@ const NoResultAlert = ({ }) => { const { ref } = useParams() - const { can: canReadAPIKeys, isLoading: isLoadingPermissions } = useAsyncCheckProjectPermissions( + const { can: canReadAPIKeys, isLoading: isLoadingPermissions } = useAsyncCheckPermissions( PermissionAction.READ, 'service_api_keys' ) diff --git a/apps/studio/components/interfaces/Realtime/RealtimeSettings.tsx b/apps/studio/components/interfaces/Realtime/RealtimeSettings.tsx index e9caa8b52e014..c755fb5118572 100644 --- a/apps/studio/components/interfaces/Realtime/RealtimeSettings.tsx +++ b/apps/studio/components/interfaces/Realtime/RealtimeSettings.tsx @@ -17,7 +17,7 @@ import { REALTIME_DEFAULT_CONFIG, useRealtimeConfigurationQuery, } from 'data/realtime/realtime-config-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { @@ -41,7 +41,7 @@ export const RealtimeSettings = () => { const { ref: projectRef } = useParams() const { data: project } = useSelectedProjectQuery() const { data: organization } = useSelectedOrganizationQuery() - const { can: canUpdateConfig } = useAsyncCheckProjectPermissions( + const { can: canUpdateConfig } = useAsyncCheckPermissions( PermissionAction.REALTIME_ADMIN_READ, '*' ) diff --git a/apps/studio/components/interfaces/Reports/Reports.tsx b/apps/studio/components/interfaces/Reports/Reports.tsx index f7f1f24c37eb3..aa8d37a780e57 100644 --- a/apps/studio/components/interfaces/Reports/Reports.tsx +++ b/apps/studio/components/interfaces/Reports/Reports.tsx @@ -22,7 +22,7 @@ import { useContentUpsertMutation, } from 'data/content/content-upsert-mutation' import { useSendEventMutation } from 'data/telemetry/send-event-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { Metric, TIME_PERIODS_REPORTS } from 'lib/constants/metrics' @@ -82,7 +82,7 @@ const Reports = () => { const currentReport = userContents?.content.find((report) => report.id === id) const currentReportContent = currentReport?.content as Dashboards.Content - const { can: canReadReport, isLoading: isLoadingPermissions } = useAsyncCheckProjectPermissions( + const { can: canReadReport, isLoading: isLoadingPermissions } = useAsyncCheckPermissions( PermissionAction.READ, 'user_content', { @@ -94,7 +94,7 @@ const Reports = () => { subject: { id: profile?.id }, } ) - const { can: canUpdateReport } = useAsyncCheckProjectPermissions( + const { can: canUpdateReport } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'user_content', { diff --git a/apps/studio/components/interfaces/SQLEditor/SQLTemplates/SQLQuickstarts.tsx b/apps/studio/components/interfaces/SQLEditor/SQLTemplates/SQLQuickstarts.tsx index eae83009246e9..5e9141c41f03d 100644 --- a/apps/studio/components/interfaces/SQLEditor/SQLTemplates/SQLQuickstarts.tsx +++ b/apps/studio/components/interfaces/SQLEditor/SQLTemplates/SQLQuickstarts.tsx @@ -7,7 +7,7 @@ import { useParams } from 'common' import { SQL_TEMPLATES } from 'components/interfaces/SQLEditor/SQLEditor.queries' import { ActionCard } from 'components/layouts/Tabs/ActionCard' import { useSendEventMutation } from 'data/telemetry/send-event-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { uuidv4 } from 'lib/helpers' @@ -26,7 +26,7 @@ const SQLQuickstarts = () => { const snapV2 = useSqlEditorV2StateSnapshot() - const { can: canCreateSQLSnippet } = useAsyncCheckProjectPermissions( + const { can: canCreateSQLSnippet } = useAsyncCheckPermissions( PermissionAction.CREATE, 'user_content', { diff --git a/apps/studio/components/interfaces/SQLEditor/SQLTemplates/SQLTemplates.tsx b/apps/studio/components/interfaces/SQLEditor/SQLTemplates/SQLTemplates.tsx index 40603c824f578..e33799346e0b6 100644 --- a/apps/studio/components/interfaces/SQLEditor/SQLTemplates/SQLTemplates.tsx +++ b/apps/studio/components/interfaces/SQLEditor/SQLTemplates/SQLTemplates.tsx @@ -7,7 +7,7 @@ import { useParams } from 'common' import { SQL_TEMPLATES } from 'components/interfaces/SQLEditor/SQLEditor.queries' import { ActionCard } from 'components/layouts/Tabs/ActionCard' import { useSendEventMutation } from 'data/telemetry/send-event-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { uuidv4 } from 'lib/helpers' @@ -26,7 +26,7 @@ const SQLTemplates = () => { const snapV2 = useSqlEditorV2StateSnapshot() - const { can: canCreateSQLSnippet } = useAsyncCheckProjectPermissions( + const { can: canCreateSQLSnippet } = useAsyncCheckPermissions( PermissionAction.CREATE, 'user_content', { diff --git a/apps/studio/components/interfaces/SQLEditor/hooks.ts b/apps/studio/components/interfaces/SQLEditor/hooks.ts index 8bba5cf16b466..6d712056d3487 100644 --- a/apps/studio/components/interfaces/SQLEditor/hooks.ts +++ b/apps/studio/components/interfaces/SQLEditor/hooks.ts @@ -4,7 +4,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react' import { toast } from 'sonner' import { useParams } from 'common' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { uuidv4 } from 'lib/helpers' import { useProfile } from 'lib/profile' @@ -24,7 +24,7 @@ export const useNewQuery = () => { const { data: project } = useSelectedProjectQuery() const snapV2 = useSqlEditorV2StateSnapshot() - const { can: canCreateSQLSnippet } = useAsyncCheckProjectPermissions( + const { can: canCreateSQLSnippet } = useAsyncCheckPermissions( PermissionAction.CREATE, 'user_content', { diff --git a/apps/studio/components/interfaces/Settings/API/PostgrestConfig.tsx b/apps/studio/components/interfaces/Settings/API/PostgrestConfig.tsx index d5676bced4958..5f2e97cc07e4f 100644 --- a/apps/studio/components/interfaces/Settings/API/PostgrestConfig.tsx +++ b/apps/studio/components/interfaces/Settings/API/PostgrestConfig.tsx @@ -15,7 +15,7 @@ import { useProjectPostgrestConfigQuery } from 'data/config/project-postgrest-co import { useProjectPostgrestConfigUpdateMutation } from 'data/config/project-postgrest-config-update-mutation' import { useDatabaseExtensionsQuery } from 'data/database-extensions/database-extensions-query' import { useSchemasQuery } from 'data/database/schemas-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { AlertDescription_Shadcn_, @@ -102,7 +102,7 @@ export const PostgrestConfig = () => { const formId = 'project-postgres-config' const hiddenSchema = ['auth', 'pgbouncer', 'hooks', 'extensions'] const { can: canUpdatePostgrestConfig, isSuccess: isPermissionsLoaded } = - useAsyncCheckProjectPermissions(PermissionAction.UPDATE, 'custom_config_postgrest') + useAsyncCheckPermissions(PermissionAction.UPDATE, 'custom_config_postgrest') const isGraphqlExtensionEnabled = (extensions ?? []).find((ext) => ext.name === 'pg_graphql')?.installed_version !== null diff --git a/apps/studio/components/interfaces/Settings/Addons/CustomDomainSidePanel.tsx b/apps/studio/components/interfaces/Settings/Addons/CustomDomainSidePanel.tsx index 3f79a908bf7ec..7e035c727bc5c 100644 --- a/apps/studio/components/interfaces/Settings/Addons/CustomDomainSidePanel.tsx +++ b/apps/studio/components/interfaces/Settings/Addons/CustomDomainSidePanel.tsx @@ -9,7 +9,7 @@ import { useProjectAddonRemoveMutation } from 'data/subscriptions/project-addon- import { useProjectAddonUpdateMutation } from 'data/subscriptions/project-addon-update-mutation' import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query' import type { AddonVariantId } from 'data/subscriptions/types' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { formatCurrency } from 'lib/helpers' import { useAddonsPagePanel } from 'state/addons-page' @@ -31,7 +31,7 @@ const CustomDomainSidePanel = () => { const [selectedOption, setSelectedOption] = useState('cd_none') - const { can: canUpdateCustomDomain } = useAsyncCheckProjectPermissions( + const { can: canUpdateCustomDomain } = useAsyncCheckPermissions( PermissionAction.BILLING_WRITE, 'stripe.subscriptions' ) diff --git a/apps/studio/components/interfaces/Settings/Addons/IPv4SidePanel.tsx b/apps/studio/components/interfaces/Settings/Addons/IPv4SidePanel.tsx index 81d1a1dbb798f..01e54ff3308d8 100644 --- a/apps/studio/components/interfaces/Settings/Addons/IPv4SidePanel.tsx +++ b/apps/studio/components/interfaces/Settings/Addons/IPv4SidePanel.tsx @@ -10,7 +10,7 @@ import { useProjectAddonRemoveMutation } from 'data/subscriptions/project-addon- import { useProjectAddonUpdateMutation } from 'data/subscriptions/project-addon-update-mutation' import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query' import type { AddonVariantId } from 'data/subscriptions/types' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { useIsAwsCloudProvider } from 'hooks/misc/useSelectedProject' import { formatCurrency } from 'lib/helpers' @@ -25,7 +25,7 @@ const IPv4SidePanel = () => { const [selectedOption, setSelectedOption] = useState('ipv4_none') - const { can: canUpdateIPv4 } = useAsyncCheckProjectPermissions( + const { can: canUpdateIPv4 } = useAsyncCheckPermissions( PermissionAction.BILLING_WRITE, 'stripe.subscriptions' ) diff --git a/apps/studio/components/interfaces/Settings/Addons/PITRSidePanel.tsx b/apps/studio/components/interfaces/Settings/Addons/PITRSidePanel.tsx index 8e80cf20d8706..cfd5deb17d69e 100644 --- a/apps/studio/components/interfaces/Settings/Addons/PITRSidePanel.tsx +++ b/apps/studio/components/interfaces/Settings/Addons/PITRSidePanel.tsx @@ -13,7 +13,7 @@ import { useProjectAddonRemoveMutation } from 'data/subscriptions/project-addon- import { useProjectAddonUpdateMutation } from 'data/subscriptions/project-addon-update-mutation' import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query' import type { AddonVariantId } from 'data/subscriptions/types' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { BASE_PATH } from 'lib/constants' @@ -61,7 +61,7 @@ const PITRSidePanel = () => { const [selectedCategory, setSelectedCategory] = useState<'on' | 'off'>('off') const [selectedOption, setSelectedOption] = useState('pitr_0') - const { can: canUpdatePitr } = useAsyncCheckProjectPermissions( + const { can: canUpdatePitr } = useAsyncCheckPermissions( PermissionAction.BILLING_WRITE, 'stripe.subscriptions' ) diff --git a/apps/studio/components/interfaces/Settings/Database/BannedIPs.tsx b/apps/studio/components/interfaces/Settings/Database/BannedIPs.tsx index 29ec00bb24625..952288603b5cd 100644 --- a/apps/studio/components/interfaces/Settings/Database/BannedIPs.tsx +++ b/apps/studio/components/interfaces/Settings/Database/BannedIPs.tsx @@ -12,7 +12,7 @@ import { FormPanel } from 'components/ui/Forms/FormPanel' import { useBannedIPsDeleteMutation } from 'data/banned-ips/banned-ips-delete-mutations' import { useBannedIPsQuery } from 'data/banned-ips/banned-ips-query' import { useUserIPAddressQuery } from 'data/misc/user-ip-address-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { Badge, Skeleton } from 'ui' import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal' @@ -39,15 +39,11 @@ const BannedIPs = () => { const [showUnban, setShowUnban] = useState(false) const [confirmingIP, setConfirmingIP] = useState(null) // Track the IP being confirmed for unban - const { can: canUnbanNetworks } = useAsyncCheckProjectPermissions( - PermissionAction.UPDATE, - 'projects', - { - resource: { - project_id: project?.id, - }, - } - ) + const { can: canUnbanNetworks } = useAsyncCheckPermissions(PermissionAction.UPDATE, 'projects', { + resource: { + project_id: project?.id, + }, + }) const { mutate: unbanIPs, isLoading: isUnbanning } = useBannedIPsDeleteMutation({ onSuccess: () => { diff --git a/apps/studio/components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling.tsx b/apps/studio/components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling.tsx index 66127cfa7c921..47e7700820fd5 100644 --- a/apps/studio/components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling.tsx +++ b/apps/studio/components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling.tsx @@ -17,7 +17,7 @@ import { useMaxConnectionsQuery } from 'data/database/max-connections-query' import { usePgbouncerConfigQuery } from 'data/database/pgbouncer-config-query' import { usePgbouncerConfigurationUpdateMutation } from 'data/database/pgbouncer-config-update-mutation' import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { @@ -51,7 +51,7 @@ export const ConnectionPooling = () => { const { data: project } = useSelectedProjectQuery() const { data: org } = useSelectedOrganizationQuery() - const { can: canUpdateConnectionPoolingConfiguration } = useAsyncCheckProjectPermissions( + const { can: canUpdateConnectionPoolingConfiguration } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'projects', { resource: { project_id: project?.id } } diff --git a/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/ResetDbPassword.tsx b/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/ResetDbPassword.tsx index b39ac8008fab8..17e30ace69036 100644 --- a/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/ResetDbPassword.tsx +++ b/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/ResetDbPassword.tsx @@ -9,7 +9,7 @@ import { ButtonTooltip } from 'components/ui/ButtonTooltip' import Panel from 'components/ui/Panel' import PasswordStrengthBar from 'components/ui/PasswordStrengthBar' import { useDatabasePasswordResetMutation } from 'data/database/database-password-reset-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { DEFAULT_MINIMUM_PASSWORD_STRENGTH } from 'lib/constants' import passwordStrength from 'lib/password-strength' @@ -21,7 +21,7 @@ const ResetDbPassword = ({ disabled = false }) => { const isProjectActive = useIsProjectActive() const { data: project } = useSelectedProjectQuery() - const { can: canResetDbPassword } = useAsyncCheckProjectPermissions( + const { can: canResetDbPassword } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'projects', { diff --git a/apps/studio/components/interfaces/Settings/Database/DiskSizeConfiguration.tsx b/apps/studio/components/interfaces/Settings/Database/DiskSizeConfiguration.tsx index f8ae07220fe29..140b110d380e5 100644 --- a/apps/studio/components/interfaces/Settings/Database/DiskSizeConfiguration.tsx +++ b/apps/studio/components/interfaces/Settings/Database/DiskSizeConfiguration.tsx @@ -12,7 +12,7 @@ import { FormHeader } from 'components/ui/Forms/FormHeader' import Panel from 'components/ui/Panel' import { useProjectDiskResizeMutation } from 'data/config/project-disk-resize-mutation' import { useDatabaseSizeQuery } from 'data/database/database-size-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { useUrlState } from 'hooks/ui/useUrlState' @@ -35,7 +35,7 @@ const DiskSizeConfiguration = ({ disabled = false }: DiskSizeConfigurationProps) setUrlParams({ show_increase_disk_size_modal: show ? 'true' : undefined }) } - const { can: canUpdateDiskSizeConfig } = useAsyncCheckProjectPermissions( + const { can: canUpdateDiskSizeConfig } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'projects', { diff --git a/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/NetworkRestrictions.tsx b/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/NetworkRestrictions.tsx index 4418578341e17..65455dd2ef49f 100644 --- a/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/NetworkRestrictions.tsx +++ b/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/NetworkRestrictions.tsx @@ -10,7 +10,7 @@ import { FormPanel } from 'components/ui/Forms/FormPanel' import Panel from 'components/ui/Panel' import ShimmeringLoader from 'components/ui/ShimmeringLoader' import { useNetworkRestrictionsQuery } from 'data/network-restrictions/network-restrictions-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { Badge, @@ -75,7 +75,7 @@ const NetworkRestrictions = () => { const [selectedRestrictionToRemove, setSelectedRestrictionToRemove] = useState() const { data, isLoading } = useNetworkRestrictionsQuery({ projectRef: ref }) - const { can: canUpdateNetworkRestrictions } = useAsyncCheckProjectPermissions( + const { can: canUpdateNetworkRestrictions } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'projects', { diff --git a/apps/studio/components/interfaces/Settings/Database/SSLConfiguration.tsx b/apps/studio/components/interfaces/Settings/Database/SSLConfiguration.tsx index 70d151e18ca7d..70092a729d447 100644 --- a/apps/studio/components/interfaces/Settings/Database/SSLConfiguration.tsx +++ b/apps/studio/components/interfaces/Settings/Database/SSLConfiguration.tsx @@ -15,7 +15,7 @@ import { useProjectSettingsV2Query } from 'data/config/project-settings-v2-query import { useSSLEnforcementQuery } from 'data/ssl-enforcement/ssl-enforcement-query' import { useSSLEnforcementUpdateMutation } from 'data/ssl-enforcement/ssl-enforcement-update-mutation' import { useCustomContent } from 'hooks/custom-content/useCustomContent' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { Alert, Button, Switch, Tooltip, TooltipContent, TooltipTrigger } from 'ui' @@ -44,7 +44,7 @@ const SSLConfiguration = () => { } ) - const { can: canUpdateSSLEnforcement } = useAsyncCheckProjectPermissions( + const { can: canUpdateSSLEnforcement } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'projects', { diff --git a/apps/studio/components/interfaces/Settings/General/ComplianceConfig/ProjectComplianceMode.tsx b/apps/studio/components/interfaces/Settings/General/ComplianceConfig/ProjectComplianceMode.tsx index 0f33a4c6e124c..d59a176634c40 100644 --- a/apps/studio/components/interfaces/Settings/General/ComplianceConfig/ProjectComplianceMode.tsx +++ b/apps/studio/components/interfaces/Settings/General/ComplianceConfig/ProjectComplianceMode.tsx @@ -12,7 +12,7 @@ import { FormSection, FormSectionContent, FormSectionLabel } from 'components/ui import { InlineLink } from 'components/ui/InlineLink' import { useComplianceConfigUpdateMutation } from 'data/config/project-compliance-config-mutation' import { useProjectSettingsV2Query } from 'data/config/project-settings-v2-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { Switch, Tooltip, TooltipContent, TooltipTrigger } from 'ui' @@ -21,7 +21,7 @@ const ComplianceConfig = () => { const { data: project } = useSelectedProjectQuery() const [isSensitive, setIsSensitive] = useState(false) - const { can: canUpdateComplianceConfig } = useAsyncCheckProjectPermissions( + const { can: canUpdateComplianceConfig } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'projects', { diff --git a/apps/studio/components/interfaces/Settings/General/CustomDomainConfig/CustomDomainsConfigureHostname.tsx b/apps/studio/components/interfaces/Settings/General/CustomDomainConfig/CustomDomainsConfigureHostname.tsx index 1f7f77233c6d9..de8a2d0541b41 100644 --- a/apps/studio/components/interfaces/Settings/General/CustomDomainConfig/CustomDomainsConfigureHostname.tsx +++ b/apps/studio/components/interfaces/Settings/General/CustomDomainConfig/CustomDomainsConfigureHostname.tsx @@ -9,7 +9,7 @@ import { FormSection, FormSectionContent, FormSectionLabel } from 'components/ui import { useProjectSettingsV2Query } from 'data/config/project-settings-v2-query' import { useCheckCNAMERecordMutation } from 'data/custom-domains/check-cname-mutation' import { useCustomDomainCreateMutation } from 'data/custom-domains/custom-domains-create-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { Form, Input } from 'ui' @@ -27,7 +27,7 @@ const CustomDomainsConfigureHostname = () => { const FORM_ID = 'custom-domains-form' const endpoint = settings?.app_config?.endpoint - const { can: canConfigureCustomDomain } = useAsyncCheckProjectPermissions( + const { can: canConfigureCustomDomain } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'projects', { diff --git a/apps/studio/components/interfaces/Settings/General/DeleteProjectPanel/DeleteProjectButton.tsx b/apps/studio/components/interfaces/Settings/General/DeleteProjectPanel/DeleteProjectButton.tsx index a47ecbb6cd6a2..d753a214cec29 100644 --- a/apps/studio/components/interfaces/Settings/General/DeleteProjectPanel/DeleteProjectButton.tsx +++ b/apps/studio/components/interfaces/Settings/General/DeleteProjectPanel/DeleteProjectButton.tsx @@ -2,7 +2,7 @@ import { PermissionAction } from '@supabase/shared-types/out/constants' import { useState } from 'react' import { ButtonTooltip } from 'components/ui/ButtonTooltip' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { DeleteProjectModal } from './DeleteProjectModal' @@ -14,13 +14,9 @@ const DeleteProjectButton = ({ type = 'danger' }: DeleteProjectButtonProps) => { const { data: project } = useSelectedProjectQuery() const [isOpen, setIsOpen] = useState(false) - const { can: canDeleteProject } = useAsyncCheckProjectPermissions( - PermissionAction.UPDATE, - 'projects', - { - resource: { project_id: project?.id }, - } - ) + const { can: canDeleteProject } = useAsyncCheckPermissions(PermissionAction.UPDATE, 'projects', { + resource: { project_id: project?.id }, + }) return ( <> diff --git a/apps/studio/components/interfaces/Settings/General/General.tsx b/apps/studio/components/interfaces/Settings/General/General.tsx index ea95391fcafe7..b58a5ff716211 100644 --- a/apps/studio/components/interfaces/Settings/General/General.tsx +++ b/apps/studio/components/interfaces/Settings/General/General.tsx @@ -9,7 +9,7 @@ import { FormSection, FormSectionContent, FormSectionLabel } from 'components/ui import Panel from 'components/ui/Panel' import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader' import { useProjectUpdateMutation } from 'data/projects/project-update-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { useProjectByRefQuery, useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { @@ -33,15 +33,11 @@ const General = () => { const formId = 'project-general-settings' const initialValues = { name: project?.name ?? '', ref: project?.ref ?? '' } - const { can: canUpdateProject } = useAsyncCheckProjectPermissions( - PermissionAction.UPDATE, - 'projects', - { - resource: { - project_id: project?.id, - }, - } - ) + const { can: canUpdateProject } = useAsyncCheckPermissions(PermissionAction.UPDATE, 'projects', { + resource: { + project_id: project?.id, + }, + }) const { mutate: updateProject, isLoading: isUpdating } = useProjectUpdateMutation() diff --git a/apps/studio/components/interfaces/Settings/General/Infrastructure/PauseProjectButton.tsx b/apps/studio/components/interfaces/Settings/General/Infrastructure/PauseProjectButton.tsx index 1cd34e163ec7b..3f8223e8a6ccf 100644 --- a/apps/studio/components/interfaces/Settings/General/Infrastructure/PauseProjectButton.tsx +++ b/apps/studio/components/interfaces/Settings/General/Infrastructure/PauseProjectButton.tsx @@ -9,7 +9,7 @@ import { useIsProjectActive } from 'components/layouts/ProjectLayout/ProjectCont import { ButtonTooltip } from 'components/ui/ButtonTooltip' import { useProjectPauseMutation } from 'data/projects/project-pause-mutation' import { setProjectStatus } from 'data/projects/projects-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { useIsAwsK8sCloudProvider, useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { PROJECT_STATUS } from 'lib/constants' @@ -25,7 +25,7 @@ const PauseProjectButton = () => { const projectRef = project?.ref ?? '' const isPaused = project?.status === PROJECT_STATUS.INACTIVE - const { can: canPauseProject } = useAsyncCheckProjectPermissions( + const { can: canPauseProject } = useAsyncCheckPermissions( PermissionAction.INFRA_EXECUTE, 'queue_jobs.projects.pause' ) diff --git a/apps/studio/components/interfaces/Settings/General/Infrastructure/RestartServerButton.tsx b/apps/studio/components/interfaces/Settings/General/Infrastructure/RestartServerButton.tsx index 8138ea7b1c0a0..55c0f44e7f327 100644 --- a/apps/studio/components/interfaces/Settings/General/Infrastructure/RestartServerButton.tsx +++ b/apps/studio/components/interfaces/Settings/General/Infrastructure/RestartServerButton.tsx @@ -11,7 +11,7 @@ import { ButtonTooltip } from 'components/ui/ButtonTooltip' import { useProjectRestartMutation } from 'data/projects/project-restart-mutation' import { useProjectRestartServicesMutation } from 'data/projects/project-restart-services-mutation' import { setProjectStatus } from 'data/projects/projects-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useIsAwsK8sCloudProvider, useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { Button, @@ -35,7 +35,7 @@ const RestartServerButton = () => { const projectRegion = project?.region ?? '' const projectRestartDisabled = useFlag('disableProjectRestarts') - const { can: canRestartProject } = useAsyncCheckProjectPermissions( + const { can: canRestartProject } = useAsyncCheckPermissions( PermissionAction.INFRA_EXECUTE, 'reboot' ) diff --git a/apps/studio/components/interfaces/Settings/General/TransferProjectPanel/TransferProjectButton.tsx b/apps/studio/components/interfaces/Settings/General/TransferProjectPanel/TransferProjectButton.tsx index 747500510b5bf..68d3413aab03a 100644 --- a/apps/studio/components/interfaces/Settings/General/TransferProjectPanel/TransferProjectButton.tsx +++ b/apps/studio/components/interfaces/Settings/General/TransferProjectPanel/TransferProjectButton.tsx @@ -9,7 +9,7 @@ import { DocsButton } from 'components/ui/DocsButton' import { useOrganizationsQuery } from 'data/organizations/organizations-query' import { useProjectTransferMutation } from 'data/projects/project-transfer-mutation' import { useProjectTransferPreviewQuery } from 'data/projects/project-transfer-preview-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { Button, InfoIcon, Listbox, Loading, Modal, WarningIcon } from 'ui' import { Admonition } from 'ui-patterns' @@ -58,7 +58,7 @@ const TransferProjectButton = () => { } }, [isOpen]) - const { can: canTransferProject } = useAsyncCheckProjectPermissions( + const { can: canTransferProject } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'organizations' ) diff --git a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceConfiguration.tsx b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceConfiguration.tsx index f74301cc8c6ab..8d6fb5b6211ca 100644 --- a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceConfiguration.tsx +++ b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceConfiguration.tsx @@ -16,7 +16,7 @@ import { ReplicaInitializationStatus, useReadReplicasStatusesQuery, } from 'data/read-replicas/replicas-status-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useIsOrioleDb, useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { timeout } from 'lib/helpers' import { type AWS_REGIONS_KEYS } from 'shared-data' @@ -60,10 +60,7 @@ const InstanceConfigurationUI = ({ diagramOnly = false }: InstanceConfigurationU const [selectedReplicaToDrop, setSelectedReplicaToDrop] = useState() const [selectedReplicaToRestart, setSelectedReplicaToRestart] = useState() - const { can: canManageReplicas } = useAsyncCheckProjectPermissions( - PermissionAction.CREATE, - 'projects' - ) + const { can: canManageReplicas } = useAsyncCheckPermissions(PermissionAction.CREATE, 'projects') const { data: loadBalancers, diff --git a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceNode.tsx b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceNode.tsx index a14c87464c1fc..07dc3bf06743c 100644 --- a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceNode.tsx +++ b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceNode.tsx @@ -14,7 +14,7 @@ import { useReadReplicasStatusesQuery, } from 'data/read-replicas/replicas-status-query' import { formatDatabaseID } from 'data/read-replicas/replicas.utils' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled' import { BASE_PATH } from 'lib/constants' import { useDatabaseSelectorStateSnapshot } from 'state/database-selector' @@ -191,10 +191,7 @@ export const ReplicaNode = ({ data }: NodeProps) => { } = data const { ref } = useParams() const dbSelectorState = useDatabaseSelectorStateSnapshot() - const { can: canManageReplicas } = useAsyncCheckProjectPermissions( - PermissionAction.CREATE, - 'projects' - ) + const { can: canManageReplicas } = useAsyncCheckPermissions(PermissionAction.CREATE, 'projects') const { projectHomepageShowInstanceSize } = useIsFeatureEnabled([ 'project_homepage:show_instance_size', ]) diff --git a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/MapView.tsx b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/MapView.tsx index 6140367095b9a..d933d78905e1d 100644 --- a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/MapView.tsx +++ b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/MapView.tsx @@ -19,7 +19,7 @@ import { ButtonTooltip } from 'components/ui/ButtonTooltip' import { DropdownMenuItemTooltip } from 'components/ui/DropdownMenuItemTooltip' import { Database, useReadReplicasQuery } from 'data/read-replicas/replicas-query' import { formatDatabaseID } from 'data/read-replicas/replicas.utils' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled' import { BASE_PATH } from 'lib/constants' import type { AWS_REGIONS_KEYS } from 'shared-data' @@ -64,10 +64,7 @@ const MapView = ({ y: number region: { key: string; country?: string; name?: string; region?: string } }>() - const { can: canManageReplicas } = useAsyncCheckProjectPermissions( - PermissionAction.CREATE, - 'projects' - ) + const { can: canManageReplicas } = useAsyncCheckPermissions(PermissionAction.CREATE, 'projects') const [, setShowConnect] = useQueryState('showConnect', parseAsBoolean.withDefault(false)) const { data } = useReadReplicasQuery({ projectRef: ref }) diff --git a/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GitHubIntegrationConnectionForm.tsx b/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GitHubIntegrationConnectionForm.tsx index e9c083c197542..e97061a5869a8 100644 --- a/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GitHubIntegrationConnectionForm.tsx +++ b/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GitHubIntegrationConnectionForm.tsx @@ -16,7 +16,7 @@ import { useGitHubConnectionDeleteMutation } from 'data/integrations/github-conn import { useGitHubConnectionUpdateMutation } from 'data/integrations/github-connection-update-mutation' import { useGitHubRepositoriesQuery } from 'data/integrations/github-repositories-query' import type { GitHubConnection } from 'data/integrations/integrations.types' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { openInstallGitHubIntegrationWindow } from 'lib/github' @@ -72,11 +72,11 @@ const GitHubIntegrationConnectionForm = ({ const [repoComboBoxOpen, setRepoComboboxOpen] = useState(false) const isParentProject = !Boolean(selectedProject?.parent_project_ref) - const { can: canUpdateGitHubConnection } = useAsyncCheckProjectPermissions( + const { can: canUpdateGitHubConnection } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'integrations.github_connections' ) - const { can: canCreateGitHubConnection } = useAsyncCheckProjectPermissions( + const { can: canCreateGitHubConnection } = useAsyncCheckPermissions( PermissionAction.CREATE, 'integrations.github_connections' ) diff --git a/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GithubSection.tsx b/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GithubSection.tsx index 36256f769ef90..2d538b3a805eb 100644 --- a/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GithubSection.tsx +++ b/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GithubSection.tsx @@ -11,7 +11,7 @@ import { import NoPermission from 'components/ui/NoPermission' import UpgradeToPro from 'components/ui/UpgradeToPro' import { useGitHubConnectionsQuery } from 'data/integrations/github-connections-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { BASE_PATH, IS_PLATFORM } from 'lib/constants' import { cn } from 'ui' @@ -33,7 +33,7 @@ const GitHubSection = () => { const { data: organization } = useSelectedOrganizationQuery() const { can: canReadGitHubConnection, isLoading: isLoadingPermissions } = - useAsyncCheckProjectPermissions(PermissionAction.READ, 'integrations.github_connections') + useAsyncCheckPermissions(PermissionAction.READ, 'integrations.github_connections') const isProPlanAndUp = organization?.plan?.id !== 'free' const promptProPlanUpgrade = IS_PLATFORM && !isProPlanAndUp diff --git a/apps/studio/components/interfaces/Settings/Integrations/VercelIntegration/VercelSection.tsx b/apps/studio/components/interfaces/Settings/Integrations/VercelIntegration/VercelSection.tsx index 74c721dbe2ffe..59c6ca8d8033d 100644 --- a/apps/studio/components/interfaces/Settings/Integrations/VercelIntegration/VercelSection.tsx +++ b/apps/studio/components/interfaces/Settings/Integrations/VercelIntegration/VercelSection.tsx @@ -26,7 +26,7 @@ import type { IntegrationName, IntegrationProjectConnection, } from 'data/integrations/integrations.types' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { pluralize } from 'lib/helpers' @@ -44,12 +44,12 @@ const VercelSection = ({ isProjectScoped }: { isProjectScoped: boolean }) => { const isBranch = project?.parent_project_ref !== undefined const { can: canReadVercelConnection, isLoading: isLoadingPermissions } = - useAsyncCheckProjectPermissions(PermissionAction.READ, 'integrations.vercel_connections') - const { can: canCreateVercelConnection } = useAsyncCheckProjectPermissions( + useAsyncCheckPermissions(PermissionAction.READ, 'integrations.vercel_connections') + const { can: canCreateVercelConnection } = useAsyncCheckPermissions( PermissionAction.CREATE, 'integrations.vercel_connections' ) - const { can: canUpdateVercelConnection } = useAsyncCheckProjectPermissions( + const { can: canUpdateVercelConnection } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'integrations.vercel_connections' ) diff --git a/apps/studio/components/interfaces/Settings/Logs/LogTable.tsx b/apps/studio/components/interfaces/Settings/Logs/LogTable.tsx index b6e32e5d1c393..0e439d9cbd82d 100644 --- a/apps/studio/components/interfaces/Settings/Logs/LogTable.tsx +++ b/apps/studio/components/interfaces/Settings/Logs/LogTable.tsx @@ -10,7 +10,7 @@ import { IS_PLATFORM, useParams } from 'common' import { ButtonTooltip } from 'components/ui/ButtonTooltip' import { DownloadResultsButton } from 'components/ui/DownloadResultsButton' import { useSelectedLog } from 'hooks/analytics/useSelectedLog' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useProfile } from 'lib/profile' import { toast } from 'sonner' import { ResponseError } from 'types' @@ -94,7 +94,7 @@ const LogTable = ({ const [selectionOpen, setSelectionOpen] = useState(false) const [selectedRow, setSelectedRow] = useState(null) - const { can: canCreateLogQuery } = useAsyncCheckProjectPermissions( + const { can: canCreateLogQuery } = useAsyncCheckPermissions( PermissionAction.CREATE, 'user_content', { diff --git a/apps/studio/components/interfaces/Storage/BucketRow.tsx b/apps/studio/components/interfaces/Storage/BucketRow.tsx index 294939db04123..031de7b14125a 100644 --- a/apps/studio/components/interfaces/Storage/BucketRow.tsx +++ b/apps/studio/components/interfaces/Storage/BucketRow.tsx @@ -7,7 +7,7 @@ import { DeleteBucketModal } from 'components/interfaces/Storage/DeleteBucketMod import { EditBucketModal } from 'components/interfaces/Storage/EditBucketModal' import { EmptyBucketModal } from 'components/interfaces/Storage/EmptyBucketModal' import type { Bucket } from 'data/storage/buckets-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { Badge, Button, @@ -29,10 +29,7 @@ export interface BucketRowProps { } export const BucketRow = ({ bucket, projectRef = '', isSelected = false }: BucketRowProps) => { - const { can: canUpdateBuckets } = useAsyncCheckProjectPermissions( - PermissionAction.STORAGE_WRITE, - '*' - ) + const { can: canUpdateBuckets } = useAsyncCheckPermissions(PermissionAction.STORAGE_WRITE, '*') const [modal, setModal] = useState(null) const onClose = () => setModal(null) diff --git a/apps/studio/components/interfaces/Storage/CreateBucketModal.tsx b/apps/studio/components/interfaces/Storage/CreateBucketModal.tsx index a6ad858197a24..1eddfd8128d97 100644 --- a/apps/studio/components/interfaces/Storage/CreateBucketModal.tsx +++ b/apps/studio/components/interfaces/Storage/CreateBucketModal.tsx @@ -17,7 +17,7 @@ import { useProjectStorageConfigQuery } from 'data/config/project-storage-config import { useBucketCreateMutation } from 'data/storage/bucket-create-mutation' import { useIcebergWrapperCreateMutation } from 'data/storage/iceberg-wrapper-create-mutation' import { useSendEventMutation } from 'data/telemetry/send-event-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { BASE_PATH, IS_PLATFORM } from 'lib/constants' import { @@ -103,10 +103,7 @@ export const CreateBucketModal = () => { const [visible, setVisible] = useState(false) const [selectedUnit, setSelectedUnit] = useState(StorageSizeUnits.MB) - const { can: canCreateBuckets } = useAsyncCheckProjectPermissions( - PermissionAction.STORAGE_WRITE, - '*' - ) + const { can: canCreateBuckets } = useAsyncCheckPermissions(PermissionAction.STORAGE_WRITE, '*') const { mutate: sendEvent } = useSendEventMutation() const { mutateAsync: createBucket, isLoading: isCreating } = useBucketCreateMutation({ diff --git a/apps/studio/components/interfaces/Storage/StorageExplorer/ColumnContextMenu.tsx b/apps/studio/components/interfaces/Storage/StorageExplorer/ColumnContextMenu.tsx index d0acf14b0337f..746d1e21f0990 100644 --- a/apps/studio/components/interfaces/Storage/StorageExplorer/ColumnContextMenu.tsx +++ b/apps/studio/components/interfaces/Storage/StorageExplorer/ColumnContextMenu.tsx @@ -3,7 +3,7 @@ import { Item, Menu, Separator, Submenu } from 'react-contexify' import 'react-contexify/dist/ReactContexify.css' import { PermissionAction } from '@supabase/shared-types/out/constants' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { ChevronRight, ChevronsDown, ChevronsUp, Clipboard, Eye, FolderPlus } from 'lucide-react' import { useStorageExplorerStateSnapshot } from 'state/storage-explorer' import { @@ -28,10 +28,7 @@ export const ColumnContextMenu = ({ id = '' }: ColumnContextMenuProps) => { addNewFolderPlaceholder, } = useStorageExplorerStateSnapshot() - const { can: canUpdateFiles } = useAsyncCheckProjectPermissions( - PermissionAction.STORAGE_WRITE, - '*' - ) + const { can: canUpdateFiles } = useAsyncCheckPermissions(PermissionAction.STORAGE_WRITE, '*') const onSelectCreateFolder = (columnIndex = -1) => { addNewFolderPlaceholder(columnIndex) diff --git a/apps/studio/components/interfaces/Storage/StorageExplorer/FileExplorerColumn.tsx b/apps/studio/components/interfaces/Storage/StorageExplorer/FileExplorerColumn.tsx index e65e425cdb416..ebbaee5a51695 100644 --- a/apps/studio/components/interfaces/Storage/StorageExplorer/FileExplorerColumn.tsx +++ b/apps/studio/components/interfaces/Storage/StorageExplorer/FileExplorerColumn.tsx @@ -8,7 +8,7 @@ import { toast } from 'sonner' import InfiniteList from 'components/ui/InfiniteList' import ShimmeringLoader from 'components/ui/ShimmeringLoader' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { BASE_PATH } from 'lib/constants' import { formatBytes } from 'lib/helpers' import { useStorageExplorerStateSnapshot } from 'state/storage-explorer' @@ -83,10 +83,7 @@ export const FileExplorerColumn = ({ const fileExplorerColumnRef = useRef(null) const snap = useStorageExplorerStateSnapshot() - const { can: canUpdateStorage } = useAsyncCheckProjectPermissions( - PermissionAction.STORAGE_WRITE, - '*' - ) + const { can: canUpdateStorage } = useAsyncCheckPermissions(PermissionAction.STORAGE_WRITE, '*') useEffect(() => { if (fileExplorerColumnRef) { diff --git a/apps/studio/components/interfaces/Storage/StorageExplorer/FileExplorerHeader.tsx b/apps/studio/components/interfaces/Storage/StorageExplorer/FileExplorerHeader.tsx index 0d080f6c90f6b..72135eb819e90 100644 --- a/apps/studio/components/interfaces/Storage/StorageExplorer/FileExplorerHeader.tsx +++ b/apps/studio/components/interfaces/Storage/StorageExplorer/FileExplorerHeader.tsx @@ -19,7 +19,7 @@ import { useCallback, useEffect, useRef, useState } from 'react' import { useIsAPIDocsSidePanelEnabled } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext' import { APIDocsButton } from 'components/ui/APIDocsButton' import { ButtonTooltip } from 'components/ui/ButtonTooltip' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useStorageExplorerStateSnapshot } from 'state/storage-explorer' import { Button, @@ -179,10 +179,7 @@ export const FileExplorerHeader = ({ const breadcrumbs = columns.map((column) => column.name) const backDisabled = columns.length <= 1 - const { can: canUpdateStorage } = useAsyncCheckProjectPermissions( - PermissionAction.STORAGE_WRITE, - '*' - ) + const { can: canUpdateStorage } = useAsyncCheckPermissions(PermissionAction.STORAGE_WRITE, '*') useEffect(() => { if (itemSearchString) setSearchString(itemSearchString) diff --git a/apps/studio/components/interfaces/Storage/StorageExplorer/FileExplorerHeaderSelection.tsx b/apps/studio/components/interfaces/Storage/StorageExplorer/FileExplorerHeaderSelection.tsx index 9b4559c5b5b71..f7b45bd74cc94 100644 --- a/apps/studio/components/interfaces/Storage/StorageExplorer/FileExplorerHeaderSelection.tsx +++ b/apps/studio/components/interfaces/Storage/StorageExplorer/FileExplorerHeaderSelection.tsx @@ -3,17 +3,14 @@ import { Download, Move, Trash2, X } from 'lucide-react' import { useParams } from 'common' import { ButtonTooltip } from 'components/ui/ButtonTooltip' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useStorageExplorerStateSnapshot } from 'state/storage-explorer' import { Button } from 'ui' import { downloadFile } from './StorageExplorer.utils' export const FileExplorerHeaderSelection = () => { const { ref: projectRef, bucketId } = useParams() - const { can: canUpdateFiles } = useAsyncCheckProjectPermissions( - PermissionAction.STORAGE_WRITE, - '*' - ) + const { can: canUpdateFiles } = useAsyncCheckPermissions(PermissionAction.STORAGE_WRITE, '*') const { selectedItems, diff --git a/apps/studio/components/interfaces/Storage/StorageExplorer/FileExplorerRow.tsx b/apps/studio/components/interfaces/Storage/StorageExplorer/FileExplorerRow.tsx index df4a5eaa8ef1d..467af3341c71c 100644 --- a/apps/studio/components/interfaces/Storage/StorageExplorer/FileExplorerRow.tsx +++ b/apps/studio/components/interfaces/Storage/StorageExplorer/FileExplorerRow.tsx @@ -19,7 +19,7 @@ import SVG from 'react-inlinesvg' import { useParams } from 'common' import type { ItemRenderer } from 'components/ui/InfiniteList' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { BASE_PATH } from 'lib/constants' import { formatBytes } from 'lib/helpers' import { useStorageExplorerStateSnapshot } from 'state/storage-explorer' @@ -139,10 +139,7 @@ export const FileExplorerRow: ItemRenderer = const isOpened = openedFolders.length > columnIndex ? openedFolders[columnIndex].name === item.name : false const isPreviewed = !isEmpty(selectedFilePreview) && isEqual(selectedFilePreview?.id, item.id) - const { can: canUpdateFiles } = useAsyncCheckProjectPermissions( - PermissionAction.STORAGE_WRITE, - '*' - ) + const { can: canUpdateFiles } = useAsyncCheckPermissions(PermissionAction.STORAGE_WRITE, '*') const onSelectFile = async (columnIndex: number, file: StorageItem) => { popColumnAtIndex(columnIndex) diff --git a/apps/studio/components/interfaces/Storage/StorageExplorer/FolderContextMenu.tsx b/apps/studio/components/interfaces/Storage/StorageExplorer/FolderContextMenu.tsx index 1242a841a7b62..c91c498c0bbb1 100644 --- a/apps/studio/components/interfaces/Storage/StorageExplorer/FolderContextMenu.tsx +++ b/apps/studio/components/interfaces/Storage/StorageExplorer/FolderContextMenu.tsx @@ -3,7 +3,7 @@ import { Clipboard, Download, Edit, Trash2 } from 'lucide-react' import { Item, Menu, Separator } from 'react-contexify' import 'react-contexify/dist/ReactContexify.css' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useStorageExplorerStateSnapshot } from 'state/storage-explorer' import { copyPathToFolder } from './StorageExplorer.utils' @@ -14,10 +14,7 @@ interface FolderContextMenuProps { export const FolderContextMenu = ({ id = '' }: FolderContextMenuProps) => { const { openedFolders, downloadFolder, setSelectedItemToRename, setSelectedItemsToDelete } = useStorageExplorerStateSnapshot() - const { can: canUpdateFiles } = useAsyncCheckProjectPermissions( - PermissionAction.STORAGE_WRITE, - '*' - ) + const { can: canUpdateFiles } = useAsyncCheckPermissions(PermissionAction.STORAGE_WRITE, '*') return ( diff --git a/apps/studio/components/interfaces/Storage/StorageExplorer/ItemContextMenu.tsx b/apps/studio/components/interfaces/Storage/StorageExplorer/ItemContextMenu.tsx index 0712e4b6578c7..359a35878c7f3 100644 --- a/apps/studio/components/interfaces/Storage/StorageExplorer/ItemContextMenu.tsx +++ b/apps/studio/components/interfaces/Storage/StorageExplorer/ItemContextMenu.tsx @@ -4,7 +4,7 @@ import { Item, Menu, Separator, Submenu } from 'react-contexify' import 'react-contexify/dist/ReactContexify.css' import { useParams } from 'common' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useStorageExplorerStateSnapshot } from 'state/storage-explorer' import { URL_EXPIRY_DURATION } from '../Storage.constants' import { StorageItemWithColumn } from '../Storage.types' @@ -28,10 +28,7 @@ export const ItemContextMenu = ({ id = '' }: ItemContextMenuProps) => { } = useStorageExplorerStateSnapshot() const { onCopyUrl } = useCopyUrl() const isPublic = selectedBucket.public - const { can: canUpdateFiles } = useAsyncCheckProjectPermissions( - PermissionAction.STORAGE_WRITE, - '*' - ) + const { can: canUpdateFiles } = useAsyncCheckPermissions(PermissionAction.STORAGE_WRITE, '*') const onHandleClick = async (event: any, item: StorageItemWithColumn, expiresIn?: number) => { if (item.isCorrupted) return diff --git a/apps/studio/components/interfaces/Storage/StorageExplorer/PreviewPane.tsx b/apps/studio/components/interfaces/Storage/StorageExplorer/PreviewPane.tsx index 44adc6c0b305a..d4cdb53dab5ec 100644 --- a/apps/studio/components/interfaces/Storage/StorageExplorer/PreviewPane.tsx +++ b/apps/studio/components/interfaces/Storage/StorageExplorer/PreviewPane.tsx @@ -6,7 +6,7 @@ import SVG from 'react-inlinesvg' import { useParams } from 'common' import { ButtonTooltip } from 'components/ui/ButtonTooltip' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { BASE_PATH } from 'lib/constants' import { formatBytes } from 'lib/helpers' import { useStorageExplorerStateSnapshot } from 'state/storage-explorer' @@ -127,10 +127,7 @@ export const PreviewPane = () => { } = useStorageExplorerStateSnapshot() const { onCopyUrl } = useCopyUrl() - const { can: canUpdateFiles } = useAsyncCheckProjectPermissions( - PermissionAction.STORAGE_WRITE, - '*' - ) + const { can: canUpdateFiles } = useAsyncCheckPermissions(PermissionAction.STORAGE_WRITE, '*') if (!file) return null diff --git a/apps/studio/components/interfaces/Storage/StorageSettings/CreateCredentialModal.tsx b/apps/studio/components/interfaces/Storage/StorageSettings/CreateCredentialModal.tsx index cb5b6de2ab9b8..0cd7cbf7c6228 100644 --- a/apps/studio/components/interfaces/Storage/StorageSettings/CreateCredentialModal.tsx +++ b/apps/studio/components/interfaces/Storage/StorageSettings/CreateCredentialModal.tsx @@ -9,7 +9,7 @@ import { useParams } from 'common' import { useIsProjectActive } from 'components/layouts/ProjectLayout/ProjectContext' import { useProjectStorageConfigQuery } from 'data/config/project-storage-config-query' import { useS3AccessKeyCreateMutation } from 'data/storage/s3-access-key-create-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { Button, Dialog, @@ -39,7 +39,7 @@ export const CreateCredentialModal = ({ visible, onOpenChange }: CreateCredentia const isProjectActive = useIsProjectActive() const [showSuccess, setShowSuccess] = useState(false) - const { can: canCreateCredentials } = useAsyncCheckProjectPermissions( + const { can: canCreateCredentials } = useAsyncCheckPermissions( PermissionAction.STORAGE_ADMIN_WRITE, '*' ) diff --git a/apps/studio/components/interfaces/Storage/StorageSettings/S3Connection.tsx b/apps/studio/components/interfaces/Storage/StorageSettings/S3Connection.tsx index 0057b4e751d4b..a4301b64d4075 100644 --- a/apps/studio/components/interfaces/Storage/StorageSettings/S3Connection.tsx +++ b/apps/studio/components/interfaces/Storage/StorageSettings/S3Connection.tsx @@ -22,7 +22,7 @@ import { useProjectSettingsV2Query } from 'data/config/project-settings-v2-query import { useProjectStorageConfigQuery } from 'data/config/project-storage-config-query' import { useProjectStorageConfigUpdateUpdateMutation } from 'data/config/project-storage-config-update-mutation' import { useStorageCredentialsQuery } from 'data/storage/s3-access-key-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { AlertDescription_Shadcn_, @@ -54,9 +54,11 @@ export const S3Connection = () => { const [openDeleteDialog, setOpenDeleteDialog] = useState(false) const [deleteCred, setDeleteCred] = useState<{ id: string; description: string }>() - const { can: canReadS3Credentials, isLoading: isLoadingPermissions } = - useAsyncCheckProjectPermissions(PermissionAction.STORAGE_ADMIN_READ, '*') - const { can: canUpdateStorageSettings } = useAsyncCheckProjectPermissions( + const { can: canReadS3Credentials, isLoading: isLoadingPermissions } = useAsyncCheckPermissions( + PermissionAction.STORAGE_ADMIN_READ, + '*' + ) + const { can: canUpdateStorageSettings } = useAsyncCheckPermissions( PermissionAction.STORAGE_ADMIN_WRITE, '*' ) diff --git a/apps/studio/components/interfaces/Storage/StorageSettings/StorageCredItem.tsx b/apps/studio/components/interfaces/Storage/StorageSettings/StorageCredItem.tsx index 7eb0717b6ff70..216449b41685e 100644 --- a/apps/studio/components/interfaces/Storage/StorageSettings/StorageCredItem.tsx +++ b/apps/studio/components/interfaces/Storage/StorageSettings/StorageCredItem.tsx @@ -3,7 +3,7 @@ import { differenceInDays } from 'date-fns' import { MoreVertical, TrashIcon } from 'lucide-react' import CopyButton from 'components/ui/CopyButton' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { Button, DropdownMenu, @@ -25,7 +25,7 @@ export const StorageCredItem = ({ access_key: string onDeleteClick: (id: string) => void }) => { - const { can: canRemoveAccessKey } = useAsyncCheckProjectPermissions( + const { can: canRemoveAccessKey } = useAsyncCheckPermissions( PermissionAction.STORAGE_ADMIN_WRITE, '*' ) diff --git a/apps/studio/components/interfaces/Storage/StorageSettings/StorageSettings.tsx b/apps/studio/components/interfaces/Storage/StorageSettings/StorageSettings.tsx index 0a046eb0c9a5a..bd0cfb22d806b 100644 --- a/apps/studio/components/interfaces/Storage/StorageSettings/StorageSettings.tsx +++ b/apps/studio/components/interfaces/Storage/StorageSettings/StorageSettings.tsx @@ -16,7 +16,7 @@ import UpgradeToPro from 'components/ui/UpgradeToPro' import { useProjectStorageConfigQuery } from 'data/config/project-storage-config-query' import { useProjectStorageConfigUpdateUpdateMutation } from 'data/config/project-storage-config-update-mutation' import { useBucketsQuery } from 'data/storage/buckets-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { formatBytes } from 'lib/helpers' import { @@ -58,9 +58,11 @@ interface StorageSettingsState { export const StorageSettings = () => { const { ref: projectRef } = useParams() - const { can: canReadStorageSettings, isLoading: isLoadingPermissions } = - useAsyncCheckProjectPermissions(PermissionAction.STORAGE_ADMIN_READ, '*') - const { can: canUpdateStorageSettings } = useAsyncCheckProjectPermissions( + const { can: canReadStorageSettings, isLoading: isLoadingPermissions } = useAsyncCheckPermissions( + PermissionAction.STORAGE_ADMIN_READ, + '*' + ) + const { can: canUpdateStorageSettings } = useAsyncCheckPermissions( PermissionAction.STORAGE_ADMIN_WRITE, '*' ) diff --git a/apps/studio/components/interfaces/Storage/__tests__/CreateBucketModal.test.tsx b/apps/studio/components/interfaces/Storage/__tests__/CreateBucketModal.test.tsx index 36ed53271691e..e3b18f770da3c 100644 --- a/apps/studio/components/interfaces/Storage/__tests__/CreateBucketModal.test.tsx +++ b/apps/studio/components/interfaces/Storage/__tests__/CreateBucketModal.test.tsx @@ -13,7 +13,7 @@ describe(`CreateBucketModal`, () => { beforeEach(() => { vi.mock(`hooks/misc/useCheckPermissions`, () => ({ useCheckPermissions: vi.fn(), - useAsyncCheckProjectPermissions: vi.fn().mockImplementation(() => ({ can: true })), + useAsyncCheckPermissions: vi.fn().mockImplementation(() => ({ can: true })), })) // useParams routerMock.setCurrentUrl(`/project/default/storage/buckets`) diff --git a/apps/studio/components/interfaces/TableGridEditor/GridHeaderActions.tsx b/apps/studio/components/interfaces/TableGridEditor/GridHeaderActions.tsx index 0322cba739a24..2a11307f97c24 100644 --- a/apps/studio/components/interfaces/TableGridEditor/GridHeaderActions.tsx +++ b/apps/studio/components/interfaces/TableGridEditor/GridHeaderActions.tsx @@ -22,7 +22,7 @@ import { } from 'data/table-editor/table-editor-types' import { useTableUpdateMutation } from 'data/tables/table-update-mutation' import { useSendEventMutation } from 'data/telemetry/send-event-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' @@ -115,9 +115,11 @@ export const GridHeaderActions = ({ table, isRefetching }: GridHeaderActionsProp }, }) - const { can: canSqlWriteTables, isLoading: isLoadingPermissions } = - useAsyncCheckProjectPermissions(PermissionAction.TENANT_SQL_ADMIN_WRITE, 'tables') - const { can: canSqlWriteColumns } = useAsyncCheckProjectPermissions( + const { can: canSqlWriteTables, isLoading: isLoadingPermissions } = useAsyncCheckPermissions( + PermissionAction.TENANT_SQL_ADMIN_WRITE, + 'tables' + ) + const { can: canSqlWriteColumns } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_WRITE, 'columns' ) diff --git a/apps/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx b/apps/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx index 2cceac5f76d64..8294554566da0 100644 --- a/apps/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx +++ b/apps/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx @@ -14,7 +14,7 @@ import { isView, TableLike, } from 'data/table-editor/table-editor-types' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useDashboardHistory } from 'hooks/misc/useDashboardHistory' import { useUrlState } from 'hooks/ui/useUrlState' import { useIsProtectedSchema } from 'hooks/useProtectedSchemas' @@ -48,11 +48,11 @@ export const TableGridEditor = ({ const [{ view: selectedView = 'data' }] = useUrlState() - const { can: canEditTables } = useAsyncCheckProjectPermissions( + const { can: canEditTables } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_WRITE, 'tables' ) - const { can: canEditColumns } = useAsyncCheckProjectPermissions( + const { can: canEditColumns } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_WRITE, 'columns' ) diff --git a/apps/studio/components/layouts/AppLayout/EnableBranchingButton/BranchingPITRNotice.tsx b/apps/studio/components/layouts/AppLayout/EnableBranchingButton/BranchingPITRNotice.tsx index de2a75a3580aa..f101320651af6 100644 --- a/apps/studio/components/layouts/AppLayout/EnableBranchingButton/BranchingPITRNotice.tsx +++ b/apps/studio/components/layouts/AppLayout/EnableBranchingButton/BranchingPITRNotice.tsx @@ -4,7 +4,7 @@ import Link from 'next/link' import { useParams } from 'common' import { ButtonTooltip } from 'components/ui/ButtonTooltip' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useAppStateSnapshot } from 'state/app-state' import { Button } from 'ui' @@ -12,7 +12,7 @@ export const BranchingPITRNotice = () => { const { ref } = useParams() const snap = useAppStateSnapshot() - const { can: canUpdateSubscription } = useAsyncCheckProjectPermissions( + const { can: canUpdateSubscription } = useAsyncCheckPermissions( PermissionAction.BILLING_WRITE, 'stripe.subscriptions' ) diff --git a/apps/studio/components/layouts/EdgeFunctionsLayout/EdgeFunctionDetailsLayout.tsx b/apps/studio/components/layouts/EdgeFunctionsLayout/EdgeFunctionDetailsLayout.tsx index ef94be5b6d26e..76b488fc84587 100644 --- a/apps/studio/components/layouts/EdgeFunctionsLayout/EdgeFunctionDetailsLayout.tsx +++ b/apps/studio/components/layouts/EdgeFunctionsLayout/EdgeFunctionDetailsLayout.tsx @@ -15,7 +15,7 @@ import NoPermission from 'components/ui/NoPermission' import { useEdgeFunctionBodyQuery } from 'data/edge-functions/edge-function-body-query' import { useEdgeFunctionQuery } from 'data/edge-functions/edge-function-query' import { useSendEventMutation } from 'data/telemetry/send-event-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { withAuth } from 'hooks/misc/withAuth' import { @@ -43,7 +43,7 @@ const EdgeFunctionDetailsLayout = ({ const { mutate: sendEvent } = useSendEventMutation() const isNewAPIDocsEnabled = useIsAPIDocsSidePanelEnabled() - const { isLoading, can: canReadFunctions } = useAsyncCheckProjectPermissions( + const { isLoading, can: canReadFunctions } = useAsyncCheckPermissions( PermissionAction.FUNCTIONS_READ, '*' ) diff --git a/apps/studio/components/layouts/LogsLayout/LogsLayout.tsx b/apps/studio/components/layouts/LogsLayout/LogsLayout.tsx index 30c4ae8bbf4d9..9965ed65b2a98 100644 --- a/apps/studio/components/layouts/LogsLayout/LogsLayout.tsx +++ b/apps/studio/components/layouts/LogsLayout/LogsLayout.tsx @@ -3,7 +3,7 @@ import { PermissionAction } from '@supabase/shared-types/out/constants' import { PropsWithChildren } from 'react' import NoPermission from 'components/ui/NoPermission' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { withAuth } from 'hooks/misc/withAuth' import ProjectLayout from '../ProjectLayout/ProjectLayout' import { LogsSidebarMenuV2 } from './LogsSidebarMenuV2' @@ -13,7 +13,7 @@ interface LogsLayoutProps { } const LogsLayout = ({ title, children }: PropsWithChildren) => { - const { isLoading, can: canUseLogsExplorer } = useAsyncCheckProjectPermissions( + const { isLoading, can: canUseLogsExplorer } = useAsyncCheckPermissions( PermissionAction.ANALYTICS_READ, 'logflare' ) diff --git a/apps/studio/components/layouts/ProjectLayout/PauseFailedState.tsx b/apps/studio/components/layouts/ProjectLayout/PauseFailedState.tsx index d82d07658b797..f0141fa27639b 100644 --- a/apps/studio/components/layouts/ProjectLayout/PauseFailedState.tsx +++ b/apps/studio/components/layouts/ProjectLayout/PauseFailedState.tsx @@ -10,7 +10,7 @@ import { DropdownMenuItemTooltip } from 'components/ui/DropdownMenuItemTooltip' import { InlineLink } from 'components/ui/InlineLink' import { useBackupDownloadMutation } from 'data/database/backup-download-mutation' import { useDownloadableBackupQuery } from 'data/database/backup-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { Button, CriticalIcon, DropdownMenu, DropdownMenuContent, DropdownMenuTrigger } from 'ui' @@ -19,13 +19,9 @@ export const PauseFailedState = () => { const { data: project } = useSelectedProjectQuery() const [visible, setVisible] = useState(false) - const { can: canDeleteProject } = useAsyncCheckProjectPermissions( - PermissionAction.UPDATE, - 'projects', - { - resource: { project_id: project?.id }, - } - ) + const { can: canDeleteProject } = useAsyncCheckPermissions(PermissionAction.UPDATE, 'projects', { + resource: { project_id: project?.id }, + }) const { data } = useDownloadableBackupQuery({ projectRef: ref }) const backups = data?.backups ?? [] diff --git a/apps/studio/components/layouts/ProjectLayout/PausedState/ProjectPausedState.tsx b/apps/studio/components/layouts/ProjectLayout/PausedState/ProjectPausedState.tsx index 353d948b00b1c..508f1a0b00276 100644 --- a/apps/studio/components/layouts/ProjectLayout/PausedState/ProjectPausedState.tsx +++ b/apps/studio/components/layouts/ProjectLayout/PausedState/ProjectPausedState.tsx @@ -18,7 +18,7 @@ import { PostgresEngine, ReleaseChannel } from 'data/projects/new-project.consta import { useProjectPauseStatusQuery } from 'data/projects/project-pause-status-query' import { useProjectRestoreMutation } from 'data/projects/project-restore-mutation' import { setProjectStatus } from 'data/projects/projects-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { usePHFlag } from 'hooks/ui/useFlag' @@ -94,7 +94,7 @@ export const ProjectPausedState = ({ product }: ProjectPausedStateProps) => { }, }) - const { can: canResumeProject } = useAsyncCheckProjectPermissions( + const { can: canResumeProject } = useAsyncCheckPermissions( PermissionAction.INFRA_EXECUTE, 'queue_jobs.projects.initialize_or_resume' ) diff --git a/apps/studio/components/layouts/ProjectLayout/RestoreFailedState.tsx b/apps/studio/components/layouts/ProjectLayout/RestoreFailedState.tsx index edb62abd66c45..401a91b6e8421 100644 --- a/apps/studio/components/layouts/ProjectLayout/RestoreFailedState.tsx +++ b/apps/studio/components/layouts/ProjectLayout/RestoreFailedState.tsx @@ -10,7 +10,7 @@ import { DropdownMenuItemTooltip } from 'components/ui/DropdownMenuItemTooltip' import { InlineLink } from 'components/ui/InlineLink' import { useBackupDownloadMutation } from 'data/database/backup-download-mutation' import { useDownloadableBackupQuery } from 'data/database/backup-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { Button, CriticalIcon, DropdownMenu, DropdownMenuContent, DropdownMenuTrigger } from 'ui' @@ -19,11 +19,9 @@ export const RestoreFailedState = () => { const { data: project } = useSelectedProjectQuery() const [visible, setVisible] = useState(false) - const { can: canDeleteProject } = useAsyncCheckProjectPermissions( - PermissionAction.UPDATE, - 'projects', - { resource: { project_id: project?.id } } - ) + const { can: canDeleteProject } = useAsyncCheckPermissions(PermissionAction.UPDATE, 'projects', { + resource: { project_id: project?.id }, + }) const { data } = useDownloadableBackupQuery({ projectRef: ref }) const backups = data?.backups ?? [] diff --git a/apps/studio/components/layouts/ReportsLayout/ReportMenuItem.tsx b/apps/studio/components/layouts/ReportsLayout/ReportMenuItem.tsx index 3ccba9049a7c3..781a4080ba2f3 100644 --- a/apps/studio/components/layouts/ReportsLayout/ReportMenuItem.tsx +++ b/apps/studio/components/layouts/ReportsLayout/ReportMenuItem.tsx @@ -3,7 +3,7 @@ import { ChevronDown, Edit2, Trash } from 'lucide-react' import Link from 'next/link' import { ContentBase } from 'data/content/content-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useProfile } from 'lib/profile' import { Dashboards } from 'types' import { @@ -41,7 +41,7 @@ export const ReportMenuItem = ({ onSelectDelete, }: ReportMenuItemProps) => { const { profile } = useProfile() - const { can: canUpdateCustomReport } = useAsyncCheckProjectPermissions( + const { can: canUpdateCustomReport } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'user_content', { diff --git a/apps/studio/components/layouts/ReportsLayout/ReportsMenu.tsx b/apps/studio/components/layouts/ReportsLayout/ReportsMenu.tsx index a0e1a4f5d4abc..bdcbc96054ff8 100644 --- a/apps/studio/components/layouts/ReportsLayout/ReportsMenu.tsx +++ b/apps/studio/components/layouts/ReportsLayout/ReportsMenu.tsx @@ -12,7 +12,7 @@ import { ButtonTooltip } from 'components/ui/ButtonTooltip' import ShimmeringLoader from 'components/ui/ShimmeringLoader' import { useContentDeleteMutation } from 'data/content/content-delete-mutation' import { Content, useContentQuery } from 'data/content/content-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled' import { useProfile } from 'lib/profile' import { Menu, cn } from 'ui' @@ -34,7 +34,7 @@ const ReportsMenu = () => { const storageSupported = useIsFeatureEnabled('project_storage:all') const storageEnabled = storageReportEnabled && storageSupported - const { can: canCreateCustomReport } = useAsyncCheckProjectPermissions( + const { can: canCreateCustomReport } = useAsyncCheckPermissions( PermissionAction.CREATE, 'user_content', { diff --git a/apps/studio/components/layouts/SQLEditorLayout/SQLEditorMenu.tsx b/apps/studio/components/layouts/SQLEditorLayout/SQLEditorMenu.tsx index bbc045e308314..a6af02d7eef3d 100644 --- a/apps/studio/components/layouts/SQLEditorLayout/SQLEditorMenu.tsx +++ b/apps/studio/components/layouts/SQLEditorLayout/SQLEditorMenu.tsx @@ -6,7 +6,7 @@ import { useRouter } from 'next/router' import { useEffect, useState } from 'react' import { toast } from 'sonner' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useLocalStorage } from 'hooks/misc/useLocalStorage' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { useProfile } from 'lib/profile' @@ -48,7 +48,7 @@ export const SQLEditorMenu = () => { const appState = getAppStateSnapshot() const debouncedSearch = useDebounce(search, 500) - const { can: canCreateSQLSnippet } = useAsyncCheckProjectPermissions( + const { can: canCreateSQLSnippet } = useAsyncCheckPermissions( PermissionAction.CREATE, 'user_content', { diff --git a/apps/studio/components/layouts/SQLEditorLayout/SQLEditorNavV2/SQLEditorTreeViewItem.tsx b/apps/studio/components/layouts/SQLEditorLayout/SQLEditorNavV2/SQLEditorTreeViewItem.tsx index 4dd78e8b07cbd..e22c2d522138b 100644 --- a/apps/studio/components/layouts/SQLEditorLayout/SQLEditorNavV2/SQLEditorTreeViewItem.tsx +++ b/apps/studio/components/layouts/SQLEditorLayout/SQLEditorNavV2/SQLEditorTreeViewItem.tsx @@ -21,7 +21,7 @@ import { createSqlSnippetSkeletonV2 } from 'components/interfaces/SQLEditor/SQLE import { getContentById } from 'data/content/content-id-query' import { useSQLSnippetFolderContentsQuery } from 'data/content/sql-folder-contents-query' import { Snippet } from 'data/content/sql-folders-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import useLatest from 'hooks/misc/useLatest' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { useProfile } from 'lib/profile' @@ -106,7 +106,7 @@ export const SQLEditorTreeViewItem = ({ const isEditing = status === 'editing' const isSaving = status === 'saving' - const { can: canCreateSQLSnippet } = useAsyncCheckProjectPermissions( + const { can: canCreateSQLSnippet } = useAsyncCheckPermissions( PermissionAction.CREATE, 'user_content', { diff --git a/apps/studio/components/layouts/SQLEditorLayout/SqlEditor.Commands.tsx b/apps/studio/components/layouts/SQLEditorLayout/SqlEditor.Commands.tsx index dc7be6eb36363..0f975237051c7 100644 --- a/apps/studio/components/layouts/SQLEditorLayout/SqlEditor.Commands.tsx +++ b/apps/studio/components/layouts/SQLEditorLayout/SqlEditor.Commands.tsx @@ -9,7 +9,7 @@ import { COMMAND_MENU_SECTIONS } from 'components/interfaces/App/CommandMenu/Com import { orderCommandSectionsByPriority } from 'components/interfaces/App/CommandMenu/ordering' import { useSqlSnippetsQuery, type SqlSnippet } from 'data/content/sql-snippets-query' import { usePrefetchTables, useTablesQuery, type TablesData } from 'data/tables/tables-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { useProtectedSchemas } from 'hooks/useProtectedSchemas' import { useProfile } from 'lib/profile' @@ -103,7 +103,7 @@ function RunSnippetPage() { const snippets = snippetPages?.pages.flatMap((page) => page.contents) const { profile } = useProfile() - const { can: canCreateSQLSnippet } = useAsyncCheckProjectPermissions( + const { can: canCreateSQLSnippet } = useAsyncCheckPermissions( PermissionAction.CREATE, 'user_content', { diff --git a/apps/studio/components/layouts/TableEditorLayout/TableEditorLayout.tsx b/apps/studio/components/layouts/TableEditorLayout/TableEditorLayout.tsx index 2727eb420285f..e7615f9f4b981 100644 --- a/apps/studio/components/layouts/TableEditorLayout/TableEditorLayout.tsx +++ b/apps/studio/components/layouts/TableEditorLayout/TableEditorLayout.tsx @@ -2,11 +2,11 @@ import { PermissionAction } from '@supabase/shared-types/out/constants' import { PropsWithChildren } from 'react' import NoPermission from 'components/ui/NoPermission' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { ProjectLayoutWithAuth } from '../ProjectLayout/ProjectLayout' const TableEditorLayout = ({ children }: PropsWithChildren<{}>) => { - const { can: canReadTables, isSuccess: isPermissionsLoaded } = useAsyncCheckProjectPermissions( + const { can: canReadTables, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_READ, 'tables' ) diff --git a/apps/studio/components/layouts/TableEditorLayout/TableEditorMenu.tsx b/apps/studio/components/layouts/TableEditorLayout/TableEditorMenu.tsx index 929db988b7c5f..59d87733ade01 100644 --- a/apps/studio/components/layouts/TableEditorLayout/TableEditorMenu.tsx +++ b/apps/studio/components/layouts/TableEditorLayout/TableEditorMenu.tsx @@ -16,7 +16,7 @@ import SchemaSelector from 'components/ui/SchemaSelector' import { ENTITY_TYPE } from 'data/entity-types/entity-type-constants' import { useEntityTypesQuery } from 'data/entity-types/entity-types-infinite-query' import { getTableEditor, useTableEditorQuery } from 'data/table-editor/table-editor-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useLocalStorage } from 'hooks/misc/useLocalStorage' import { useQuerySchemaState } from 'hooks/misc/useSchemaQueryState' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' @@ -85,7 +85,7 @@ export const TableEditorMenu = () => { [data?.pages] ) - const { can: canCreateTables } = useAsyncCheckProjectPermissions( + const { can: canCreateTables } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_WRITE, 'tables' ) diff --git a/apps/studio/components/layouts/Tabs/NewTab.tsx b/apps/studio/components/layouts/Tabs/NewTab.tsx index 182b85e96645b..c982690727667 100644 --- a/apps/studio/components/layouts/Tabs/NewTab.tsx +++ b/apps/studio/components/layouts/Tabs/NewTab.tsx @@ -9,7 +9,7 @@ import { useParams } from 'common' import { SQL_TEMPLATES } from 'components/interfaces/SQLEditor/SQLEditor.queries' import { createSqlSnippetSkeletonV2 } from 'components/interfaces/SQLEditor/SQLEditor.utils' import { useSendEventMutation } from 'data/telemetry/send-event-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { uuidv4 } from 'lib/helpers' @@ -46,7 +46,7 @@ export function NewTab() { const [quickstarts] = partition(SQL_TEMPLATES, { type: 'quickstart' }) const { mutate: sendEvent } = useSendEventMutation() - const { can: canCreateSQLSnippet } = useAsyncCheckProjectPermissions( + const { can: canCreateSQLSnippet } = useAsyncCheckPermissions( PermissionAction.CREATE, 'user_content', { diff --git a/apps/studio/components/ui/AIAssistantPanel/AIOptInModal.tsx b/apps/studio/components/ui/AIAssistantPanel/AIOptInModal.tsx index 919b847f50b26..70f7a91360222 100644 --- a/apps/studio/components/ui/AIAssistantPanel/AIOptInModal.tsx +++ b/apps/studio/components/ui/AIAssistantPanel/AIOptInModal.tsx @@ -3,7 +3,7 @@ import { useEffect } from 'react' import { AIOptInLevelSelector } from 'components/interfaces/Organization/GeneralSettings/AIOptInLevelSelector' import { useAIOptInForm } from 'hooks/forms/useAIOptInForm' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { Button, cn, @@ -24,7 +24,7 @@ interface AIOptInModalProps { export const AIOptInModal = ({ visible, onCancel }: AIOptInModalProps) => { const { form, onSubmit, isUpdating, currentOptInLevel } = useAIOptInForm(onCancel) - const { can: canUpdateOrganization } = useAsyncCheckProjectPermissions( + const { can: canUpdateOrganization } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'organizations' ) diff --git a/apps/studio/components/ui/AIAssistantPanel/DisplayBlockRenderer.tsx b/apps/studio/components/ui/AIAssistantPanel/DisplayBlockRenderer.tsx index deb418a749ecf..a36502f0bfa38 100644 --- a/apps/studio/components/ui/AIAssistantPanel/DisplayBlockRenderer.tsx +++ b/apps/studio/components/ui/AIAssistantPanel/DisplayBlockRenderer.tsx @@ -6,7 +6,7 @@ import { DragEvent, PropsWithChildren, useMemo, useState } from 'react' import { useParams } from 'common' import { ChartConfig } from 'components/interfaces/SQLEditor/UtilityPanel/ChartConfig' import { useSendEventMutation } from 'data/telemetry/send-event-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { useProfile } from 'lib/profile' import { useAiAssistantStateSnapshot } from 'state/ai-assistant-state' @@ -48,7 +48,7 @@ export const DisplayBlockRenderer = ({ const snap = useAiAssistantStateSnapshot() const { mutate: sendEvent } = useSendEventMutation() - const { can: canCreateSQLSnippet } = useAsyncCheckProjectPermissions( + const { can: canCreateSQLSnippet } = useAsyncCheckPermissions( PermissionAction.CREATE, 'user_content', { diff --git a/apps/studio/components/ui/AIAssistantPanel/MessageMarkdown.tsx b/apps/studio/components/ui/AIAssistantPanel/MessageMarkdown.tsx index f3acd11c622a2..7764136b47f3e 100644 --- a/apps/studio/components/ui/AIAssistantPanel/MessageMarkdown.tsx +++ b/apps/studio/components/ui/AIAssistantPanel/MessageMarkdown.tsx @@ -13,7 +13,7 @@ import { import { ChartConfig } from 'components/interfaces/SQLEditor/UtilityPanel/ChartConfig' import { useSendEventMutation } from 'data/telemetry/send-event-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { useProfile } from 'lib/profile' @@ -232,7 +232,7 @@ export const MarkdownPre = ({ const { data: project } = useSelectedProjectQuery() const { data: org } = useSelectedOrganizationQuery() - const { can: canCreateSQLSnippet } = useAsyncCheckProjectPermissions( + const { can: canCreateSQLSnippet } = useAsyncCheckPermissions( PermissionAction.CREATE, 'user_content', { diff --git a/apps/studio/components/ui/ProjectSettings/DisplayApiSettings.tsx b/apps/studio/components/ui/ProjectSettings/DisplayApiSettings.tsx index 0ef28a3426f79..80277032385cb 100644 --- a/apps/studio/components/ui/ProjectSettings/DisplayApiSettings.tsx +++ b/apps/studio/components/ui/ProjectSettings/DisplayApiSettings.tsx @@ -9,7 +9,7 @@ import { useParams } from 'common' import Panel from 'components/ui/Panel' import { useJwtSecretUpdatingStatusQuery } from 'data/config/jwt-secret-updating-status-query' import { useProjectSettingsV2Query } from 'data/config/project-settings-v2-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { Input } from 'ui' import { getLastUsedAPIKeys, useLastUsedAPIKeysLogQuery } from './DisplayApiSettings.utils' @@ -36,7 +36,7 @@ export const DisplayApiSettings = ({ } = useJwtSecretUpdatingStatusQuery({ projectRef }) const jwtSecretUpdateStatus = data?.jwtSecretUpdateStatus - const { isLoading: isLoadingPermissions, can: canReadAPIKeys } = useAsyncCheckProjectPermissions( + const { isLoading: isLoadingPermissions, can: canReadAPIKeys } = useAsyncCheckPermissions( PermissionAction.READ, 'service_api_keys' ) diff --git a/apps/studio/components/ui/ProjectSettings/ToggleLegacyApiKeys.tsx b/apps/studio/components/ui/ProjectSettings/ToggleLegacyApiKeys.tsx index 19b67e34cc173..8998ab5c14591 100644 --- a/apps/studio/components/ui/ProjectSettings/ToggleLegacyApiKeys.tsx +++ b/apps/studio/components/ui/ProjectSettings/ToggleLegacyApiKeys.tsx @@ -8,7 +8,7 @@ import { useToggleLegacyAPIKeysMutation } from 'data/api-keys/legacy-api-key-tog import { useLegacyAPIKeysStatusQuery } from 'data/api-keys/legacy-api-keys-status-query' import { useLegacyJWTSigningKeyQuery } from 'data/jwt-signing-keys/legacy-jwt-signing-key-query' import { useAuthorizedAppsQuery } from 'data/oauth/authorized-apps-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { AlertDialog, @@ -35,8 +35,10 @@ export const ToggleLegacyApiKeysPanel = () => { const { data: legacyJWTSecret } = useLegacyJWTSigningKeyQuery({ projectRef }) - const { can: canUpdateAPIKeys, isSuccess: isPermissionsSuccess } = - useAsyncCheckProjectPermissions(PermissionAction.SECRETS_WRITE, '*') + const { can: canUpdateAPIKeys, isSuccess: isPermissionsSuccess } = useAsyncCheckPermissions( + PermissionAction.SECRETS_WRITE, + '*' + ) const { data: authorizedApps = [], isSuccess: isAuthorizedAppsSuccess } = useAuthorizedAppsQuery({ slug: org?.slug, diff --git a/apps/studio/components/ui/SchemaSelector.tsx b/apps/studio/components/ui/SchemaSelector.tsx index 72669f80ffedc..e3f89590ff23d 100644 --- a/apps/studio/components/ui/SchemaSelector.tsx +++ b/apps/studio/components/ui/SchemaSelector.tsx @@ -3,7 +3,7 @@ import { Check, ChevronsUpDown, Plus } from 'lucide-react' import { useState } from 'react' import { useSchemasQuery } from 'data/database/schemas-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { AlertDescription_Shadcn_, @@ -52,7 +52,7 @@ const SchemaSelector = ({ align = 'start', }: SchemaSelectorProps) => { const [open, setOpen] = useState(false) - const { can: canCreateSchemas } = useAsyncCheckProjectPermissions( + const { can: canCreateSchemas } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_WRITE, 'schemas' ) diff --git a/apps/studio/components/ui/UpgradeToPro.tsx b/apps/studio/components/ui/UpgradeToPro.tsx index 8e4b2a9d96622..7cf9aa395238a 100644 --- a/apps/studio/components/ui/UpgradeToPro.tsx +++ b/apps/studio/components/ui/UpgradeToPro.tsx @@ -3,7 +3,7 @@ import Link from 'next/link' import { ReactNode } from 'react' import { useFlag } from 'common' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { Button, cn } from 'ui' @@ -34,7 +34,7 @@ const UpgradeToPro = ({ const { data: organization } = useSelectedOrganizationQuery() const plan = organization?.plan?.id - const { can: canUpdateSubscription } = useAsyncCheckProjectPermissions( + const { can: canUpdateSubscription } = useAsyncCheckPermissions( PermissionAction.BILLING_WRITE, 'stripe.subscriptions' ) diff --git a/apps/studio/data/config/project-settings-v2-query.ts b/apps/studio/data/config/project-settings-v2-query.ts index 1bba0b1806a43..759c0a784c732 100644 --- a/apps/studio/data/config/project-settings-v2-query.ts +++ b/apps/studio/data/config/project-settings-v2-query.ts @@ -3,7 +3,7 @@ import { useQuery, UseQueryOptions } from '@tanstack/react-query' import type { components } from 'data/api' import { get, handleError } from 'data/fetchers' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import type { ResponseError } from 'types' import { configKeys } from './keys' @@ -44,7 +44,7 @@ export const useProjectSettingsV2Query = ( ) => { // [Joshen] Sync with API perms checking here - shouldReturnApiKeys // https://github.com/supabase/infrastructure/blob/develop/api/src/routes/platform/projects/ref/settings.controller.ts#L92 - const { can: canReadAPIKeys } = useAsyncCheckProjectPermissions( + const { can: canReadAPIKeys } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_WRITE, '*' ) diff --git a/apps/studio/data/organizations/organization-customer-profile-query.ts b/apps/studio/data/organizations/organization-customer-profile-query.ts index b95c9a7a15efe..7fe953a0a17e2 100644 --- a/apps/studio/data/organizations/organization-customer-profile-query.ts +++ b/apps/studio/data/organizations/organization-customer-profile-query.ts @@ -2,7 +2,7 @@ import { PermissionAction } from '@supabase/shared-types/out/constants' import { useQuery, UseQueryOptions } from '@tanstack/react-query' import { get, handleError } from 'data/fetchers' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import type { ResponseError } from 'types' import { organizationKeys } from './keys' @@ -43,7 +43,7 @@ export const useOrganizationCustomerProfileQuery = { // [Joshen] Thinking it makes sense to add this check at the RQ level - prevent // unnecessary requests, although this behaviour still needs handling on the UI - const { can: canReadCustomerProfile } = useAsyncCheckProjectPermissions( + const { can: canReadCustomerProfile } = useAsyncCheckPermissions( PermissionAction.BILLING_READ, 'stripe.customer' ) diff --git a/apps/studio/data/organizations/organization-payment-methods-query.ts b/apps/studio/data/organizations/organization-payment-methods-query.ts index 800fd895f0f25..cc22ddd36c5b7 100644 --- a/apps/studio/data/organizations/organization-payment-methods-query.ts +++ b/apps/studio/data/organizations/organization-payment-methods-query.ts @@ -3,7 +3,7 @@ import { useQuery, UseQueryOptions } from '@tanstack/react-query' import { components } from 'api-types' import { get, handleError } from 'data/fetchers' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import type { ResponseError } from 'types' import { organizationKeys } from './keys' @@ -44,7 +44,7 @@ export const useOrganizationPaymentMethodsQuery = = {} ) => { - const { can: canReadSubscriptions } = useAsyncCheckProjectPermissions( + const { can: canReadSubscriptions } = useAsyncCheckPermissions( PermissionAction.BILLING_READ, 'stripe.payment_methods' ) diff --git a/apps/studio/data/organizations/organization-tax-id-query.ts b/apps/studio/data/organizations/organization-tax-id-query.ts index 06e7ca658964a..ede1efe0c2f0c 100644 --- a/apps/studio/data/organizations/organization-tax-id-query.ts +++ b/apps/studio/data/organizations/organization-tax-id-query.ts @@ -3,7 +3,7 @@ import { useQuery, UseQueryOptions } from '@tanstack/react-query' import { components } from 'api-types' import { get, handleError } from 'data/fetchers' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import type { ResponseError } from 'types' import { organizationKeys } from './keys' @@ -36,7 +36,7 @@ export const useOrganizationTaxIdQuery = ( ...options }: UseQueryOptions = {} ) => { - const { can: canReadSubscriptions } = useAsyncCheckProjectPermissions( + const { can: canReadSubscriptions } = useAsyncCheckPermissions( PermissionAction.BILLING_READ, 'stripe.tax_ids' ) diff --git a/apps/studio/data/storage/iceberg-wrapper-create-mutation.ts b/apps/studio/data/storage/iceberg-wrapper-create-mutation.ts index ed59e90e08c85..56752fd634651 100644 --- a/apps/studio/data/storage/iceberg-wrapper-create-mutation.ts +++ b/apps/studio/data/storage/iceberg-wrapper-create-mutation.ts @@ -9,7 +9,7 @@ import { import { getKeys, useAPIKeysQuery } from 'data/api-keys/api-keys-query' import { useProjectSettingsV2Query } from 'data/config/project-settings-v2-query' import { FDWCreateVariables, useFDWCreateMutation } from 'data/fdw/fdw-create-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { useS3AccessKeyCreateMutation } from './s3-access-key-create-mutation' @@ -27,7 +27,7 @@ export const useIcebergWrapperCreateMutation = () => { const wrapperMeta = WRAPPERS.find((wrapper) => wrapper.name === 'iceberg_wrapper') - const { can: canCreateCredentials } = useAsyncCheckProjectPermissions( + const { can: canCreateCredentials } = useAsyncCheckPermissions( PermissionAction.STORAGE_ADMIN_WRITE, '*' ) diff --git a/apps/studio/data/subscriptions/org-plans-query.ts b/apps/studio/data/subscriptions/org-plans-query.ts index a79e76e95272c..ab1a68ee525f9 100644 --- a/apps/studio/data/subscriptions/org-plans-query.ts +++ b/apps/studio/data/subscriptions/org-plans-query.ts @@ -2,7 +2,7 @@ import { PermissionAction } from '@supabase/shared-types/out/constants' import { useQuery, UseQueryOptions } from '@tanstack/react-query' import { get, handleError } from 'data/fetchers' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { subscriptionKeys } from './keys' export type OrgPlansVariables = { @@ -27,7 +27,7 @@ export const useOrgPlansQuery = ( { orgSlug }: OrgPlansVariables, { enabled = true, ...options }: UseQueryOptions = {} ) => { - const { can: canReadSubscriptions } = useAsyncCheckProjectPermissions( + const { can: canReadSubscriptions } = useAsyncCheckPermissions( PermissionAction.BILLING_READ, 'stripe.subscriptions' ) diff --git a/apps/studio/data/subscriptions/org-subscription-query.ts b/apps/studio/data/subscriptions/org-subscription-query.ts index a91e6f29e7fe0..c2d068bbbec9d 100644 --- a/apps/studio/data/subscriptions/org-subscription-query.ts +++ b/apps/studio/data/subscriptions/org-subscription-query.ts @@ -2,7 +2,7 @@ import { PermissionAction } from '@supabase/shared-types/out/constants' import { useQuery, UseQueryOptions } from '@tanstack/react-query' import { get, handleError } from 'data/fetchers' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import type { ResponseError } from 'types' import { subscriptionKeys } from './keys' @@ -37,7 +37,7 @@ export const useOrgSubscriptionQuery = ( ) => { // [Joshen] Thinking it makes sense to add this check at the RQ level - prevent // unnecessary requests, although this behaviour still needs handling on the UI - const { can: canReadSubscriptions } = useAsyncCheckProjectPermissions( + const { can: canReadSubscriptions } = useAsyncCheckPermissions( PermissionAction.BILLING_READ, 'stripe.subscriptions' ) diff --git a/apps/studio/hooks/forms/useAIOptInForm.ts b/apps/studio/hooks/forms/useAIOptInForm.ts index 9a85468fb1777..10f94b86252e1 100644 --- a/apps/studio/hooks/forms/useAIOptInForm.ts +++ b/apps/studio/hooks/forms/useAIOptInForm.ts @@ -8,7 +8,7 @@ import * as z from 'zod' import { LOCAL_STORAGE_KEYS } from 'common' import { useOrganizationUpdateMutation } from 'data/organizations/organization-update-mutation' import { invalidateOrganizationsQuery } from 'data/organizations/organizations-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage' import { getAiOptInLevel } from 'hooks/misc/useOrgOptedIntoAi' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' @@ -31,7 +31,7 @@ export type AIOptInFormValues = z.infer export const useAIOptInForm = (onSuccessCallback?: () => void) => { const queryClient = useQueryClient() const { data: selectedOrganization } = useSelectedOrganizationQuery() - const { can: canUpdateOrganization } = useAsyncCheckProjectPermissions( + const { can: canUpdateOrganization } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'organizations' ) diff --git a/apps/studio/hooks/misc/useCheckPermissions.ts b/apps/studio/hooks/misc/useCheckPermissions.ts index 15437b5f3c980..8b2106c3d58d6 100644 --- a/apps/studio/hooks/misc/useCheckPermissions.ts +++ b/apps/studio/hooks/misc/useCheckPermissions.ts @@ -1,9 +1,7 @@ import { useIsLoggedIn, useParams } from 'common' import jsonLogic from 'json-logic-js' -import { useOrganizationsQuery } from 'data/organizations/organizations-query' import { usePermissionsQuery } from 'data/permissions/permissions-query' -import { useProjectDetailQuery } from 'data/projects/project-detail-query' import { IS_PLATFORM } from 'lib/constants' import type { Permission } from 'types' import { useSelectedOrganizationQuery } from './useSelectedOrganization' @@ -74,7 +72,7 @@ export function useGetPermissions( return useGetProjectPermissions(permissionsOverride, organizationSlugOverride, undefined, enabled) } -export function useGetProjectPermissions( +function useGetProjectPermissions( permissionsOverride?: Permission[], organizationSlugOverride?: string, projectRefOverride?: string, @@ -135,78 +133,9 @@ export function useGetProjectPermissions( } } -/** - * @deprecated If checking for project permissions, use useAsyncCheckProjectPermissions instead so that we can always - * check for loading states to not prematurely show "no perms" UIs. We'll also need a separate async check for org perms too - * - * Use `import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions'` instead - * [Joshen] No longer being used, can be deprecated in follow up PR - */ -export function useCheckPermissions( - action: string, - resource: string, - data?: object, - // [Joshen] Pass the variables if you want to avoid hooks in this - // e.g If you want to use useCheckPermissions in a loop like organization settings - organizationSlug?: string, - permissions?: Permission[] -) { - return useCheckProjectPermissions(action, resource, data, { - organizationSlug, - projectRef: undefined, - permissions, - }) -} - -export function useCheckProjectPermissions( - action: string, - resource: string, - data?: object, - overrides?: { - organizationSlug?: string - projectRef?: string - permissions?: Permission[] - } -) { - const isLoggedIn = useIsLoggedIn() - const { organizationSlug, projectRef, permissions } = overrides ?? {} - - const { - permissions: allPermissions, - organizationSlug: _organizationSlug, - projectRef: _projectRef, - } = useGetProjectPermissions(permissions, organizationSlug, projectRef, isLoggedIn) - - if (!isLoggedIn) return false - if (!IS_PLATFORM) return true - - return doPermissionsCheck(allPermissions, action, resource, data, _organizationSlug, _projectRef) -} - -/** [Joshen] No longer being used, can be deprecated in follow up PR */ -export function usePermissionsLoaded() { - const isLoggedIn = useIsLoggedIn() - const { isFetched: isPermissionsFetched } = usePermissionsQuery({ enabled: isLoggedIn }) - const { isFetched: isOrganizationsFetched } = useOrganizationsQuery({ enabled: isLoggedIn }) - - const { ref } = useParams() - const { isFetched: isProjectDetailFetched } = useProjectDetailQuery( - { ref }, - { enabled: !!ref && isLoggedIn } - ) - - if (!IS_PLATFORM) return true - - if (ref) { - return isLoggedIn && isPermissionsFetched && isOrganizationsFetched && isProjectDetailFetched - } - - return isLoggedIn && isPermissionsFetched && isOrganizationsFetched -} - /** [Joshen] To be renamed to be useAsyncCheckPermissions, more generic as it covers both org and project perms */ // Useful when you want to avoid layout changes while waiting for permissions to load -export function useAsyncCheckProjectPermissions( +export function useAsyncCheckPermissions( action: string, resource: string, data?: object, diff --git a/apps/studio/pages/new/[slug].tsx b/apps/studio/pages/new/[slug].tsx index beaa6dacab5d7..c1c01b8478371 100644 --- a/apps/studio/pages/new/[slug].tsx +++ b/apps/studio/pages/new/[slug].tsx @@ -49,7 +49,7 @@ import { import { useProjectsQuery } from 'data/projects/projects-query' import { useSendEventMutation } from 'data/telemetry/send-event-mutation' import { useCustomContent } from 'hooks/custom-content/useCustomContent' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled' import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' @@ -260,7 +260,7 @@ const Wizard: NextPageWithLayout = () => { ? availableRegionsData?.recommendations.smartGroup.name : _defaultRegion - const { can: isAdmin } = useAsyncCheckProjectPermissions(PermissionAction.CREATE, 'projects') + const { can: isAdmin } = useAsyncCheckPermissions(PermissionAction.CREATE, 'projects') const isInvalidSlug = isOrganizationsSuccess && currentOrg === undefined const orgNotFound = isOrganizationsSuccess && (organizations?.length ?? 0) > 0 && isInvalidSlug diff --git a/apps/studio/pages/project/[ref]/auth/advanced.tsx b/apps/studio/pages/project/[ref]/auth/advanced.tsx index 254e8c0721d89..923f701430566 100644 --- a/apps/studio/pages/project/[ref]/auth/advanced.tsx +++ b/apps/studio/pages/project/[ref]/auth/advanced.tsx @@ -9,7 +9,7 @@ import { ScaffoldContainer, ScaffoldSection } from 'components/layouts/Scaffold' import NoPermission from 'components/ui/NoPermission' import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader' import { UnknownInterface } from 'components/ui/UnknownInterface' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled' import type { NextPageWithLayout } from 'types' @@ -17,8 +17,10 @@ const AdvancedPage: NextPageWithLayout = () => { const { ref } = useParams() const showAdvanced = useIsFeatureEnabled('authentication:advanced') - const { can: canReadAuthSettings, isSuccess: isPermissionsLoaded } = - useAsyncCheckProjectPermissions(PermissionAction.READ, 'custom_config_gotrue') + const { can: canReadAuthSettings, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissions( + PermissionAction.READ, + 'custom_config_gotrue' + ) if (!showAdvanced) { return diff --git a/apps/studio/pages/project/[ref]/auth/audit-logs.tsx b/apps/studio/pages/project/[ref]/auth/audit-logs.tsx index 0b3554b0beed0..6f955ce1ec1de 100644 --- a/apps/studio/pages/project/[ref]/auth/audit-logs.tsx +++ b/apps/studio/pages/project/[ref]/auth/audit-logs.tsx @@ -10,14 +10,16 @@ import { DocsButton } from 'components/ui/DocsButton' import NoPermission from 'components/ui/NoPermission' import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader' import { useAuthConfigQuery } from 'data/auth/auth-config-query' -import { useCheckPermissions, usePermissionsLoaded } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import type { NextPageWithLayout } from 'types' const AuditLogsPage: NextPageWithLayout = () => { const { ref: projectRef } = useParams() - const isPermissionsLoaded = usePermissionsLoaded() const { isLoading: isLoadingConfig } = useAuthConfigQuery({ projectRef }) - const canReadAuthSettings = useCheckPermissions(PermissionAction.READ, 'custom_config_gotrue') + const { can: canReadAuthSettings, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissions( + PermissionAction.READ, + 'custom_config_gotrue' + ) if (isPermissionsLoaded && !canReadAuthSettings) { return diff --git a/apps/studio/pages/project/[ref]/auth/hooks.tsx b/apps/studio/pages/project/[ref]/auth/hooks.tsx index ebea0d189d3a1..023327154fa03 100644 --- a/apps/studio/pages/project/[ref]/auth/hooks.tsx +++ b/apps/studio/pages/project/[ref]/auth/hooks.tsx @@ -7,13 +7,15 @@ import { PageLayout } from 'components/layouts/PageLayout/PageLayout' import { ScaffoldContainer, ScaffoldSection } from 'components/layouts/Scaffold' import { DocsButton } from 'components/ui/DocsButton' import NoPermission from 'components/ui/NoPermission' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import type { NextPageWithLayout } from 'types' import { GenericSkeletonLoader } from 'ui-patterns' const Hooks: NextPageWithLayout = () => { - const { can: canReadAuthSettings, isSuccess: isPermissionsLoaded } = - useAsyncCheckProjectPermissions(PermissionAction.READ, 'custom_config_gotrue') + const { can: canReadAuthSettings, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissions( + PermissionAction.READ, + 'custom_config_gotrue' + ) if (isPermissionsLoaded && !canReadAuthSettings) { return diff --git a/apps/studio/pages/project/[ref]/auth/mfa.tsx b/apps/studio/pages/project/[ref]/auth/mfa.tsx index 30844c34b806c..d6919211c3120 100644 --- a/apps/studio/pages/project/[ref]/auth/mfa.tsx +++ b/apps/studio/pages/project/[ref]/auth/mfa.tsx @@ -9,7 +9,7 @@ import { ScaffoldContainer, ScaffoldSection } from 'components/layouts/Scaffold' import NoPermission from 'components/ui/NoPermission' import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader' import { UnknownInterface } from 'components/ui/UnknownInterface' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled' import type { NextPageWithLayout } from 'types' @@ -17,8 +17,10 @@ const MfaPage: NextPageWithLayout = () => { const { ref } = useParams() const showMFA = useIsFeatureEnabled('authentication:multi_factor') - const { can: canReadAuthSettings, isSuccess: isPermissionsLoaded } = - useAsyncCheckProjectPermissions(PermissionAction.READ, 'custom_config_gotrue') + const { can: canReadAuthSettings, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissions( + PermissionAction.READ, + 'custom_config_gotrue' + ) if (!showMFA) { return diff --git a/apps/studio/pages/project/[ref]/auth/policies.tsx b/apps/studio/pages/project/[ref]/auth/policies.tsx index c66c3b62ae93b..cc3bd1269d56a 100644 --- a/apps/studio/pages/project/[ref]/auth/policies.tsx +++ b/apps/studio/pages/project/[ref]/auth/policies.tsx @@ -20,7 +20,7 @@ import SchemaSelector from 'components/ui/SchemaSelector' import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader' import { useDatabasePoliciesQuery } from 'data/database-policies/database-policies-query' import { useTablesQuery } from 'data/tables/tables-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { useUrlState } from 'hooks/ui/useUrlState' import { useIsProtectedSchema } from 'hooks/useProtectedSchemas' @@ -98,7 +98,7 @@ const AuthPoliciesPage: NextPageWithLayout = () => { }) const filteredTables = onFilterTables(tables ?? [], policies ?? [], searchString) - const { can: canReadPolicies, isSuccess: isPermissionsLoaded } = useAsyncCheckProjectPermissions( + const { can: canReadPolicies, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_READ, 'policies' ) diff --git a/apps/studio/pages/project/[ref]/auth/protection.tsx b/apps/studio/pages/project/[ref]/auth/protection.tsx index 6a18dee5f6056..efd6eec56a1c7 100644 --- a/apps/studio/pages/project/[ref]/auth/protection.tsx +++ b/apps/studio/pages/project/[ref]/auth/protection.tsx @@ -9,7 +9,7 @@ import { ScaffoldContainer, ScaffoldSection } from 'components/layouts/Scaffold' import NoPermission from 'components/ui/NoPermission' import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader' import { UnknownInterface } from 'components/ui/UnknownInterface' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled' import type { NextPageWithLayout } from 'types' @@ -17,8 +17,10 @@ const ProtectionPage: NextPageWithLayout = () => { const { ref } = useParams() const showAttackProtection = useIsFeatureEnabled('authentication:attack_protection') - const { can: canReadAuthSettings, isSuccess: isPermissionsLoaded } = - useAsyncCheckProjectPermissions(PermissionAction.READ, 'custom_config_gotrue') + const { can: canReadAuthSettings, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissions( + PermissionAction.READ, + 'custom_config_gotrue' + ) if (!showAttackProtection) { return diff --git a/apps/studio/pages/project/[ref]/auth/rate-limits.tsx b/apps/studio/pages/project/[ref]/auth/rate-limits.tsx index 9c736babb4d41..4b6d186e64dc4 100644 --- a/apps/studio/pages/project/[ref]/auth/rate-limits.tsx +++ b/apps/studio/pages/project/[ref]/auth/rate-limits.tsx @@ -10,7 +10,7 @@ import { DocsButton } from 'components/ui/DocsButton' import NoPermission from 'components/ui/NoPermission' import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader' import { UnknownInterface } from 'components/ui/UnknownInterface' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled' import type { NextPageWithLayout } from 'types' @@ -18,8 +18,10 @@ const RateLimitsPage: NextPageWithLayout = () => { const { ref } = useParams() const showRateLimits = useIsFeatureEnabled('authentication:rate_limits') - const { can: canReadAuthSettings, isSuccess: isPermissionsLoaded } = - useAsyncCheckProjectPermissions(PermissionAction.READ, 'custom_config_gotrue') + const { can: canReadAuthSettings, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissions( + PermissionAction.READ, + 'custom_config_gotrue' + ) if (!showRateLimits) { return diff --git a/apps/studio/pages/project/[ref]/auth/sessions.tsx b/apps/studio/pages/project/[ref]/auth/sessions.tsx index 683b111196f8e..eb22314bb1da2 100644 --- a/apps/studio/pages/project/[ref]/auth/sessions.tsx +++ b/apps/studio/pages/project/[ref]/auth/sessions.tsx @@ -7,12 +7,14 @@ import { PageLayout } from 'components/layouts/PageLayout/PageLayout' import { ScaffoldContainer, ScaffoldSection } from 'components/layouts/Scaffold' import NoPermission from 'components/ui/NoPermission' import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import type { NextPageWithLayout } from 'types' const SessionsPage: NextPageWithLayout = () => { - const { can: canReadAuthSettings, isSuccess: isPermissionsLoaded } = - useAsyncCheckProjectPermissions(PermissionAction.READ, 'custom_config_gotrue') + const { can: canReadAuthSettings, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissions( + PermissionAction.READ, + 'custom_config_gotrue' + ) if (isPermissionsLoaded && !canReadAuthSettings) { return diff --git a/apps/studio/pages/project/[ref]/auth/smtp.tsx b/apps/studio/pages/project/[ref]/auth/smtp.tsx index b6bd764a9081c..ba95e4c9eed40 100644 --- a/apps/studio/pages/project/[ref]/auth/smtp.tsx +++ b/apps/studio/pages/project/[ref]/auth/smtp.tsx @@ -5,13 +5,15 @@ import { AuthEmailsLayout } from 'components/layouts/AuthLayout/AuthEmailsLayout import DefaultLayout from 'components/layouts/DefaultLayout' import { ScaffoldContainer, ScaffoldSection } from 'components/layouts/Scaffold' import NoPermission from 'components/ui/NoPermission' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import type { NextPageWithLayout } from 'types' import { GenericSkeletonLoader } from 'ui-patterns' const SmtpPage: NextPageWithLayout = () => { - const { can: canReadAuthSettings, isSuccess: isPermissionsLoaded } = - useAsyncCheckProjectPermissions(PermissionAction.READ, 'custom_config_gotrue') + const { can: canReadAuthSettings, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissions( + PermissionAction.READ, + 'custom_config_gotrue' + ) if (isPermissionsLoaded && !canReadAuthSettings) { return diff --git a/apps/studio/pages/project/[ref]/auth/templates.tsx b/apps/studio/pages/project/[ref]/auth/templates.tsx index 8ac5ec3aacd0e..cc1ccbaa0fed5 100644 --- a/apps/studio/pages/project/[ref]/auth/templates.tsx +++ b/apps/studio/pages/project/[ref]/auth/templates.tsx @@ -5,13 +5,15 @@ import { AuthEmailsLayout } from 'components/layouts/AuthLayout/AuthEmailsLayout import DefaultLayout from 'components/layouts/DefaultLayout' import { ScaffoldContainer, ScaffoldSection } from 'components/layouts/Scaffold' import NoPermission from 'components/ui/NoPermission' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import type { NextPageWithLayout } from 'types' import { GenericSkeletonLoader } from 'ui-patterns' const TemplatesPage: NextPageWithLayout = () => { - const { can: canReadAuthSettings, isSuccess: isPermissionsLoaded } = - useAsyncCheckProjectPermissions(PermissionAction.READ, 'custom_config_gotrue') + const { can: canReadAuthSettings, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissions( + PermissionAction.READ, + 'custom_config_gotrue' + ) if (isPermissionsLoaded && !canReadAuthSettings) { return diff --git a/apps/studio/pages/project/[ref]/auth/third-party.tsx b/apps/studio/pages/project/[ref]/auth/third-party.tsx index fac8db8e2a318..6e989a5d6c58c 100644 --- a/apps/studio/pages/project/[ref]/auth/third-party.tsx +++ b/apps/studio/pages/project/[ref]/auth/third-party.tsx @@ -8,14 +8,16 @@ import DefaultLayout from 'components/layouts/DefaultLayout' import { ScaffoldContainer } from 'components/layouts/Scaffold' import NoPermission from 'components/ui/NoPermission' import { UnknownInterface } from 'components/ui/UnknownInterface' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled' import type { NextPageWithLayout } from 'types' const ThirdPartyPage: NextPageWithLayout = () => { const { ref } = useParams() - const { can: canReadAuthSettings, isSuccess: isPermissionsLoaded } = - useAsyncCheckProjectPermissions(PermissionAction.READ, 'custom_config_gotrue') + const { can: canReadAuthSettings, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissions( + PermissionAction.READ, + 'custom_config_gotrue' + ) const showThirdPartyAuth = useIsFeatureEnabled('authentication:third_party_auth') diff --git a/apps/studio/pages/project/[ref]/auth/url-configuration.tsx b/apps/studio/pages/project/[ref]/auth/url-configuration.tsx index 81df0a87cd9be..442d9e9e25727 100644 --- a/apps/studio/pages/project/[ref]/auth/url-configuration.tsx +++ b/apps/studio/pages/project/[ref]/auth/url-configuration.tsx @@ -8,12 +8,14 @@ import { PageLayout } from 'components/layouts/PageLayout/PageLayout' import { ScaffoldContainer, ScaffoldSection } from 'components/layouts/Scaffold' import NoPermission from 'components/ui/NoPermission' import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import type { NextPageWithLayout } from 'types' const URLConfiguration: NextPageWithLayout = () => { - const { can: canReadAuthSettings, isSuccess: isPermissionsLoaded } = - useAsyncCheckProjectPermissions(PermissionAction.READ, 'custom_config_gotrue') + const { can: canReadAuthSettings, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissions( + PermissionAction.READ, + 'custom_config_gotrue' + ) if (isPermissionsLoaded && !canReadAuthSettings) { return diff --git a/apps/studio/pages/project/[ref]/branches/index.tsx b/apps/studio/pages/project/[ref]/branches/index.tsx index 006d7b5ff28b0..30cb0df93356d 100644 --- a/apps/studio/pages/project/[ref]/branches/index.tsx +++ b/apps/studio/pages/project/[ref]/branches/index.tsx @@ -19,7 +19,7 @@ import { useBranchDeleteMutation } from 'data/branches/branch-delete-mutation' import { Branch, useBranchesQuery } from 'data/branches/branches-query' import { useGitHubConnectionsQuery } from 'data/integrations/github-connections-query' import { useSendEventMutation } from 'data/telemetry/send-event-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { useAppStateSnapshot } from 'state/app-state' @@ -42,7 +42,7 @@ const BranchesPage: NextPageWithLayout = () => { const projectRef = project !== undefined ? (isBranch ? project.parent_project_ref : ref) : undefined - const { can: canReadBranches, isSuccess: isPermissionsLoaded } = useAsyncCheckProjectPermissions( + const { can: canReadBranches, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissions( PermissionAction.READ, 'preview_branches' ) @@ -186,7 +186,7 @@ const BranchesPage: NextPageWithLayout = () => { BranchesPage.getLayout = (page) => { const BranchesPageWrapper = () => { const snap = useAppStateSnapshot() - const { can: canCreateBranches } = useAsyncCheckProjectPermissions( + const { can: canCreateBranches } = useAsyncCheckPermissions( PermissionAction.CREATE, 'preview_branches', { diff --git a/apps/studio/pages/project/[ref]/branches/merge-requests.tsx b/apps/studio/pages/project/[ref]/branches/merge-requests.tsx index 749b79d91607e..d66359dc3796b 100644 --- a/apps/studio/pages/project/[ref]/branches/merge-requests.tsx +++ b/apps/studio/pages/project/[ref]/branches/merge-requests.tsx @@ -24,7 +24,7 @@ import { useBranchUpdateMutation } from 'data/branches/branch-update-mutation' import { Branch, useBranchesQuery } from 'data/branches/branches-query' import { useGitHubConnectionsQuery } from 'data/integrations/github-connections-query' import { useSendEventMutation } from 'data/telemetry/send-event-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import type { NextPageWithLayout } from 'types' @@ -49,7 +49,7 @@ const MergeRequestsPage: NextPageWithLayout = () => { const projectRef = project !== undefined ? (isBranch ? project.parent_project_ref : ref) : undefined - const { can: canReadBranches, isSuccess: isPermissionsLoaded } = useAsyncCheckProjectPermissions( + const { can: canReadBranches, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissions( PermissionAction.READ, 'preview_branches' ) diff --git a/apps/studio/pages/project/[ref]/database/backups/pitr.tsx b/apps/studio/pages/project/[ref]/database/backups/pitr.tsx index ae534f92f1320..94679b8eeb651 100644 --- a/apps/studio/pages/project/[ref]/database/backups/pitr.tsx +++ b/apps/studio/pages/project/[ref]/database/backups/pitr.tsx @@ -14,7 +14,7 @@ import NoPermission from 'components/ui/NoPermission' import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader' import UpgradeToPro from 'components/ui/UpgradeToPro' import { useBackupsQuery } from 'data/database/backups-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { useIsOrioleDbInAws, useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { PROJECT_STATUS } from 'lib/constants' @@ -57,8 +57,10 @@ const PITR = () => { const isEnabled = backups?.pitr_enabled const isActiveHealthy = project?.status === PROJECT_STATUS.ACTIVE_HEALTHY - const { can: canReadPhysicalBackups, isSuccess: isPermissionsLoaded } = - useAsyncCheckProjectPermissions(PermissionAction.READ, 'physical_backups') + const { can: canReadPhysicalBackups, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissions( + PermissionAction.READ, + 'physical_backups' + ) if (isPermissionsLoaded && !canReadPhysicalBackups) { return diff --git a/apps/studio/pages/project/[ref]/database/backups/restore-to-new-project.tsx b/apps/studio/pages/project/[ref]/database/backups/restore-to-new-project.tsx index 31a58c8bccb4a..56016f6392c3d 100644 --- a/apps/studio/pages/project/[ref]/database/backups/restore-to-new-project.tsx +++ b/apps/studio/pages/project/[ref]/database/backups/restore-to-new-project.tsx @@ -23,7 +23,7 @@ import UpgradeToPro from 'components/ui/UpgradeToPro' import { useDiskAttributesQuery } from 'data/config/disk-attributes-query' import { useCloneBackupsQuery } from 'data/projects/clone-query' import { useCloneStatusQuery } from 'data/projects/clone-status-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { useIsAwsK8sCloudProvider, @@ -82,9 +82,11 @@ const RestoreToNewProject = () => { const isActiveHealthy = project?.status === PROJECT_STATUS.ACTIVE_HEALTHY - const { can: canReadPhysicalBackups, isSuccess: isPermissionsLoaded } = - useAsyncCheckProjectPermissions(PermissionAction.READ, 'physical_backups') - const { can: canTriggerPhysicalBackups } = useAsyncCheckProjectPermissions( + const { can: canReadPhysicalBackups, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissions( + PermissionAction.READ, + 'physical_backups' + ) + const { can: canTriggerPhysicalBackups } = useAsyncCheckPermissions( PermissionAction.INFRA_EXECUTE, 'queue_job.restore.prepare' ) diff --git a/apps/studio/pages/project/[ref]/database/backups/scheduled.tsx b/apps/studio/pages/project/[ref]/database/backups/scheduled.tsx index 52b0838add596..b0a3b0c6c8000 100644 --- a/apps/studio/pages/project/[ref]/database/backups/scheduled.tsx +++ b/apps/studio/pages/project/[ref]/database/backups/scheduled.tsx @@ -14,7 +14,7 @@ import InformationBox from 'components/ui/InformationBox' import NoPermission from 'components/ui/NoPermission' import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader' import { useBackupsQuery } from 'data/database/backups-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useIsOrioleDbInAws } from 'hooks/misc/useSelectedProject' import type { NextPageWithLayout } from 'types' import { Admonition } from 'ui-patterns' @@ -27,8 +27,10 @@ const DatabaseScheduledBackups: NextPageWithLayout = () => { const isOrioleDbInAws = useIsOrioleDbInAws() const isPitrEnabled = backups?.pitr_enabled - const { can: canReadScheduledBackups, isSuccess: isPermissionsLoaded } = - useAsyncCheckProjectPermissions(PermissionAction.READ, 'back_ups') + const { can: canReadScheduledBackups, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissions( + PermissionAction.READ, + 'back_ups' + ) return ( diff --git a/apps/studio/pages/project/[ref]/database/extensions.tsx b/apps/studio/pages/project/[ref]/database/extensions.tsx index 01bc3ba3e841c..51b06d46f713a 100644 --- a/apps/studio/pages/project/[ref]/database/extensions.tsx +++ b/apps/studio/pages/project/[ref]/database/extensions.tsx @@ -6,12 +6,14 @@ import DefaultLayout from 'components/layouts/DefaultLayout' import { PageLayout } from 'components/layouts/PageLayout/PageLayout' import { ScaffoldContainer, ScaffoldSection } from 'components/layouts/Scaffold' import NoPermission from 'components/ui/NoPermission' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import type { NextPageWithLayout } from 'types' const DatabaseExtensions: NextPageWithLayout = () => { - const { can: canReadExtensions, isSuccess: isPermissionsLoaded } = - useAsyncCheckProjectPermissions(PermissionAction.TENANT_SQL_ADMIN_READ, 'extensions') + const { can: canReadExtensions, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissions( + PermissionAction.TENANT_SQL_ADMIN_READ, + 'extensions' + ) if (isPermissionsLoaded && !canReadExtensions) { return diff --git a/apps/studio/pages/project/[ref]/database/functions.tsx b/apps/studio/pages/project/[ref]/database/functions.tsx index fc74e83002ada..1ab76e36bb859 100644 --- a/apps/studio/pages/project/[ref]/database/functions.tsx +++ b/apps/studio/pages/project/[ref]/database/functions.tsx @@ -11,7 +11,7 @@ import { EditorPanel } from 'components/ui/EditorPanel/EditorPanel' import { FormHeader } from 'components/ui/Forms/FormHeader' import NoPermission from 'components/ui/NoPermission' import { DatabaseFunction } from 'data/database-functions/database-functions-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import type { NextPageWithLayout } from 'types' const DatabaseFunctionsPage: NextPageWithLayout = () => { @@ -26,7 +26,7 @@ const DatabaseFunctionsPage: NextPageWithLayout = () => { DatabaseFunction | undefined >() - const { can: canReadFunctions, isSuccess: isPermissionsLoaded } = useAsyncCheckProjectPermissions( + const { can: canReadFunctions, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_READ, 'functions' ) diff --git a/apps/studio/pages/project/[ref]/database/publications/[id].tsx b/apps/studio/pages/project/[ref]/database/publications/[id].tsx index 81fec4d623a87..2905ae2a7c184 100644 --- a/apps/studio/pages/project/[ref]/database/publications/[id].tsx +++ b/apps/studio/pages/project/[ref]/database/publications/[id].tsx @@ -6,12 +6,14 @@ import DefaultLayout from 'components/layouts/DefaultLayout' import { PageLayout } from 'components/layouts/PageLayout/PageLayout' import { ScaffoldContainer, ScaffoldSection } from 'components/layouts/Scaffold' import NoPermission from 'components/ui/NoPermission' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import type { NextPageWithLayout } from 'types' const DatabasePublications: NextPageWithLayout = () => { - const { can: canViewPublications, isSuccess: isPermissionsLoaded } = - useAsyncCheckProjectPermissions(PermissionAction.TENANT_SQL_ADMIN_READ, 'publications') + const { can: canViewPublications, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissions( + PermissionAction.TENANT_SQL_ADMIN_READ, + 'publications' + ) if (isPermissionsLoaded && !canViewPublications) { return diff --git a/apps/studio/pages/project/[ref]/database/publications/index.tsx b/apps/studio/pages/project/[ref]/database/publications/index.tsx index b5ee05c33dcd2..ddf605455a42c 100644 --- a/apps/studio/pages/project/[ref]/database/publications/index.tsx +++ b/apps/studio/pages/project/[ref]/database/publications/index.tsx @@ -6,12 +6,14 @@ import DefaultLayout from 'components/layouts/DefaultLayout' import { PageLayout } from 'components/layouts/PageLayout/PageLayout' import { ScaffoldContainer, ScaffoldSection } from 'components/layouts/Scaffold' import NoPermission from 'components/ui/NoPermission' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import type { NextPageWithLayout } from 'types' const DatabasePublications: NextPageWithLayout = () => { - const { can: canViewPublications, isSuccess: isPermissionsLoaded } = - useAsyncCheckProjectPermissions(PermissionAction.TENANT_SQL_ADMIN_READ, 'publications') + const { can: canViewPublications, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissions( + PermissionAction.TENANT_SQL_ADMIN_READ, + 'publications' + ) if (isPermissionsLoaded && !canViewPublications) { return diff --git a/apps/studio/pages/project/[ref]/database/triggers.tsx b/apps/studio/pages/project/[ref]/database/triggers.tsx index 4f90286f184f6..e483e2f752c5a 100644 --- a/apps/studio/pages/project/[ref]/database/triggers.tsx +++ b/apps/studio/pages/project/[ref]/database/triggers.tsx @@ -13,7 +13,7 @@ import { ScaffoldContainer, ScaffoldSection } from 'components/layouts/Scaffold' import { EditorPanel } from 'components/ui/EditorPanel/EditorPanel' import { FormHeader } from 'components/ui/Forms/FormHeader' import NoPermission from 'components/ui/NoPermission' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import type { NextPageWithLayout } from 'types' const TriggersPage: NextPageWithLayout = () => { @@ -27,7 +27,7 @@ const TriggersPage: NextPageWithLayout = () => { const [editorPanelOpen, setEditorPanelOpen] = useState(false) const [selectedTriggerForEditor, setSelectedTriggerForEditor] = useState() - const { can: canReadTriggers, isSuccess: isPermissionsLoaded } = useAsyncCheckProjectPermissions( + const { can: canReadTriggers, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissions( PermissionAction.TENANT_SQL_ADMIN_READ, 'triggers' ) diff --git a/apps/studio/pages/project/[ref]/functions/[functionSlug]/code.tsx b/apps/studio/pages/project/[ref]/functions/[functionSlug]/code.tsx index 21ab897ec4445..2de8d35300607 100644 --- a/apps/studio/pages/project/[ref]/functions/[functionSlug]/code.tsx +++ b/apps/studio/pages/project/[ref]/functions/[functionSlug]/code.tsx @@ -14,7 +14,7 @@ import { useEdgeFunctionBodyQuery } from 'data/edge-functions/edge-function-body import { useEdgeFunctionQuery } from 'data/edge-functions/edge-function-query' import { useEdgeFunctionDeployMutation } from 'data/edge-functions/edge-functions-deploy-mutation' import { useSendEventMutation } from 'data/telemetry/send-event-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { BASE_PATH } from 'lib/constants' @@ -28,10 +28,7 @@ const CodePage = () => { const { mutate: sendEvent } = useSendEventMutation() const [showDeployWarning, setShowDeployWarning] = useState(false) - const { can: canDeployFunction } = useAsyncCheckProjectPermissions( - PermissionAction.FUNCTIONS_WRITE, - '*' - ) + const { can: canDeployFunction } = useAsyncCheckPermissions(PermissionAction.FUNCTIONS_WRITE, '*') const { data: selectedFunction } = useEdgeFunctionQuery({ projectRef: ref, slug: functionSlug }) const { diff --git a/apps/studio/pages/project/[ref]/functions/[functionSlug]/index.tsx b/apps/studio/pages/project/[ref]/functions/[functionSlug]/index.tsx index dc9cd65fb22f2..e09f4959457a0 100644 --- a/apps/studio/pages/project/[ref]/functions/[functionSlug]/index.tsx +++ b/apps/studio/pages/project/[ref]/functions/[functionSlug]/index.tsx @@ -7,6 +7,7 @@ import sumBy from 'lodash/sumBy' import { useRouter } from 'next/router' import { useMemo, useState } from 'react' +import { useFlag } from 'common' import ReportWidget from 'components/interfaces/Reports/ReportWidget' import DefaultLayout from 'components/layouts/DefaultLayout' import EdgeFunctionDetailsLayout from 'components/layouts/EdgeFunctionsLayout/EdgeFunctionDetailsLayout' @@ -19,7 +20,7 @@ import { } from 'data/analytics/functions-combined-stats-query' import { useEdgeFunctionQuery } from 'data/edge-functions/edge-function-query' import { useFillTimeseriesSorted } from 'hooks/analytics/useFillTimeseriesSorted' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import type { ChartIntervals, NextPageWithLayout } from 'types' import { AlertDescription_Shadcn_, @@ -28,7 +29,6 @@ import { Button, WarningIcon, } from 'ui' -import { useFlag } from 'common' const CHART_INTERVALS: ChartIntervals[] = [ { @@ -122,7 +122,7 @@ const PageLayout: NextPageWithLayout = () => { endDate.toISOString() ) - const { isLoading: permissionsLoading, can: canReadFunction } = useAsyncCheckProjectPermissions( + const { isLoading: permissionsLoading, can: canReadFunction } = useAsyncCheckPermissions( PermissionAction.FUNCTIONS_READ, functionSlug as string ) diff --git a/apps/studio/pages/project/[ref]/logs/auth-logs.tsx b/apps/studio/pages/project/[ref]/logs/auth-logs.tsx index 3992a84cf048f..cf03e3b2bd37f 100644 --- a/apps/studio/pages/project/[ref]/logs/auth-logs.tsx +++ b/apps/studio/pages/project/[ref]/logs/auth-logs.tsx @@ -4,13 +4,13 @@ import LogsPreviewer from 'components/interfaces/Settings/Logs/LogsPreviewer' import DefaultLayout from 'components/layouts/DefaultLayout' import LogsLayout from 'components/layouts/LogsLayout/LogsLayout' import NoPermission from 'components/ui/NoPermission' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import type { NextPageWithLayout } from 'types' const LogsPage: NextPageWithLayout = () => { const { data: project } = useSelectedProjectQuery() - const { can: canReadAuthLogs } = useAsyncCheckProjectPermissions( + const { can: canReadAuthLogs } = useAsyncCheckPermissions( PermissionAction.ANALYTICS_READ, 'logflare' ) diff --git a/apps/studio/pages/project/[ref]/reports/database.tsx b/apps/studio/pages/project/[ref]/reports/database.tsx index 959967b54aa7e..d792f2b9114b3 100644 --- a/apps/studio/pages/project/[ref]/reports/database.tsx +++ b/apps/studio/pages/project/[ref]/reports/database.tsx @@ -34,7 +34,7 @@ import { useMaxConnectionsQuery } from 'data/database/max-connections-query' import { usePgbouncerConfigQuery } from 'data/database/pgbouncer-config-query' import { getReportAttributes, getReportAttributesV2 } from 'data/reports/database-charts' import { useDatabaseReport } from 'data/reports/database-report-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useReportDateRange } from 'hooks/misc/useReportDateRange' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' @@ -107,7 +107,7 @@ const DatabaseUsage = () => { }) const { data: poolerConfig } = usePgbouncerConfigQuery({ projectRef: project?.ref }) - const { can: canUpdateDiskSizeConfig } = useAsyncCheckProjectPermissions( + const { can: canUpdateDiskSizeConfig } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'projects', { diff --git a/apps/studio/pages/project/[ref]/reports/index.tsx b/apps/studio/pages/project/[ref]/reports/index.tsx index ff2cc6e12e676..3fa77b7124ce0 100644 --- a/apps/studio/pages/project/[ref]/reports/index.tsx +++ b/apps/studio/pages/project/[ref]/reports/index.tsx @@ -9,7 +9,7 @@ import ReportsLayout from 'components/layouts/ReportsLayout/ReportsLayout' import ProductEmptyState from 'components/to-be-cleaned/ProductEmptyState' import { Loading } from 'components/ui/Loading' import { useContentQuery } from 'data/content/content-query' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useProfile } from 'lib/profile' import type { NextPageWithLayout } from 'types' @@ -36,7 +36,7 @@ export const UserReportPage: NextPageWithLayout = () => { } ) - const { can: canCreateReport } = useAsyncCheckProjectPermissions( + const { can: canCreateReport } = useAsyncCheckPermissions( PermissionAction.CREATE, 'user_content', { diff --git a/apps/studio/pages/project/[ref]/settings/jwt/signing-keys.tsx b/apps/studio/pages/project/[ref]/settings/jwt/signing-keys.tsx index 99b866a2e9498..1013828e9ed5d 100644 --- a/apps/studio/pages/project/[ref]/settings/jwt/signing-keys.tsx +++ b/apps/studio/pages/project/[ref]/settings/jwt/signing-keys.tsx @@ -6,11 +6,11 @@ import JWTKeysLayout from 'components/layouts/JWTKeys/JWTKeysLayout' import SettingsLayout from 'components/layouts/ProjectSettingsLayout/SettingsLayout' import NoPermission from 'components/ui/NoPermission' import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import type { NextPageWithLayout } from 'types' const JWTSigningKeysPage: NextPageWithLayout = () => { - const { can: canReadAPIKeys, isSuccess: isPermissionsLoaded } = useAsyncCheckProjectPermissions( + const { can: canReadAPIKeys, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissions( PermissionAction.READ, 'auth_signing_keys' ) diff --git a/apps/studio/pages/project/[ref]/settings/log-drains.tsx b/apps/studio/pages/project/[ref]/settings/log-drains.tsx index cdd982e072b9e..b118cf9bccd92 100644 --- a/apps/studio/pages/project/[ref]/settings/log-drains.tsx +++ b/apps/studio/pages/project/[ref]/settings/log-drains.tsx @@ -18,15 +18,17 @@ import { DocsButton } from 'components/ui/DocsButton' import { useCreateLogDrainMutation } from 'data/log-drains/create-log-drain-mutation' import { LogDrainData, useLogDrainsQuery } from 'data/log-drains/log-drains-query' import { useUpdateLogDrainMutation } from 'data/log-drains/update-log-drain-mutation' -import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions' +import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useCurrentOrgPlan } from 'hooks/misc/useCurrentOrgPlan' import type { NextPageWithLayout } from 'types' import { Alert_Shadcn_, Button } from 'ui' import { GenericSkeletonLoader } from 'ui-patterns' const LogDrainsSettings: NextPageWithLayout = () => { - const { can: canManageLogDrains, isLoading: isLoadingPermissions } = - useAsyncCheckProjectPermissions(PermissionAction.ANALYTICS_ADMIN_WRITE, 'logflare') + const { can: canManageLogDrains, isLoading: isLoadingPermissions } = useAsyncCheckPermissions( + PermissionAction.ANALYTICS_ADMIN_WRITE, + 'logflare' + ) const [open, setOpen] = useState(false) const { ref } = useParams() as { ref: string } diff --git a/apps/www/_blog/2025-09-09-orioledb-patent-free.mdx b/apps/www/_blog/2025-09-09-orioledb-patent-free.mdx index 08404b9f9164a..f2e699e412068 100644 --- a/apps/www/_blog/2025-09-09-orioledb-patent-free.mdx +++ b/apps/www/_blog/2025-09-09-orioledb-patent-free.mdx @@ -42,7 +42,7 @@ OrioleDB will continue as an [open source project](https://github.com/orioledb/o ## License compatibility with Postgres -[OrioleDB License](https://github.com/orioledb/orioledb?tab=License-1-ov-file#readme) is based on the [PostgreSQL License](https://github.com/postgres/postgres?tab=License-1-ov-file). To reinforce the IP compatibility, Supabase is making available a non-exclusive license of U.S. Patent (“Durable multiversion B+-tree”) to all OrioleDB users, including proprietary forks, in accordance with the OrioleDB license. The patent is intended as a shield, not a sword, to protect Open Source from hostile IP claims. +[OrioleDB License](https://github.com/orioledb/orioledb?tab=Apache-2.0-1-ov-file#readme) is now Apache 2.0. This license is quite similar to [PostgreSQL License](https://github.com/postgres/postgres?tab=License-1-ov-file), but explicitly grants patent usage. With this change, Supabase is making available a non-exclusive license of U.S. Patent (“Durable multiversion B+-tree”) to all OrioleDB users, including proprietary forks. The patent is intended as a shield, not a sword, to protect Open Source from hostile IP claims. ## **Aligned with Postgres** diff --git a/apps/www/_blog/2025-09-12-processing-large-jobs-with-edge-functions.mdx b/apps/www/_blog/2025-09-12-processing-large-jobs-with-edge-functions.mdx new file mode 100644 index 0000000000000..35dc7d0132a45 --- /dev/null +++ b/apps/www/_blog/2025-09-12-processing-large-jobs-with-edge-functions.mdx @@ -0,0 +1,402 @@ +--- +title: Processing large jobs with Edge Functions, Cron, and Queues +description: Learn how to build scalable data processing pipelines using Supabase Edge Functions, cron jobs, and database queues and handle large workloads without timeouts or crashes. +author: prashant +image: 2025-09-processing-large-jobs-with-edge-functions/og.png +thumb: 2025-09-processing-large-jobs-with-edge-functions/og.png +categories: + - postgres + - edge functions + - cron + - queues +date: 2025-09-16:08:00 +toc_depth: 2 +--- + +When you're building applications that process large amounts of data, you quickly run into a fundamental problem: trying to do everything at once leads to timeouts, crashes, and frustrated users. The solution isn't to buy bigger servers. It's to break big jobs into small, manageable pieces. + +Supabase gives you three tools that work beautifully together for this: [Edge Functions](/edge-functions) for serverless compute, [Cron](/modules/cron) for scheduling, and database [queues](/modules/queues) for reliable job processing. + +Here's how to use them to build a system that can handle serious scale. + +## The three-layer pattern + +The architecture is simple but powerful. Think of it like an assembly line: + +**Collection**: Cron jobs run Edge Functions that discover work and add tasks to queues + +**Distribution**: Other cron jobs route tasks from main queues to specialized processing queues + +**Processing**: Specialized workers handle specific types of tasks from their assigned queues + +A diagram showing the three-layer pattern described above + +This breaks apart the complexity. Instead of one giant function that scrapes websites, processes content with AI, and stores everything, you have focused functions that each do one thing well. + +## Real example: Building an NFL news aggregator + +Let's say you want to build a dashboard that tracks NFL (American football) news from multiple sources including NFL-related websites and NFL-related videos on YouTube, automatically tags articles by topic, and lets users search by player or team. When they see an article they’re interested in, they can click on it and visit the website that hosts the article. It’s like a dedicated Twitter feed for the NFL without any of the toxicity. + +This sounds straightforward, but at scale this becomes complex fast. You need to monitor dozens of news sites, process hundreds of articles daily, make API calls to OpenAI for content analysis, generate vector embeddings for search, and store everything efficiently. Do this wrong and a single broken webpage crashes your entire pipeline. + +We need to build a more resilient approach. With Supabase Edge Functions, Cron, and Queues, we have the building blocks for a robust content extraction and categorization pipeline. + +## Setting up the foundation + +Everything starts with the [database](/database), and Supabase is Postgres at its core. We know what we’re getting: scalable, dependable, and standard. + +The database design for the application follows a clean pattern. You have content tables for storing articles and videos, queue tables for managing work, entity tables for NFL players and teams, and relationship tables linking everything together. For example: + +```sql +create table articles ( + url text unique not null, + headline text, + content text, + embedding vector(1536) +); +``` + +## Collection: Finding new content + +The collection layer seeks out new NFL-related content and runs on a schedule to discover new articles and videos. We create a collector for every site we want to search. A cron job triggers every 30 minutes to begin collection: + +```sql +SELECT cron.schedule( + 'nfl-collector', + '*/30 * * * *', + $$SELECT net.http_post(url := '[https://your-project.supabase.co/functions/v1/collect-content')$$](https://your-project.supabase.co/functions/v1/collect-content')$$) +); +``` + +The Edge Function does the actual scraping. The trick is being selective about what you collect: + +```tsx +function isRelevantArticle(url: string): boolean { + return url.includes('/news/') && !url.includes('/video/') +} +``` + +This simple filter prevents collecting promotional content or videos. You only want actual news articles. + +When parsing HTML, you need to handle relative URLs properly: + +```tsx +if (href.startsWith('/')) { + href = BASE_URL + href +} +``` + +And always deduplicate within a single scraping session: + +```tsx +const seen = new Set() +if (!seen.has(href)) { + seen.add(href) + articles.push({ url: href, site: 'nfl' }) +} +``` + +For database insertion, let the database handle duplicates rather than checking in your application: + +```tsx +const { error } = await supabase.from('articles').insert({ url, site }) +if (error && !error.message.includes('duplicate')) { + console.error(`Error inserting: ${url}`, error) +} +``` + +This approach is more reliable than complex application-level deduplication logic. + +## Distribution: Smart routing + +The distribution layer identifies articles that need processing and routes them to appropriate queues. The key insight is using separate queue tables for different content sources. [NFL.com](http://NFL.com) articles need different parsing than ESPN articles, so they get routed to specialized processors. It runs more frequently than collection: every 5 minutes: + +```sql +SELECT cron.schedule( + 'distributor', + '*/5 * * * *', + $$SELECT net.http_post(url := '[https://your-project.supabase.co/functions/v1/distribute-work')$$](https://your-project.supabase.co/functions/v1/distribute-work')$$) +); +``` + +The Edge Function finds unprocessed articles using a simple SQL query: + +```tsx +const { data } = await supabase + .from('articles') + .select('url, site') + .is('headline', null) // Missing headline means unprocessed + .limit(50) +``` + +Then it routes based on the source site: + +```tsx +if ([article.site](http://article.site) === "nfl") { + await supabase.from("nfl_queue").insert({ url: article.url }); +} else if ([article.site](http://article.site) === "espn") { + await supabase.from("espn_queue").insert({ url: article.url }); +} +``` + +This separation is crucial because each site has different HTML structures and parsing requirements. + +## Processing: The heavy lifting + +Each content source gets its own processor that runs on its own schedule. [NFL.com](http://NFL.com) gets processed every 15 seconds because it's high-priority: + +```sql +SELECT cron.schedule( + 'nfl-processor', + '*/15 * * * *', + $$SELECT net.http_post(url := '[https://your-project.supabase.co/functions/v1/process-nfl')$$](https://your-project.supabase.co/functions/v1/process-nfl')$$) +); +``` + +The processor handles one article at a time to stay within Edge Function timeout limits: + +```tsx +const { data } = await supabase + .from('nfl_queue') + .select('id, url') + .eq('processed', false) + .order('created_at') + .limit(1) +``` + +Content extraction requires site-specific CSS selectors: + +```tsx +const headline = $('h1').first().text().trim() +const content = $('.article-body').text().trim() || $('article').text().trim() +``` + +Date parsing often needs custom logic for each site's format: + +```tsx +const dateText = $('.publish-date').text() +const match = dateText.match(/(\w+ \d+, \d{4})/) +if (match) { + publication_date = new Date(match[1]) +} +``` + +After scraping, the article gets analyzed with AI to extract entities: + +```tsx +const result = await classifyArticle(headline, content) +const playerIds = await upsertPlayers(supabase, result.players) +const teamIds = await upsertTeams(supabase, result.teams) +``` + +Finally, create the relationships and generate embeddings: + +```tsx +await supabase.from("article_players").insert( + [playerIds.map](http://playerIds.map)(id => ({ article_url: url, player_id: id })) +); + +const embedding = await generateEmbedding(`${headline}\n${content}`); +await supabase.from("articles").update({ embedding }).eq("url", url); +``` + +The critical pattern is the finally block. We use it to always mark queue items as processed, preventing infinite loops when articles fail to process: + +```tsx +try { + // Process article +} finally { + await supabase.from("nfl_queue") + .update({ processed: true }) + .eq("id", [item.id](http://item.id)); +} +``` + +### Monitoring with Sentry + +While the finally block prevents infinite loops, you still need visibility into what's actually failing. Sentry integration gives you detailed error tracking for your Edge Functions. + +First, set up Sentry in your Edge Function: + +```jsx +import { captureException, init } from 'https://deno.land/x/sentry/index.js' + +init({ + dsn: Deno.env.get('SENTRY_DSN'), + environment: Deno.env.get('ENVIRONMENT') || 'production', +}) +``` + +Then wrap your processing logic with proper error capture: + +```jsx +try { + const content = await scrapeArticle(url); + const analysis = await classifyArticle(headline, content); + await storeArticle(article, analysis); +} catch (error) { + *// Capture the full context for debugging* + captureException(error, { + tags: { + function: "nfl-processor", + site: article.site + }, + extra: { + url: article.url, + queueId: queueItem.id + } + }); + console.error(`Failed to process ${url}:`, error); +} finally { + await supabase.from("nfl_queue") + .update({ processed: true }) + .eq("id", queueItem.id); +} +``` + +This gives you real-time alerts when processors fail and detailed context for debugging production issues. + +## Processing user interactions through the pipeline + +The same pipeline pattern works for user-generated events. When someone clicks, shares, or saves an article, you don't want to block their response while updating trending scores for every player and team mentioned in that article. + +Instead, treat interactions like any other job to be processed: + +```tsx +// Just record the interaction quickly +await supabase.from('interaction_queue').insert({ + article_url: url, + user_id: userId, + interaction_type: 'share', +}) +``` + +Then let a separate cron job process the trending updates in batches: + +```sql +SELECT cron.schedule( + 'process-interactions', + '*/2 * * * *', -- Every 2 minutes + $$SELECT net.http_post(url := '[https://your-project.supabase.co/functions/v1/process-interactions')$$](https://your-project.supabase.co/functions/v1/process-interactions')$$) +); +``` + +The processor can handle multiple interactions efficiently: + +```tsx +const { data: interactions } = await supabase + .from('interaction_queue') + .select('*') + .eq('processed', false) + .limit(100) +``` + +This keeps your user interface snappy while ensuring trending scores get updated reliably. If the trending processor goes down, interactions are safely queued and will be processed when it recovers. + +## AI-powered content scoring + +To surface the most important content automatically, use AI to analyze article context and assign importance scores. + +Define scores for different news types: + +```tsx +const CONTEXT_SCORES = { + championship: 9, + trade: 6, + injury: 4, + practice: 1, +} +``` + +Prompt OpenAI with structured output: + +```tsx +const prompt = `Analyze this headline: "${headline}" +Return JSON: {"context": "trade|injury|etc", "score": 1-9}`; + +const result = await [openai.chat](http://openai.chat).completions.create({ + model: "gpt-3.5-turbo", + response_format: { type: "json_object" } +}); +``` + +Process articles in batches to manage API costs: + +```tsx +const unprocessed = articles.filter((a) => !processedUrls.has(a.url)).slice(0, 10) + +for (const article of unprocessed) { + const analysis = await analyzeArticle(article) + await storeAnalysis(article.url, analysis) +} +``` + +## Background tasks for expensive operations + +Some operations are too expensive to run synchronously, even in your cron-triggered processors. Vector embedding generation and bulk AI analysis benefit from background task patterns. + +Edge Functions support background tasks that continue processing after the main response completes: + +typescript + +```jsx +*// In your article processor* +const article = await scrapeAndStore(url); + +*// Start expensive operations in background* +const backgroundTasks = [ + generateEmbedding(article), + analyzeWithAI(article), + updateRelatedContent(article) +]; + +*// Run background tasks without blocking the main flow* +Promise.all(backgroundTasks).catch(error => { + captureException(error, { + tags: { operation: "background-tasks" }, + extra: { articleUrl: url } + }); +}); + +*// Main processing continues immediately* +await markAsProcessed(queueItem.id); +``` + +For operations that might take longer than Edge Function limits, break them into smaller background chunks: + +typescript + +```jsx +async function generateEmbeddingInBackground(article: Article) { + *// Process content in chunks* + const chunks = splitIntoChunks(article.content, 1000); + + for (const chunk of chunks) { + await new Promise(resolve => { + *// Use background task for each chunk* + setTimeout(async () => { + const embedding = await generateEmbedding(chunk); + await storeEmbedding(article.id, embedding); + resolve(void 0); + }, 0); + }); + } +} +``` + +This pattern keeps your main processing pipeline fast while ensuring expensive operations complete reliably. + +## Why this works + +This pattern succeeds because it embraces the constraints of serverless computing rather than fighting them. Edge Functions have time limits, so you process one item at a time. External APIs have rate limits, so you control timing with cron schedules. Failures happen, so you isolate them to individual tasks. + +The result is a system that scales horizontally by adding more cron jobs and queues. Each component can fail independently without bringing down the whole pipeline. Users get fresh content as it becomes available rather than waiting for batch jobs to complete. + +Most importantly, it's built entirely with Supabase primitives — no external queue systems or job schedulers required. You get enterprise-grade reliability with startup simplicity. diff --git a/apps/www/_customers/juniver.mdx b/apps/www/_customers/juniver.mdx new file mode 100644 index 0000000000000..aa19fbf1f9854 --- /dev/null +++ b/apps/www/_customers/juniver.mdx @@ -0,0 +1,110 @@ +--- +name: Juniver +title: 'Juniver built a self-serve B2B platform with Supabase to scale eating disorder recovery' +# Use meta_title to add a custom meta title. Otherwise it defaults to '{name} | Supabase Customer Stories': +# meta_title: +description: Juniver switched from Firebase to Supabase and saw immediate improvements in developer experience and performance. +# Use meta_description to add a custom meta description. Otherwise it defaults to {description}: +meta_description: Juniver switched from Firebase to Supabase and saw immediate improvements in developer experience and performance. +author: prashant +author_title: Prashant Sridharan +author_url: https://github.com/CoolAssPuppy +author_image_url: https://avatars.githubusercontent.com/u/914007?v=4 +logo: /images/customers/logos/juniver.png +logo_inverse: /images/customers/logos/light/juniver.png +og_image: /images/customers/og/juniver.jpg +tags: + - supabase +date: '2025-01-15' +company_url: https://www.joinjuniver.com +misc: [{ label: 'Founded', text: 'United Kingdom' }] +about: Science-based recovery program for disordered eating +# "healthcare" | "fintech" | "ecommerce" | "education" | "gaming" | "media" | "real-estate" | "saas" | "social" | "analytics" | "ai" | "developer-tools" +industry: ['healthcare', 'ai', 'saas'] +# "startup" | "enterprise" | "indie_dev" +company_size: 'startup' +# "Asia" | "Europe" | "North America" | "South America" | "Africa" | "Oceania" +region: 'Europe' +# "database" | "auth" | "storage" | "realtime" | "functions" | "vector" +supabase_products: ['database', 'auth', 'functions'] +--- + + + For me, the biggest benefit of Supabase is developer experience. My expertise doesn't lie in + databases and infrastructure. It really didn't take much time at all to spin up this product with + Supabase. + + +[Juniver](https://www.joinjuniver.com/) is an iOS app that guides people through recovery from eating disorders and disordered eating. The product combines an AI recovery coach, a thoroughly researched curriculum, and self-serve tools designed for moments of need. Juniver is expanding from B2C into B2B2C, licensing its platform to clinics and clinicians who then offer it to patients. + +## The challenge + +Juniver needed to evolve its backend to support a new B2B2C product, without risking the stability of its consumer app. + +- Launch a self-serve, automated, scalable platform for clinics and clinicians +- Enforce strict privacy and access controls across clinics, clinicians, patients, and licenses +- Integrate tightly with Stripe and webhooks to automate onboarding and license provisioning +- Move quickly with a lean team, choosing tools that won't have to be replaced in a few years + +They also faced significant friction with their previous Firebase setup: + +- Document-based storage made data relationships difficult to manage +- Manual relationship handling slowed development +- Limited scalability for complex B2B requirements +- Developer productivity was constrained by Firebase's limitations + + + Time is such a big currency in startup world. With Firebase, we were really struggling with + relationships within our data. It was all done very manually, as you can expect with + document-based storage. Supabase is a relational database and it's much easier and we can move + faster. + + +## Choosing Supabase + +Juniver had long run on Google Cloud with Firebase for the mobile app. The new B2B product created a clean slate to evaluate alternatives and set a foundation for future scale. Supabase offered a relational core (Postgres) and an integrated developer experience that aligned with Juniver's needs now and later. + +**Why Supabase** + +- A relational database (Postgres) to model clean, maintainable relationships +- Integrated developer experience: visual Table Editor with inline SQL, clear logs, SDKs +- Strong security posture with Row Level Security, plus an easy way to "view as user" to validate policies +- Built-in primitives (Auth, Functions) to save time and build with best-of-breed products + + + The Supabase developer experience is so clear. I've got everything at my fingertips. I'm in the + Table Editor. The SQL editor is literally right below the table editor. The feature you have to + see the table from a different user's perspective to test your Row Level Security is a wonderful + little feature that I use all the time. + + +## The approach + +Juniver used the B2B product as a greenfield build on Supabase, avoiding risky dependencies on the legacy Firebase data while preparing for an eventual B2C migration. + +- **Getting started** + - Spun up a new Supabase project and schema for clinics, clinicians, patients, and licenses + - Leaned on documentation and the iOS SDK to accelerate the build +- **Implementation highlights** + - **Database (Postgres):** Relational schema with strict Row Level Security; frequent use of "view as user" to validate policies + - **Auth & OAuth:** Managing identities for clinics and patients with fine-grained access + - **Webhooks + Edge Functions:** Stripe purchase triggers an automated sequence to authenticate partners, provision license codes, and send emails + - **Operational visibility:** Edge Function logs and an integrated console for fast debugging and iteration + + + You have to expect, plan, and build for scale. We can scale exponentially with Supabase. + + +## The results + +Juniver's B2B platform is out in the wild and early in adoption, but the team is already seeing meaningful wins in developer experience and delivery speed. + +- Rapidly build-out of a self-serve, automated B2B platform using out-of-the-box Supabase features +- Faster iteration through an integrated UI, inline SQL, clear logs, and RLS policy testing +- A relational foundation that supports today's B2B needs and tomorrow's B2C migration +- Streamlined development process with Supabase's integrated tooling + + + My advice to developers thinking of moving to Supabase: Try it, it's free. Replicate your project. + You'll see how much easier it is to think about your data from a relational point of view. + diff --git a/apps/www/data/CustomerStories.ts b/apps/www/data/CustomerStories.ts index b12e56ac87810..063854d9d2a70 100644 --- a/apps/www/data/CustomerStories.ts +++ b/apps/www/data/CustomerStories.ts @@ -18,6 +18,18 @@ export type CustomerStoryType = { } export const data: CustomerStoryType[] = [ + { + type: 'Customer Story', + title: + 'Juniver built automated B2B workflows with Supabase Edge Functions and Row Level Security', + description: + 'Juniver switched from Firebase to Supabase and saw immediate improvements in developer experience and performance.', + organization: 'Juniver', + imgUrl: 'images/customers/logos/juniver.png', + logo: '/images/customers/logos/juniver.png', + logo_inverse: '/images/customers/logos/light/juniver.png', + url: '/customers/juniver', + }, { type: 'Customer Story', title: 'Kayhan Space saw 8x improvement in developer speed when moving to Supabase', diff --git a/apps/www/public/customers-rss.xml b/apps/www/public/customers-rss.xml index 2c776ae03103e..57ff2acef841c 100644 --- a/apps/www/public/customers-rss.xml +++ b/apps/www/public/customers-rss.xml @@ -70,6 +70,13 @@ Scaling seamlessly to 5,000+ paying customers & millions of emails sent daily with Supabase Fri, 21 Feb 2025 00:00:00 -0700 + + https://supabase.com/customers/juniver + Juniver built a self-serve B2B platform with Supabase to scale eating disorder recovery + https://supabase.com/customers/juniver + Juniver switched from Firebase to Supabase and saw immediate improvements in developer experience and performance. + Wed, 15 Jan 2025 00:00:00 -0700 + https://supabase.com/customers/e2b E2B: Accelerating AI-Driven Development with Supabase diff --git a/apps/www/public/images/blog/2025-09-processing-large-jobs-with-edge-functions/og.png b/apps/www/public/images/blog/2025-09-processing-large-jobs-with-edge-functions/og.png new file mode 100644 index 0000000000000..cca6165b2114c Binary files /dev/null and b/apps/www/public/images/blog/2025-09-processing-large-jobs-with-edge-functions/og.png differ diff --git a/apps/www/public/images/blog/2025-09-processing-large-jobs-with-edge-functions/three-layer-pattern-diagram.png b/apps/www/public/images/blog/2025-09-processing-large-jobs-with-edge-functions/three-layer-pattern-diagram.png new file mode 100644 index 0000000000000..3046914da4298 Binary files /dev/null and b/apps/www/public/images/blog/2025-09-processing-large-jobs-with-edge-functions/three-layer-pattern-diagram.png differ diff --git a/apps/www/public/images/blog/avatars/nick-farrant-juniver.jpg b/apps/www/public/images/blog/avatars/nick-farrant-juniver.jpg new file mode 100644 index 0000000000000..49c7335de71c8 Binary files /dev/null and b/apps/www/public/images/blog/avatars/nick-farrant-juniver.jpg differ diff --git a/apps/www/public/images/customers/logos/juniver.png b/apps/www/public/images/customers/logos/juniver.png new file mode 100644 index 0000000000000..bbdadd32efd70 Binary files /dev/null and b/apps/www/public/images/customers/logos/juniver.png differ diff --git a/apps/www/public/images/customers/logos/light/juniver.png b/apps/www/public/images/customers/logos/light/juniver.png new file mode 100644 index 0000000000000..90f22bdd80dcc Binary files /dev/null and b/apps/www/public/images/customers/logos/light/juniver.png differ diff --git a/apps/www/public/sitemap_www.xml b/apps/www/public/sitemap_www.xml index 0d54ecc08960a..e5aa94c39fc45 100644 --- a/apps/www/public/sitemap_www.xml +++ b/apps/www/public/sitemap_www.xml @@ -2209,6 +2209,12 @@ weekly 0.5 + + + https://supabase.com/customers/juniver + weekly + 0.5 + https://supabase.com/customers/kayhanspace