/* Copyright 2019 The Matrix.org Foundation C.I.C. 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 url from 'url'; import React from 'react'; import PropTypes from 'prop-types'; import * as sdk from '../../../index'; import { _t, pickBestLanguage } from '../../../languageHandler'; import Matrix from 'matrix-js-sdk'; class TermsCheckbox extends React.PureComponent { static propTypes = { onChange: PropTypes.func.isRequired, url: PropTypes.string.isRequired, checked: PropTypes.bool.isRequired, } onChange = (ev) => { this.props.onChange(this.props.url, ev.target.checked); } render() { return ; } } export default class TermsDialog extends React.PureComponent { static propTypes = { /** * Array of [Service, policies] pairs, where policies is the response from the * /terms endpoint for that service */ policiesAndServicePairs: PropTypes.array.isRequired, /** * urls that the user has already agreed to */ agreedUrls: PropTypes.arrayOf(PropTypes.string), /** * Called with: * * success {bool} True if the user accepted any douments, false if cancelled * * agreedUrls {string[]} List of agreed URLs */ onFinished: PropTypes.func.isRequired, } constructor(props) { super(); this.state = { // url -> boolean agreedUrls: {}, }; for (const url of props.agreedUrls) { this.state.agreedUrls[url] = true; } } _onCancelClick = () => { this.props.onFinished(false); } _onNextClick = () => { this.props.onFinished(true, Object.keys(this.state.agreedUrls).filter((url) => this.state.agreedUrls[url])); } _nameForServiceType(serviceType, host) { switch (serviceType) { case Matrix.SERVICE_TYPES.IS: return
{_t("To continue you need to accept the terms of this service.")}
{_t("Service")} | {_t("Summary")} | {_t("Document")} | {_t("Accept")} |
---|