fix rename: Fixed Renaming Directories not working properly
feat dialogs.error: Added Error dialogs to show errors
This commit is contained in:
@ -18,6 +18,7 @@ export default function(state = new Immutable.Map(), action) {
|
||||
fileMenu: menu(state, action, 'fileMenu'),
|
||||
directoryMenu: menu(state, action, 'directoryMenu'),
|
||||
renameDialog: dialog(state, action, 'renameDialog'),
|
||||
deleteDialog: dialog(state, action, 'deleteDialog')
|
||||
deleteDialog: dialog(state, action, 'deleteDialog'),
|
||||
errorDialog: dialog(state, action, 'errorDialog')
|
||||
});
|
||||
}
|
||||
|
@ -1,11 +1,13 @@
|
||||
import { DIALOG } from 'actions/types';
|
||||
import Immutable from 'immutable';
|
||||
import omit from 'lodash/object/omit';
|
||||
|
||||
export default function(state = new Immutable.Map({}), action, id) {
|
||||
if (action.type === DIALOG) {
|
||||
let useful = omit(action, ['id', 'type'])
|
||||
// action applied to all dialogs
|
||||
if (!action.id) {
|
||||
return Object.assign({}, state.get(id), {active: action.active});
|
||||
return Object.assign({}, state.get(id), useful);
|
||||
}
|
||||
|
||||
if (action.id !== id) return state.get(id);
|
||||
@ -13,9 +15,7 @@ export default function(state = new Immutable.Map({}), action, id) {
|
||||
let target = state.get(action.id);
|
||||
let active = action.active === 'toggle' ? !target.get('active') : action.active;
|
||||
|
||||
let style = Object.assign({}, state.style, {left: action.x, top: action.y});
|
||||
|
||||
return Object.assign({}, target, { style, active });
|
||||
return Object.assign({}, target, useful);
|
||||
} else {
|
||||
return state.get(id);
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
import { LIST_FILES, RENAME_FILE, DELETE_FILE } from 'actions/types';
|
||||
import { refresh } from 'actions/files-view';
|
||||
import { rename, sdcard } from 'api/files';
|
||||
import { move, sdcard } from 'api/files';
|
||||
import { show } from 'actions/dialog';
|
||||
import store from 'store';
|
||||
|
||||
export default function(state = [], action) {
|
||||
if (action.type === LIST_FILES) {
|
||||
@ -11,7 +13,10 @@ export default function(state = [], action) {
|
||||
if (action.type === RENAME_FILE) {
|
||||
let file = state[action.file];
|
||||
|
||||
rename(file, action.name).then(refresh);
|
||||
move(file, (file.path || '') + action.name).then(refresh, err => {
|
||||
let action = show('errorDialog', {description: err.message});
|
||||
store.dispatch(action);
|
||||
});
|
||||
|
||||
return state;
|
||||
}
|
||||
|
@ -1,11 +1,13 @@
|
||||
import { MENU } from 'actions/types';
|
||||
import Immutable from 'immutable';
|
||||
import omit from 'lodash/object/omit';
|
||||
|
||||
export default function(state = new Immutable.Map({}), action, id) {
|
||||
if (action.type === MENU) {
|
||||
let useful = omit(action, ['id', 'type'])
|
||||
// action applied to all menus
|
||||
if (!action.id) {
|
||||
return Object.assign({}, state.get(id), {active: action.active});
|
||||
return Object.assign({}, state.get(id), useful);
|
||||
}
|
||||
|
||||
if (action.id !== id) return state.get(id);
|
||||
@ -13,9 +15,7 @@ export default function(state = new Immutable.Map({}), action, id) {
|
||||
let target = state.get(action.id);
|
||||
let active = action.active === 'toggle' ? !target.get('active') : action.active;
|
||||
|
||||
let style = Object.assign({}, state.style, {left: action.x, top: action.y});
|
||||
|
||||
return Object.assign({}, target, { style, active });
|
||||
return Object.assign({}, target, useful);
|
||||
} else {
|
||||
return state.get(id);
|
||||
}
|
||||
|
Reference in New Issue
Block a user