insomnia/app/redux/modules/workspaces.js

39 lines
770 B
JavaScript
Raw Normal View History

import {combineReducers} from 'redux';
import {MODAL_WORKSPACE_RENAME} from '../../lib/constants';
import {show} from './modals';
2016-04-23 06:08:52 +00:00
export const WORKSPACE_ACTIVATE = 'workspaces/activate';
// ~~~~~~~~ //
// REDUCERS //
// ~~~~~~~~ //
function activeReducer (state = null, action) {
switch (action.type) {
case WORKSPACE_ACTIVATE:
return action.workspace._id;
2016-04-23 06:08:52 +00:00
default:
return state;
}
}
export default combineReducers({
activeId: activeReducer
2016-04-23 06:08:52 +00:00
});
// ~~~~~~~ //
// ACTIONS //
// ~~~~~~~ //
export function activate (workspace) {
return {type: WORKSPACE_ACTIVATE, workspace};
2016-04-23 06:08:52 +00:00
}
export function showUpdateNamePrompt (workspace) {
const defaultValue = workspace.name;
return show(MODAL_WORKSPACE_RENAME, {defaultValue, workspace});
2016-04-23 06:08:52 +00:00
}