From f245fa6a5273db61e2cd95510ad755051f254cb5 Mon Sep 17 00:00:00 2001 From: Bastian Date: Thu, 31 Jan 2019 17:57:57 +0100 Subject: [PATCH] Add InfoDialog Signed-off-by: Bastian --- src/components/views/dialogs/InfoDialog.js | 80 ++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 src/components/views/dialogs/InfoDialog.js diff --git a/src/components/views/dialogs/InfoDialog.js b/src/components/views/dialogs/InfoDialog.js new file mode 100644 index 0000000000..f917a907bd --- /dev/null +++ b/src/components/views/dialogs/InfoDialog.js @@ -0,0 +1,80 @@ +/* +Copyright 2015, 2016 OpenMarket Ltd +Copyright 2017 New Vector Ltd. + +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 PropTypes from 'prop-types'; +import sdk from '../../../index'; +import { _t } from '../../../languageHandler'; + +export default React.createClass({ + displayName: 'InfoDialog', + propTypes: { + title: PropTypes.string, + description: PropTypes.node, + extraButtons: PropTypes.node, + button: PropTypes.string, + danger: PropTypes.bool, + focus: PropTypes.bool, + onFinished: PropTypes.func.isRequired, + }, + + getDefaultProps: function() { + return { + title: "", + description: "", + extraButtons: null, + focus: true, + danger: false, + }; + }, + + onOk: function() { + this.props.onFinished(true); + }, + + onCancel: function() { + this.props.onFinished(false); + }, + + render: function() { + const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog'); + const DialogButtons = sdk.getComponent('views.elements.DialogButtons'); + let primaryButtonClass = ""; + if (this.props.danger) { + primaryButtonClass = "danger"; + } + return ( + +
+ { this.props.description } +
+ + { this.props.extraButtons } + +
+ ); + }, +});