import { useParams } from 'common' import { AlertTriangle, ExternalLink } from 'lucide-react' import Link from 'next/link' import { useState } from 'react' import { useResourceWarningsQuery } from 'data/usage/resource-warnings-query' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { DOCS_URL } from 'lib/constants' import { AlertDescription_Shadcn_, AlertTitle_Shadcn_, Alert_Shadcn_, Button } from 'ui' import ConfirmDisableReadOnlyModeModal from './DatabaseSettings/ConfirmDisableReadOnlyModal' export const DatabaseReadOnlyAlert = () => { const { ref: projectRef } = useParams() const { data: organization } = useSelectedOrganizationQuery() const [showConfirmationModal, setShowConfirmationModal] = useState(false) const { data: resourceWarnings } = useResourceWarningsQuery({ ref: projectRef }) // [Joshen Cleanup] JFYI this can be cleaned up once BE changes are live which will only return the warnings based on the provided ref // No longer need to filter by ref on the client side const isReadOnlyMode = (resourceWarnings ?? [])?.find((warning) => warning.project === projectRef) ?.is_readonly_mode_enabled ?? false return ( <> {isReadOnlyMode && ( Project is in read-only mode and database is no longer accepting write requests You have reached 95% of your project's disk space, and read-only mode has been enabled to preserve your database's stability and prevent your project from exceeding its current billing plan. To resolve this, you may:
  • Temporarily disable read-only mode to free up space and reduce your database size
  • {organization?.plan.id === 'free' ? (
  • Upgrade to the Pro Plan {' '} to increase your database size limit to 8GB.
  • ) : organization?.plan.id === 'pro' && organization?.usage_billing_enabled ? (
  • Disable your Spend Cap {' '} to allow your project to auto-scale and expand beyond the 8GB database size limit
  • ) : null}
)} setShowConfirmationModal(false)} /> ) }