Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

RQ convert mutateAsync calls to mutate where possible, otherwise add try finally blocks (#26737)

Joshen Lim0c8155111066
diff --git a/apps/studio/components/interfaces/Account/Preferences/ProfileInformation.tsx b/apps/studio/components/interfaces/Account/Preferences/ProfileInformation.tsx
index 45a30fc98f9..5643674bc62 100644
--- a/apps/studio/components/interfaces/Account/Preferences/ProfileInformation.tsx
+++ b/apps/studio/components/interfaces/Account/Preferences/ProfileInformation.tsx
@@ -31,23 +31,13 @@ export const ProfileInformation = ({ profile }: { profile: Profile }) => {
defaultValues: { first_name: profile.first_name ?? '', last_name: profile.last_name ?? '' },
})
- const { mutateAsync: updateProfile, isLoading } = useProfileUpdateMutation({
- onSuccess: () => {
- toast.success('Successfully saved profile')
- },
- onError: (error) => {
- toast.error("Couldn't update profile. Please try again later.")
- },
+ const { mutate: updateProfile, isLoading } = useProfileUpdateMutation({
+ onSuccess: () => toast.success('Successfully saved profile'),
+ onError: (error) => toast.error(`Failed to update profile: ${error.message}`),
})
const onSubmit: SubmitHandler<z.infer<typeof FormSchema>> = async (data) => {
- try {
- await updateProfile({
- firstName: data.first_name || '',
- lastName: data.last_name || '',
- })
- } finally {
- }
+ updateProfile({ firstName: data.first_name || '', lastName: data.last_name || '' })
}
return (
diff --git a/apps/studio/components/interfaces/Auth/Users/InviteUserModal.tsx b/apps/studio/components/interfaces/Auth/Users/InviteUserModal.tsx
index d8eb4c08efa..d5da5f29418 100644
--- a/apps/studio/components/interfaces/Auth/Users/InviteUserModal.tsx
+++ b/apps/studio/components/interfaces/Auth/Users/InviteUserModal.tsx
@@ -1,7 +1,8 @@
import { PermissionAction } from '@supabase/shared-types/out/constants'
import { useParams } from 'common'
+import { Mail } from 'lucide-react'
import toast from 'react-hot-toast'
-import { Button, Form, IconMail, Input, Modal } from 'ui'
+import { Button, Form, Input, Modal } from 'ui'
import { useUserInviteMutation } from 'data/auth/user-invite-mutation'
import { useCheckPermissions } from 'hooks'
@@ -15,7 +16,12 @@ const InviteUserModal = ({ visible, setVisible }: InviteUserModalProps) => {
const { ref: projectRef } = useParams()
const handleToggle = () => setVisible(!visible)
- const { mutateAsync: inviteUser, isLoading: isInviting } = useUserInviteMutation()
+ const { mutate: inviteUser, isLoading: isInviting } = useUserInviteMutation({
+ onSuccess: (_, variables) => {
+ toast.success(`Sent invite email to ${variables.email}`)
+ setVisible(false)
+ },
+ })
const canInviteUsers = useCheckPermissions(PermissionAction.AUTH_EXECUTE, 'invite_user')
const validate = (values: any) => {
@@ -34,10 +40,7 @@ const InviteUserModal = ({ visible, setVisible }: InviteUserModalProps) => {
const onInviteUser = async (values: any) => {
if (!projectRef) return console.error('Project ref is required')
-
- await inviteUser({ projectRef, email: values.email })
- toast.success(`Sent invite email to ${values.email}`)
- setVisible(false)
+ inviteUser({ projectRef, email: values.email })
}
return (
@@ -64,7 +67,7 @@ const InviteUserModal = ({ visible, setVisible }: InviteUserModalProps) => {
id="email"
className="w-full"
label="User email"
- icon={<IconMail />}
+ icon={<Mail />}
type="email"
name="email"
placeholder="User email"
diff --git a/apps/studio/components/interfaces/Auth/Users/UserDropdown.tsx b/apps/studio/components/interfaces/Auth/Users/UserDropdown.tsx
index 35c76f1b902..1c576066396 100644
--- a/apps/studio/components/interfaces/Auth/Users/UserDropdown.tsx
+++ b/apps/studio/components/interfaces/Auth/Users/UserDropdown.tsx
@@ -23,7 +23,6 @@ import {
IconShieldOff,
IconTrash,
IconUser,
- Modal,
} from 'ui'
import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
@@ -43,6 +42,8 @@ const UserDropdown = ({
setUserSidePanelOpen,
}: UserDropdownProps) => {
const { ref } = useParams()
+ const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false)
+ const [isDeleteFactorsModalOpen, setIsDeleteFactorsModalOpen] = useState(false)
const { mutate: resetPassword, isLoading: isResetting } = useUserResetPasswordMutation({
onSuccess: () => {
@@ -59,9 +60,20 @@ const UserDropdown = ({
toast.success(`Sent OTP to ${user.phone}`)
},
})
- const { mutateAsync: deleteUser, isLoading: isDeleting } = useUserDeleteMutation()
- const { mutateAsync: deleteUserMFAFactors, isLoading: isDeletingFactors } =
- useUserDeleteMFAFactorsMutation()
+ const { mutate: deleteUser, isLoading: isDeleting } = useUserDeleteMutation({
+ onSuccess: () => {
+ toast.success(`Successfully deleted ${user.email}`)
+ setIsDeleteModalOpen(false)
+ },
+ })
+ const { mutate: deleteUserMFAFactors, isLoading: isDeletingFactors } =
+ useUserDeleteMFAFactorsMutation({
+ onSuccess: () => {
+ toast.success("Successfully deleted the user's factors")
+ setIsDeleteFactorsModalOpen(false)
+ },
+ })
+
const isLoading = isResetting || isSendingLink || isSendingOTP || isDeleting || isDeletingFactors
const handleResetPassword = async () => {
@@ -79,37 +91,17 @@ const UserDropdown = ({
sendOTP({ projectRef: ref, user })
}
- const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false)
-
async function handleDelete() {
await timeout(200)
-
if (!ref) return console.error('Project ref is required')
- try {
- await deleteUser({ projectRef: ref, user })
- toast.success(`Successfully deleted ${user.email}`)
- setIsDeleteModalOpen(false)
- } catch (error: any) {
- toast.error(error?.message ?? 'Something went wrong while trying to delete user')
- }
+ deleteUser({ projectRef: ref, user })
}
- const [isDeleteFactorsModalOpen, setIsDeleteFactorsModalOpen] = useState(false)
-
async function handleDeleteFactors() {
await timeout(200)
-
if (!ref) return console.error('Project ref is required')
if (!user.id) return console.error('User id is required')
-
- try {
- await deleteUserMFAFactors({ projectRef: ref, userId: user.id })
- toast.success("Successfully deleted the user's factors")
- setIsDeleteFactorsModalOpen(false)
- } catch (error: any) {
- toast.error(error?.message ?? "Something went wrong while trying to delete user's factors")
- } finally {
- }
+ deleteUserMFAFactors({ projectRef: ref, userId: user.id })
}
const handleViewUserInfo = () => {
diff --git a/apps/studio/components/interfaces/BranchManagement/CreateBranchModal.tsx b/apps/studio/components/interfaces/BranchManagement/CreateBranchModal.tsx
index e7e98033248..6a28ef30bad 100644
--- a/apps/studio/components/interfaces/BranchManagement/CreateBranchModal.tsx
+++ b/apps/studio/components/interfaces/BranchManagement/CreateBranchModal.tsx
@@ -91,9 +91,7 @@ const CreateBranchModal = ({ visible, onClose }: CreateBranchModalProps) => {
if (val.length > 0) {
try {
- if (!githubConnection?.id) {
- throw new Error('No GitHub connection found')
- }
+ if (!githubConnection?.id) throw new Error('No GitHub connection found')
await checkGithubBranchValidity({
connectionId: githubConnection.id,
diff --git a/apps/studio/components/interfaces/Functions/EdgeFunctionDetails/EdgeFunctionDetails.tsx b/apps/studio/components/interfaces/Functions/EdgeFunctionDetails/EdgeFunctionDetails.tsx
index 95314c48e1f..7f1b81463e6 100644
--- a/apps/studio/components/interfaces/Functions/EdgeFunctionDetails/EdgeFunctionDetails.tsx
+++ b/apps/studio/components/interfaces/Functions/EdgeFunctionDetails/EdgeFunctionDetails.tsx
@@ -47,7 +47,7 @@ const EdgeFunctionDetails = () => {
const { data: settings } = useProjectApiQuery({ projectRef })
const { data: customDomainData } = useCustomDomainsQuery({ projectRef })
const { data: selectedFunction } = useEdgeFunctionQuery({ projectRef, slug: functionSlug })
- const { mutateAsync: updateEdgeFunction, isLoading: isUpdating } = useEdgeFunctionUpdateMutation()
+ const { mutate: updateEdgeFunction, isLoading: isUpdating } = useEdgeFunctionUpdateMutation()
const { mutate: deleteEdgeFunction, isLoading: isDeleting } = useEdgeFunctionDeleteMutation({
onSuccess: () => {
toast.success(`Successfully deleted "${selectedFunction?.name}"`)
@@ -80,15 +80,19 @@ const EdgeFunctionDetails = () => {
if (!projectRef) return console.error('Project ref is required')
if (selectedFunction === undefined) return console.error('No edge function selected')
- try {
- await updateEdgeFunction({
+ updateEdgeFunction(
+ {
projectRef,
slug: selectedFunction.slug,
payload: values,
- })
- resetForm({ values, initialValues: values })
- toast.success(`Successfully updated edge function`)
- } catch (error) {}
+ },
+ {
+ onSuccess: () => {
+ resetForm({ values, initialValues: values })
+ toast.success(`Successfully updated edge function`)
+ },
+ }
+ )
}
const onConfirmDelete = async () => {
diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/BillingAddress/BillingAddress.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/BillingAddress/BillingAddress.tsx
index b7dd9644694..95029f72ca3 100644
--- a/apps/studio/components/interfaces/Organization/BillingSettings/BillingAddress/BillingAddress.tsx
+++ b/apps/studio/components/interfaces/Organization/BillingSettings/BillingAddress/BillingAddress.tsx
@@ -23,7 +23,7 @@ const BillingAddress = () => {
const { data, error, isLoading, isSuccess, isError } = useOrganizationCustomerProfileQuery({
slug,
})
- const { mutateAsync: updateCustomerProfile, isLoading: isUpdating } =
+ const { mutate: updateCustomerProfile, isLoading: isUpdating } =
useOrganizationCustomerProfileUpdateMutation()
const formId = 'billing-address-form'
@@ -54,11 +54,15 @@ const BillingAddress = () => {
const onSubmit = async (values: any, { resetForm }: any) => {
if (!slug) return console.error('Slug is required')
- try {
- await updateCustomerProfile({ slug, address: values })
- toast.success('Successfully updated billing address')
- resetForm({ values, initialValues: values })
- } catch (error) {}
+ updateCustomerProfile(
+ { slug, address: values },
+ {
+ onSuccess: () => {
+ toast.success('Successfully updated billing address')
+ resetForm({ values, initialValues: values })
+ },
+ }
+ )
}
return (
diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/BillingEmail.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/BillingEmail.tsx
index d45216904b2..e8aeb3ae1cc 100644
--- a/apps/studio/components/interfaces/Organization/BillingSettings/BillingEmail.tsx
+++ b/apps/studio/components/interfaces/Organization/BillingSettings/BillingEmail.tsx
@@ -26,7 +26,7 @@ const BillingEmail = () => {
const canUpdateOrganization = useCheckPermissions(PermissionAction.UPDATE, 'organizations')
const canReadBillingEmail = useCheckPermissions(PermissionAction.READ, 'organizations')
- const { mutateAsync: updateOrganization, isLoading: isUpdating } = useOrganizationUpdateMutation()
+ const { mutate: updateOrganization, isLoading: isUpdating } = useOrganizationUpdateMutation()
const onUpdateOrganizationEmail = async (values: any, { resetForm }: any) => {
if (!canUpdateOrganization) {
@@ -35,17 +35,20 @@ const BillingEmail = () => {
if (!slug) return console.error('Slug is required')
if (!name) return console.error('Organization name is required')
- try {
- const { billing_email } = await updateOrganization({
+ updateOrganization(
+ {
slug,
name,
billing_email: values.billing_email,
- })
- resetForm({ values: { billing_email }, initialValues: { billing_email } })
- invalidateOrganizationsQuery(queryClient)
- toast.success('Successfully saved settings')
- } finally {
- }
+ },
+ {
+ onSuccess: ({ billing_email }) => {
+ resetForm({ values: { billing_email }, initialValues: { billing_email } })
+ invalidateOrganizationsQuery(queryClient)
+ toast.success('Successfully saved settings')
+ },
+ }
+ )
}
return (
diff --git a/apps/studio/components/interfaces/Organization/GeneralSettings/DeleteOrganizationButton.tsx b/apps/studio/components/interfaces/Organization/GeneralSettings/DeleteOrganizationButton.tsx
index 0c32d4f14d8..aaad24ff686 100644
--- a/apps/studio/components/interfaces/Organization/GeneralSettings/DeleteOrganizationButton.tsx
+++ b/apps/studio/components/interfaces/Organization/GeneralSettings/DeleteOrganizationButton.tsx
@@ -16,7 +16,12 @@ const DeleteOrganizationButton = () => {
const [value, setValue] = useState('')
const canDeleteOrganization = useCheckPermissions(PermissionAction.UPDATE, 'organizations')
- const { mutateAsync: deleteOrganization, isLoading: isDeleting } = useOrganizationDeleteMutation()
+ const { mutate: deleteOrganization, isLoading: isDeleting } = useOrganizationDeleteMutation({
+ onSuccess: () => {
+ toast.success(`Successfully deleted ${orgName}`)
+ router.push('/projects')
+ },
+ })
const onValidate = (values: any) => {
const errors: any = {}
@@ -35,12 +40,7 @@ const DeleteOrganizationButton = () => {
}
if (!orgSlug) return console.error('Org slug is required')
- try {
- await deleteOrganization({ slug: orgSlug })
- } finally {
- toast.success(`Successfully deleted ${orgName}`)
- router.push('/projects')
- }
+ deleteOrganization({ slug: orgSlug })
}
return (
diff --git a/apps/studio/components/interfaces/Organization/NewOrg/NewOrgForm.tsx b/apps/studio/components/interfaces/Organization/NewOrg/NewOrgForm.tsx
index 5f7d9c32dc7..d092e89da87 100644
--- a/apps/studio/components/interfaces/Organization/NewOrg/NewOrgForm.tsx
+++ b/apps/studio/components/interfaces/Organization/NewOrg/NewOrgForm.tsx
@@ -75,11 +75,15 @@ const NewOrgForm = ({ onPaymentMethodReset }: NewOrgFormProps) => {
router.push({ query })
}, [dbPricingTierKey, orgName, orgKind, orgSize, isSpendCapEnabled])
- const { mutateAsync: createOrganization } = useOrganizationCreateMutation({
+ const { mutate: createOrganization } = useOrganizationCreateMutation({
onSuccess: async (org: any) => {
await invalidateOrganizationsQuery(queryClient)
router.push(`/new/${org.slug}`)
},
+ onError: () => {
+ resetPaymentMethod()
+ setNewOrgLoading(false)
+ },
})
function validateOrgName(name: any) {
@@ -105,23 +109,19 @@ const NewOrgForm = ({ onPaymentMethodReset }: NewOrgFormProps) => {
async function createOrg(paymentMethodId?: string) {
const dbTier = dbPricingTierKey === 'PRO' && !isSpendCapEnabled ? 'PAYG' : dbPricingTierKey
- try {
- await createOrganization({
- name: orgName,
- kind: orgKind,
- tier: ('tier_' + dbTier.toLowerCase()) as
- | 'tier_payg'
- | 'tier_pro'
- | 'tier_free'
- | 'tier_team'
- | 'tier_enterprise',
- ...(orgKind == 'COMPANY' ? { size: orgSize } : {}),
- payment_method: paymentMethodId,
- })
- } catch (error) {
- resetPaymentMethod()
- setNewOrgLoading(false)
- }
+
+ createOrganization({
+ name: orgName,
+ kind: orgKind,
+ tier: ('tier_' + dbTier.toLowerCase()) as
+ | 'tier_payg'
+ | 'tier_pro'
+ | 'tier_free'
+ | 'tier_team'
+ | 'tier_enterprise',
+ ...(orgKind == 'COMPANY' ? { size: orgSize } : {}),
+ payment_method: paymentMethodId,
+ })
}
const handleSubmit = async (event: any) => {
@@ -158,9 +158,9 @@ const NewOrgForm = ({ onPaymentMethodReset }: NewOrgFormProps) => {
const paymentMethodFromSetup = setupIntent.payment_method as PaymentMethod
setPaymentMethod(paymentMethodFromSetup)
- await createOrg(paymentMethodFromSetup.id)
+ createOrg(paymentMethodFromSetup.id)
} else {
- await createOrg(paymentMethod.id)
+ createOrg(paymentMethod.id)
}
}
@@ -170,66 +170,84 @@ const NewOrgForm = ({ onPaymentMethodReset }: NewOrgFormProps) => {
}
return (
- <>
- <form onSubmit={handleSubmit}>
- <Panel
- title={
- <div key="panel-title">
- <h4>Create a new organization</h4>
- </div>
- }
- footer={
- <div key="panel-footer" className="flex w-full items-center justify-between">
+ <form onSubmit={handleSubmit}>
+ <Panel
+ title={
+ <div key="panel-title">
+ <h4>Create a new organization</h4>
+ </div>
+ }
+ footer={
+ <div key="panel-footer" className="flex w-full items-center justify-between">
+ <Button
+ type="default"
+ disabled={newOrgLoading}
+ onClick={() => router.push('/projects')}
+ >
+ Cancel
+ </Button>
+ <div className="flex items-center space-x-3">
+ <p className="text-xs text-foreground-lighter">
+ You can rename your organization later
+ </p>
<Button
- type="default"
+ htmlType="submit"
+ type="primary"
+ loading={newOrgLoading}
disabled={newOrgLoading}
- onClick={() => router.push('/projects')}
>
- Cancel
+ Create organization
</Button>
- <div className="flex items-center space-x-3">
- <p className="text-xs text-foreground-lighter">
- You can rename your organization later
- </p>
- <Button
- htmlType="submit"
- type="primary"
- loading={newOrgLoading}
- disabled={newOrgLoading}
- >
- Create organization
- </Button>
- </div>
</div>
- }
- >
- <Panel.Content>
- <p className="text-sm">This is your organization within Supabase.</p>
- <p className="text-sm text-foreground-light">
- For example, you can use the name of your company or department.
- </p>
- </Panel.Content>
- <Panel.Content className="Form section-block--body has-inputs-centered">
- <Input
- autoFocus
- label="Name"
- type="text"
- layout="horizontal"
- placeholder="Organization name"
- descriptionText="What's the name of your company or team?"
- value={orgName}
- onChange={onOrgNameChange}
- />
- </Panel.Content>
+ </div>
+ }
+ >
+ <Panel.Content>
+ <p className="text-sm">This is your organization within Supabase.</p>
+ <p className="text-sm text-foreground-light">
+ For example, you can use the name of your company or department.
+ </p>
+ </Panel.Content>
+ <Panel.Content className="Form section-block--body has-inputs-centered">
+ <Input
+ autoFocus
+ label="Name"
+ type="text"
+ layout="horizontal"
+ placeholder="Organization name"
+ descriptionText="What's the name of your company or team?"
+ value={orgName}
+ onChange={onOrgNameChange}
+ />
+ </Panel.Content>
+ <Panel.Content className="Form section-block--body has-inputs-centered">
+ <Listbox
+ label="Type of organization"
+ layout="horizontal"
+ value={orgKind}
+ onChange={onOrgKindChange}
+ descriptionText="What would best describe your organization?"
+ >
+ {Object.entries(ORG_KIND_TYPES).map(([k, v]) => {
+ return (
+ <Listbox.Option key={k} label={v} value={k}>
+ {v}
+ </Listbox.Option>
+ )
+ })}
+ </Listbox>
+ </Panel.Content>
+
+ {orgKind == 'COMPANY' ? (
<Panel.Content className="Form section-block--body has-inputs-centered">
<Listbox
- label="Type of organization"
+ label="Company size"
layout="horizontal"
- value={orgKind}
- onChange={onOrgKindChange}
- descriptionText="What would best describe your organization?"
+ value={orgSize}
+ onChange={onOrgSizeChange}
+ descriptionText="How many people are in your company?"
>
- {Object.entries(ORG_KIND_TYPES).map(([k, v]) => {
+ {Object.entries(ORG_SIZE_TYPES).map(([k, v]) => {
return (
<Listbox.Option key={k} label={v} value={k}>
{v}
@@ -238,140 +256,120 @@ const NewOrgForm = ({ onPaymentMethodReset }: NewOrgFormProps) => {
})}
</Listbox>
</Panel.Content>
-
- {orgKind == 'COMPANY' ? (
- <Panel.Content className="Form section-block--body has-inputs-centered">
- <Listbox
- label="Company size"
+ ) : (
+ <></>
+ )}
+
+ <Panel.Content>
+ <Listbox
+ label="Pricing Plan"
+ layout="horizontal"
+ value={dbPricingTierKey}
+ // @ts-ignore
+ onChange={onDbPricingPlanChange}
+ // @ts-ignore
+ descriptionText={
+ <>
+ Select a plan that suits your needs.&nbsp;
+ <a
+ className="underline"
+ target="_blank"
+ rel="noreferrer"
+ href="https://supabase.com/pricing"
+ >
+ More details
+ </a>
+ </>
+ }
+ >
+ {Object.entries(PRICING_TIER_LABELS_ORG).map(([k, v]) => {
+ return (
+ <Listbox.Option key={k} label={v} value={k}>
+ {v}
+ </Listbox.Option>
+ )
+ })}
+ </Listbox>
+ </Panel.Content>
+
+ {dbPricingTierKey === 'PRO' && (
+ <>
+ <Panel.Content className="border-b border-panel-border-interior-light dark:border-panel-border-interior-dark">
+ <Toggle
+ id="spend-cap"
layout="horizontal"
- value={orgSize}
- onChange={onOrgSizeChange}
- descriptionText="How many people are in your company?"
- >
- {Object.entries(ORG_SIZE_TYPES).map(([k, v]) => {
- return (
- <Listbox.Option key={k} label={v} value={k}>
- {v}
- </Listbox.Option>
- )
- })}
- </Listbox>
- </Panel.Content>
- ) : (
- <></>
- )}
-
- <Panel.Content>
- <Listbox
- label="Pricing Plan"
- layout="horizontal"
- value={dbPricingTierKey}
- // @ts-ignore
- onChange={onDbPricingPlanChange}
- // @ts-ignore
- descriptionText={
- <>
- Select a plan that suits your needs.&nbsp;
- <a
- className="underline"
- target="_blank"
- rel="noreferrer"
- href="https://supabase.com/pricing"
- >
- More details
- </a>
- </>
- }
- >
- {Object.entries(PRICING_TIER_LABELS_ORG).map(([k, v]) => {
- return (
- <Listbox.Option key={k} label={v} value={k}>
- {v}
- </Listbox.Option>
- )
- })}
- </Listbox>
- </Panel.Content>
-
- {dbPricingTierKey === 'PRO' && (
- <>
- <Panel.Content className="border-b border-panel-border-interior-light dark:border-panel-border-interior-dark">
- <Toggle
- id="spend-cap"
- layout="horizontal"
- label={
- <div className="flex space-x-4">
- <span>Spend Cap</span>
- <IconHelpCircle
- size={16}
- strokeWidth={1.5}
- className="transition opacity-50 cursor-pointer hover:opacity-100"
- onClick={() => setShowSpendCapHelperModal(true)}
- />
- </div>
- }
- checked={isSpendCapEnabled}
- onChange={() => setIsSpendCapEnabled(!isSpendCapEnabled)}
- descriptionText={
- <div>
- <p>
- By default, Pro plan organizations have a spend cap to control costs. When
- enabled, usage is limited to the plan's quota, with restrictions when limits
- are exceeded. To scale beyond Pro limits without restrictions, disable the
- spend cap and pay for over-usage beyond the quota.
- </p>
- </div>
- }
- />
- </Panel.Content>
-
- <SpendCapModal
- visible={showSpendCapHelperModal}
- onHide={() => setShowSpendCapHelperModal(false)}
- />
- </>
- )}
-
- {dbPricingTierKey !== 'FREE' && (
- <Panel.Content>
- {paymentMethod?.card !== undefined ? (
- <div key={paymentMethod.id} className="flex items-center justify-between">
- <div className="flex items-center space-x-8">
- <img
- alt="Card"
- src={`${BASE_PATH}/img/payment-methods/${paymentMethod.card.brand
- .replace(' ', '-')
- .toLowerCase()}.png`}
- width="32"
- />
- <Input
- readOnly
- className="w-64"
- size="small"
- value={`•••• •••• •••• ${paymentMethod.card.last4}`}
+ label={
+ <div className="flex space-x-4">
+ <span>Spend Cap</span>
+ <IconHelpCircle
+ size={16}
+ strokeWidth={1.5}
+ className="transition opacity-50 cursor-pointer hover:opacity-100"
+ onClick={() => setShowSpendCapHelperModal(true)}
/>
- <p className="text-sm tabular-nums">
- Expires: {paymentMethod.card.exp_month}/{paymentMethod.card.exp_year}
- </p>
</div>
+ }
+ checked={isSpendCapEnabled}
+ onChange={() => setIsSpendCapEnabled(!isSpendCapEnabled)}
+ descriptionText={
<div>
- <Button
- type="outline"
- icon={<IconEdit2 />}
- onClick={() => resetPaymentMethod()}
- disabled={newOrgLoading}
- className="hover:border-muted"
- />
+ <p>
+ By default, Pro plan organizations have a spend cap to control costs. When
+ enabled, usage is limited to the plan's quota, with restrictions when limits
+ are exceeded. To scale beyond Pro limits without restrictions, disable the
+ spend cap and pay for over-usage beyond the quota.
+ </p>
</div>
- </div>
- ) : (
- <PaymentElement />
- )}
+ }
+ />
</Panel.Content>
- )}
- </Panel>
- </form>
- </>
+
+ <SpendCapModal
+ visible={showSpendCapHelperModal}
+ onHide={() => setShowSpendCapHelperModal(false)}
+ />
+ </>
+ )}
+
+ {dbPricingTierKey !== 'FREE' && (
+ <Panel.Content>
+ {paymentMethod?.card !== undefined ? (
+ <div key={paymentMethod.id} className="flex items-center justify-between">
+ <div className="flex items-center space-x-8">
+ <img
+ alt="Card"
+ src={`${BASE_PATH}/img/payment-methods/${paymentMethod.card.brand
+ .replace(' ', '-')
+ .toLowerCase()}.png`}
+ width="32"
+ />
+ <Input
+ readOnly
+ className="w-64"
+ size="small"
+ value={`•••• •••• •••• ${paymentMethod.card.last4}`}
+ />
+ <p className="text-sm tabular-nums">
+ Expires: {paymentMethod.card.exp_month}/{paymentMethod.card.exp_year}
+ </p>
+ </div>
+ <div>
+ <Button
+ type="outline"
+ icon={<IconEdit2 />}
+ onClick={() => resetPaymentMethod()}
+ disabled={newOrgLoading}
+ className="hover:border-muted"
+ />
+ </div>
+ </div>
+ ) : (
+ <PaymentElement />
+ )}
+ </Panel.Content>
+ )}
+ </Panel>
+ </form>
)
}
diff --git a/apps/studio/components/interfaces/Organization/TeamSettings/InviteMemberButton.tsx b/apps/studio/components/interfaces/Organization/TeamSettings/InviteMemberButton.tsx
index a598a88e5bb..70326da0578 100644
--- a/apps/studio/components/interfaces/Organization/TeamSettings/InviteMemberButton.tsx
+++ b/apps/studio/components/interfaces/Organization/TeamSettings/InviteMemberButton.tsx
@@ -47,7 +47,7 @@ const InviteMemberButton = ({
role: string().required('Role is required'),
})
- const { mutateAsync: inviteMember, isLoading: isInviting } =
+ const { mutate: inviteMember, isLoading: isInviting } =
useOrganizationMemberInviteCreateMutation()
const onInviteMember = async (values: any, { resetForm }: any) => {
@@ -68,21 +68,25 @@ const InviteMemberButton = ({
const roleId = Number(values.role)
- try {
- const response = await inviteMember({
+ inviteMember(
+ {
slug,
invitedEmail: values.email.toLowerCase(),
ownerId: userId,
roleId,
- })
- if (isNil(response)) {
- toast.error('Failed to add member')
- } else {
- toast.success('Successfully added new member')
- setIsOpen(!isOpen)
- resetForm({ initialValues: { ...initialValues, role: roleId } })
+ },
+ {
+ onSuccess: (data) => {
+ if (isNil(data)) {
+ toast.error('Failed to add member')
+ } else {
+ toast.success('Successfully added new member')
+ setIsOpen(!isOpen)
+ resetForm({ initialValues: { ...initialValues, role: roleId } })
+ }
+ },
}
- } catch (error) {}
+ )
}
return (
diff --git a/apps/studio/components/interfaces/Organization/TeamSettings/MemberActions.tsx b/apps/studio/components/interfaces/Organization/TeamSettings/MemberActions.tsx
index e905e0ff003..92236c4497d 100644
--- a/apps/studio/components/interfaces/Organization/TeamSettings/MemberActions.tsx
+++ b/apps/studio/components/interfaces/Organization/TeamSettings/MemberActions.tsx
@@ -73,7 +73,7 @@ const MemberActions = ({ member, roles }: MemberActionsProps) => {
},
})
- const { mutateAsync: asyncDeleteMemberInvite, isLoading: isDeletingInvite } =
+ const { mutate: asyncDeleteMemberInvite, isLoading: isDeletingInvite } =
useOrganizationMemberInviteDeleteMutation()
const handleMemberDelete = async () => {
@@ -89,13 +89,19 @@ const MemberActions = ({ member, roles }: MemberActionsProps) => {
if (!slug) return console.error('Slug is required')
if (!invitedId) return console.error('Member invited ID is required')
- await asyncDeleteMemberInvite({ slug, invitedId, invalidateDetail: false })
- createOrganizationMemberInvite({
- slug,
- invitedEmail: member.primary_email!,
- ownerId: invitedId,
- roleId: roleId,
- })
+ asyncDeleteMemberInvite(
+ { slug, invitedId, invalidateDetail: false },
+ {
+ onSuccess: () => {
+ createOrganizationMemberInvite({
+ slug,
+ invitedEmail: member.primary_email!,
+ ownerId: invitedId,
+ roleId: roleId,
+ })
+ },
+ }
+ )
}
const handleRevokeInvitation = async (member: OrganizationMember) => {
@@ -103,8 +109,14 @@ const MemberActions = ({ member, roles }: MemberActionsProps) => {
if (!slug) return console.error('Slug is required')
if (!invitedId) return console.error('Member invited ID is required')
- await asyncDeleteMemberInvite({ slug, invitedId })
- toast.success('Successfully revoked the invitation.')
+ asyncDeleteMemberInvite(
+ { slug, invitedId },
+ {
+ onSuccess: () => {
+ toast.success('Successfully revoked the invitation.')
+ },
+ }
+ )
}
if (!canRemoveMember || (isPendingInviteAcceptance && !canResendInvite && !canRevokeInvite)) {
diff --git a/apps/studio/components/interfaces/Organization/TeamSettings/TeamSettings.tsx b/apps/studio/components/interfaces/Organization/TeamSettings/TeamSettings.tsx
index 7c48c266479..1274896d030 100644
--- a/apps/studio/components/interfaces/Organization/TeamSettings/TeamSettings.tsx
+++ b/apps/studio/components/interfaces/Organization/TeamSettings/TeamSettings.tsx
@@ -1,4 +1,5 @@
import * as Tooltip from '@radix-ui/react-tooltip'
+import { Search } from 'lucide-react'
import { useState } from 'react'
import toast from 'react-hot-toast'
@@ -16,7 +17,7 @@ import { useOrganizationRolesQuery } from 'data/organizations/organization-roles
import { usePermissionsQuery } from 'data/permissions/permissions-query'
import { useIsFeatureEnabled, useSelectedOrganization } from 'hooks'
import { useProfile } from 'lib/profile'
-import { Button, IconSearch, Input, Modal } from 'ui'
+import { Button, Input } from 'ui'
import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
import InviteMemberButton from './InviteMemberButton'
import MembersView from './MembersView'
@@ -52,22 +53,25 @@ const TeamSettings = () => {
const canAddMembers = rolesAddable.length > 0
const canLeave = !isOwner || (isOwner && hasMultipleOwners(members, roles))
- const { mutateAsync: deleteMember } = useOrganizationMemberDeleteMutation()
+ const { mutate: deleteMember } = useOrganizationMemberDeleteMutation({
+ onSuccess: () => {
+ setIsLeaving(false)
+ setIsLeaveTeamModalOpen(false)
+ window?.location.replace('/') // Force reload to clear Store
+ },
+ onError: (error) => {
+ setIsLeaving(false)
+ toast.error(`Failed to leave organization: ${error?.message}`)
+ },
+ })
const [isLeaveTeamModalOpen, setIsLeaveTeamModalOpen] = useState(false)
const leaveTeam = async () => {
+ if (!slug) return console.error('Org slug is required')
+
setIsLeaving(true)
- try {
- if (!slug) return console.error('Org slug is required')
- await deleteMember({ slug, gotrueId: profile!.gotrue_id })
- setIsLeaveTeamModalOpen(false)
- window?.location.replace('/') // Force reload to clear Store
- } catch (error: any) {
- toast.error(`Failed to leave organization: ${error?.message}`)
- } finally {
- setIsLeaving(false)
- }
+ deleteMember({ slug, gotrueId: profile!.gotrue_id })
}
return (
@@ -76,7 +80,7 @@ const TeamSettings = () => {
<ScaffoldFilterAndContent>
<ScaffoldActionsContainer className="justify-between">
<Input
- icon={<IconSearch size="tiny" />}
+ icon={<Search size={12} />}
size="small"
value={searchString}
onChange={(e: any) => setSearchString(e.target.value)}
diff --git a/apps/studio/components/interfaces/QueryPerformance/IndexAdvisorDisabledState.tsx b/apps/studio/components/interfaces/QueryPerformance/IndexAdvisorDisabledState.tsx
index f25c2cf93ce..523cccf5acb 100644
--- a/apps/studio/components/interfaces/QueryPerformance/IndexAdvisorDisabledState.tsx
+++ b/apps/studio/components/interfaces/QueryPerformance/IndexAdvisorDisabledState.tsx
@@ -1,12 +1,12 @@
import { ExternalLink } from 'lucide-react'
+import Link from 'next/link'
+import { useParams } from 'common'
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
import { useDatabaseExtensionEnableMutation } from 'data/database-extensions/database-extension-enable-mutation'
import { useDatabaseExtensionsQuery } from 'data/database-extensions/database-extensions-query'
import { AlertDescription_Shadcn_, AlertTitle_Shadcn_, Alert_Shadcn_, Button } from 'ui'
import { Markdown } from '../Markdown'
-import Link from 'next/link'
-import { useParams } from 'common'
export const IndexAdvisorDisabledState = () => {
const { ref } = useParams()
@@ -23,23 +23,27 @@ export const IndexAdvisorDisabledState = () => {
const onEnableIndexAdvisor = async () => {
if (project === undefined) return console.error('Project is required')
- if (hypopgExtension?.installed_version === null) {
- await enableExtension({
- projectRef: project?.ref,
- connectionString: project?.connectionString,
- name: hypopgExtension.name,
- schema: hypopgExtension?.schema ?? 'extensions',
- version: hypopgExtension.default_version,
- })
- }
- if (indexAdvisorExtension?.installed_version === null) {
- await enableExtension({
- projectRef: project?.ref,
- connectionString: project?.connectionString,
- name: indexAdvisorExtension.name,
- schema: indexAdvisorExtension?.schema ?? 'extensions',
- version: indexAdvisorExtension.default_version,
- })
+
+ try {
+ if (hypopgExtension?.installed_version === null) {
+ await enableExtension({
+ projectRef: project?.ref,
+ connectionString: project?.connectionString,
+ name: hypopgExtension.name,
+ schema: hypopgExtension?.schema ?? 'extensions',
+ version: hypopgExtension.default_version,
+ })
+ }
+ if (indexAdvisorExtension?.installed_version === null) {
+ await enableExtension({
+ projectRef: project?.ref,
+ connectionString: project?.connectionString,
+ name: indexAdvisorExtension.name,
+ schema: indexAdvisorExtension?.schema ?? 'extensions',
+ version: indexAdvisorExtension.default_version,
+ })
+ }
+ } finally {
}
}
diff --git a/apps/studio/components/interfaces/Reports/Reports.CreateReportModal.tsx b/apps/studio/components/interfaces/Reports/Reports.CreateReportModal.tsx
index 455ff463698..d50b77781e3 100644
--- a/apps/studio/components/interfaces/Reports/Reports.CreateReportModal.tsx
+++ b/apps/studio/components/interfaces/Reports/Reports.CreateReportModal.tsx
@@ -1,8 +1,9 @@
+import { useRouter } from 'next/router'
+import toast from 'react-hot-toast'
+
import { useContentInsertMutation } from 'data/content/content-insert-mutation'
import { useSelectedProject } from 'hooks'
import { uuidv4 } from 'lib/helpers'
-import { useRouter } from 'next/router'
-import toast from 'react-hot-toast'
import { Button, Form, Input, Modal } from 'ui'
type CustomReport = { name: string; description?: string }
@@ -13,46 +14,48 @@ export interface CreateReportModal {
}
export const CreateReportModal = ({ visible, onCancel, afterSubmit }: CreateReportModal) => {
+ const router = useRouter()
const project = useSelectedProject()
- const insertReport = useContentInsertMutation()
const ref = project?.ref ?? 'default'
- const router = useRouter()
+
+ const { mutate: insertReport, isLoading: isCreating } = useContentInsertMutation({
+ onSuccess: (data) => {
+ toast.success('Successfully created new report')
+ const newReportId = data[0].id
+ router.push(`/project/${ref}/reports/${newReportId}`)
+ afterSubmit()
+ },
+ onError: (error) => {
+ toast.error(`Failed to create report: ${error.message}`)
+ },
+ })
async function createCustomReport({ name, description }: { name: string; description?: string }) {
- try {
- if (!ref) return
+ if (!ref) return
- const res = await insertReport.mutateAsync({
- projectRef: ref,
- payload: {
- id: uuidv4(),
- type: 'report',
- name,
- description: description || '',
- visibility: 'project',
- content: {
- schema_version: 1,
- period_start: {
- time_period: '7d',
- date: '',
- },
- period_end: {
- time_period: 'today',
- date: '',
- },
- interval: '1d',
- layout: [],
+ insertReport({
+ projectRef: ref,
+ payload: {
+ id: uuidv4(),
+ type: 'report',
+ name,
+ description: description || '',
+ visibility: 'project',
+ content: {
+ schema_version: 1,
+ period_start: {
+ time_period: '7d',
+ date: '',
},
+ period_end: {
+ time_period: 'today',
+ date: '',
+ },
+ interval: '1d',
+ layout: [],
},
- })
- toast.success('New report created')
- const newReportId = res[0].id
- router.push(`/project/${ref}/reports/${newReportId}`)
- afterSubmit()
- } catch (error) {
- toast.error(`Failed to create report. Check console for more details.`)
- console.error(error)
- }
+ },
+ })
}
return (
@@ -78,7 +81,7 @@ export const CreateReportModal = ({ visible, onCancel, afterSubmit }: CreateRepo
}}
onSubmit={(newVals) => createCustomReport(newVals)}
>
- {({ isSubmitting }: { isSubmitting: boolean }) => (
+ {() => (
<div className="space-y-4 py-4">
<Modal.Content>
<Input label="Name" id="name" name="name" />
@@ -95,10 +98,10 @@ export const CreateReportModal = ({ visible, onCancel, afterSubmit }: CreateRepo
<Modal.Separator />
<Modal.Content>
<div className="flex items-center justify-end gap-2">
- <Button htmlType="reset" type="default" onClick={onCancel} disabled={isSubmitting}>
+ <Button htmlType="reset" type="default" onClick={onCancel} disabled={isCreating}>
Cancel
</Button>
- <Button htmlType="submit" loading={isSubmitting} disabled={isSubmitting}>
+ <Button htmlType="submit" loading={isCreating} disabled={isCreating}>
Create report
</Button>
</div>
diff --git a/apps/studio/components/interfaces/Reports/Reports.UpdateModal.tsx b/apps/studio/components/interfaces/Reports/Reports.UpdateModal.tsx
index d305f58e114..9a903322da2 100644
--- a/apps/studio/components/interfaces/Reports/Reports.UpdateModal.tsx
+++ b/apps/studio/components/interfaces/Reports/Reports.UpdateModal.tsx
@@ -1,33 +1,60 @@
+import { useParams } from 'common'
+import { Content } from 'data/content/content-query'
+import { useContentUpsertMutation } from 'data/content/content-upsert-mutation'
+import toast from 'react-hot-toast'
import { Button, Form, Input, Modal } from 'ui'
type CustomReport = { name: string; description?: string }
export interface UpdateCustomReportProps {
- visible: boolean
- onCancel: () => void
- onSubmit: (newValues: CustomReport) => void
+ selectedReport?: Content
initialValues: CustomReport
+ onCancel: () => void
}
export const UpdateCustomReportModal = ({
- visible,
- onCancel,
- onSubmit,
+ selectedReport,
initialValues,
+ onCancel,
}: UpdateCustomReportProps) => {
- function validate(values: CustomReport) {
- const errors: Partial<CustomReport> = {}
+ const { ref } = useParams()
+ const { mutate: updateReport } = useContentUpsertMutation({
+ onSuccess: () => {
+ toast.success('Successfully updated report')
+ onCancel()
+ },
+ onError: (error) => {
+ toast.error(`Failed to update report: ${error.message}`)
+ },
+ })
+
+ const onConfirmUpdateReport = (newVals: { name: string; description?: string }) => {
+ if (!ref) return console.error('Project ref is required')
+ if (!selectedReport) return
+ if (!selectedReport.id) return
+ if (!selectedReport.project_id) return
- if (!values.name) {
- errors.name = 'Required'
- }
+ updateReport({
+ projectRef: ref,
+ payload: {
+ ...selectedReport,
+ project_id: selectedReport.project_id,
+ id: selectedReport.id,
+ name: newVals.name,
+ description: newVals.description || '',
+ },
+ })
+ }
+ function validate(values: CustomReport) {
+ const errors: Partial<CustomReport> = {}
+ if (!values.name) errors.name = 'This field is required'
return errors
}
return (
<Modal
- visible={visible}
+ visible={selectedReport !== undefined}
onCancel={onCancel}
hideFooter
header="Update custom report"
@@ -38,7 +65,7 @@ export const UpdateCustomReportModal = ({
validateOnBlur
initialValues={initialValues}
validate={validate}
- onSubmit={onSubmit}
+ onSubmit={onConfirmUpdateReport}
>
{({ isSubmitting }: { isSubmitting: boolean }) => (
<div className="space-y-4 py-4">
diff --git a/apps/studio/components/interfaces/Reports/Reports.tsx b/apps/studio/components/interfaces/Reports/Reports.tsx
index 3a23a1f16d0..8b099984ddb 100644
--- a/apps/studio/components/interfaces/Reports/Reports.tsx
+++ b/apps/studio/components/interfaces/Reports/Reports.tsx
@@ -45,10 +45,14 @@ const Reports = () => {
const [hasEdits, setHasEdits] = useState<any>(false)
const { data: userContents, isLoading } = useContentQuery(ref)
- const { mutateAsync: saveReport, isLoading: isSaving } = useContentUpdateMutation({
+ const { mutate: saveReport, isLoading: isSaving } = useContentUpdateMutation({
onSuccess: () => {
+ setHasEdits(false)
toast.success('Successfully saved report!')
},
+ onError: (error) => {
+ toast.error(`Failed to update report: ${error.message}`)
+ },
})
const currentReport = userContents?.content.find((report) => report.id === id)
@@ -117,10 +121,7 @@ const Reports = () => {
const onSaveReport = async () => {
if (ref === undefined) return console.error('Project ref is required')
if (id === undefined) return console.error('Report ID is required')
-
- await saveReport({ projectRef: ref, id, type: 'report', content: config })
-
- setHasEdits(false)
+ saveReport({ projectRef: ref, id, type: 'report', content: config })
}
function handleChartSelection({ metric, value }: any) {
diff --git a/apps/studio/components/interfaces/SQLEditor/RenameQueryModal.tsx b/apps/studio/components/interfaces/SQLEditor/RenameQueryModal.tsx
index a2de3b21cfd..76aec556466 100644
--- a/apps/studio/components/interfaces/SQLEditor/RenameQueryModal.tsx
+++ b/apps/studio/components/interfaces/SQLEditor/RenameQueryModal.tsx
@@ -56,8 +56,16 @@ const RenameQueryModal = ({ snippet, visible, onCancel, onComplete }: RenameQuer
}
}
- const { mutateAsync: titleSql, isLoading: isTitleGenerationLoading } =
- useSqlTitleGenerateMutation()
+ const { mutate: titleSql, isLoading: isTitleGenerationLoading } = useSqlTitleGenerateMutation({
+ onSuccess: (data) => {
+ const { title, description } = data
+ setNameInput(title)
+ if (!descriptionInput) setDescriptionInput(description)
+ },
+ onError: (error) => {
+ toast.error(`Failed to rename query: ${error.message}`)
+ },
+ })
const isAiButtonVisible = !!snippet.content.sql
@@ -87,24 +95,7 @@ const RenameQueryModal = ({ snippet, visible, onCancel, onComplete }: RenameQuer
{!hasHipaaAddon && isAiButtonVisible && (
<Button
type="default"
- onClick={async () => {
- try {
- const { title, description } = await titleSql({
- sql: snippet.content.sql,
- })
-
- setNameInput(title)
-
- // Only update description if it was empty
- if (!descriptionInput) {
- setDescriptionInput(description)
- }
- } catch (error: unknown) {
- if (isError(error)) {
- toast.error(`Failed to rename query: ${error.message}`)
- }
- }
- }}
+ onClick={() => titleSql({ sql: snippet.content.sql })}
size="tiny"
disabled={isTitleGenerationLoading}
>
diff --git a/apps/studio/components/interfaces/SQLEditor/SQLEditor.tsx b/apps/studio/components/interfaces/SQLEditor/SQLEditor.tsx
index 2be93efde6d..f5f20690bff 100644
--- a/apps/studio/components/interfaces/SQLEditor/SQLEditor.tsx
+++ b/apps/studio/components/interfaces/SQLEditor/SQLEditor.tsx
@@ -222,9 +222,11 @@ const SQLEditor = () => {
*/
const setAiTitle = useCallback(
async (id: string, sql: string) => {
- const { title } = await generateSqlTitle({ sql })
-
- snap.renameSnippet(id, title)
+ try {
+ const { title } = await generateSqlTitle({ sql })
+ snap.renameSnippet(id, title)
+ } finally {
+ }
},
[generateSqlTitle, snap]
)
diff --git a/apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityPanel.tsx b/apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityPanel.tsx
index 5137718984a..308400594a8 100644
--- a/apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityPanel.tsx
+++ b/apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityPanel.tsx
@@ -39,13 +39,15 @@ const UtilityPanel = ({
executeQuery,
onDebug,
}: UtilityPanelProps) => {
- const snap = useSqlEditorStateSnapshot()
const { ref } = useParams()
- const snippet = snap.snippets[id]?.snippet
+ const queryClient = useQueryClient()
+ const snap = useSqlEditorStateSnapshot()
+ const snippet = snap.snippets[id]?.snippet
const queryKeys = contentKeys.list(ref)
+ const result = snap.results[id]?.[0]
- const upsertContent = useContentUpsertMutation({
+ const { mutate: upsertContent } = useContentUpsertMutation({
invalidateQueriesOnSuccess: false,
// Optimistic update to the cache
onMutate: async (newContentSnippet) => {
@@ -72,7 +74,6 @@ const UtilityPanel = ({
toast.error(`Failed to update chart. Please try again.`)
},
})
- const queryClient = useQueryClient()
function getChartConfig() {
if (!snippet || snippet.type !== 'sql') {
@@ -88,14 +89,10 @@ const UtilityPanel = ({
const chartConfig = getChartConfig()
- const result = snap.results[id]?.[0]
-
function onConfigChange(config: ChartConfig) {
- if (!ref || !snippet.id) {
- return
- }
+ if (!ref || !snippet.id) return
- upsertContent.mutateAsync({
+ upsertContent({
projectRef: ref,
payload: {
...snippet,
diff --git a/apps/studio/components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling.tsx b/apps/studio/components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling.tsx
index 2f4ec27f315..e11e2309876 100644
--- a/apps/studio/components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling.tsx
+++ b/apps/studio/components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling.tsx
@@ -113,7 +113,7 @@ export const ConnectionPooling = () => {
},
})
- const { mutateAsync: updateConfiguration, isLoading: isUpdating } =
+ const { mutate: updateConfiguration, isLoading: isUpdating } =
usePoolingConfigurationUpdateMutation({
onSuccess: (data) => {
if (data) {
@@ -131,14 +131,11 @@ export const ConnectionPooling = () => {
if (!projectRef) return console.error('Project ref is required')
if (!poolingInfo) return console.error('Pooling info required')
- try {
- await updateConfiguration({
- ref: projectRef,
- default_pool_size: data.default_pool_size as number | undefined,
- pool_mode: data.pool_mode,
- })
- } finally {
- }
+ updateConfiguration({
+ ref: projectRef,
+ default_pool_size: data.default_pool_size as number | undefined,
+ pool_mode: data.pool_mode,
+ })
}
useEffect(() => {
diff --git a/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/AddRestrictionModal.tsx b/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/AddRestrictionModal.tsx
index 93eee97c9f0..c12b49908db 100644
--- a/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/AddRestrictionModal.tsx
+++ b/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/AddRestrictionModal.tsx
@@ -69,8 +69,12 @@ const AddRestrictionModal = ({
return errors
}
- const isPrivate = checkIfPrivate(type, ipAddress)
- if (isPrivate) errors.ipAddress = 'Private IP addresses are not supported'
+ try {
+ const isPrivate = checkIfPrivate(type, ipAddress)
+ if (isPrivate) errors.ipAddress = 'Private IP addresses are not supported'
+ } catch (error: any) {
+ errors.ipAddress = error.message
+ }
return errors
}
diff --git a/apps/studio/components/interfaces/Settings/General/DeleteProjectPanel/DeleteProjectButton.tsx b/apps/studio/components/interfaces/Settings/General/DeleteProjectPanel/DeleteProjectButton.tsx
index caf5bcf3a32..732e9991236 100644
--- a/apps/studio/components/interfaces/Settings/General/DeleteProjectPanel/DeleteProjectButton.tsx
+++ b/apps/studio/components/interfaces/Settings/General/DeleteProjectPanel/DeleteProjectButton.tsx
@@ -2,9 +2,8 @@ import * as Tooltip from '@radix-ui/react-tooltip'
import { PermissionAction } from '@supabase/shared-types/out/constants'
import { useRouter } from 'next/router'
import { useEffect, useState } from 'react'
-import { Button, Input } from 'ui'
import toast from 'react-hot-toast'
-import TextConfirmModal from 'ui-patterns/Dialogs/TextConfirmModal'
+import { Button, Input } from 'ui'
import { CANCELLATION_REASONS } from 'components/interfaces/Billing/Billing.constants'
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
@@ -12,6 +11,7 @@ import { useSendDowngradeFeedbackMutation } from 'data/feedback/exit-survey-send
import { useProjectDeleteMutation } from 'data/projects/project-delete-mutation'
import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'
import { useCheckPermissions, useSelectedOrganization } from 'hooks'
+import TextConfirmModal from 'ui-patterns/Dialogs/TextConfirmModal'
export interface DeleteProjectButtonProps {
type?: 'danger' | 'default'
@@ -31,7 +31,24 @@ const DeleteProjectButton = ({ type = 'danger' }: DeleteProjectButtonProps) => {
const [message, setMessage] = useState<string>('')
const [selectedReasons, setSelectedReasons] = useState<string[]>([])
- const { mutateAsync: deleteProject, isLoading: isDeleting } = useProjectDeleteMutation()
+ const { mutate: deleteProject, isLoading: isDeleting } = useProjectDeleteMutation({
+ onSuccess: async () => {
+ if (!isFree) {
+ try {
+ await sendExitSurvey({
+ projectRef,
+ message,
+ reasons: selectedReasons.reduce((a, b) => `${a}- ${b}\n`, ''),
+ exitAction: 'delete',
+ })
+ } finally {
+ }
+ }
+
+ toast.success(`Successfully deleted ${project?.name}`)
+ router.push(`/projects`)
+ },
+ })
const { mutateAsync: sendExitSurvey, isLoading: isSending } = useSendDowngradeFeedbackMutation()
const isSubmitting = isDeleting || isSending
@@ -64,27 +81,11 @@ const DeleteProjectButton = ({ type = 'danger' }: DeleteProjectButtonProps) => {
async function handleDeleteProject() {
if (project === undefined) return
-
if (!isFree && selectedReasons.length === 0) {
return toast.error('Please select at least one reason for deleting your project')
}
- try {
- await deleteProject({ projectRef: project.ref })
-
- if (!isFree) {
- await sendExitSurvey({
- projectRef,
- message,
- reasons: selectedReasons.reduce((a, b) => `${a}- ${b}\n`, ''),
- exitAction: 'delete',
- })
- }
-
- toast.success(`Successfully deleted ${project.name}`)
- router.push(`/projects`)
- } finally {
- }
+ deleteProject({ projectRef: project.ref })
}
return (
diff --git a/apps/studio/components/interfaces/Settings/General/General.tsx b/apps/studio/components/interfaces/Settings/General/General.tsx
index d3dd4f92dfc..c9fbf68b6a1 100644
--- a/apps/studio/components/interfaces/Settings/General/General.tsx
+++ b/apps/studio/components/interfaces/Settings/General/General.tsx
@@ -31,6 +31,7 @@ import { useProjectUpdateMutation } from 'data/projects/project-update-mutation'
import { useCheckPermissions, useFlag, useProjectByRef, useSelectedOrganization } from 'hooks'
import PauseProjectButton from './Infrastructure/PauseProjectButton'
import RestartServerButton from './Infrastructure/RestartServerButton'
+import { WarningIcon } from 'ui-patterns/Icons/StatusIcons'
const General = () => {
const { project } = useProjectContext()
@@ -58,15 +59,20 @@ const General = () => {
},
})
- const { mutateAsync: updateProject, isLoading: isUpdating } = useProjectUpdateMutation()
+ const { mutate: updateProject, isLoading: isUpdating } = useProjectUpdateMutation()
const onSubmit = async (values: any, { resetForm }: any) => {
if (!project?.ref) return console.error('Ref is required')
- try {
- const { name } = await updateProject({ ref: project.ref, name: values.name.trim() })
- resetForm({ values: { name }, initialValues: { name } })
- toast.success('Successfully saved settings')
- } catch (error) {}
+
+ updateProject(
+ { ref: project.ref, name: values.name.trim() },
+ {
+ onSuccess: ({ name }) => {
+ resetForm({ values: { name }, initialValues: { name } })
+ toast.success('Successfully saved settings')
+ },
+ }
+ )
}
return (
@@ -75,7 +81,7 @@ const General = () => {
{isBranch && (
<Alert_Shadcn_ variant="default" className="mb-6">
- <IconAlertCircle strokeWidth={2} />
+ <WarningIcon />
<AlertTitle_Shadcn_>
You are currently on a preview branch of your project
</AlertTitle_Shadcn_>
diff --git a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DeployNewReplicaPanel.tsx b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DeployNewReplicaPanel.tsx
index cbcc60d981c..a644c175957 100644
--- a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DeployNewReplicaPanel.tsx
+++ b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DeployNewReplicaPanel.tsx
@@ -147,7 +147,38 @@ const DeployNewReplicaPanel = ({
disabled={!canDeployReplica}
header="Deploy a new read replica"
>
- <SidePanel.Content className="flex flex-col py-4 gap-y-8">
+ <SidePanel.Content className="flex flex-col py-4 gap-y-4">
+ {currentComputeAddon === undefined && (
+ <Alert_Shadcn_>
+ <WarningIcon />
+ <AlertTitle_Shadcn_>
+ Project required to at least be on a Small compute
+ </AlertTitle_Shadcn_>
+ <AlertDescription_Shadcn_>
+ <span>
+ This is to ensure that read replicas can keep up with the primary databases'
+ activities.
+ </span>
+ <div className="flex items-center gap-x-2 mt-3">
+ <Button asChild type="default">
+ <Link href={`/project/${projectRef}/settings/addons?panel=computeInstance`}>
+ Change compute size
+ </Link>
+ </Button>
+ <Button asChild type="default" icon={<ExternalLink size={14} />}>
+ <a
+ href="https://supabase.com/docs/guides/platform/read-replicas#prerequisites"
+ target="_blank"
+ rel="noreferrer"
+ >
+ Documentation
+ </a>
+ </Button>
+ </div>
+ </AlertDescription_Shadcn_>
+ </Alert_Shadcn_>
+ )}
+
{!isWalgEnabled && (
<Alert_Shadcn_>
<WarningIcon />
@@ -196,37 +227,6 @@ const DeployNewReplicaPanel = ({
</Alert_Shadcn_>
)}
- {currentComputeAddon === undefined && (
- <Alert_Shadcn_>
- <WarningIcon />
- <AlertTitle_Shadcn_>
- Project required to at least be on a Small compute
- </AlertTitle_Shadcn_>
- <AlertDescription_Shadcn_>
- <span>
- This is to ensure that read replicas can keep up with the primary databases'
- activities.
- </span>
- <div className="flex items-center gap-x-2 mt-3">
- <Button asChild type="default">
- <Link href={`/project/${projectRef}/settings/addons?panel=computeInstance`}>
- Change compute size
- </Link>
- </Button>
- <Button asChild type="default" icon={<ExternalLink size={14} />}>
- <a
- href="https://supabase.com/docs/guides/platform/read-replicas#prerequisites"
- target="_blank"
- rel="noreferrer"
- >
- Documentation
- </a>
- </Button>
- </div>
- </AlertDescription_Shadcn_>
- </Alert_Shadcn_>
- )}
-
{reachedMaxReplicas && (
<Alert_Shadcn_>
<WarningIcon />
@@ -276,53 +276,55 @@ const DeployNewReplicaPanel = ({
</Alert_Shadcn_>
)}
- <Listbox
- size="small"
- id="region"
- name="region"
- disabled={!canDeployReplica}
- value={selectedRegion}
- onChange={setSelectedRegion}
- label="Select a region to deploy your read replica in"
- >
- {availableRegions.map((region) => (
- <Listbox.Option
- key={region.key}
- label={region.name}
- value={region.key}
- addOnBefore={() => (
- <img
- alt="region icon"
- className="w-5 rounded-sm"
- src={`${BASE_PATH}/img/regions/${region.key}.svg`}
- />
- )}
- >
- {region.name}
- </Listbox.Option>
- ))}
- </Listbox>
+ <div className="flex flex-col gap-y-8">
+ <Listbox
+ size="small"
+ id="region"
+ name="region"
+ disabled={!canDeployReplica}
+ value={selectedRegion}
+ onChange={setSelectedRegion}
+ label="Select a region to deploy your read replica in"
+ >
+ {availableRegions.map((region) => (
+ <Listbox.Option
+ key={region.key}
+ label={region.name}
+ value={region.key}
+ addOnBefore={() => (
+ <img
+ alt="region icon"
+ className="w-5 rounded-sm"
+ src={`${BASE_PATH}/img/regions/${region.key}.svg`}
+ />
+ )}
+ >
+ {region.name}
+ </Listbox.Option>
+ ))}
+ </Listbox>
- <div className="flex flex-col gap-y-2">
- <p className="text-foreground-light text-sm">
- Read replicas will be on the same compute size as your primary database. Deploying a
- read replica incurs additional{' '}
- <span className="text-foreground">{selectedComputeMeta?.name}</span> compute hours.
- Pricing is still in early access and is subject to change.
- </p>
+ <div className="flex flex-col gap-y-2">
+ <p className="text-foreground-light text-sm">
+ Read replicas will be on the same compute size as your primary database. Deploying a
+ read replica incurs additional{' '}
+ <span className="text-foreground">{selectedComputeMeta?.name}</span> compute hours.
+ Pricing is still in early access and is subject to change.
+ </p>
- <p className="text-foreground-light text-sm">
- Read more about{' '}
- <Link
- href="https://supabase.com/docs/guides/platform/org-based-billing#usage-based-billing-for-compute"
- target="_blank"
- rel="noreferrer"
- className="underline hover:text-foreground transition"
- >
- usage-based billing
- </Link>{' '}
- for compute.
- </p>
+ <p className="text-foreground-light text-sm">
+ Read more about{' '}
+ <Link
+ href="https://supabase.com/docs/guides/platform/org-based-billing#usage-based-billing-for-compute"
+ target="_blank"
+ rel="noreferrer"
+ className="underline hover:text-foreground transition"
+ >
+ usage-based billing
+ </Link>{' '}
+ for compute.
+ </p>
+ </div>
</div>
</SidePanel.Content>
</SidePanel>
diff --git a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DropAllReplicasConfirmationModal.tsx b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DropAllReplicasConfirmationModal.tsx
index a56372bfe50..91d48b363e3 100644
--- a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DropAllReplicasConfirmationModal.tsx
+++ b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DropAllReplicasConfirmationModal.tsx
@@ -1,7 +1,7 @@
-import { useParams } from 'common'
+import { useQueryClient } from '@tanstack/react-query'
import toast from 'react-hot-toast'
-import { useQueryClient } from '@tanstack/react-query'
+import { useParams } from 'common'
import { replicaKeys } from 'data/read-replicas/keys'
import { useReadReplicaRemoveMutation } from 'data/read-replicas/replica-remove-mutation'
import { useReadReplicasQuery } from 'data/read-replicas/replicas-query'
@@ -29,24 +29,28 @@ const DropAllReplicasConfirmationModal = ({
if (databases.length === 1) toast('Your project has no read replicas')
const replicas = databases.filter((db) => db.identifier !== projectRef)
- await Promise.all(
- replicas.map((db) =>
- removeReadReplica({
- projectRef,
- identifier: db.identifier,
- invalidateReplicaQueries: false,
- })
+ try {
+ await Promise.all(
+ replicas.map((db) =>
+ removeReadReplica({
+ projectRef,
+ identifier: db.identifier,
+ invalidateReplicaQueries: false,
+ })
+ )
)
- )
- toast.success(`Tearing down all read replicas`)
+ toast.success(`Tearing down all read replicas`)
- await Promise.all([
- queryClient.invalidateQueries(replicaKeys.list(projectRef)),
- queryClient.invalidateQueries(replicaKeys.loadBalancers(projectRef)),
- ])
+ await Promise.all([
+ queryClient.invalidateQueries(replicaKeys.list(projectRef)),
+ queryClient.invalidateQueries(replicaKeys.loadBalancers(projectRef)),
+ ])
- onSuccess()
- onCancel()
+ onSuccess()
+ onCancel()
+ } catch (error) {
+ toast.error('Failed to drop all replicas')
+ }
}
return (
diff --git a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DropReplicaConfirmationModal.tsx b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DropReplicaConfirmationModal.tsx
index 3f5c1734f95..965e5d9485b 100644
--- a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DropReplicaConfirmationModal.tsx
+++ b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DropReplicaConfirmationModal.tsx
@@ -19,7 +19,7 @@ const DropReplicaConfirmationModal = ({
}: DropReplicaConfirmationModalProps) => {
const { ref: projectRef } = useParams()
const formattedId = formatDatabaseID(selectedReplica?.identifier ?? '')
- const { mutateAsync: removeReadReplica, isLoading: isRemoving } = useReadReplicaRemoveMutation({
+ const { mutate: removeReadReplica, isLoading: isRemoving } = useReadReplicaRemoveMutation({
onSuccess: () => {
toast.success(`Tearing down read replica (ID: ${formattedId})`)
onSuccess()
@@ -31,7 +31,7 @@ const DropReplicaConfirmationModal = ({
if (!projectRef) return console.error('Project is required')
if (selectedReplica === undefined) return toast.error('No replica selected')
- await removeReadReplica({
+ removeReadReplica({
projectRef,
identifier: selectedReplica.identifier,
invalidateReplicaQueries: true,
diff --git a/apps/studio/components/interfaces/Settings/Logs/Logs.SavedQueriesItem.tsx b/apps/studio/components/interfaces/Settings/Logs/Logs.SavedQueriesItem.tsx
index c72039b9996..dc2700593b4 100644
--- a/apps/studio/components/interfaces/Settings/Logs/Logs.SavedQueriesItem.tsx
+++ b/apps/studio/components/interfaces/Settings/Logs/Logs.SavedQueriesItem.tsx
@@ -2,8 +2,8 @@ import { useRouter } from 'next/router'
import { useState } from 'react'
import toast from 'react-hot-toast'
+import { useParams } from 'common'
import Table from 'components/to-be-cleaned/Table'
-import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
import { useContentDeleteMutation } from 'data/content/content-delete-mutation'
import { useContentUpsertMutation } from 'data/content/content-upsert-mutation'
import {
@@ -17,8 +17,8 @@ import {
IconMoreVertical,
IconPlay,
IconTrash,
- Modal,
} from 'ui'
+import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
import SqlSnippetCode from './Logs.SqlSnippetCode'
import { UpdateSavedQueryModal } from './Logs.UpdateSavedQueryModal'
import { timestampLocalFormatter } from './LogsFormatters'
@@ -28,29 +28,34 @@ interface SavedQueriesItemProps {
}
const SavedQueriesItem = ({ item }: SavedQueriesItemProps) => {
+ const router = useRouter()
+ const { ref } = useParams()
const [expand, setExpand] = useState<boolean>(false)
const [showConfirmModal, setShowConfirmModal] = useState<boolean>(false)
const [showUpdateModal, setShowUpdateModal] = useState<boolean>(false)
- const { mutateAsync: deleteContent } = useContentDeleteMutation()
- const { mutateAsync: updateContent } = useContentUpsertMutation()
-
- const router = useRouter()
- const { ref } = router.query
+ const { mutate: deleteContent } = useContentDeleteMutation({
+ onSuccess: () => {
+ setShowConfirmModal(false)
+ toast.success('Successfully deleted query')
+ },
+ onError: (error) => {
+ toast.error(`Failed to delete saved query: ${error.message}`)
+ },
+ })
+ const { mutate: updateContent } = useContentUpsertMutation({
+ onSuccess: () => {
+ setShowUpdateModal(false)
+ toast.success('Successfully updated query')
+ },
+ onError: (error) => {
+ toast.error(`Failed to update query: ${error.message}`)
+ },
+ })
const onConfirmDelete = async () => {
- try {
- if (!ref || typeof ref !== 'string') {
- console.error('Invalid project reference')
- return
- }
- await deleteContent({ projectRef: ref, ids: [item.id] })
- setShowConfirmModal(false)
- toast.success('Query deleted')
- } catch (error) {
- toast.error(`Failed to delete saved query. Check the console for more details.`)
- console.error('Failed to delete saved query', error)
- }
+ if (!ref || typeof ref !== 'string') return console.error('Invalid project reference')
+ deleteContent({ projectRef: ref, ids: [item.id] })
}
const onConfirmUpdate = async ({
@@ -60,13 +65,8 @@ const SavedQueriesItem = ({ item }: SavedQueriesItemProps) => {
name: string
description: string | null
}) => {
- if (!ref || typeof ref !== 'string') {
- console.error('Invalid project reference')
- return
- }
- await updateContent({ projectRef: ref, payload: { ...item, name, description } })
- setShowUpdateModal(false)
- toast.success('Query updated')
+ if (!ref || typeof ref !== 'string') return console.error('Invalid project reference')
+ updateContent({ projectRef: ref, payload: { ...item, name, description } })
}
return (
diff --git a/apps/studio/components/interfaces/Settings/Vault/Keys/EncryptionKeysManagement.tsx b/apps/studio/components/interfaces/Settings/Vault/Keys/EncryptionKeysManagement.tsx
index 23922a0d677..8e5f4c4790d 100644
--- a/apps/studio/components/interfaces/Settings/Vault/Keys/EncryptionKeysManagement.tsx
+++ b/apps/studio/components/interfaces/Settings/Vault/Keys/EncryptionKeysManagement.tsx
@@ -38,8 +38,6 @@ const EncryptionKeysManagement = () => {
const [selectedSort, setSelectedSort] = useState<'name' | 'created'>('created')
const [showAddKeyModal, setShowAddKeyModal] = useState(false)
const [selectedKeyToRemove, setSelectedKeyToRemove] = useState<any>()
- const [isDeletingKey, setIsDeletingKey] = useState(false)
-
const canManageKeys = useCheckPermissions(PermissionAction.TENANT_SQL_ADMIN_WRITE, 'tables')
useEffect(() => {
@@ -50,8 +48,18 @@ const EncryptionKeysManagement = () => {
projectRef: project?.ref,
connectionString: project?.connectionString,
})
- const { mutateAsync: addKeyMutation } = usePgSodiumKeyCreateMutation()
- const { mutateAsync: deleteKeyMutation } = usePgSodiumKeyDeleteMutation()
+ const { mutate: addKeyMutation, isLoading: isCreating } = usePgSodiumKeyCreateMutation({
+ onSuccess: () => {
+ toast.success('Successfully added new key')
+ setShowAddKeyModal(false)
+ },
+ })
+ const { mutate: deleteKeyMutation, isLoading: isDeleting } = usePgSodiumKeyDeleteMutation({
+ onSuccess: () => {
+ toast.success(`Successfully deleted encryption key`)
+ setSelectedKeyToRemove(undefined)
+ },
+ })
const allKeys = data || []
const keys = sortBy(
@@ -74,38 +82,22 @@ const EncryptionKeysManagement = () => {
const addKey = async (values: any, { setSubmitting }: any) => {
if (!project) return console.error('Project is required')
- setSubmitting(true)
- const res = await addKeyMutation({
+ addKeyMutation({
projectRef: project.ref,
connectionString: project.connectionString,
name: values.name,
})
- if (!res.error) {
- toast.success('Successfully added new key')
- setShowAddKeyModal(false)
- } else {
- toast.error(`Failed to add new key: ${res.error.message}`)
- }
- setSubmitting(false)
}
const confirmDeleteKey = async () => {
if (!selectedKeyToRemove) return
if (!project) return console.error('Project is required')
- setIsDeletingKey(true)
- const res = await deleteKeyMutation({
+ deleteKeyMutation({
projectRef: project.ref,
connectionString: project.connectionString,
id: selectedKeyToRemove.id,
})
- if (!res.error) {
- toast.success(`Successfully deleted encryption key`)
- setSelectedKeyToRemove(undefined)
- } else {
- toast.error(`Failed to delete encryption key: ${res.error.message}`)
- }
- setIsDeletingKey(false)
}
return (
@@ -299,7 +291,7 @@ const EncryptionKeysManagement = () => {
visible={selectedKeyToRemove !== undefined}
onCancel={() => setSelectedKeyToRemove(undefined)}
onConfirm={confirmDeleteKey}
- loading={isDeletingKey}
+ loading={isDeleting}
header={<h5 className="text-sm text-foreground">Confirm to delete key</h5>}
>
<div className="py-4">
@@ -347,7 +339,7 @@ const EncryptionKeysManagement = () => {
}}
onSubmit={addKey}
>
- {({ isSubmitting }: any) => {
+ {() => {
return (
<div className="py-4">
<Modal.Content>
@@ -363,12 +355,12 @@ const EncryptionKeysManagement = () => {
<div className="flex items-center justify-end space-x-2">
<Button
type="default"
- disabled={isSubmitting}
+ disabled={isCreating}
onClick={() => setShowAddKeyModal(false)}
>
Cancel
</Button>
- <Button htmlType="submit" disabled={isSubmitting} loading={isSubmitting}>
+ <Button htmlType="submit" disabled={isCreating} loading={isCreating}>
Add key
</Button>
</div>
diff --git a/apps/studio/components/interfaces/Settings/Vault/Secrets/AddNewSecretModal.tsx b/apps/studio/components/interfaces/Settings/Vault/Secrets/AddNewSecretModal.tsx
index a24bc1d05ce..56c1911f0f1 100644
--- a/apps/studio/components/interfaces/Settings/Vault/Secrets/AddNewSecretModal.tsx
+++ b/apps/studio/components/interfaces/Settings/Vault/Secrets/AddNewSecretModal.tsx
@@ -49,34 +49,37 @@ const AddNewSecretModal = ({ visible, onClose }: AddNewSecretModalProps) => {
setSubmitting(true)
let encryptionKeyId = selectedKeyId
- if (selectedKeyId === 'create-new') {
- const addKeyRes = await addKeyMutation({
- projectRef: project?.ref!,
+ try {
+ setSubmitting(true)
+ if (selectedKeyId === 'create-new') {
+ const addKeyRes = await addKeyMutation({
+ projectRef: project?.ref!,
+ connectionString: project?.connectionString,
+ name: values.keyName || undefined,
+ })
+ if (addKeyRes.error) {
+ return toast.error(`Failed to create new key: ${addKeyRes.error.message}`)
+ } else {
+ encryptionKeyId = addKeyRes[0].id
+ }
+ }
+
+ const res = await addSecret({
+ projectRef: project.ref,
connectionString: project?.connectionString,
- name: values.keyName || undefined,
+ name: values.name,
+ description: values.description,
+ secret: values.secret,
+ key_id: encryptionKeyId,
})
- if (addKeyRes.error) {
- return toast.error(`Failed to create new key: ${addKeyRes.error.message}`)
+
+ if (!res.error) {
+ toast.success(`Successfully added new secret ${values.name}`)
+ onClose()
} else {
- encryptionKeyId = addKeyRes[0].id
+ toast.error(`Failed to add secret ${values.name}: ${res.error.message}`)
}
- }
-
- const res = await addSecret({
- projectRef: project.ref,
- connectionString: project?.connectionString,
- name: values.name,
- description: values.description,
- secret: values.secret,
- key_id: encryptionKeyId,
- })
-
- if (!res.error) {
- toast.success(`Successfully added new secret ${values.name}`)
- onClose()
- setSubmitting(false)
- } else {
- toast.error(`Failed to add secret ${values.name}: ${res.error.message}`)
+ } finally {
setSubmitting(false)
}
}
diff --git a/apps/studio/components/interfaces/Settings/Vault/Secrets/DeleteSecretModal.tsx b/apps/studio/components/interfaces/Settings/Vault/Secrets/DeleteSecretModal.tsx
index f413e421313..1ee4dc068d4 100644
--- a/apps/studio/components/interfaces/Settings/Vault/Secrets/DeleteSecretModal.tsx
+++ b/apps/studio/components/interfaces/Settings/Vault/Secrets/DeleteSecretModal.tsx
@@ -1,4 +1,3 @@
-import { useState } from 'react'
import toast from 'react-hot-toast'
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
@@ -13,30 +12,25 @@ interface DeleteSecretModalProps {
const DeleteSecretModal = ({ selectedSecret, onClose }: DeleteSecretModalProps) => {
const { project } = useProjectContext()
-
- const [isDeleting, setIsDeleting] = useState(false)
-
- const { mutateAsync: deleteSecret } = useVaultSecretDeleteMutation()
+ const { mutate: deleteSecret, isLoading: isDeleting } = useVaultSecretDeleteMutation({
+ onSuccess: () => {
+ toast.success(`Successfully deleted secret ${selectedSecret?.name}`)
+ onClose()
+ },
+ onError: (error) => {
+ toast.error(`Failed to delete secret: ${error.message}`)
+ },
+ })
const onConfirmDeleteSecret = async () => {
if (!project) return console.error('Project is required')
+ if (!selectedSecret) return
- setIsDeleting(true)
- if (!selectedSecret) {
- return
- }
- const res = await deleteSecret({
+ deleteSecret({
projectRef: project.ref,
connectionString: project?.connectionString,
id: selectedSecret.id,
})
- if (res.error) {
- toast.error(`Failed to delete secret: ${res.error.message}`)
- } else {
- toast.success(`Successfully deleted secret ${selectedSecret.name}`)
- onClose()
- }
- setIsDeleting(false)
}
return (
diff --git a/apps/studio/components/interfaces/Settings/Vault/Secrets/EditSecretModal.tsx b/apps/studio/components/interfaces/Settings/Vault/Secrets/EditSecretModal.tsx
index 2c8b75a8b4e..412714ee879 100644
--- a/apps/studio/components/interfaces/Settings/Vault/Secrets/EditSecretModal.tsx
+++ b/apps/studio/components/interfaces/Settings/Vault/Secrets/EditSecretModal.tsx
@@ -47,44 +47,48 @@ const EditSecretModal = ({ selectedSecret, onClose }: EditSecretModalProps) => {
const onUpdateSecret = async (values: any, { setSubmitting }: any) => {
if (!project) return console.error('Project is required')
- const payload: Partial<VaultSecret> = {}
- if (values.name !== selectedSecret?.name) payload.name = values.name
- if (values.description !== selectedSecret?.description) payload.description = values.description
- if (selectedKeyId !== selectedSecret?.key_id) {
- let encryptionKeyId = selectedKeyId
- if (values.keyId === 'create-new') {
- const addKeyRes = await addKeyMutation({
- projectRef: project?.ref!,
+ try {
+ const payload: Partial<VaultSecret> = {}
+ if (values.name !== selectedSecret?.name) payload.name = values.name
+ if (values.description !== selectedSecret?.description)
+ payload.description = values.description
+ if (selectedKeyId !== selectedSecret?.key_id) {
+ let encryptionKeyId = selectedKeyId
+ if (values.keyId === 'create-new') {
+ const addKeyRes = await addKeyMutation({
+ projectRef: project?.ref!,
+ connectionString: project?.connectionString,
+ name: values.keyName || undefined,
+ })
+ if (addKeyRes.error) {
+ return toast.error(`Failed to create new key: ${addKeyRes.error.message}`)
+ } else {
+ encryptionKeyId = addKeyRes[0].id
+ }
+ }
+
+ payload.key_id = encryptionKeyId
+ }
+ payload.secret = values.secret
+
+ if (!isEmpty(payload) && selectedSecret) {
+ setSubmitting(true)
+ const res = await updateSecret({
+ projectRef: project.ref,
connectionString: project?.connectionString,
- name: values.keyName || undefined,
+ id: selectedSecret.id,
+ ...payload,
})
- if (addKeyRes.error) {
- return toast.error(`Failed to create new key: ${addKeyRes.error.message}`)
+ if (!res.error) {
+ toast.success('Successfully updated secret')
+ setSubmitting(false)
+ onClose()
} else {
- encryptionKeyId = addKeyRes[0].id
+ toast.error(`Failed to update secret: ${res.error.message}`)
+ setSubmitting(false)
}
}
-
- payload.key_id = encryptionKeyId
- }
- payload.secret = values.secret
-
- if (!isEmpty(payload) && selectedSecret) {
- setSubmitting(true)
- const res = await updateSecret({
- projectRef: project.ref,
- connectionString: project?.connectionString,
- id: selectedSecret.id,
- ...payload,
- })
- if (!res.error) {
- toast.success('Successfully updated secret')
- setSubmitting(false)
- onClose()
- } else {
- toast.error(`Failed to update secret: ${res.error.message}`)
- setSubmitting(false)
- }
+ } finally {
}
}
diff --git a/apps/studio/components/interfaces/SignIn/SignInMfaForm.tsx b/apps/studio/components/interfaces/SignIn/SignInMfaForm.tsx
index b50a163975f..a448b237b83 100644
--- a/apps/studio/components/interfaces/SignIn/SignInMfaForm.tsx
+++ b/apps/studio/components/interfaces/SignIn/SignInMfaForm.tsx
@@ -33,11 +33,7 @@ const SignInMfaForm = () => {
isSuccess: isSuccessFactors,
isLoading: isLoadingFactors,
} = useMfaListFactorsQuery()
- const {
- mutateAsync: mfaChallengeAndVerify,
- isLoading,
- isSuccess,
- } = useMfaChallengeAndVerifyMutation()
+ const { mutate: mfaChallengeAndVerify, isLoading, isSuccess } = useMfaChallengeAndVerifyMutation()
const [selectedFactor, setSelectedFactor] = useState<Factor | null>(null)
const signOut = useSignOut()
@@ -61,7 +57,7 @@ const SignInMfaForm = () => {
const onSignIn = async ({ code }: { code: string }) => {
const toastId = toast.loading('Signing in...')
if (selectedFactor) {
- await mfaChallengeAndVerify(
+ mfaChallengeAndVerify(
{ factorId: selectedFactor.id, code, refreshFactors: false },
{
onSuccess: async () => {
diff --git a/apps/studio/components/interfaces/TableGridEditor/DeleteConfirmationDialogs.tsx b/apps/studio/components/interfaces/TableGridEditor/DeleteConfirmationDialogs.tsx
index 2fe180011d4..940efaaeb47 100644
--- a/apps/studio/components/interfaces/TableGridEditor/DeleteConfirmationDialogs.tsx
+++ b/apps/studio/components/interfaces/TableGridEditor/DeleteConfirmationDialogs.tsx
@@ -1,20 +1,11 @@
+import { ExternalLink } from 'lucide-react'
import Link from 'next/link'
import toast from 'react-hot-toast'
-import {
- Alert,
- AlertDescription_Shadcn_,
- AlertTitle_Shadcn_,
- Alert_Shadcn_,
- Button,
- Checkbox,
- IconExternalLink,
- Modal,
-} from 'ui'
+import { AlertDescription_Shadcn_, AlertTitle_Shadcn_, Alert_Shadcn_, Button, Checkbox } from 'ui'
import type { SupaRow } from 'components/grid'
import { formatFilterURLParams } from 'components/grid/SupabaseGrid.utils'
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
-import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
import { useDatabaseColumnDeleteMutation } from 'data/database-columns/database-column-delete-mutation'
import { useTableRowDeleteAllMutation } from 'data/table-rows/table-row-delete-all-mutation'
import { useTableRowDeleteMutation } from 'data/table-rows/table-row-delete-mutation'
@@ -26,6 +17,7 @@ import type { TableLike } from 'hooks/misc/useTable'
import { noop } from 'lib/void'
import { useGetImpersonatedRole } from 'state/role-impersonation-state'
import { useTableEditorStateSnapshot } from 'state/table-editor'
+import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
export type DeleteConfirmationDialogsProps = {
selectedTable?: TableLike
@@ -82,7 +74,7 @@ const DeleteConfirmationDialogs = ({
snap.closeConfirmationDialog()
},
})
- const { mutateAsync: deleteTable } = useTableDeleteMutation({
+ const { mutate: deleteTable } = useTableDeleteMutation({
onSuccess: async () => {
const tables = await getTables(snap.selectedSchemaName)
onAfterDeleteTable(tables)
@@ -108,7 +100,7 @@ const DeleteConfirmationDialogs = ({
},
})
- const { mutateAsync: deleteAllRows } = useTableRowDeleteAllMutation({
+ const { mutate: deleteAllRows } = useTableRowDeleteAllMutation({
onSuccess: () => {
if (snap.confirmationDialog?.type === 'row') {
snap.confirmationDialog.callback?.()
@@ -123,7 +115,7 @@ const DeleteConfirmationDialogs = ({
},
})
- const { mutateAsync: truncateRows } = useTableRowTruncateMutation({
+ const { mutate: truncateRows } = useTableRowTruncateMutation({
onSuccess: () => {
if (snap.confirmationDialog?.type === 'row') {
snap.confirmationDialog.callback?.()
@@ -259,7 +251,7 @@ const DeleteConfirmationDialogs = ({
recursively.
</AlertTitle_Shadcn_>
<AlertDescription_Shadcn_>
- <Button asChild size="tiny" type="default" icon={<IconExternalLink />}>
+ <Button asChild size="tiny" type="default" icon={<ExternalLink />}>
<Link
href="https://www.postgresql.org/docs/current/ddl-depend.html"
target="_blank"
@@ -299,25 +291,26 @@ const DeleteConfirmationDialogs = ({
onChange={() => snap.toggleConfirmationIsWithCascade(!isDeleteWithCascade)}
/>
{isDeleteWithCascade && (
- <Alert
- withIcon
- variant="warning"
- title="Warning: Dropping with cascade may result in unintended consequences"
- >
- <p className="mb-4">
+ <Alert_Shadcn_ variant="warning">
+ <AlertTitle_Shadcn_>
+ Warning: Dropping with cascade may result in unintended consequences
+ </AlertTitle_Shadcn_>
+ <AlertDescription_Shadcn_>
All dependent objects will be removed, as will any objects that depend on them,
recursively.
- </p>
- <Button asChild size="tiny" type="default" icon={<IconExternalLink />}>
- <Link
- href="https://www.postgresql.org/docs/current/ddl-depend.html"
- target="_blank"
- rel="noreferrer"
- >
- About dependency tracking
- </Link>
- </Button>
- </Alert>
+ </AlertDescription_Shadcn_>
+ <AlertDescription_Shadcn_ className="mt-4">
+ <Button asChild size="tiny" type="default" icon={<ExternalLink />}>
+ <Link
+ href="https://www.postgresql.org/docs/current/ddl-depend.html"
+ target="_blank"
+ rel="noreferrer"
+ >
+ About dependency tracking
+ </Link>
+ </Button>
+ </AlertDescription_Shadcn_>
+ </Alert_Shadcn_>
)}
</div>
</ConfirmationModal>
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/FeedbackDropdown/FeedbackWidget.tsx b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/FeedbackDropdown/FeedbackWidget.tsx
index 906cfd22fde..595d46ea49b 100644
--- a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/FeedbackDropdown/FeedbackWidget.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/FeedbackDropdown/FeedbackWidget.tsx
@@ -46,7 +46,22 @@ const FeedbackWidget = ({
const [isSending, setSending] = useState(false)
const [isSavingScreenshot, setIsSavingScreenshot] = useState(false)
- const { mutateAsync: submitFeedback } = useSendFeedbackMutation()
+ const { mutate: submitFeedback } = useSendFeedbackMutation({
+ onSuccess: () => {
+ setFeedback('')
+ setScreenshot(undefined)
+ localStorage.removeItem(FEEDBACK_STORAGE_KEY)
+ localStorage.removeItem(SCREENSHOT_STORAGE_KEY)
+ toast.success(
+ 'Feedback sent. Thank you!\n\nPlease be aware that we do not provide responses to feedback. If you require assistance or a reply, consider submitting a support ticket.'
+ )
+ setSending(false)
+ },
+ onError: (error) => {
+ toast.error(`Failed to submit feedback: ${error.message}`)
+ setSending(false)
+ },
+ })
useEffect(() => {
const storedFeedback = localStorage.getItem(FEEDBACK_STORAGE_KEY)
@@ -136,23 +151,12 @@ const FeedbackWidget = ({
const formattedFeedback =
attachmentUrl !== undefined ? `${feedback}\n\nAttachments:\n${attachmentUrl}` : feedback
- try {
- await submitFeedback({
- projectRef: ref,
- organizationSlug: slug,
- message: formattedFeedback,
- pathname: router.asPath,
- })
- setFeedback('')
- setScreenshot(undefined)
- localStorage.removeItem(FEEDBACK_STORAGE_KEY)
- localStorage.removeItem(SCREENSHOT_STORAGE_KEY)
- toast.success(
- 'Feedback sent. Thank you!\n\nPlease be aware that we do not provide responses to feedback. If you require assistance or a reply, consider submitting a support ticket.'
- )
- } finally {
- setSending(false)
- }
+ submitFeedback({
+ projectRef: ref,
+ organizationSlug: slug,
+ message: formattedFeedback,
+ pathname: router.asPath,
+ })
}
return onClose()
diff --git a/apps/studio/components/layouts/ReportsLayout/ReportsMenu.tsx b/apps/studio/components/layouts/ReportsLayout/ReportsMenu.tsx
index aafa4b0905e..52ddfeffdad 100644
--- a/apps/studio/components/layouts/ReportsLayout/ReportsMenu.tsx
+++ b/apps/studio/components/layouts/ReportsLayout/ReportsMenu.tsx
@@ -1,16 +1,16 @@
import { ChevronDown, Edit2, Plus, Trash } from 'lucide-react'
import Link from 'next/link'
import { useRouter } from 'next/router'
-import React from 'react'
+import { useState } from 'react'
import toast from 'react-hot-toast'
+import { useParams } from 'common'
import { CreateReportModal } from 'components/interfaces/Reports/Reports.CreateReportModal'
import { UpdateCustomReportModal } from 'components/interfaces/Reports/Reports.UpdateModal'
import ShimmeringLoader from 'components/ui/ShimmeringLoader'
import { useContentDeleteMutation } from 'data/content/content-delete-mutation'
import { Content, useContentQuery } from 'data/content/content-query'
-import { useContentUpsertMutation } from 'data/content/content-upsert-mutation'
-import { useIsFeatureEnabled, useSelectedProject } from 'hooks'
+import { useIsFeatureEnabled } from 'hooks'
import {
AlertDescription_Shadcn_,
AlertTitle_Shadcn_,
@@ -28,21 +28,32 @@ import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
const ReportsMenu = () => {
const router = useRouter()
- const { id } = router.query
- const project = useSelectedProject()
- const deleteReport = useContentDeleteMutation()
- const updateReport = useContentUpsertMutation()
+ const { ref, id } = useParams()
+ const pageKey = (id || router.pathname.split('/')[4]) as string
const storageEnabled = useIsFeatureEnabled('project_storage:all')
- const pageKey = (id || router.pathname.split('/')[4]) as string
- const ref = project?.ref ?? 'default'
+ const { data: content, isLoading } = useContentQuery(ref)
+ const { mutate: deleteReport, isLoading: isDeleting } = useContentDeleteMutation({
+ onSuccess: () => {
+ setDeleteModalOpen(false)
+ toast.success('Successfully deleted report')
+ router.push(`/project/${ref}/reports`)
+ },
+ onError: (error) => {
+ toast.error(`Failed to delete report: ${error.message}`)
+ },
+ })
- const [deleteModalOpen, setDeleteModalOpen] = React.useState(false)
- const [showNewReportModal, setShowNewReportModal] = React.useState(false)
- const [showUpdateReportModal, setShowUpdateReportModal] = React.useState(false)
- const [selectedReport, setSelectedReport] = React.useState<Content>()
+ const [deleteModalOpen, setDeleteModalOpen] = useState(false)
+ const [showNewReportModal, setShowNewReportModal] = useState(false)
+ const [selectedReportToDelete, setSelectedReportToDelete] = useState<Content>()
+ const [selectedReportToUpdate, setSelectedReportToUpdate] = useState<Content>()
- const { data: content, isLoading } = useContentQuery(ref)
+ const onConfirmDeleteReport = () => {
+ if (ref === undefined) return console.error('Project ref is required')
+ if (selectedReportToDelete?.id === undefined) return console.error('Report ID is required')
+ deleteReport({ projectRef: ref, ids: [selectedReportToDelete.id] })
+ }
function getReportMenuItems() {
if (!content) return []
@@ -155,8 +166,7 @@ const ReportsMenu = () => {
<DropdownMenuItem
onClick={() => {
if (!item.id) return
- setSelectedReport(item.report)
- setShowUpdateReportModal(true)
+ setSelectedReportToUpdate(item.report)
}}
>
<Edit2 size={12} />
@@ -166,7 +176,7 @@ const ReportsMenu = () => {
<DropdownMenuItem
onClick={async () => {
if (!item.id) return
- setSelectedReport(item.report)
+ setSelectedReportToDelete(item.report)
setDeleteModalOpen(true)
}}
>
@@ -224,34 +234,11 @@ const ReportsMenu = () => {
</Alert_Shadcn_>
<UpdateCustomReportModal
- onSubmit={async (newVals) => {
- try {
- if (!selectedReport) return
- if (!selectedReport.id) return
- if (!selectedReport.project_id) return
-
- await updateReport.mutateAsync({
- projectRef: ref,
- payload: {
- ...selectedReport,
- project_id: selectedReport.project_id,
- id: selectedReport.id,
- name: newVals.name,
- description: newVals.description || '',
- },
- })
- toast.success('Report updated')
- setShowUpdateReportModal(false)
- } catch (error) {
- toast.error(`Failed to update report. Check console for more details.`)
- console.error(error)
- }
- }}
- onCancel={() => setShowUpdateReportModal(false)}
- visible={showUpdateReportModal}
+ onCancel={() => setSelectedReportToUpdate(undefined)}
+ selectedReport={selectedReportToUpdate}
initialValues={{
- name: selectedReport?.name || '',
- description: selectedReport?.description || '',
+ name: selectedReportToUpdate?.name || '',
+ description: selectedReportToUpdate?.description || '',
}}
/>
@@ -260,37 +247,22 @@ const ReportsMenu = () => {
confirmLabel="Delete report"
confirmLabelLoading="Deleting report"
size="medium"
- loading={deleteReport.isLoading}
+ loading={isDeleting}
visible={deleteModalOpen}
onCancel={() => setDeleteModalOpen(false)}
- onConfirm={async () => {
- if (selectedReport) {
- if (!selectedReport.id) return
- await deleteReport.mutateAsync({
- projectRef: ref,
- ids: [selectedReport.id],
- })
- toast.success('Report deleted')
- router.push(`/project/${ref}/reports`)
- }
- setDeleteModalOpen(false)
- }}
+ onConfirm={onConfirmDeleteReport}
>
<div className="text-sm text-foreground-light grid gap-4">
<div className="grid gap-1">
- <p>Are you sure you want to delete '{selectedReport?.name}'?</p>
+ <p>Are you sure you want to delete '{selectedReportToDelete?.name}'?</p>
</div>
</div>
</ConfirmationModal>
<CreateReportModal
visible={showNewReportModal}
- onCancel={() => {
- setShowNewReportModal(false)
- }}
- afterSubmit={() => {
- setShowNewReportModal(false)
- }}
+ onCancel={() => setShowNewReportModal(false)}
+ afterSubmit={() => setShowNewReportModal(false)}
/>
</div>
)}
diff --git a/apps/studio/components/to-be-cleaned/Storage/DeleteBucketModal.tsx b/apps/studio/components/to-be-cleaned/Storage/DeleteBucketModal.tsx
index 61422b8d88a..60f34b4654e 100644
--- a/apps/studio/components/to-be-cleaned/Storage/DeleteBucketModal.tsx
+++ b/apps/studio/components/to-be-cleaned/Storage/DeleteBucketModal.tsx
@@ -45,19 +45,23 @@ const DeleteBucketModal = ({ visible = false, bucket, onClose }: DeleteBucketMod
['policies'],
[]
)
- await Promise.all(
- bucketPolicies.map((policy: any) =>
- deletePolicy({
- projectRef: project?.ref,
- connectionString: project?.connectionString,
- id: policy.id,
- })
+
+ try {
+ await Promise.all(
+ bucketPolicies.map((policy: any) =>
+ deletePolicy({
+ projectRef: project?.ref,
+ connectionString: project?.connectionString,
+ id: policy.id,
+ })
+ )
)
- )
- toast.success(`Successfully deleted bucket ${bucket!.name}`)
- router.push(`/project/${projectRef}/storage/buckets`)
- onClose()
+ toast.success(`Successfully deleted bucket ${bucket!.name}`)
+ router.push(`/project/${projectRef}/storage/buckets`)
+ onClose()
+ } finally {
+ }
},
})
diff --git a/apps/studio/components/to-be-cleaned/Storage/StoragePolicies/StoragePolicies.tsx b/apps/studio/components/to-be-cleaned/Storage/StoragePolicies/StoragePolicies.tsx
index c8b4955b263..3fb66c72d21 100644
--- a/apps/studio/components/to-be-cleaned/Storage/StoragePolicies/StoragePolicies.tsx
+++ b/apps/studio/components/to-be-cleaned/Storage/StoragePolicies/StoragePolicies.tsx
@@ -106,21 +106,24 @@ const StoragePolicies = () => {
return true
}
- return await Promise.all(
- payloads.map(async (payload) => {
- try {
- await createDatabasePolicy({
- projectRef: project?.ref,
- connectionString: project?.connectionString,
- payload,
- })
- return false
- } catch (error: any) {
- toast.error(`Error adding policy: ${error.message}`)
- return true
- }
- })
- )
+ try {
+ return await Promise.all(
+ payloads.map(async (payload) => {
+ try {
+ await createDatabasePolicy({
+ projectRef: project?.ref,
+ connectionString: project?.connectionString,
+ payload,
+ })
+ return false
+ } catch (error: any) {
+ toast.error(`Error adding policy: ${error.message}`)
+ return true
+ }
+ })
+ )
+ } finally {
+ }
}
const onCreatePolicy = async (payload: any) => {
diff --git a/apps/studio/data/auth/user-delete-mfa-factors-mutation.ts b/apps/studio/data/auth/user-delete-mfa-factors-mutation.ts
index 1b58cfcc842..8190ce556c5 100644
--- a/apps/studio/data/auth/user-delete-mfa-factors-mutation.ts
+++ b/apps/studio/data/auth/user-delete-mfa-factors-mutation.ts
@@ -35,7 +35,7 @@ export const useUserDeleteMFAFactorsMutation = ({
},
async onError(data, variables, context) {
if (onError === undefined) {
- toast.error(`Failed to delete user MFA factors: ${data.message}`)
+ toast.error(`Failed to delete the user's MFA factors: ${data.message}`)
} else {
onError(data, variables, context)
}
diff --git a/apps/studio/data/config/project-upgrade-eligibility-query.ts b/apps/studio/data/config/project-upgrade-eligibility-query.ts
index f1fec99c611..434fbde9e71 100644
--- a/apps/studio/data/config/project-upgrade-eligibility-query.ts
+++ b/apps/studio/data/config/project-upgrade-eligibility-query.ts
@@ -53,6 +53,7 @@ export const useProjectUpgradeEligibilityQuery = <TData = ProjectUpgradeEligibil
enabled &&
project !== undefined &&
project.status !== PROJECT_STATUS.INACTIVE &&
+ project.status !== PROJECT_STATUS.COMING_UP &&
typeof projectRef !== 'undefined' &&
IS_PLATFORM,
...options,
diff --git a/apps/studio/data/vault/vault-secret-create-mutation.ts b/apps/studio/data/vault/vault-secret-create-mutation.ts
index 67798e557c2..e51387351e0 100644
--- a/apps/studio/data/vault/vault-secret-create-mutation.ts
+++ b/apps/studio/data/vault/vault-secret-create-mutation.ts
@@ -51,7 +51,7 @@ export const useVaultSecretCreateMutation = ({
},
async onError(data, variables, context) {
if (onError === undefined) {
- toast.error(`Failed to delete secret: ${data.message}`)
+ toast.error(`Failed to create secret: ${data.message}`)
} else {
onError(data, variables, context)
}
diff --git a/apps/studio/pages/project/[ref]/reports/index.tsx b/apps/studio/pages/project/[ref]/reports/index.tsx
index 72d4a30cff9..4fda277cae3 100644
--- a/apps/studio/pages/project/[ref]/reports/index.tsx
+++ b/apps/studio/pages/project/[ref]/reports/index.tsx
@@ -34,7 +34,7 @@ export const UserReportPage: NextPageWithLayout = () => {
})
return (
- <div className="mx-auto my-32 w-full max-w-7xl flex-grow space-y-16">
+ <div className="h-full w-full">
{isLoading ? (
<Loading />
) : (
diff --git a/apps/studio/pages/sign-in-fly-tos.tsx b/apps/studio/pages/sign-in-fly-tos.tsx
index b48e5bafb84..93cdf7d5520 100644
--- a/apps/studio/pages/sign-in-fly-tos.tsx
+++ b/apps/studio/pages/sign-in-fly-tos.tsx
@@ -23,15 +23,15 @@ const SignInFlyTos = () => {
onSuccess: (res) => {
router.replace(`/project/${res.ref}`)
},
- onError: (_) => {
+ onError: () => {
setLoading(false)
},
})
const { mutateAsync: getOrgByFlyOrgId } = useOrganizationByFlyOrgIdMutation({
- onSuccess: (_) => {
+ onSuccess: () => {
router.replace('/projects')
},
- onError: (_) => {
+ onError: () => {
setLoading(false)
},
})