Convert DialogButtons to TS
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
parent
cebf256dc0
commit
af853e1d86
3 changed files with 47 additions and 48 deletions
|
@ -26,10 +26,9 @@ import { SettingLevel } from "../../../../settings/SettingLevel";
|
||||||
import Field from '../../../../components/views/elements/Field';
|
import Field from '../../../../components/views/elements/Field';
|
||||||
import BaseDialog from "../../../../components/views/dialogs/BaseDialog";
|
import BaseDialog from "../../../../components/views/dialogs/BaseDialog";
|
||||||
import DialogButtons from "../../../../components/views/elements/DialogButtons";
|
import DialogButtons from "../../../../components/views/elements/DialogButtons";
|
||||||
|
import { IDialogProps } from "../../../../components/views/dialogs/IDialogProps";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps extends IDialogProps {}
|
||||||
onFinished: (confirmed: boolean) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface IState {
|
interface IState {
|
||||||
eventIndexSize: number;
|
eventIndexSize: number;
|
||||||
|
|
|
@ -23,10 +23,9 @@ import Modal from '../../../Modal';
|
||||||
import BaseDialog from "./BaseDialog";
|
import BaseDialog from "./BaseDialog";
|
||||||
import DialogButtons from "../elements/DialogButtons";
|
import DialogButtons from "../elements/DialogButtons";
|
||||||
import QuestionDialog from "./QuestionDialog";
|
import QuestionDialog from "./QuestionDialog";
|
||||||
|
import { IDialogProps } from "./IDialogProps";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps extends IDialogProps {}
|
||||||
onFinished: (success: boolean) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
const CryptoStoreTooNewDialog: React.FC<IProps> = (props: IProps) => {
|
const CryptoStoreTooNewDialog: React.FC<IProps> = (props: IProps) => {
|
||||||
const brand = SdkConfig.get().brand;
|
const brand = SdkConfig.get().brand;
|
||||||
|
|
|
@ -17,60 +17,61 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import PropTypes from "prop-types";
|
|
||||||
import { _t } from '../../../languageHandler';
|
import { _t } from '../../../languageHandler';
|
||||||
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
||||||
|
|
||||||
|
interface IProps {
|
||||||
|
// The primary button which is styled differently and has default focus.
|
||||||
|
primaryButton: React.ReactNode;
|
||||||
|
|
||||||
|
// A node to insert into the cancel button instead of default "Cancel"
|
||||||
|
cancelButton?: React.ReactNode;
|
||||||
|
|
||||||
|
// If true, make the primary button a form submit button (input type="submit")
|
||||||
|
primaryIsSubmit?: boolean;
|
||||||
|
|
||||||
|
// onClick handler for the primary button.
|
||||||
|
onPrimaryButtonClick?: (ev: React.MouseEvent) => void;
|
||||||
|
|
||||||
|
// should there be a cancel button? default: true
|
||||||
|
hasCancel?: boolean;
|
||||||
|
|
||||||
|
// The class of the cancel button, only used if a cancel button is
|
||||||
|
// enabled
|
||||||
|
cancelButtonClass?: string;
|
||||||
|
|
||||||
|
// onClick handler for the cancel button.
|
||||||
|
onCancel?: (...args: any[]) => void;
|
||||||
|
|
||||||
|
focus?: boolean;
|
||||||
|
|
||||||
|
// disables the primary and cancel buttons
|
||||||
|
disabled?: boolean;
|
||||||
|
|
||||||
|
// disables only the primary button
|
||||||
|
primaryDisabled?: boolean;
|
||||||
|
|
||||||
|
// something to stick next to the buttons, optionally
|
||||||
|
additive?: React.ReactNode;
|
||||||
|
|
||||||
|
primaryButtonClass?: string;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic container for buttons in modal dialogs.
|
* Basic container for buttons in modal dialogs.
|
||||||
*/
|
*/
|
||||||
@replaceableComponent("views.elements.DialogButtons")
|
@replaceableComponent("views.elements.DialogButtons")
|
||||||
export default class DialogButtons extends React.Component {
|
export default class DialogButtons extends React.Component<IProps> {
|
||||||
static propTypes = {
|
public static defaultProps: Partial<IProps> = {
|
||||||
// The primary button which is styled differently and has default focus.
|
|
||||||
primaryButton: PropTypes.node.isRequired,
|
|
||||||
|
|
||||||
// A node to insert into the cancel button instead of default "Cancel"
|
|
||||||
cancelButton: PropTypes.node,
|
|
||||||
|
|
||||||
// If true, make the primary button a form submit button (input type="submit")
|
|
||||||
primaryIsSubmit: PropTypes.bool,
|
|
||||||
|
|
||||||
// onClick handler for the primary button.
|
|
||||||
onPrimaryButtonClick: PropTypes.func,
|
|
||||||
|
|
||||||
// should there be a cancel button? default: true
|
|
||||||
hasCancel: PropTypes.bool,
|
|
||||||
|
|
||||||
// The class of the cancel button, only used if a cancel button is
|
|
||||||
// enabled
|
|
||||||
cancelButtonClass: PropTypes.node,
|
|
||||||
|
|
||||||
// onClick handler for the cancel button.
|
|
||||||
onCancel: PropTypes.func,
|
|
||||||
|
|
||||||
focus: PropTypes.bool,
|
|
||||||
|
|
||||||
// disables the primary and cancel buttons
|
|
||||||
disabled: PropTypes.bool,
|
|
||||||
|
|
||||||
// disables only the primary button
|
|
||||||
primaryDisabled: PropTypes.bool,
|
|
||||||
|
|
||||||
// something to stick next to the buttons, optionally
|
|
||||||
additive: PropTypes.element,
|
|
||||||
};
|
|
||||||
|
|
||||||
static defaultProps = {
|
|
||||||
hasCancel: true,
|
hasCancel: true,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
_onCancelClick = () => {
|
private onCancelClick = (event: React.MouseEvent): void => {
|
||||||
this.props.onCancel();
|
this.props.onCancel(event);
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
public render(): JSX.Element {
|
||||||
let primaryButtonClassName = "mx_Dialog_primary";
|
let primaryButtonClassName = "mx_Dialog_primary";
|
||||||
if (this.props.primaryButtonClass) {
|
if (this.props.primaryButtonClass) {
|
||||||
primaryButtonClassName += " " + this.props.primaryButtonClass;
|
primaryButtonClassName += " " + this.props.primaryButtonClass;
|
||||||
|
@ -82,7 +83,7 @@ export default class DialogButtons extends React.Component {
|
||||||
// important: the default type is 'submit' and this button comes before the
|
// important: the default type is 'submit' and this button comes before the
|
||||||
// primary in the DOM so will get form submissions unless we make it not a submit.
|
// primary in the DOM so will get form submissions unless we make it not a submit.
|
||||||
type="button"
|
type="button"
|
||||||
onClick={this._onCancelClick}
|
onClick={this.onCancelClick}
|
||||||
className={this.props.cancelButtonClass}
|
className={this.props.cancelButtonClass}
|
||||||
disabled={this.props.disabled}
|
disabled={this.props.disabled}
|
||||||
>
|
>
|
Loading…
Add table
Add a link
Reference in a new issue