File tree Expand file tree Collapse file tree 4 files changed +30
-7
lines changed
web/packages/teleport/src Expand file tree Collapse file tree 4 files changed +30
-7
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ import {
4343import Validation from 'shared/components/Validation' ;
4444import { requiredField } from 'shared/components/Validation/rules' ;
4545
46- import { editBot , fetchRoles } from 'teleport/services/bot/bot' ;
46+ import { editBotMutationFunction , fetchRoles } from 'teleport/services/bot/bot' ;
4747import { FlatBot } from 'teleport/services/bot/types' ;
4848import useTeleport from 'teleport/useTeleport' ;
4949
@@ -82,7 +82,7 @@ export function EditDialog(props: {
8282 error : saveError ,
8383 isPending : isSubmitting ,
8484 } = useMutation ( {
85- mutationFn : editBot ,
85+ mutationFn : editBotMutationFunction ,
8686 onSuccess : newData => {
8787 const key = createGetBotQueryKey ( { botName : newData . name } ) ;
8888 queryClient . setQueryData ( key , newData ) ;
Original file line number Diff line number Diff line change @@ -21,8 +21,8 @@ import { useCallback } from 'react';
2121
2222import { LockResourceKind } from 'teleport/LocksV2/NewLock/common' ;
2323import {
24- createLock ,
25- deleteLock ,
24+ createLockMutationFn ,
25+ deleteLockMutationFn ,
2626 listLocks ,
2727} from 'teleport/services/locks/locks' ;
2828import { createQueryHook } from 'teleport/services/queryHelpers' ;
@@ -70,7 +70,7 @@ export function useResourceLock(opts: {
7070 isPending : unlockPending ,
7171 error : unlockError ,
7272 } = useMutation ( {
73- mutationFn : deleteLock ,
73+ mutationFn : deleteLockMutationFn ,
7474 onSuccess : ( _ , vars ) => {
7575 queryClient . setQueryData ( listLocksQueryKey ( queryVars ) , existingLocks => {
7676 return existingLocks ?. filter ( lock => lock . name !== vars . uuid ) ;
@@ -83,7 +83,7 @@ export function useResourceLock(opts: {
8383 isPending : lockPending ,
8484 error : lockError ,
8585 } = useMutation ( {
86- mutationFn : createLock ,
86+ mutationFn : createLockMutationFn ,
8787 onSuccess : newLock => {
8888 queryClient . setQueryData ( listLocksQueryKey ( queryVars ) , existingLocks => {
8989 return existingLocks ? [ ...existingLocks , newLock ] : [ newLock ] ;
@@ -95,7 +95,7 @@ export function useResourceLock(opts: {
9595 // locks may affect other resources
9696 const canUnlock =
9797 hasRemovePermission &&
98- data &&
98+ ! ! data &&
9999 data . length > 0 &&
100100 data . reduce (
101101 ( acc , lock ) =>
Original file line number Diff line number Diff line change 1616 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1717 */
1818
19+ import { MutationFunction } from '@tanstack/react-query' ;
20+
1921import cfg from 'teleport/config' ;
2022import api from 'teleport/services/api' ;
2123import {
@@ -140,6 +142,11 @@ export async function fetchRoles(
140142 ) ;
141143}
142144
145+ export const editBotMutationFunction : MutationFunction <
146+ FlatBot ,
147+ { botName : string ; req : EditBotRequest }
148+ > = vars => editBot ( vars ) ;
149+
143150export async function editBot (
144151 variables : { botName : string ; req : EditBotRequest } ,
145152 signal ?: AbortSignal
Original file line number Diff line number Diff line change 1616 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1717 */
1818
19+ import { MutationFunction } from '@tanstack/react-query' ;
20+
1921import cfg from 'teleport/config' ;
2022import api from 'teleport/services/api' ;
2123
@@ -65,6 +67,13 @@ export async function listLocks(
6567 }
6668}
6769
70+ export const createLockMutationFn : MutationFunction <
71+ Lock ,
72+ CreateLockRequest
73+ > = vars => {
74+ return createLock ( vars ) ;
75+ } ;
76+
6877export async function createLock (
6978 variables : CreateLockRequest ,
7079 signal ?: AbortSignal
@@ -77,6 +86,13 @@ export async function createLock(
7786 return makeLock ( json ) ;
7887}
7988
89+ export const deleteLockMutationFn : MutationFunction <
90+ unknown ,
91+ { uuid : string }
92+ > = vars => {
93+ return deleteLock ( vars ) ;
94+ } ;
95+
8096export async function deleteLock (
8197 variables : { uuid : string } ,
8298 signal ?: AbortSignal
You can’t perform that action at this time.
0 commit comments