Adjusted the connect modal to be optionally popoutable

master
WolverinDEV 2021-01-22 14:45:23 +01:00
parent 16ad080df9
commit 3958fb29b4
3 changed files with 15 additions and 16 deletions

View File

@ -4,7 +4,6 @@ import {
ConnectUiVariables, ConnectUiVariables,
} from "tc-shared/ui/modal/connect/Definitions"; } from "tc-shared/ui/modal/connect/Definitions";
import {spawnReactModal} from "tc-shared/ui/react-elements/Modal"; import {spawnReactModal} from "tc-shared/ui/react-elements/Modal";
import {ConnectModal} from "tc-shared/ui/modal/connect/Renderer";
import {LogCategory, logError, logWarn} from "tc-shared/log"; import {LogCategory, logError, logWarn} from "tc-shared/log";
import { import {
availableConnectProfiles, availableConnectProfiles,
@ -21,8 +20,9 @@ import {parseServerAddress} from "tc-shared/tree/Server";
import {spawnSettingsModal} from "tc-shared/ui/modal/ModalSettings"; import {spawnSettingsModal} from "tc-shared/ui/modal/ModalSettings";
import * as ipRegex from "ip-regex"; import * as ipRegex from "ip-regex";
import {UiVariableProvider} from "tc-shared/ui/utils/Variable"; import {UiVariableProvider} from "tc-shared/ui/utils/Variable";
import {createLocalUiVariables} from "tc-shared/ui/utils/LocalVariable";
import {createIpcUiVariableProvider} from "tc-shared/ui/utils/IpcVariable"; import {createIpcUiVariableProvider} from "tc-shared/ui/utils/IpcVariable";
import {spawnExternalModal} from "tc-shared/ui/react-elements/external-modal";
import ConnectModal = require("tc-shared/ui/modal/connect/Renderer");
const kRegexDomain = /^(localhost|((([a-zA-Z0-9_-]{0,63}\.){0,253})?[a-zA-Z0-9_-]{0,63}\.[a-zA-Z]{2,64}))$/i; const kRegexDomain = /^(localhost|((([a-zA-Z0-9_-]{0,63}\.){0,253})?[a-zA-Z0-9_-]{0,63}\.[a-zA-Z]{2,64}))$/i;
@ -356,10 +356,10 @@ export function spawnConnectModalNew(options: ConnectModalOptions) {
controller.setSelectedProfile(options.selectedProfile); controller.setSelectedProfile(options.selectedProfile);
} }
const modal = spawnReactModal(ConnectModal, controller.uiEvents, variableProvider.generateConsumerDescription(), options.connectInANewTab || false); const modal = spawnReactModal(ConnectModal, controller.uiEvents.generateIpcDescription(), variableProvider.generateConsumerDescription(), options.connectInANewTab || false);
//const modal = spawnExternalModal("modal-connect", [controller.uiEvents.generateIpcDescription(), variableProvider.generateConsumerDescription(), options.connectInANewTab || false]);
modal.show(); modal.show();
modal.getEvents().one("destroy", () => {
modal.events.one("destroy", () => {
controller.destroy(); controller.destroy();
}); });

View File

@ -1,6 +1,6 @@
import {kUnknownHistoryServerUniqueId} from "tc-shared/connectionlog/History";
import {RemoteIconInfo} from "tc-shared/file/Icons"; import {RemoteIconInfo} from "tc-shared/file/Icons";
export const kUnknownHistoryServerUniqueId = "unknown";
export type ConnectProfileEntry = { export type ConnectProfileEntry = {
id: string, id: string,
name: string, name: string,

View File

@ -1,16 +1,14 @@
import { import {
ConnectHistoryEntry, ConnectHistoryEntry,
ConnectUiEvents, ConnectUiVariables, ConnectUiEvents, ConnectUiVariables, kUnknownHistoryServerUniqueId,
} from "tc-shared/ui/modal/connect/Definitions"; } from "tc-shared/ui/modal/connect/Definitions";
import * as React from "react"; import * as React from "react";
import {useContext} from "react"; import {useContext} from "react";
import {Registry} from "tc-shared/events"; import {IpcRegistryDescription, Registry} from "tc-shared/events";
import {InternalModal} from "tc-shared/ui/react-elements/internal-modal/Controller";
import {Translatable} from "tc-shared/ui/react-elements/i18n";
import {ControlledFlatInputField, ControlledSelect, FlatInputField} from "tc-shared/ui/react-elements/InputField";
import {joinClassList, useTr} from "tc-shared/ui/react-elements/Helper"; import {joinClassList, useTr} from "tc-shared/ui/react-elements/Helper";
import {Translatable} from "tc-shared/ui/react-elements/i18n";
import {Button} from "tc-shared/ui/react-elements/Button"; import {Button} from "tc-shared/ui/react-elements/Button";
import {kUnknownHistoryServerUniqueId} from "tc-shared/connectionlog/History"; import {ControlledFlatInputField, ControlledSelect, FlatInputField} from "tc-shared/ui/react-elements/InputField";
import {ClientIconRenderer} from "tc-shared/ui/react-elements/Icons"; import {ClientIconRenderer} from "tc-shared/ui/react-elements/Icons";
import {ClientIcon} from "svg-sprites/client-icons"; import {ClientIcon} from "svg-sprites/client-icons";
import * as i18n from "../../../i18n/country"; import * as i18n from "../../../i18n/country";
@ -385,16 +383,16 @@ const HistoryContainer = () => {
) )
} }
export class ConnectModal extends AbstractModal { class ConnectModal extends AbstractModal {
private readonly events: Registry<ConnectUiEvents>; private readonly events: Registry<ConnectUiEvents>;
private readonly variables: UiVariableConsumer<ConnectUiVariables>; private readonly variables: UiVariableConsumer<ConnectUiVariables>;
private readonly connectNewTabByDefault: boolean; private readonly connectNewTabByDefault: boolean;
constructor(events: Registry<ConnectUiEvents>, variables: IpcVariableDescriptor<ConnectUiVariables>, connectNewTabByDefault: boolean) { constructor(events: IpcRegistryDescription<ConnectUiEvents>, variables: IpcVariableDescriptor<ConnectUiVariables>, connectNewTabByDefault: boolean) {
super(); super();
this.variables = createIpcUiVariableConsumer(variables); this.variables = createIpcUiVariableConsumer(variables);
this.events = events; this.events = Registry.fromIpcDescription(events);
this.connectNewTabByDefault = connectNewTabByDefault; this.connectNewTabByDefault = connectNewTabByDefault;
} }
@ -431,4 +429,5 @@ export class ConnectModal extends AbstractModal {
verticalAlignment(): "top" | "center" | "bottom" { verticalAlignment(): "top" | "center" | "bottom" {
return "top"; return "top";
} }
} }
export = ConnectModal;