diff --git a/package.json b/package.json index 68c0020..fe2e1ce 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ "react-app-polyfill": "^1.0.4", "react-beautiful-dnd": "^12.1.1", "react-beforeunload": "^2.1.0", - "react-contextmenu": "^2.13.0", + "react-contexify": "^4.1.1", "react-dev-utils": "^9.1.0", "react-dnd": "^9.4.0", "react-dnd-html5-backend": "^9.4.0", diff --git a/src/api.ts b/src/api.ts index f66a941..851bec4 100644 --- a/src/api.ts +++ b/src/api.ts @@ -77,7 +77,7 @@ interface Album { // TODO } -interface TimeslotItemBase { +export interface TimeslotItemBase { timeslotitemid: string; channel: number; weight: number; @@ -88,7 +88,7 @@ interface TimeslotItemBase { cue: number; } -interface TimeslotItemCentral { +export interface TimeslotItemCentral { type: "central"; artist: string; intro: number; diff --git a/src/showplanner/Item.tsx b/src/showplanner/Item.tsx index c0242ba..527d4f4 100644 --- a/src/showplanner/Item.tsx +++ b/src/showplanner/Item.tsx @@ -1,15 +1,16 @@ import React, { memo } from "react"; -import { PlanItem, itemId } from "./state"; +import { PlanItem, itemId, isTrack, isAux } from "./state"; import { Track, AuxItem } from "../api"; import { useDispatch, useSelector } from "react-redux"; import { RootState } from "../rootReducer"; import * as MixerState from "../mixer/state"; import { Draggable } from "react-beautiful-dnd"; -import { ContextMenuTrigger } from "react-contextmenu"; +import { contextMenu } from "react-contexify"; import "./item.scss"; export const TS_ITEM_MENU_ID = "SongMenu"; +export const TS_ITEM_AUX_ID = "AuxMenu"; export const Item = memo(function Item({ item: x, @@ -22,7 +23,6 @@ export const Item = memo(function Item({ }) { const dispatch = useDispatch(); const id = itemId(x); - const isReal = "timeslotitemid" in x; const isGhost = "ghostid" in x; const playerState = useSelector((state: RootState) => @@ -44,6 +44,30 @@ export const Item = memo(function Item({ } } + function openContextMenu(e: React.MouseEvent) { + e.preventDefault(); + if (isTrack(x)) { + contextMenu.show({ + id: TS_ITEM_MENU_ID, + event: e, + props: { + id, + title: x.title, + artist: x.artist, + }, + }); + } else if (isAux(x)) { + contextMenu.show({ + id: TS_ITEM_MENU_ID, + event: e, + props: { + id, + title: x.title, + }, + }); + } + } + return ( - ({ id })} + +   + {x.title.toString()} + {"artist" in x && x.artist !== "" && " - " + x.artist} + - -   - {x.title.toString()} - {"artist" in x && x.artist !== "" && " - " + x.artist} - - Explicit - - {showDebug && ( - - {itemId(x)} {"channel" in x && x.channel + "/" + x.weight} - - )} - + Explicit + + {showDebug && ( + + {itemId(x)} {"channel" in x && x.channel + "/" + x.weight} + + )} )} diff --git a/src/showplanner/index.tsx b/src/showplanner/index.tsx index e120db2..a673c18 100644 --- a/src/showplanner/index.tsx +++ b/src/showplanner/index.tsx @@ -1,5 +1,6 @@ import React, { useState, useReducer, useEffect } from "react"; -import { ContextMenu, MenuItem } from "react-contextmenu"; +import { Menu, Item as CtxMenuItem } from "react-contexify"; +import "react-contexify/dist/ReactContexify.min.css"; import { useBeforeunload } from "react-beforeunload"; import { FaBookOpen, @@ -379,13 +380,6 @@ const Showplanner: React.FC<{ timeslotId: number }> = function({ timeslotId }) { } } - async function onCtxRemoveClick(e: any, data: { id: string }) { - dispatch(removeItem(timeslotId, data.id)); - } - async function onCtxUnPlayedClick(e: any, data: { id: string }) { - dispatch(setItemPlayed({ itemId: data.id, played: false })); - } - // Add support for reloading the show plan from the iFrames. // There is a similar listener in showplanner/ImporterModal.tsx to handle closing the iframe. useEffect(() => { @@ -440,14 +434,24 @@ const Showplanner: React.FC<{ timeslotId: number }> = function({ timeslotId }) { - - + + + dispatch(removeItem(timeslotId, (args.props as any).id)) + } + > Remove - - + + + dispatch( + setItemPlayed({ itemId: (args.props as any).id, played: false }) + ) + } + > Mark Unplayed - - + +