/* Copyright 2015, 2016 OpenMarket 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. */ 'use strict'; import React from 'react'; import * as Roles from '../../../Roles'; import { _t } from '../../../languageHandler'; module.exports = React.createClass({ displayName: 'PowerSelector', propTypes: { value: React.PropTypes.number.isRequired, // The maximum value that can be set with the power selector maxValue: React.PropTypes.number.isRequired, // Default user power level for the room usersDefault: React.PropTypes.number.isRequired, // if true, the ; } customPicker = of { input }; } let selectValue; if (this.state.custom) { selectValue = "Custom"; } else { selectValue = this.state.levelRoleMap[this.props.value] || "Custom"; } let select; if (this.props.disabled) { select = { selectValue }; } else { // Each level must have a definition in this.state.levelRoleMap let options = this.state.options.map((level) => { return { value: this.state.levelRoleMap[level], text: Roles.textualPowerLevel(level, this.props.usersDefault), }; }); options.push({ value: "Custom", text: _t("Custom level") }); options = options.map((op) => { return ; }); select = ; } return ( { select } { customPicker } ); }, });