mirror of
https://github.com/portainer/portainer.git
synced 2025-07-25 00:09:40 +02:00
refactor(namespace): migrate namespace access view to react [r8s-141] (#87)
This commit is contained in:
parent
8ed7cd80cb
commit
e9fc6d5598
62 changed files with 1018 additions and 610 deletions
|
@ -9,33 +9,37 @@ import { Configuration } from '../types';
|
|||
import { configMapQueryKeys } from './query-keys';
|
||||
import { ConfigMapQueryParams } from './types';
|
||||
|
||||
export function useConfigMap(
|
||||
export function useConfigMap<T = Configuration>(
|
||||
environmentId: EnvironmentId,
|
||||
namespace: string,
|
||||
configMap: string,
|
||||
options?: { autoRefreshRate?: number } & ConfigMapQueryParams
|
||||
options?: {
|
||||
autoRefreshRate?: number;
|
||||
select?: (data: Configuration) => T;
|
||||
enabled?: boolean;
|
||||
} & ConfigMapQueryParams
|
||||
) {
|
||||
return useQuery(
|
||||
configMapQueryKeys.configMap(environmentId, namespace, configMap),
|
||||
() => getConfigMap(environmentId, namespace, configMap, { withData: true }),
|
||||
{
|
||||
...withGlobalError('Unable to retrieve ConfigMaps for cluster'),
|
||||
refetchInterval() {
|
||||
return options?.autoRefreshRate ?? false;
|
||||
},
|
||||
select: options?.select,
|
||||
enabled: options?.enabled,
|
||||
refetchInterval: () => options?.autoRefreshRate ?? false,
|
||||
...withGlobalError(`Unable to retrieve ConfigMap '${configMap}'`),
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// get a configmap
|
||||
async function getConfigMap(
|
||||
export async function getConfigMap(
|
||||
environmentId: EnvironmentId,
|
||||
namespace: string,
|
||||
configMap: string,
|
||||
params?: { withData?: boolean }
|
||||
) {
|
||||
try {
|
||||
const { data } = await axios.get<Configuration[]>(
|
||||
const { data } = await axios.get<Configuration>(
|
||||
`/kubernetes/${environmentId}/namespaces/${namespace}/configmaps/${configMap}`,
|
||||
{ params }
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue