diff --git a/app/actions/index.jsx b/app/actions/index.jsx new file mode 100644 index 0000000..d137b51 --- /dev/null +++ b/app/actions/index.jsx @@ -0,0 +1,13 @@ +import * as types from '../constants' + +export function updateContextMenu(items) { + return { type: types.UPDATE_CONTEXT_MENU, items } +} + +export function openContextMenu(x, y){ + return {type: types.OPEN_CONTEXT_MENU, x, y} +} + +export function closeContextMenu(){ + return {type: types.CLOSE_CONTEXT_MENU} +} diff --git a/app/constants/index.jsx b/app/constants/index.jsx new file mode 100644 index 0000000..72dd52f --- /dev/null +++ b/app/constants/index.jsx @@ -0,0 +1,3 @@ +export const UPDATE_CONTEXT_MENU = "UPDATE_CONTEXT_MENU" +export const OPEN_CONTEXT_MENU = "OPEN_CONTEXT_MENU" +export const CLOSE_CONTEXT_MENU = "CLOSE_CONTEXT_MENU" diff --git a/app/main.jsx b/app/main.jsx index d58144a..5118131 100644 --- a/app/main.jsx +++ b/app/main.jsx @@ -11,6 +11,20 @@ import Delete from 'material-ui/lib/svg-icons/action/delete' import Divider from 'material-ui/lib/divider' import moment from 'moment' import mui from 'material-ui' +import {Provider} from 'react-redux' +import { createStore } from 'redux' +import rootReducer from './reducers' +import * as ContextMenuActions from './actions' + +import { bindActionCreators } from 'redux' +import { connect } from 'react-redux' + + +function getStore(reducer, initialState){ + return createStore(reducer, initialState) +} + +const store = getStore(rootReducer) const { Popover, @@ -43,11 +57,18 @@ class Main extends React.Component { createTables() this.state = { entries: [], - contextMenuOpen: false, - contextMenuItems: this.context.contextMenuItems } } + static get childContextTypes(){ + return {muiTheme: React.PropTypes.object} + } + + getChildContext() { + return { + muiTheme: getMuiTheme(DefaultRawTheme) + } + } entriesTapped = () => { r.table('notes').getAll('jyapayne@gmail.com', {index: 'account_id'}).run().then( @@ -58,33 +79,27 @@ class Main extends React.Component { }; handleRequestClose = () => { - this.setState({ - contextMenuOpen: false, - }) + this.props.contextMenuActions.closeContextMenu() }; - tapped = () => { - console.log('tapped') - console.log(this.context.contextMenuItems) - }; - render() { + const { contextMenu, contextMenuActions } = this.props return ( -