Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bulk delete session tracks #4736

Merged
merged 2 commits into from
Dec 19, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ const ShoppingCart = observer(function ({
}: {
model: HierarchicalTrackSelectorModel
}) {
const session = getSession(model)
const { selection } = model
const { pluginManager } = getEnv(model)
const session = getSession(model)
const { adminMode, sessionTracks } = session
const s = new Set<string>(sessionTracks?.map(t => t.trackId))
const canEdit = (t: string) => adminMode || s.has(t)
const items = pluginManager.evaluateExtensionPoint(
'TrackSelector-multiTrackMenuItems',
[],
Expand All @@ -25,11 +28,23 @@ const ShoppingCart = observer(function ({
<CascadingMenuButton
menuItems={[
{
label: 'Clear',
label: 'Clear selection',
onClick: () => {
model.clearSelection()
},
},
...(selection.every(elt => canEdit(elt.trackId))
? [
{
label: 'Delete tracks',
onClick: () => {
// @ts-expect-error
selection.forEach(s => session.deleteTrackConf?.(s))
},
},
]
: []),

...items.map(item => ({
...item,
...('onClick' in item
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export default function TrackLabel({ data }: { data: NodeData }) {
id,
trackId,
name,
onChange,
selected,
onChange,
} = data
const description = readConfObject(conf, 'description')
return (
Expand All @@ -53,6 +53,16 @@ export default function TrackLabel({ data }: { data: NodeData }) {
>
<FormControlLabel
className={classes.checkboxLabel}
onClick={event => {
if (event.ctrlKey || event.metaKey) {
if (selected) {
model.removeFromSelection([conf])
} else {
model.addToSelection([conf])
}
event.preventDefault()
}
}}
control={
<Checkbox
className={classes.compactCheckbox}
Expand All @@ -70,7 +80,7 @@ export default function TrackLabel({ data }: { data: NodeData }) {
label={
<div
data-testid={`htsTrackLabel-${id}`}
style={{ background: selected ? '#cccc' : undefined }}
className={selected ? classes.selected : undefined}
>
<SanitizedHTML html={name} />
</div>
Expand Down
Loading