/* * * Copyright 2016 RIFT.IO Inc * * 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 LoggingStore from './loggingStore.js'; class DenyEvent extends React.Component { constructor(props) { super(props); this.state = { eventID: props.eventID }; } componentWillReceiveProps(props) { this.setState({ eventID: props.eventID }); } handleEventIdChange = (e) => { //console.log("DenyEvent.handleEventIdChange called. value=", e.target.value); // TODO: Save only if value is valid this.setState({ eventID: e.target.value }); } isEventIdValid(eventID) { // Return true if null, empty string or a number, else return false if (!eventID || eventID.length == 0) { return true; } else { return (isNaN(+eventID)) ? false : true; } } render() { const {className, onSave, onRemove, warnInvalidEventID, inputPattern, ...props} = this.props; let textBoxClassNames = "textBox"; if (warnInvalidEventID && !this.isEventIdValid(this.state.eventID)) { //console.log("eventID is not valid: ", this.state.eventID); textBoxClassNames += " invalidValue"; } return (