diff --git a/app/react/portainer/HomeView/EnvironmentList/EnvironmentItem/AgentDetails.tsx b/app/react/portainer/HomeView/EnvironmentList/EnvironmentItem/AgentDetails.tsx index a292dfeb2..68af4b81e 100644 --- a/app/react/portainer/HomeView/EnvironmentList/EnvironmentItem/AgentDetails.tsx +++ b/app/react/portainer/HomeView/EnvironmentList/EnvironmentItem/AgentDetails.tsx @@ -1,10 +1,52 @@ +import { AlertTriangle } from 'lucide-react'; + import { Environment } from '@/react/portainer/environments/types'; -import { isAgentEnvironment } from '@/react/portainer/environments/utils'; +import { + isAgentEnvironment, + isEdgeEnvironment, +} from '@/react/portainer/environments/utils'; +import { isVersionSmaller } from '@/react/common/semver-utils'; +import { useSystemStatus } from '@/react/portainer/system/useSystemStatus'; + +import { Tooltip } from '@@/Tip/Tooltip'; +import { Icon } from '@@/Icon'; export function AgentDetails({ environment }: { environment: Environment }) { if (!isAgentEnvironment(environment.Type)) { return null; } + if (isEdgeEnvironment(environment.Type)) { + return ; + } + return {environment.Agent.Version}; } + +function EdgeAgentDetails({ environment }: { environment: Environment }) { + const { data: systemStatus } = useSystemStatus(); + const associated = !!environment.EdgeID; + + if (!systemStatus || !associated) { + return null; + } + + const agentVersion = environment.Agent.Version; + + const { Version } = systemStatus; + const isSmaller = + !agentVersion || // agents before 2.15 don't send the version so it will be empty + isVersionSmaller(agentVersion, Version); + + if (!isSmaller) { + return {agentVersion}; + } + + return ( + + + {agentVersion || '< 2.15'} + + + ); +}