Skip to content

Commit ec484f3

Browse files
committed
WIP: Add Critical path configuration menu and critical path view
Note that code is hard-coded. A generic way is needed to configure the menu and command-handler driven by the server. Alternatively, this feature could be added in a third-party, trace compass specific front-end extension(s) (i.e. Theia extension/Vscode extension). Signed-off-by: Bernd Hufmann <[email protected]>
1 parent 3843e8d commit ec484f3

File tree

3 files changed

+75
-1
lines changed

3 files changed

+75
-1
lines changed

packages/base/src/signals/signal-manager.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export declare interface SignalManager {
4747
fireRequestSelectionRangeChange(payload: TimeRangeUpdatePayload): void;
4848
fireContributeContextMenu(payload: ContextMenuContributedSignalPayload): void;
4949
fireContextMenuItemClicked(payload: ContextMenuItemClickedSignalPayload): void;
50+
fireTraceContexModelUpdated(payload: { [key: string]: unknown }): void;
5051
}
5152

5253
export const Signals = {
@@ -84,7 +85,8 @@ export const Signals = {
8485
REQUEST_SELECTION_RANGE_CHANGE: 'change selection range',
8586
OUTPUT_DATA_CHANGED: 'output data changed',
8687
CONTRIBUTE_CONTEXT_MENU: 'contribute context menu',
87-
CONTEXT_MENU_ITEM_CLICKED: 'context menu item clicked'
88+
CONTEXT_MENU_ITEM_CLICKED: 'context menu item clicked',
89+
TRACE_MODEL_UPDATED: 'trace model updated'
8890
};
8991

9092
export class SignalManager extends EventEmitter implements SignalManager {
@@ -193,6 +195,9 @@ export class SignalManager extends EventEmitter implements SignalManager {
193195
fireContextMenuItemClicked(payload: ContextMenuItemClickedSignalPayload): void {
194196
this.emit(Signals.CONTEXT_MENU_ITEM_CLICKED, payload);
195197
}
198+
fireTraceContexModelUpdated(payload: { [key: string]: unknown }): void {
199+
this.emit(Signals.TRACE_MODEL_UPDATED, payload);
200+
}
196201
}
197202

198203
let instance: SignalManager = new SignalManager();

packages/react-components/src/components/timegraph-output-component.tsx

+52
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ export class TimegraphOutputComponent extends AbstractTreeOutputComponent<Timegr
104104
this.chartLayer.updateChart();
105105
}, 500);
106106

107+
private additonalParameters: { [key: string]: unknown } | undefined;
108+
107109
constructor(props: TimegraphOutputProps) {
108110
super(props);
109111
this.state = {
@@ -260,6 +262,12 @@ export class TimegraphOutputComponent extends AbstractTreeOutputComponent<Timegr
260262
});
261263
this.waitAnalysisCompletion();
262264
this.subscribeToEvents();
265+
266+
/* Server-side context menus */
267+
if (this.props.outputDescriptor) {
268+
console.log('this.props.outputDescriptor');
269+
this.registerServerSideMenus();
270+
}
263271
}
264272

265273
componentWillUnmount(): void {
@@ -273,13 +281,17 @@ export class TimegraphOutputComponent extends AbstractTreeOutputComponent<Timegr
273281
signalManager().on(Signals.OUTPUT_DATA_CHANGED, this.onOutputDataChanged);
274282
signalManager().on(Signals.THEME_CHANGED, this.onThemeChange);
275283
signalManager().on(Signals.SELECTION_CHANGED, this.onSelectionChanged);
284+
signalManager().on(Signals.CONTEXT_MENU_ITEM_CLICKED, this._onContextMenuItemClicked);
285+
signalManager().on(Signals.TRACE_MODEL_UPDATED, this.onModelUpdated);
276286
}
277287

