Edition via drag & drop des items
This commit is contained in:
49
js/store/actions/edit.js
Normal file
49
js/store/actions/edit.js
Normal file
@ -0,0 +1,49 @@
|
||||
var Util = require('../../util');
|
||||
var path = require('path');
|
||||
|
||||
// Action types
|
||||
var LOAD_DESKTOP_APPS = exports.LOAD_PROFILE = 'LOAD_DESKTOP_APPS';
|
||||
var LOAD_DESKTOP_APPS_SUCCESS = exports.LOAD_DESKTOP_APPS_SUCCESS = 'LOAD_DESKTOP_APPS_SUCCESS';
|
||||
var LOAD_DESKTOP_APPS_FAILED = exports.LOAD_DESKTOP_APPS_FAILED = 'LOAD_DESKTOP_APPS_FAILED';
|
||||
var MOVE_PROFILE_ITEM = exports.MOVE_PROFILE_ITEM = 'MOVE_PROFILE_ITEM';
|
||||
var ADD_PROFILE_ITEM = exports.ADD_PROFILE_ITEM = 'ADD_PROFILE_ITEM';
|
||||
|
||||
// Actions creators
|
||||
|
||||
exports.loadDesktopApps = function() {
|
||||
return function(dispatch, getState) {
|
||||
|
||||
var baseDirs = global.process.env.XDG_DATA_DIRS.split(':').map(function(baseDir){
|
||||
return path.join(baseDir, 'applications');
|
||||
});
|
||||
|
||||
dispatch({ type: LOAD_DESKTOP_APPS });
|
||||
|
||||
return Util.DesktopApps.loadAllDesktopFiles(baseDirs)
|
||||
.then(function(desktopApps) {
|
||||
dispatch({ type: LOAD_DESKTOP_APPS_SUCCESS, desktopApps: desktopApps });
|
||||
})
|
||||
.catch(function(err) {
|
||||
dispatch({ type: LOAD_DESKTOP_APPS_FAILED, error: err });
|
||||
})
|
||||
;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
exports.moveProfileItem = function(movedItem, targetItem) {
|
||||
return {
|
||||
type: 'MOVE_PROFILE_ITEM',
|
||||
movedItem: movedItem,
|
||||
targetItem: targetItem
|
||||
};
|
||||
};
|
||||
|
||||
exports.addProfileItem = function(newItem, targetItem) {
|
||||
return {
|
||||
type: 'ADD_PROFILE_ITEM',
|
||||
newItem: newItem,
|
||||
targetItem: targetItem
|
||||
};
|
||||
};
|
2
js/store/actions/index.js
Normal file
2
js/store/actions/index.js
Normal file
@ -0,0 +1,2 @@
|
||||
exports.launcher = require('./launcher');
|
||||
exports.edit = require('./edit');
|
51
js/store/actions/launcher.js
Normal file
51
js/store/actions/launcher.js
Normal file
@ -0,0 +1,51 @@
|
||||
var Util = require('../../util');
|
||||
|
||||
var LOAD_PROFILE = exports.LOAD_PROFILE = 'LOAD_PROFILE';
|
||||
var LOAD_PROFILE_SUCCESS = exports.LOAD_PROFILE_SUCCESS = 'LOAD_PROFILE_SUCCESS';
|
||||
var LOAD_PROFILE_FAILED = exports.LOAD_PROFILE_FAILED = 'LOAD_PROFILE_FAILED';
|
||||
|
||||
var RUN_APP = exports.RUN_APP = 'RUN_APP';
|
||||
var RUN_APP_SUCCESS = exports.RUN_APP_SUCCESS = 'RUN_APP_SUCCESS';
|
||||
var RUN_APP_FAILED = exports.RUN_APP_FAILED = 'RUN_APP_FAILED';
|
||||
|
||||
exports.loadProfile = function(profilePath) {
|
||||
|
||||
return function(dispatch, getState) {
|
||||
|
||||
dispatch({ type: LOAD_PROFILE, profilePath: profilePath });
|
||||
|
||||
return Util.System.loadJSONFile(profilePath)
|
||||
.then(function(profile) {
|
||||
dispatch({ type: LOAD_PROFILE_SUCCESS, profile: profile });
|
||||
return profile;
|
||||
})
|
||||
.catch(function(err) {
|
||||
dispatch({ type: LOAD_PROFILE_FAILED, error: err });
|
||||
return err;
|
||||
})
|
||||
;
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
exports.runApp = function(execPath) {
|
||||
|
||||
return function(dispatch, getState) {
|
||||
|
||||
dispatch({ type: RUN_APP, execPath: execPath });
|
||||
|
||||
return Util.System.runApp(execPath)
|
||||
.then(function() {
|
||||
dispatch({ type: RUN_APP_SUCCESS, execPath: execPath });
|
||||
return execPath;
|
||||
})
|
||||
.catch(function(err) {
|
||||
dispatch({ type: RUN_APP_FAILED, error: err });
|
||||
return err;
|
||||
})
|
||||
;
|
||||
|
||||
};
|
||||
|
||||
};
|
Reference in New Issue
Block a user