Files
mattermost/webapp/components/setting_item_max.jsx

98 lines
3.2 KiB
React
Raw Normal View History

// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
2015-06-14 23:53:32 -08:00
// See License.txt for license information.
2016-03-14 08:50:46 -04:00
import {FormattedMessage} from 'react-intl';
import React from 'react';
2015-08-31 10:10:22 -07:00
export default class SettingItemMax extends React.Component {
render() {
var clientError = null;
if (this.props.client_error) {
clientError = (<div className='form-group'><label className='col-sm-12 has-error'>{this.props.client_error}</label></div>);
}
var serverError = null;
if (this.props.server_error) {
serverError = (<div className='form-group'><label className='col-sm-12 has-error'>{this.props.server_error}</label></div>);
}
var extraInfo = null;
if (this.props.extraInfo) {
extraInfo = (<div className='setting-list__hint'>{this.props.extraInfo}</div>);
2015-08-31 10:10:22 -07:00
}
var submit = '';
if (this.props.submit) {
submit = (
<a
className='btn btn-sm btn-primary'
href='#'
onClick={this.props.submit}
>
<FormattedMessage
id='setting_item_max.save'
defaultMessage='Save'
/>
</a>
);
2015-08-31 10:10:22 -07:00
}
2015-06-14 23:53:32 -08:00
var inputs = this.props.inputs;
2015-10-12 20:55:40 +05:00
var widthClass;
if (this.props.width === 'full') {
widthClass = 'col-sm-12';
} else if (this.props.width === 'medium') {
2015-10-23 21:42:47 +05:00
widthClass = 'col-sm-10 col-sm-offset-2';
} else {
widthClass = 'col-sm-9 col-sm-offset-3';
2015-10-12 20:55:40 +05:00
}
2015-06-14 23:53:32 -08:00
let title;
if (this.props.title) {
title = <li className='col-sm-12 section-title'>{this.props.title}</li>;
}
2015-06-14 23:53:32 -08:00
return (
2015-08-31 10:10:22 -07:00
<ul className='section-max form-horizontal'>
{title}
2015-10-12 20:55:40 +05:00
<li className={widthClass}>
2015-08-31 10:10:22 -07:00
<ul className='setting-list'>
<li className='setting-list-item'>
2015-06-14 23:53:32 -08:00
{inputs}
{extraInfo}
2015-06-14 23:53:32 -08:00
</li>
2015-08-31 10:10:22 -07:00
<li className='setting-list-item'>
2016-02-22 08:31:10 -05:00
<hr/>
2015-08-31 10:10:22 -07:00
{serverError}
{clientError}
{submit}
<a
className='btn btn-sm theme'
href='#'
onClick={this.props.updateSection}
>
<FormattedMessage
id='setting_item_max.cancel'
defaultMessage='Cancel'
/>
2015-08-31 10:10:22 -07:00
</a>
2015-06-14 23:53:32 -08:00
</li>
</ul>
</li>
</ul>
);
}
2015-08-31 10:10:22 -07:00
}
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,
2015-10-12 20:55:40 +05:00
width: React.PropTypes.string
2015-08-31 10:10:22 -07:00
};