From 30357018c4096f8a63e2ba79f057ecf4952cecd5 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Wed, 30 Sep 2020 20:28:30 +0200 Subject: [PATCH] Enabled remote channel trees --- file.ts | 1 + shared/js/tree/ChannelTree.tsx | 19 ---- .../{context-menu/index.ts => ContextMenu.ts} | 4 +- shared/js/ui/elements/ContextMenu.ts | 2 +- shared/js/ui/frames/control-bar/Renderer.tsx | 2 +- .../external-modal/PopoutEntrypoint.ts | 1 - web/app/index.ts | 2 +- {shared/js => web/app}/ui/context-menu/Ipc.ts | 5 +- .../app}/ui/context-menu/ReactRenderer.scss | 0 .../app}/ui/context-menu/ReactRenderer.tsx | 88 +------------------ web/app/ui/context-menu/index.ts | 1 + 11 files changed, 9 insertions(+), 116 deletions(-) rename shared/js/ui/{context-menu/index.ts => ContextMenu.ts} (97%) rename {shared/js => web/app}/ui/context-menu/Ipc.ts (97%) rename {shared/js => web/app}/ui/context-menu/ReactRenderer.scss (100%) rename {shared/js => web/app}/ui/context-menu/ReactRenderer.tsx (69%) create mode 100644 web/app/ui/context-menu/index.ts diff --git a/file.ts b/file.ts index fcb84027..5c36d422 100644 --- a/file.ts +++ b/file.ts @@ -314,6 +314,7 @@ namespace server { } async function serve_file(pathname: string, response: http.ServerResponse) { + if(pathname.startsWith("//")) { pathname = pathname.substring(1); } const file = await generator.search_http_file(files, pathname, options.search_options); if(!file) { console.log("[SERVER] Client requested unknown file %s", pathname); diff --git a/shared/js/tree/ChannelTree.tsx b/shared/js/tree/ChannelTree.tsx index 19402d1f..0fd3f09b 100644 --- a/shared/js/tree/ChannelTree.tsx +++ b/shared/js/tree/ChannelTree.tsx @@ -382,25 +382,6 @@ export class ChannelTree { renderChannelTree(this, this.tagContainer[0], { popoutButton: true }); this.reset(); - - if(!settings.static(Settings.KEY_DISABLE_CONTEXT_MENU, false)) { - /* - TODO: Show the context menu when clicked on no channel - this._tag_container.on("contextmenu", (event) => { - event.preventDefault(); - - const entry = this.view.current?.getEntryFromPoint(event.pageX, event.pageY); - if(entry) { - if(this.selection.is_multi_select()) { - this.open_multiselect_context_menu(this.selection.selected_entries, event.pageX, event.pageY); - } - } else { - this.selection.clear_selection(); - this.showContextMenu(event.pageX, event.pageY); - } - }); - */ - } } tag_tree() : JQuery { diff --git a/shared/js/ui/context-menu/index.ts b/shared/js/ui/ContextMenu.ts similarity index 97% rename from shared/js/ui/context-menu/index.ts rename to shared/js/ui/ContextMenu.ts index fc1b621a..651f5f10 100644 --- a/shared/js/ui/context-menu/index.ts +++ b/shared/js/ui/ContextMenu.ts @@ -1,14 +1,12 @@ import {RemoteIcon} from "tc-shared/file/Icons"; import {ClientIcon} from "svg-sprites/client-icons"; -import "./Ipc"; - export type MenuEntryLabel = { text: string, bold?: boolean; } | string; -type MenuEntryClickable = { +export type MenuEntryClickable = { uniqueId?: string, label: MenuEntryLabel, diff --git a/shared/js/ui/elements/ContextMenu.ts b/shared/js/ui/elements/ContextMenu.ts index 7065409d..6e37a5e2 100644 --- a/shared/js/ui/elements/ContextMenu.ts +++ b/shared/js/ui/elements/ContextMenu.ts @@ -1,4 +1,4 @@ -import {closeContextMenu, ContextMenuEntry, spawnContextMenu} from "tc-shared/ui/context-menu"; +import {closeContextMenu, ContextMenuEntry, spawnContextMenu} from "tc-shared/ui/ContextMenu"; import {ClientIcon} from "svg-sprites/client-icons"; export interface MenuEntry { diff --git a/shared/js/ui/frames/control-bar/Renderer.tsx b/shared/js/ui/frames/control-bar/Renderer.tsx index 86927322..6d5e3cec 100644 --- a/shared/js/ui/frames/control-bar/Renderer.tsx +++ b/shared/js/ui/frames/control-bar/Renderer.tsx @@ -11,7 +11,7 @@ import {useContext, useRef, useState} from "react"; import {DropdownEntry} from "tc-shared/ui/frames/control-bar/DropDown"; import {Translatable} from "tc-shared/ui/react-elements/i18n"; import {Button} from "tc-shared/ui/frames/control-bar/Button"; -import {spawnContextMenu} from "tc-shared/ui/context-menu"; +import {spawnContextMenu} from "tc-shared/ui/ContextMenu"; import {ClientIcon} from "svg-sprites/client-icons"; const cssStyle = require("./Renderer.scss"); diff --git a/shared/js/ui/react-elements/external-modal/PopoutEntrypoint.ts b/shared/js/ui/react-elements/external-modal/PopoutEntrypoint.ts index f96e6a30..2cc55111 100644 --- a/shared/js/ui/react-elements/external-modal/PopoutEntrypoint.ts +++ b/shared/js/ui/react-elements/external-modal/PopoutEntrypoint.ts @@ -14,7 +14,6 @@ import {setupJSRender} from "../../../ui/jsrender"; import "../../../file/RemoteAvatars"; import "../../../file/RemoteIcons"; -import "../../context-menu"; let modalRenderer: ModalRenderer; let modalInstance: AbstractModal; diff --git a/web/app/index.ts b/web/app/index.ts index a2f50861..eb97d86c 100644 --- a/web/app/index.ts +++ b/web/app/index.ts @@ -12,7 +12,7 @@ import "./hooks/AudioRecorder"; import "./UnloadHandler"; - +import "./ui/context-menu"; import "./ui/FaviconRenderer"; export = require("tc-shared/main"); \ No newline at end of file diff --git a/shared/js/ui/context-menu/Ipc.ts b/web/app/ui/context-menu/Ipc.ts similarity index 97% rename from shared/js/ui/context-menu/Ipc.ts rename to web/app/ui/context-menu/Ipc.ts index 96eb3339..dcad3e97 100644 --- a/shared/js/ui/context-menu/Ipc.ts +++ b/web/app/ui/context-menu/Ipc.ts @@ -5,11 +5,10 @@ import { ContextMenuEntry, ContextMenuFactory, setGlobalContextMenuFactory -} from "tc-shared/ui/context-menu/index"; +} from "tc-shared/ui/ContextMenu"; import {ChannelMessage, IPCChannel} from "tc-shared/ipc/BrowserIPC"; import * as ipc from "tc-shared/ipc/BrowserIPC"; -import {Settings} from "tc-shared/settings"; -import {reactContextMenuInstance} from "tc-shared/ui/context-menu/ReactRenderer"; +import {reactContextMenuInstance} from "./ReactRenderer"; import {getIconManager, RemoteIcon} from "tc-shared/file/Icons"; const kIPCContextMenuChannel = "context-menu"; diff --git a/shared/js/ui/context-menu/ReactRenderer.scss b/web/app/ui/context-menu/ReactRenderer.scss similarity index 100% rename from shared/js/ui/context-menu/ReactRenderer.scss rename to web/app/ui/context-menu/ReactRenderer.scss diff --git a/shared/js/ui/context-menu/ReactRenderer.tsx b/web/app/ui/context-menu/ReactRenderer.tsx similarity index 69% rename from shared/js/ui/context-menu/ReactRenderer.tsx rename to web/app/ui/context-menu/ReactRenderer.tsx index e96e9888..50d168da 100644 --- a/shared/js/ui/context-menu/ReactRenderer.tsx +++ b/web/app/ui/context-menu/ReactRenderer.tsx @@ -5,7 +5,7 @@ import { ContextMenuEntry, ContextMenuEntryNormal, ContextMenuFactory, MenuEntryLabel, -} from "tc-shared/ui/context-menu/index"; +} from "tc-shared/ui/ContextMenu"; import * as React from "react"; import * as ReactDOM from "react-dom"; import {IconRenderer, RemoteIconRenderer} from "tc-shared/ui/react-elements/Icon"; @@ -189,91 +189,5 @@ loader.register_task(Stage.JAVASCRIPT_INITIALIZING, { } } }; - - /* - setTimeout(() => { - spawnContextMenu({ pageX: 100, pageY: 100 }, [ - { - type: "normal", - label: { text: "test", bold: true }, - icon: ClientIcon.IsTalker - }, - { - type: "normal", - label: "test 2", - icon: ClientIcon.ServerGreen - }, - { - type: "separator" - }, - { - type: "normal", - label: "test 3", - subMenu: [ - { - type: "checkbox", - label: "test - cb", - checked: false - }, - { - type: "checkbox", - label: "test - cb 1", - checked: true - } - ] - }, - { - type: "normal", - label: "test 4", - subMenu: [ - { - type: "normal", - label: "test 1", - icon: ClientIcon.IsTalker - }, - { - type: "normal", - label: "test 2", - icon: ClientIcon.ServerGreen - }, - { - type: "separator" - }, - { - type: "normal", - label: "test 3" - }, - { - type: "normal", - label: "test 4", - subMenu: [ - { - type: "normal", - label: "test 1", - icon: ClientIcon.IsTalker - }, - { - type: "normal", - label: "test 2", - icon: ClientIcon.ServerGreen - }, - { - type: "separator" - }, - { - type: "normal", - label: "test 3" - }, - { - type: "normal", - label: "test 4" - } - ] - } - ] - } - ]); - }, 1000); - */ } }) diff --git a/web/app/ui/context-menu/index.ts b/web/app/ui/context-menu/index.ts new file mode 100644 index 00000000..b17204ba --- /dev/null +++ b/web/app/ui/context-menu/index.ts @@ -0,0 +1 @@ +import "./Ipc.ts"; \ No newline at end of file