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:
parent
c21921a08d
commit
eccc8131dd
16 changed files with 366 additions and 33 deletions
|
@ -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,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
9
app/react/portainer/status/build-url.ts
Normal file
9
app/react/portainer/status/build-url.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
export function buildUrl(action?: string) {
|
||||
let url = '/status';
|
||||
|
||||
if (action) {
|
||||
url += `/${action}`;
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
25
app/react/portainer/status/useNodesCount.ts
Normal file
25
app/react/portainer/status/useNodesCount.ts
Normal 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'),
|
||||
});
|
||||
}
|
28
app/react/portainer/status/useSystemInfo.ts
Normal file
28
app/react/portainer/status/useSystemInfo.ts
Normal 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'),
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue