diff --git a/src/actions/findbar.js b/src/actions/findbar.js index 68db0399..2e990088 100644 --- a/src/actions/findbar.js +++ b/src/actions/findbar.js @@ -10,14 +10,18 @@ export function run(commandName, payload) { return { type: RUN_COMMAND, command: commandName, payload }; } +export function createNewEntryInCollection(collectionName) { + return runCommand(CREATE_COLLECTION, { collectionName }); +} + export function runCommand(commandName, payload) { - return (dispatch, getState) => { + return dispatch => { switch (commandName) { case SHOW_COLLECTION: history.push(`/collections/${payload.collectionName}`); break; case CREATE_COLLECTION: - window.alert(`Create a new ${payload.collectionName} - not supported yet`); + history.push(`/collections/${payload.collectionName}/entries/new`); break; case HELP: window.alert('Find Bar Help (PLACEHOLDER)\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit.'); diff --git a/src/containers/App.css b/src/containers/App.css index 59a39646..defe191a 100644 --- a/src/containers/App.css +++ b/src/containers/App.css @@ -16,6 +16,8 @@ color: #fff; } +.actions {} + .findBar { flex: 1; } diff --git a/src/containers/App.js b/src/containers/App.js index 64a56d4d..c784d614 100644 --- a/src/containers/App.js +++ b/src/containers/App.js @@ -1,14 +1,19 @@ import React from 'react'; import { connect } from 'react-redux'; import { IndexLink } from 'react-router'; +import pluralize from 'pluralize'; import { loadConfig } from '../actions/config'; import { loginUser } from '../actions/auth'; import { currentBackend } from '../backends/backend'; import { Loader } from '../components/UI'; -import { SHOW_COLLECTION, CREATE_COLLECTION, HELP } from '../actions/findbar'; +import { + SHOW_COLLECTION, + CREATE_COLLECTION, + HELP, + createNewEntryInCollection +} from '../actions/findbar'; import FindBar from './FindBar'; import styles from './App.css'; -import pluralize from 'pluralize'; class App extends React.Component { componentDidMount() { @@ -84,8 +89,14 @@ class App extends React.Component { return { commands, defaultCommands }; } + handleCreatePostClick = collectionName => { + this.props.dispatch( + createNewEntryInCollection(collectionName) + ); + } + render() { - const { user, config, children } = this.props; + const { user, config, children, collections } = this.props; if (config === null) { return null; @@ -117,6 +128,16 @@ class App extends React.Component { defaultCommands={defaultCommands} /> +
+ { + collections.map(collection => + ) + } +
{children}