dify/web/features/deployments/shared/domain/runtime-status.ts
Stephen Zhou 48452aefbc
feat: app deploy (#35670)
Co-authored-by: zhangx1n <zhangxin@dify.ai>
Co-authored-by: yyh <yuanyouhuilyz@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-06-17 09:28:43 +00:00

31 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
}