mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-20 06:29:07 +00:00
chore: improve convention entry <> event
This commit is contained in:
+9
-9
@@ -2,7 +2,7 @@ import { IoAdd, IoArrowDown, IoArrowUp, IoDuplicateOutline, IoOptions, IoTrash }
|
||||
import { MenuDivider, MenuItem, MenuList } from '@chakra-ui/react';
|
||||
import { isOntimeEvent, SupportedEvent } from 'ontime-types';
|
||||
|
||||
import { useEventAction } from '../../../../common/hooks/useEventAction';
|
||||
import { useEntryActions } from '../../../../common/hooks/useEntryAction';
|
||||
import { cloneEvent } from '../../../../common/utils/eventsManager';
|
||||
|
||||
interface CuesheetTableMenuActionsProps {
|
||||
@@ -13,17 +13,17 @@ interface CuesheetTableMenuActionsProps {
|
||||
|
||||
export default function CuesheetTableMenuActions(props: CuesheetTableMenuActionsProps) {
|
||||
const { eventId, entryIndex, showModal } = props;
|
||||
const { addEvent, getEventById, reorderEvent, deleteEvent } = useEventAction();
|
||||
const { addEntry, getEntryById, reorderEntry, deleteEntry } = useEntryActions();
|
||||
|
||||
const handleCloneEvent = () => {
|
||||
const currentEvent = getEventById(eventId);
|
||||
const currentEvent = getEntryById(eventId);
|
||||
if (!currentEvent || !isOntimeEvent(currentEvent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const newEvent = cloneEvent(currentEvent);
|
||||
try {
|
||||
addEvent(newEvent, { after: eventId });
|
||||
addEntry(newEvent, { after: eventId });
|
||||
} catch (_error) {
|
||||
// we do not handle errors here
|
||||
}
|
||||
@@ -35,10 +35,10 @@ export default function CuesheetTableMenuActions(props: CuesheetTableMenuActions
|
||||
Edit ...
|
||||
</MenuItem>
|
||||
<MenuDivider />
|
||||
<MenuItem icon={<IoAdd />} onClick={() => addEvent({ type: SupportedEvent.Event }, { before: eventId })}>
|
||||
<MenuItem icon={<IoAdd />} onClick={() => addEntry({ type: SupportedEvent.Event }, { before: eventId })}>
|
||||
Add event above
|
||||
</MenuItem>
|
||||
<MenuItem icon={<IoAdd />} onClick={() => addEvent({ type: SupportedEvent.Event }, { after: eventId })}>
|
||||
<MenuItem icon={<IoAdd />} onClick={() => addEntry({ type: SupportedEvent.Event }, { after: eventId })}>
|
||||
Add event below
|
||||
</MenuItem>
|
||||
<MenuItem icon={<IoDuplicateOutline />} onClick={handleCloneEvent}>
|
||||
@@ -48,14 +48,14 @@ export default function CuesheetTableMenuActions(props: CuesheetTableMenuActions
|
||||
<MenuItem
|
||||
isDisabled={entryIndex < 1}
|
||||
icon={<IoArrowUp />}
|
||||
onClick={() => reorderEvent(eventId, entryIndex, entryIndex - 1)}
|
||||
onClick={() => reorderEntry(eventId, entryIndex, entryIndex - 1)}
|
||||
>
|
||||
Move up
|
||||
</MenuItem>
|
||||
<MenuItem icon={<IoArrowDown />} onClick={() => reorderEvent(eventId, entryIndex, entryIndex + 1)}>
|
||||
<MenuItem icon={<IoArrowDown />} onClick={() => reorderEntry(eventId, entryIndex, entryIndex + 1)}>
|
||||
Move down
|
||||
</MenuItem>
|
||||
<MenuItem icon={<IoTrash />} onClick={() => deleteEvent([eventId])}>
|
||||
<MenuItem icon={<IoTrash />} onClick={() => deleteEntry([eventId])}>
|
||||
Delete
|
||||
</MenuItem>
|
||||
</MenuList>
|
||||
|
||||
Reference in New Issue
Block a user