// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import {FormattedMessage} from 'react-intl';
import * as Utils from 'utils/utils.jsx';
import Constants from 'utils/constants.jsx';
import React from 'react';
export default class SettingItemMax extends React.Component {
constructor(props) {
super(props);
this.onKeyDown = this.onKeyDown.bind(this);
}
onKeyDown(e) {
if (e.keyCode === Constants.KeyCodes.ENTER) {
this.props.submit(e);
}
}
componentDidMount() {
document.addEventListener('keydown', this.onKeyDown);
}
componentWillUnmount() {
document.removeEventListener('keydown', this.onKeyDown);
}
render() {
var clientError = null;
if (this.props.client_error) {
clientError = (
);
}
var serverError = null;
if (this.props.server_error) {
serverError = (
);
}
var extraInfo = null;
if (this.props.extraInfo) {
extraInfo = ({this.props.extraInfo}
);
}
var submit = '';
if (this.props.submit) {
submit = (
);
}
var inputs = this.props.inputs;
var widthClass;
if (this.props.width === 'full') {
widthClass = 'col-sm-12';
} else if (this.props.width === 'medium') {
widthClass = 'col-sm-10 col-sm-offset-2';
} else {
widthClass = 'col-sm-9 col-sm-offset-3';
}
let title;
let titleProp = 'unknownTitle';
if (this.props.title) {
title = {this.props.title};
titleProp = this.props.title;
}
return (
{title}
-
-
{inputs}
{extraInfo}
-
{this.props.submitExtra}
{serverError}
{clientError}
{submit}
);
}
}
SettingItemMax.propTypes = {
inputs: React.PropTypes.array,
client_error: React.PropTypes.string,
server_error: React.PropTypes.string,
extraInfo: React.PropTypes.element,
updateSection: React.PropTypes.func,
submit: React.PropTypes.func,
title: React.PropTypes.node,
width: React.PropTypes.string,
submitExtra: React.PropTypes.node
};