mirror of
https://github.com/supabase/supabase.git
synced 2026-10-18 15:49:09 +03:00
* init * moar * moat * moar * add read replica bar * moar * Update DiskMangementPanelForm.tsx * added temp state mang to test * moar * Prepare react queries + data from API for disk mgt * moat * moat * moar * Update DiskMangementReviewAndSubmitDialog.tsx * badge updates * Hook up actual endpoints for E2E testing, but commented out for now for local dev * Hook up real data + clean up files and add tests * Update APi types * Hook up E2E and fix all validation logic * Only show new disk mgt UI for orb billing * Add note on RRs 25% more disk size * Add state to handle free plan for disk mgt * Update increase disk size CTA in reports/database * Fix file spelling errors * Address feedback * Fix missing framer motion package in ui * Address comments * Address feedabck * Minor fix * Use new disk util endpoint * Remove unused import * Address feedback * More addressing of feedback * Update pricing details for IO2 - no included disk size --------- Co-authored-by: Jonathan Summers-Muir <MildTomato@users.noreply.github.com>
95 lines
3.1 KiB
TypeScript
95 lines
3.1 KiB
TypeScript
import { AnimatePresence, motion } from 'framer-motion'
|
|
import { X } from 'lucide-react'
|
|
import React, { useEffect, useState } from 'react'
|
|
|
|
import { DialogSection } from 'ui'
|
|
import CountdownTimerRadial from '../../ui/CountdownTimer/CountdownTimerRadial'
|
|
|
|
export const DiskMangementCoolDownSection: React.FC = () => {
|
|
const [progress, setProgress] = useState(100)
|
|
const [showCountdown, setShowCountdown] = useState(false)
|
|
const [isJumping, setIsJumping] = useState(false)
|
|
const [isVisible, setIsVisible] = useState(true)
|
|
|
|
useEffect(() => {
|
|
const startCountdown = () => {
|
|
setShowCountdown(true)
|
|
setProgress(100)
|
|
const interval = setInterval(() => {
|
|
setProgress((prevProgress) => {
|
|
if (prevProgress <= 0) {
|
|
clearInterval(interval)
|
|
setIsJumping(true)
|
|
setTimeout(() => {
|
|
setIsJumping(false)
|
|
setProgress(100)
|
|
startCountdown() // Restart the countdown
|
|
}, 300) // Duration of the jump animation
|
|
return 0
|
|
}
|
|
return prevProgress - 1
|
|
})
|
|
}, 100)
|
|
|
|
return () => clearInterval(interval)
|
|
}
|
|
|
|
const initialDelay = setTimeout(startCountdown, 1000)
|
|
|
|
return () => clearTimeout(initialDelay)
|
|
}, [])
|
|
|
|
return (
|
|
<AnimatePresence>
|
|
{isVisible && (
|
|
<motion.div
|
|
initial={{ opacity: 1, height: 'auto' }}
|
|
exit={{ opacity: 0, height: 0 }}
|
|
transition={{ duration: 0.15 }}
|
|
>
|
|
<DialogSection className="bg-surface-100 text-sm text-foreground-light flex items-center gap-4 relative">
|
|
<div className="w-12 h-12 opacity-75">
|
|
<AnimatePresence>
|
|
{showCountdown && (
|
|
<motion.div
|
|
key="countdown-timer"
|
|
initial={{ scale: 0.8, opacity: 0, y: -8 }}
|
|
animate={{
|
|
scale: isJumping ? 1.2 : 1,
|
|
opacity: 1,
|
|
y: isJumping ? -8 : 0,
|
|
}}
|
|
exit={{ scale: 0.8, opacity: 0, y: -8 }}
|
|
transition={{
|
|
duration: isJumping ? 0.3 : 0.8,
|
|
type: 'spring',
|
|
bounce: 0.6,
|
|
}}
|
|
>
|
|
<CountdownTimerRadial progress={progress} />
|
|
</motion.div>
|
|
)}
|
|
</AnimatePresence>
|
|
</div>
|
|
<div className="flex flex-col gap-0 flex-grow">
|
|
<p className="text-sm text-foreground">
|
|
For 6 hours you will not be able to make further changes.
|
|
</p>
|
|
<p className="text-sm text-foreground-light">
|
|
Due to a cooldown period between disk changes.
|
|
</p>
|
|
</div>
|
|
<button
|
|
type="button"
|
|
className="text-foreground-lighter hover:text-foreground-light transition-colors self-start p-1"
|
|
onClick={() => setIsVisible(false)}
|
|
>
|
|
<X size={14} />
|
|
</button>
|
|
</DialogSection>
|
|
</motion.div>
|
|
)}
|
|
</AnimatePresence>
|
|
)
|
|
}
|