mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 09:55:06 +03:00
## Problem platform, v1 and v2 have been already completely migrated and introduced some changes. Some types have been renamed, some outputs and inputs updated. ## Solution - Update the API types - Fix the TS errors ## Update Taking this over to unblock #50134, which needs the new scoped token permission ids from the regenerated types. - Merged `master`. - Regenerated `api-v2.d.ts` from the production spec. The previous files came from a local API that exposed a webhook events endpoint production doesn't have yet. Production has since added standardized 400 error responses on the v2 organization endpoints. `api-v1.d.ts` and `platform.d.ts` already matched production. - Fixed `verify-production-types`. It formatted the regenerated files in a temp directory outside the repository, so Prettier fell back to its defaults and the comparison could never match the committed files. It now passes the repository config explicitly. `pnpm api:verify-types` passes on this branch. - Verified locally: `pnpm typecheck`, `pnpm api:verify-types`, Studio unit tests. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Preserved descriptions when saving, sharing, moving, or unsharing notebooks, reports, SQL snippets, and saved queries. * Improved handling of empty or null values across notebook descriptions, billing usage, pooler settings, and infrastructure fields. * Improved read-replica connection handling, including read-only connection strings. * Updated storage configuration and capability handling to match current settings. * **API and Compatibility** * Updated organization, project, storage, OAuth, billing, and infrastructure data handling to match current API responses. * OAuth app creation and updates now require scopes. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
91 lines
2.7 KiB
TypeScript
91 lines
2.7 KiB
TypeScript
import { Eye, Unlock } from 'lucide-react'
|
|
import { useState } from 'react'
|
|
import { toast } from 'sonner'
|
|
import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
|
|
|
|
import { getContentById } from '@/data/content/content-id-query'
|
|
import { useContentUpsertMutation } from '@/data/content/content-upsert-mutation'
|
|
|
|
type ReportSnippet = { id: string; name: string }
|
|
|
|
export const MakeReportSnippetPublicModal = ({
|
|
projectRef,
|
|
snippet,
|
|
onCancel,
|
|
onConfirm,
|
|
}: {
|
|
projectRef?: string
|
|
snippet?: ReportSnippet
|
|
onCancel: () => void
|
|
onConfirm: (snippet: ReportSnippet) => void
|
|
}) => {
|
|
const [isPreparing, setIsPreparing] = useState(false)
|
|
|
|
const { mutate: upsertContent, isPending: isUpserting } = useContentUpsertMutation({
|
|
onError: (error) => {
|
|
toast.error(`Failed to share snippet: ${error.message}`)
|
|
},
|
|
})
|
|
|
|
const onMakePublic = async () => {
|
|
if (!projectRef) return console.error('Project ref is required')
|
|
if (!snippet) return console.error('Snippet is required')
|
|
|
|
setIsPreparing(true)
|
|
try {
|
|
const item = await getContentById({ projectRef, id: snippet.id })
|
|
upsertContent(
|
|
{
|
|
projectRef,
|
|
payload: {
|
|
...item,
|
|
description: item.description ?? undefined,
|
|
visibility: 'project',
|
|
folder_id: null,
|
|
},
|
|
},
|
|
{
|
|
onSuccess: () => {
|
|
toast.success('Snippet is now shared to the project')
|
|
onConfirm(snippet)
|
|
},
|
|
}
|
|
)
|
|
} catch (error: unknown) {
|
|
if (error instanceof Error) {
|
|
toast.error(`Failed to share snippet: ${error.message}`)
|
|
}
|
|
} finally {
|
|
setIsPreparing(false)
|
|
}
|
|
}
|
|
|
|
return (
|
|
<ConfirmationModal
|
|
size="medium"
|
|
loading={isPreparing || isUpserting}
|
|
title={`Share snippet with the team: ${snippet?.name}`}
|
|
confirmLabel="Share and add to report"
|
|
confirmLabelLoading="Sharing snippet"
|
|
visible={snippet !== undefined}
|
|
onCancel={onCancel}
|
|
onConfirm={onMakePublic}
|
|
alert={{
|
|
title: 'This snippet will become visible to all project members',
|
|
description: 'Snippets added to the report must be shared so the team can view them',
|
|
}}
|
|
>
|
|
<ul className="text-sm text-foreground-light space-y-5">
|
|
<li className="flex gap-3 items-center">
|
|
<Eye size={16} />
|
|
<span>Project members will have read-only access to this snippet.</span>
|
|
</li>
|
|
<li className="flex gap-3 items-center">
|
|
<Unlock size={16} />
|
|
<span>Project members can duplicate it to their personal snippets.</span>
|
|
</li>
|
|
</ul>
|
|
</ConfirmationModal>
|
|
)
|
|
}
|