From e80dba9414c0b6454b414d9cdf2a77307e37ebae Mon Sep 17 00:00:00 2001 From: Jason Robinson Date: Fri, 15 Jan 2021 15:32:30 +0200 Subject: [PATCH] WIP --- res/css/views/dialogs/_HostSignupDialog.scss | 96 ++++++++--- src/components/structures/UserMenu.tsx | 5 +- .../views/dialogs/HostSignupDialog.tsx | 157 +++++++++++++----- .../views/dialogs/HostSignupDialogTypes.tsx | 41 +++++ 4 files changed, 238 insertions(+), 61 deletions(-) diff --git a/res/css/views/dialogs/_HostSignupDialog.scss b/res/css/views/dialogs/_HostSignupDialog.scss index 130fdb44a6..316b7bc06c 100644 --- a/res/css/views/dialogs/_HostSignupDialog.scss +++ b/res/css/views/dialogs/_HostSignupDialog.scss @@ -15,16 +15,88 @@ limitations under the License. */ .mx_HostSignupDialog { + min-height: 531px; max-height: 600px; width: 580px; .mx_HostSignupDialog_info { text-align: center; - .mx_HostSignupDialog_content { - margin-top: 64px; - margin-bottom: 45px; + .mx_HostSignupDialog_content_top { + margin-bottom: 24px; } + + .mx_HostSignupDialog_paragraphs { + text-align: left; + padding-left: 25%; + padding-right: 25%; + } + + .mx_HostSignupDialog_buttons { + margin-bottom: 24px; + + button { + padding: 12px; + } + } + } + + iframe { + width: 100%; + height: 100%; + border: none; + background-color: #fff; + min-height: 500px; + } +} + +.mx_HostSignupDialog_text_dark { + color: $primary-fg-color; +} + +.mx_HostSignupDialog_text_light { + color: $secondary-fg-color; +} + +.mx_HostSignup_maximize_button { + mask: url('$(res)/img/feather-customised/widget/maximise.svg'); + mask-repeat: no-repeat; + mask-position: center; + mask-size: cover; + width: 14px; + height: 14px; + background-color: $dialog-close-fg-color; + cursor: pointer; + position: absolute; + top: 10px; + right: 10px; +} + +.mx_HostSignup_persisted { + width: 580px; + height: 600px; + top: 0; + left: 0; + position: fixed; + display: none; +} + +.mx_HostSignupDialog_minimized { + position: fixed; + bottom: 80px; + right: 26px; + width: 314px; + height: 217px; + overflow: hidden; + + &.mx_Dialog { + padding: 12px; + } + + .mx_Dialog_title { + text-align: left !important; + padding-left: 20px; + font-size: $font-15px; } iframe { @@ -34,21 +106,3 @@ limitations under the License. background-color: #fff; } } - -.mx_HostSignup_persisted { - width: 580px; - height: 600px; - top: 0; - left: 0; - position: fixed; -} - -.mx_HostSignupDialog_minimized { - position: fixed; - bottom: 100px; - right: 100px; - width: 200px; - height: 120px; - overflow: hidden; - z-index: 6000; -} diff --git a/src/components/structures/UserMenu.tsx b/src/components/structures/UserMenu.tsx index 31994c4fad..296642a8d9 100644 --- a/src/components/structures/UserMenu.tsx +++ b/src/components/structures/UserMenu.tsx @@ -52,6 +52,7 @@ import ErrorDialog from "../views/dialogs/ErrorDialog"; import EditCommunityPrototypeDialog from "../views/dialogs/EditCommunityPrototypeDialog"; import {UIFeature} from "../../settings/UIFeature"; import HostSignupAction from "./HostSignupAction"; +import {IHostSignupConfig} from "../views/dialogs/HostSignupDialogTypes"; interface IProps { isMinimized: boolean; @@ -274,7 +275,7 @@ export default class UserMenu extends React.Component { let topSection; const signupLink = getHostingLink("user-context-menu"); - const hostSignupConfig = SdkConfig.get().host_signup; + const hostSignupConfig: IHostSignupConfig = SdkConfig.get().hostSignup; if (MatrixClientPeg.get().isGuest()) { topSection = (
@@ -297,7 +298,7 @@ export default class UserMenu extends React.Component { } else if (signupLink || hostSignupConfig) { let hostSignupAction; if (hostSignupConfig && hostSignupConfig.url) { - // If host_signup.domains is set to a non-empty array, only show + // If hostSignup.domains is set to a non-empty array, only show // dialog if the user is on the domain or a subdomain. const hostSignupDomains = hostSignupConfig.domains || []; const mxDomain = MatrixClientPeg.get().getDomain(); diff --git a/src/components/views/dialogs/HostSignupDialog.tsx b/src/components/views/dialogs/HostSignupDialog.tsx index fabfdb07f5..c2cbe382e8 100644 --- a/src/components/views/dialogs/HostSignupDialog.tsx +++ b/src/components/views/dialogs/HostSignupDialog.tsx @@ -15,6 +15,7 @@ limitations under the License. */ import * as React from "react"; +import AccessibleButton from "../elements/AccessibleButton"; import Modal from "../../../Modal"; import PersistedElement from "../elements/PersistedElement"; import QuestionDialog from './QuestionDialog'; @@ -23,7 +24,12 @@ import {_t} from "../../../languageHandler"; import {MatrixClientPeg} from "../../../MatrixClientPeg"; import {HostSignupStore} from "../../../stores/HostSignupStore"; import {OwnProfileStore} from "../../../stores/OwnProfileStore"; -import {IPostmessage, IPostmessageResponseData, PostmessageAction} from "./HostSignupDialogTypes"; +import { + IHostSignupConfig, + IPostmessage, + IPostmessageResponseData, + PostmessageAction, +} from "./HostSignupDialogTypes"; interface IProps {} @@ -32,11 +38,12 @@ interface IState { error: string; loadIframe: boolean; minimized: boolean; + termsAccepted: boolean; } export default class HostSignupDialog extends React.PureComponent { private iframeRef: React.RefObject = React.createRef(); - private readonly hostSignupSetupUrl: string; + private readonly config: IHostSignupConfig; constructor(props: IProps) { super(props); @@ -46,13 +53,14 @@ export default class HostSignupDialog extends React.PureComponent { - if (!this.hostSignupSetupUrl.startsWith(message.origin)) { + if (!this.config.url.startsWith(message.origin)) { return; } switch (message.data.action) { @@ -73,14 +81,16 @@ export default class HostSignupDialog extends React.PureComponent { - this.setState({ - minimized: false, - }); + if (this.state.minimized) { + this.setState({ + minimized: false, + }); + } } private minimizeDialog = () => { @@ -97,8 +107,8 @@ export default class HostSignupDialog extends React.PureComponent { - if (result || this.state.completed) { + private onCloseClick = async () => { + if (this.state.completed) { // We're done, close return this.closeDialog(); } else { @@ -121,7 +131,7 @@ export default class HostSignupDialog extends React.PureComponent { - this.iframeRef.current.contentWindow.postMessage(message, this.hostSignupSetupUrl); + this.iframeRef.current.contentWindow.postMessage(message, this.config.url); } private async sendAccountDetails() { @@ -141,6 +151,7 @@ export default class HostSignupDialog extends React.PureComponent { + Modal.createDialog( + QuestionDialog, + { + title: this.config.termsDialog.title, + description: this.config.termsDialog.text, + button: this.config.termsDialog.acceptText, + onFinished: result => { + if (result) { + this.setState({ + termsAccepted: true, + }); + this.loadIframe(); + } + }, + }, + ); + } + public componentWillUnmount() { if (HostSignupStore.instance.isHostSignupActive) { // Run the close dialog actions if we're still active, otherwise good to go @@ -164,41 +194,92 @@ export default class HostSignupDialog extends React.PureComponent
-
{this.state.loadIframe && -