findbar integration
This commit is contained in:
parent
bee2169aa0
commit
fd8038465e
@ -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 };
|
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));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
@ -3,6 +3,7 @@ import { connect } from 'react-redux';
|
|||||||
import { loadConfig } from '../actions/config';
|
import { loadConfig } from '../actions/config';
|
||||||
import { loginUser } from '../actions/auth';
|
import { loginUser } from '../actions/auth';
|
||||||
import { currentBackend } from '../backends/backend';
|
import { currentBackend } from '../backends/backend';
|
||||||
|
import { LIST_POSTS, LIST_FAQ, HELP } from '../actions/findbar';
|
||||||
import FindBar from './FindBar';
|
import FindBar from './FindBar';
|
||||||
|
|
||||||
class App extends React.Component {
|
class App extends React.Component {
|
||||||
@ -51,14 +52,6 @@ class App extends React.Component {
|
|||||||
render() {
|
render() {
|
||||||
const { user, config, children } = this.props;
|
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) {
|
if (config === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -77,7 +70,11 @@ class App extends React.Component {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<FindBar commands={commands} />
|
<FindBar commands={[
|
||||||
|
{ id: LIST_POSTS, pattern: 'List Posts' },
|
||||||
|
{ id: LIST_FAQ, pattern: 'List FAQs' },
|
||||||
|
{ id: HELP, pattern: 'Help' },
|
||||||
|
]} />
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user