Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ESLint errors and warnings in the lobby build #137

Merged
merged 4 commits into from
May 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 45 additions & 10 deletions support/lobby/lib/ActiveSessions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from "react";
import PropTypes from "prop-types";
import { Button } from "react-bootstrap";
import ReactTable from "react-table";

Expand All @@ -16,6 +17,11 @@ export default function ActiveSessions( props ) {
);
}

ActiveSessions.propTypes = {
records:
PropTypes.arrayOf( PropTypes.object ).isRequired,
};

const columns = [ {
Header:
"Scenario",
Expand All @@ -25,17 +31,13 @@ const columns = [ {
session => session,
Cell:
function Cell( props ) { return <ScenarioCell { ...props }/> },
filterMethod: ( filter, row, column ) => {
return row[ filter.id ] !== undefined ?
String( row[ filter.id ].state.scenarioTitle ).toLowerCase().indexOf( filter.value.toLowerCase() ) >= 0 : true
filterMethod:
function( filter, row, column ) {
return row[ filter.id ] !== undefined ?
String( row[ filter.id ].state.scenarioTitle ).toLowerCase().indexOf( filter.value.toLowerCase() ) >= 0 : true;
},
Filter: ( {filter, onChange} ) => (
<input
type="text"
placeholder="Search"
value={ filter ? filter.value : "" }
onChange={ event => onChange( event.target.value ) } />
),
Filter:
function Filter( props ) { return <ScenarioFilter { ...props }/> },
}, {
Header:
"Company",
Expand Down Expand Up @@ -77,21 +79,54 @@ const columns = [ {
false,
} ];

class ScenarioFilter extends React.Component {

static propTypes = {
filter:
PropTypes.object,
onChange:
PropTypes.func.isRequired,
};

render() {
return <input
type="text"
placeholder="Search"
value={ this.props.filter ? this.props.filter.value : "" }
onChange={ event => this.props.onChange( event.target.value ) } />;
}

}

class ScenarioCell extends React.Component {

static propTypes = {
value:
PropTypes.object.isRequired,
};

render() {
return <React.Fragment>
{ this.props.value.state.scenarioTitle }
<br/>
<span className="small">{ instructorStudentsLabel( this.props.value ) }</span>
</React.Fragment>;
}

}

class ActionCell extends React.Component {

static propTypes = {
value:
PropTypes.object.isRequired,
};

render() {
return <Button href={ this.props.value.instance || this.props.value.document.uri } target="_blank"
bsSize="small" bsStyle="link"> { this.props.value.instance ? "Join" : "Start" } </Button>;
}

}

// Generate the Instructor/Students annotation for a session.
Expand Down
6 changes: 3 additions & 3 deletions support/lobby/lib/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,23 +82,23 @@ export default class Layout extends React.Component {
then( version =>
this.setState( { version: version || {} } ) ).
catch( error =>
console.log( error.message ) );
console.log( error.message ) ); /* eslint no-console: "off" */
}

handleUser = () => {
get( "user" ).
then( user =>
this.setState( { user: user || {} } ) ).
catch( error =>
console.log( error.message ) );
console.log( error.message ) ); /* eslint no-console: "off" */
}

handleManifest = () => {
get( "manifest" ).
then( manifest =>
this.setState( { manifest: manifest || {} } ) ).
catch( error =>
console.log( error.message ) );
console.log( error.message ) ); /* eslint no-console: "off" */
}

scenarioRecords() {
Expand Down
8 changes: 7 additions & 1 deletion support/lobby/lib/Login.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import React from "react";
import PropTypes from "prop-types";
import { Modal, Form, FormGroup, FormControl, Checkbox, ControlLabel, Button, Image, Row, Fade, Alert } from "react-bootstrap";

import { get } from "./utils";

export default class Login extends React.Component {

static propTypes = {
flash:
PropTypes.arrayOf( PropTypes.object ).isRequired,
};

static defaultProps = {
flash: []
};
Expand Down Expand Up @@ -104,7 +110,7 @@ export default class Login extends React.Component {
then( version =>
this.setState( { version: version || {} } ) ).
catch( error =>
console.log( error.message ) );
console.log( error.message ) ); /* eslint no-console: "off" */
}

}
Expand Down
65 changes: 57 additions & 8 deletions support/lobby/lib/PreviousSessions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from "react";
import PropTypes from "prop-types";
import { Button } from "react-bootstrap";
import ReactTable from "react-table";
import dateFormat from "dateformat";
Expand All @@ -12,20 +13,20 @@ export default function PreviousSessions( props ) {
/>;
}

PreviousSessions.propTypes = {
records:
PropTypes.arrayOf( PropTypes.object ).isRequired,
};

const columns = [ {
Header:
"Scenario",
accessor:
"state.scenarioTitle",
Cell:
function Cell( props ) { return <TextCell { ...props }/> },
Filter: ( {filter, onChange} ) => (
<input
type="text"
placeholder="Search"
value={ filter ? filter.value : "" }
onChange={ event => onChange( event.target.value ) } />
)
Filter:
function Filter( props ) { return <ScenarioFilter { ...props }/> },
}, {
Header:
"Company",
Expand Down Expand Up @@ -91,25 +92,65 @@ const buttonContainerStyle = {
textAlign: "center"
}

class ScenarioFilter extends React.Component {

static propTypes = {
filter:
PropTypes.object,
onChange:
PropTypes.func.isRequired,
};

render() {
return <input
type="text"
placeholder="Search"
value={ this.props.filter ? this.props.filter.value : "" }
onChange={ event => this.props.onChange( event.target.value ) } />;
}

}

class TextCell extends React.Component {

static propTypes = {
value:
PropTypes.string.isRequired,
};

render() {
return (
<div style={{ height: "100%", display: "flex", alignItems: "center" }}>
{ this.props.value }
</div>
);
}

}

class DateCell extends React.Component {

static propTypes = {
value:
PropTypes.string.isRequired,
};

render() {
return <TextCell value={ dateFormat( this.props.value ) } />;
}

}

class ReviewCell extends React.Component {

static propTypes = {
value:
PropTypes.object.isRequired,
};

render() {
const url = ( this.props.value.instance || this.props.value.document.uri ) + "?isReview=true";
const url =
( this.props.value.instance || this.props.value.document.uri ) + "?isReview=true";
return (
<div style={ buttonContainerStyle }>
<Button href={ url } target="_blank" bsSize="small" bsStyle="link">
Expand All @@ -118,9 +159,16 @@ class ReviewCell extends React.Component {
</div>
);
}

}

class ResumeCell extends React.Component {

static propTypes = {
value:
PropTypes.object.isRequired,
};

render() {
return (
<div style={ buttonContainerStyle }>
Expand All @@ -135,4 +183,5 @@ class ResumeCell extends React.Component {
</div>
);
}

}
Loading