Skip to content

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

Replace ui setnotification with toast midway (#21867)

Joshen Lim6b741bc96401
diff --git a/apps/studio/components/interfaces/Account/Preferences/ProfileInformation.tsx b/apps/studio/components/interfaces/Account/Preferences/ProfileInformation.tsx
index 525acd01e82..45a30fc98f9 100644
--- a/apps/studio/components/interfaces/Account/Preferences/ProfileInformation.tsx
+++ b/apps/studio/components/interfaces/Account/Preferences/ProfileInformation.tsx
@@ -1,5 +1,6 @@
import { zodResolver } from '@hookform/resolvers/zod'
import { SubmitHandler, useForm } from 'react-hook-form'
+import toast from 'react-hot-toast'
import {
FormControl_Shadcn_,
FormField_Shadcn_,
@@ -15,7 +16,6 @@ import { FormActions } from 'components/ui/Forms'
import Panel from 'components/ui/Panel'
import { useProfileUpdateMutation } from 'data/profile/profile-update-mutation'
import type { Profile } from 'data/profile/types'
-import { useStore } from 'hooks'
import type { FormSchema } from 'types'
const FormSchema = z.object({
@@ -26,8 +26,6 @@ const FormSchema = z.object({
const formId = 'profile-information-form'
export const ProfileInformation = ({ profile }: { profile: Profile }) => {
- const { ui } = useStore()
-
const form = useForm({
resolver: zodResolver(FormSchema),
defaultValues: { first_name: profile.first_name ?? '', last_name: profile.last_name ?? '' },
@@ -35,14 +33,10 @@ export const ProfileInformation = ({ profile }: { profile: Profile }) => {
const { mutateAsync: updateProfile, isLoading } = useProfileUpdateMutation({
onSuccess: () => {
- ui.setNotification({ category: 'success', message: 'Successfully saved profile' })
+ toast.success('Successfully saved profile')
},
onError: (error) => {
- ui.setNotification({
- error,
- category: 'error',
- message: "Couldn't update profile. Please try again later.",
- })
+ toast.error("Couldn't update profile. Please try again later.")
},
})
diff --git a/apps/studio/components/interfaces/Account/TOTPFactors/AddNewFactorModal.tsx b/apps/studio/components/interfaces/Account/TOTPFactors/AddNewFactorModal.tsx
index 6f5ba7fd7ed..62d943f4895 100644
--- a/apps/studio/components/interfaces/Account/TOTPFactors/AddNewFactorModal.tsx
+++ b/apps/studio/components/interfaces/Account/TOTPFactors/AddNewFactorModal.tsx
@@ -1,13 +1,13 @@
import { Dispatch, SetStateAction, useEffect, useState } from 'react'
+import toast from 'react-hot-toast'
import { Input, Modal } from 'ui'
-
import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
+
import InformationBox from 'components/ui/InformationBox'
import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'
import { useMfaChallengeAndVerifyMutation } from 'data/profile/mfa-challenge-and-verify-mutation'
import { useMfaEnrollMutation } from 'data/profile/mfa-enroll-mutation'
import { useMfaUnenrollMutation } from 'data/profile/mfa-unenroll-mutation'
-import { useStore } from 'hooks'
interface AddNewFactorModalProps {
visible: boolean
@@ -116,23 +116,15 @@ const SecondStep = ({
onSuccess,
onClose,
}: SecondStepProps) => {
- const { ui } = useStore()
const [code, setCode] = useState('')
const { mutate: unenroll } = useMfaUnenrollMutation({ onSuccess: () => onClose() })
-
const { mutate: challengeAndVerify, isLoading: isVerifying } = useMfaChallengeAndVerifyMutation({
onError: (error) => {
- ui.setNotification({
- category: 'error',
- message: `Failed to add a second factor authentication: ${error?.message}`,
- })
+ toast.error(`Failed to add a second factor authentication: ${error?.message}`)
},
onSuccess: () => {
- ui.setNotification({
- category: 'success',
- message: `Successfully added a second factor authentication`,
- })
+ toast.success(`Successfully added a second factor authentication`)
onSuccess()
},
})
diff --git a/apps/studio/components/interfaces/Auth/AuthProvidersForm/ProviderForm.tsx b/apps/studio/components/interfaces/Auth/AuthProvidersForm/ProviderForm.tsx
index e9cf4695643..938dbdc454f 100644
--- a/apps/studio/components/interfaces/Auth/AuthProvidersForm/ProviderForm.tsx
+++ b/apps/studio/components/interfaces/Auth/AuthProvidersForm/ProviderForm.tsx
@@ -1,14 +1,15 @@
import * as Tooltip from '@radix-ui/react-tooltip'
import { PermissionAction } from '@supabase/shared-types/out/constants'
+import { useParams } from 'common'
import { useState } from 'react'
+import toast from 'react-hot-toast'
import ReactMarkdown from 'react-markdown'
import { Alert, Button, Collapsible, Form, IconCheck, IconChevronUp, Input } from 'ui'
-import { useParams } from 'common'
import type { components } from 'data/api'
import { useAuthConfigUpdateMutation } from 'data/auth/auth-config-update-mutation'
import { useCustomDomainsQuery } from 'data/custom-domains/custom-domains-query'
-import { useCheckPermissions, useStore } from 'hooks'
+import { useCheckPermissions } from 'hooks'
import { BASE_PATH } from 'lib/constants'
import { ProviderCollapsibleClasses } from './AuthProvidersForm.constants'
import type { Provider } from './AuthProvidersForm.types'
@@ -20,7 +21,6 @@ export interface ProviderFormProps {
}
const ProviderForm = ({ config, provider }: ProviderFormProps) => {
- const { ui } = useStore()
const [open, setOpen] = useState(false)
const { ref: projectRef } = useParams()
const { mutate: updateAuthConfig, isLoading: isUpdatingConfig } = useAuthConfigUpdateMutation()
@@ -87,7 +87,7 @@ const ProviderForm = ({ config, provider }: ProviderFormProps) => {
onSuccess: () => {
resetForm({ values: { ...values }, initialValues: { ...values } })
setOpen(false)
- ui.setNotification({ category: 'success', message: 'Successfully updated settings' })
+ toast.error('Successfully updated settings')
},
}
)
diff --git a/apps/studio/components/interfaces/Auth/Hooks/BasicHooksConfig.tsx b/apps/studio/components/interfaces/Auth/Hooks/BasicHooksConfig.tsx
index 476f85236b7..b089b4dc6f4 100644
--- a/apps/studio/components/interfaces/Auth/Hooks/BasicHooksConfig.tsx
+++ b/apps/studio/components/interfaces/Auth/Hooks/BasicHooksConfig.tsx
@@ -1,6 +1,7 @@
import { PermissionAction } from '@supabase/shared-types/out/constants'
import { useParams } from 'common'
import { useEffect } from 'react'
+import toast from 'react-hot-toast'
import {
AlertDescription_Shadcn_,
AlertTitle_Shadcn_,
@@ -21,7 +22,7 @@ import {
} from 'components/ui/Forms'
import { useAuthConfigQuery } from 'data/auth/auth-config-query'
import { useAuthConfigUpdateMutation } from 'data/auth/auth-config-update-mutation'
-import { useCheckPermissions, useStore } from 'hooks'
+import { useCheckPermissions } from 'hooks'
import SchemaFunctionSelector from './SchemaFunctionSelector'
const schema = object({
@@ -32,7 +33,6 @@ const schema = object({
const formId = 'auth-basic-hooks-form'
const BasicHooksConfig = () => {
- const { ui } = useStore()
const { ref: projectRef } = useParams()
const {
data: authConfig,
@@ -60,17 +60,9 @@ const BasicHooksConfig = () => {
updateAuthConfig(
{ projectRef: projectRef!, config: payload },
{
- onError: () => {
- ui.setNotification({
- category: 'error',
- message: `Failed to update settings`,
- })
- },
+ onError: () => toast.error(`Failed to update settings`),
onSuccess: () => {
- ui.setNotification({
- category: 'success',
- message: `Successfully updated settings`,
- })
+ toast.success(`Successfully updated settings`)
resetForm({ values: values, initialValues: values })
},
}
diff --git a/apps/studio/components/interfaces/Billing/Payment/AddNewPaymentMethodModal.tsx b/apps/studio/components/interfaces/Billing/Payment/AddNewPaymentMethodModal.tsx
index 0041cbb6207..2fd7bf429a5 100644
--- a/apps/studio/components/interfaces/Billing/Payment/AddNewPaymentMethodModal.tsx
+++ b/apps/studio/components/interfaces/Billing/Payment/AddNewPaymentMethodModal.tsx
@@ -3,10 +3,11 @@ import { Elements } from '@stripe/react-stripe-js'
import { loadStripe } from '@stripe/stripe-js'
import { useTheme } from 'next-themes'
import { useCallback, useEffect, useState } from 'react'
+import toast from 'react-hot-toast'
import { Modal } from 'ui'
import { useOrganizationPaymentMethodSetupIntent } from 'data/organizations/organization-payment-method-setup-intent-mutation'
-import { useSelectedOrganization, useStore } from 'hooks'
+import { useSelectedOrganization } from 'hooks'
import { STRIPE_PUBLIC_KEY } from 'lib/constants'
import { useIsHCaptchaLoaded } from 'stores/hcaptcha-loaded-store'
import AddPaymentMethodForm from './AddPaymentMethodForm'
@@ -26,7 +27,6 @@ const AddNewPaymentMethodModal = ({
onCancel,
onConfirm,
}: AddNewPaymentMethodModalProps) => {
- const { ui } = useStore()
const { resolvedTheme } = useTheme()
const [intent, setIntent] = useState<any>()
const selectedOrganization = useSelectedOrganization()
@@ -40,11 +40,7 @@ const AddNewPaymentMethodModal = ({
setIntent(intent)
},
onError: (error) => {
- ui.setNotification({
- category: 'error',
- error: intent.error,
- message: `Failed to setup intent: ${error.message}`,
- })
+ toast.error(`Failed to setup intent: ${error.message}`)
},
})
diff --git a/apps/studio/components/interfaces/Billing/Payment/AddPaymentMethodForm.tsx b/apps/studio/components/interfaces/Billing/Payment/AddPaymentMethodForm.tsx
index 92cfca9fae7..581fe0a2da0 100644
--- a/apps/studio/components/interfaces/Billing/Payment/AddPaymentMethodForm.tsx
+++ b/apps/studio/components/interfaces/Billing/Payment/AddPaymentMethodForm.tsx
@@ -1,9 +1,8 @@
import { PaymentElement, useElements, useStripe } from '@stripe/react-stripe-js'
import { useState } from 'react'
+import toast from 'react-hot-toast'
import { Button, Modal } from 'ui'
-import { useStore } from 'hooks'
-
interface AddPaymentMethodFormProps {
returnUrl: string
onCancel: () => void
@@ -15,7 +14,6 @@ interface AddPaymentMethodFormProps {
// Small UX annoyance here, that the page will be refreshed
const AddPaymentMethodForm = ({ returnUrl, onCancel, onConfirm }: AddPaymentMethodFormProps) => {
- const { ui } = useStore()
const stripe = useStripe()
const elements = useElements()
@@ -44,10 +42,7 @@ const AddPaymentMethodForm = ({ returnUrl, onCancel, onConfirm }: AddPaymentMeth
if (error) {
setIsSaving(false)
- ui.setNotification({
- category: 'error',
- message: error?.message ?? ' Failed to save card details',
- })
+ toast.error(error?.message ?? ' Failed to save card details')
} else {
setIsSaving(false)
onConfirm()
diff --git a/apps/studio/components/interfaces/Database/Wrappers/CreateWrapper.tsx b/apps/studio/components/interfaces/Database/Wrappers/CreateWrapper.tsx
index f28917a8d9c..213f4584017 100644
--- a/apps/studio/components/interfaces/Database/Wrappers/CreateWrapper.tsx
+++ b/apps/studio/components/interfaces/Database/Wrappers/CreateWrapper.tsx
@@ -1,12 +1,14 @@
import { PermissionAction } from '@supabase/shared-types/out/constants'
import { useQueryClient } from '@tanstack/react-query'
+import { useParams } from 'common'
import { isEmpty } from 'lodash'
import { observer } from 'mobx-react-lite'
import Link from 'next/link'
import { useRouter } from 'next/router'
import { useState } from 'react'
+import toast from 'react-hot-toast'
+import { Button, Form, IconArrowLeft, IconEdit, IconExternalLink, IconTrash, Input } from 'ui'
-import { useParams } from 'common/hooks'
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
import {
FormActions,
@@ -18,8 +20,7 @@ import {
} from 'components/ui/Forms'
import { invalidateSchemasQuery } from 'data/database/schemas-query'
import { useFDWCreateMutation } from 'data/fdw/fdw-create-mutation'
-import { useCheckPermissions, useStore } from 'hooks'
-import { Button, Form, IconArrowLeft, IconEdit, IconExternalLink, IconTrash, Input } from 'ui'
+import { useCheckPermissions } from 'hooks'
import InputField from './InputField'
import { WRAPPERS } from './Wrappers.constants'
import { makeValidateRequired } from './Wrappers.utils'
@@ -29,7 +30,6 @@ const CreateWrapper = () => {
const formId = 'create-wrapper-form'
const router = useRouter()
const queryClient = useQueryClient()
- const { ui } = useStore()
const { ref, type } = useParams()
const { project } = useProjectContext()
const canCreateWrapper = useCheckPermissions(PermissionAction.TENANT_SQL_ADMIN_WRITE, 'wrappers')
@@ -41,10 +41,7 @@ const CreateWrapper = () => {
const { mutate: createFDW, isLoading: isCreating } = useFDWCreateMutation({
onSuccess: () => {
- ui.setNotification({
- category: 'success',
- message: `Successfully created ${wrapperMeta?.label} foreign data wrapper`,
- })
+ toast.success(`Successfully created ${wrapperMeta?.label} foreign data wrapper`)
setNewTables([])
const hasNewSchema = newTables.some((table) => table.is_new_schema)
diff --git a/apps/studio/components/interfaces/Database/Wrappers/DeleteWrapperModal.tsx b/apps/studio/components/interfaces/Database/Wrappers/DeleteWrapperModal.tsx
index 37b62bbef6f..f7033ee3b52 100644
--- a/apps/studio/components/interfaces/Database/Wrappers/DeleteWrapperModal.tsx
+++ b/apps/studio/components/interfaces/Database/Wrappers/DeleteWrapperModal.tsx
@@ -1,8 +1,9 @@
+import toast from 'react-hot-toast'
+import { Modal } from 'ui'
+
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
import { useFDWDeleteMutation } from 'data/fdw/fdw-delete-mutation'
import type { FDW } from 'data/fdw/fdws-query'
-import { useStore } from 'hooks'
-import { Modal } from 'ui'
import { WRAPPERS } from './Wrappers.constants'
interface DeleteWrapperModalProps {
@@ -11,14 +12,10 @@ interface DeleteWrapperModalProps {
}
const DeleteWrapperModal = ({ selectedWrapper, onClose }: DeleteWrapperModalProps) => {
- const { ui } = useStore()
const { project } = useProjectContext()
const { mutate: deleteFDW, isLoading: isDeleting } = useFDWDeleteMutation({
onSuccess: () => {
- ui.setNotification({
- category: 'success',
- message: `Successfully disabled ${selectedWrapper?.name} foreign data wrapper`,
- })
+ toast.success(`Successfully disabled ${selectedWrapper?.name} foreign data wrapper`)
onClose()
},
})
diff --git a/apps/studio/components/interfaces/Database/Wrappers/EditWrapper.tsx b/apps/studio/components/interfaces/Database/Wrappers/EditWrapper.tsx
index 9048a20ae2c..0ee190c7073 100644
--- a/apps/studio/components/interfaces/Database/Wrappers/EditWrapper.tsx
+++ b/apps/studio/components/interfaces/Database/Wrappers/EditWrapper.tsx
@@ -1,12 +1,13 @@
import { PermissionAction } from '@supabase/shared-types/out/constants'
import { useQueryClient } from '@tanstack/react-query'
+import { useParams } from 'common'
import { isEmpty } from 'lodash'
import { observer } from 'mobx-react-lite'
import Link from 'next/link'
import { useRouter } from 'next/router'
import { useEffect, useState } from 'react'
+import toast from 'react-hot-toast'
-import { useParams } from 'common/hooks'
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
import {
FormActions,
@@ -22,7 +23,7 @@ import { useFDWUpdateMutation } from 'data/fdw/fdw-update-mutation'
import { useFDWsQuery } from 'data/fdw/fdws-query'
import { getDecryptedValue } from 'data/vault/vault-secret-decrypted-value-query'
import { useVaultSecretsQuery } from 'data/vault/vault-secrets-query'
-import { useCheckPermissions, useImmutableValue, useStore } from 'hooks'
+import { useCheckPermissions, useImmutableValue } from 'hooks'
import {
Button,
Form,
@@ -46,7 +47,6 @@ const EditWrapper = () => {
const formId = 'edit-wrapper-form'
const router = useRouter()
const queryClient = useQueryClient()
- const { ui } = useStore()
const { ref, id } = useParams()
const { project } = useProjectContext()
@@ -68,10 +68,7 @@ const EditWrapper = () => {
const { mutate: updateFDW, isLoading: isSaving } = useFDWUpdateMutation({
onSuccess: () => {
- ui.setNotification({
- category: 'success',
- message: `Successfully updated ${wrapperMeta?.label} foreign data wrapper`,
- })
+ toast.success(`Successfully updated ${wrapperMeta?.label} foreign data wrapper`)
setWrapperTables([])
const hasNewSchema = wrapperTables.some((table) => table.is_new_schema)
diff --git a/apps/studio/components/interfaces/Functions/EdgeFunctionSecrets/AddNewSecretModal.tsx b/apps/studio/components/interfaces/Functions/EdgeFunctionSecrets/AddNewSecretModal.tsx
index f80526d3979..76b99e50bd8 100644
--- a/apps/studio/components/interfaces/Functions/EdgeFunctionSecrets/AddNewSecretModal.tsx
+++ b/apps/studio/components/interfaces/Functions/EdgeFunctionSecrets/AddNewSecretModal.tsx
@@ -1,9 +1,9 @@
import { useParams } from 'common'
import { useRef, useState } from 'react'
+import toast from 'react-hot-toast'
import { Button, Form, IconEye, IconEyeOff, Input, Modal } from 'ui'
import { useSecretsCreateMutation } from 'data/secrets/secrets-create-mutation'
-import { useStore } from 'hooks'
interface AddNewSecretModalProps {
visible: boolean
@@ -11,17 +11,13 @@ interface AddNewSecretModalProps {
}
const AddNewSecretModal = ({ visible, onClose }: AddNewSecretModalProps) => {
- const { ui } = useStore()
const { ref: projectRef } = useParams()
const submitRef = useRef<HTMLButtonElement>(null)
const [showSecretValue, setShowSecretValue] = useState(false)
const { mutate: createSecret, isLoading: isCreating } = useSecretsCreateMutation({
onSuccess: (res, variables) => {
- ui.setNotification({
- category: 'success',
- message: `Successfully created new secret "${variables.secrets[0].name}"`,
- })
+ toast.success(`Successfully created new secret "${variables.secrets[0].name}"`)
onClose()
},
})
diff --git a/apps/studio/components/interfaces/Functions/EdgeFunctionSecrets/EdgeFunctionSecrets.tsx b/apps/studio/components/interfaces/Functions/EdgeFunctionSecrets/EdgeFunctionSecrets.tsx
index 15732a74355..53bd9781550 100644
--- a/apps/studio/components/interfaces/Functions/EdgeFunctionSecrets/EdgeFunctionSecrets.tsx
+++ b/apps/studio/components/interfaces/Functions/EdgeFunctionSecrets/EdgeFunctionSecrets.tsx
@@ -1,20 +1,19 @@
import { useParams } from 'common'
import Link from 'next/link'
import { useState } from 'react'
+import toast from 'react-hot-toast'
import { Button, IconExternalLink, IconSearch, Input, Modal } from 'ui'
+import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
import Table from 'components/to-be-cleaned/Table'
import AlertError from 'components/ui/AlertError'
-import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'
import { useSecretsDeleteMutation } from 'data/secrets/secrets-delete-mutation'
import { ProjectSecret, useSecretsQuery } from 'data/secrets/secrets-query'
-import { useStore } from 'hooks'
import AddNewSecretModal from './AddNewSecretModal'
import EdgeFunctionSecret from './EdgeFunctionSecret'
const EdgeFunctionSecrets = () => {
- const { ui } = useStore()
const { ref: projectRef } = useParams()
const [searchString, setSearchString] = useState('')
const [showCreateSecret, setShowCreateSecret] = useState(false)
@@ -26,10 +25,7 @@ const EdgeFunctionSecrets = () => {
const { mutate: deleteSecret, isLoading: isDeleting } = useSecretsDeleteMutation({
onSuccess: () => {
- ui.setNotification({
- category: 'success',
- message: `Successfully deleted ${selectedSecret?.name}`,
- })
+ toast.success(`Successfully deleted ${selectedSecret?.name}`)
setSelectedSecret(undefined)
},
})
diff --git a/apps/studio/components/interfaces/Integrations/IntegrationConnection.tsx b/apps/studio/components/interfaces/Integrations/IntegrationConnection.tsx
index 78122f739a7..3f4974ec761 100644
--- a/apps/studio/components/interfaces/Integrations/IntegrationConnection.tsx
+++ b/apps/studio/components/interfaces/Integrations/IntegrationConnection.tsx
@@ -1,6 +1,7 @@
import Link from 'next/link'
import { useRouter } from 'next/router'
import { forwardRef, useCallback, useState } from 'react'
+import toast from 'react-hot-toast'
import {
AlertDescription_Shadcn_,
AlertTitle_Shadcn_,
@@ -23,11 +24,10 @@ import {
IntegrationConnection,
IntegrationConnectionProps,
} from 'components/interfaces/Integrations/IntegrationPanels'
-import { WarningIcon } from 'ui-patterns/Icons/StatusIcons'
import { useIntegrationsVercelConnectionSyncEnvsMutation } from 'data/integrations/integrations-vercel-connection-sync-envs-mutation'
import type { IntegrationProjectConnection } from 'data/integrations/integrations.types'
import { useProjectsQuery } from 'data/projects/projects-query'
-import { useStore } from 'hooks'
+import { WarningIcon } from 'ui-patterns/Icons/StatusIcons'
interface IntegrationConnectionItemProps extends IntegrationConnectionProps {
disabled?: boolean
@@ -36,7 +36,6 @@ interface IntegrationConnectionItemProps extends IntegrationConnectionProps {
const IntegrationConnectionItem = forwardRef<HTMLLIElement, IntegrationConnectionItemProps>(
({ disabled, onDeleteConnection, ...props }, ref) => {
- const { ui } = useStore()
const router = useRouter()
const { type, connection } = props
@@ -62,10 +61,7 @@ const IntegrationConnectionItem = forwardRef<HTMLLIElement, IntegrationConnectio
const { mutate: syncEnvs, isLoading: isSyncEnvLoading } =
useIntegrationsVercelConnectionSyncEnvsMutation({
onSuccess: () => {
- ui.setNotification({
- category: 'success',
- message: 'Successfully synced environment variables',
- })
+ toast.success('Successfully synced environment variables')
setDropdownVisible(false)
},
})
diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/BillingAddress/BillingAddress.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/BillingAddress/BillingAddress.tsx
index c30aa76e556..454956fb6ec 100644
--- a/apps/studio/components/interfaces/Organization/BillingSettings/BillingAddress/BillingAddress.tsx
+++ b/apps/studio/components/interfaces/Organization/BillingSettings/BillingAddress/BillingAddress.tsx
@@ -1,7 +1,9 @@
import { PermissionAction } from '@supabase/shared-types/out/constants'
+import { useParams } from 'common'
import { useEffect } from 'react'
+import toast from 'react-hot-toast'
+import { Form, Input, Listbox } from 'ui'
-import { useParams } from 'common'
import {
ScaffoldSection,
ScaffoldSectionContent,
@@ -13,12 +15,10 @@ import NoPermission from 'components/ui/NoPermission'
import ShimmeringLoader from 'components/ui/ShimmeringLoader'
import { useOrganizationCustomerProfileQuery } from 'data/organizations/organization-customer-profile-query'
import { useOrganizationCustomerProfileUpdateMutation } from 'data/organizations/organization-customer-profile-update-mutation'
-import { useCheckPermissions, useStore } from 'hooks'
-import { Form, Input, Listbox } from 'ui'
+import { useCheckPermissions } from 'hooks'
import { COUNTRIES } from './BillingAddress.constants'
const BillingAddress = () => {
- const { ui } = useStore()
const { slug } = useParams()
const { data, error, isLoading, isSuccess, isError } = useOrganizationCustomerProfileQuery({
slug,
@@ -56,10 +56,7 @@ const BillingAddress = () => {
try {
await updateCustomerProfile({ slug, address: values })
- ui.setNotification({
- category: 'success',
- message: 'Successfully updated billing address',
- })
+ toast.success('Successfully updated billing address')
resetForm({ values, initialValues: values })
} catch (error) {}
}
diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/PaymentMethods/DeletePaymentMethodModal.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/PaymentMethods/DeletePaymentMethodModal.tsx
index 770976f4009..75ffd0881cb 100644
--- a/apps/studio/components/interfaces/Organization/BillingSettings/PaymentMethods/DeletePaymentMethodModal.tsx
+++ b/apps/studio/components/interfaces/Organization/BillingSettings/PaymentMethods/DeletePaymentMethodModal.tsx
@@ -1,8 +1,9 @@
import { useParams } from 'common'
+import toast from 'react-hot-toast'
+import { Alert, Button, Modal } from 'ui'
+
import { useOrganizationPaymentMethodDeleteMutation } from 'data/organizations/organization-payment-method-delete-mutation'
import type { OrganizationPaymentMethod } from 'data/organizations/organization-payment-methods-query'
-import { useStore } from 'hooks'
-import { Alert, Button, Modal } from 'ui'
export interface DeletePaymentMethodModalProps {
selectedPaymentMethod?: OrganizationPaymentMethod
@@ -13,18 +14,14 @@ const DeletePaymentMethodModal = ({
selectedPaymentMethod,
onClose,
}: DeletePaymentMethodModalProps) => {
- const { ui } = useStore()
const { slug } = useParams()
const { mutate: deletePayment, isLoading: isDeleting } =
useOrganizationPaymentMethodDeleteMutation({
onSuccess: () => {
- ui.setNotification({
- category: 'success',
- message: `Successfully removed payment method ending with ${
- selectedPaymentMethod!.card.last4
- }`,
- })
+ toast.success(
+ `Successfully removed payment method ending with ${selectedPaymentMethod!.card.last4}`
+ )
onClose()
},
})
diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/PaymentMethods/PaymentMethods.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/PaymentMethods/PaymentMethods.tsx
index b1c8a5da7b4..044cd902616 100644
--- a/apps/studio/components/interfaces/Organization/BillingSettings/PaymentMethods/PaymentMethods.tsx
+++ b/apps/studio/components/interfaces/Organization/BillingSettings/PaymentMethods/PaymentMethods.tsx
@@ -1,8 +1,24 @@
import { PermissionAction } from '@supabase/shared-types/out/constants'
import { useQueryClient } from '@tanstack/react-query'
+import { useParams } from 'common'
+import Link from 'next/link'
import { useState } from 'react'
+import toast from 'react-hot-toast'
+import {
+ Alert,
+ Badge,
+ Button,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuSeparator,
+ DropdownMenuTrigger,
+ IconCreditCard,
+ IconMoreHorizontal,
+ IconPlus,
+} from 'ui'
-import { useParams } from 'common'
+import AddNewPaymentMethodModal from 'components/interfaces/Billing/Payment/AddNewPaymentMethodModal'
import {
ScaffoldSection,
ScaffoldSectionContent,
@@ -15,29 +31,13 @@ import ShimmeringLoader from 'components/ui/ShimmeringLoader'
import { organizationKeys } from 'data/organizations/keys'
import { useOrganizationPaymentMethodsQuery } from 'data/organizations/organization-payment-methods-query'
import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'
-import { useCheckPermissions, useStore } from 'hooks'
+import { useCheckPermissions } from 'hooks'
import { BASE_PATH } from 'lib/constants'
import { getURL } from 'lib/helpers'
-import Link from 'next/link'
-import {
- Alert,
- Badge,
- Button,
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuSeparator,
- DropdownMenuTrigger,
- IconCreditCard,
- IconMoreHorizontal,
- IconPlus,
-} from 'ui'
import ChangePaymentMethodModal from './ChangePaymentMethodModal'
import DeletePaymentMethodModal from './DeletePaymentMethodModal'
-import AddNewPaymentMethodModal from 'components/interfaces/Billing/Payment/AddNewPaymentMethodModal'
const PaymentMethods = () => {
- const { ui } = useStore()
const { slug } = useParams()
const queryClient = useQueryClient()
const [selectedMethodForUse, setSelectedMethodForUse] = useState<any>()
@@ -224,10 +224,7 @@ const PaymentMethods = () => {
onCancel={() => setShowAddPaymentMethodModal(false)}
onConfirm={async () => {
setShowAddPaymentMethodModal(false)
- ui.setNotification({
- category: 'success',
- message: 'Successfully added new payment method',
- })
+ toast.success('Successfully added new payment method')
await queryClient.invalidateQueries(organizationKeys.paymentMethods(slug))
}}
/>
diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PaymentMethodSelection.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PaymentMethodSelection.tsx
index d9ec63e6538..e49b4160a7f 100644
--- a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PaymentMethodSelection.tsx
+++ b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PaymentMethodSelection.tsx
@@ -1,15 +1,15 @@
import * as Tooltip from '@radix-ui/react-tooltip'
import { PermissionAction } from '@supabase/shared-types/out/constants'
import { useEffect, useMemo, useState } from 'react'
+import toast from 'react-hot-toast'
+import { Button, IconAlertCircle, IconCreditCard, IconLoader, IconPlus, Listbox } from 'ui'
-import { useParams } from 'common'
+import AddNewPaymentMethodModal from 'components/interfaces/Billing/Payment/AddNewPaymentMethodModal'
import { useOrganizationCustomerProfileQuery } from 'data/organizations/organization-customer-profile-query'
import { useOrganizationPaymentMethodsQuery } from 'data/organizations/organization-payment-methods-query'
-import { useCheckPermissions, useSelectedOrganization, useStore } from 'hooks'
+import { useCheckPermissions, useSelectedOrganization } from 'hooks'
import { BASE_PATH } from 'lib/constants'
import { getURL } from 'lib/helpers'
-import { Button, IconAlertCircle, IconCreditCard, IconLoader, IconPlus, Listbox } from 'ui'
-import AddNewPaymentMethodModal from 'components/interfaces/Billing/Payment/AddNewPaymentMethodModal'
export interface PaymentMethodSelectionProps {
selectedPaymentMethod?: string
@@ -22,8 +22,6 @@ const PaymentMethodSelection = ({
onSelectPaymentMethod,
layout = 'vertical',
}: PaymentMethodSelectionProps) => {
- const { ui } = useStore()
- const { ref: projectRef } = useParams()
const selectedOrganization = useSelectedOrganization()
const slug = selectedOrganization?.slug
const [showAddNewPaymentMethodModal, setShowAddNewPaymentMethodModal] = useState(false)
@@ -167,10 +165,7 @@ const PaymentMethodSelection = ({
onCancel={() => setShowAddNewPaymentMethodModal(false)}
onConfirm={async () => {
setShowAddNewPaymentMethodModal(false)
- ui.setNotification({
- category: 'success',
- message: 'Successfully added new payment method',
- })
+ toast.success('Successfully added new payment method')
const { data } = await refetchPaymentMethods()
if (data?.length) {
// Preselect the card that was just added
diff --git a/apps/studio/components/interfaces/Organization/Documents/SOC2.tsx b/apps/studio/components/interfaces/Organization/Documents/SOC2.tsx
index 2506a5fdab2..675fe63790b 100644
--- a/apps/studio/components/interfaces/Organization/Documents/SOC2.tsx
+++ b/apps/studio/components/interfaces/Organization/Documents/SOC2.tsx
@@ -1,5 +1,10 @@
-import Link from 'next/link'
import { useParams } from 'common'
+import Link from 'next/link'
+import { useState } from 'react'
+import toast from 'react-hot-toast'
+import { Button, IconDownload, Modal } from 'ui'
+import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
+
import {
ScaffoldSection,
ScaffoldSectionContent,
@@ -7,16 +12,11 @@ import {
} from 'components/layouts/Scaffold'
import AlertError from 'components/ui/AlertError'
import ShimmeringLoader from 'components/ui/ShimmeringLoader'
-import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'
-import { Button, IconDownload, Modal } from 'ui'
-import { useState } from 'react'
-import { useStore } from 'hooks'
-import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
import { getDocument } from 'data/documents/document-query'
+import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'
const SOC2 = () => {
const { slug } = useParams()
- const { ui } = useStore()
const {
data: subscription,
error,
@@ -33,10 +33,7 @@ const SOC2 = () => {
if (soc2Link?.fileUrl) window.open(soc2Link.fileUrl, '_blank')
setIsOpen(false)
} catch (error: any) {
- ui.setNotification({
- category: 'error',
- message: `Failed to download SOC2 report: ${error.message}`,
- })
+ toast.error(`Failed to download SOC2 report: ${error.message}`)
}
}
diff --git a/apps/studio/components/interfaces/Organization/Documents/SecurityQuestionnaire.tsx b/apps/studio/components/interfaces/Organization/Documents/SecurityQuestionnaire.tsx
index 04befff3912..ca032652b0d 100644
--- a/apps/studio/components/interfaces/Organization/Documents/SecurityQuestionnaire.tsx
+++ b/apps/studio/components/interfaces/Organization/Documents/SecurityQuestionnaire.tsx
@@ -1,5 +1,8 @@
-import Link from 'next/link'
import { useParams } from 'common'
+import Link from 'next/link'
+import toast from 'react-hot-toast'
+import { Button, IconDownload } from 'ui'
+
import {
ScaffoldSection,
ScaffoldSectionContent,
@@ -7,14 +10,11 @@ import {
} from 'components/layouts/Scaffold'
import AlertError from 'components/ui/AlertError'
import ShimmeringLoader from 'components/ui/ShimmeringLoader'
-import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'
-import { Button, IconDownload } from 'ui'
-import { useStore } from 'hooks'
import { getDocument } from 'data/documents/document-query'
+import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'
const SecurityQuestionnaire = () => {
const { slug } = useParams()
- const { ui } = useStore()
const {
data: subscription,
error,
@@ -32,10 +32,7 @@ const SecurityQuestionnaire = () => {
})
if (questionnaireLink?.fileUrl) window.open(questionnaireLink.fileUrl, '_blank')
} catch (error: any) {
- ui.setNotification({
- category: 'error',
- message: `Failed to download Security Questionnaire: ${error.message}`,
- })
+ toast.error(`Failed to download Security Questionnaire: ${error.message}`)
}
}
diff --git a/apps/studio/components/interfaces/Organization/IntegrationSettings/IntegrationSettings.tsx b/apps/studio/components/interfaces/Organization/IntegrationSettings/IntegrationSettings.tsx
index ac57389031e..44975703eda 100644
--- a/apps/studio/components/interfaces/Organization/IntegrationSettings/IntegrationSettings.tsx
+++ b/apps/studio/components/interfaces/Organization/IntegrationSettings/IntegrationSettings.tsx
@@ -1,4 +1,5 @@
import { useCallback } from 'react'
+import toast from 'react-hot-toast'
import { EmptyIntegrationConnection } from 'components/interfaces/Integrations/IntegrationPanels'
import { Markdown } from 'components/interfaces/Markdown'
@@ -13,7 +14,7 @@ import {
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 { useFlag, useSelectedOrganization, useStore } from 'hooks'
+import { useFlag, useSelectedOrganization } from 'hooks'
import { BASE_PATH } from 'lib/constants'
import { useSidePanelsStateSnapshot } from 'state/side-panels'
import { IntegrationConnectionItem } from '../../Integrations/IntegrationConnection'
@@ -31,17 +32,13 @@ const IntegrationImageHandler = ({ title }: { title: 'vercel' | 'github' }) => {
}
const IntegrationSettings = () => {
- const { ui } = useStore()
const org = useSelectedOrganization()
const hasAccessToBranching = useFlag<boolean>('branchManagement')
const { data: connections } = useGitHubConnectionsQuery({ organizationId: org?.id })
const { mutate: deleteGitHubConnection } = useGitHubConnectionDeleteMutation({
onSuccess: () => {
- ui.setNotification({
- category: 'success',
- message: 'Successfully deleted Github connection',
- })
+ toast.success('Successfully deleted Github connection')
},
})
diff --git a/apps/studio/components/interfaces/Organization/IntegrationSettings/SidePanelVercelProjectLinker.tsx b/apps/studio/components/interfaces/Organization/IntegrationSettings/SidePanelVercelProjectLinker.tsx
index a597118305b..eb883e15110 100644
--- a/apps/studio/components/interfaces/Organization/IntegrationSettings/SidePanelVercelProjectLinker.tsx
+++ b/apps/studio/components/interfaces/Organization/IntegrationSettings/SidePanelVercelProjectLinker.tsx
@@ -1,5 +1,7 @@
import { keyBy } from 'lodash'
import { useCallback, useMemo } from 'react'
+import toast from 'react-hot-toast'
+import { SidePanel } from 'ui'
import { ENV_VAR_RAW_KEYS } from 'components/interfaces/Integrations/Integrations-Vercel.constants'
import ProjectLinker, { ForeignProject } from 'components/interfaces/Integrations/ProjectLinker'
@@ -9,11 +11,10 @@ import { useOrgIntegrationsQuery } from 'data/integrations/integrations-query-or
import { useIntegrationVercelConnectionsCreateMutation } from 'data/integrations/integrations-vercel-connections-create-mutation'
import { useVercelProjectsQuery } from 'data/integrations/integrations-vercel-projects-query'
import { useProjectsQuery } from 'data/projects/projects-query'
-import { useSelectedOrganization, useStore } from 'hooks'
+import { useSelectedOrganization } from 'hooks'
import { BASE_PATH } from 'lib/constants'
import { EMPTY_ARR } from 'lib/void'
import { useSidePanelsStateSnapshot } from 'state/side-panels'
-import { SidePanel } from 'ui'
const VERCEL_ICON = (
<svg xmlns="http://www.w3.org/2000/svg" fill="white" viewBox="0 0 512 512" className="w-6">
@@ -22,7 +23,6 @@ const VERCEL_ICON = (
)
const SidePanelVercelProjectLinker = () => {
- const { ui } = useStore()
const selectedOrganization = useSelectedOrganization()
const sidePanelStateSnapshot = useSidePanelsStateSnapshot()
const organizationIntegrationId = sidePanelStateSnapshot.vercelConnectionsIntegrationId
@@ -89,11 +89,9 @@ const SidePanelVercelProjectLinker = () => {
useIntegrationVercelConnectionsCreateMutation({
async onSuccess({ env_sync_error: envSyncError }) {
if (envSyncError) {
- ui.setNotification({
- category: 'error',
- message: `Failed to sync environment variables: ${envSyncError.message}`,
- description: 'Please try re-syncing manually from settings.',
- })
+ toast.error(
+ `Failed to sync environment variables: ${envSyncError.message}. Please try re-syncing manually from settings.`
+ )
}
sidePanelStateSnapshot.setVercelConnectionsOpen(false)
diff --git a/apps/studio/components/interfaces/Organization/InvoicesSettings/InvoicesSettings.tsx b/apps/studio/components/interfaces/Organization/InvoicesSettings/InvoicesSettings.tsx
index 6a3a1d80497..23c71c1048e 100644
--- a/apps/studio/components/interfaces/Organization/InvoicesSettings/InvoicesSettings.tsx
+++ b/apps/studio/components/interfaces/Organization/InvoicesSettings/InvoicesSettings.tsx
@@ -1,7 +1,10 @@
import { PermissionAction } from '@supabase/shared-types/out/constants'
import Link from 'next/link'
import { useEffect, useState } from 'react'
+import toast from 'react-hot-toast'
+import { Button, IconChevronLeft, IconChevronRight, IconDownload, IconFileText } from 'ui'
+import InvoiceStatusBadge from 'components/interfaces/Billing/InvoiceStatusBadge'
import { InvoiceStatus } from 'components/interfaces/Billing/Invoices.types'
import { ScaffoldContainerLegacy } from 'components/layouts/Scaffold'
import Table from 'components/to-be-cleaned/Table'
@@ -11,15 +14,12 @@ import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'
import { getInvoice } from 'data/invoices/invoice-query'
import { useInvoicesCountQuery } from 'data/invoices/invoices-count-query'
import { useInvoicesQuery } from 'data/invoices/invoices-query'
-import { useCheckPermissions, useSelectedOrganization, useStore } from 'hooks'
-import { Button, IconChevronLeft, IconChevronRight, IconDownload, IconFileText } from 'ui'
-import InvoiceStatusBadge from 'components/interfaces/Billing/InvoiceStatusBadge'
+import { useCheckPermissions, useSelectedOrganization } from 'hooks'
import { formatCurrency } from 'lib/helpers'
const PAGE_LIMIT = 10
const InvoicesSettings = () => {
- const { ui } = useStore()
const [page, setPage] = useState(1)
const selectedOrganization = useSelectedOrganization()
@@ -49,10 +49,7 @@ const InvoicesSettings = () => {
const invoice = await getInvoice({ id })
if (invoice?.invoice_pdf) window.open(invoice.invoice_pdf, '_blank')
} catch (error: any) {
- ui.setNotification({
- category: 'info',
- message: `Failed to fetch the selected invoice: ${error.message}`,
- })
+ toast.error(`Failed to fetch the selected invoice: ${error.message}`)
}
}
diff --git a/apps/studio/components/interfaces/Organization/OAuthApps/RevokeAppModal.tsx b/apps/studio/components/interfaces/Organization/OAuthApps/RevokeAppModal.tsx
index 47f7e64bcb9..5583bef9226 100644
--- a/apps/studio/components/interfaces/Organization/OAuthApps/RevokeAppModal.tsx
+++ b/apps/studio/components/interfaces/Organization/OAuthApps/RevokeAppModal.tsx
@@ -1,8 +1,9 @@
import { useParams } from 'common'
+import toast from 'react-hot-toast'
+import { Alert, IconLock, Modal } from 'ui'
+
import { useAuthorizedAppRevokeMutation } from 'data/oauth/authorized-app-revoke-mutation'
import type { AuthorizedApp } from 'data/oauth/authorized-apps-query'
-import { useStore } from 'hooks'
-import { Alert, IconLock, Modal } from 'ui'
export interface RevokeAppModalProps {
selectedApp?: AuthorizedApp
@@ -10,14 +11,10 @@ export interface RevokeAppModalProps {
}
const RevokeAppModal = ({ selectedApp, onClose }: RevokeAppModalProps) => {
- const { ui } = useStore()
const { slug } = useParams()
const { mutate: revokeAuthorizedApp, isLoading: isDeleting } = useAuthorizedAppRevokeMutation({
onSuccess: () => {
- ui.setNotification({
- category: 'success',
- message: `Successfully revoked the app "${selectedApp?.name}"`,
- })
+ toast.success(`Successfully revoked the app "${selectedApp?.name}"`)
onClose()
},
})
diff --git a/apps/studio/components/interfaces/SQLEditor/SQLTemplates/SQLQuickstarts.tsx b/apps/studio/components/interfaces/SQLEditor/SQLTemplates/SQLQuickstarts.tsx
index 1bb12104b9f..6ae77372afb 100644
--- a/apps/studio/components/interfaces/SQLEditor/SQLTemplates/SQLQuickstarts.tsx
+++ b/apps/studio/components/interfaces/SQLEditor/SQLTemplates/SQLQuickstarts.tsx
@@ -1,21 +1,21 @@
import { PermissionAction } from '@supabase/shared-types/out/constants'
+import { useParams, useTelemetryProps } from 'common'
import { partition } from 'lodash'
import { observer } from 'mobx-react-lite'
+import { useRouter } from 'next/router'
+import toast from 'react-hot-toast'
-import { useParams, useTelemetryProps } from 'common'
import { SQL_TEMPLATES } from 'components/interfaces/SQLEditor/SQLEditor.queries'
import type { SqlSnippet } from 'data/content/sql-snippets-query'
-import { useCheckPermissions, useSelectedProject, useStore } from 'hooks'
+import { useCheckPermissions, useSelectedProject } from 'hooks'
import { uuidv4 } from 'lib/helpers'
import { useProfile } from 'lib/profile'
import Telemetry from 'lib/telemetry'
-import { useRouter } from 'next/router'
import { useSqlEditorStateSnapshot } from 'state/sql-editor'
import { createSqlSnippetSkeleton } from '../SQLEditor.utils'
import SQLCard from './SQLCard'
const SQLQuickstarts = observer(() => {
- const { ui } = useStore()
const { ref } = useParams()
const router = useRouter()
const { profile } = useProfile()
@@ -32,10 +32,7 @@ const SQLQuickstarts = observer(() => {
const handleNewQuery = async (sql: string, name: string) => {
if (!ref) return console.error('Project ref is required')
if (!canCreateSQLSnippet) {
- return ui.setNotification({
- category: 'info',
- message: 'Your queries will not be saved as you do not have sufficient permissions',
- })
+ return toast('Your queries will not be saved as you do not have sufficient permissions')
}
try {
@@ -50,10 +47,7 @@ const SQLQuickstarts = observer(() => {
snap.addNeedsSaving(snippet.id!)
router.push(`/project/${ref}/sql/${snippet.id}`)
} catch (error: any) {
- ui.setNotification({
- category: 'error',
- message: `Failed to create new query: ${error.message}`,
- })
+ toast.error(`Failed to create new query: ${error.message}`)
}
}
diff --git a/apps/studio/components/interfaces/SQLEditor/SQLTemplates/SQLTemplates.tsx b/apps/studio/components/interfaces/SQLEditor/SQLTemplates/SQLTemplates.tsx
index 2de33112c81..124733d20b7 100644
--- a/apps/studio/components/interfaces/SQLEditor/SQLTemplates/SQLTemplates.tsx
+++ b/apps/studio/components/interfaces/SQLEditor/SQLTemplates/SQLTemplates.tsx
@@ -1,8 +1,10 @@
import { PermissionAction } from '@supabase/shared-types/out/constants'
import { partition } from 'lodash'
import { observer } from 'mobx-react-lite'
-
+import toast from 'react-hot-toast'
import { useTelemetryProps } from 'common'
+import { useRouter } from 'next/router'
+
import { SQL_TEMPLATES } from 'components/interfaces/SQLEditor/SQLEditor.queries'
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
import type { SqlSnippet } from 'data/content/sql-snippets-query'
@@ -10,13 +12,11 @@ import { useCheckPermissions, useStore } from 'hooks'
import { uuidv4 } from 'lib/helpers'
import { useProfile } from 'lib/profile'
import Telemetry from 'lib/telemetry'
-import { useRouter } from 'next/router'
import { useSqlEditorStateSnapshot } from 'state/sql-editor'
import { createSqlSnippetSkeleton } from '../SQLEditor.utils'
import SQLCard from './SQLCard'
const SQLTemplates = observer(() => {
- const { ui } = useStore()
const router = useRouter()
const { profile } = useProfile()
const { project } = useProjectContext()
@@ -33,10 +33,7 @@ const SQLTemplates = observer(() => {
if (!project) return console.error('Project is required')
if (!profile) return console.error('Profile is required')
if (!canCreateSQLSnippet) {
- return ui.setNotification({
- category: 'info',
- message: 'Your queries will not be saved as you do not have sufficient permissions',
- })
+ return toast('Your queries will not be saved as you do not have sufficient permissions')
}
try {
@@ -52,10 +49,7 @@ const SQLTemplates = observer(() => {
snap.addNeedsSaving(snippet.id!)
router.push(`/project/${project.ref}/sql/${snippet.id}`)
} catch (error: any) {
- ui.setNotification({
- category: 'error',
- message: `Failed to create new query: ${error.message}`,
- })
+ toast.error(`Failed to create new query: ${error.message}`)
}
}
diff --git a/apps/studio/components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling.tsx b/apps/studio/components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling.tsx
index d5d433a63c4..b2c2d607a66 100644
--- a/apps/studio/components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling.tsx
+++ b/apps/studio/components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling.tsx
@@ -4,6 +4,7 @@ import { useParams } from 'common'
import { capitalize } from 'lodash'
import { Fragment, useEffect } from 'react'
import { SubmitHandler, useForm } from 'react-hook-form'
+import toast from 'react-hot-toast'
import {
AlertDescription_Shadcn_,
AlertTitle_Shadcn_,
@@ -34,7 +35,7 @@ import { useMaxConnectionsQuery } from 'data/database/max-connections-query'
import { usePoolingConfigurationQuery } from 'data/database/pooling-configuration-query'
import { usePoolingConfigurationUpdateMutation } from 'data/database/pooling-configuration-update-mutation'
import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query'
-import { useCheckPermissions, useStore } from 'hooks'
+import { useCheckPermissions } from 'hooks'
import { useDatabaseSettingsStateSnapshot } from 'state/database-settings'
import { SESSION_MODE_DESCRIPTION, TRANSACTION_MODE_DESCRIPTION } from '../Database.constants'
import { POOLING_OPTIMIZATIONS } from './ConnectionPooling.constants'
@@ -62,7 +63,6 @@ const FormSchema = z.object({
})
export const ConnectionPooling = () => {
- const { ui } = useStore()
const { ref: projectRef } = useParams()
const { project } = useProjectContext()
const snap = useDatabaseSettingsStateSnapshot()
@@ -126,8 +126,7 @@ export const ConnectionPooling = () => {
max_client_conn: poolingConfiguration?.max_client_conn,
})
}
-
- ui.setNotification({ category: 'success', message: 'Successfully saved settings' })
+ toast.success('Successfully saved settings')
},
})
diff --git a/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/ResetDbPassword.tsx b/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/ResetDbPassword.tsx
index 4d50fe665ee..dcaba5cd42e 100644
--- a/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/ResetDbPassword.tsx
+++ b/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/ResetDbPassword.tsx
@@ -4,6 +4,7 @@ import { useParams } from 'common'
import generator from 'generate-password-browser'
import { debounce } from 'lodash'
import { useEffect, useRef, useState } from 'react'
+import toast from 'react-hot-toast'
import { Button, Input, Modal } from 'ui'
import {
@@ -13,14 +14,12 @@ import {
import Panel from 'components/ui/Panel'
import PasswordStrengthBar from 'components/ui/PasswordStrengthBar'
import { useDatabasePasswordResetMutation } from 'data/database/database-password-reset-mutation'
-import { useCheckPermissions, useStore } from 'hooks'
+import { useCheckPermissions } from 'hooks'
import { DEFAULT_MINIMUM_PASSWORD_STRENGTH } from 'lib/constants'
import { passwordStrength } from 'lib/helpers'
const ResetDbPassword = ({ disabled = false }) => {
const { ref } = useParams()
- const { ui } = useStore()
-
const isProjectActive = useIsProjectActive()
const { project } = useProjectContext()
const canResetDbPassword = useCheckPermissions(PermissionAction.UPDATE, 'projects', {
@@ -39,10 +38,7 @@ const ResetDbPassword = ({ disabled = false }) => {
const { mutate: resetDatabasePassword, isLoading: isUpdatingPassword } =
useDatabasePasswordResetMutation({
onSuccess: async () => {
- ui.setNotification({
- category: 'success',
- message: 'Successfully updated database password',
- })
+ toast.success('Successfully updated database password')
setShowResetDbPass(false)
},
})
diff --git a/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/RemoveRestrictionModal.tsx b/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/RemoveRestrictionModal.tsx
index 4cc3035c758..77f09cad631 100644
--- a/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/RemoveRestrictionModal.tsx
+++ b/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/RemoveRestrictionModal.tsx
@@ -1,9 +1,9 @@
import { useParams } from 'common'
+import toast from 'react-hot-toast'
import { Alert, Button, Modal } from 'ui'
-import { useNetworkRestrictionsApplyMutation } from 'data/network-restrictions/network-retrictions-apply-mutation'
-import { useStore } from 'hooks'
import { useNetworkRestrictionsQuery } from 'data/network-restrictions/network-restrictions-query'
+import { useNetworkRestrictionsApplyMutation } from 'data/network-restrictions/network-retrictions-apply-mutation'
interface RemoveRestrictionModalProps {
visible: boolean
@@ -16,7 +16,6 @@ const RemoveRestrictionModal = ({
selectedRestriction,
onClose,
}: RemoveRestrictionModalProps) => {
- const { ui } = useStore()
const { ref } = useParams()
const { data } = useNetworkRestrictionsQuery({ projectRef: ref })
@@ -29,10 +28,7 @@ const RemoveRestrictionModal = ({
useNetworkRestrictionsApplyMutation({
onSuccess: () => onClose(),
onError: (error) => {
- ui.setNotification({
- category: 'error',
- message: `Failed to remove restriction: ${error.message}`,
- })
+ toast.error(`Failed to remove restriction: ${error.message}`)
},
})
diff --git a/apps/studio/components/interfaces/Settings/General/CustomDomainConfig/CustomDomainActivate.tsx b/apps/studio/components/interfaces/Settings/General/CustomDomainConfig/CustomDomainActivate.tsx
index b7d20ff1703..8f97e9792f8 100644
--- a/apps/studio/components/interfaces/Settings/General/CustomDomainConfig/CustomDomainActivate.tsx
+++ b/apps/studio/components/interfaces/Settings/General/CustomDomainConfig/CustomDomainActivate.tsx
@@ -1,6 +1,7 @@
import { observer } from 'mobx-react-lite'
import Link from 'next/link'
import { useState } from 'react'
+import toast from 'react-hot-toast'
import {
AlertDescription_Shadcn_,
AlertTitle_Shadcn_,
@@ -10,15 +11,14 @@ import {
IconExternalLink,
Modal,
} from 'ui'
-
import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
+
import Panel from 'components/ui/Panel'
import { useProjectApiQuery } from 'data/config/project-api-query'
import { useCheckCNAMERecordMutation } from 'data/custom-domains/check-cname-mutation'
import { useCustomDomainActivateMutation } from 'data/custom-domains/custom-domains-activate-mutation'
import { useCustomDomainDeleteMutation } from 'data/custom-domains/custom-domains-delete-mutation'
import type { CustomDomainResponse } from 'data/custom-domains/custom-domains-query'
-import { useStore } from 'hooks'
export type CustomDomainActivateProps = {
projectRef?: string
@@ -26,7 +26,6 @@ export type CustomDomainActivateProps = {
}
const CustomDomainActivate = ({ projectRef, customDomain }: CustomDomainActivateProps) => {
- const { ui } = useStore()
const [isActivateConfirmModalVisible, setIsActivateConfirmModalVisible] = useState(false)
const { data: settings } = useProjectApiQuery({ projectRef })
@@ -34,7 +33,7 @@ const CustomDomainActivate = ({ projectRef, customDomain }: CustomDomainActivate
const { mutate: activateCustomDomain, isLoading: isActivating } = useCustomDomainActivateMutation(
{
onSuccess: () => {
- ui.setNotification({ category: 'success', message: `Successfully activated custom domain` })
+ toast.success(`Successfully activated custom domain`)
setIsActivateConfirmModalVisible(false)
},
}
diff --git a/apps/studio/components/interfaces/Settings/General/CustomDomainConfig/CustomDomainDelete.tsx b/apps/studio/components/interfaces/Settings/General/CustomDomainConfig/CustomDomainDelete.tsx
index 4e4341ef4c2..a943eb10a4c 100644
--- a/apps/studio/components/interfaces/Settings/General/CustomDomainConfig/CustomDomainDelete.tsx
+++ b/apps/studio/components/interfaces/Settings/General/CustomDomainConfig/CustomDomainDelete.tsx
@@ -1,13 +1,13 @@
import { observer } from 'mobx-react-lite'
import Link from 'next/link'
import { useState } from 'react'
+import toast from 'react-hot-toast'
import { Button, IconExternalLink, IconTrash } from 'ui'
-
import ConfirmModal from 'ui-patterns/Dialogs/ConfirmDialog'
+
import Panel from 'components/ui/Panel'
import { useCustomDomainDeleteMutation } from 'data/custom-domains/custom-domains-delete-mutation'
import type { CustomDomainResponse } from 'data/custom-domains/custom-domains-query'
-import { useStore } from 'hooks'
export type CustomDomainDeleteProps = {
projectRef?: string
@@ -15,11 +15,10 @@ export type CustomDomainDeleteProps = {
}
const CustomDomainDelete = ({ projectRef, customDomain }: CustomDomainDeleteProps) => {
- const { ui } = useStore()
const [isDeleteConfirmModalVisible, setIsDeleteConfirmModalVisible] = useState(false)
const { mutate: deleteCustomDomain } = useCustomDomainDeleteMutation({
onSuccess: () => {
- ui.setNotification({ category: 'success', message: `Successfully deleted custom domain` })
+ toast.success(`Successfully deleted custom domain`)
setIsDeleteConfirmModalVisible(false)
},
})
diff --git a/apps/studio/components/interfaces/Settings/General/General.tsx b/apps/studio/components/interfaces/Settings/General/General.tsx
index 9162e14ee8f..d3dd4f92dfc 100644
--- a/apps/studio/components/interfaces/Settings/General/General.tsx
+++ b/apps/studio/components/interfaces/Settings/General/General.tsx
@@ -1,25 +1,7 @@
import { PermissionAction } from '@supabase/shared-types/out/constants'
-import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
-import {
- FormActions,
- FormHeader,
- FormPanel,
- FormSection,
- FormSectionContent,
- FormSectionLabel,
-} from 'components/ui/Forms'
-import Panel from 'components/ui/Panel'
-import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'
-import { useProjectUpdateMutation } from 'data/projects/project-update-mutation'
-import {
- useCheckPermissions,
- useFlag,
- useProjectByRef,
- useSelectedOrganization,
- useStore,
-} from 'hooks'
import { ChevronRight } from 'lucide-react'
import Link from 'next/link'
+import toast from 'react-hot-toast'
import {
AlertDescription_Shadcn_,
AlertTitle_Shadcn_,
@@ -33,11 +15,24 @@ import {
IconBarChart2,
Input,
} from 'ui'
+
+import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
+import {
+ FormActions,
+ FormHeader,
+ FormPanel,
+ FormSection,
+ FormSectionContent,
+ FormSectionLabel,
+} from 'components/ui/Forms'
+import Panel from 'components/ui/Panel'
+import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'
+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'
const General = () => {
- const { ui } = useStore()
const { project } = useProjectContext()
const organization = useSelectedOrganization()
@@ -70,7 +65,7 @@ const General = () => {
try {
const { name } = await updateProject({ ref: project.ref, name: values.name.trim() })
resetForm({ values: { name }, initialValues: { name } })
- ui.setNotification({ category: 'success', message: 'Successfully saved settings' })
+ toast.success('Successfully saved settings')
} catch (error) {}
}
diff --git a/apps/studio/components/interfaces/Settings/General/TransferProjectPanel/TransferProjectButton.tsx b/apps/studio/components/interfaces/Settings/General/TransferProjectPanel/TransferProjectButton.tsx
index b809a96e156..1e9c0a7f746 100644
--- a/apps/studio/components/interfaces/Settings/General/TransferProjectPanel/TransferProjectButton.tsx
+++ b/apps/studio/components/interfaces/Settings/General/TransferProjectPanel/TransferProjectButton.tsx
@@ -2,6 +2,7 @@ import * as Tooltip from '@radix-ui/react-tooltip'
import { PermissionAction } from '@supabase/shared-types/out/constants'
import Link from 'next/link'
import { useEffect, useState } from 'react'
+import toast from 'react-hot-toast'
import {
Alert,
Button,
@@ -18,12 +19,10 @@ import {
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 { useCheckPermissions, useFlag, useSelectedProject, useStore } from 'hooks'
+import { useCheckPermissions, useFlag, useSelectedProject } from 'hooks'
import { formatCurrency } from 'lib/helpers'
const TransferProjectButton = () => {
- const { ui } = useStore()
-
const project = useSelectedProject()
const projectRef = project?.ref
const projectOrgId = project?.organization_id
@@ -41,11 +40,7 @@ const TransferProjectButton = () => {
isLoading: isTransferring,
} = useProjectTransferMutation({
onSuccess: () => {
- ui.setNotification({
- category: 'success',
- duration: 5000,
- message: `Successfully transferred project ${project?.name}.`,
- })
+ toast.success(`Successfully transferred project ${project?.name}.`)
setIsOpen(false)
},
})
diff --git a/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GithubSection.tsx b/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GithubSection.tsx
index a2fe72535fd..be7f4e8ccbd 100644
--- a/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GithubSection.tsx
+++ b/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GithubSection.tsx
@@ -1,6 +1,7 @@
+import { useParams } from 'common'
import { useCallback } from 'react'
+import toast from 'react-hot-toast'
-import { useParams } from 'common'
import { IntegrationConnectionItem } from 'components/interfaces/Integrations/IntegrationConnection'
import { EmptyIntegrationConnection } from 'components/interfaces/Integrations/IntegrationPanels'
import { Markdown } from 'components/interfaces/Markdown'
@@ -18,8 +19,7 @@ import type {
IntegrationName,
IntegrationProjectConnection,
} from 'data/integrations/integrations.types'
-import { useFlag, useSelectedOrganization, useSelectedProject, useStore } from 'hooks'
-import { OPT_IN_TAGS } from 'lib/constants'
+import { useFlag, useSelectedOrganization, useSelectedProject } from 'hooks'
import { useSidePanelsStateSnapshot } from 'state/side-panels'
import { IntegrationImageHandler } from '../IntegrationsSettings'
import GitHubIntegrationConnectionForm from './GitHubIntegrationConnectionForm'
@@ -39,7 +39,6 @@ The GitHub app will watch for changes in your repository such as file changes, b
`
const GitHubSection = () => {
- const { ui } = useStore()
const { ref: projectRef } = useParams()
const project = useSelectedProject()
const org = useSelectedOrganization()
@@ -50,10 +49,7 @@ const GitHubSection = () => {
const { mutate: deleteGitHubConnection } = useGitHubConnectionDeleteMutation({
onSuccess: () => {
- ui.setNotification({
- category: 'success',
- message: 'Successfully deleted Github connection',
- })
+ toast.success('Successfully deleted Github connection')
},
})
diff --git a/apps/studio/components/interfaces/Settings/Integrations/VercelIntegration/VercelIntegrationConnectionForm.tsx b/apps/studio/components/interfaces/Settings/Integrations/VercelIntegration/VercelIntegrationConnectionForm.tsx
index 4078c84eb67..493d1bbf1be 100644
--- a/apps/studio/components/interfaces/Settings/Integrations/VercelIntegration/VercelIntegrationConnectionForm.tsx
+++ b/apps/studio/components/interfaces/Settings/Integrations/VercelIntegration/VercelIntegrationConnectionForm.tsx
@@ -1,10 +1,10 @@
import { zodResolver } from '@hookform/resolvers/zod'
import { useForm } from 'react-hook-form'
+import toast from 'react-hot-toast'
import {
AlertDescription_Shadcn_,
AlertTitle_Shadcn_,
Alert_Shadcn_,
- cn,
FormControl_Shadcn_,
FormDescription_Shadcn_,
FormField_Shadcn_,
@@ -13,6 +13,7 @@ import {
Form_Shadcn_,
IconClock,
Switch,
+ cn,
} from 'ui'
import * as z from 'zod'
@@ -22,7 +23,7 @@ import type {
IntegrationProjectConnection,
} from 'data/integrations/integrations.types'
import { useVercelConnectionUpdateMutation } from 'data/integrations/vercel-connection-update-mutate'
-import { useFlag, useStore } from 'hooks'
+import { useFlag } from 'hooks'
const VercelIntegrationConnectionForm = ({
connection,
@@ -32,8 +33,6 @@ const VercelIntegrationConnectionForm = ({
integration: Integration
}) => {
const enableVercelConnectionsConfig = useFlag('enableVercelConnectionsConfig')
-
- const { ui } = useStore()
const config = connection.metadata.supabaseConfig
const FormSchema = z.object({
@@ -57,10 +56,7 @@ const VercelIntegrationConnectionForm = ({
const { mutate: updateVercelConnection } = useVercelConnectionUpdateMutation({
onSuccess: (data) => {
- ui.setNotification({
- category: 'success',
- message: `Updated Supabase directory`,
- })
+ toast.success(`Updated Supabase directory`)
},
})
diff --git a/apps/studio/components/interfaces/Settings/Integrations/VercelIntegration/VercelSection.tsx b/apps/studio/components/interfaces/Settings/Integrations/VercelIntegration/VercelSection.tsx
index 53b49161d45..38e26b13ecc 100644
--- a/apps/studio/components/interfaces/Settings/Integrations/VercelIntegration/VercelSection.tsx
+++ b/apps/studio/components/interfaces/Settings/Integrations/VercelIntegration/VercelSection.tsx
@@ -1,6 +1,7 @@
import Link from 'next/link'
import { useCallback, useMemo } from 'react'
-import { Button, IconExternalLink } from 'ui'
+import toast from 'react-hot-toast'
+import { Button, IconExternalLink, cn } from 'ui'
import { IntegrationConnectionItem } from 'components/interfaces/Integrations/IntegrationConnection'
import {
@@ -22,16 +23,14 @@ import type {
IntegrationName,
IntegrationProjectConnection,
} from 'data/integrations/integrations.types'
-import { useSelectedOrganization, useSelectedProject, useStore } from 'hooks'
+import { useSelectedOrganization, useSelectedProject } from 'hooks'
import { pluralize } from 'lib/helpers'
import { getIntegrationConfigurationUrl } from 'lib/integration-utils'
import { useSidePanelsStateSnapshot } from 'state/side-panels'
import { IntegrationImageHandler } from '../IntegrationsSettings'
import VercelIntegrationConnectionForm from './VercelIntegrationConnectionForm'
-import clsx from 'clsx'
const VercelSection = ({ isProjectScoped }: { isProjectScoped: boolean }) => {
- const { ui } = useStore()
const project = useSelectedProject()
const org = useSelectedOrganization()
const { data } = useOrgIntegrationsQuery({ orgSlug: org?.slug })
@@ -42,10 +41,7 @@ const VercelSection = ({ isProjectScoped }: { isProjectScoped: boolean }) => {
const { mutate: deleteVercelConnection } = useIntegrationsVercelInstalledConnectionDeleteMutation(
{
onSuccess: () => {
- ui.setNotification({
- category: 'success',
- message: 'Successfully deleted Vercel connection',
- })
+ toast.success('Successfully deleted Vercel connection')
},
}
)
@@ -163,7 +159,7 @@ You can change the scope of the access for Supabase by configuring
{connections.map((connection) => (
<div
key={connection.id}
- className={clsx(
+ className={cn(
isProjectScoped && 'relative flex flex-col -gap-[1px] [&>li]:pb-0'
)}
>
@@ -171,7 +167,7 @@ You can change the scope of the access for Supabase by configuring
connection={connection}
type={'Vercel' as IntegrationName}
onDeleteConnection={onDeleteVercelConnection}
- className={clsx(isProjectScoped && '!rounded-b-none !mb-0')}
+ className={cn(isProjectScoped && '!rounded-b-none !mb-0')}
/>
{isProjectScoped ? (
<div className="relative pl-8 ml-6 border-l border-muted pb-6">
diff --git a/apps/studio/components/interfaces/Settings/Logs/LogTable.tsx b/apps/studio/components/interfaces/Settings/Logs/LogTable.tsx
index c9e802289d8..15b997cdcd7 100644
--- a/apps/studio/components/interfaces/Settings/Logs/LogTable.tsx
+++ b/apps/studio/components/interfaces/Settings/Logs/LogTable.tsx
@@ -1,7 +1,10 @@
+import * as Tooltip from '@radix-ui/react-tooltip'
+import { PermissionAction } from '@supabase/shared-types/out/constants'
+import { IS_PLATFORM } from 'common'
import { isEqual } from 'lodash'
import { Key, ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react'
-import * as Tooltip from '@radix-ui/react-tooltip'
import DataGrid, { Column, RenderRowProps, Row } from 'react-data-grid'
+import toast from 'react-hot-toast'
import {
Alert,
Button,
@@ -18,8 +21,9 @@ import {
} from 'ui'
import CSVButton from 'components/ui/CSVButton'
-import { useCheckPermissions, useStore } from 'hooks'
+import { useCheckPermissions } from 'hooks'
import { copyToClipboard } from 'lib/helpers'
+import { useProfile } from 'lib/profile'
import { LogQueryError, isDefaultLogPreviewFormat } from '.'
import AuthColumnRenderer from './LogColumnRenderers/AuthColumnRenderer'
import DatabaseApiColumnRender from './LogColumnRenderers/DatabaseApiColumnRender'
@@ -31,10 +35,6 @@ import LogSelection, { LogSelectionProps } from './LogSelection'
import type { LogData, QueryType } from './Logs.types'
import DefaultErrorRenderer from './LogsErrorRenderers/DefaultErrorRenderer'
import ResourcesExceededErrorRenderer from './LogsErrorRenderers/ResourcesExceededErrorRenderer'
-import { CSVLink } from 'react-csv'
-import { IS_PLATFORM } from 'common'
-import { PermissionAction } from '@supabase/shared-types/out/constants'
-import { useProfile } from 'lib/profile'
interface Props {
data?: Array<LogData | Object>
@@ -71,7 +71,6 @@ const LogTable = ({
onSave,
hasEditorValue,
}: Props) => {
- const { ui } = useStore()
const [focusedLog, setFocusedLog] = useState<LogData | null>(null)
const firstRow: LogData | undefined = data?.[0] as LogData
const { profile } = useProfile()
@@ -91,7 +90,6 @@ const LogTable = ({
const columnNames = Object.keys(getFirstRow() || {})
const hasId = columnNames.includes('id')
const hasTimestamp = columnNames.includes('timestamp')
- const csvRef = useRef<CSVLink & HTMLAnchorElement & { link: HTMLAnchorElement }>(null)
const DEFAULT_COLUMNS = columnNames.map((v: keyof LogData, idx) => {
const result: Column<LogData> = {
@@ -197,7 +195,7 @@ const LogTable = ({
const copyResultsToClipboard = () => {
copyToClipboard(stringData, () => {
- ui.setNotification({ category: 'success', message: 'Results copied to clipboard.' })
+ toast.success('Results copied to clipboard')
})
}
diff --git a/apps/studio/components/interfaces/Storage/EditBucketModal.tsx b/apps/studio/components/interfaces/Storage/EditBucketModal.tsx
index c030d2cd4c5..1a41f7aee1a 100644
--- a/apps/studio/components/interfaces/Storage/EditBucketModal.tsx
+++ b/apps/studio/components/interfaces/Storage/EditBucketModal.tsx
@@ -1,16 +1,7 @@
-import clsx from 'clsx'
import { useParams } from 'common'
-import { StorageSizeUnits } from 'components/to-be-cleaned/Storage/StorageSettings/StorageSettings.constants'
-import {
- convertFromBytes,
- convertToBytes,
-} from 'components/to-be-cleaned/Storage/StorageSettings/StorageSettings.utils'
-import { useProjectStorageConfigQuery } from 'data/config/project-storage-config-query'
-import { useBucketUpdateMutation } from 'data/storage/bucket-update-mutation'
-import { useStore } from 'hooks'
-import { IS_PLATFORM } from 'lib/constants'
import Link from 'next/link'
import { useEffect, useState } from 'react'
+import toast from 'react-hot-toast'
import {
Alert,
Button,
@@ -21,7 +12,17 @@ import {
Listbox,
Modal,
Toggle,
+ cn,
} from 'ui'
+
+import { StorageSizeUnits } from 'components/to-be-cleaned/Storage/StorageSettings/StorageSettings.constants'
+import {
+ convertFromBytes,
+ convertToBytes,
+} from 'components/to-be-cleaned/Storage/StorageSettings/StorageSettings.utils'
+import { useProjectStorageConfigQuery } from 'data/config/project-storage-config-query'
+import { useBucketUpdateMutation } from 'data/storage/bucket-update-mutation'
+import { IS_PLATFORM } from 'lib/constants'
import type { StorageBucket } from './Storage.types'
export interface EditBucketModalProps {
@@ -31,15 +32,11 @@ export interface EditBucketModalProps {
}
const EditBucketModal = ({ visible, bucket, onClose }: EditBucketModalProps) => {
- const { ui } = useStore()
const { ref } = useParams()
const { mutate: updateBucket, isLoading: isUpdating } = useBucketUpdateMutation({
onSuccess: () => {
- ui.setNotification({
- category: 'success',
- message: `Successfully updated bucket "${bucket?.name}"`,
- })
+ toast.success(`Successfully updated bucket "${bucket?.name}"`)
onClose()
},
})
@@ -168,7 +165,7 @@ const EditBucketModal = ({ visible, bucket, onClose }: EditBucketModalProps) =>
<IconChevronDown
size={18}
strokeWidth={2}
- className={clsx('text-foreground-light', showConfiguration && 'rotate-180')}
+ className={cn('text-foreground-light', showConfiguration && 'rotate-180')}
/>
</div>
</Collapsible.Trigger>
diff --git a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx
index 264958f5f59..61e84e319f6 100644
--- a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx
+++ b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx
@@ -2,10 +2,11 @@ import type { PostgresTable } from '@supabase/postgres-meta'
import { isEmpty, isUndefined, noop } from 'lodash'
import Link from 'next/link'
import { useEffect, useState } from 'react'
+import toast from 'react-hot-toast'
import { Alert, Badge, Button, Checkbox, IconBookOpen, Input, Modal, SidePanel } from 'ui'
+import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
-import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
import { useDatabasePublicationsQuery } from 'data/database-publications/database-publications-query'
import {
CONSTRAINT_TYPE,
@@ -17,7 +18,7 @@ import {
useForeignKeyConstraintsQuery,
} from 'data/database/foreign-key-constraints-query'
import { useEnumeratedTypesQuery } from 'data/enumerated-types/enumerated-types-query'
-import { useIsFeatureEnabled, useStore } from 'hooks'
+import { useIsFeatureEnabled } from 'hooks'
import { EXCLUDED_SCHEMAS_WITHOUT_EXTENSIONS } from 'lib/constants/schemas'
import { useTableEditorStateSnapshot } from 'state/table-editor'
import { SpreadsheetImport } from '../'
@@ -75,7 +76,6 @@ const TableEditor = ({
updateEditorDirty = noop,
}: TableEditorProps) => {
const snap = useTableEditorStateSnapshot()
- const { ui } = useStore()
const { project } = useProjectContext()
const isNewRecord = isUndefined(table)
const realtimeEnabled = useIsFeatureEnabled('realtime:all')
@@ -171,7 +171,7 @@ const TableEditor = ({
if (tableFields) {
const errors: any = validateFields(tableFields)
if (errors.columns) {
- ui.setNotification({ category: 'error', message: errors.columns, duration: 4000 })
+ toast.error(errors.columns)
}
setErrors(errors)
diff --git a/apps/studio/components/layouts/AppLayout/EnableBranchingButton/EnableBranchingModal.tsx b/apps/studio/components/layouts/AppLayout/EnableBranchingButton/EnableBranchingModal.tsx
index b7a64cda1f6..13ae40e6c0d 100644
--- a/apps/studio/components/layouts/AppLayout/EnableBranchingButton/EnableBranchingModal.tsx
+++ b/apps/studio/components/layouts/AppLayout/EnableBranchingButton/EnableBranchingModal.tsx
@@ -4,6 +4,7 @@ import { last } from 'lodash'
import Link from 'next/link'
import { useEffect, useState } from 'react'
import { useForm } from 'react-hook-form'
+import toast from 'react-hot-toast'
import {
Button,
Form_Shadcn_,
@@ -25,7 +26,7 @@ import { useGitHubConnectionsQuery } from 'data/integrations/github-connections-
import { useGitHubRepositoriesQuery } from 'data/integrations/github-repositories-query'
import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'
import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query'
-import { useSelectedOrganization, useStore } from 'hooks'
+import { useSelectedOrganization } from 'hooks'
import { useAppStateSnapshot } from 'state/app-state'
import BranchingPITRNotice from './BranchingPITRNotice'
import BranchingPlanNotice from './BranchingPlanNotice'
@@ -33,7 +34,6 @@ import BranchingPostgresVersionNotice from './BranchingPostgresVersionNotice'
import GithubRepositorySelection from './GithubRepositorySelection'
const EnableBranchingModal = () => {
- const { ui } = useStore()
const { ref } = useParams()
const snap = useAppStateSnapshot()
const selectedOrg = useSelectedOrganization()
@@ -86,7 +86,7 @@ const EnableBranchingModal = () => {
const { mutate: createBranch, isLoading: isCreating } = useBranchCreateMutation({
onSuccess: () => {
- ui.setNotification({ category: 'success', message: `Successfully created new branch` })
+ toast.success(`Successfully created new branch`)
snap.setShowEnableBranchingModal(false)
},
})
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/FeedbackDropdown/FeedbackWidget.tsx b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/FeedbackDropdown/FeedbackWidget.tsx
index a4fb3ae9f52..a1a5c553667 100644
--- a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/FeedbackDropdown/FeedbackWidget.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/FeedbackDropdown/FeedbackWidget.tsx
@@ -3,6 +3,7 @@ import { toPng } from 'html-to-image'
import Link from 'next/link'
import { useRouter } from 'next/router'
import { ChangeEvent, useEffect, useRef, useState } from 'react'
+import toast from 'react-hot-toast'
import {
Button,
DropdownMenu,
@@ -17,7 +18,6 @@ import {
} from 'ui'
import { useSendFeedbackMutation } from 'data/feedback/feedback-send'
-import { useStore } from 'hooks'
import { timeout } from 'lib/helpers'
import { convertB64toBlob, uploadAttachment } from './FeedbackDropdown.utils'
@@ -38,8 +38,6 @@ const FeedbackWidget = ({
}: FeedbackWidgetProps) => {
const router = useRouter()
const { ref, slug } = useParams()
-
- const { ui } = useStore()
const inputRef = useRef<any>(null)
const uploadButtonRef = useRef()
@@ -69,14 +67,7 @@ const FeedbackWidget = ({
await timeout(100)
toPng(document.body, { filter })
.then((dataUrl: any) => setScreenshot(dataUrl))
- .catch((error: any) => {
- ui.setNotification({
- error,
- category: 'error',
- message: 'Failed to capture screenshot',
- duration: 4000,
- })
- })
+ .catch((error: any) => toast.error('Failed to capture screenshot'))
.finally(() => {
setIsSavingScreenshot(false)
})
@@ -96,11 +87,7 @@ const FeedbackWidget = ({
const sendFeedback = async () => {
if (feedback.length === 0 && screenshot !== undefined) {
- return ui.setNotification({
- category: 'error',
- message: 'Please include a message in your feedback.',
- duration: 4000,
- })
+ return toast.error('Please include a message in your feedback.')
} else if (feedback.length > 0) {
setSending(true)
@@ -118,11 +105,9 @@ const FeedbackWidget = ({
pathname: router.asPath,
})
setFeedback('')
- ui.setNotification({
- category: 'success',
- message:
- '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.',
- })
+ 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)
}
diff --git a/apps/studio/components/layouts/SQLEditorLayout/QueryItemActions.tsx b/apps/studio/components/layouts/SQLEditorLayout/QueryItemActions.tsx
index 7e8359d8e1c..751a6c57a37 100644
--- a/apps/studio/components/layouts/SQLEditorLayout/QueryItemActions.tsx
+++ b/apps/studio/components/layouts/SQLEditorLayout/QueryItemActions.tsx
@@ -2,6 +2,7 @@ import { PermissionAction } from '@supabase/shared-types/out/constants'
import { IS_PLATFORM, useParams } from 'common'
import { Copy, Download, Edit, MoreHorizontal, Share, Trash } from 'lucide-react'
import { useRouter } from 'next/router'
+import toast from 'react-hot-toast'
import {
Button,
DropdownMenu,
@@ -13,7 +14,7 @@ import {
import { createSqlSnippetSkeleton } from 'components/interfaces/SQLEditor/SQLEditor.utils'
import type { SqlSnippet } from 'data/content/sql-snippets-query'
-import { useCheckPermissions, useSelectedProject, useStore } from 'hooks'
+import { useCheckPermissions, useSelectedProject } from 'hooks'
import { uuidv4 } from 'lib/helpers'
import { useProfile } from 'lib/profile'
import { useSqlEditorStateSnapshot } from 'state/sql-editor'
@@ -37,7 +38,6 @@ export const QueryItemActions = ({
onSelectShareQuery,
onSelectDownloadQuery,
}: QueryItemActionsProps) => {
- const { ui } = useStore()
const { ref } = useParams()
const router = useRouter()
const { profile } = useProfile()
@@ -90,10 +90,7 @@ export const QueryItemActions = ({
snap.addNeedsSaving(snippet.id!)
router.push(`/project/${ref}/sql/${snippet.id}`)
} catch (error: any) {
- ui.setNotification({
- category: 'error',
- message: `Failed to create a personal copy of this query: ${error.message}`,
- })
+ toast.error(`Failed to create a personal copy of this query: ${error.message}`)
}
}
diff --git a/apps/studio/components/layouts/SQLEditorLayout/SQLEditorMenu.tsx b/apps/studio/components/layouts/SQLEditorLayout/SQLEditorMenu.tsx
index a12de5934fd..0605b0e6685 100644
--- a/apps/studio/components/layouts/SQLEditorLayout/SQLEditorMenu.tsx
+++ b/apps/studio/components/layouts/SQLEditorLayout/SQLEditorMenu.tsx
@@ -31,18 +31,17 @@ import {
import { untitledSnippetTitle } from 'components/interfaces/SQLEditor/SQLEditor.constants'
import { createSqlSnippetSkeleton } from 'components/interfaces/SQLEditor/SQLEditor.utils'
-import { WarningIcon } from 'ui-patterns/Icons/StatusIcons'
import { useContentDeleteMutation } from 'data/content/content-delete-mutation'
import { SqlSnippet, useSqlSnippetsQuery } from 'data/content/sql-snippets-query'
-import { useCheckPermissions, useSelectedProject, useStore } from 'hooks'
+import { useCheckPermissions, useSelectedProject } from 'hooks'
import { uuidv4 } from 'lib/helpers'
import { useProfile } from 'lib/profile'
import { useSnippets, useSqlEditorStateSnapshot } from 'state/sql-editor'
+import { WarningIcon } from 'ui-patterns/Icons/StatusIcons'
import QueryItem from './QueryItem'
import { selectItemsInRange } from './SQLEditorLayout.utils'
const SideBarContent = observer(() => {
- const { ui } = useStore()
const { ref, id: activeId } = useParams()
const router = useRouter()
const { profile } = useProfile()
@@ -179,10 +178,7 @@ const SideBarContent = observer(() => {
if (!ref) return console.error('Project is required')
if (!profile) return console.error('Profile is required')
if (!canCreateSQLSnippet) {
- return ui.setNotification({
- category: 'info',
- message: 'Your queries will not be saved as you do not have sufficient permissions',
- })
+ return toast('Your queries will not be saved as you do not have sufficient permissions')
}
try {
@@ -198,10 +194,7 @@ const SideBarContent = observer(() => {
router.push(`/project/${ref}/sql/${snippet.id}`)
setSearchText('')
} catch (error: any) {
- ui.setNotification({
- category: 'error',
- message: `Failed to create new query: ${error.message}`,
- })
+ toast.error(`Failed to create new query: ${error.message}`)
}
}
diff --git a/apps/studio/components/layouts/StorageLayout/StorageLayout.tsx b/apps/studio/components/layouts/StorageLayout/StorageLayout.tsx
index 8e70cadc132..3d77e112835 100644
--- a/apps/studio/components/layouts/StorageLayout/StorageLayout.tsx
+++ b/apps/studio/components/layouts/StorageLayout/StorageLayout.tsx
@@ -1,8 +1,9 @@
+import { useParams } from 'common'
import { ReactNode, useEffect } from 'react'
+import toast from 'react-hot-toast'
-import { useParams } from 'common/hooks'
import { AutoApiService, useProjectApiQuery } from 'data/config/project-api-query'
-import { useSelectedProject, useStore, withAuth } from 'hooks'
+import { useSelectedProject, withAuth } from 'hooks'
import { PROJECT_STATUS } from 'lib/constants'
import { useStorageStore } from 'localStores/storageExplorer/StorageExplorerStore'
import { ProjectLayout } from '../'
@@ -14,7 +15,6 @@ export interface StorageLayoutProps {
}
const StorageLayout = ({ title, children }: StorageLayoutProps) => {
- const { ui } = useStore()
const { ref: projectRef } = useParams()
const project = useSelectedProject()
const storageExplorerStore = useStorageStore()
@@ -39,11 +39,9 @@ const StorageLayout = ({ title, children }: StorageLayoutProps) => {
apiService.protocol
)
} else {
- ui.setNotification({
- category: 'error',
- message:
- 'Failed to fetch project configuration. Try refreshing your browser, or reach out to us at [email protected]',
- })
+ toast.error(
+ 'Failed to fetch project configuration. Try refreshing your browser, or reach out to us at [email protected]'
+ )
}
storageExplorerStore.setLoaded(true)
}
diff --git a/apps/studio/components/to-be-cleaned/Reports/EditReportModal.tsx b/apps/studio/components/to-be-cleaned/Reports/EditReportModal.tsx
index 8d3a109fceb..8119942098f 100644
--- a/apps/studio/components/to-be-cleaned/Reports/EditReportModal.tsx
+++ b/apps/studio/components/to-be-cleaned/Reports/EditReportModal.tsx
@@ -2,17 +2,14 @@ import { toJS } from 'mobx'
import { observer } from 'mobx-react-lite'
import { useRouter } from 'next/router'
import { useEffect, useState } from 'react'
+import toast from 'react-hot-toast'
import { Input, Modal } from 'ui'
-import { useStore } from 'hooks'
import { useProjectContentStore } from 'stores/projectContentStore'
const EditModal = () => {
const router = useRouter()
const { id, ref } = router.query
-
- const { ui } = useStore()
-
const [visible, setVisible] = useState<boolean>(false)
const [loading, setLoading] = useState<boolean>(false)
const [name, setName] = useState<string>()
@@ -57,7 +54,7 @@ const EditModal = () => {
setVisible(!visible)
return data
} catch (error: any) {
- ui.setNotification({ category: 'error', message: error.message })
+ toast.error(error.message)
setLoading(false)
}
}
diff --git a/apps/studio/components/to-be-cleaned/Storage/StorageExplorer/StorageExplorer.tsx b/apps/studio/components/to-be-cleaned/Storage/StorageExplorer/StorageExplorer.tsx
index 0c0beb8cbd1..9c6f0f2be6b 100644
--- a/apps/studio/components/to-be-cleaned/Storage/StorageExplorer/StorageExplorer.tsx
+++ b/apps/studio/components/to-be-cleaned/Storage/StorageExplorer/StorageExplorer.tsx
@@ -2,11 +2,11 @@ import { useParams } from 'common'
import { compact, get, isEmpty, uniqBy } from 'lodash'
import { observer } from 'mobx-react-lite'
import { useEffect, useRef, useState } from 'react'
+import toast from 'react-hot-toast'
import { useProjectSettingsQuery } from 'data/config/project-settings-query'
import { useCustomDomainsQuery } from 'data/custom-domains/custom-domains-query'
import type { Bucket } from 'data/storage/buckets-query'
-import { useStore } from 'hooks'
import { DEFAULT_PROJECT_API_SERVICE_ID } from 'lib/constants'
import { copyToClipboard } from 'lib/helpers'
import { useStorageStore } from 'localStores/storageExplorer/StorageExplorerStore'
@@ -55,7 +55,6 @@ const StorageExplorer = ({ bucket }: StorageExplorerProps) => {
const storageExplorerRef = useRef(null)
- const { ui } = useStore()
const { ref } = useParams()
const { data: customDomainData } = useCustomDomainsQuery({ projectRef: ref })
const { data: projectSettings } = useProjectSettingsQuery({ projectRef: ref })
@@ -191,11 +190,7 @@ const StorageExplorer = ({ bucket }: StorageExplorerProps) => {
? url.replace(apiUrl, `https://${customDomainData.customDomain.hostname}`)
: url
copyToClipboard(formattedUrl, () => {
- ui.setNotification({
- category: 'success',
- message: `Copied URL for ${name} to clipboard.`,
- duration: 4000,
- })
+ toast.success(`Copied URL for ${name} to clipboard.`)
})
}
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 faafc875586..e2aa4a00942 100644
--- a/apps/studio/components/to-be-cleaned/Storage/StoragePolicies/StoragePolicies.tsx
+++ b/apps/studio/components/to-be-cleaned/Storage/StoragePolicies/StoragePolicies.tsx
@@ -6,20 +6,18 @@ import { IconLoader } from 'ui'
import { PolicyEditorModal } from 'components/interfaces/Auth/Policies'
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
-import ConfirmModal from 'ui-patterns/Dialogs/ConfirmDialog'
import { useDatabasePoliciesQuery } from 'data/database-policies/database-policies-query'
import { useDatabasePolicyCreateMutation } from 'data/database-policies/database-policy-create-mutation'
import { useDatabasePolicyDeleteMutation } from 'data/database-policies/database-policy-delete-mutation'
import { useDatabasePolicyUpdateMutation } from 'data/database-policies/database-policy-update-mutation'
import { useBucketsQuery } from 'data/storage/buckets-query'
-import { useStore } from 'hooks'
+import ConfirmModal from 'ui-patterns/Dialogs/ConfirmDialog'
import { formatPoliciesForStorage } from '../Storage.utils'
import StoragePoliciesBucketRow from './StoragePoliciesBucketRow'
import StoragePoliciesEditPolicyModal from './StoragePoliciesEditPolicyModal'
import StoragePoliciesPlaceholder from './StoragePoliciesPlaceholder'
const StoragePolicies = () => {
- const { ui } = useStore()
const { project } = useProjectContext()
const { ref: projectRef } = useParams()
@@ -93,7 +91,7 @@ const StoragePolicies = () => {
const onCancelPolicyDelete = () => setSelectedPolicyToDelete({})
const onSavePolicySuccess = async () => {
- ui.setNotification({ category: 'success', message: 'Successfully saved policy!' })
+ toast.success('Successfully saved policy!')
await refetch()
onCancelPolicyEdit()
}
diff --git a/apps/studio/components/to-be-cleaned/Storage/StorageSettings/StorageSettings.tsx b/apps/studio/components/to-be-cleaned/Storage/StorageSettings/StorageSettings.tsx
index 8917e5ab9f3..660819eb671 100644
--- a/apps/studio/components/to-be-cleaned/Storage/StorageSettings/StorageSettings.tsx
+++ b/apps/studio/components/to-be-cleaned/Storage/StorageSettings/StorageSettings.tsx
@@ -10,13 +10,12 @@ import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'
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 { useCheckPermissions, useSelectedOrganization, useStore } from 'hooks'
+import { useCheckPermissions, useSelectedOrganization } from 'hooks'
import { IS_PLATFORM } from 'lib/constants'
import { STORAGE_FILE_SIZE_LIMIT_MAX_BYTES, StorageSizeUnits } from './StorageSettings.constants'
import { convertFromBytes, convertToBytes } from './StorageSettings.utils'
const StorageSettings = () => {
- const { ui } = useStore()
const { ref: projectRef } = useParams()
const organization = useSelectedOrganization()
const organizationSlug = organization?.slug
@@ -44,10 +43,7 @@ const StorageSettings = () => {
fileSizeLimit: updatedValue.value,
unformattedFileSizeLimit: res.fileSizeLimit,
}
- ui.setNotification({
- category: 'success',
- message: 'Successfully updated storage settings',
- })
+ toast.success('Successfully updated storage settings')
},
})
diff --git a/apps/studio/data/__templates/README.md b/apps/studio/data/__templates/README.md
index 9a5d6f25d6f..71a970294da 100644
--- a/apps/studio/data/__templates/README.md
+++ b/apps/studio/data/__templates/README.md
@@ -79,10 +79,10 @@ We should also aim to convert most of the `mutateAsync` to `mutate`, otherwise w
```jsx
const { mutate: someAction } = useMutation({
onSuccess: (res) => {
- ui.setNotification({ category: 'success', message: 'Success' })
+ toast.success('Success')
},
onError: (error) => {
- ui.setNotification({ category: 'error', message: `Failed: ${error.message}` })
+ toast.error(`Failed: ${error.message}`)
},
})
diff --git a/apps/studio/hooks/misc/withAuth.tsx b/apps/studio/hooks/misc/withAuth.tsx
index 868d96b460d..da864ede682 100644
--- a/apps/studio/hooks/misc/withAuth.tsx
+++ b/apps/studio/hooks/misc/withAuth.tsx
@@ -1,9 +1,9 @@
import { useRouter } from 'next/router'
import { ComponentType, useEffect } from 'react'
+import toast from 'react-hot-toast'
import { usePermissionsQuery } from 'data/permissions/permissions-query'
import { useAuthenticatorAssuranceLevelQuery } from 'data/profile/mfa-authenticator-assurance-level-query'
-import { useStore } from 'hooks'
import { useAuth } from 'lib/auth'
import { IS_PLATFORM } from 'lib/constants'
import { NextPageWithLayout, isNextPageWithLayout } from 'types'
@@ -29,27 +29,20 @@ export function withAuth<T>(
const WithAuthHOC: ComponentType<T> = (props) => {
const router = useRouter()
- const rootStore = useStore()
- const { ui } = rootStore
-
const { isLoading, session } = useAuth()
const { isLoading: isAALLoading, data: aalData } = useAuthenticatorAssuranceLevelQuery({
onError(error) {
- ui.setNotification({
- error,
- category: 'error',
- message: `Failed to fetch authenticator assurance level: ${error.message}. Try refreshing your browser, or reach out to us via a support ticket if the issue persists`,
- })
+ toast.error(
+ `Failed to fetch authenticator assurance level: ${error.message}. Try refreshing your browser, or reach out to us via a support ticket if the issue persists`
+ )
},
})
usePermissionsQuery({
onError(error: any) {
- ui.setNotification({
- error,
- category: 'error',
- message: `Failed to fetch permissions: ${error.message}. Try refreshing your browser, or reach out to us via a support ticket if the issue persists`,
- })
+ toast.error(
+ `Failed to fetch permissions: ${error.message}. Try refreshing your browser, or reach out to us via a support ticket if the issue persists`
+ )
},
})
diff --git a/apps/studio/lib/auth.tsx b/apps/studio/lib/auth.tsx
index 4827c9c1d8a..a51c975ba20 100644
--- a/apps/studio/lib/auth.tsx
+++ b/apps/studio/lib/auth.tsx
@@ -1,25 +1,21 @@
import { useQueryClient } from '@tanstack/react-query'
+import { AuthProvider as AuthProviderInternal, gotrueClient } from 'common'
import { PropsWithChildren, useCallback, useEffect } from 'react'
+import toast from 'react-hot-toast'
-import { AuthProvider as AuthProviderInternal, gotrueClient } from 'common'
-import { useStore } from 'hooks'
import { GOTRUE_ERRORS, IS_PLATFORM } from './constants'
import { clearLocalStorage } from './local-storage'
export const AuthProvider = ({ children }: PropsWithChildren<{}>) => {
- const { ui } = useStore()
-
// Check for unverified GitHub users after a GitHub sign in
useEffect(() => {
async function handleEmailVerificationError() {
const { error } = await gotrueClient.initialize()
if (error?.message === GOTRUE_ERRORS.UNVERIFIED_GITHUB_USER) {
- ui.setNotification({
- category: 'error',
- message:
- 'Please verify your email on GitHub first, then reach out to us at [email protected] to log into the dashboard',
- })
+ toast.error(
+ 'Please verify your email on GitHub first, then reach out to us at [email protected] to log into the dashboard'
+ )
}
}
diff --git a/apps/studio/lib/profile.tsx b/apps/studio/lib/profile.tsx
index 2e779f1b815..598d1db0aff 100644
--- a/apps/studio/lib/profile.tsx
+++ b/apps/studio/lib/profile.tsx
@@ -1,12 +1,12 @@
+import { useIsLoggedIn, useTelemetryProps } from 'common'
import { useRouter } from 'next/router'
import { PropsWithChildren, createContext, useContext, useMemo } from 'react'
+import toast from 'react-hot-toast'
-import { useIsLoggedIn, useTelemetryProps } from 'common'
import { usePermissionsQuery } from 'data/permissions/permissions-query'
import { useProfileCreateMutation } from 'data/profile/profile-create-mutation'
import { useProfileQuery } from 'data/profile/profile-query'
import type { Profile } from 'data/profile/types'
-import { useStore } from 'hooks'
import Telemetry from 'lib/telemetry'
import type { ResponseError } from 'types'
@@ -27,7 +27,6 @@ export const ProfileContext = createContext<ProfileContextType>({
})
export const ProfileProvider = ({ children }: PropsWithChildren<{}>) => {
- const { ui } = useStore()
const router = useRouter()
const telemetryProps = useTelemetryProps()
@@ -42,10 +41,7 @@ export const ProfileProvider = ({ children }: PropsWithChildren<{}>) => {
)
},
onError() {
- ui.setNotification({
- category: 'error',
- message: 'Failed to create your profile. Please refresh to try again.',
- })
+ toast.error('Failed to create your profile. Please refresh to try again.')
},
})