Files
flipper/desktop/plugins/public/ui-debugger/utils/tracker.tsx
Luke De Feo ce1fdfdf19 Added context menu items for collapsing and expanding nodes
Summary:
Added 3 context menu items:
- expand recursive
- collapse recursive

These are self explanatory.

I also collapse non ancestors. This collapses everything except your direct ancestor path to the root. Quite useful to refocus the tree on a node

Changelog: UIDebugger - added  context menu items for exanding and collapsing the tree.

Reviewed By: aigoncharov

Differential Revision: D47949840

fbshipit-source-id: 6eebba182fe2092fbf5f0db0ec5ff728c3900424
2023-08-01 10:32:29 -07:00

86 lines
1.8 KiB
TypeScript

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
import {getFlipperLib} from 'flipper-plugin';
import {FrameworkEventType, Tag} from '../ClientTypes';
import {SelectionSource} from '../DesktopTypes';
const UI_DEBUGGER_IDENTIFIER = 'ui-debugger';
type NodeEventPayload = {
name: string;
tags: Tag[];
source?: SelectionSource;
};
type TrackerEvents = {
'more-options-opened': {};
'context-menu-opened': {};
'play-pause-toggled': {
paused: boolean;
};
'framework-event-monitored': {
eventType: FrameworkEventType;
monitored: boolean;
};
'search-term-updated': {
searchTerm: string;
};
'node-selected': NodeEventPayload;
'node-focused': NodeEventPayload;
'context-menu-name-copied': {
name: string;
};
'context-menu-copied': {
name: string;
key: string;
value: string;
};
'big-grep-searched': {
searchTerm: string;
tags: Tag[];
};
'ide-opened': {
ide: string;
name: string;
tags: Tag[];
};
'target-mode-switched': {
on: boolean;
};
'target-mode-adjusted': {};
'context-menu-expand-recursive': {};
'context-menu-collapse-recursive': {};
'context-menu-collapse-non-ancestors': {};
};
export interface Tracker {
track<Event extends keyof TrackerEvents>(
event: Event,
payload: TrackerEvents[Event],
): void;
}
class UIDebuggerTracker implements Tracker {
track<Event extends keyof TrackerEvents>(
event: Event,
payload: TrackerEvents[Event],
): void {
getFlipperLib().logger.track(
'usage',
event,
payload,
UI_DEBUGGER_IDENTIFIER,
);
}
}
export const tracker: Tracker = new UIDebuggerTracker();