Files
supabase/apps/studio/components/interfaces/ProjectHome/MakeReportSnippetPublicModal.tsx
Joshen Lim 09a1f431bc Mass update for all lucide icon imports to use the component with Icon suffix (#51659)
## Context

This is largely just a mechanical change here:
Opting to use lucide icons with the `Icon` suffix across all icon
imports within `studio`
- so that it’s clearer which components are icons + reduces the
possibility of name collision with our own components
- e.g <User /> vs <UserIcon />

Also added a eslint rule for this:
<img width="1069" height="167" alt="image"
src="https://github.com/user-attachments/assets/7f36f443-5ca2-4bf6-8d22-86e774513bfc"
/>

And updated `AGENTS.md` as such:
```
Icons come from `lucide-react`, always imported with the `Icon` suffix (`import { CheckIcon, Trash2Icon } from 'lucide-react'`) — never the bare names (`Check`) or `Check as CheckIcon` aliases (lint-enforced).
```
2026-10-14 12:56:55 +02:00

91 lines
2.7 KiB
TypeScript

import { EyeIcon, UnlockIcon } 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">
<EyeIcon size={16} />
<span>Project members will have read-only access to this snippet.</span>
</li>
<li className="flex gap-3 items-center">
<UnlockIcon size={16} />
<span>Project members can duplicate it to their personal snippets.</span>
</li>
</ul>
</ConfirmationModal>
)
}