'use client' import type { EnvironmentDeployment, RuntimeInstanceStatus as RuntimeInstanceStatusValue, } from '@dify/contracts/enterprise/types.gen' import type { ComponentPropsWithRef } from 'react' import { cn } from '@langgenius/dify-ui/cn' import { StatusDot } from '@langgenius/dify-ui/status-dot' import { useTranslation } from 'react-i18next' import { isRuntimeDeploymentInProgress } from '../domain/runtime-status' import { deploymentStatusDotStatus, deploymentStatusDotTextClassName, deploymentStatusLabelKey, deploymentStatusToneClassNames, } from './deployment-status-style' type DeploymentStatusBadgeProps = Omit, 'children'> & { status: RuntimeInstanceStatusValue label: string variant?: 'badge' | 'status-dot' } export function DeploymentStatusBadge({ status, label, className, variant = 'badge', ref, ...props }: DeploymentStatusBadgeProps) { const isInProgress = isRuntimeDeploymentInProgress(status) if (variant === 'status-dot') { const dotStatus = deploymentStatusDotStatus(status) return ( {label} ) } const toneClassNames = deploymentStatusToneClassNames(status) const dotStatus = deploymentStatusDotStatus(status) return ( {label} ) } type EnvironmentDeploymentBadgeProps = Omit, 'children' | 'title'> & { row: EnvironmentDeployment showStatus?: boolean summaryLabel?: string } export function EnvironmentDeploymentBadge({ row, className, showStatus = true, summaryLabel, 'aria-label': ariaLabel, ref, ...props }: EnvironmentDeploymentBadgeProps) { const { t } = useTranslation('deployments') const name = row.environment.displayName const status = row.status const toneClassNames = deploymentStatusToneClassNames(status) const dotStatus = deploymentStatusDotStatus(status) const isInProgress = isRuntimeDeploymentInProgress(status) const statusLabel = t(($) => $[deploymentStatusLabelKey(status)]) const label = summaryLabel ?? `${name} · ${statusLabel}` const visibleLabel = showStatus ? `${name} · ${statusLabel}` : name return ( {visibleLabel} ) }