piano/js/components/Channel/Modal.js

58 lines
1.5 KiB
JavaScript
Raw Normal View History

2014-11-08 17:52:36 +00:00
/*jshint nomen:true */
/*globals React, App */
(function () {
'use strict';
/**
* Modal for managing channels
*
* @prop {channels: Array} List of channels
* @prop {open: func} Called to open the window
* @prop {close: func} Called to close the window
*/
App.components.modal('Channel', {
displayName: 'Modal',
mixins: [React.addons.PureRenderMixin],
propTypes: {
channels: React.PropTypes.array,
open: React.PropTypes.func,
close: React.PropTypes.func
},
getDefaultProps: function () {
return {
channels: [],
open: function () {},
close: function () {}
};
},
/**
* Render modal
*/
render: function () {
var title = 'Gestion des canaux', channels;
channels = this.props.channels.map(function (channel) {
channel.key = 'channel-' + channel.id;
return App.components.Channel.Channel(channel);
});
return React.DOM.form({
className: 'vex-dialog-form channels'
}, [
React.DOM.h4({
key: 'title',
className: 'main-title'
}, title),
React.DOM.ul({
key: 'channels'
}, channels)
]);
}
});
}());