dify/web/features/deployments/shared/domain/runtime-status.ts
Stephen Zhou a84c2d36a3
style: format with vp fmt (#38803)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-07-12 15:57:46 +00:00

40 lines
1.3 KiB
TypeScript

import type {
EnvironmentDeployment,
RuntimeInstanceStatus as RuntimeInstanceStatusValue,
} from '@dify/contracts/enterprise/types.gen'
import { RuntimeInstanceStatus } from '@dify/contracts/enterprise/types.gen'
const DEPLOYMENT_STATUS_POLLING_INTERVAL = 3000
export function isUndeployedDeploymentRow(row: EnvironmentDeployment) {
const status = row.status
return (
status === RuntimeInstanceStatus.RUNTIME_INSTANCE_STATUS_UNDEPLOYED ||
(status === RuntimeInstanceStatus.RUNTIME_INSTANCE_STATUS_UNSPECIFIED &&
!row.currentRelease &&
!row.desiredRelease &&
!row.currentDeployment)
)
}
export function hasRuntimeInstanceDeployment(row: EnvironmentDeployment) {
return !isUndeployedDeploymentRow(row)
}
export function isAvailableDeploymentTarget(row: EnvironmentDeployment) {
return isUndeployedDeploymentRow(row)
}
export function isRuntimeDeploymentInProgress(status?: RuntimeInstanceStatusValue) {
return (
status === RuntimeInstanceStatus.RUNTIME_INSTANCE_STATUS_DEPLOYING ||
status === RuntimeInstanceStatus.RUNTIME_INSTANCE_STATUS_UNDEPLOYING
)
}
export function deploymentStatusPollingInterval(rows?: EnvironmentDeployment[]) {
return rows?.some((row) => isRuntimeDeploymentInProgress(row.status))
? DEPLOYMENT_STATUS_POLLING_INTERVAL
: false
}