Skip to content

Commit ec89b85

Browse files
committed
fix: show mission control backend version
VersionInfo always queried canary-checker /about, so Mission Control deployments showed the canary-checker backend version. Use the deployment mode to query mission-control /about outside Canary UI and prefer chartVersion over appVersion for the displayed backend version.
1 parent 8340c61 commit ec89b85

2 files changed

Lines changed: 25 additions & 15 deletions

File tree

src/api/services/users.ts

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import { isCanaryUI } from "@flanksource-ui/context/Environment";
12
import { UserFormValue } from "@flanksource-ui/components/Users/UserForm";
23
import {
34
Auth,
45
CanaryChecker,
56
IncidentCommander,
67
People,
7-
Rback
8+
Rback,
9+
apiBase
810
} from "../axios";
911
import { resolvePostGrestRequestWithPagination } from "../resolve";
1012
import { VersionInfo } from "../types/common";
@@ -154,17 +156,27 @@ export const inviteUser = ({
154156
}>("/invite_user", { firstName, lastName, email, role });
155157
};
156158

157-
export const getVersionInfo = () =>
158-
resolvePostGrestRequestWithPagination<VersionInfo>(
159-
CanaryChecker.get("/about").then((data) => {
160-
const versionInfo: any = data.data || {};
161-
data.data = {
162-
...versionInfo,
163-
backend: versionInfo.Version
164-
};
165-
return data;
166-
})
167-
);
159+
export const getVersionInfo = async () => {
160+
let backend: string | undefined;
161+
162+
if (isCanaryUI) {
163+
const { data } = await CanaryChecker.get<{ Version?: string }>("/about");
164+
backend = data.Version;
165+
} else {
166+
const { data } = await apiBase.get<{
167+
appVersion?: string;
168+
chartVersion?: string;
169+
}>("/about");
170+
backend = data.chartVersion || data.appVersion;
171+
}
172+
173+
return {
174+
data: {
175+
backend: backend || "NA"
176+
} satisfies VersionInfo,
177+
error: null
178+
};
179+
};
168180

169181
export const updateUserRole = (userId: string, roles: string[]) => {
170182
return resolvePostGrestRequestWithPagination<{

src/api/types/common.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ export type PaginationInfo = {
44
};
55

66
export type VersionInfo = {
7-
frontend: string;
7+
frontend?: string;
88
backend: string;
9-
Version: string;
10-
Timestamp: string;
119
};
1210

1311
export type CostsData = {

0 commit comments

Comments
 (0)