1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-09 07:45:22 +02:00

feat(system/upgrade): add upgrade banner [EE-4564] (#8046)

This commit is contained in:
Chaim Lev-Ari 2022-11-16 18:38:39 +02:00 committed by GitHub
parent c21921a08d
commit eccc8131dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 366 additions and 33 deletions

View file

@ -4,15 +4,20 @@ import { usePublicSettings } from '@/react/portainer/settings/queries';
export enum FeatureFlag {
EdgeRemoteUpdate = 'edgeRemoteUpdate',
BEUpgrade = 'beUpgrade',
}
export function useFeatureFlag(
flag: FeatureFlag,
{ onSuccess }: { onSuccess?: (isEnabled: boolean) => void } = {}
{
onSuccess,
enabled = true,
}: { onSuccess?: (isEnabled: boolean) => void; enabled?: boolean } = {}
) {
return usePublicSettings<boolean>({
select: (settings) => settings.Features[flag],
onSuccess,
enabled,
});
}

View file

@ -0,0 +1,9 @@
export function buildUrl(action?: string) {
let url = '/status';
if (action) {
url += `/${action}`;
}
return url;
}

View file

@ -0,0 +1,25 @@
import { useQuery } from 'react-query';
import axios, { parseAxiosError } from '@/portainer/services/axios';
import { withError } from '@/react-tools/react-query';
import { buildUrl } from './build-url';
export interface NodesCountResponse {
nodes: number;
}
async function getNodesCount() {
try {
const { data } = await axios.get<NodesCountResponse>(buildUrl('nodes'));
return data.nodes;
} catch (error) {
throw parseAxiosError(error as Error);
}
}
export function useNodesCount() {
return useQuery(['status', 'nodes'], getNodesCount, {
...withError('Unable to retrieve nodes count'),
});
}

View file

@ -0,0 +1,28 @@
import { useQuery } from 'react-query';
import axios, { parseAxiosError } from '@/portainer/services/axios';
import { withError } from '@/react-tools/react-query';
import { buildUrl } from './build-url';
export interface SystemInfoResponse {
platform: string;
agents: number;
edgeAgents: number;
edgeDevices: number;
}
async function getSystemInfo() {
try {
const { data } = await axios.get<SystemInfoResponse>(buildUrl('system'));
return data;
} catch (error) {
throw parseAxiosError(error as Error);
}
}
export function useSystemInfo() {
return useQuery(['status', 'system'], getSystemInfo, {
...withError('Unable to retrieve system info'),
});
}