Rename Element Pro -> Host Signup

This commit is contained in:
Jason Robinson 2021-01-04 16:05:49 +02:00
parent 6286c23aa5
commit bb53ae8038
6 changed files with 33 additions and 33 deletions

View file

@ -69,9 +69,9 @@
@import "./views/dialogs/_DeactivateAccountDialog.scss";
@import "./views/dialogs/_DevtoolsDialog.scss";
@import "./views/dialogs/_EditCommunityPrototypeDialog.scss";
@import "./views/dialogs/_ElementProDialog.scss";
@import "./views/dialogs/_FeedbackDialog.scss";
@import "./views/dialogs/_GroupAddressPicker.scss";
@import "./views/dialogs/_HostSignupDialog.scss";
@import "./views/dialogs/_IncomingSasDialog.scss";
@import "./views/dialogs/_InviteDialog.scss";
@import "./views/dialogs/_KeyboardShortcutsDialog.scss";

View file

@ -14,16 +14,16 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
.mx_ElementProDialog .mx_Dialog {
.mx_HostSignupDialog .mx_Dialog {
height: 66%;
min-width: 50%;
}
.mx_ElementProBaseDialog {
.mx_HostSignupBaseDialog {
height: 100%;
}
.mx_ElementProDialog_container {
.mx_HostSignupDialog_container {
height: 90%;
iframe {

View file

@ -15,7 +15,7 @@ limitations under the License.
*/
import * as React from "react";
import ElementProDialog from "../views/dialogs/ElementProDialog";
import HostSignupDialog from "../views/dialogs/HostSignupDialog";
import Modal, {IHandle} from "../../Modal";
import {
IconizedContextMenuOption,
@ -27,15 +27,15 @@ interface IProps {}
interface IState {}
export default class ElementProAction extends React.PureComponent<IProps, IState> {
export default class HostSignupAction extends React.PureComponent<IProps, IState> {
private closingAllowed = false;
private modalRef: IHandle<void[]>;
private openDialog = () => {
this.modalRef = Modal.createTrackedDialog(
'Element Pro Open', '', ElementProDialog, {
'Host Signup Open', '', HostSignupDialog, {
requestClose: this.requestClose,
}, "mx_ElementProDialog", false, true, {
}, "mx_HostSignupDialog", false, true, {
onBeforeClose: async () => this.closingAllowed,
},
);

View file

@ -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 ElementProAction from "./ElementProAction";
import HostSignupAction from "./HostSignupAction";
interface IProps {
isMinimized: boolean;
@ -274,7 +274,7 @@ export default class UserMenu extends React.Component<IProps, IState> {
let topSection;
const signupLink = getHostingLink("user-context-menu");
const elementProConfig = SdkConfig.get().element_pro;
const hostSignupConfig = SdkConfig.get().host_signup;
if (MatrixClientPeg.get().isGuest()) {
topSection = (
<div className="mx_UserMenu_contextMenu_header mx_UserMenu_contextMenu_guestPrompts">
@ -294,20 +294,20 @@ export default class UserMenu extends React.Component<IProps, IState> {
})}
</div>
)
} else if (signupLink || elementProConfig) {
let elementProIFrame;
if (elementProConfig && elementProConfig.url) {
// If element_pro.domains is set to a non-empty array, only show
} else if (signupLink || hostSignupConfig) {
let hostSignupAction;
if (hostSignupConfig && hostSignupConfig.url) {
// If host_signup.domains is set to a non-empty array, only show
// dialog if the user is on the domain or a subdomain.
const elementProDomains = elementProConfig.domains || [];
const hostSignupDomains = hostSignupConfig.domains || [];
const mxDomain = MatrixClientPeg.get().getDomain();
const validDomains = elementProDomains.filter(d => (d === mxDomain || mxDomain.endsWith(`.${d}`)));
if (!elementProDomains || validDomains.length > 0) {
elementProIFrame = <div
const validDomains = hostSignupDomains.filter(d => (d === mxDomain || mxDomain.endsWith(`.${d}`)));
if (!hostSignupDomains || validDomains.length > 0) {
hostSignupAction = <div
className=""
onClick={this.onCloseMenu}
>
<ElementProAction />
<HostSignupAction />
</div>;
}
}
@ -327,7 +327,7 @@ export default class UserMenu extends React.Component<IProps, IState> {
)}
</div>
}
{elementProIFrame}
{hostSignupAction}
</>
);
}

View file

@ -23,7 +23,7 @@ import SdkConfig from "../../../SdkConfig";
import {_t} from "../../../languageHandler";
import {MatrixClientPeg} from "../../../MatrixClientPeg";
import {OwnProfileStore} from "../../../stores/OwnProfileStore";
import {IPostmessage, IPostmessageResponseData, PostmessageAction} from "./ElementProDialogTypes";
import {IPostmessage, IPostmessageResponseData, PostmessageAction} from "./HostSignupDialogTypes";
interface IProps {
requestClose(): void;
@ -34,9 +34,9 @@ interface IState {
error: string;
}
export default class ElementProDialog extends React.PureComponent<IProps, IState> {
export default class HostSignupDialog extends React.PureComponent<IProps, IState> {
private iframeRef: React.RefObject<HTMLIFrameElement> = React.createRef();
private readonly elementProSetupUrl: string;
private readonly hostSignupSetupUrl: string;
constructor(props: IProps) {
super(props);
@ -46,15 +46,15 @@ export default class ElementProDialog extends React.PureComponent<IProps, IState
error: null,
};
this.elementProSetupUrl = SdkConfig.get().element_pro.url;
this.hostSignupSetupUrl = SdkConfig.get().host_signup.url;
}
private messageHandler = (message: IPostmessage) => {
if (!this.elementProSetupUrl.startsWith(message.origin)) {
if (!this.hostSignupSetupUrl.startsWith(message.origin)) {
return;
}
switch (message.data.action) {
case PostmessageAction.ElementProAccountDetailsRequest:
case PostmessageAction.HostSignupAccountDetailsRequest:
Modal.createDialog(
ElementProDataConfirmDialog,
{
@ -98,7 +98,7 @@ export default class ElementProDialog extends React.PureComponent<IProps, IState
}
private sendMessage = (message: IPostmessageResponseData) => {
this.iframeRef.current.contentWindow.postMessage(message, this.elementProSetupUrl);
this.iframeRef.current.contentWindow.postMessage(message, this.hostSignupSetupUrl);
}
private async sendAccountDetails() {
@ -111,7 +111,7 @@ export default class ElementProDialog extends React.PureComponent<IProps, IState
return;
}
this.sendMessage({
action: PostmessageAction.ElementProAccountDetails,
action: PostmessageAction.HostSignupAccountDetails,
account: {
accessToken: await MatrixClientPeg.get().getAccessToken(),
name: OwnProfileStore.instance.displayName,
@ -133,15 +133,15 @@ export default class ElementProDialog extends React.PureComponent<IProps, IState
public render(): React.ReactNode {
return (
<BaseDialog
className="mx_ElementProBaseDialog"
className="mx_HostSignupBaseDialog"
onFinished={this.onFinished}
title={_t("Set up your own personal Element host")}
hasCancel={true}
fixedWidth={false}
>
<div className="mx_ElementProDialog_container">
<div className="mx_HostSignupDialog_container">
<iframe
src={this.elementProSetupUrl}
src={this.hostSignupSetupUrl}
ref={this.iframeRef}
sandbox="allow-forms allow-scripts allow-same-origin"
/>

View file

@ -1,7 +1,7 @@
export enum PostmessageAction {
CloseDialog = "close_dialog",
ElementProAccountDetails = "element_pro_account_details",
ElementProAccountDetailsRequest = "element_pro_account_details_request",
HostSignupAccountDetails = "host_signup_account_details",
HostSignupAccountDetailsRequest = "host_signup_account_details_request",
SetupComplete = "setup_complete",
}