2015-08-28 14:20:07 +02:00
|
|
|
var React = require('react');
|
2015-09-03 15:50:23 +02:00
|
|
|
var connect = require('react-redux').connect;
|
2015-10-09 14:22:23 +02:00
|
|
|
var ProfileTree = require('./profile-tree.js');
|
|
|
|
var DesktopAppList = require('./desktop-app-list.js');
|
|
|
|
var ItemForm = require('./item-form.js');
|
|
|
|
var IconThemeSelector = require('./icon-theme-selector.js');
|
|
|
|
var ProfileMenu = require('./profile-menu.js');
|
2015-09-11 16:25:45 +02:00
|
|
|
|
|
|
|
var actions = require('../../store/actions');
|
|
|
|
var DragDropContext = require('react-dnd').DragDropContext;
|
2017-04-21 14:12:59 +02:00
|
|
|
var HTML5Backend = require('react-dnd-html5-backend');
|
2015-08-28 14:20:07 +02:00
|
|
|
|
2015-09-03 15:50:23 +02:00
|
|
|
var EditView = React.createClass({
|
|
|
|
|
|
|
|
componentDidMount: function() {
|
|
|
|
this.props.dispatch(actions.edit.loadDesktopApps());
|
|
|
|
},
|
2015-08-28 14:20:07 +02:00
|
|
|
|
|
|
|
render: function() {
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="edit">
|
2015-10-16 15:12:49 +02:00
|
|
|
<link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.min.css" />
|
2015-10-13 17:27:15 +02:00
|
|
|
<div className="menu-bar">
|
|
|
|
<div className="left">
|
2015-10-13 14:32:22 +02:00
|
|
|
<ProfileMenu />
|
2015-09-11 16:25:45 +02:00
|
|
|
</div>
|
2015-10-13 17:27:15 +02:00
|
|
|
<div className="main">
|
2015-10-13 20:44:55 +02:00
|
|
|
<div className="full-width">
|
|
|
|
<button className="btn btn-primary pull-right btn-sm" onClick={this.handleAddNewNode}>Ajouter un noeud</button>
|
|
|
|
</div>
|
2015-10-13 17:27:15 +02:00
|
|
|
</div>
|
|
|
|
<div className="right"></div>
|
|
|
|
</div>
|
|
|
|
<div className="workspace">
|
|
|
|
<div className="left">
|
|
|
|
<div className="apps-menu">
|
2015-10-13 20:44:55 +02:00
|
|
|
<b className="title">Thème</b>
|
2015-10-13 17:27:15 +02:00
|
|
|
<IconThemeSelector onThemeSelected={this.handleThemeSelect} />
|
2015-10-13 20:44:55 +02:00
|
|
|
<b className="title">Applications</b>
|
2015-10-13 17:27:15 +02:00
|
|
|
<DesktopAppList
|
|
|
|
theme={this.props.theme}
|
|
|
|
desktopApps={this.props.desktopApps}
|
|
|
|
onItemDropped={this.handleItemDrop} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="main">
|
2015-10-13 20:44:55 +02:00
|
|
|
<b className="title">Arbre de profil</b>
|
2015-10-13 17:27:15 +02:00
|
|
|
<ProfileTree />
|
|
|
|
</div>
|
|
|
|
<div className="right">
|
2015-10-13 20:44:55 +02:00
|
|
|
<b className="title">Édition</b>
|
2015-10-13 17:27:15 +02:00
|
|
|
<ItemForm item={this.props.selectedItem} onItemChange={this.handleItemChange} />
|
|
|
|
</div>
|
2015-09-11 16:25:45 +02:00
|
|
|
</div>
|
2015-08-28 14:20:07 +02:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
|
2015-09-11 16:25:45 +02:00
|
|
|
},
|
|
|
|
|
2015-09-16 17:26:56 +02:00
|
|
|
handleItemDrop: function(desktopEntry, targetItem) {
|
2015-09-11 16:25:45 +02:00
|
|
|
|
|
|
|
var newProfileItem = {
|
|
|
|
label: desktopEntry.Name,
|
|
|
|
icon: desktopEntry.Icon,
|
|
|
|
exec: desktopEntry.Exec
|
|
|
|
};
|
|
|
|
|
|
|
|
this.props.dispatch(actions.edit.addProfileItem(newProfileItem, targetItem));
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2015-09-16 17:26:56 +02:00
|
|
|
handleThemeSelect: function(theme) {
|
|
|
|
this.props.dispatch(actions.edit.useIconTheme(theme));
|
|
|
|
},
|
|
|
|
|
|
|
|
handleItemChange: function(item, key, value) {
|
|
|
|
this.props.dispatch(actions.edit.updateProfileItem(item, key, value));
|
2015-10-16 15:12:49 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
handleAddNewNode: function() {
|
|
|
|
var newItem = {
|
|
|
|
label: 'Nouveau noeud',
|
|
|
|
icon: '',
|
|
|
|
exec: '',
|
|
|
|
background: ''
|
|
|
|
};
|
|
|
|
this.props.dispatch(actions.edit.addProfileItem(newItem, this.props.profile));
|
2015-08-28 14:20:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
2015-09-03 15:50:23 +02:00
|
|
|
|
|
|
|
function select(state) {
|
|
|
|
return {
|
2015-09-11 16:25:45 +02:00
|
|
|
desktopApps: state.desktopApps,
|
|
|
|
profile: state.profile,
|
2015-09-16 17:26:56 +02:00
|
|
|
theme: state.theme,
|
2015-11-03 17:45:37 +01:00
|
|
|
selectedItem: state.selectedItem
|
2015-09-03 15:50:23 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2015-09-11 16:25:45 +02:00
|
|
|
module.exports = DragDropContext(HTML5Backend)(connect(select)(EditView));
|