The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Replace ui setnotification with toast part 3 (#21877)
Joshen Lim3906f1cfb007
diff --git a/apps/studio/components/interfaces/SQLEditor/SQLEditor.tsx b/apps/studio/components/interfaces/SQLEditor/SQLEditor.tsxindex 4a8b257afea..bb3badbfefb 100644--- a/apps/studio/components/interfaces/SQLEditor/SQLEditor.tsx+++ b/apps/studio/components/interfaces/SQLEditor/SQLEditor.tsx@@ -1,26 +1,13 @@import type { Monaco } from '@monaco-editor/react'import { useChat } from 'ai/react'-import { useParams, useTelemetryProps } from 'common'import { AnimatePresence, motion } from 'framer-motion'import dynamic from 'next/dynamic'import { useRouter } from 'next/router'import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react'import toast from 'react-hot-toast'import { format } from 'sql-formatter'-import {- AiIconAnimation,- IconCornerDownLeft,- IconSettings,- IconX,- Input_Shadcn_,- Loading,- ResizableHandle,- ResizablePanel,- ResizablePanelGroup,- cn,-} from 'ui'-import ConfirmModal from 'ui-patterns/Dialogs/ConfirmDialog'+import { useParams, useTelemetryProps } from 'common'import { useSqlEditMutation } from 'data/ai/sql-edit-mutation'import { useSqlGenerateMutation } from 'data/ai/sql-generate-mutation'import { useSqlTitleGenerateMutation } from 'data/ai/sql-title-mutation'@@ -47,6 +34,19 @@ import { useAppStateSnapshot } from 'state/app-state'import { useDatabaseSelectorStateSnapshot } from 'state/database-selector'import { isRoleImpersonationEnabled, useGetImpersonatedRole } from 'state/role-impersonation-state'import { getSqlEditorStateSnapshot, useSqlEditorStateSnapshot } from 'state/sql-editor'+import {+ AiIconAnimation,+ IconCornerDownLeft,+ IconSettings,+ IconX,+ Input_Shadcn_,+ Loading,+ ResizableHandle,+ ResizablePanel,+ ResizablePanelGroup,+ cn,+} from 'ui'+import ConfirmModal from 'ui-patterns/Dialogs/ConfirmDialog'import { useIsSQLEditorAiAssistantEnabled } from '../App/FeaturePreview/FeaturePreviewContext'import { subscriptionHasHipaaAddon } from '../Billing/Subscription/Subscription.utils'import AISchemaSuggestionPopover from './AISchemaSuggestionPopover'@@ -395,10 +395,7 @@ const SQLEditor = () => {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}`)}},[profile?.id, project?.id, ref, router, snap, ui]@@ -742,11 +739,9 @@ const SQLEditor = () => {// If this was an edit and AI returned the same SQL as beforeif (currentSql && formattedSql.trim() === currentSql.trim()) {- ui.setNotification({- category: 'error',- message:- 'Unable to edit SQL. Try adding more details to your prompt.',- })+ toast.error(+ 'Unable to edit SQL. Try adding more details to your prompt.'+ )return}@@ -756,16 +751,9 @@ const SQLEditor = () => {})setSelectedDiffType(DiffType.Modification)- if (title) {- setPendingTitle(title)- }+ if (title) setPendingTitle(title)} catch (error: unknown) {- if (isError(error)) {- ui.setNotification({- category: 'error',- message: error.message,- })- }+ if (isError(error)) toast.error(error.message)}}}}diff --git a/apps/studio/components/interfaces/Settings/Addons/ComputeInstanceSidePanel.tsx b/apps/studio/components/interfaces/Settings/Addons/ComputeInstanceSidePanel.tsxindex 44f64dc52b2..abadf017f52 100644--- a/apps/studio/components/interfaces/Settings/Addons/ComputeInstanceSidePanel.tsx+++ b/apps/studio/components/interfaces/Settings/Addons/ComputeInstanceSidePanel.tsx@@ -1,11 +1,25 @@import * as Tooltip from '@radix-ui/react-tooltip'import { PermissionAction } from '@supabase/shared-types/out/constants'import { useQueryClient } from '@tanstack/react-query'-import { useParams } from 'common'import Link from 'next/link'import { useRouter } from 'next/router'import { useEffect, useMemo, useState } from 'react'import toast from 'react-hot-toast'++import { useParams } from 'common'+import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'+import { setProjectStatus } from 'data/projects/projects-query'+import { useReadReplicasQuery } from 'data/read-replicas/replicas-query'+import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'+import { useProjectAddonRemoveMutation } from 'data/subscriptions/project-addon-remove-mutation'+import { useProjectAddonUpdateMutation } from 'data/subscriptions/project-addon-update-mutation'+import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query'+import type { AddonVariantId, ProjectAddonVariantMeta } from 'data/subscriptions/types'+import { useCheckPermissions, useFlag, useSelectedOrganization } from 'hooks'+import { getCloudProviderArchitecture } from 'lib/cloudprovider-utils'+import { INSTANCE_MICRO_SPECS, PROJECT_STATUS } from 'lib/constants'+import Telemetry from 'lib/telemetry'+import { useSubscriptionPageStateSnapshot } from 'state/subscription-page'import {Alert,AlertDescription_Shadcn_,@@ -20,25 +34,10 @@ import {Radio,SidePanel,} from 'ui'--import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'import { WarningIcon } from 'ui-patterns/Icons/StatusIcons'-import { setProjectStatus } from 'data/projects/projects-query'-import { useReadReplicasQuery } from 'data/read-replicas/replicas-query'-import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'-import { useProjectAddonRemoveMutation } from 'data/subscriptions/project-addon-remove-mutation'-import { useProjectAddonUpdateMutation } from 'data/subscriptions/project-addon-update-mutation'-import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query'-import type { AddonVariantId, ProjectAddonVariantMeta } from 'data/subscriptions/types'-import { useCheckPermissions, useFlag, useSelectedOrganization, useStore } from 'hooks'-import { getCloudProviderArchitecture } from 'lib/cloudprovider-utils'-import { INSTANCE_MICRO_SPECS, PROJECT_STATUS } from 'lib/constants'-import Telemetry from 'lib/telemetry'-import { useSubscriptionPageStateSnapshot } from 'state/subscription-page'const ComputeInstanceSidePanel = () => {const queryClient = useQueryClient()- const { ui } = useStore()const router = useRouter()const { ref: projectRef } = useParams()const { project: selectedProject } = useProjectContext()@@ -67,40 +66,30 @@ const ComputeInstanceSidePanel = () => {const { data: subscription } = useOrgSubscriptionQuery({ orgSlug: organization?.slug })const { mutate: updateAddon, isLoading: isUpdating } = useProjectAddonUpdateMutation({onSuccess: () => {- ui.setNotification({- duration: 8000,- category: 'success',- message: `Successfully updated compute instance to ${selectedCompute?.name}. Your project is currently being restarted to update its instance`,- })+ toast.success(+ `Successfully updated compute instance to ${selectedCompute?.name}. Your project is currently being restarted to update its instance`,+ { duration: 8000 }+ )setProjectStatus(queryClient, projectRef!, PROJECT_STATUS.RESTORING)onClose()router.push(`/project/${projectRef}`)},onError: (error) => {- ui.setNotification({- error,- category: 'error',- message: `Unable to update compute instance: ${error.message}`,- })+ toast.error(`Unable to update compute instance: ${error.message}`)},})const { mutate: removeAddon, isLoading: isRemoving } = useProjectAddonRemoveMutation({onSuccess: () => {- ui.setNotification({- duration: 8000,- category: 'success',- message: `Successfully updated compute instance. Your project is currently being restarted to update its instance`,- })+ toast.success(+ `Successfully updated compute instance. Your project is currently being restarted to update its instance`,+ { duration: 8000 }+ )setProjectStatus(queryClient, projectRef!, PROJECT_STATUS.RESTORING)onClose()router.push(`/project/${projectRef}`)},onError: (error) => {- ui.setNotification({- error,- category: 'error',- message: `Unable to update compute instance: ${error.message}`,- })+ toast.error(`Unable to update compute instance: ${error.message}`)},})diff --git a/apps/studio/components/interfaces/Settings/Addons/CustomDomainSidePanel.tsx b/apps/studio/components/interfaces/Settings/Addons/CustomDomainSidePanel.tsxindex b8b4affbbfa..f19209aabea 100644--- a/apps/studio/components/interfaces/Settings/Addons/CustomDomainSidePanel.tsx+++ b/apps/studio/components/interfaces/Settings/Addons/CustomDomainSidePanel.tsx@@ -1,14 +1,17 @@import { PermissionAction } from '@supabase/shared-types/out/constants'-import clsx from 'clsx'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'+import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'import { useProjectAddonRemoveMutation } from 'data/subscriptions/project-addon-remove-mutation'import { useProjectAddonUpdateMutation } from 'data/subscriptions/project-addon-update-mutation'import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query'-import { useCheckPermissions, useSelectedOrganization, useStore } from 'hooks'+import type { AddonVariantId } from 'data/subscriptions/types'+import { useCheckPermissions, useFlag, useSelectedOrganization } from 'hooks'+import { formatCurrency } from 'lib/helpers'import Telemetry from 'lib/telemetry'import { useSubscriptionPageStateSnapshot } from 'state/subscription-page'import {@@ -22,14 +25,10 @@ import {IconExternalLink,Radio,SidePanel,+ cn,} from 'ui'-import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'-import type { AddonVariantId } from 'data/subscriptions/types'-import { formatCurrency } from 'lib/helpers'-import { useFlag } from 'hooks'const CustomDomainSidePanel = () => {- const { ui } = useStore()const router = useRouter()const { ref: projectRef } = useParams()const organization = useSelectedOrganization()@@ -56,34 +55,20 @@ const CustomDomainSidePanel = () => {const { data: subscription } = useOrgSubscriptionQuery({ orgSlug: organization?.slug })const { mutate: updateAddon, isLoading: isUpdating } = useProjectAddonUpdateMutation({onSuccess: () => {- ui.setNotification({- category: 'success',- message: `Successfully enabled custom domain`,- })+ toast.success(`Successfully enabled custom domain`)onClose()},onError: (error) => {- ui.setNotification({- error,- category: 'error',- message: `Unable to enable custom domain: ${error.message}`,- })+ toast.error(`Unable to enable custom domain: ${error.message}`)},})const { mutate: removeAddon, isLoading: isRemoving } = useProjectAddonRemoveMutation({onSuccess: () => {- ui.setNotification({- category: 'success',- message: `Successfully disabled custom domain`,- })+ toast.success(`Successfully disabled custom domain`)onClose()},onError: (error) => {- ui.setNotification({- error,- category: 'error',- message: `Unable to disable custom domain: ${error.message}`,- })+ toast.error(`Unable to disable custom domain: ${error.message}`)},})const isSubmitting = isUpdating || isRemoving@@ -194,7 +179,7 @@ const CustomDomainSidePanel = () => {page after enabling the add-on.</p>- <div className={clsx('!mt-8 pb-4', isFreePlan && 'opacity-75')}>+ <div className={cn('!mt-8 pb-4', isFreePlan && 'opacity-75')}><Radio.Grouptype="large-cards"size="tiny"diff --git a/apps/studio/components/interfaces/Settings/Addons/IPv4SidePanel.tsx b/apps/studio/components/interfaces/Settings/Addons/IPv4SidePanel.tsxindex e652ff5078e..3d822a59e64 100644--- a/apps/studio/components/interfaces/Settings/Addons/IPv4SidePanel.tsx+++ b/apps/studio/components/interfaces/Settings/Addons/IPv4SidePanel.tsx@@ -1,8 +1,8 @@import { PermissionAction } from '@supabase/shared-types/out/constants'-import clsx from 'clsx'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'import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'@@ -10,14 +10,13 @@ import { useProjectAddonRemoveMutation } from 'data/subscriptions/project-addon-import { useProjectAddonUpdateMutation } from 'data/subscriptions/project-addon-update-mutation'import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query'import type { AddonVariantId } from 'data/subscriptions/types'-import { useCheckPermissions, useSelectedOrganization, useStore } from 'hooks'+import { useCheckPermissions, useSelectedOrganization } from 'hooks'import { formatCurrency } from 'lib/helpers'import Telemetry from 'lib/telemetry'import { useSubscriptionPageStateSnapshot } from 'state/subscription-page'-import { Alert, Button, IconExternalLink, Radio, SidePanel } from 'ui'+import { Alert, Button, IconExternalLink, Radio, SidePanel, cn } from 'ui'const IPv4SidePanel = () => {- const { ui } = useStore()const router = useRouter()const { ref: projectRef } = useParams()const organization = useSelectedOrganization()@@ -40,34 +39,20 @@ const IPv4SidePanel = () => {const { data: subscription } = useOrgSubscriptionQuery({ orgSlug: organization?.slug })const { mutate: updateAddon, isLoading: isUpdating } = useProjectAddonUpdateMutation({onSuccess: () => {- ui.setNotification({- category: 'success',- message: `Successfully enabled IPv4`,- })+ toast.success(`Successfully enabled IPv4`)onClose()},onError: (error) => {- ui.setNotification({- error,- category: 'error',- message: `Unable to enable IPv4: ${error.message}`,- })+ toast.error(`Unable to enable IPv4: ${error.message}`)},})const { mutate: removeAddon, isLoading: isRemoving } = useProjectAddonRemoveMutation({onSuccess: () => {- ui.setNotification({- category: 'success',- message: `Successfully disabled IPv4.`,- })+ toast.success(`Successfully disabled IPv4.`)onClose()},onError: (error) => {- ui.setNotification({- error,- category: 'error',- message: `Unable to disable IPv4: ${error.message}`,- })+ toast.error(`Unable to disable IPv4: ${error.message}`)},})const isSubmitting = isUpdating || isRemoving@@ -159,7 +144,7 @@ const IPv4SidePanel = () => {.</p>- <div className={clsx('!mt-8 pb-4', isFreePlan && 'opacity-75')}>+ <div className={cn('!mt-8 pb-4', isFreePlan && 'opacity-75')}><Radio.Grouptype="large-cards"size="tiny"diff --git a/apps/studio/components/interfaces/Settings/Addons/PITRSidePanel.tsx b/apps/studio/components/interfaces/Settings/Addons/PITRSidePanel.tsxindex 7037ac0f5fd..ca128402f91 100644--- a/apps/studio/components/interfaces/Settings/Addons/PITRSidePanel.tsx+++ b/apps/studio/components/interfaces/Settings/Addons/PITRSidePanel.tsx@@ -1,20 +1,18 @@import { PermissionAction } from '@supabase/shared-types/out/constants'-import clsx from 'clsx'import Link from 'next/link'import { useRouter } from 'next/router'+import toast from 'react-hot-toast'import { useEffect, useState } from 'react'+import { useTheme } from 'next-themes'import { useParams } from 'common'import { useProjectAddonRemoveMutation } from 'data/subscriptions/project-addon-remove-mutation'import { useProjectAddonUpdateMutation } from 'data/subscriptions/project-addon-update-mutation'import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query'-import { useCheckPermissions, useSelectedOrganization, useSelectedProject, useStore } from 'hooks'+import { useCheckPermissions, useSelectedOrganization, useSelectedProject } from 'hooks'import { BASE_PATH } from 'lib/constants'import Telemetry from 'lib/telemetry'-import { useTheme } from 'next-themes'-import { subscriptionHasHipaaAddon } from 'components/interfaces/Billing/Subscription/Subscription.utils'-import { CriticalIcon, WarningIcon } from 'ui-patterns/Icons/StatusIcons'import { useReadReplicasQuery } from 'data/read-replicas/replicas-query'import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'import type { AddonVariantId } from 'data/subscriptions/types'@@ -30,7 +28,9 @@ import {IconExternalLink,Radio,SidePanel,+ cn,} from 'ui'+import { CriticalIcon, WarningIcon } from 'ui-patterns/Icons/StatusIcons'const PITR_CATEGORY_OPTIONS: {id: 'off' | 'on'@@ -53,7 +53,6 @@ const PITR_CATEGORY_OPTIONS: {]const PITRSidePanel = () => {- const { ui } = useStore()const router = useRouter()const { ref: projectRef } = useParams()const { resolvedTheme } = useTheme()@@ -84,34 +83,20 @@ const PITRSidePanel = () => {const { mutate: updateAddon, isLoading: isUpdating } = useProjectAddonUpdateMutation({onSuccess: () => {- ui.setNotification({- category: 'success',- message: `Successfully updated point in time recovery duration`,- })+ toast.success(`Successfully updated point in time recovery duration`)onClose()},onError: (error) => {- ui.setNotification({- error,- category: 'error',- message: `Unable to update PITR: ${error.message}`,- })+ toast.error(`Unable to update PITR: ${error.message}`)},})const { mutate: removeAddon, isLoading: isRemoving } = useProjectAddonRemoveMutation({onSuccess: () => {- ui.setNotification({- category: 'success',- message: `Successfully disabled point in time recovery`,- })+ toast.success(`Successfully disabled point in time recovery`)onClose()},onError: (error) => {- ui.setNotification({- error,- category: 'error',- message: `Unable to disable PITR: ${error.message}`,- })+ toast.error(`Unable to disable PITR: ${error.message}`)},})const isSubmitting = isUpdating || isRemoving@@ -233,7 +218,7 @@ const PITRSidePanel = () => {return (<divkey={option.id}- className={clsx('col-span-3 group space-y-1', isFreePlan && 'opacity-75')}+ className={cn('col-span-3 group space-y-1', isFreePlan && 'opacity-75')}onClick={() => {setSelectedCategory(option.id)if (option.id === 'off') {@@ -260,7 +245,7 @@ const PITRSidePanel = () => {><imgalt="Point-In-Time-Recovery"- className={clsx(+ className={cn('relative rounded-xl transition border bg-no-repeat bg-center bg-cover cursor-pointer w-[160px] h-[96px]',isSelected? 'border-foreground'@@ -272,7 +257,7 @@ const PITRSidePanel = () => {/><p- className={clsx(+ className={cn('text-sm transition',isSelected ? 'text-foreground' : 'text-foreground-light')}diff --git a/apps/studio/components/interfaces/Settings/General/Infrastructure/RestartServerButton.tsx b/apps/studio/components/interfaces/Settings/General/Infrastructure/RestartServerButton.tsxindex 8a5a5ef365e..51208880e0a 100644--- a/apps/studio/components/interfaces/Settings/General/Infrastructure/RestartServerButton.tsx+++ b/apps/studio/components/interfaces/Settings/General/Infrastructure/RestartServerButton.tsx@@ -4,6 +4,16 @@ import { useQueryClient } from '@tanstack/react-query'import { observer } from 'mobx-react-lite'import { useRouter } from 'next/router'import { useState } from 'react'+import toast from 'react-hot-toast'++import {+ useIsProjectActive,+ useProjectContext,+} from 'components/layouts/ProjectLayout/ProjectContext'+import { useProjectRestartMutation } from 'data/projects/project-restart-mutation'+import { useProjectRestartServicesMutation } from 'data/projects/project-restart-services-mutation'+import { setProjectPostgrestStatus } from 'data/projects/projects-query'+import { useCheckPermissions } from 'hooks'import {Button,DropdownMenu,@@ -12,19 +22,9 @@ import {DropdownMenuTrigger,IconChevronDown,} from 'ui'--import {- useIsProjectActive,- useProjectContext,-} from 'components/layouts/ProjectLayout/ProjectContext'import ConfirmModal from 'ui-patterns/Dialogs/ConfirmDialog'-import { useProjectRestartMutation } from 'data/projects/project-restart-mutation'-import { useProjectRestartServicesMutation } from 'data/projects/project-restart-services-mutation'-import { setProjectPostgrestStatus } from 'data/projects/projects-query'-import { useCheckPermissions, useStore } from 'hooks'const RestartServerButton = () => {- const { ui } = useStore()const router = useRouter()const queryClient = useQueryClient()const { project } = useProjectContext()@@ -58,36 +58,26 @@ const RestartServerButton = () => {const requestProjectRestart = () => {if (!canRestartProject) {- return ui.setNotification({- category: 'error',- message: 'You do not have the required permissions to restart this project',- })+ return toast.error('You do not have the required permissions to restart this project')}restartProject({ ref: projectRef })}const requestDatabaseRestart = async () => {if (!canRestartProject) {- return ui.setNotification({- category: 'error',- message: 'You do not have the required permissions to restart this project',- })+ return toast.error('You do not have the required permissions to restart this project')}restartProjectServices({ ref: projectRef, region: projectRegion, services: ['postgresql'] })}const onRestartFailed = (error: any, type: string) => {- ui.setNotification({- error,- category: 'error',- message: `Unable to restart ${type}: ${error.message}`,- })+ toast.error(`Unable to restart ${type}: ${error.message}`)setServiceToRestart(undefined)}const onRestartSuccess = () => {setProjectPostgrestStatus(queryClient, projectRef, 'OFFLINE')- ui.setNotification({ category: 'success', message: 'Restarting server...' })+ toast.success('Restarting server...')router.push(`/project/${projectRef}`)setServiceToRestart(undefined)}diff --git a/apps/studio/components/interfaces/Settings/Vault/Keys/EncryptionKeysManagement.tsx b/apps/studio/components/interfaces/Settings/Vault/Keys/EncryptionKeysManagement.tsxindex cccd7114bdc..3c6282419dd 100644--- a/apps/studio/components/interfaces/Settings/Vault/Keys/EncryptionKeysManagement.tsx+++ b/apps/studio/components/interfaces/Settings/Vault/Keys/EncryptionKeysManagement.tsx@@ -1,11 +1,19 @@import * as Tooltip from '@radix-ui/react-tooltip'import { PermissionAction } from '@supabase/shared-types/out/constants'-import { useParams } from 'common'import dayjs from 'dayjs'import { sortBy } from 'lodash'import { observer } from 'mobx-react-lite'import Link from 'next/link'import { Fragment, useEffect, useState } from 'react'+import toast from 'react-hot-toast'++import { useParams } from 'common'+import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'+import Divider from 'components/ui/Divider'+import { usePgSodiumKeyCreateMutation } from 'data/pg-sodium-keys/pg-sodium-key-create-mutation'+import { usePgSodiumKeyDeleteMutation } from 'data/pg-sodium-keys/pg-sodium-key-delete-mutation'+import { usePgSodiumKeysQuery } from 'data/pg-sodium-keys/pg-sodium-keys-query'+import { useCheckPermissions } from 'hooks'import {Alert,Button,@@ -21,17 +29,9 @@ import {Modal,} from 'ui'-import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'-import Divider from 'components/ui/Divider'-import { usePgSodiumKeyCreateMutation } from 'data/pg-sodium-keys/pg-sodium-key-create-mutation'-import { usePgSodiumKeyDeleteMutation } from 'data/pg-sodium-keys/pg-sodium-key-delete-mutation'-import { usePgSodiumKeysQuery } from 'data/pg-sodium-keys/pg-sodium-keys-query'-import { useCheckPermissions, useStore } from 'hooks'-const DEFAULT_KEY_NAME = 'No description provided'const EncryptionKeysManagement = () => {- const { ui } = useStore()const { id } = useParams()const { project } = useProjectContext()@@ -82,14 +82,10 @@ const EncryptionKeysManagement = () => {name: values.name,})if (!res.error) {- ui.setNotification({ category: 'success', message: 'Successfully added new key' })+ toast.success('Successfully added new key')setShowAddKeyModal(false)} else {- ui.setNotification({- error: res.error,- category: 'error',- message: `Failed to add new key: ${res.error.message}`,- })+ toast.error(`Failed to add new key: ${res.error.message}`)}setSubmitting(false)}@@ -105,14 +101,10 @@ const EncryptionKeysManagement = () => {id: selectedKeyToRemove.id,})if (!res.error) {- ui.setNotification({ category: 'success', message: `Successfully deleted encryption key` })+ toast.success(`Successfully deleted encryption key`)setSelectedKeyToRemove(undefined)} else {- ui.setNotification({- error: res.error,- category: 'error',- message: `Failed to delete encryption key: ${res.error.message}`,- })+ toast.error(`Failed to delete encryption key: ${res.error.message}`)}setIsDeletingKey(false)}diff --git a/apps/studio/components/interfaces/Settings/Vault/Secrets/AddNewSecretModal.tsx b/apps/studio/components/interfaces/Settings/Vault/Secrets/AddNewSecretModal.tsxindex c2ac918e4ba..a24bc1d05ce 100644--- a/apps/studio/components/interfaces/Settings/Vault/Secrets/AddNewSecretModal.tsx+++ b/apps/studio/components/interfaces/Settings/Vault/Secrets/AddNewSecretModal.tsx@@ -1,12 +1,12 @@import { useEffect, useState } from 'react'-import { Button, Form, IconEye, IconEyeOff, IconHelpCircle, Input, Modal } from 'ui'+import toast from 'react-hot-toast'import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'import InformationBox from 'components/ui/InformationBox'import { usePgSodiumKeyCreateMutation } from 'data/pg-sodium-keys/pg-sodium-key-create-mutation'import { usePgSodiumKeysQuery } from 'data/pg-sodium-keys/pg-sodium-keys-query'import { useVaultSecretCreateMutation } from 'data/vault/vault-secret-create-mutation'-import { useStore } from 'hooks'+import { Button, Form, IconEye, IconEyeOff, IconHelpCircle, Input, Modal } from 'ui'import EncryptionKeySelector from '../Keys/EncryptionKeySelector'interface AddNewSecretModalProps {@@ -15,7 +15,6 @@ interface AddNewSecretModalProps {}const AddNewSecretModal = ({ visible, onClose }: AddNewSecretModalProps) => {- const { ui } = useStore()const [showSecretValue, setShowSecretValue] = useState(false)const [selectedKeyId, setSelectedKeyId] = useState<string>()const { project } = useProjectContext()@@ -57,11 +56,7 @@ const AddNewSecretModal = ({ visible, onClose }: AddNewSecretModalProps) => {name: values.keyName || undefined,})if (addKeyRes.error) {- return ui.setNotification({- error: addKeyRes.error,- category: 'error',- message: `Failed to create new key: ${addKeyRes.error.message}`,- })+ return toast.error(`Failed to create new key: ${addKeyRes.error.message}`)} else {encryptionKeyId = addKeyRes[0].id}@@ -77,18 +72,11 @@ const AddNewSecretModal = ({ visible, onClose }: AddNewSecretModalProps) => {})if (!res.error) {- ui.setNotification({- category: 'success',- message: `Successfully added new secret ${values.name}`,- })+ toast.success(`Successfully added new secret ${values.name}`)onClose()setSubmitting(false)} else {- ui.setNotification({- error: res.error,- category: 'error',- message: `Failed to add secret ${values.name}: ${res.error.message}`,- })+ toast.error(`Failed to add secret ${values.name}: ${res.error.message}`)setSubmitting(false)}}diff --git a/apps/studio/components/interfaces/Settings/Vault/Secrets/EditSecretModal.tsx b/apps/studio/components/interfaces/Settings/Vault/Secrets/EditSecretModal.tsxindex a91ba6cecc0..2c8b75a8b4e 100644--- a/apps/studio/components/interfaces/Settings/Vault/Secrets/EditSecretModal.tsx+++ b/apps/studio/components/interfaces/Settings/Vault/Secrets/EditSecretModal.tsx@@ -1,14 +1,14 @@import { isEmpty } from 'lodash'import { useEffect, useState } from 'react'-import { Button, Form, IconEye, IconEyeOff, Input, Modal } from 'ui'+import toast from 'react-hot-toast'import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'import { usePgSodiumKeyCreateMutation } from 'data/pg-sodium-keys/pg-sodium-key-create-mutation'import { useVaultSecretDecryptedValueQuery } from 'data/vault/vault-secret-decrypted-value-query'import { useVaultSecretUpdateMutation } from 'data/vault/vault-secret-update-mutation'-import { useStore } from 'hooks'import type { VaultSecret } from 'types'+import { Button, Form, IconEye, IconEyeOff, Input, Modal } from 'ui'import EncryptionKeySelector from '../Keys/EncryptionKeySelector'interface EditSecretModalProps {@@ -17,7 +17,6 @@ interface EditSecretModalProps {}const EditSecretModal = ({ selectedSecret, onClose }: EditSecretModalProps) => {- const { ui } = useStore()const [selectedKeyId, setSelectedKeyId] = useState<string>()const [showSecretValue, setShowSecretValue] = useState(false)const { project } = useProjectContext()@@ -60,11 +59,7 @@ const EditSecretModal = ({ selectedSecret, onClose }: EditSecretModalProps) => {name: values.keyName || undefined,})if (addKeyRes.error) {- return ui.setNotification({- error: addKeyRes.error,- category: 'error',- message: `Failed to create new key: ${addKeyRes.error.message}`,- })+ return toast.error(`Failed to create new key: ${addKeyRes.error.message}`)} else {encryptionKeyId = addKeyRes[0].id}@@ -83,15 +78,11 @@ const EditSecretModal = ({ selectedSecret, onClose }: EditSecretModalProps) => {...payload,})if (!res.error) {- ui.setNotification({ category: 'success', message: 'Successfully updated secret' })+ toast.success('Successfully updated secret')setSubmitting(false)onClose()} else {- ui.setNotification({- error: res.error,- category: 'error',- message: `Failed to update secret: ${res.error.message}`,- })+ toast.error(`Failed to update secret: ${res.error.message}`)setSubmitting(false)}}diff --git a/apps/studio/components/interfaces/SignIn/ResetPasswordForm.tsx b/apps/studio/components/interfaces/SignIn/ResetPasswordForm.tsxindex dca1a2d8730..82312ae3cf6 100644--- a/apps/studio/components/interfaces/SignIn/ResetPasswordForm.tsx+++ b/apps/studio/components/interfaces/SignIn/ResetPasswordForm.tsx@@ -1,21 +1,15 @@import { useRouter } from 'next/router'import toast from 'react-hot-toast'-import { useStore } from 'hooks'import { auth } from 'lib/gotrue'import { passwordSchema } from 'lib/schemas'import { Button, Form, Input } from 'ui'const ResetPasswordForm = () => {- const { ui } = useStore()const router = useRouter()const onResetPassword = async ({ password }: { password: string }) => {- const toastId = ui.setNotification({- category: 'loading',- message: `Saving password...`,- })-+ const toastId = toast.loading('Saving password...')const { error } = await auth.updateUser({ password })if (!error) {diff --git a/apps/studio/components/interfaces/SignIn/SignInForm.tsx b/apps/studio/components/interfaces/SignIn/SignInForm.tsxindex 506b13568e4..d1f424d6bda 100644--- a/apps/studio/components/interfaces/SignIn/SignInForm.tsx+++ b/apps/studio/components/interfaces/SignIn/SignInForm.tsx@@ -4,10 +4,10 @@ import { useQueryClient } from '@tanstack/react-query'import Link from 'next/link'import { useRouter } from 'next/router'import { useRef, useState } from 'react'+import toast from 'react-hot-toast'import { object, string } from 'yup'import { getMfaAuthenticatorAssuranceLevel } from 'data/profile/mfa-authenticator-assurance-level-query'-import { useStore } from 'hooks'import { auth, buildPathWithParams, getReturnToPath } from 'lib/gotrue'import { Button, Form, Input } from 'ui'@@ -17,7 +17,6 @@ const signInSchema = object({})const SignInForm = () => {- const { ui } = useStore()const router = useRouter()const queryClient = useQueryClient()@@ -25,10 +24,7 @@ const SignInForm = () => {const captchaRef = useRef<HCaptcha>(null)const onSignIn = async ({ email, password }: { email: string; password: string }) => {- const toastId = ui.setNotification({- category: 'loading',- message: `Signing in...`,- })+ const toastId = toast.loading('Signing in...')let token = captchaTokenif (!token) {@@ -47,50 +43,32 @@ const SignInForm = () => {const data = await getMfaAuthenticatorAssuranceLevel()if (data) {if (data.currentLevel !== data.nextLevel) {- ui.setNotification({- id: toastId,- category: 'success',- message: `You need to provide your second factor authentication.`,- })+ toast.success(`You need to provide your second factor authentication`, { id: toastId })const url = buildPathWithParams('/sign-in-mfa')router.replace(url)return}}- ui.setNotification({- id: toastId,- category: 'success',- message: `Signed in successfully!`,- })-+ toast.success(`Signed in successfully!`, { id: toastId })await queryClient.resetQueries()router.push(getReturnToPath())} catch (error) {- ui.setNotification({- id: toastId,- category: 'error',- message: (error as AuthError).message,- })+ toast.error((error as AuthError).message, { id: toastId })}} else {setCaptchaToken(null)captchaRef.current?.resetCaptcha()if (error.message.toLowerCase() === 'email not confirmed') {- return ui.setNotification({- id: toastId,- category: 'error',- message: 'Account has not been verified, please check the link sent to your email',- })+ return toast.error(+ 'Account has not been verified, please check the link sent to your email',+ { id: toastId }+ )}- ui.setNotification({- id: toastId,- category: 'error',- message: error.message,- })+ toast.error(error.message, { id: toastId })}}diff --git a/apps/studio/components/interfaces/SignIn/SignInMfaForm.tsx b/apps/studio/components/interfaces/SignIn/SignInMfaForm.tsxindex c3552582891..3dd480112ef 100644--- a/apps/studio/components/interfaces/SignIn/SignInMfaForm.tsx+++ b/apps/studio/components/interfaces/SignIn/SignInMfaForm.tsx@@ -12,7 +12,6 @@ import AlertError from 'components/ui/AlertError'import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'import { useMfaChallengeAndVerifyMutation } from 'data/profile/mfa-challenge-and-verify-mutation'import { useMfaListFactorsQuery } from 'data/profile/mfa-list-factors-query'-import { useStore } from 'hooks'import { useSignOut } from 'lib/auth'import { getReturnToPath } from 'lib/gotrue'import Telemetry from 'lib/telemetry'@@ -23,7 +22,6 @@ const signInSchema = object({})const SignInMfaForm = () => {- const { ui } = useStore()const queryClient = useQueryClient()const router = useRouter()const telemetryProps = useTelemetryProps()@@ -61,10 +59,7 @@ const SignInMfaForm = () => {}, [factors?.totp, isSuccessFactors, router, queryClient])const onSignIn = async ({ code }: { code: string }) => {- const toastId = ui.setNotification({- category: 'loading',- message: `Signing in...`,- })+ const toastId = toast.loading('Signing in...')if (selectedFactor) {await mfaChallengeAndVerify({ factorId: selectedFactor.id, code, refreshFactors: false },diff --git a/apps/studio/components/interfaces/SignIn/SignInSSOForm.tsx b/apps/studio/components/interfaces/SignIn/SignInSSOForm.tsxindex 2c887f01b49..6708879bf34 100644--- a/apps/studio/components/interfaces/SignIn/SignInSSOForm.tsx+++ b/apps/studio/components/interfaces/SignIn/SignInSSOForm.tsx@@ -1,29 +1,25 @@import HCaptcha from '@hcaptcha/react-hcaptcha'import { useQueryClient } from '@tanstack/react-query'-import { useStore } from 'hooks'-import { BASE_PATH } from 'lib/constants'-import { auth, buildPathWithParams } from 'lib/gotrue'import { useRef, useState } from 'react'import toast from 'react-hot-toast'-import { Button, Form, Input } from 'ui'import { object, string } from 'yup'+import { BASE_PATH } from 'lib/constants'+import { auth, buildPathWithParams } from 'lib/gotrue'+import { Button, Form, Input } from 'ui'+const signInSchema = object({email: string().email('Must be a valid email').required('Email is required'),})const SignInSSOForm = () => {- const { ui } = useStore()const queryClient = useQueryClient()const [captchaToken, setCaptchaToken] = useState<string | null>(null)const captchaRef = useRef<HCaptcha>(null)const onSignIn = async ({ email }: { email: string }) => {- const toastId = ui.setNotification({- category: 'loading',- message: `Signing in...`,- })+ const toastId = toast.loading('Signing in...')let token = captchaTokenif (!token) {diff --git a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsxindex 227d0aef15d..a1fc06afd64 100644--- a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx+++ b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx@@ -234,7 +234,7 @@ const SidePanelEditor = ({})if (response?.error) {- ui.setNotification({ category: 'error', message: response.error.message })+ toast.error(response.error.message)} else {if (!isNewRecord &&@@ -495,10 +495,9 @@ const SidePanelEditor = ({}const { file, rowCount, selectedHeaders, resolve } = importContent- const toastId = ui.setNotification({- category: 'loading',- message: `Adding ${rowCount.toLocaleString()} rows to ${selectedTable.name}`,- })+ const toastId = toast.loading(+ `Adding ${rowCount.toLocaleString()} rows to ${selectedTable.name}`+ )if (file && rowCount > 0) {// CSV file upload@@ -551,10 +550,8 @@ const SidePanelEditor = ({sqlKeys.query(project?.ref, [selectedTable!.schema, selectedTable!.name])),])- ui.setNotification({+ toast.success(`Successfully imported ${rowCount} rows of data into ${selectedTable.name}`, {id: toastId,- category: 'success',- message: `Successfully imported ${rowCount} rows of data into ${selectedTable.name}`,})resolve()snap.closeSidePanel()diff --git a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/SpreadsheetImport/SpreadsheetImport.tsx b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/SpreadsheetImport/SpreadsheetImport.tsxindex 3f5ca626dc6..c587a914a41 100644--- a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/SpreadsheetImport/SpreadsheetImport.tsx+++ b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/SpreadsheetImport/SpreadsheetImport.tsx@@ -1,10 +1,10 @@-import Link from 'next/link'import type { PostgresTable } from '@supabase/postgres-meta'import { debounce, includes, noop } from 'lodash'+import Link from 'next/link'import { useCallback, useEffect, useState } from 'react'-import { Button, IconExternalLink, SidePanel, Tabs } from 'ui'+import toast from 'react-hot-toast'-import { useStore } from 'hooks'+import { Button, IconExternalLink, SidePanel, Tabs } from 'ui'import ActionBar from '../ActionBar'import type { ImportContent } from '../TableEditor/TableEditor.types'import SpreadSheetFileUpload from './SpreadSheetFileUpload'@@ -18,7 +18,6 @@ import {parseSpreadsheetText,} from './SpreadsheetImport.utils'import SpreadsheetImportPreview from './SpreadsheetImportPreview'-import toast from 'react-hot-toast'const MAX_CSV_SIZE = 1024 * 1024 * 100 // 100 MB@@ -43,8 +42,6 @@ const SpreadsheetImport = ({closePanel,updateEditorDirty = noop,}: SpreadsheetImportProps) => {- const { ui } = useStore()-useEffect(() => {if (visible && headers.length === 0) {resetSpreadsheetImport()@@ -100,10 +97,7 @@ const SpreadsheetImport = ({}if (!file || !includes(UPLOAD_FILE_TYPES, file?.type) || !acceptedFileExtension(file)) {- ui.setNotification({- category: 'info',- message: 'Sorry! We only accept CSV or TSV file types, please upload another file.',- })+ toast.error('Sorry! We only accept CSV or TSV file types, please upload another file.')} else {updateEditorDirty(true)setUploadedFile(file)@@ -112,12 +106,9 @@ const SpreadsheetImport = ({onProgressUpdate)if (errors.length > 0) {- ui.setNotification({- error: errors,- category: 'error',- message: `Some issues have been detected on ${errors.length} rows. More details below the content preview.`,- duration: 4000,- })+ toast.error(+ `Some issues have been detected on ${errors.length} rows. More details below the content preview.`+ )}setErrors(errors)@@ -139,12 +130,9 @@ const SpreadsheetImport = ({if (text.length > 0) {const { headers, rows, columnTypeMap, errors } = await parseSpreadsheetText(text)if (errors.length > 0) {- ui.setNotification({- error: errors,- category: 'error',- message: `Some issues have been detected on ${errors.length} rows. More details below the content preview.`,- duration: 4000,- })+ toast.error(+ `Some issues have been detected on ${errors.length} rows. More details below the content preview.`+ )}setErrors(errors)setSelectedHeaders(headers)@@ -169,22 +157,15 @@ const SpreadsheetImport = ({const onConfirm = (resolve: () => void) => {if (tab === 'fileUpload' && uploadedFile === undefined) {- ui.setNotification({- category: 'error',- message: 'Please upload a file to import your data with',- })+ toast.error('Please upload a file to import your data with')resolve()} else if (selectedHeaders.length === 0) {- ui.setNotification({- category: 'error',- message: 'Please select at least one header from your CSV',- })+ toast.error('Please select at least one header from your CSV')resolve()} else if (!isCompatible) {- ui.setNotification({- category: 'error',- message: 'The data that you are trying to import is incompatible with your table structure',- })+ toast.error(+ 'The data that you are trying to import is incompatible with your table structure'+ )resolve()} else {saveContent({ file: uploadedFile, ...spreadsheetData, selectedHeaders, resolve })diff --git a/apps/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx b/apps/studio/components/interfaces/TableGridEditor/TableGridEditor.tsxindex a826bb34101..9111f4a2576 100644--- a/apps/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx+++ b/apps/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx@@ -5,6 +5,7 @@ import { useParams } from 'common'import { find, isUndefined } from 'lodash'import { observer } from 'mobx-react-lite'import { useRouter } from 'next/router'+import toast from 'react-hot-toast'import { parseSupaTable, SupabaseGrid, SupaTable } from 'components/grid'import { ERROR_PRIMARY_KEY_NOTFOUND } from 'components/grid/constants'@@ -16,10 +17,9 @@ import {useForeignKeyConstraintsQuery,} from 'data/database/foreign-key-constraints-query'import { ENTITY_TYPE } from 'data/entity-types/entity-type-constants'-import { executeSql } from 'data/sql/execute-sql-query'import { sqlKeys } from 'data/sql/keys'import { useTableRowUpdateMutation } from 'data/table-rows/table-row-update-mutation'-import { useCheckPermissions, useLatest, useStore, useUrlState } from 'hooks'+import { useCheckPermissions, useLatest, useUrlState } from 'hooks'import useEntityType from 'hooks/misc/useEntityType'import type { TableLike } from 'hooks/misc/useTable'import { EXCLUDED_SCHEMAS } from 'lib/constants/schemas'@@ -47,7 +47,6 @@ const TableGridEditor = ({selectedTable,}: TableGridEditorProps) => {const router = useRouter()- const { ui } = useStore()const { ref: projectRef, id } = useParams()const { project } = useProjectContext()@@ -196,10 +195,7 @@ const TableGridEditor = ({if (column) {snap.onEditColumn(column)} else {- ui.setNotification({- category: 'error',- message: `Unable to find column ${name} in ${selectedTable?.name}`,- })+ toast.error(`Unable to find column ${name} in ${selectedTable?.name}`)}}@@ -208,18 +204,12 @@ const TableGridEditor = ({if (column) {snap.onDeleteColumn(column)} else {- ui.setNotification({- category: 'error',- message: `Unable to find column ${name} in ${selectedTable?.name}`,- })+ toast.error(`Unable to find column ${name} in ${selectedTable?.name}`)}}const onError = (error: any) => {- ui.setNotification({- category: 'error',- message: error?.details ?? error?.message ?? error,- })+ toast.error(error?.details ?? error?.message ?? error)}const updateTableRow = (previousRow: any, updatedData: any) => {@@ -241,10 +231,7 @@ const TableGridEditor = ({const configuration = { identifiers }if (Object.keys(identifiers).length === 0) {- return ui.setNotification({- category: 'error',- message: ERROR_PRIMARY_KEY_NOTFOUND,- })+ toast.error(ERROR_PRIMARY_KEY_NOTFOUND)}mutateUpdateTableRow({diff --git a/apps/studio/components/layouts/TableEditorLayout/EntityListItem.tsx b/apps/studio/components/layouts/TableEditorLayout/EntityListItem.tsxindex 6f68ae1466a..08a056780f2 100644--- a/apps/studio/components/layouts/TableEditorLayout/EntityListItem.tsx+++ b/apps/studio/components/layouts/TableEditorLayout/EntityListItem.tsx@@ -1,10 +1,18 @@import * as Tooltip from '@radix-ui/react-tooltip'-import clsx from 'clsx'-import { IS_PLATFORM } from 'common'import saveAs from 'file-saver'import { Eye, MoreHorizontal, Table2, Unlock } from 'lucide-react'import Link from 'next/link'import Papa from 'papaparse'+import toast from 'react-hot-toast'++import { IS_PLATFORM } from 'common'+import { parseSupaTable } from 'components/grid'+import type { ItemRenderer } from 'components/ui/InfiniteList'+import { ENTITY_TYPE } from 'data/entity-types/entity-type-constants'+import type { Entity } from 'data/entity-types/entity-type-query'+import { fetchAllTableRows } from 'data/table-rows/table-rows-query'+import { getTable } from 'data/tables/table-query'+import { useTableEditorStateSnapshot } from 'state/table-editor'import {DropdownMenu,DropdownMenuContent,@@ -18,15 +26,6 @@ import {IconTrash,cn,} from 'ui'--import { parseSupaTable } from 'components/grid'-import type { ItemRenderer } from 'components/ui/InfiniteList'-import { ENTITY_TYPE } from 'data/entity-types/entity-type-constants'-import type { Entity } from 'data/entity-types/entity-type-query'-import { fetchAllTableRows } from 'data/table-rows/table-rows-query'-import { getTable } from 'data/tables/table-query'-import { useStore } from 'hooks'-import { useTableEditorStateSnapshot } from 'state/table-editor'import { useProjectContext } from '../ProjectLayout/ProjectContext'export interface EntityListItemProps {@@ -41,7 +40,6 @@ const EntityListItem: ItemRenderer<Entity, EntityListItemProps> = ({item: entity,isLocked,}) => {- const { ui } = useStore()const { project } = useProjectContext()const snap = useTableEditorStateSnapshot()@@ -56,12 +54,10 @@ const EntityListItem: ItemRenderer<Entity, EntityListItemProps> = ({}const exportTableAsCSV = async () => {- if (IS_PLATFORM && !project?.connectionString)+ if (IS_PLATFORM && !project?.connectionString) {return console.error('Connection string is required')- const toastId = ui.setNotification({- category: 'loading',- message: `Exporting ${entity.name} as CSV...`,- })+ }+ const toastId = toast.loading(`Exporting ${entity.name} as CSV...`)try {const table = await getTable({@@ -103,17 +99,9 @@ const EntityListItem: ItemRenderer<Entity, EntityListItemProps> = ({saveAs(csvData, `${entity!.name}_rows.csv`)}- ui.setNotification({- id: toastId,- category: 'success',- message: `Successfully exported ${entity.name} as CSV`,- })+ toast.success(`Successfully exported ${entity.name} as CSV`, { id: toastId })} catch (error: any) {- ui.setNotification({- id: toastId,- category: 'error',- message: `Failed to export table: ${error.message}`,- })+ toast.error(`Failed to export table: ${error.message}`, { id: toastId })}}@@ -142,7 +130,7 @@ const EntityListItem: ItemRenderer<Entity, EntityListItemProps> = ({<Eye size={15} strokeWidth={1.5} className="text-foreground-lighter" />) : (<div- className={clsx(+ className={cn('flex items-center justify-center text-xs h-4 w-4 rounded-[2px] font-bold',entity.type === ENTITY_TYPE.FOREIGN_TABLE && 'text-yellow-900 bg-yellow-500',entity.type === ENTITY_TYPE.MATERIALIZED_VIEW && 'text-purple-1000 bg-purple-500',diff --git a/apps/studio/components/to-be-cleaned/Storage/StoragePolicies/StoragePoliciesEditPolicyModal.tsx b/apps/studio/components/to-be-cleaned/Storage/StoragePolicies/StoragePoliciesEditPolicyModal.tsxindex e5dac39b628..bbf03752aff 100644--- a/apps/studio/components/to-be-cleaned/Storage/StoragePolicies/StoragePoliciesEditPolicyModal.tsx+++ b/apps/studio/components/to-be-cleaned/Storage/StoragePolicies/StoragePoliciesEditPolicyModal.tsx@@ -1,20 +1,19 @@import { noop, pull } from 'lodash'import { useEffect, useState } from 'react'-import { Button, IconChevronLeft, IconExternalLink, Modal } from 'ui'+import toast from 'react-hot-toast'-import { useStore } from 'hooks'+import {+ POLICY_MODAL_VIEWS,+ PolicySelection,+ PolicyTemplates,+} from 'components/interfaces/Auth/Policies'+import { Button, IconChevronLeft, IconExternalLink, Modal } from 'ui'import {applyBucketIdToTemplateDefinition,createPayloadsForAddPolicy,createSQLPolicies,} from '../Storage.utils'import { STORAGE_POLICY_TEMPLATES } from './StoragePolicies.constants'--import {- POLICY_MODAL_VIEWS,- PolicySelection,- PolicyTemplates,-} from 'components/interfaces/Auth/Policies'import StoragePoliciesEditor from './StoragePoliciesEditor'import StoragePoliciesReview from './StoragePoliciesReview'@@ -33,7 +32,6 @@ const StoragePoliciesEditPolicyModal = ({onCreatePolicies = () => {},onSaveSuccess = () => {},}: any) => {- const { ui } = useStore()const [previousView, setPreviousView] = useState('') // Mainly to decide which view to show when back from templatesconst [view, setView] = useState('')@@ -122,20 +120,14 @@ const StoragePoliciesEditPolicyModal = ({const validatePolicyEditorFormFields = () => {const { name, definition, allowedOperations } = policyFormFieldsif (name.length === 0) {- return ui.setNotification({ category: 'info', message: 'Do give your policy a name' })+ return toast.error('Please provide a name for your policy')}if (definition.length === 0) {// Will need to figure out how to strip away comments or something- return ui.setNotification({- category: 'info',- message: 'Did you forget to provide a definition for your policy?',- })+ return toast.error('Please provide a definition for your policy')}if (allowedOperations.length === 0) {- return ui.setNotification({- category: 'info',- message: 'You will need to allow at least one operation in your policy',- })+ return toast.error('Please allow at least one operation in your policy')}const policySQLStatements = createSQLPolicies(bucketName, policyFormFields)diff --git a/apps/studio/localStores/storageExplorer/StorageExplorerStore.ts b/apps/studio/localStores/storageExplorer/StorageExplorerStore.tsindex 1f400d094fc..5581824837a 100644--- a/apps/studio/localStores/storageExplorer/StorageExplorerStore.ts+++ b/apps/studio/localStores/storageExplorer/StorageExplorerStore.ts@@ -563,10 +563,7 @@ class StorageExplorerStore {if (error) {numberOfFilesUploadedFail += 1- this.ui.setNotification({- message: `Failed to upload ${file.name}: ${error.message}`,- category: 'error',- })+ toast.error(`Failed to upload ${file.name}: ${error.message}`)resolve()} else {numberOfFilesUploadedSuccess += 1@@ -607,37 +604,27 @@ class StorageExplorerStore {if (numberOfFilesToUpload === 0) {toast.dismiss(toastId)} else if (numberOfFilesUploadedFail === numberOfFilesToUpload) {- this.ui.setNotification({- id: toastId,- category: 'error',- message: `Failed to upload ${numberOfFilesToUpload} file${- numberOfFilesToUpload > 1 ? 's' : ''- }!`,- })+ toast.error(+ `Failed to upload ${numberOfFilesToUpload} file${numberOfFilesToUpload > 1 ? 's' : ''}!`,+ { id: toastId }+ )} else if (numberOfFilesUploadedSuccess === numberOfFilesToUpload) {- this.ui.setNotification({- id: toastId,- category: 'success',- message: `Successfully uploaded ${numberOfFilesToUpload} file${+ toast.success(+ `Successfully uploaded ${numberOfFilesToUpload} file${numberOfFilesToUpload > 1 ? 's' : ''}!`,- })+ { id: toastId }+ )} else {- this.ui.setNotification({- id: toastId,- category: 'success',- message: `Successfully uploaded ${numberOfFilesUploadedSuccess} out of ${numberOfFilesToUpload} file${+ toast.success(+ `Successfully uploaded ${numberOfFilesUploadedSuccess} out of ${numberOfFilesToUpload} file${numberOfFilesToUpload > 1 ? 's' : ''}!`,- })+ { id: toastId }+ )}} catch (e) {- this.ui.setNotification({- id: toastId,- error: e,- message: 'Failed to upload files',- category: 'error',- })+ toast.error('Failed to upload files', { id: toastId })}const t2 = new Date()@@ -674,7 +661,7 @@ class StorageExplorerStore {})if (res.error) {numberOfFilesMovedFail += 1- this.ui.setNotification({ category: 'error', message: res.error.message })+ toast.error(res.error.message)}}))@@ -715,10 +702,7 @@ class StorageExplorerStore {if (!res.error) {return res.publicUrl} else {- this.ui.setNotification({- category: 'error',- message: `Failed to fetch public file preview: ${res.error.message}`,- })+ toast.error(`Failed to fetch public file preview: ${res.error.message}`)}} else {const res = await post(`${this.endpoint}/buckets/${this.selectedBucket.id}/objects/sign`, {@@ -728,10 +712,7 @@ class StorageExplorerStore {if (!res.error) {return res.signedUrl} else {- this.ui.setNotification({- category: 'error',- message: `Failed to fetch signed url preview: ${res.error.message}`,- })+ toast.error(`Failed to fetch signed url preview: ${res.error.message}`)}}return null@@ -803,11 +784,7 @@ class StorageExplorerStore {await Promise.all(parentFolderPrefixes.map((prefix) => this.validateParentFolderEmpty(prefix)))- this.ui.setNotification({- id: toastId,- category: 'success',- message: `Successfully deleted ${prefixes.length} file(s)`,- })+ toast.success(`Successfully deleted ${prefixes.length} file(s)`, { id: toastId })await this.refetchAllOpenedFolders()this.clearSelectedItemsToDelete()} else {@@ -817,10 +794,7 @@ class StorageExplorerStore {downloadFolder = async (folder) => {let progress = 0- const toastId = this.ui.setNotification({- category: 'loading',- message: 'Retrieving files from folder...',- })+ const toastId = toast.loading('Retrieving files from folder...')const files = await this.getAllItemsAlongFolder(folder)@@ -875,11 +849,7 @@ class StorageExplorerStore {const zipWriter = new ZipWriter(zipFileWriter, { bufferedWrite: true })if (downloadedFiles.length === 0) {- return this.ui.setNotification({- id: toastId,- category: 'error',- message: `Failed to download files from "${folder.name}"`,- })+ toast.error(`Failed to download files from "${folder.name}"`, { id: toastId })}downloadedFiles.forEach((file) => {@@ -894,16 +864,14 @@ class StorageExplorerStore {link.click()link.parentNode.removeChild(link)- this.ui.setNotification({- id: toastId,- category: 'success',- message:- downloadedFiles.length === files.length- ? `Successfully downloaded folder "${folder.name}"`- : `Downloaded folder "${folder.name}". However, ${- files.length - downloadedFiles.length- } files did not download successfully.`,- })+ toast.success(+ downloadedFiles.length === files.length+ ? `Successfully downloaded folder "${folder.name}"`+ : `Downloaded folder "${folder.name}". However, ${+ files.length - downloadedFiles.length+ } files did not download successfully.`,+ { id: toastId }+ )}downloadSelectedFiles = async (files) => {@@ -922,10 +890,7 @@ class StorageExplorerStore {let progress = 0const returnBlob = trueconst showIndividualToast = false- const toastId = this.ui.setNotification({- category: 'loading',- message: `Downloading ${files.length} files...`,- })+ const toastId = toast.loading(`Downloading ${files.length} files...`)const promises = formattedFilesWithPrefix.map((file) => {return () => {@@ -965,20 +930,14 @@ class StorageExplorerStore {link.click()link.parentNode.removeChild(link)- this.ui.setNotification({- id: toastId,- category: 'success',- message: `Successfully downloaded ${downloadedFiles.length} files`,- })+ toast.success(`Successfully downloaded ${downloadedFiles.length} files`, { id: toastId })}downloadFile = async (file, showToast = true, returnBlob = false) => {const fileName = file.nameconst fileMimeType = file?.metadata?.mimetype ?? null- const toastId = showToast- ? this.ui.setNotification({ category: 'loading', message: `Retrieving ${fileName}...` })- : undefined+ const toastId = showToast ? toast.loading(`Retrieving ${fileName}...`) : undefinedconst pathToFile = this.openedFolders.slice(0, file.columnIndex)@@ -1004,21 +963,12 @@ class StorageExplorerStore {link.parentNode.removeChild(link)window.URL.revokeObjectURL(blob)if (toastId) {- this.ui.setNotification({- id: toastId,- category: 'success',- message: `Downloading ${fileName}`,- })+ toast.success(`Downloading ${fileName}`, { id: toastId })}return true} else {if (toastId) {- this.ui.setNotification({- error: res.error,- id: toastId,- category: 'error',- message: `Failed to download ${fileName}`,- })+ toast.error(`Failed to download ${fileName}`, { id: toastId })}return false}@@ -1042,15 +992,9 @@ class StorageExplorerStore {})if (res.error) {- this.ui.setNotification({- category: 'error',- message: `Failed to rename file: ${res.error.message}`,- })+ toast.error(`Failed to rename file: ${res.error.message}`)} else {- this.ui.setNotification({- category: 'success',- message: `Successfully renamed "${originalName}" to "${newName}"`,- })+ toast.success(`Successfully renamed "${originalName}" to "${newName}"`)// Clear file preview cache if the renamed file exists in the cacheconst updatedFilePreviewCache = this.filePreviewCache.filter(@@ -1112,11 +1056,7 @@ class StorageExplorerStore {index)} else if (!res.error.message.includes('aborted')) {- this.ui.setNotification({- error: res.error,- category: 'error',- message: `Failed to retrieve folder contents from "${folderName}": ${res.error.message}`,- })+ toast.error(`Failed to retrieve folder contents from "${folderName}": ${res.error.message}`)}}@@ -1152,11 +1092,7 @@ class StorageExplorerStore {return col})} else if (!res.error.message.includes('aborted')) {- this.ui.setNotification({- error: res.error,- category: 'error',- message: `Failed to retrieve folder contents from "${folderName}": ${res.error.message}`,- })+ toast.error(`Failed to retrieve folder contents from "${folderName}": ${res.error.message}`)}}@@ -1191,11 +1127,7 @@ class StorageExplorerStore {options,})if (res.error) {- this.ui.setNotification({- error: res.error,- category: 'error',- message: `Failed to fetch folders: ${res.error.message}`,- })+ toast.error(`Failed to fetch folders: ${res.error.message}`)return []}return res@@ -1267,10 +1199,7 @@ class StorageExplorerStore {await this.refetchAllOpenedFolders()this.clearSelectedItemsToDelete()- this.ui.setNotification({- category: 'success',- message: `Successfully deleted ${folder.name}`,- })+ toast.success(`Successfully deleted ${folder.name}`)}renameFolder = async (folder, newName, columnIndex) => {@@ -1295,10 +1224,7 @@ class StorageExplorerStore {* todo: move this to a util file, as createFolder() uses same logic*/if (newName.includes('/') || newName.includes('\\')) {- return this.ui.setNotification({- message: `Folder name cannot contain forward or back slashes.`,- type: 'error',- })+ return toast.error(`Folder name cannot contain forward or back slashes.`)}this.updateRowStatus(originalName, STORAGE_ROW_STATUS.LOADING, columnIndex, newName)@@ -1328,10 +1254,7 @@ class StorageExplorerStore {)if (res.error) {hasErrors = true- this.ui.setNotification({- category: 'error',- message: `Failed to move ${fromPath} to the new folder`,- })+ toast.error(`Failed to move ${fromPath} to the new folder`)}resolve()})@@ -1355,17 +1278,9 @@ class StorageExplorerStore {}, Promise.resolve())if (!hasErrors) {- this.ui.setNotification({- id: toastId,- message: `Successfully renamed folder to ${newName}`,- category: 'success',- })+ toast.success(`Successfully renamed folder to ${newName}`, { id: toastId })} else {- this.ui.setNotification({- id: toastId,- message: `Renamed folder to ${newName} with some errors`,- category: 'error',- })+ toast.error(`Renamed folder to ${newName} with some errors`, { id: toastId })}await this.refetchAllOpenedFolders()@@ -1376,11 +1291,7 @@ class StorageExplorerStore {)this.filePreviewCache = updatedFilePreviewCache} catch (e) {- this.ui.setNotification({- id: toastId,- message: `Failed to rename folder to ${newName}`,- category: 'error',- })+ toast.error(`Failed to rename folder to ${newName}`, { id: toastId })}}@@ -1471,11 +1382,9 @@ class StorageExplorerStore {const updatedFileName = fileName + ` (${itemsWithSameNameInColumn.length + 1})`return fileExt ? `${updatedFileName}.${fileExt}` : updatedFileName} else {- this.ui.setNotification({- message: `The name ${name} already exists in the current directory. Please use a different name.`,- category: 'error',- duration: 4000,- })+ toast.error(+ `The name ${name} already exists in the current directory. Please use a different name.`+ )return null}}