278288
protected unsubscribeToEvents(): void {
279289
signalManager().off(Signals.CONTRIBUTE_CONTEXT_MENU, this.onContextMenuContributed);
280290
signalManager().off(Signals.OUTPUT_DATA_CHANGED, this.onOutputDataChanged);
281291
signalManager().off(Signals.THEME_CHANGED, this.onThemeChange);
282292
signalManager().off(Signals.SELECTION_CHANGED, this.onSelectionChanged);
293+
signalManager().off(Signals.CONTEXT_MENU_ITEM_CLICKED, this._onContextMenuItemClicked);
294+
signalManager().off(Signals.TRACE_MODEL_UPDATED, this.onModelUpdated);
283295
}
284296

285297
async fetchTree(): Promise<ResponseStatus> {
@@ -1482,4 +1494,44 @@ export class TimegraphOutputComponent extends AbstractTreeOutputComponent<Timegr
14821494
);
14831495
this.chartLayer.selectAndReveal(rowIndex);
14841496
}
1497+
1498+
protected registerServerSideMenus(): void {
1499+
// TODO: create generic API to register server driven menus
1500+
const ctxMenu: ContextMenuItems = {
1501+
submenus: [],
1502+
items: [{ id: 'org.eclipse.tracecompass.follow.thread.id', label: 'Follow thread' }]
1503+
};
1504+
const pld: ContextMenuContributedSignalPayload = new ContextMenuContributedSignalPayload(
1505+
this.props.outputDescriptor.id,
1506+
ctxMenu
1507+
);
1508+
signalManager().fireContributeContextMenu(pld);
1509+
}
1510+
1511+
private _onContextMenuItemClicked = async (payload: ContextMenuItemClickedSignalPayload): Promise<void> => {
1512+
// handle item clicked payload and perform whatever function you need to based on the selection
1513+
// TODO: create generic API to execute command-handler for server driven actions
1514+
// For example, a pre-defined way to query additional query parameters that are passed to back-end calls (global filter)
1515+
1516+
if (payload?.getItemId() === 'org.eclipse.tracecompass.follow.thread.id') {
1517+
const items: { id: number; parentId?: number; metadata?: { [key: string]: unknown } }[] =
1518+
payload.getProps()['selectedRows'];
1519+
const item = items[0].id;
1520+
const parameters = QueryHelper.selectionQuery([item]);
1521+
const tspClientResponse = await this.props.tspClient.fetchTimeGraphTreeContext(
1522+
this.props.traceId,
1523+
this.props.outputDescriptor.id,
1524+
parameters
1525+
);
1526+
const model: { [key: string]: unknown } | undefined = tspClientResponse.getModel()?.model;
1527+
if (model) {
1528+
signalManager().fireTraceContexModelUpdated(model);
1529+
}
1530+
}
1531+
};
1532+
1533+
onModelUpdated = (model: { [key: string]: unknown }): void => {
1534+
// TODO add model as addtional parameters to back-end queries
1535+
this.additonalParameters = model;
1536+
};
14851537
}

theia-extensions/viewer-prototype/src/browser/theia-rpc-tsp-proxy.ts

+17
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,23 @@ export class TheiaRpcTspProxy implements ITspClient {
219219
);
220220
}
221221

222+
/**
223+
* Fetch Time Graph tree, Model is a key-value map
224+
* @param expUUID Experiment UUID
225+
* @param outputID Output ID
226+
* @param parameters Query object
227+
* @returns Time graph entry response with model is a key-value map
228+
*/
229+
public async fetchTimeGraphTreeContext(
230+
expUUID: string,
231+
outputID: string,
232+
parameters: Query
233+
): Promise<TspClientResponse<GenericResponse<{ [key: string]: unknown }>>> {
234+
return this.toTspClientResponse<GenericResponse<{ [key: string]: unknown }>>(
235+
await this.tspClient.fetchTimeGraphTreeContext(expUUID, outputID, parameters)
236+
);
237+
}
238+
222239
/**
223240
* Fetch Time Graph states. Model extends TimeGraphModel
224241
* @param expUUID Experiment UUID

0 commit comments

Comments
 (0)