Rename a few things, make hosting signup config an object

This commit is contained in:
Jason Robinson 2020-11-13 12:56:42 +02:00
parent 54b22290e7
commit a1d750a4aa
3 changed files with 15 additions and 15 deletions

View file

@ -16,22 +16,22 @@ limitations under the License.
import * as React from "react";
import Modal from "../../Modal";
import HostingProviderDialog from "./HostingProviderDialog";
import HostingSignupDialog from "./HostingSignupDialog";
interface IProps {}
interface IState {}
export default class HostingProviderTrigger extends React.PureComponent<IProps, IState> {
export default class HostingSignupAction extends React.PureComponent<IProps, IState> {
private static openDialog() {
Modal.createDialog(
HostingProviderDialog, {}, "mx_HostingProviderDialog",
HostingSignupDialog, {}, "mx_HostingSignupDialog",
);
}
public render(): React.ReactNode {
return (
<div onClick={HostingProviderTrigger.openDialog} className="mx_HostingProviderTrigger">
<div onClick={HostingSignupAction.openDialog} className="mx_HostingSignupAction">
Get your own personal Element!
</div>
);

View file

@ -24,7 +24,7 @@ interface IState {
error: string,
}
export default class HostingProviderDialog extends React.PureComponent<IProps, IState> {
export default class HostingSignupDialog extends React.PureComponent<IProps, IState> {
iframeRef;
hostingSignupUrl: string;
@ -36,7 +36,7 @@ export default class HostingProviderDialog extends React.PureComponent<IProps, I
};
this.iframeRef = React.createRef();
this.hostingSignupUrl = SdkConfig.get().hosting_signup_iframe;
this.hostingSignupUrl = SdkConfig.get().hosting_signup.url;
}
private messageHandler = (message) => {
@ -83,7 +83,7 @@ export default class HostingProviderDialog extends React.PureComponent<IProps, I
public render(): React.ReactNode {
return (
<div className="mx_HostingProviderDialog_container">
<div className="mx_HostingSignupDialog_container">
<iframe
src={this.hostingSignupUrl}
ref={ref => this.iframeRef = ref}

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 HostingProviderTrigger from "./HostingProviderTrigger";
import HostingSignupAction from "./HostingSignupAction";
interface IProps {
isMinimized: boolean;
@ -312,20 +312,20 @@ export default class UserMenu extends React.Component<IProps, IState> {
</div>
);
}
const hostingSignupIFrame = SdkConfig.get().hosting_signup_iframe;
let hostingIFrame;
if (hostingSignupIFrame) {
const hostingSignupOptions = SdkConfig.get().hosting_signup;
let hostingSignupIFrame;
if (hostingSignupOptions && hostingSignupOptions.url) {
// If hosting_signup_domains is set to a non-empty array, only show
// dialog if the user is on the domain or a subdomain.
const hostingSignupDomains = SdkConfig.get().hosting_signup_domains || [];
const hostingSignupDomains = hostingSignupOptions.domains || [];
const mxDomain = MatrixClientPeg.get().getDomain();
const validDomains = hostingSignupDomains.filter(d => (d === mxDomain || mxDomain.endsWith(`.${d}`)));
if (!hostingSignupDomains || validDomains.length > 0) {
hostingIFrame = <div
hostingSignupIFrame = <div
className="mx_UserMenu_contextMenu_header mx_UserMenu_contextMenu_hostingLink"
onClick={this.onCloseMenu}
>
<HostingProviderTrigger />
<HostingSignupAction />
</div>;
}
}
@ -513,7 +513,7 @@ export default class UserMenu extends React.Component<IProps, IState> {
</AccessibleTooltipButton>
</div>
{topSection}
{hostingIFrame}
{hostingSignupIFrame}
{primaryOptionList}
{secondarySection}
</IconizedContextMenu>;