Dont' allow HostingSignupDialog to close
Except via confirmed cancel action or host setup success postmessage.
This commit is contained in:
parent
a1d750a4aa
commit
e6582c140f
3 changed files with 104 additions and 16 deletions
|
@ -23,15 +23,34 @@ interface IProps {}
|
||||||
interface IState {}
|
interface IState {}
|
||||||
|
|
||||||
export default class HostingSignupAction extends React.PureComponent<IProps, IState> {
|
export default class HostingSignupAction extends React.PureComponent<IProps, IState> {
|
||||||
private static openDialog() {
|
closingAllowed = false;
|
||||||
Modal.createDialog(
|
modalRef: any;
|
||||||
HostingSignupDialog, {}, "mx_HostingSignupDialog",
|
|
||||||
|
private openDialog = () => {
|
||||||
|
this.modalRef = Modal.createTrackedDialog(
|
||||||
|
'Hosting Signup Open',
|
||||||
|
'',
|
||||||
|
HostingSignupDialog,
|
||||||
|
{
|
||||||
|
requestClose: this.requestClose,
|
||||||
|
},
|
||||||
|
"mx_HostingSignupDialog",
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
{
|
||||||
|
onBeforeClose: async () => this.closingAllowed,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private requestClose = () => {
|
||||||
|
this.closingAllowed = true;
|
||||||
|
this.modalRef.close();
|
||||||
|
}
|
||||||
|
|
||||||
public render(): React.ReactNode {
|
public render(): React.ReactNode {
|
||||||
return (
|
return (
|
||||||
<div onClick={HostingSignupAction.openDialog} className="mx_HostingSignupAction">
|
<div onClick={this.openDialog} className="mx_HostingSignupAction">
|
||||||
Get your own personal Element!
|
Get your own personal Element!
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -15,10 +15,14 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
|
import * as sdk from '../../index';
|
||||||
|
import Modal from "../../Modal";
|
||||||
import SdkConfig from "../../SdkConfig";
|
import SdkConfig from "../../SdkConfig";
|
||||||
import {MatrixClientPeg} from "../../MatrixClientPeg";
|
import {MatrixClientPeg} from "../../MatrixClientPeg";
|
||||||
|
|
||||||
interface IProps {}
|
interface IProps {
|
||||||
|
requestClose(): void,
|
||||||
|
}
|
||||||
|
|
||||||
interface IState {
|
interface IState {
|
||||||
error: string,
|
error: string,
|
||||||
|
@ -49,6 +53,29 @@ export default class HostingSignupDialog extends React.PureComponent<IProps, ISt
|
||||||
// noinspection JSIgnoredPromiseFromCall
|
// noinspection JSIgnoredPromiseFromCall
|
||||||
this.fetchOpenIDToken();
|
this.fetchOpenIDToken();
|
||||||
break;
|
break;
|
||||||
|
case 'setup_complete':
|
||||||
|
this.onFinished(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private onFinished = (result: boolean) => {
|
||||||
|
if (result) {
|
||||||
|
// We're done, close
|
||||||
|
this.props.requestClose();
|
||||||
|
} else {
|
||||||
|
const ConfirmDialog = sdk.getComponent('views.dialogs.ConfirmCloseHostingSignupDialog');
|
||||||
|
Modal.createDialog(
|
||||||
|
ConfirmDialog,
|
||||||
|
{
|
||||||
|
onFinished: result => {
|
||||||
|
if (result) {
|
||||||
|
// TODO call an API endpoint to clean up?
|
||||||
|
this.props.requestClose();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,18 +109,25 @@ export default class HostingSignupDialog extends React.PureComponent<IProps, ISt
|
||||||
}
|
}
|
||||||
|
|
||||||
public render(): React.ReactNode {
|
public render(): React.ReactNode {
|
||||||
|
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
|
||||||
return (
|
return (
|
||||||
<div className="mx_HostingSignupDialog_container">
|
<BaseDialog
|
||||||
<iframe
|
onFinished={this.onFinished}
|
||||||
src={this.hostingSignupUrl}
|
title="Set up your own personal Element host"
|
||||||
ref={ref => this.iframeRef = ref}
|
hasCancel={true}
|
||||||
/>
|
>
|
||||||
{this.state.error &&
|
<div className="mx_HostingSignupDialog_container">
|
||||||
<div>
|
<iframe
|
||||||
{this.state.error}
|
src={this.hostingSignupUrl}
|
||||||
</div>
|
ref={ref => this.iframeRef = ref}
|
||||||
}
|
/>
|
||||||
</div>
|
{this.state.error &&
|
||||||
|
<div>
|
||||||
|
{this.state.error}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</BaseDialog>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
Copyright 2020 Element
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
import * as sdk from '../../../index';
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A dialog for confirming closing the Hosting signup setup dialog.
|
||||||
|
*/
|
||||||
|
export default class ConfirmCloseHostingSignupDialog extends React.Component {
|
||||||
|
render() {
|
||||||
|
const QuestionDialog = sdk.getComponent('views.dialogs.QuestionDialog');
|
||||||
|
return (
|
||||||
|
<QuestionDialog
|
||||||
|
onFinished={this.props.onFinished}
|
||||||
|
title="Confirm Abort Of Host Creation"
|
||||||
|
description="Are you sure you wish to abort creation of the host? The process cannot be continued."
|
||||||
|
button="Abort"
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue