Skip to content

Commit

Permalink
Use /url endpoint to get proper URL to UI (#53)
Browse files Browse the repository at this point in the history
Signed-off-by: Ondra Machacek <[email protected]>
  • Loading branch information
machacekondra authored Dec 13, 2024
1 parent 58564bd commit 07596d5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 3 additions & 3 deletions apps/agent/src/login-form/hooks/UseViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@ export const useViewModel = (): LoginFormViewModelInterface => {
},
[agentApi, navigateTo]
),
handleReturnToAssistedMigration: useCallback(() => {
const assistedMigrationUrl = import.meta.env.ASSISTED_MIGRATION_URL || 'http://localhost:3000/migrate/wizard';
window.open(assistedMigrationUrl, '_blank', 'noopener,noreferrer');
handleReturnToAssistedMigration: useCallback(async () => {
const serviceUrl = await agentApi.getServiceUiUrl() || "http://localhost:3000/migrate/wizard";
window.open(serviceUrl, '_blank', 'noopener,noreferrer');
}, []),
handleChangeDataSharingAllowed: useCallback((checked)=>{
console.log(checked);
Expand Down
10 changes: 10 additions & 0 deletions packages/agent-client/src/apis/AgentApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface AgentApiInterface {
): Promise<Either<number, CredentialsError>>;
getStatus(options?: RequestInit): Promise<StatusReply>;
getAgentVersion():Promise<string>;
getServiceUiUrl():Promise<string>;
}

export class AgentApi implements AgentApiInterface {
Expand Down Expand Up @@ -70,4 +71,13 @@ export class AgentApi implements AgentApiInterface {
const statusReply = (await response.json()) as { version: string };
return statusReply.version;
}
async getServiceUiUrl(): Promise<string> {
const request = new Request(this.configuration.basePath + "/url", {
method: "GET"
});

const response = await fetch(request);
const uiReply = (await response.json()) as { url: string };
return uiReply.url;
}
}

0 comments on commit 07596d5

Please sign in to comment.