2015-08-28 14:20:07 +02:00
|
|
|
var React = require('react');
|
2015-09-04 12:10:08 +02:00
|
|
|
var Util = require('../../util');
|
2015-10-09 14:22:23 +02:00
|
|
|
var AppIcon = require('../common/app-icon.js');
|
2015-09-11 16:25:45 +02:00
|
|
|
var DragSource = require('react-dnd').DragSource;
|
2015-08-31 23:08:56 +02:00
|
|
|
|
2015-09-11 16:25:45 +02:00
|
|
|
var DesktopAppItem = React.createClass({
|
2015-08-28 14:20:07 +02:00
|
|
|
|
|
|
|
render: function() {
|
|
|
|
|
|
|
|
var desktopEntry = this.props.desktopEntry;
|
|
|
|
var label = desktopEntry.Name;
|
|
|
|
var category = desktopEntry.Categories;
|
2015-09-03 15:50:23 +02:00
|
|
|
var icon = desktopEntry.Icon;
|
2015-08-28 14:20:07 +02:00
|
|
|
|
2015-09-11 16:25:45 +02:00
|
|
|
var connectDragSource = this.props.connectDragSource;
|
|
|
|
|
|
|
|
return connectDragSource(
|
|
|
|
<li className="desktop-app list-group-item">
|
2015-09-03 15:50:23 +02:00
|
|
|
<AppIcon className="desktop-app-icon" icon={icon} theme={this.props.theme} />
|
2015-08-28 14:20:07 +02:00
|
|
|
<span className="desktop-app-label">{label}</span>
|
|
|
|
</li>
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
2015-09-11 16:25:45 +02:00
|
|
|
|
|
|
|
var dragSourceSpec = {
|
|
|
|
|
|
|
|
beginDrag: function(props) {
|
|
|
|
return props;
|
|
|
|
},
|
|
|
|
|
|
|
|
endDrag: function(props, monitor) {
|
|
|
|
|
|
|
|
if (!monitor.didDrop()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var dropResult = monitor.getDropResult();
|
|
|
|
|
|
|
|
return props.onItemDropped(props.desktopEntry, dropResult);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
function dragSourceCollect(connect, monitor) {
|
|
|
|
return {
|
|
|
|
connectDragSource: connect.dragSource(),
|
|
|
|
isDragging: monitor.isDragging()
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = DragSource('NEW_ITEM', dragSourceSpec, dragSourceCollect)(DesktopAppItem);
|