mirror of
https://github.com/langgenius/dify.git
synced 2026-09-07 01:43:41 +08:00
62 lines
1.9 KiB
TypeScript
62 lines
1.9 KiB
TypeScript
'use client'
|
|
|
|
import { skipToken } from '@tanstack/react-query'
|
|
import { atom } from 'jotai'
|
|
import { atomWithQuery } from 'jotai-tanstack-query'
|
|
import { consoleQuery } from '@/service/client'
|
|
import { deploymentRouteAppInstanceIdAtom } from '../route-state'
|
|
import { deploymentStatusPollingInterval } from '../shared/domain/runtime-status'
|
|
|
|
export const deploymentSourceAppIdAtom = atom<string | undefined>(undefined)
|
|
|
|
export const deploymentDetailAppInstanceQueryAtom = atomWithQuery((get) => {
|
|
const appInstanceId = get(deploymentRouteAppInstanceIdAtom)
|
|
|
|
return consoleQuery.enterprise.appInstanceService.getAppInstance.queryOptions({
|
|
input: appInstanceId
|
|
? {
|
|
params: { appInstanceId },
|
|
}
|
|
: skipToken,
|
|
enabled: Boolean(appInstanceId),
|
|
})
|
|
})
|
|
|
|
export const deploymentDetailOverviewQueryAtom = atomWithQuery((get) => {
|
|
const appInstanceId = get(deploymentRouteAppInstanceIdAtom)
|
|
|
|
return consoleQuery.enterprise.appInstanceService.getAppInstanceOverview.queryOptions({
|
|
input: appInstanceId
|
|
? {
|
|
params: { appInstanceId },
|
|
}
|
|
: skipToken,
|
|
enabled: Boolean(appInstanceId),
|
|
})
|
|
})
|
|
|
|
export const deploymentEnvironmentDeploymentsQueryAtom = atomWithQuery((get) => {
|
|
const appInstanceId = get(deploymentRouteAppInstanceIdAtom)
|
|
|
|
return consoleQuery.enterprise.deploymentService.listEnvironmentDeployments.queryOptions({
|
|
input: appInstanceId
|
|
? {
|
|
params: { appInstanceId },
|
|
}
|
|
: skipToken,
|
|
enabled: Boolean(appInstanceId),
|
|
refetchInterval: query => deploymentStatusPollingInterval(query.state.data?.environmentDeployments),
|
|
})
|
|
})
|
|
|
|
export const deploymentSourceAppQueryAtom = atomWithQuery((get) => {
|
|
const sourceAppId = get(deploymentSourceAppIdAtom)
|
|
|
|
return consoleQuery.apps.byAppId.get.queryOptions({
|
|
input: sourceAppId
|
|
? { params: { app_id: sourceAppId } }
|
|
: skipToken,
|
|
enabled: Boolean(sourceAppId),
|
|
})
|
|
})
|