MCPcopy
hub / github.com/callumalpass/tasknotes / ICSEventContextMenu

Class ICSEventContextMenu

src/components/ICSEventContextMenu.ts:21–334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19}
20
21export class ICSEventContextMenu {
22 private menu: ContextMenu;
23 private options: ICSEventContextMenuOptions;
24
25 constructor(options: ICSEventContextMenuOptions) {
26 this.menu = new ContextMenu();
27 this.options = options;
28 this.buildMenu();
29 }
30
31 private t(key: string, params?: Record<string, string | number>): string {
32 return this.options.plugin.i18n.translate(key, params);
33 }
34
35 private getLocale(): string {
36 return this.options.plugin.i18n.getCurrentLocale() || "en";
37 }
38
39 private buildMenu(): void {
40 const { icsEvent, plugin, subscriptionName } = this.options;
41
42 // Show details option
43 this.menu.addItem((item) =>
44 item
45 .setTitle(this.t("contextMenus.ics.showDetails"))
46 .setIcon("info")
47 .onClick(() => {
48 const modal = new ICSEventInfoModal(
49 plugin.app,
50 plugin,
51 icsEvent,
52 subscriptionName
53 );
54 modal.open();
55 })
56 );
57
58 this.menu.addSeparator();
59
60 // Create task from event
61 this.menu.addItem((item) =>
62 item
63 .setTitle(this.t("contextMenus.ics.createTask"))
64 .setIcon("check-circle")
65 .onClick(async () => {
66 await this.createTaskFromEvent();
67 })
68 );
69
70 // Create note from event
71 this.menu.addItem((item) =>
72 item
73 .setTitle(this.t("contextMenus.ics.createNote"))
74 .setIcon("file-plus")
75 .onClick(() => {
76 this.createNoteFromEvent();
77 })
78 );

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected