From cd836be80904037491a66b49c1f1f947aefde8d3 Mon Sep 17 00:00:00 2001 From: Jason Robinson Date: Tue, 15 Dec 2020 10:50:38 +0200 Subject: [PATCH] Rename everything HostingSignup -> EMSElementPro This setup flow ended up quite specific due to all the various moving parts. --- .../views/dialogs/_HostingSignupDialog.scss | 6 +-- ...gnupAction.tsx => EMSElementProAction.tsx} | 8 ++-- src/components/structures/UserMenu.tsx | 40 ++++++------------- ...sx => EMSElementProConfirmCloseDialog.tsx} | 4 +- ...tsx => EMSElementProDataConfirmDialog.tsx} | 4 +- ...gnupDialog.tsx => EMSElementProDialog.tsx} | 25 ++++++------ 6 files changed, 36 insertions(+), 51 deletions(-) rename src/components/structures/{HostingSignupAction.tsx => EMSElementProAction.tsx} (87%) rename src/components/views/dialogs/{ConfirmCloseHostingSignupDialog.tsx => EMSElementProConfirmCloseDialog.tsx} (90%) rename src/components/views/dialogs/{HostingSignupAccountDataConfirmDialog.tsx => EMSElementProDataConfirmDialog.tsx} (88%) rename src/components/views/dialogs/{HostingSignupDialog.tsx => EMSElementProDialog.tsx} (85%) diff --git a/res/css/views/dialogs/_HostingSignupDialog.scss b/res/css/views/dialogs/_HostingSignupDialog.scss index 599b445ac8..63f4c984c9 100644 --- a/res/css/views/dialogs/_HostingSignupDialog.scss +++ b/res/css/views/dialogs/_HostingSignupDialog.scss @@ -14,16 +14,16 @@ See the License for the specific language governing permissions and limitations under the License. */ -.mx_HostingSignupDialog .mx_Dialog { +.mx_EMSElementProDialog .mx_Dialog { height: 66%; min-width: 50%; } -.mx_HostingSignupBaseDialog { +.mx_EMSElementProBaseDialog { height: 100%; } -.mx_HostingSignupDialog_container { +.mx_EMSElementProDialog_container { height: 90%; iframe { diff --git a/src/components/structures/HostingSignupAction.tsx b/src/components/structures/EMSElementProAction.tsx similarity index 87% rename from src/components/structures/HostingSignupAction.tsx rename to src/components/structures/EMSElementProAction.tsx index f5f08807b5..84526686cf 100644 --- a/src/components/structures/HostingSignupAction.tsx +++ b/src/components/structures/EMSElementProAction.tsx @@ -15,8 +15,8 @@ limitations under the License. */ import * as React from "react"; +import EMSElementProDialog from "../views/dialogs/EMSElementProDialog"; import Modal from "../../Modal"; -import HostingSignupDialog from "../views/dialogs/HostingSignupDialog"; import { IconizedContextMenuOption, IconizedContextMenuOptionList, @@ -27,15 +27,15 @@ interface IProps {} interface IState {} -export default class HostingSignupAction extends React.PureComponent { +export default class EMSElementProAction extends React.PureComponent { closingAllowed = false; modalRef: any; private openDialog = () => { this.modalRef = Modal.createTrackedDialog( - 'Hosting Signup Open', '', HostingSignupDialog, { + 'Element Pro Open', '', EMSElementProDialog, { requestClose: this.requestClose, - }, "mx_HostingSignupDialog", false, true, { + }, "mx_EMSElementProDialog", false, true, { onBeforeClose: async () => this.closingAllowed, }, ); diff --git a/src/components/structures/UserMenu.tsx b/src/components/structures/UserMenu.tsx index ef4d214709..01ed972a99 100644 --- a/src/components/structures/UserMenu.tsx +++ b/src/components/structures/UserMenu.tsx @@ -51,7 +51,7 @@ import { RightPanelPhases } from "../../stores/RightPanelStorePhases"; import ErrorDialog from "../views/dialogs/ErrorDialog"; import EditCommunityPrototypeDialog from "../views/dialogs/EditCommunityPrototypeDialog"; import {UIFeature} from "../../settings/UIFeature"; -import HostingSignupAction from "./HostingSignupAction"; +import EMSElementProAction from "./EMSElementProAction"; interface IProps { isMinimized: boolean; @@ -274,7 +274,7 @@ export default class UserMenu extends React.Component { let topSection; const signupLink = getHostingLink("user-context-menu"); - const hostingSignupOptions = SdkConfig.get().hosting_signup; + const elementProConfig = SdkConfig.get().ems_element_pro; if (MatrixClientPeg.get().isGuest()) { topSection = (
@@ -294,36 +294,20 @@ export default class UserMenu extends React.Component { })}
) - } else if (signupLink || hostingSignupOptions) { - let hostingSignupIFrame; - /* - Config schema: - - ``` - "hosting_signup": { - // URL to load iframe from. - "url": "https://prodiver.tld/setup", - // Accepted Matrix user server names to show iframe action for. - // Subdomains will also match. - "domains": [ - "matrix.org", - "domain.tld" - ] - } - ``` - */ - if (hostingSignupOptions && hostingSignupOptions.url) { - // If hosting_signup_domains is set to a non-empty array, only show + } else if (signupLink || elementProConfig) { + let elementProIFrame; + if (elementProConfig && elementProConfig.url) { + // If ems_element_pro.domains is set to a non-empty array, only show // dialog if the user is on the domain or a subdomain. - const hostingSignupDomains = hostingSignupOptions.domains || []; + const elementProDomains = elementProConfig.domains || []; const mxDomain = MatrixClientPeg.get().getDomain(); - const validDomains = hostingSignupDomains.filter(d => (d === mxDomain || mxDomain.endsWith(`.${d}`))); - if (!hostingSignupDomains || validDomains.length > 0) { - hostingSignupIFrame =
(d === mxDomain || mxDomain.endsWith(`.${d}`))); + if (!elementProDomains || validDomains.length > 0) { + elementProIFrame =
- +
; } } @@ -346,7 +330,7 @@ export default class UserMenu extends React.Component { )}
} - {hostingSignupIFrame} + {elementProIFrame} ); } diff --git a/src/components/views/dialogs/ConfirmCloseHostingSignupDialog.tsx b/src/components/views/dialogs/EMSElementProConfirmCloseDialog.tsx similarity index 90% rename from src/components/views/dialogs/ConfirmCloseHostingSignupDialog.tsx rename to src/components/views/dialogs/EMSElementProConfirmCloseDialog.tsx index c8cbf6a8f3..95210a49a5 100644 --- a/src/components/views/dialogs/ConfirmCloseHostingSignupDialog.tsx +++ b/src/components/views/dialogs/EMSElementProConfirmCloseDialog.tsx @@ -26,9 +26,9 @@ interface IProps extends IDialogProps { interface IState {} /* - * A dialog for confirming closing the Hosting signup setup dialog. + * A dialog for confirming closing the Element Pro setup dialog. */ -export default class ConfirmCloseHostingSignupDialog extends React.PureComponent { +export default class EMSElementProConfirmCloseDialog extends React.PureComponent { public render() { return ( { +export default class EMSElementProDataConfirmDialog extends React.PureComponent { public render() { return ( { +export default class EMSElementProDialog extends React.PureComponent { iframeRef; - hostingSignupUrl: string; + elementProSetupUrl: string; constructor(props: IProps) { super(props); @@ -46,17 +46,17 @@ export default class HostingSignupDialog extends React.PureComponent { - if (!this.hostingSignupUrl.startsWith(message.origin)) { + if (!this.elementProSetupUrl.startsWith(message.origin)) { return; } switch (message.data.action) { case 'element_pro_account_details_request': Modal.createDialog( - HostingSignupAccountDataConfirmDialog, + EMSElementProDataConfirmDialog, { onFinished: result => { if (result) { @@ -85,7 +85,7 @@ export default class HostingSignupDialog extends React.PureComponent { if (result) { @@ -100,7 +100,7 @@ export default class HostingSignupDialog extends React.PureComponent { this.iframeRef.contentWindow.postMessage( message, - this.hostingSignupUrl, + this.elementProSetupUrl, ) } @@ -108,6 +108,7 @@ export default class HostingSignupDialog extends React.PureComponent -
+