mirror of
https://github.com/supabase/supabase.git
synced 2026-10-13 05:09:12 +03:00
* First * Fix the parsing of SQL. * Get thread data action * Remove old page * Wait for data to complete * SSR everywhere * Remove unused * Add monaco settings * update loaders * Add sorting * supress hydration warnings * Fix profile layout * more server action action * fixes * Update page.tsx * Update actions.ts * Update AssistantChatForm.tsx * init * add polling * Update actions.ts * redirect to message id * Update page.tsx * Update page.tsx * handle run loading states with use client state with valtio * reduce first load JS * test action v1 * test action v2 * server action test 3 * test action 4 * test action 5 * test 6 * test 7 * test 7 * test 8 * test 9 * test 10 * test 11 * TEST 12 * TEST 13 * try and make it work * Update page.tsx * Update actions.ts * redirect added in * Update page.tsx * Update SchemaFlow.tsx * Update SchemaFlowHandler.tsx * 14 * Update SchemaFlow.tsx * move parse tables to client * a11y fixes --------- Co-authored-by: Terry Sutton <saltcod@gmail.com> Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
75 lines
2.1 KiB
TypeScript
75 lines
2.1 KiB
TypeScript
'use client'
|
|
|
|
import { getAppStateSnapshot, useAppStateSnapshot } from '@/lib/state'
|
|
import Image from 'next/image'
|
|
import {
|
|
Button,
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuTrigger,
|
|
IconChevronDown,
|
|
IconClipboard,
|
|
IconDownload,
|
|
} from 'ui'
|
|
|
|
const SaveSchemaDropdown = () => {
|
|
const snap = useAppStateSnapshot()
|
|
|
|
const copyToClipboard = () => {
|
|
const snap = getAppStateSnapshot()
|
|
const focused = window.document.hasFocus()
|
|
if (focused) {
|
|
window.navigator?.clipboard?.writeText(snap.selectedCode)
|
|
} else {
|
|
console.warn('Unable to copy to clipboard')
|
|
}
|
|
}
|
|
|
|
const downloadSQL = () => {
|
|
const snap = getAppStateSnapshot()
|
|
const blob = new Blob([snap.selectedCode], { type: 'text/plain' })
|
|
const url = URL.createObjectURL(blob)
|
|
const link = document.createElement('a')
|
|
link.download = 'migration.sql'
|
|
link.href = url
|
|
link.click()
|
|
}
|
|
|
|
const loadSQLInSupabase = () => {
|
|
const snap = getAppStateSnapshot()
|
|
window.open(
|
|
`https://supabase.com/dashboard/project/_/sql?content=${encodeURIComponent(
|
|
snap.selectedCode
|
|
)}`,
|
|
'_blank'
|
|
)
|
|
}
|
|
|
|
return (
|
|
<DropdownMenu modal={false}>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button type="default" iconRight={<IconChevronDown />}>
|
|
Save schema
|
|
</Button>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent className="w-44" align="end">
|
|
<DropdownMenuItem className="space-x-2" onClick={() => copyToClipboard()}>
|
|
<IconClipboard size={14} strokeWidth={1.5} className="text-lighter" />
|
|
<p>Copy SQL</p>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuItem className="space-x-2" onClick={() => downloadSQL()}>
|
|
<IconDownload size={14} strokeWidth={1.5} className="text-lighter" />
|
|
<p>Download SQL</p>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuItem className="space-x-2" onClick={() => loadSQLInSupabase()}>
|
|
<Image alt="supabase" src="/supabase.png" width={14} height={14} />
|
|
<p>Load SQL in Supabase</p>
|
|
</DropdownMenuItem>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
)
|
|
}
|
|
|
|
export default SaveSchemaDropdown
|