/* jhsint node:true, jsx: true */ var React = require('react'); var connect = require('react-redux').connect; var actions = require('../../store/actions'); var dialog = require('electron').remote.dialog; var ProfileMenu = React.createClass({ render: function() { return (
); }, handleOpenClick: function() { var dispatch = this.props.dispatch; this.showOpenProfileDialog() .then(function(profilePath) { if(profilePath) dispatch(actions.common.loadProfile(profilePath, false)); }) ; }, handleSaveClick: function() { var dispatch = this.props.dispatch; var profile = this.props.profile; var profilePath = this.props.profilePath; this.showSaveProfileDialog(profilePath) .then(function(profilePath) { if(profilePath) dispatch(actions.edit.saveProfile(profilePath, profile)); }); }, showOpenProfileDialog: function() { return new Promise(function(resolve) { dialog.showOpenDialog( { title: 'Éditer un profil', filters: [ {name: 'Profils Pitaya', extensions: ['json'] } ], properties: ['openFile'] }, function(files) { return resolve(files ? files[0] : null); } ) }); }, showSaveProfileDialog: function(defaultPath) { return new Promise(function(resolve) { dialog.showSaveDialog( { defaultPath: defaultPath, title: 'Enregistrer un profil', filters: [ {name: 'Profils Pitaya', extensions: ['json'] } ] }, function(file) { return resolve(file); } ) }); } }); function select(state) { return { profile: state.profile, profilePath: state.profilePath }; } module.exports = connect(select)(ProfileMenu);