mirror of
https://github.com/portainer/portainer.git
synced 2025-08-05 05:45:22 +02:00
feat(snapshots): avoid parsing raw snapshots when possible BE-11724 (#560)
This commit is contained in:
parent
0dfde1374d
commit
995c3ef81b
16 changed files with 89 additions and 28 deletions
|
@ -4,5 +4,5 @@ import { useEnvironmentId } from './useEnvironmentId';
|
|||
|
||||
export function useCurrentEnvironment(force = true) {
|
||||
const id = useEnvironmentId(force);
|
||||
return useEnvironment(id);
|
||||
return useEnvironment(id, undefined, { excludeSnapshot: false });
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
import { DockerSnapshot } from '@/react/docker/snapshots/types';
|
||||
import { useIsPodman } from '@/react/portainer/environments/queries/useIsPodman';
|
||||
import {
|
||||
Environment,
|
||||
PlatformType,
|
||||
KubernetesSnapshot,
|
||||
ContainerEngine,
|
||||
} from '@/react/portainer/environments/types';
|
||||
import { getPlatformType } from '@/react/portainer/environments/utils';
|
||||
import { getDockerEnvironmentType } from '@/react/portainer/environments/utils/getDockerEnvironmentType';
|
||||
|
||||
export function EngineVersion({ environment }: { environment: Environment }) {
|
||||
const platform = getPlatformType(environment.Type);
|
||||
const isPodman = useIsPodman(environment.Id);
|
||||
const isPodman = environment.ContainerEngine === ContainerEngine.Podman;
|
||||
|
||||
switch (platform) {
|
||||
case PlatformType.Docker:
|
||||
|
|
|
@ -110,6 +110,7 @@ export function EnvironmentList({ onClickBrowse, onRefresh }: Props) {
|
|||
updateInformation: isBE,
|
||||
edgeAsync: getEdgeAsyncValue(connectionTypes),
|
||||
platformTypes,
|
||||
excludeSnapshotRaw: true,
|
||||
};
|
||||
|
||||
const queryWithSort = {
|
||||
|
|
|
@ -42,6 +42,7 @@ export interface BaseEnvironmentsQueryParams {
|
|||
edgeAsync?: boolean;
|
||||
edgeDeviceUntrusted?: boolean;
|
||||
excludeSnapshots?: boolean;
|
||||
excludeSnapshotRaw?: boolean;
|
||||
provisioned?: boolean;
|
||||
name?: string;
|
||||
agentVersions?: string[];
|
||||
|
@ -119,9 +120,15 @@ export async function getAgentVersions() {
|
|||
}
|
||||
}
|
||||
|
||||
export async function getEndpoint(id: EnvironmentId) {
|
||||
export async function getEndpoint(
|
||||
id: EnvironmentId,
|
||||
excludeSnapshot = true,
|
||||
excludeSnapshotRaw = true
|
||||
) {
|
||||
try {
|
||||
const { data: endpoint } = await axios.get<Environment>(buildUrl(id));
|
||||
const { data: endpoint } = await axios.get<Environment>(buildUrl(id), {
|
||||
params: { excludeSnapshot, excludeSnapshotRaw },
|
||||
});
|
||||
return endpoint;
|
||||
} catch (e) {
|
||||
throw parseAxiosError(e as Error);
|
||||
|
|
|
@ -10,11 +10,20 @@ import { environmentQueryKeys } from './query-keys';
|
|||
export function useEnvironment<T = Environment>(
|
||||
environmentId?: EnvironmentId,
|
||||
select?: (environment: Environment) => T,
|
||||
options?: { autoRefreshRate?: number }
|
||||
options?: {
|
||||
autoRefreshRate?: number;
|
||||
excludeSnapshot?: boolean;
|
||||
excludeSnapshotRaw?: boolean;
|
||||
}
|
||||
) {
|
||||
return useQuery(
|
||||
environmentQueryKeys.item(environmentId!),
|
||||
() => getEndpoint(environmentId!),
|
||||
() =>
|
||||
getEndpoint(
|
||||
environmentId!,
|
||||
options?.excludeSnapshot ?? undefined,
|
||||
options?.excludeSnapshotRaw ?? undefined
|
||||
),
|
||||
{
|
||||
select,
|
||||
...withError('Failed loading environment'),
|
||||
|
|
|
@ -3,7 +3,7 @@ import { EdgeGroupId, EdgeTypes } from '@/react/portainer/environments/types';
|
|||
|
||||
export function useEnvironments(edgeGroupIds: Array<EdgeGroupId>) {
|
||||
const environmentsQuery = useEnvironmentList(
|
||||
{ edgeGroupIds, types: EdgeTypes, pageLimit: 0 },
|
||||
{ edgeGroupIds, types: EdgeTypes, pageLimit: 0, excludeSnapshots: true },
|
||||
{
|
||||
enabled: edgeGroupIds.length > 0,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue