mirror of
https://github.com/supabase/supabase.git
synced 2026-09-06 09:59:03 +08:00
## Summary - Regenerates `packages/api-types` for the content endpoints now that the Platform API's `notebook` content type has landed (list/get/upsert `type` enums, plus `UpsertContentBody`'s notebook cell shape with `_id`/`y_series`). Unrelated schema drift from the same regen (Warehouse, SSO, notification exceptions, etc.) is excluded — only the content-endpoint hunks are applied. - Removes every local widening cast added while the API support was pending (`content-query.ts`, `content-infinite-query.ts`, `notebook-query.ts`, `notebook-upsert-mutation.ts`, `sql-folders-query.ts`). - What remains is scoped and renamed to match: draft ids (`generateDraftId`/`isDraftId`), used only for cells created client-side in the editor before their first save, dropped before they'd ever reach the backend as a fake `_id`. ## Test plan - [x] `pnpm typecheck` — clean - [x] `pnpm --filter studio test` — full suite passes (518 files / 5471 tests) - [x] `pnpm --filter studio run lint:ratchet` — no new warnings - [x] `pnpm format` / prettier — clean <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved notebook cell tracking during editing, reordering, insertion, and deletion. * Preserved existing cell identifiers while removing temporary draft identifiers before saving. * Improved chart configuration for selecting and displaying multiple Y-axis series. * Strengthened notebook validation and content persistence behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
58 lines
1.8 KiB
TypeScript
58 lines
1.8 KiB
TypeScript
import { ArrowDown, ArrowUp, Trash } from 'lucide-react'
|
|
import { DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator } from 'ui'
|
|
|
|
import { useCurrentNotebook, useNotebooksStateSnapshot } from '@/state/notebooks/notebooks-state'
|
|
|
|
interface MoveCellDropdownContentProps {
|
|
cellId: string
|
|
}
|
|
|
|
export const MoveCellDropdownContent = ({ cellId }: MoveCellDropdownContentProps) => {
|
|
const snap = useNotebooksStateSnapshot()
|
|
const currentNotebook = useCurrentNotebook()
|
|
|
|
const cells = currentNotebook?.notebook.content?.cells ?? []
|
|
const currentIndex = cells.findIndex((c) => c._id === cellId)
|
|
const isFirstCell = currentIndex <= 0
|
|
const isLastCell = currentIndex === -1 || currentIndex === cells.length - 1
|
|
|
|
const onSelectMoveCell = (direction: 'up' | 'down') => {
|
|
const notebookId = currentNotebook?.notebook.id
|
|
if (!notebookId) return
|
|
|
|
snap.moveCell({ id: notebookId, cellId, direction })
|
|
}
|
|
|
|
const onSelectRemoveCell = () => {
|
|
const notebookId = currentNotebook?.notebook.id
|
|
if (!notebookId) return
|
|
snap.removeCell({ id: notebookId, cellId })
|
|
}
|
|
|
|
return (
|
|
<DropdownMenuContent align="start" className="w-40">
|
|
<DropdownMenuItem
|
|
className="gap-x-2"
|
|
disabled={isFirstCell}
|
|
onClick={() => onSelectMoveCell('up')}
|
|
>
|
|
<ArrowUp size={14} />
|
|
<p>Move up</p>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuItem
|
|
className="gap-x-2"
|
|
disabled={isLastCell}
|
|
onClick={() => onSelectMoveCell('down')}
|
|
>
|
|
<ArrowDown size={14} />
|
|
<p>Move down</p>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuSeparator />
|
|
<DropdownMenuItem className="gap-x-2" onClick={() => onSelectRemoveCell()}>
|
|
<Trash size={14} />
|
|
<p>Remove cell</p>
|
|
</DropdownMenuItem>
|
|
</DropdownMenuContent>
|
|
)
|
|
}
|