mirror of
https://github.com/supabase/supabase.git
synced 2026-10-08 10:55:06 +03:00
Update all changes saved message on table editor to be consistent with sql editor
This commit is contained in:
1 parent
72f8b34880
commit
1fa0b5ba83
2 files changed
+50
-12
No files matched your search
@@ -1,26 +1,27 @@
|
||||
import * as React from 'react'
|
||||
import { useState, FC, useEffect } from 'react'
|
||||
import * as Tooltip from '@radix-ui/react-tooltip'
|
||||
import { IconLoader, IconCheck } from '@supabase/ui'
|
||||
import { SupabaseGridQueue } from '../../constants'
|
||||
import { Typography } from '@supabase/ui'
|
||||
|
||||
type StatusLabelProps = {}
|
||||
interface Props {}
|
||||
|
||||
const StatusLabel: React.FC<StatusLabelProps> = ({}) => {
|
||||
const [msg, setMsg] = React.useState<string | undefined>(undefined)
|
||||
const StatusLabel: FC<Props> = ({}) => {
|
||||
const [status, setStatus] = useState<string>()
|
||||
|
||||
React.useEffect(() => {
|
||||
useEffect(() => {
|
||||
let isMounted = true
|
||||
let timer: number | null
|
||||
|
||||
SupabaseGridQueue.on('active', () => {
|
||||
if (timer) clearTimeout(timer)
|
||||
|
||||
if (isMounted) setMsg('Saving...')
|
||||
if (isMounted) setStatus('saving')
|
||||
})
|
||||
SupabaseGridQueue.on('idle', () => {
|
||||
if (timer) clearTimeout(timer)
|
||||
timer = window.setTimeout(() => setMsg(undefined), 2000)
|
||||
timer = window.setTimeout(() => setStatus(undefined), 4000)
|
||||
|
||||
if (isMounted) setMsg('All changes saved')
|
||||
if (isMounted) setStatus('saved')
|
||||
})
|
||||
|
||||
return () => {
|
||||
@@ -31,8 +32,45 @@ const StatusLabel: React.FC<StatusLabelProps> = ({}) => {
|
||||
|
||||
return (
|
||||
<div className="sb-grid-status-label">
|
||||
{msg && <Typography.Text>{msg}</Typography.Text>}
|
||||
{!msg && (
|
||||
{status === 'saving' ? (
|
||||
<Tooltip.Root delayDuration={0}>
|
||||
<Tooltip.Trigger>
|
||||
<IconLoader className="animate-spin mx-1" size={14} strokeWidth={2} />
|
||||
</Tooltip.Trigger>
|
||||
<Tooltip.Content side="left">
|
||||
<Tooltip.Arrow className="radix-tooltip-arrow" />
|
||||
<div
|
||||
className={[
|
||||
'bg-scale-100 rounded py-1 px-2 leading-none shadow',
|
||||
'border-scale-200 border',
|
||||
].join(' ')}
|
||||
>
|
||||
<span className="text-scale-1200 text-xs">Saving changes...</span>
|
||||
</div>
|
||||
</Tooltip.Content>
|
||||
</Tooltip.Root>
|
||||
) : status === 'saved' ? (
|
||||
<Tooltip.Root delayDuration={0}>
|
||||
<Tooltip.Trigger>
|
||||
<IconCheck className="text-brand-900 mx-1" size={14} strokeWidth={3} />
|
||||
</Tooltip.Trigger>
|
||||
<Tooltip.Content side="left">
|
||||
<Tooltip.Arrow className="radix-tooltip-arrow" />
|
||||
<div
|
||||
className={[
|
||||
'bg-scale-100 rounded py-1 px-2 leading-none shadow',
|
||||
'border-scale-200 border ',
|
||||
].join(' ')}
|
||||
>
|
||||
<span className="text-scale-1200 text-xs">All changes saved</span>
|
||||
</div>
|
||||
</Tooltip.Content>
|
||||
</Tooltip.Root>
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
|
||||
{!status && (
|
||||
<div className="sb-grid-status-label__no-msg">
|
||||
<div></div>
|
||||
</div>
|
||||
|
||||
@@ -339,7 +339,7 @@ const SavingIndicator = observer(({ updateSqlSnippet }) => {
|
||||
{showSavedText && (
|
||||
<Tooltip.Root delayDuration={0}>
|
||||
<Tooltip.Trigger>
|
||||
<IconCheck className="text-brand-800" size={14} strokeWidth={3} />
|
||||
<IconCheck className="text-brand-900" size={14} strokeWidth={3} />
|
||||
</Tooltip.Trigger>
|
||||
<Tooltip.Content side="bottom">
|
||||
<Tooltip.Arrow className="radix-tooltip-arrow" />
|
||||
|
||||
Reference in new issue
Block a user