The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Move upgrade prompt out to own component
Terry Sutton520e8c1144fb
diff --git a/studio/components/interfaces/Settings/Logs/UpgradePrompt.tsx b/studio/components/interfaces/Settings/Logs/UpgradePrompt.tsxindex c0a3c28abb9..1b9cb9e82c6 100644--- a/studio/components/interfaces/Settings/Logs/UpgradePrompt.tsx+++ b/studio/components/interfaces/Settings/Logs/UpgradePrompt.tsx@@ -1,101 +1,71 @@-import Link from 'next/link'-import dayjs from 'dayjs'-import { useState } from 'react'-import { Button, IconHelpCircle, IconLoader, Modal } from 'ui'+import { Button, Modal } from 'ui'import { TIER_QUERY_LIMITS } from '.'-import { useProjectSubscription } from 'hooks'+import Link from 'next/link'+import { useRouter } from 'next/router'interface Props {- projectRef: string- from: string+ show: boolean+ setShowUpgradePrompt: (value: boolean) => void}-const UpgradePrompt: React.FC<Props> = ({ projectRef, from }) => {- const [showHelperModal, setShowHelperModal] = useState(false)- const { subscription, isLoading, isError } = useProjectSubscription(projectRef)-- if (isLoading) return <IconLoader size={16} className="animate-spin" />- if (isError) console.error('Error fetching project subscription')-- const tier = subscription?.tier- const queryLimit = TIER_QUERY_LIMITS[(tier?.key || 'FREE') as keyof typeof TIER_QUERY_LIMITS]-- const fromValue = from ? dayjs(from) : dayjs()- const fromMax = dayjs().startOf('day').subtract(queryLimit.value, queryLimit.unit)- const isExceedingLimit = fromValue.isBefore(fromMax)+const UpgradePrompt: React.FC<Props> = ({ show, setShowUpgradePrompt }) => {+ const router = useRouter()+ const { ref } = router.queryreturn (- <>- <div- className={`flex flex-row items-center gap-3 px-2 py-1 text-xs transition-all ${- isExceedingLimit- ? 'rounded border border-yellow-700 bg-yellow-200 font-semibold text-yellow-1100'- : ''- }`}- >- <span className="text-scale-1100">{`${queryLimit.text} retention`}</span>- <IconHelpCircle- size={16}- strokeWidth={1.5}- className="cursor-pointer text-scale-1100 transition hover:text-scale-1200"- onClick={() => setShowHelperModal(true)}- />- {queryLimit.promptUpgrade && (- <Link href={`/project/${projectRef}/settings/billing`}>- <Button size="tiny">Upgrade</Button>- </Link>- )}- </div>-- <Modal- hideFooter- visible={showHelperModal}- size="medium"- header="Log retention"- onCancel={() => setShowHelperModal(false)}- >- <div className="space-y-4 py-4">- <Modal.Content>- <div className="space-y-4">- <p className="text-sm">- Logs can be retained up to a duration of 3 months depending on the plan that your- project is on. The table below shows an overview of the duration for which your logs- will be retained for based on each plan.- </p>- <div className="rounded border border-scale-600 bg-scale-500">- <div className="flex items-center px-4 pt-2 pb-1">- <p className="w-[40%] text-sm text-scale-1100">Plan</p>- <p className="w-[60%] text-sm text-scale-1100">Retention duration</p>+ <Modal+ hideFooter+ visible={show}+ closable+ size="medium"+ header="Log retention"+ onCancel={() => setShowUpgradePrompt(false)}+ >+ <div className="space-y-4 py-4">+ <Modal.Content>+ <div className="space-y-4">+ <p className="text-sm">+ Logs can be retained up to a duration of 3 months depending on the plan that your+ project is on. The table below shows an overview of the duration for which your logs+ will be retained for based on each plan.+ </p>+ <div className="border-scale-600 bg-scale-500 rounded border">+ <div className="flex items-center px-4 pt-2 pb-1">+ <p className="text-scale-1100 w-[40%] text-sm">Plan</p>+ <p className="text-scale-1100 w-[60%] text-sm">Retention duration</p>+ </div>+ <div className="py-1">+ <div className="flex items-center px-4 py-1">+ <p className="w-[40%] text-sm">Free</p>+ <p className="w-[60%] text-sm">{TIER_QUERY_LIMITS.FREE.text}</p>+ </div>+ <div className="flex items-center px-4 py-1">+ <p className="w-[40%] text-sm">Pro</p>+ <p className="w-[60%] text-sm">{TIER_QUERY_LIMITS.PRO.text}</p></div>- <div className="py-1">- <div className="flex items-center px-4 py-1">- <p className="w-[40%] text-sm">Free</p>- <p className="w-[60%] text-sm">{TIER_QUERY_LIMITS.FREE.text}</p>- </div>- <div className="flex items-center px-4 py-1">- <p className="w-[40%] text-sm">Pro</p>- <p className="w-[60%] text-sm">{TIER_QUERY_LIMITS.PRO.text}</p>- </div>- <div className="flex items-center px-4 py-1">- <p className="w-[40%] text-sm">Enterprise</p>- <p className="w-[60%] text-sm">{TIER_QUERY_LIMITS.ENTERPRISE.text}</p>- </div>+ <div className="flex items-center px-4 py-1">+ <p className="w-[40%] text-sm">Enterprise</p>+ <p className="w-[60%] text-sm">{TIER_QUERY_LIMITS.ENTERPRISE.text}</p></div></div></div>- </Modal.Content>- <Modal.Seperator />- <Modal.Content>- <div className="flex items-center gap-2">- <Button block type="primary" onClick={() => setShowHelperModal(false)}>- Understood- </Button>- </div>- </Modal.Content>- </div>- </Modal>- </>+ </div>+ </Modal.Content>+ <Modal.Seperator />+ <Modal.Content>+ <div className="flex justify-between">+ <Button type="default" onClick={() => setShowUpgradePrompt(false)}>+ Close+ </Button>++ <Link href={`/project/${ref}/settings/billing`}>+ <Button size="tiny">Upgrade</Button>+ </Link>+ </div>+ </Modal.Content>+ </div>+ </Modal>)}diff --git a/studio/hooks/misc/useUpgradePrompt.tsx b/studio/hooks/misc/useUpgradePrompt.tsxindex 27781aa60a0..d709ff33d28 100644--- a/studio/hooks/misc/useUpgradePrompt.tsx+++ b/studio/hooks/misc/useUpgradePrompt.tsx@@ -1,9 +1,7 @@-import { Button, Modal } from '@supabase/ui'import { useEffect, useState } from 'react'import { useProjectSubscription } from 'hooks'import { useRouter } from 'next/router'-import { maybeShowUpgradePrompt, TIER_QUERY_LIMITS } from 'components/interfaces/Settings/Logs'-import Link from 'next/link'+import { maybeShowUpgradePrompt } from 'components/interfaces/Settings/Logs'import { StripeProduct } from 'components/interfaces/Billing'export const useUpgradePrompt = (from: string) => {@@ -21,59 +19,5 @@ export const useUpgradePrompt = (from: string) => {}}, [from])- const UpgradePrompt = (- <Modal- hideFooter- visible={showUpgradePrompt}- closable- size="medium"- header="Log retention"- onCancel={() => setShowUpgradePrompt(false)}- >- <div className="space-y-4 py-4">- <Modal.Content>- <div className="space-y-4">- <p className="text-sm">- Logs can be retained up to a duration of 3 months depending on the plan that your- project is on. The table below shows an overview of the duration for which your logs- will be retained for based on each plan.- </p>- <div className="border-scale-600 bg-scale-500 rounded border">- <div className="flex items-center px-4 pt-2 pb-1">- <p className="text-scale-1100 w-[40%] text-sm">Plan</p>- <p className="text-scale-1100 w-[60%] text-sm">Retention duration</p>- </div>- <div className="py-1">- <div className="flex items-center px-4 py-1">- <p className="w-[40%] text-sm">Free</p>- <p className="w-[60%] text-sm">{TIER_QUERY_LIMITS.FREE.text}</p>- </div>- <div className="flex items-center px-4 py-1">- <p className="w-[40%] text-sm">Pro</p>- <p className="w-[60%] text-sm">{TIER_QUERY_LIMITS.PRO.text}</p>- </div>- <div className="flex items-center px-4 py-1">- <p className="w-[40%] text-sm">Enterprise</p>- <p className="w-[60%] text-sm">{TIER_QUERY_LIMITS.ENTERPRISE.text}</p>- </div>- </div>- </div>- </div>- </Modal.Content>- <Modal.Seperator />- <Modal.Content>- <div className="flex justify-between">- <Button type="default" onClick={() => setShowUpgradePrompt(false)}>- Close- </Button>-- <Link href={`/project/${ref}/settings/billing`}>- <Button size="tiny">Upgrade</Button>- </Link>- </div>- </Modal.Content>- </div>- </Modal>- )- return { UpgradePrompt, showUpgradePrompt, setShowUpgradePrompt, shouldShowUpgradePrompt }+ return { showUpgradePrompt, setShowUpgradePrompt, shouldShowUpgradePrompt }}