Remove unnecessary codes
This commit is contained in:
@@ -30,60 +30,58 @@ const errorPage = {
|
||||
}
|
||||
};
|
||||
|
||||
class ErrorView extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<Grid
|
||||
id={this.props.id}
|
||||
style={this.props.style}
|
||||
>
|
||||
<div style={errorPage.tableStyle}>
|
||||
<div style={errorPage.cellStyle}>
|
||||
<Row>
|
||||
<Col
|
||||
xs={0}
|
||||
sm={1}
|
||||
md={1}
|
||||
lg={2}
|
||||
/>
|
||||
<Col
|
||||
xs={12}
|
||||
sm={10}
|
||||
md={10}
|
||||
lg={8}
|
||||
>
|
||||
<h2>{'Cannot connect to Mattermost'}</h2>
|
||||
<hr/>
|
||||
<p>{'We\'re having trouble connecting to Mattermost. If refreshing this page (Ctrl+R or Command+R) does not work please verify that:'}</p>
|
||||
<br/>
|
||||
<ul style={errorPage.bullets}>
|
||||
<li>{'Your computer is connected to the internet.'}</li>
|
||||
<li>{'The Mattermost URL '}
|
||||
<a href={this.props.errorInfo.validatedURL}>
|
||||
{this.props.errorInfo.validatedURL}
|
||||
</a>{' is correct.'}</li>
|
||||
<li>{'You can reach '}
|
||||
<a href={this.props.errorInfo.validatedURL}>
|
||||
{this.props.errorInfo.validatedURL}
|
||||
</a>{' from a browser window.'}</li>
|
||||
</ul>
|
||||
<br/>
|
||||
<div style={errorPage.techInfo}>
|
||||
{this.props.errorInfo.errorDescription}{' ('}
|
||||
{this.props.errorInfo.errorCode }{')'}</div>
|
||||
</Col>
|
||||
<Col
|
||||
xs={0}
|
||||
sm={1}
|
||||
md={1}
|
||||
lg={2}
|
||||
/>
|
||||
</Row>
|
||||
</div>
|
||||
function ErrorView(props) {
|
||||
return (
|
||||
<Grid
|
||||
id={props.id}
|
||||
style={props.style}
|
||||
>
|
||||
<div style={errorPage.tableStyle}>
|
||||
<div style={errorPage.cellStyle}>
|
||||
<Row>
|
||||
<Col
|
||||
xs={0}
|
||||
sm={1}
|
||||
md={1}
|
||||
lg={2}
|
||||
/>
|
||||
<Col
|
||||
xs={12}
|
||||
sm={10}
|
||||
md={10}
|
||||
lg={8}
|
||||
>
|
||||
<h2>{'Cannot connect to Mattermost'}</h2>
|
||||
<hr/>
|
||||
<p>{'We\'re having trouble connecting to Mattermost. If refreshing this page (Ctrl+R or Command+R) does not work please verify that:'}</p>
|
||||
<br/>
|
||||
<ul style={errorPage.bullets}>
|
||||
<li>{'Your computer is connected to the internet.'}</li>
|
||||
<li>{'The Mattermost URL '}
|
||||
<a href={props.errorInfo.validatedURL}>
|
||||
{props.errorInfo.validatedURL}
|
||||
</a>{' is correct.'}</li>
|
||||
<li>{'You can reach '}
|
||||
<a href={props.errorInfo.validatedURL}>
|
||||
{props.errorInfo.validatedURL}
|
||||
</a>{' from a browser window.'}</li>
|
||||
</ul>
|
||||
<br/>
|
||||
<div style={errorPage.techInfo}>
|
||||
{props.errorInfo.errorDescription}{' ('}
|
||||
{props.errorInfo.errorCode }{')'}</div>
|
||||
</Col>
|
||||
<Col
|
||||
xs={0}
|
||||
sm={1}
|
||||
md={1}
|
||||
lg={2}
|
||||
/>
|
||||
</Row>
|
||||
</div>
|
||||
</Grid>
|
||||
);
|
||||
}
|
||||
</div>
|
||||
</Grid>
|
||||
);
|
||||
}
|
||||
|
||||
ErrorView.propTypes = {
|
||||
|
@@ -1,13 +1,11 @@
|
||||
const React = require('react');
|
||||
|
||||
class HoveringURL extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<div style={this.props.style}>
|
||||
{this.props.targetURL}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
function HoveringURL(props) {
|
||||
return (
|
||||
<div style={props.style}>
|
||||
{props.targetURL}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
HoveringURL.propTypes = {
|
||||
|
@@ -1,148 +0,0 @@
|
||||
const React = require('react');
|
||||
const {findDOMNode} = require('react-dom');
|
||||
const {Button, HelpBlock, ListGroupItem} = require('react-bootstrap');
|
||||
|
||||
const TeamListItemNew = React.createClass({
|
||||
propTypes: {
|
||||
onTeamAdd: React.PropTypes.func,
|
||||
teamIndex: React.PropTypes.number,
|
||||
teamName: React.PropTypes.string,
|
||||
teamUrl: React.PropTypes.string
|
||||
},
|
||||
|
||||
getInitialState() {
|
||||
return {
|
||||
name: this.props.teamName,
|
||||
url: this.props.teamUrl,
|
||||
index: this.props.teamIndex,
|
||||
errorMessage: null
|
||||
};
|
||||
},
|
||||
handleSubmit(e) {
|
||||
console.log('submit');
|
||||
e.preventDefault();
|
||||
const errorMessage = this.getValidationErrorMessage();
|
||||
if (errorMessage) {
|
||||
this.setState({
|
||||
errorMessage
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
this.props.onTeamAdd({
|
||||
name: this.state.name.trim(),
|
||||
url: this.state.url.trim(),
|
||||
index: this.state.index
|
||||
});
|
||||
|
||||
this.setState({
|
||||
name: '',
|
||||
url: '',
|
||||
index: '',
|
||||
errorMessage: null
|
||||
});
|
||||
},
|
||||
handleNameChange(e) {
|
||||
console.log('name');
|
||||
this.setState({
|
||||
name: e.target.value
|
||||
});
|
||||
},
|
||||
handleURLChange(e) {
|
||||
console.log('url');
|
||||
this.setState({
|
||||
url: e.target.value
|
||||
});
|
||||
},
|
||||
|
||||
getValidationErrorMessage() {
|
||||
if (this.state.name.trim() === '') {
|
||||
return 'Name is required.';
|
||||
} else if (this.state.url.trim() === '') {
|
||||
return 'URL is required.';
|
||||
} else if (!(/^https?:\/\/.*/).test(this.state.url.trim())) {
|
||||
return 'URL should start with http:// or https://.';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
componentDidMount() {
|
||||
const inputTeamName = findDOMNode(this.refs.inputTeamName);
|
||||
const setErrorMessage = () => {
|
||||
this.setState({
|
||||
errorMessage: this.getValidationErrorMessage()
|
||||
});
|
||||
};
|
||||
inputTeamName.addEventListener('invalid', setErrorMessage);
|
||||
const inputTeamURL = findDOMNode(this.refs.inputTeamURL);
|
||||
inputTeamURL.addEventListener('invalid', setErrorMessage);
|
||||
},
|
||||
|
||||
render() {
|
||||
var existingTeam = false;
|
||||
if (this.state.name !== '' && this.state.url !== '') {
|
||||
existingTeam = true;
|
||||
}
|
||||
|
||||
var btnAddText;
|
||||
if (existingTeam) {
|
||||
btnAddText = 'Save';
|
||||
} else {
|
||||
btnAddText = 'Add';
|
||||
}
|
||||
|
||||
return (
|
||||
<ListGroupItem>
|
||||
<form
|
||||
className='form-inline'
|
||||
onSubmit={this.handleSubmit}
|
||||
>
|
||||
<div className='form-group'>
|
||||
<label htmlFor='inputTeamName'>{'Name'}</label>
|
||||
{ ' ' }
|
||||
<input
|
||||
type='text'
|
||||
required={true}
|
||||
className='form-control'
|
||||
id='inputTeamName'
|
||||
ref='inputTeamName'
|
||||
placeholder='Example team'
|
||||
value={this.state.name}
|
||||
onChange={this.handleNameChange}
|
||||
/>
|
||||
</div>
|
||||
{ ' ' }
|
||||
<div className='form-group'>
|
||||
<label htmlFor='inputTeamURL'>{'URL'}</label>
|
||||
{ ' ' }
|
||||
<input
|
||||
type='url'
|
||||
required={true}
|
||||
className='form-control'
|
||||
id='inputTeamURL'
|
||||
ref='inputTeamURL'
|
||||
placeholder='https://example.com/team'
|
||||
value={this.state.url}
|
||||
onChange={this.handleURLChange}
|
||||
/>
|
||||
</div>
|
||||
{ ' ' }
|
||||
<Button type='submit'>
|
||||
{ btnAddText }
|
||||
</Button>
|
||||
</form>
|
||||
{ (() => {
|
||||
if (this.state.errorMessage !== null) {
|
||||
return (
|
||||
<HelpBlock style={{color: '#777777'}}>
|
||||
{ this.state.errorMessage }
|
||||
</HelpBlock>);
|
||||
}
|
||||
return null;
|
||||
})() }
|
||||
</ListGroupItem>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = TeamListItemNew;
|
Reference in New Issue
Block a user