pitaya-launcher/js/components/desktop-app-item.jsx

47 lines
906 B
React
Raw Normal View History

2015-08-28 14:20:07 +02:00
var React = require('react');
var Util = require('../util');
module.exports = React.createClass({
getInitialState: function() {
return { icon: '' };
},
render: function() {
var desktopEntry = this.props.desktopEntry;
var label = desktopEntry.Name;
var category = desktopEntry.Categories;
// Search for best icon
var icon = '';
if(!this.state.icon) {
this._findIcon(desktopEntry.Icon);
} else {
icon = this.state.icon;
}
return (
<li className="desktop-app">
<img src={icon} className="desktop-app-icon" />
<span className="desktop-app-label">{label}</span>
</li>
);
},
_findIcon: function(iconPath) {
var desktopEntry = this.props.desktopEntry;
Util.DesktopApps.findIcon(iconPath)
.then(function(iconPath) {
this.setState({ icon: iconPath });
}.bind(this))
;
}
});