feat: duplicate groups

This commit is contained in:
Carlos Valente
2025-05-19 20:01:03 +02:00
committed by arc-alex
parent 11e0215530
commit 2f26f20db5
20 changed files with 448 additions and 88 deletions
+7
View File
@@ -87,6 +87,13 @@ export async function requestApplyDelay(delayId: EntryId): Promise<AxiosResponse
return axios.patch(`${rundownPath}/applydelay/${delayId}`);
}
/**
* HTTP request for cloning an entry
*/
export async function postCloneEntry(entryId: EntryId): Promise<AxiosResponse<Rundown>> {
return axios.post(`${rundownPath}/clone/${entryId}`);
}
/**
* HTTP request for dissolving of a block
*/
@@ -20,6 +20,7 @@ import {
deleteEntries,
patchReorderEntry,
postAddEntry,
postCloneEntry,
putBatchEditEvents,
putEditEntry,
ReorderEntry,
@@ -164,6 +165,29 @@ export const useEntryActions = () => {
],
);
/**
* Calls mutation to clone a selection
* @private
*/
const _cloneMutation = useMutation({
mutationFn: postCloneEntry,
onSettled: () => queryClient.invalidateQueries({ queryKey: RUNDOWN }),
});
/**
* Clone a selection
*/
const clone = useCallback(
async (entryId: EntryId) => {
try {
await _cloneMutation.mutateAsync(entryId);
} catch (error) {
logAxiosError('Error cloning entry', error);
}
},
[_cloneMutation],
);
/**
* Calls mutation to update existing entry
* @private
@@ -735,6 +759,7 @@ export const useEntryActions = () => {
addEntry,
applyDelay,
batchUpdateEvents,
clone,
deleteEntry,
deleteAllEntries,
dissolveBlock,
@@ -1,6 +1,6 @@
import { EndAction, EntryCustomFields, OntimeEvent, SupportedEntry, TimerType, TimeStrategy } from 'ontime-types';
import { cloneEvent } from '../eventsManager';
import { cloneEvent } from '../clone';
describe('cloneEvent()', () => {
it('creates a stem from a given event', () => {