From 31a003bb4e89f3ae9051fe07783529c4a17ea431 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Sat, 23 Apr 2016 02:10:23 +0200 Subject: [PATCH] Extract PlaylistBox --- public/components/{dups => }/duplicate.js | 0 .../components/{dups => }/duplicates-box.js | 0 public/components/playlist-box.js | 39 +++++++++++++++++++ public/script.jsx | 37 +----------------- 4 files changed, 41 insertions(+), 35 deletions(-) rename public/components/{dups => }/duplicate.js (100%) rename public/components/{dups => }/duplicates-box.js (100%) create mode 100644 public/components/playlist-box.js diff --git a/public/components/dups/duplicate.js b/public/components/duplicate.js similarity index 100% rename from public/components/dups/duplicate.js rename to public/components/duplicate.js diff --git a/public/components/dups/duplicates-box.js b/public/components/duplicates-box.js similarity index 100% rename from public/components/dups/duplicates-box.js rename to public/components/duplicates-box.js diff --git a/public/components/playlist-box.js b/public/components/playlist-box.js new file mode 100644 index 0000000..4fe0fe9 --- /dev/null +++ b/public/components/playlist-box.js @@ -0,0 +1,39 @@ +'use strict'; +var React = require('react'); +var ReactBootstrap = require('react-bootstrap'); + +var PlaylistBox = React.createClass({ + getInitialState: function () { + return { + currentId: null + }; + }, + clickOnItem: function (id, uid, event) { + event.preventDefault(); + this.setState({currentId: id}); + this.props.handleClick(id, uid); + }, + render: function () { + var ListGroup = ReactBootstrap.ListGroup, + ListGroupItem = ReactBootstrap.ListGroupItem; + var currentId = this.state.currentId; + + var playlists =

No playlist found.

; + if (this.props.playlists) { + playlists = this.props.playlists.map(function (pl) { + var id = pl.id; + return ( + {pl.name} + ); + }, this); + } + + return ( + + {playlists} + + ); + } +}); + +module.exports = PlaylistBox; diff --git a/public/script.jsx b/public/script.jsx index 6e8545e..48b3332 100644 --- a/public/script.jsx +++ b/public/script.jsx @@ -20,42 +20,9 @@ function getHashParams() { return hashParams; } -var DuplicatesBox = require('./components/dups/duplicates-box'); +var DuplicatesBox = require('./components/duplicates-box'); - -var PlaylistBox = React.createClass({ - getInitialState: function () { - return { - currentId: null - }; - }, - clickOnItem: function (id, uid, event) { - event.preventDefault(); - this.setState({currentId: id}); - this.props.handleClick(id, uid); - }, - render: function () { - var ListGroup = ReactBootstrap.ListGroup, - ListGroupItem = ReactBootstrap.ListGroupItem; - var currentId = this.state.currentId; - - var playlists =

No playlist found.

; - if (this.props.playlists) { - playlists = this.props.playlists.map(function (pl) { - var id = pl.id; - return ( - {pl.name} - ); - }, this); - } - - return ( - - {playlists} - - ); - } -}); +var PlaylistBox = require('./components/playlist-box'); var DuplicateFinderBox = React.createClass({ getInitialState: function () {