[ui] Rename `trackId` (i.e. UI track IDs) to `trackKey`, or just `key`
where appropriate.
Change-Id: I7c994b6328fdd22334c3369630e996e52149493b
diff --git a/ui/src/frontend/track_panel.ts b/ui/src/frontend/track_panel.ts
index 5e39589..90a593a 100644
--- a/ui/src/frontend/track_panel.ts
+++ b/ui/src/frontend/track_panel.ts
@@ -106,8 +106,8 @@
let highlightClass = '';
const searchIndex = globals.state.searchIndex;
if (searchIndex !== -1) {
- const trackId = globals.currentSearchResults.trackIds[searchIndex];
- if (trackId === attrs.trackState.id) {
+ const trackKey = globals.currentSearchResults.trackKeys[searchIndex];
+ if (trackKey === attrs.trackState.key) {
highlightClass = 'flash';
}
}
@@ -140,12 +140,12 @@
m(TrackButton, {
action: () => {
globals.dispatch(
- Actions.toggleTrackPinned({trackId: attrs.trackState.id}));
+ Actions.toggleTrackPinned({trackKey: attrs.trackState.key}));
},
i: Icons.Pin,
- filledIcon: isPinned(attrs.trackState.id),
- tooltip: isPinned(attrs.trackState.id) ? 'Unpin' : 'Pin to top',
- showButton: isPinned(attrs.trackState.id),
+ filledIcon: isPinned(attrs.trackState.key),
+ tooltip: isPinned(attrs.trackState.key) ? 'Unpin' : 'Pin to top',
+ showButton: isPinned(attrs.trackState.key),
fullHeight: true,
}),
globals.state.currentSelection !== null &&
@@ -153,12 +153,12 @@
m(TrackButton, {
action: (e: MouseEvent) => {
globals.dispatch(Actions.toggleTrackSelection(
- {id: attrs.trackState.id, isTrackGroup: false}));
+ {id: attrs.trackState.key, isTrackGroup: false}));
e.stopPropagation();
},
- i: isSelected(attrs.trackState.id) ? Icons.Checkbox :
- Icons.BlankCheckbox,
- tooltip: isSelected(attrs.trackState.id) ?
+ i: isSelected(attrs.trackState.key) ? Icons.Checkbox :
+ Icons.BlankCheckbox,
+ tooltip: isSelected(attrs.trackState.key) ?
'Remove track' :
'Add track to selection',
showButton: true,
@@ -171,7 +171,7 @@
if (dataTransfer === null) return;
this.dragging = true;
raf.scheduleFullRedraw();
- dataTransfer.setData('perfetto/track', `${this.attrs!.trackState.id}`);
+ dataTransfer.setData('perfetto/track', `${this.attrs!.trackState.key}`);
dataTransfer.setDragImage(new Image(), 0, 0);
}
@@ -210,7 +210,7 @@
if (dataTransfer === null) return;
raf.scheduleFullRedraw();
const srcId = dataTransfer.getData('perfetto/track');
- const dstId = this.attrs!.trackState.id;
+ const dstId = this.attrs!.trackState.key;
globals.dispatch(Actions.moveTrack({srcId, op: this.dropping, dstId}));
this.dropping = undefined;
}
@@ -289,7 +289,7 @@
style: {
height: `${Math.max(18, attrs.track.getHeight())}px`,
},
- id: 'track_' + attrs.trackState.id,
+ id: 'track_' + attrs.trackState.key,
},
[
m(TrackShell, {track: attrs.track, trackState: attrs.trackState}),
@@ -298,9 +298,9 @@
}
oncreate({attrs}: m.CVnode<TrackComponentAttrs>) {
- if (globals.frontendLocalState.scrollToTrackId === attrs.trackState.id) {
- verticalScrollToTrack(attrs.trackState.id);
- globals.frontendLocalState.scrollToTrackId = undefined;
+ if (globals.frontendLocalState.scrollToTrackKey === attrs.trackState.key) {
+ verticalScrollToTrack(attrs.trackState.key);
+ globals.frontendLocalState.scrollToTrackKey = undefined;
}
}
}
@@ -332,7 +332,7 @@
}
interface TrackPanelAttrs {
- id: string;
+ trackKey: string;
selectable: boolean;
}
@@ -344,22 +344,22 @@
private trackState: TrackState|undefined;
private tryLoadTrack(vnode: m.CVnode<TrackPanelAttrs>) {
- const trackId = vnode.attrs.id;
- const trackState = globals.state.tracks[trackId];
+ const trackKey = vnode.attrs.trackKey;
+ const trackState = globals.state.tracks[trackKey];
if (!trackState) return;
- const {id, uri, params} = trackState;
+ const {uri, params} = trackState;
const trackCtx: TrackContext = {
- trackInstanceId: id,
+ trackKey,
mountStore: <T>(migrate: Migrate<T>) => {
const {store, state} = globals;
- const migratedState = migrate(state.tracks[trackId].state);
+ const migratedState = migrate(state.tracks[trackKey].state);
globals.store.edit((draft) => {
- draft.tracks[trackId].state = migratedState;
+ draft.tracks[trackKey].state = migratedState;
});
- return store.createProxy<T>(['tracks', trackId, 'state']);
+ return store.createProxy<T>(['tracks', trackKey, 'state']);
},
params,
};
@@ -409,7 +409,7 @@
}
const selectedArea = globals.state.areas[selection.areaId];
const selectedAreaDuration = selectedArea.end - selectedArea.start;
- if (selectedArea.tracks.includes(trackState.id)) {
+ if (selectedArea.tracks.includes(trackState.key)) {
ctx.fillStyle = SELECTION_FILL_COLOR;
ctx.fillRect(
visibleTimeScale.timeToPx(selectedArea.start) + TRACK_SHELL_WIDTH,