Generating findbar commands dynamically based on config

This commit is contained in:
Cássio Zen
2016-07-20 12:15:29 -03:00
parent 9f220181b3
commit 7345c7bd32
4 changed files with 55 additions and 17 deletions

@ -2,8 +2,8 @@ import history from '../routing/history';
import { SEARCH } from '../containers/FindBar';
export const RUN_COMMAND = 'RUN_COMMAND';
export const LIST_POSTS = 'LIST_POSTS';
export const LIST_FAQ = 'LIST_FAQ';
export const SHOW_COLLECTION = 'SHOW_COLLECTION';
export const CREATE_COLLECTION = 'CREATE_COLLECTION';
export const HELP = 'HELP';
export function run(commandName, payload) {
@ -13,11 +13,11 @@ export function run(commandName, payload) {
export function runCommand(commandName, payload) {
return (dispatch, getState) => {
switch (commandName) {
case LIST_POSTS:
history.push('/collections/posts');
case SHOW_COLLECTION:
history.push(`/collections/${payload.collectionName}`);
break;
case LIST_FAQ:
history.push('/collections/faq');
case CREATE_COLLECTION:
window.alert(`Create a new ${payload.collectionName} - not supported yet`);
break;
case HELP:
window.alert('Find Bar Help (PLACEHOLDER)\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit.');