Fixed some modal flaws (will break because of ts inter op which hasn't been commited)
parent
82cbfd9e45
commit
439ba5488e
|
@ -75,7 +75,7 @@ loader.register_task(Stage.JAVASCRIPT_INITIALIZING, {
|
||||||
throw "missing handler";
|
throw "missing handler";
|
||||||
}
|
}
|
||||||
|
|
||||||
modalClass = await registeredModal.classLoader();
|
modalClass = (await registeredModal.classLoader()).default;
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
loader.critical_error("Failed to load modal", "Lookup the console for more detail");
|
loader.critical_error("Failed to load modal", "Lookup the console for more detail");
|
||||||
console.error("Failed to load modal %s: %o", modalTarget, error);
|
console.error("Failed to load modal %s: %o", modalTarget, error);
|
||||||
|
|
|
@ -50,8 +50,7 @@ export class InternalModalController implements ModalController {
|
||||||
this.refModal = React.createRef();
|
this.refModal = React.createRef();
|
||||||
this.domElement = document.createElement("div");
|
this.domElement = document.createElement("div");
|
||||||
|
|
||||||
this.modalInstance = new (await this.modalType.classLoader())(...this.constructorArguments);
|
this.modalInstance = new (await this.modalType.classLoader()).default(...this.constructorArguments);
|
||||||
console.error(this.modalInstance);
|
|
||||||
const element = React.createElement(InternalModalRenderer, {
|
const element = React.createElement(InternalModalRenderer, {
|
||||||
ref: this.refModal,
|
ref: this.refModal,
|
||||||
modal: this.modalInstance,
|
modal: this.modalInstance,
|
||||||
|
|
|
@ -141,6 +141,7 @@ html:root {
|
||||||
justify-content: stretch;
|
justify-content: stretch;
|
||||||
|
|
||||||
padding: .25em;
|
padding: .25em;
|
||||||
|
@include user-select(none);
|
||||||
|
|
||||||
.icon, .button {
|
.icon, .button {
|
||||||
flex-grow: 0;
|
flex-grow: 0;
|
||||||
|
@ -155,6 +156,7 @@ html:root {
|
||||||
border-radius: .2em;
|
border-radius: .2em;
|
||||||
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
display: flex;
|
||||||
|
|
||||||
-webkit-app-region: no-drag;
|
-webkit-app-region: no-drag;
|
||||||
pointer-events: all;
|
pointer-events: all;
|
||||||
|
|
|
@ -26,7 +26,7 @@ export const InternalModalContentRenderer = React.memo((props: {
|
||||||
<div className={cssStyle.content + " " + props.containerClass} ref={props.refContent}>
|
<div className={cssStyle.content + " " + props.containerClass} ref={props.refContent}>
|
||||||
<div className={cssStyle.header + " " + props.headerClass}>
|
<div className={cssStyle.header + " " + props.headerClass}>
|
||||||
<div className={cssStyle.icon}>
|
<div className={cssStyle.icon}>
|
||||||
<img src="img/favicon/teacup.png" alt={tr("Modal - Icon")} />
|
<img src="img/favicon/teacup.png" alt={tr("Modal - Icon")} draggable={false} />
|
||||||
</div>
|
</div>
|
||||||
<div className={cssStyle.title + " " + props.headerTitleClass}>
|
<div className={cssStyle.title + " " + props.headerTitleClass}>
|
||||||
<ErrorBoundary>
|
<ErrorBoundary>
|
||||||
|
|
|
@ -8,6 +8,7 @@ import {InviteUiEvents, InviteUiVariables} from "tc-shared/ui/modal/invite/Defin
|
||||||
import {ReactElement} from "react";
|
import {ReactElement} from "react";
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import {IpcVariableDescriptor} from "tc-shared/ui/utils/IpcVariable";
|
import {IpcVariableDescriptor} from "tc-shared/ui/utils/IpcVariable";
|
||||||
|
import {ModalBookmarkEvents, ModalBookmarkVariables} from "tc-shared/ui/modal/bookmarks/Definitions";
|
||||||
|
|
||||||
export type ModalType = "error" | "warning" | "info" | "none";
|
export type ModalType = "error" | "warning" | "info" | "none";
|
||||||
export type ModalRenderType = "page" | "dialog";
|
export type ModalRenderType = "page" | "dialog";
|
||||||
|
@ -132,5 +133,9 @@ export interface ModalConstructorArguments {
|
||||||
/* events */ IpcRegistryDescription<InviteUiEvents>,
|
/* events */ IpcRegistryDescription<InviteUiEvents>,
|
||||||
/* variables */ IpcVariableDescriptor<InviteUiVariables>,
|
/* variables */ IpcVariableDescriptor<InviteUiVariables>,
|
||||||
/* serverName */ string
|
/* serverName */ string
|
||||||
|
],
|
||||||
|
"modal-bookmarks": [
|
||||||
|
/* events */ IpcRegistryDescription<ModalBookmarkEvents>,
|
||||||
|
/* variables */ IpcVariableDescriptor<ModalBookmarkVariables>,
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ import {ModalConstructorArguments} from "tc-shared/ui/react-elements/modal/Defin
|
||||||
|
|
||||||
export interface RegisteredModal<T extends keyof ModalConstructorArguments> {
|
export interface RegisteredModal<T extends keyof ModalConstructorArguments> {
|
||||||
modalId: T,
|
modalId: T,
|
||||||
classLoader: () => Promise<new (...args: ModalConstructorArguments[T]) => AbstractModal>,
|
classLoader: () => Promise<{ default: new (...args: ModalConstructorArguments[T]) => AbstractModal }>,
|
||||||
popoutSupported: boolean
|
popoutSupported: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,3 +73,9 @@ registerModal({
|
||||||
popoutSupported: true
|
popoutSupported: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
registerModal({
|
||||||
|
modalId: "modal-bookmarks",
|
||||||
|
classLoader: async () => await import("tc-shared/ui/modal/bookmarks/Renderer"),
|
||||||
|
popoutSupported: true
|
||||||
|
});
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ export function spawnReactModal<ModalClass extends InternalModal>(modalClass: ne
|
||||||
return new InternalModalController({
|
return new InternalModalController({
|
||||||
popoutSupported: false,
|
popoutSupported: false,
|
||||||
modalId: "__internal__unregistered",
|
modalId: "__internal__unregistered",
|
||||||
classLoader: async () => modalClass
|
classLoader: async () => ({ default: modalClass })
|
||||||
}, args);
|
}, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue