ReadOnlyBadge.tsx17 lines · main
| 1 | import { Badge } from 'ui' |
| 2 | |
| 3 | import { useProfile } from '@/lib/profile' |
| 4 | import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor-v2' |
| 5 | |
| 6 | export type ReadOnlyBadgeProps = { id: string } |
| 7 | const ReadOnlyBadge = ({ id }: ReadOnlyBadgeProps) => { |
| 8 | const { profile } = useProfile() |
| 9 | const snapV2 = useSqlEditorV2StateSnapshot() |
| 10 | |
| 11 | const snippet = snapV2.snippets[id] |
| 12 | const isSnippetOwner = profile?.id === snippet?.snippet.owner_id |
| 13 | |
| 14 | return <>{isSnippetOwner ? null : <Badge>Read-only</Badge>}</> |
| 15 | } |
| 16 | |
| 17 | export default ReadOnlyBadge |