add hide action for console
This commit is contained in:
parent
0211d7781f
commit
37410b874f
6 changed files with 26 additions and 1 deletions
|
@ -1,5 +1,11 @@
|
||||||
import actions from 'console/actions';
|
import actions from 'console/actions';
|
||||||
|
|
||||||
|
const hide = () => {
|
||||||
|
return {
|
||||||
|
type: actions.CONSOLE_HIDE,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
const showCommand = (text) => {
|
const showCommand = (text) => {
|
||||||
return {
|
return {
|
||||||
type: actions.CONSOLE_SHOW_COMMAND,
|
type: actions.CONSOLE_SHOW_COMMAND,
|
||||||
|
@ -61,6 +67,6 @@ const completionPrev = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export {
|
export {
|
||||||
showCommand, showFind, showError, showInfo, hideCommand, setConsoleText,
|
hide, showCommand, showFind, showError, showInfo, hideCommand, setConsoleText,
|
||||||
setCompletions, completionNext, completionPrev
|
setCompletions, completionNext, completionPrev
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
export default {
|
export default {
|
||||||
// console commands
|
// console commands
|
||||||
|
CONSOLE_HIDE: 'console.hide',
|
||||||
CONSOLE_SHOW_COMMAND: 'console.show.command',
|
CONSOLE_SHOW_COMMAND: 'console.show.command',
|
||||||
CONSOLE_SHOW_ERROR: 'console.show.error',
|
CONSOLE_SHOW_ERROR: 'console.show.error',
|
||||||
CONSOLE_SHOW_INFO: 'console.show.info',
|
CONSOLE_SHOW_INFO: 'console.show.info',
|
||||||
|
|
|
@ -24,6 +24,8 @@ const onMessage = (message) => {
|
||||||
return store.dispatch(consoleActions.showError(message.text));
|
return store.dispatch(consoleActions.showError(message.text));
|
||||||
case messages.CONSOLE_SHOW_INFO:
|
case messages.CONSOLE_SHOW_INFO:
|
||||||
return store.dispatch(consoleActions.showInfo(message.text));
|
return store.dispatch(consoleActions.showInfo(message.text));
|
||||||
|
case messages.CONSOLE_HIDE:
|
||||||
|
return store.dispatch(consoleActions.hide());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,10 @@ const nextConsoleText = (completions, group, item, defaults) => {
|
||||||
|
|
||||||
export default function reducer(state = defaultState, action = {}) {
|
export default function reducer(state = defaultState, action = {}) {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
|
case actions.CONSOLE_HIDE:
|
||||||
|
return Object.assign({}, state, {
|
||||||
|
mode: '',
|
||||||
|
});
|
||||||
case actions.CONSOLE_SHOW_COMMAND:
|
case actions.CONSOLE_SHOW_COMMAND:
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
mode: 'command',
|
mode: 'command',
|
||||||
|
|
|
@ -3,6 +3,12 @@ import actions from 'console/actions';
|
||||||
import * as consoleActions from 'console/actions/console';
|
import * as consoleActions from 'console/actions/console';
|
||||||
|
|
||||||
describe("console actions", () => {
|
describe("console actions", () => {
|
||||||
|
describe('hide', () => {
|
||||||
|
it('create CONSOLE_HIDE action', () => {
|
||||||
|
let action = consoleActions.hide();
|
||||||
|
expect(action.type).to.equal(actions.CONSOLE_HIDE);
|
||||||
|
});
|
||||||
|
});
|
||||||
describe("showCommand", () => {
|
describe("showCommand", () => {
|
||||||
it('create CONSOLE_SHOW_COMMAND action', () => {
|
it('create CONSOLE_SHOW_COMMAND action', () => {
|
||||||
let action = consoleActions.showCommand('hello');
|
let action = consoleActions.showCommand('hello');
|
||||||
|
|
|
@ -13,6 +13,12 @@ describe("console reducer", () => {
|
||||||
expect(state).to.have.property('itemSelection', -1);
|
expect(state).to.have.property('itemSelection', -1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('return next state for CONSOLE_HIDE', () => {
|
||||||
|
let action = { type: actions.CONSOLE_HIDE };
|
||||||
|
let state = reducer({ mode: 'error' }, action);
|
||||||
|
expect(state).to.have.property('mode', '');
|
||||||
|
})
|
||||||
|
|
||||||
it('return next state for CONSOLE_SHOW_COMMAND', () => {
|
it('return next state for CONSOLE_SHOW_COMMAND', () => {
|
||||||
let action = { type: actions.CONSOLE_SHOW_COMMAND, text: 'open ' };
|
let action = { type: actions.CONSOLE_SHOW_COMMAND, text: 'open ' };
|
||||||
let state = reducer({}, action);
|
let state = reducer({}, action);
|
||||||
|
|
Reference in a new issue