Skip to content
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
## 1.0.0-beta.9 - [UNRELEASED]
### Added
- Support for named urls when sharing links to workspaces
- Ability to convert items to other types by right-clicking
- Ancestor items in context menus now stay tinted when their child menus are opened
### Fixed
- An issue where the inspector started to scroll horisontally on overflow
- Closing electron windows may cause a loop preventing user defaults from being saved
Expand Down
17 changes: 14 additions & 3 deletions app/components/ContextMenuItem/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ const MOUSE_LEAVE_DELAY_MS = 150

export const ContextMenuItem = ({ text, children = [], onClick = () => {} }) => {
const elRef = React.useRef()

/*
Delayed hover is used for preventing unmounting of
child menus when the cursor leaves the item,
regular hover is used for tinting the item
*/
const [delayedHover, setDelayedHover] = React.useState(false)
const [hover, setHover] = React.useState(false)

const childArr = Array.isArray(children) ? children : [children]

const timeoutRef = React.useRef()
Expand All @@ -29,12 +37,14 @@ export const ContextMenuItem = ({ text, children = [], onClick = () => {} }) =>
if (timeoutRef.current) {
clearTimeout(timeoutRef.current)
}
setDelayedHover(true)
setHover(true)
}

function handleMouseLeave () {
setHover(false)
timeoutRef.current = setTimeout(() => {
setHover(false)
setDelayedHover(false)
}, MOUSE_LEAVE_DELAY_MS)
}

Expand All @@ -45,6 +55,7 @@ export const ContextMenuItem = ({ text, children = [], onClick = () => {} }) =>
}

function handleFocus (e) {
setDelayedHover(true)
setHover(true)
}

Expand All @@ -53,7 +64,7 @@ export const ContextMenuItem = ({ text, children = [], onClick = () => {} }) =>
return (
<div
ref={elRef}
className='ContextMenuItem'
className={`ContextMenuItem ${hover ? 'is-hovered' : ''}`}
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
onClick={() => onClick()}
Expand All @@ -69,7 +80,7 @@ export const ContextMenuItem = ({ text, children = [], onClick = () => {} }) =>
<Icon name='arrowRight' color='black' />
}
{
hover && childArr.length > 0
delayedHover && childArr.length > 0
? (
<ContextMenu x={bounds?.x + CTX_MENU_OFFSET_X_PX} y={bounds?.y + bounds?.height / 2}>
{children}
Expand Down
3 changes: 2 additions & 1 deletion app/components/ContextMenuItem/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
--base-color: black;
}

.ContextMenuItem:hover > .ContextMenuItem-text {
.ContextMenuItem:hover > .ContextMenuItem-text,
.ContextMenuItem.is-hovered > .ContextMenuItem-text {
background: rgb(228, 228, 228);
}

Expand Down
134 changes: 96 additions & 38 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions plugins/rundown/app/components/RundownList/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,7 @@ export function RundownList ({
console.warn('Dropped spec is missing type')
return
}
const itemId = await bridge.items.createItem(spec.type)

bridge.items.applyItem(itemId, spec)
const itemId = await bridge.items.createItem(spec.type, spec?.data)
bridge.commands.executeCommand('rundown.moveItem', rundownId, newIndex, itemId)
} catch (_) {
console.warn('Tried to drop an invalid spec')
Expand Down
15 changes: 15 additions & 0 deletions plugins/rundown/app/components/RundownListItem/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ export function RundownListItem ({
label: 'Add after',
children: contextMenu.generateAddContextMenuItems(types, typeId => handleAdd(typeId))
},
{
type: 'item',
label: 'Convert to',
children: contextMenu.generateAddContextMenuItems(types, typeId => handleConvertTo(typeId))
},
{
type: 'item',
label: 'Create reference',
Expand Down Expand Up @@ -189,6 +194,16 @@ export function RundownListItem ({
bridge.commands.executeCommand('rundown.moveItem', rundownId, index + 1, itemId)
}

async function handleConvertTo (typeId) {
if (!item?.id) {
return
}

await bridge.items.applyItem(item?.id, {
type: typeId
})
}

async function handleCreateReference () {
const newItemId = await bridge.items.createItem('bridge.types.reference')

Expand Down