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.6 KB
Raw Blame
import { LemonButton } from '@posthog/lemon-ui'

import { More } from 'lib/lemon-ui/LemonButton/More'
import { changeRequestDialogHandlers } from 'scenes/approvals/ChangeRequestActions'
import { getChangeRequestButtonVisibility } from 'scenes/approvals/changeRequestsLogic'
import { urls } from 'scenes/urls'

import { ChangeRequest } from '~/types'

export interface ChangeRequestTableActionsProps {
    changeRequest: ChangeRequest
    onApprove: (id: string) => void
    onReject: (id: string, reason: string) => void
}

export function ChangeRequestTableActions({
    changeRequest,
    onApprove,
    onReject,
}: ChangeRequestTableActionsProps): JSX.Element {
    const { showApproveButton, showRejectButton } = getChangeRequestButtonVisibility(changeRequest)
    const { handleApprove, handleReject } = changeRequestDialogHandlers({ changeRequest, onApprove, onReject })

    return (
        <More
            overlay={
                <>
                    <LemonButton fullWidth to={urls.approval(changeRequest.id)}>
                        View details
                    </LemonButton>
                    {showApproveButton && (
                        <LemonButton fullWidth type="primary" onClick={handleApprove}>
                            Approve
                        </LemonButton>
                    )}
                    {showRejectButton && (
                        <LemonButton fullWidth status="danger" onClick={handleReject}>
                            Reject
                        </LemonButton>
                    )}
                </>
            }
        />
    )
}