MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / buildTabContextMenu

Function buildTabContextMenu

frontend/app/tab/tabcontextmenu.ts:39–120  ·  view source on GitHub ↗
(
    id: string,
    renameRef: React.RefObject<(() => void) | null>,
    onClose: (event: React.MouseEvent<HTMLButtonElement, MouseEvent> | null) => void,
    env: TabEnv
)

Source from the content-addressed store, hash-verified

37}
38
39export function buildTabContextMenu(
40 id: string,
41 renameRef: React.RefObject<(() => void) | null>,
42 onClose: (event: React.MouseEvent<HTMLButtonElement, MouseEvent> | null) => void,
43 env: TabEnv
44): ContextMenuItem[] {
45 const menu: ContextMenuItem[] = [];
46 menu.push(
47 { label: "Rename Tab", click: () => renameRef.current?.() },
48 {
49 label: "Copy TabId",
50 click: () => fireAndForget(() => navigator.clipboard.writeText(id)),
51 },
52 { type: "separator" }
53 );
54 const tabORef = makeORef("tab", id);
55 const currentFlagColor = globalStore.get(getOrefMetaKeyAtom(tabORef, "tab:flagcolor")) ?? null;
56 const flagSubmenu: ContextMenuItem[] = [
57 {
58 label: "None",
59 type: "checkbox",
60 checked: currentFlagColor == null,
61 click: () =>
62 fireAndForget(() =>
63 env.rpc.SetMetaCommand(TabRpcClient, { oref: tabORef, meta: { "tab:flagcolor": null } })
64 ),
65 },
66 ...FlagColors.map((fc) => ({
67 label: fc.label,
68 type: "checkbox" as const,
69 checked: currentFlagColor === fc.value,
70 click: () =>
71 fireAndForget(() =>
72 env.rpc.SetMetaCommand(TabRpcClient, { oref: tabORef, meta: { "tab:flagcolor": fc.value } })
73 ),
74 })),
75 ];
76 menu.push({ label: "Flag Tab", type: "submenu", submenu: flagSubmenu }, { type: "separator" });
77 const fullConfig = globalStore.get(env.atoms.fullConfigAtom);
78 const backgrounds = fullConfig?.backgrounds ?? {};
79 const bgKeys = Object.keys(backgrounds).filter((k) => backgrounds[k] != null);
80 bgKeys.sort((a, b) => {
81 const aOrder = backgrounds[a]["display:order"] ?? 0;
82 const bOrder = backgrounds[b]["display:order"] ?? 0;
83 return aOrder - bOrder;
84 });
85 if (bgKeys.length > 0) {
86 const submenu: ContextMenuItem[] = [];
87 const oref = makeORef("tab", id);
88 submenu.push({
89 label: "Default",
90 click: () =>
91 fireAndForget(async () => {
92 await env.rpc.SetMetaCommand(TabRpcClient, {
93 oref,
94 meta: { "bg:*": true, "tab:background": null },
95 });
96 env.rpc.ActivityCommand(TabRpcClient, { settabtheme: 1 }, { noresponse: true });

Callers 2

tab.tsxFile · 0.90
VTabWrapperFunction · 0.90

Calls 9

fireAndForgetFunction · 0.90
makeORefFunction · 0.90
getOrefMetaKeyAtomFunction · 0.90
recordTEventFunction · 0.90
buildTabBarContextMenuFunction · 0.85
pushMethod · 0.80
getMethod · 0.80
SetMetaCommandMethod · 0.65
ActivityCommandMethod · 0.65

Tested by

no test coverage detected