mirror of
https://github.com/portainer/portainer.git
synced 2025-07-20 22:09:41 +02:00
* fix(kubeapi): fix ts api error handling [EE-5558] * use portainer errors for mapped functions * don't parse long patch responses * allow nested kube error that's thrown to bubble up --------- Co-authored-by: testa113 <testa113>
27 lines
837 B
TypeScript
27 lines
837 B
TypeScript
import { useQuery } from 'react-query';
|
|
|
|
import axios, { parseAxiosError } from '@/portainer/services/axios';
|
|
import { EnvironmentId } from '@/react/portainer/environments/types';
|
|
import { withError } from '@/react-tools/react-query';
|
|
|
|
export function useIsRBACEnabledQuery(environmentId: EnvironmentId) {
|
|
return useQuery<boolean, Error>(
|
|
['environments', environmentId, 'rbacEnabled'],
|
|
() => getIsRBACEnabled(environmentId),
|
|
{
|
|
enabled: !!environmentId,
|
|
...withError('Unable to check if RBAC is enabled.'),
|
|
}
|
|
);
|
|
}
|
|
|
|
export async function getIsRBACEnabled(environmentId: EnvironmentId) {
|
|
try {
|
|
const { data } = await axios.get<boolean>(
|
|
`kubernetes/${environmentId}/rbac_enabled`
|
|
);
|
|
return data;
|
|
} catch (e) {
|
|
throw parseAxiosError(e, 'Unable to check if RBAC is enabled.');
|
|
}
|
|
}
|