Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

2.2 KB
Raw Blame
import { useActions, useValues } from 'kea'

import { IconGlobe } from '@posthog/icons'
import {
    AlertDialog,
    AlertDialogContent,
    AlertDialogDescription,
    AlertDialogFooter,
    AlertDialogHeader,
    AlertDialogTitle,
    Button,
} from '@posthog/quill'

import { teamLogic } from 'scenes/teamLogic'

import { canvasSceneLogic } from './canvasSceneLogic'

export function CanvasMakePublicDialog(): JSX.Element {
    const { canvas, visibilityChanging } = useValues(canvasSceneLogic)
    const { closeMakePublic, setCanvasVisibility } = useActions(canvasSceneLogic)
    const { currentTeam } = useValues(teamLogic)
    const project = currentTeam?.name ? `Everyone in ${currentTeam.name}` : 'Everyone in this project'
    const name = canvas?.name ? `“${canvas.name}”` : 'this canvas'

    return (
        <AlertDialog
            open
            onOpenChange={(open: boolean) => {
                if (!open && !visibilityChanging) {
                    closeMakePublic()
                }
            }}
        >
            <AlertDialogContent>
                <AlertDialogHeader>
                    <AlertDialogTitle>Make this canvas public?</AlertDialogTitle>
                    <AlertDialogDescription>
                        {`${project} will be able to open and edit ${name}. Only you can rename it or make it private again.`}
                    </AlertDialogDescription>
                </AlertDialogHeader>
                <AlertDialogFooter>
                    <Button
                        variant="outline"
                        onClick={() => closeMakePublic()}
                        disabled={visibilityChanging}
                        data-attr="canvas-make-public-cancel"
                    >
                        Cancel
                    </Button>
                    <Button
                        variant="primary"
                        loading={visibilityChanging}
                        onClick={() => setCanvasVisibility('public')}
                        data-attr="canvas-make-public-confirm"
                    >
                        <IconGlobe />
                        Make public
                    </Button>
                </AlertDialogFooter>
            </AlertDialogContent>
        </AlertDialog>
    )
}