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

feat(helm): update helm view [r8s-256] (#582)

Co-authored-by: Cara Ryan <cara.ryan@portainer.io>
Co-authored-by: James Player <james.player@portainer.io>
Co-authored-by: stevensbkang <skan070@gmail.com>
This commit is contained in:
Ali 2025-04-10 16:08:24 +12:00 committed by GitHub
parent 46eddbe7b9
commit 0ca9321db1
57 changed files with 2635 additions and 222 deletions

View file

@ -0,0 +1,62 @@
import { useQuery } from '@tanstack/react-query';
import { useEnvironmentId } from '@/react/hooks/useEnvironmentId';
import axios, { parseAxiosError } from '@/portainer/services/axios';
import { withGlobalError } from '@/react-tools/react-query';
type DescribeAPIParams = {
name: string;
kind: string;
namespace?: string;
};
type DescribeResourceResponse = {
describe: string;
};
async function getDescribeResource(
environmentId: number,
name: string,
resourceType?: string,
namespace?: string
) {
try {
// This should never happen, but to keep the linter happy...
if (!name || !resourceType) {
throw new Error('Name and kind are required');
}
const params: DescribeAPIParams = {
name,
namespace,
kind: resourceType,
};
const { data } = await axios.get<DescribeResourceResponse>(
`kubernetes/${environmentId}/describe`,
{
params,
}
);
return data;
} catch (err) {
throw parseAxiosError(err, 'Unable to retrieve resource details');
}
}
export function useDescribeResource(
name: string,
resourceType?: string,
namespace?: string
) {
const environmentId = useEnvironmentId();
return useQuery(
[environmentId, 'kubernetes', 'describe', namespace, resourceType, name],
() => getDescribeResource(environmentId, name, resourceType, namespace),
{
enabled: !!environmentId && !!name && !!resourceType,
...withGlobalError('Enable to retrieve data for resource'),
}
);
}