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.3 KB
Raw Blame
import { IconPlus } from '@posthog/icons'
import { Button, ButtonGroup } from '@posthog/quill'

import { FeedbackSurveyButton } from 'lib/components/FeedbackSurveyButton/FeedbackSurveyButton'
import { Shortcut } from 'lib/components/Shortcuts/Shortcut'
import { keyBinds } from 'lib/components/Shortcuts/shortcuts'
import { LinkPrimitive } from 'lib/lemon-ui/Link'
import { getAccessControlDisabledReason } from 'lib/utils/accessControlUtils'
import { Scene } from 'scenes/sceneTypes'

import { AccessControlLevel, AccessControlResourceType } from '~/types'

import { QuillNewFeatureFlagMenu } from './QuillNewFeatureFlagMenu'

export interface QuillFeatureFlagsActionsProps {
    feedbackSurveyId: string
    showRulesV2Editor: boolean
    rulesV2DisabledReason: string | null | undefined
    newFeatureFlagUrl: string
}

export function QuillFeatureFlagsActions({
    feedbackSurveyId,
    showRulesV2Editor,
    rulesV2DisabledReason,
    newFeatureFlagUrl,
}: QuillFeatureFlagsActionsProps): JSX.Element {
    const createDisabledReason = getAccessControlDisabledReason(
        AccessControlResourceType.FeatureFlag,
        AccessControlLevel.Editor
    )

    return (
        <>
            <FeedbackSurveyButton surveyId={feedbackSurveyId} data-attr="feature-flags-feedback-button" />
            <ButtonGroup>
                <Shortcut
                    name="NewFeatureFlag"
                    keybind={[keyBinds.new]}
                    intent="New feature flag"
                    interaction="click"
                    scope={Scene.FeatureFlags}
                    disabledReason={createDisabledReason}
                >
                    <Button
                        variant="primary"
                        render={<LinkPrimitive to={newFeatureFlagUrl} />}
                        disabledReason={createDisabledReason}
                        tooltip="New feature flag"
                        data-attr="new-feature-flag"
                    >
                        <IconPlus />
                        New
                    </Button>
                </Shortcut>
                <QuillNewFeatureFlagMenu
                    disabledReason={createDisabledReason}
                    showRulesV2Editor={showRulesV2Editor}
                    rulesV2DisabledReason={rulesV2DisabledReason}
                />
            </ButtonGroup>
        </>
    )
}