Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for multi row select and context menu in Timegraph Component #1044

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/***************************************************************************************
* Copyright (c) 2024 BlackBerry Limited and contributors.
*
* Licensed under the MIT license. See LICENSE file in the project root for details.
***************************************************************************************/
export interface MenuItem {
id: string;
label: string;
// Parent Menu that this item belongs to - undefined indicates root menu item
parentMenuId?: string;
}

export interface SubMenu {
id: string;
label: string;
items: MenuItem[];
submenu: SubMenu | undefined;
}

export interface ContextMenuItems {
submenus: SubMenu[];
items: MenuItem[];
}

export class ContextMenuContributedSignalPayload {
private outputDescriptorId: string;
private menuItems: ContextMenuItems;

constructor(descriptorId: string, menuItems: ContextMenuItems) {
this.outputDescriptorId = descriptorId;
this.menuItems = menuItems;
}

public getOutputDescriptorId(): string {
return this.outputDescriptorId;
}

public getMenuItems(): ContextMenuItems {
return this.menuItems;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/***************************************************************************************
* Copyright (c) 2024 BlackBerry Limited and contributors.
*
* Licensed under the MIT license. See LICENSE file in the project root for details.
***************************************************************************************/
/* eslint-disable @typescript-eslint/no-explicit-any */
export class ContextMenuItemClickedSignalPayload {
private outputDescriptorId: string;
private itemId: string;
private parentMenuId: string | undefined;
private props: { [key: string]: any };

constructor(descriptorId: string, itemId: string, props: { [key: string]: any }, parentMenuId?: string) {
this.outputDescriptorId = descriptorId;
this.itemId = itemId;
this.props = props;
this.parentMenuId = parentMenuId;
}

public getOutputDescriptorId(): string {
return this.outputDescriptorId;
}

public getItemId(): string {
return this.itemId;
}

public getProps(): { [key: string]: any } {
return this.props;
}

public getParentMenuId(): string | undefined {
return this.parentMenuId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/***************************************************************************************
* Copyright (c) 2024 BlackBerry Limited and contributors.
*
* Licensed under the MIT license. See LICENSE file in the project root for details.
***************************************************************************************/
/* eslint-disable @typescript-eslint/no-explicit-any */
export class RowSelectionsChangedSignalPayload {
private traceId: string;
private outputDescriptorId: string;
private rows: { id: number; parentId?: number; metadata?: { [key: string]: any } }[];

constructor(
traceId: string,
descriptorId: string,
rows: { id: number; parentId?: number; metadata?: { [key: string]: any } }[]
) {
this.outputDescriptorId = descriptorId;
this.traceId = traceId;
this.rows = rows;
}

public getOutputDescriptorId(): string {
return this.outputDescriptorId;
}

public getTraceId(): string {
return this.traceId;
}

public getRows(): { id: number; parentId?: number; metadata?: { [key: string]: any } }[] {
return this.rows;
}
}
21 changes: 20 additions & 1 deletion packages/base/src/signals/signal-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { Trace } from 'tsp-typescript-client/lib/models/trace';
import { OpenedTracesUpdatedSignalPayload } from './opened-traces-updated-signal-payload';
import { OutputAddedSignalPayload } from './output-added-signal-payload';
import { TimeRangeUpdatePayload } from './time-range-data-signal-payloads';
import { ContextMenuContributedSignalPayload } from './context-menu-contributed-signal-payload';
import { ContextMenuItemClickedSignalPayload } from './context-menu-item-clicked-signal-payload';
import { RowSelectionsChangedSignalPayload } from './row-selections-changed-signal-payload';

export declare interface SignalManager {
fireTraceOpenedSignal(trace: Trace): void;
Expand All @@ -20,6 +23,7 @@ export declare interface SignalManager {
fireThemeChangedSignal(theme: string): void;
// TODO - Refactor or remove this signal. Similar signal to fireRequestSelectionRangeChange
fireSelectionChangedSignal(payload: { [key: string]: string }): void;
fireRowSelectionsChanged(payload: RowSelectionsChangedSignalPayload): void;
fireCloseTraceViewerTabSignal(traceUUID: string): void;
fireTraceViewerTabActivatedSignal(experiment: Experiment): void;
fireUpdateZoomSignal(hasZoomedIn: boolean): void;
Expand All @@ -41,6 +45,8 @@ export declare interface SignalManager {
fireSelectionRangeUpdated(payload: TimeRangeUpdatePayload): void;
fireViewRangeUpdated(payload: TimeRangeUpdatePayload): void;
fireRequestSelectionRangeChange(payload: TimeRangeUpdatePayload): void;
fireContributeContextMenu(payload: ContextMenuContributedSignalPayload): void;
fireContextMenuItemClicked(payload: ContextMenuItemClickedSignalPayload): void;
}

export const Signals = {
Expand All @@ -57,6 +63,7 @@ export const Signals = {
ITEM_PROPERTIES_UPDATED: 'item properties updated',
THEME_CHANGED: 'theme changed',
SELECTION_CHANGED: 'selection changed',
ROW_SELECTIONS_CHANGED: 'rows selected changed',
CLOSE_TRACEVIEWERTAB: 'tab closed',
TRACEVIEWERTAB_ACTIVATED: 'widget activated',
UPDATE_ZOOM: 'update zoom',
Expand All @@ -75,7 +82,9 @@ export const Signals = {
VIEW_RANGE_UPDATED: 'view range updated',
SELECTION_RANGE_UPDATED: 'selection range updated',
REQUEST_SELECTION_RANGE_CHANGE: 'change selection range',
OUTPUT_DATA_CHANGED: 'output data changed'
OUTPUT_DATA_CHANGED: 'output data changed',
CONTRIBUTE_CONTEXT_MENU: 'contribute context menu',
CONTEXT_MENU_ITEM_CLICKED: 'context menu item clicked'
};

export class SignalManager extends EventEmitter implements SignalManager {
Expand All @@ -97,6 +106,10 @@ export class SignalManager extends EventEmitter implements SignalManager {
fireExperimentSelectedSignal(experiment: Experiment | undefined): void {
this.emit(Signals.EXPERIMENT_SELECTED, experiment);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
fireRowSelectionsChanged(payload: RowSelectionsChangedSignalPayload): void {
this.emit(Signals.ROW_SELECTIONS_CHANGED, payload);
}
fireExperimentUpdatedSignal(experiment: Experiment): void {
this.emit(Signals.EXPERIMENT_UPDATED, experiment);
}
Expand Down Expand Up @@ -174,6 +187,12 @@ export class SignalManager extends EventEmitter implements SignalManager {
fireRequestSelectionRangeChange(payload: TimeRangeUpdatePayload): void {
this.emit(Signals.REQUEST_SELECTION_RANGE_CHANGE, payload);
}
fireContributeContextMenu(payload: ContextMenuContributedSignalPayload): void {
this.emit(Signals.CONTRIBUTE_CONTEXT_MENU, payload);
}
fireContextMenuItemClicked(payload: ContextMenuItemClickedSignalPayload): void {
this.emit(Signals.CONTEXT_MENU_ITEM_CLICKED, payload);
}
}

let instance: SignalManager = new SignalManager();
Expand Down
Loading
Loading