diff --git a/ui/src/common/actions.ts b/ui/src/common/actions.ts index fc7f162411..193b54fc2a 100644 --- a/ui/src/common/actions.ts +++ b/ui/src/common/actions.ts @@ -100,10 +100,16 @@ export type AddTrackLikeArgs = AddTrackArgs | AddTrackGroupArgs; export interface RemoveTrackArgs { // The ID of the track to remove id: string; + // Whether to keep the ID so that it may be reused when the // track is subsequently added again (required for group // summary tracks only). keepId?: boolean; + + // Set to true if the track is user-defined and the user wishes + // to outright delete the track definition rather than just hide + // it. I.e., don't add the track to the filtered list. + purge? : boolean; } export interface RemoveTrackGroupArgs { @@ -501,11 +507,11 @@ export const StateActions = { removeTracks(state: StateDraft, args: {tracks: RemoveTrackArgs[]}): void { args.tracks.forEach((track) => this.removeTrack( - state, {trackId: track.id, keepId: track.keepId})); + state, {trackId: track.id, keepId: track.keepId, purge: track.purge})); }, removeTrack(state: StateDraft, - args: {trackId: string, keepId?: boolean}): void { + args: {trackId: string, keepId?: boolean, purge?: boolean}): void { const track = state.tracks[args.trackId]; if (!track) { return; @@ -514,20 +520,22 @@ export const StateActions = { this.cleanUiTrackIdByTraceTrackId(state, track as TrackState, args.trackId); - // Don't attempt to reuse track IDs unless requested (usually only - // for group summary tracks) - const id = args.keepId ? {id: args.trackId} : {}; - state.filteredTracks.push({ - ...id, - kind: track.kind, - engineId: track.engineId, - name: track.name, - title: track.title, - trackSortKey: track.trackSortKey, - trackGroup: track.trackGroup, - labels: track.labels, - config: current(track.config), - }); + if (!args.purge) { + // Don't attempt to reuse track IDs unless requested (usually only + // for group summary tracks) + const id = args.keepId ? {id: args.trackId} : {}; + state.filteredTracks.push({ + ...id, + kind: track.kind, + engineId: track.engineId, + name: track.name, + title: track.title, + trackSortKey: track.trackSortKey, + trackGroup: track.trackGroup, + labels: track.labels, + config: current(track.config), + }); + } dropTables(track.engineId, track.id); }, diff --git a/ui/src/frontend/track_group_panel.ts b/ui/src/frontend/track_group_panel.ts index 6525a3404d..8ac513f42c 100644 --- a/ui/src/frontend/track_group_panel.ts +++ b/ui/src/frontend/track_group_panel.ts @@ -389,9 +389,9 @@ export class TrackGroupPanel extends Panel { ]); e.stopPropagation(); }, - i: 'delete', + i: 'hide', disabled, - tooltip: 'Remove track group', + tooltip: 'Hide track group', showButton: false, // Only show on roll-over fullHeight: true, })); diff --git a/ui/src/frontend/track_panel.ts b/ui/src/frontend/track_panel.ts index 29cde7778b..f0ba0686c6 100644 --- a/ui/src/frontend/track_panel.ts +++ b/ui/src/frontend/track_panel.ts @@ -306,8 +306,8 @@ class TrackShell implements m.ClassComponent { result.push(m(TrackButton, { action: () => globals.dispatch( Actions.removeTrack({trackId: attrs.trackState.id})), - i: 'delete', - tooltip: 'Remove track', + i: 'hide', + tooltip: 'Hide track', showButton: false, // Only show on roll-over fullHeight: true, disabled: !this.canDeleteTrack(attrs.trackState),