Fix all linting errors/warnings

This commit is contained in:
Andrew Nicolaou 2019-10-21 10:35:20 +02:00
parent 59469d9f85
commit 14a8f48fd5
6 changed files with 45 additions and 22 deletions

View file

@ -69,7 +69,12 @@ const CollectionPopover = ({
const handleSelect = inCollection ? handleRemoveFromCollection : handleAddToCollection;
return (
<Item inCollection={inCollection} key={collection.id} collection={collection} onSelect={() => handleSelect(collection.id)} />
<Item
inCollection={inCollection}
key={collection.id}
collection={collection}
onSelect={() => handleSelect(collection.id)}
/>
);
})
}
@ -89,7 +94,12 @@ const CollectionPopover = ({
</div>
<div className="collection-popover__filter">
<Searchbar searchLabel="Search collections..." searchTerm={searchTerm} setSearchTerm={setSearchTerm} resetSearchTerm={() => setSearchTerm('')} />
<Searchbar
searchLabel="Search collections..."
searchTerm={searchTerm}
setSearchTerm={setSearchTerm}
resetSearchTerm={() => setSearchTerm('')}
/>
</div>
<div className="collection-popover__items">

View file

@ -256,7 +256,12 @@ class SketchListRowBase extends React.Component {
</button>
</li>}
</ul>}
{this.state.showPopover && <CollectionPopover onClose={this.handleCloseCollectionPopover} project={this.props.sketch} />}
{this.state.showPopover &&
<CollectionPopover
onClose={this.handleCloseCollectionPopover}
project={this.props.sketch}
/>
}
</td>
);
}
@ -446,7 +451,8 @@ class SketchList extends React.Component {
addMode={this.props.addMode}
onCollectionAdd={() => this.handleCollectionAdd(sketch.id)}
onCollectionRemove={() => this.handleCollectionRemove(sketch.id)}
inCollection={this.props.collection && this.props.collection.items.find(item => item.project.id === sketch.id) != null}
inCollection={this.props.collection &&
this.props.collection.items.find(item => item.project.id === sketch.id) != null}
/>))}
</tbody>
</table>}
@ -505,7 +511,10 @@ function mapStateToProps(state) {
}
function mapDispatchToProps(dispatch) {
return bindActionCreators(Object.assign({}, ProjectsActions, CollectionsActions, ToastActions, SortingActions), dispatch);
return bindActionCreators(
Object.assign({}, ProjectsActions, CollectionsActions, ToastActions, SortingActions),
dispatch
);
}
export default connect(mapStateToProps, mapDispatchToProps)(SketchList);

View file

@ -29,9 +29,6 @@ import * as ToastActions from '../actions/toast';
import * as ConsoleActions from '../actions/console';
import { getHTMLFile } from '../reducers/files';
import Overlay from '../../App/components/Overlay';
import SketchList from '../components/SketchList';
import Searchbar from '../components/Searchbar';
import AssetList from '../components/AssetList';
import About from '../components/About';
import CollectionList from '../components/CollectionList';
import Feedback from '../components/Feedback';

View file

@ -162,7 +162,7 @@ class CollectionItemRowBase extends React.Component {
}
render() {
const { item, username } = this.props;
const { item } = this.props;
const { renameOpen, optionsOpen, renameValue } = this.state;
const sketchOwnerUsername = item.project.user.username;
const userIsOwner = this.props.user.username === sketchOwnerUsername;
@ -285,7 +285,9 @@ class Collection extends React.Component {
isOwner() {
let isOwner = false;
if (this.props.user != null && this.props.user.username && this.props.collection.owner.username === this.props.user.username) {
if (this.props.user != null &&
this.props.user.username &&
this.props.collection.owner.username === this.props.user.username) {
isOwner = true;
}
@ -307,7 +309,7 @@ class Collection extends React.Component {
_renderCollectionMetadata() {
const {
id, name, description, items, owner, slug
id, name, description, items, owner
} = this.props.collection;
const hostname = window.location.origin;
@ -331,13 +333,16 @@ class Collection extends React.Component {
this.props.editCollection(id, { description: value });
};
const handleEditCollectionSlug = (value) => {
if (value === slug) {
return;
}
this.props.editCollection(id, { slug: value });
};
//
// TODO: Implement UI for editing slug
//
// const handleEditCollectionSlug = (value) => {
// if (value === slug) {
// return;
// }
//
// this.props.editCollection(id, { slug: value });
// };
return (
<div className={`collection-metadata ${this.isOwner() ? 'collection-metadata--is-owner' : ''}`}>
@ -518,7 +523,10 @@ function mapStateToProps(state, ownProps) {
}
function mapDispatchToProps(dispatch) {
return bindActionCreators(Object.assign({}, CollectionsActions, ProjectsActions, ToastActions, SortingActions), dispatch);
return bindActionCreators(
Object.assign({}, CollectionsActions, ProjectsActions, ToastActions, SortingActions),
dispatch
);
}
export default connect(mapStateToProps, mapDispatchToProps)(Collection);

View file

@ -10,7 +10,7 @@ import Overlay from '../../App/components/Overlay';
import AssetList from '../../IDE/components/AssetList';
import CollectionList from '../../IDE/components/CollectionList';
import SketchList from '../../IDE/components/SketchList';
import Searchbar from '../../IDE/components/Searchbar';
import SketchSearchbar from '../../IDE/components/Searchbar';
import CollectionCreate from '../components/CollectionCreate';
import DashboardTabSwitcher, { TabKey } from '../components/DashboardTabSwitcher';
@ -85,7 +85,7 @@ class DashboardView extends React.Component {
default:
return (
<React.Fragment>
<Searchbar />
<SketchSearchbar />
<Link className="dashboard__action-button" to="/">New sketch</Link>
</React.Fragment>
);

View file

@ -1,5 +1,4 @@
import Collection from '../../models/collection';
import Project from '../../models/project';
export default function addProjectToCollection(req, res) {
const owner = req.user._id;