diff --git a/packages/base/src/signal-manager.ts b/packages/base/src/signal-manager.ts index a9001adac..7bb8ededf 100644 --- a/packages/base/src/signal-manager.ts +++ b/packages/base/src/signal-manager.ts @@ -3,7 +3,7 @@ import { Experiment } from 'tsp-typescript-client/lib/models/experiment'; export declare interface SignalManager { - fireTooltipSignal(tooltip: { [key: string]: string }): void; + fireTooltipSignal(tooltip?: { [key: string]: string }): void; fireThemeChangedSignal(theme: string): void; fireSelectionChangedSignal(payload: { [key: string]: string }): void; fireCloseTraceViewerTabSignal(traceUUID: string): void; @@ -25,7 +25,7 @@ export const Signals = { export class SignalManager extends EventEmitter implements SignalManager { - fireTooltipSignal(tooltip: { [key: string]: string; }): void { + fireTooltipSignal(tooltip?: { [key: string]: string; }): void { this.emit(Signals.TOOLTIP_UPDATED, { tooltip }); } diff --git a/theia-extensions/viewer-prototype/src/browser/trace-explorer/trace-explorer-sub-widgets/trace-explorer-tooltip-widget.tsx b/theia-extensions/viewer-prototype/src/browser/trace-explorer/trace-explorer-sub-widgets/trace-explorer-tooltip-widget.tsx index 7aad3c5db..34a725841 100644 --- a/theia-extensions/viewer-prototype/src/browser/trace-explorer/trace-explorer-sub-widgets/trace-explorer-tooltip-widget.tsx +++ b/theia-extensions/viewer-prototype/src/browser/trace-explorer/trace-explorer-sub-widgets/trace-explorer-tooltip-widget.tsx @@ -8,11 +8,11 @@ import { Signals, signalManager } from '@trace-viewer/base/lib/signal-manager'; @injectable() export class TraceExplorerTooltipWidget extends ReactWidget { static ID = 'trace-explorer-tooltip-widget'; - static LABEL = 'Time Graph Tooltip'; + static LABEL = 'Item Properties'; @inject(EditorManager) protected readonly editorManager!: EditorManager; - tooltip: { [key: string]: string } = {}; + tooltip?: { [key: string]: string } = undefined; @postConstruct() init(): void { @@ -30,10 +30,9 @@ export class TraceExplorerTooltipWidget extends ReactWidget { private renderTooltip() { const tooltipArray: JSX.Element[] = []; if (this.tooltip) { - const keys = Object.keys(this.tooltip); - keys.forEach(key => { + Object.entries(this.tooltip).forEach(([key, value]) => { if (key === 'Source') { - const sourceCodeInfo = this.tooltip[key]; + const sourceCodeInfo = value; const matches = sourceCodeInfo.match('(.*):(\\d+)'); let fileLocation; let line; @@ -47,9 +46,11 @@ export class TraceExplorerTooltipWidget extends ReactWidget { data-id={JSON.stringify({ fileLocation, line })} >{key + ': ' + sourceCodeInfo}
); } else { - tooltipArray.push({key + ': ' + this.tooltip[key]}
); + tooltipArray.push({key + ': ' + value}
); } }); + } else { + tooltipArray.push(Select item to view properties
); } return ( @@ -111,7 +112,7 @@ export class TraceExplorerTooltipWidget extends ReactWidget { ); } - private onTooltip(tooltip: { [key: string]: string }) { + private onTooltip(tooltip?: { [key: string]: string }) { this.tooltip = tooltip; this.update(); }