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.

1.1 KB
Raw Blame
import { useState } from 'react'

import { LemonButton, LemonInput, LemonModal } from '@posthog/lemon-ui'

export function BIFieldNameModal({
    name,
    onSave,
    onClose,
}: {
    name: string
    onSave: (name: string) => void
    onClose: () => void
}): JSX.Element {
    const [draft, setDraft] = useState(name)
    return (
        <LemonModal
            title="Rename field"
            isOpen
            onClose={onClose}
            footer={
                <LemonButton
                    type="primary"
                    disabledReason={!draft.trim() ? 'Enter a name' : undefined}
                    onClick={() => {
                        onSave(draft.trim())
                        onClose()
                    }}
                >
                    Save name
                </LemonButton>
            }
        >
            <LemonInput aria-label="Field name" value={draft} onChange={setDraft} autoFocus />
            <p className="mt-2 mb-0 text-secondary">
                This name applies to this field in this worksheet. The source field stays the same.
            </p>
        </LemonModal>
    )
}