Skip to content

Commit

Permalink
Add agent version to Agent UI (#52)
Browse files Browse the repository at this point in the history
Signed-off-by: Montse Ortega <[email protected]>
  • Loading branch information
ammont82 authored Dec 10, 2024
1 parent 61f7a74 commit b9c87e1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions apps/agent/src/common/AgentUIVersion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import React, { useState, useEffect } from 'react';
import type { AgentApiInterface } from "@migration-planner-ui/agent-client/apis";
import { useInjection } from '@migration-planner-ui/ioc';
import { Symbols } from '#/main/Symbols';
import { StatusReply } from '@migration-planner-ui/agent-client/models';

export const AgentUIVersion: React.FC = () => {
const agentApi = useInjection<AgentApiInterface>(Symbols.AgentApi);
const [versionInfo, setVersionInfo] = useState<StatusReply | null>(null);
const [versionInfo, setVersionInfo] = useState<string | null>(null);
const [error, setError] = useState<string | null>(null);

useEffect(() => {
Expand All @@ -33,7 +32,7 @@ export const AgentUIVersion: React.FC = () => {

return (
<div data-testid="agent-api-lib-version" hidden>
{versionInfo.statusInfo}
{versionInfo}
</div>
);
};
8 changes: 4 additions & 4 deletions packages/agent-client/src/apis/AgentApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface AgentApiInterface {
options?: RequestInit & { pathParams?: string[] }
): Promise<Either<number, CredentialsError>>;
getStatus(options?: RequestInit): Promise<StatusReply>;
getAgentVersion():Promise<StatusReply>;
getAgentVersion():Promise<string>;
}

export class AgentApi implements AgentApiInterface {
Expand Down Expand Up @@ -61,13 +61,13 @@ export class AgentApi implements AgentApiInterface {
}
}

async getAgentVersion(): Promise<StatusReply> {
async getAgentVersion(): Promise<string> {
const request = new Request(this.configuration.basePath + "/version", {
method: "GET"
});

const response = await fetch(request);
const statusReply = (await response.json()) as StatusReply;
return statusReply;
const statusReply = (await response.json()) as { version: string };
return statusReply.version;
}
}

0 comments on commit b9c87e1

Please sign in to comment.