47 lines
906 B
React
47 lines
906 B
React
|
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))
|
||
|
;
|
||
|
|
||
|
}
|
||
|
|
||
|
});
|