parent
8593b3f5cd
commit
e8056d2a70
6 changed files with 123 additions and 78 deletions
@ -0,0 +1,28 @@ |
||||
import actions from '../actions'; |
||||
|
||||
export function showCommand(text) { |
||||
return { |
||||
type: actions.CONSOLE_SHOW_COMMAND, |
||||
text: text |
||||
}; |
||||
} |
||||
|
||||
export function setCompletions(completions) { |
||||
return {
|
||||
type: actions.CONSOLE_SET_COMPLETIONS, |
||||
completions: completions |
||||
}; |
||||
} |
||||
|
||||
export function showError(text) { |
||||
return { |
||||
type: actions.CONSOLE_SHOW_ERROR, |
||||
text: text |
||||
}; |
||||
} |
||||
|
||||
export function hide() { |
||||
return {
|
||||
type: actions.CONSOLE_HIDE |
||||
}; |
||||
} |
@ -0,0 +1,6 @@ |
||||
export default { |
||||
CONSOLE_SHOW_COMMAND: 'vimvixen.console.show.command', |
||||
CONSOLE_SET_COMPLETIONS: 'vimvixen.console.set.completions', |
||||
CONSOLE_SHOW_ERROR: 'vimvixen.console.show.error', |
||||
CONSOLE_HIDE: 'vimvixen.console.hide' |
||||
}; |
@ -0,0 +1,39 @@ |
||||
import actions from '../actions'; |
||||
|
||||
export const defaultState = { |
||||
errorText: '', |
||||
errorShown: false, |
||||
commandText: '', |
||||
commandShown: false, |
||||
completions: [], |
||||
}; |
||||
|
||||
export default function reducer(state = defaultState, action = {}) { |
||||
switch (action.type) { |
||||
case actions.CONSOLE_SHOW_COMMAND: |
||||
return Object.assign({}, state, { |
||||
commandShown: true,
|
||||
commandText: action.text, |
||||
errorShow: false, |
||||
completions: [] |
||||
}); |
||||
case actions.CONSOLE_SET_COMPLETIONS: |
||||
return Object.assign({}, state, { |
||||
completions: action.completions |
||||
}); |
||||
case actions.CONSOLE_SHOW_ERROR: |
||||
return Object.assign({}, state, { |
||||
errorText: action.message, |
||||
errorShow: true, |
||||
commandShown: false, |
||||
}); |
||||
case actions.CONSOLE_HIDE: |
||||
return Object.assign({}, state, { |
||||
errorShown: false, |
||||
commandShown: false |
||||
|
||||
}); |
||||
default: |
||||
return state; |
||||
} |
||||
} |
Reference in new issue