mirror of
https://github.com/portainer/portainer.git
synced 2025-07-21 22:39:41 +02:00
refactor(namespace): migrate namespace edit to react [r8s-125] (#38)
This commit is contained in:
parent
40c7742e46
commit
ce7e0d8d60
108 changed files with 3183 additions and 2194 deletions
|
@ -0,0 +1,34 @@
|
|||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
|
||||
import axios from '@/portainer/services/axios';
|
||||
import { EnvironmentId } from '@/react/portainer/environments/types';
|
||||
import { withGlobalError, withInvalidate } from '@/react-tools/react-query';
|
||||
|
||||
import { queryKeys } from './queryKeys';
|
||||
|
||||
export function useToggleSystemNamespaceMutation(
|
||||
environmentId: EnvironmentId,
|
||||
namespaceName: string
|
||||
) {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (isSystem: boolean) =>
|
||||
toggleSystemNamespace(environmentId, namespaceName, isSystem),
|
||||
...withInvalidate(queryClient, [
|
||||
queryKeys.namespace(environmentId, namespaceName),
|
||||
]),
|
||||
...withGlobalError('Failed to update namespace'),
|
||||
});
|
||||
}
|
||||
|
||||
async function toggleSystemNamespace(
|
||||
environmentId: EnvironmentId,
|
||||
namespaceName: string,
|
||||
system: boolean
|
||||
) {
|
||||
const response = await axios.put(
|
||||
`/kubernetes/${environmentId}/namespaces/${namespaceName}/system`,
|
||||
{ system }
|
||||
);
|
||||
return response.data;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue