Skip to content

Commit

Permalink
Change trace-explorer-tooltip-widget title
Browse files Browse the repository at this point in the history
Change the title from 'Time Graph Tooltip' to 'Item Properties'.

Use a default message when there is no tooltip information available.

Allow TOOLTIP_UPDATED signal to carry undefined tooltip to clear.

Signed-off-by: Patrick Tasse <patrick.tasse@ericsson.com>
  • Loading branch information
PatrickTasse committed Mar 25, 2021
1 parent fa979ba commit 9866a80
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions packages/base/src/signal-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 });
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
Expand All @@ -47,9 +46,11 @@ export class TraceExplorerTooltipWidget extends ReactWidget {
data-id={JSON.stringify({ fileLocation, line })}
>{key + ': ' + sourceCodeInfo}</p>);
} else {
tooltipArray.push(<p key={key}>{key + ': ' + this.tooltip[key]}</p>);
tooltipArray.push(<p key={key}>{key + ': ' + value}</p>);
}
});
} else {
tooltipArray.push(<p><i>Select item to view properties</i></p>);
}

return (
Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit 9866a80

Please sign in to comment.