mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-02-18 08:37:48 +01:00
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> Co-authored-by: Gregory Schier <gschier1990@gmail.com>
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
import type { GrpcRequest, HttpRequest, WebsocketRequest } from '@yaakapp-internal/models';
|
|
|
|
import { MoveToWorkspaceDialog } from '../components/MoveToWorkspaceDialog';
|
|
import { activeWorkspaceIdAtom } from '../hooks/useActiveWorkspace';
|
|
import { createFastMutation } from '../hooks/useFastMutation';
|
|
import { pluralizeCount } from '../lib/pluralize';
|
|
import { showDialog } from '../lib/dialog';
|
|
import { jotaiStore } from '../lib/jotai';
|
|
|
|
export const moveToWorkspace = createFastMutation({
|
|
mutationKey: ['move_workspace'],
|
|
mutationFn: async (requests: (HttpRequest | GrpcRequest | WebsocketRequest)[]) => {
|
|
const activeWorkspaceId = jotaiStore.get(activeWorkspaceIdAtom);
|
|
if (activeWorkspaceId == null) return;
|
|
if (requests.length === 0) return;
|
|
|
|
const title =
|
|
requests.length === 1
|
|
? 'Move Request'
|
|
: `Move ${pluralizeCount('Request', requests.length)}`;
|
|
|
|
showDialog({
|
|
id: 'change-workspace',
|
|
title,
|
|
size: 'sm',
|
|
render: ({ hide }) => (
|
|
<MoveToWorkspaceDialog
|
|
onDone={hide}
|
|
requests={requests}
|
|
activeWorkspaceId={activeWorkspaceId}
|
|
/>
|
|
),
|
|
});
|
|
},
|
|
});
|