Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions web/packages/teleport/src/Bots/Edit/EditDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import { Option } from 'shared/components/Select';
import Validation from 'shared/components/Validation';
import { requiredField } from 'shared/components/Validation/rules';

import { editBot, fetchRoles } from 'teleport/services/bot/bot';
import { editBotMutationFunction, fetchRoles } from 'teleport/services/bot/bot';
import { FlatBot } from 'teleport/services/bot/types';
import {
TraitsEditor,
Expand Down Expand Up @@ -82,7 +82,7 @@ export function EditDialog(props: {
error: saveError,
isPending: isSubmitting,
} = useMutation({
mutationFn: editBot,
mutationFn: editBotMutationFunction,
onSuccess: newData => {
const key = createGetBotQueryKey({ botName: newData.name });
queryClient.setQueryData(key, newData);
Expand Down
10 changes: 5 additions & 5 deletions web/packages/teleport/src/lib/locks/useResourceLock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import { useCallback } from 'react';

import { LockResourceKind } from 'teleport/LocksV2/NewLock/common';
import {
createLock,
deleteLock,
createLockMutationFn,
deleteLockMutationFn,
listLocks,
} from 'teleport/services/locks/locks';
import { createQueryHook } from 'teleport/services/queryHelpers';
Expand Down Expand Up @@ -70,7 +70,7 @@ export function useResourceLock(opts: {
isPending: unlockPending,
error: unlockError,
} = useMutation({
mutationFn: deleteLock,
mutationFn: deleteLockMutationFn,
onSuccess: (_, vars) => {
queryClient.setQueryData(listLocksQueryKey(queryVars), existingLocks => {
return existingLocks?.filter(lock => lock.name !== vars.uuid);
Expand All @@ -83,7 +83,7 @@ export function useResourceLock(opts: {
isPending: lockPending,
error: lockError,
} = useMutation({
mutationFn: createLock,
mutationFn: createLockMutationFn,
onSuccess: newLock => {
queryClient.setQueryData(listLocksQueryKey(queryVars), existingLocks => {
return existingLocks ? [...existingLocks, newLock] : [newLock];
Expand All @@ -95,7 +95,7 @@ export function useResourceLock(opts: {
// locks may affect other resources
const canUnlock =
hasRemovePermission &&
data &&
!!data &&
data.length > 0 &&
data.reduce(
(acc, lock) =>
Expand Down
7 changes: 7 additions & 0 deletions web/packages/teleport/src/services/bot/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import { MutationFunction } from '@tanstack/react-query';

import cfg from 'teleport/config';
import api from 'teleport/services/api';
import {
Expand Down Expand Up @@ -140,6 +142,11 @@ export async function fetchRoles(
);
}

export const editBotMutationFunction: MutationFunction<
FlatBot,
{ botName: string; req: EditBotRequest }
> = vars => editBot(vars);

export async function editBot(
variables: { botName: string; req: EditBotRequest },
signal?: AbortSignal
Expand Down
16 changes: 16 additions & 0 deletions web/packages/teleport/src/services/locks/locks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import { MutationFunction } from '@tanstack/react-query';

import cfg from 'teleport/config';
import api from 'teleport/services/api';

Expand Down Expand Up @@ -65,6 +67,13 @@ export async function listLocks(
}
}

export const createLockMutationFn: MutationFunction<
Lock,
CreateLockRequest
> = vars => {
return createLock(vars);
};

export async function createLock(
variables: CreateLockRequest,
signal?: AbortSignal
Expand All @@ -77,6 +86,13 @@ export async function createLock(
return makeLock(json);
}

export const deleteLockMutationFn: MutationFunction<
unknown,
{ uuid: string }
> = vars => {
return deleteLock(vars);
};

export async function deleteLock(
variables: { uuid: string },
signal?: AbortSignal
Expand Down
Loading