diff --git a/src/actions/findbar.js b/src/actions/findbar.js index 91f38c30..db178b82 100644 --- a/src/actions/findbar.js +++ b/src/actions/findbar.js @@ -1,5 +1,33 @@ -export const RUN_COMMAND = 'RUN_COMMAND'; +import { browserHistory } from 'react-router'; +import { SEARCH } from '../containers/FindBar'; -export function runCommand(commandName, payload) { +export const RUN_COMMAND = 'RUN_COMMAND'; +export const LIST_POSTS = 'LIST_POSTS'; +export const LIST_FAQ = 'LIST_FAQ'; +export const HELP = 'HELP'; + + +export function run(commandName, payload) { return { type: RUN_COMMAND, command: commandName, payload }; } + + +export function runCommand(commandName, payload) { + return (dispatch, getState) => { + switch (commandName) { + case LIST_POSTS: + browserHistory.push('/collections/posts'); + break; + case LIST_FAQ: + browserHistory.push('/collections/faq'); + break; + case HELP: + window.alert('Find Bar Help (PLACEHOLDER)\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit.'); + break; + case SEARCH: + browserHistory.push('/search'); + break; + } + dispatch(run(commandName, payload)); + }; +} diff --git a/src/containers/App.js b/src/containers/App.js index 235dd7a8..cc105bc7 100644 --- a/src/containers/App.js +++ b/src/containers/App.js @@ -3,6 +3,7 @@ import { connect } from 'react-redux'; import { loadConfig } from '../actions/config'; import { loginUser } from '../actions/auth'; import { currentBackend } from '../backends/backend'; +import { LIST_POSTS, LIST_FAQ, HELP } from '../actions/findbar'; import FindBar from './FindBar'; class App extends React.Component { @@ -51,14 +52,6 @@ class App extends React.Component { render() { const { user, config, children } = this.props; - const commands = [ - { pattern: 'Create new Post(:postName)' }, - { pattern: 'Create new FAQ item(:faqName as FAQ item name)' }, - { pattern: 'Add new User(:userName as User name)' }, - { pattern: 'Go to Settings' }, - ]; - - if (config === null) { return null; } @@ -77,7 +70,11 @@ class App extends React.Component { return (