Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/initial task flow #103

Merged
merged 19 commits into from
Jul 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
f06decd
feat(db): add task migration
ahdinosaur Jul 13, 2017
6d536d2
feat(db): add dev seed
ahdinosaur Jul 13, 2017
212efc3
chore(babel): add babel-plugin to transform class properties
ahdinosaur Jul 13, 2017
772564f
chore(tasks): fixup rename subTaskPlans to childTaskPlans to match mi…
ahdinosaur Jul 13, 2017
e4f2ed9
feat(tasks): add helper to create simple or nested task plan, with te…
ahdinosaur Jul 13, 2017
09113a4
feat(nav): integrate new Navigation component with app
ahdinosaur Jul 14, 2017
01cb333
feat(nav): fancy conditional routes for Home or Dashboard at /
ahdinosaur Jul 14, 2017
f0d3304
load current agent in layout
ahdinosaur Jul 14, 2017
d5eefc1
fix auth hoc bug
ahdinosaur Jul 14, 2017
0dd3fd7
feat(dashboard): added container for dashboard
gregorykan Jul 14, 2017
9033c1f
feat(dashboard): repathed for dashboard container
gregorykan Jul 14, 2017
b631fa2
feat(dashboard): added store file for taskPlans
gregorykan Jul 14, 2017
13e05a9
feat(dashboard): added taskPlans refs to epic and updater files. init…
gregorykan Jul 14, 2017
226960f
feat(tasks): setup taskPlans and taskWorks redux modules
ahdinosaur Jul 14, 2017
acee5bc
feat(tasks): add taskPlans and taskWorks services
ahdinosaur Jul 14, 2017
74bad2b
feat(dashboard): updated path for task plans dux stuff
gregorykan Jul 14, 2017
f7327ce
feat(dashboard): updated container to handle both plan and work actio…
gregorykan Jul 14, 2017
387a83e
feat(dashboard): hook in 'open order' button to ordering actions and …
ahdinosaur Jul 14, 2017
e39f45d
chore(app): fix storybook
ahdinosaur Jul 14, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions agents/components/LogOut.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,23 @@ import { FormattedMessage } from '../../lib/Intl'
import styles from '../styles/LogOut'

function LogOut (props) {
const { styles, actions } = props
const {
styles,
actions,
as: Component = FlatButton,
...moreProps
} = props
return (
<FlatButton
<Component
className={styles.container}
backgroundColor='#ddd'
onClick={actions.authentication.logOut}
{...moreProps}
>
<FormattedMessage
id='agents.logout'
id='agents.logOut'
className={styles.buttonText}
/>
</FlatButton>
</Component>
)
}

Expand Down
2 changes: 1 addition & 1 deletion agents/containers/LogOut.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import LogOut from '../components/LogOut'

export default flow(
connectFeathers({
selector: (state) => ({}),
selector: (state, ownProps) => ownProps,
actions: { authentication: { logOut } },
query: []
})
Expand Down
8 changes: 6 additions & 2 deletions app/components/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import styles from '../styles/Dashboard'
import { FormattedMessage } from '../../lib/Intl'

function Dashboard (props) {
const { styles, startOrder } = props
const { styles, actions } = props

return (
<div className={styles.container}>
Expand All @@ -18,7 +18,11 @@ function Dashboard (props) {
/>
</p>
<div className={styles.buttonContainer}>
<RaisedButton className={styles.button} type='button' onClick={startOrder}>
<RaisedButton
className={styles.button}
type='button'
onClick={actions.ordering.startOrder}
>
<FormattedMessage
id='app.startOrder'
className={styles.labelText}
Expand Down
4 changes: 2 additions & 2 deletions app/components/layout.js → app/components/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { createComponent } from '@ahdinosaur/react-fela'
import { Route, Switch } from 'react-router-dom'
import { pipe, map, values, isNil } from 'ramda'

import styles from '../styles/layout'
import styles from '../styles/Layout'

import Nav from './nav'
import Nav from './Navigation'

const Container = createComponent(styles.container, 'div')

Expand Down
72 changes: 49 additions & 23 deletions app/components/Navigation.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,63 @@
import React from 'react'
import { connect as connectFela } from 'react-fela'
import { not } from 'ramda'
import { not, pipe, map, values, isNil } from 'ramda'
import AppBar from 'material-ui/AppBar'
import Drawer from 'material-ui/Drawer'
import MenuItem from 'material-ui/MenuItem'
import Divider from 'material-ui/Divider'
import { withState, withHandlers, compose } from 'recompose'
import { NavLink } from 'react-router-dom'

import styles from '../styles/Navigation'
import { FormattedMessage } from '../../lib/Intl'
import LogOut from '../../agents/containers/LogOut'

function Navigation (props) {
const { styles, isDrawerOpen, toggleDrawer } = props
const { styles, isDrawerOpen, toggleDrawer, navigationRoutes } = props

const mapRouteItems = pipe(
map(route => {
const {
path,
name = path,
navigation
} = route

const {
Component,
title = name,
icon
} = navigation

if (Component) {
return (
<Component
key={name}
as={MenuItem}
leftIcon={
<i className={icon} aria-hidden="true" />
}
/>
)
}

return (
<NavLink to={path} key={name}>
<MenuItem
leftIcon={
<i className={icon} aria-hidden="true" />
}
>
<FormattedMessage
id={title}
className={styles.labelText}
/>
</MenuItem>
</NavLink>
)
}),
values
)

return (
<div>
Expand All @@ -37,27 +83,7 @@ function Navigation (props) {
/>
</MenuItem>
<Divider />
<MenuItem
leftIcon={
<i className="fa fa-tachometer" aria-hidden="true" />
}
>
<FormattedMessage
id='app.dashboard'
className={styles.labelText}
/>
</MenuItem>
<Divider />
<MenuItem
leftIcon={
<i className="fa fa-sign-out" aria-hidden="true" />
}
>
<FormattedMessage
id='app.logOut'
className={styles.labelText}
/>
</MenuItem>
{mapRouteItems(navigationRoutes)}
<Divider />
</Drawer>
</div>
Expand Down
38 changes: 0 additions & 38 deletions app/components/nav.js

This file was deleted.

26 changes: 26 additions & 0 deletions app/containers/Dashboard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { connect } from 'feathers-action-react'

import Dashboard from '../components/Dashboard'
import { actions as taskPlanActions } from '../../tasks/dux/plans'
import { actions as taskWorkActions } from '../../tasks/dux/works'
import * as orderingActions from '../../ordering/actions'
import { getDashboardProps } from '../getters'

export default connect({
selector: getDashboardProps,
actions: {
taskPlans: taskPlanActions,
taskWorks: taskWorkActions,
ordering: orderingActions
},
query: [
{
service: 'taskPlans',
params: {}
},
{
service: 'taskWorks',
params: {}
}
]
})(Dashboard)
5 changes: 3 additions & 2 deletions app/containers/layout.js → app/containers/Layout.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { connect } from 'react-redux'

import Layout from '../components/layout'
import Layout from '../components/Layout'

import { getLayoutProps } from '../getters'

export default connect(
getLayoutProps
getLayoutProps,

)(Layout)
20 changes: 19 additions & 1 deletion app/getters.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
import { createSelector, createStructuredSelector } from 'reselect'
import { pipe, not, isNil, map, filter, prop, propOr, indexBy, nthArg, uncurryN } from 'ramda'
import getCurrentAgent from 'dogstack-agents/agents/getters/getCurrentAgent'

export const getState = state => state
export const getConfig = prop('config')

export const getHomeProps = (state) => ({})

export const getRoutes = pipe(
export const getAllRoutes = pipe(
nthArg(1),
propOr(null, 'routes')
)

export const getRoutes = createSelector(
getState,
getAllRoutes,
uncurryN(2, state => filter(route => {
const { selector } = route
return isNil(selector) || selector(state)
}))
)

const indexByName = indexBy(prop('name'))
const filterNil = filter(pipe(isNil, not))
export const getNavigationRoutes = createSelector(
Expand All @@ -29,6 +39,14 @@ export const getNavigationRoutes = createSelector(
)

export const getLayoutProps = createStructuredSelector({
currentAgent: getCurrentAgent,
routes: getRoutes,
navigationRoutes: getNavigationRoutes
})

// GK: just temporary so i can see that shit is flowing
export const getTaskPlans = (state) => state.taskPlans

export const getDashboardProps = createStructuredSelector({
taskPlans: getTaskPlans
})
5 changes: 3 additions & 2 deletions app/locales/en.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{
"app.name": "Cobuy",
"app.closeMenu": "close menu",
"app.home": "home",
"app.dashboard": "dashboard",
"app.logOut": "log out",
"app.startOrder": "start order",
"agents.nameLabel": "name",
"agents.descriptionLabel": "description",
"agents.logout": "log out",
"agents.email": "email",
"agents.role": "role",
"agents.password": "password",
Expand All @@ -17,7 +16,9 @@
"agents.editProfile": "edit profile",
"agents.saveProfile": "save profile",
"agents.createAccount": "create new account",
"agents.register": "register",
"agents.signIn": "sign in",
"agents.logOut": "log out",
"agents.welcome": "hey, welcome to cobuy!",
"agents.signInWith": "sign in with...",
"agents.saveAvatar": "save avatar",
Expand Down
9 changes: 8 additions & 1 deletion app/stories/Dashboard.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import React from 'react'
import { storiesOf } from '@storybook/react'
import { action } from '@storybook/addon-actions'

import Dashboard from '../components/Dashboard'

const actions = {
ordering: {
startOrder: action('ordering.startOrder')
}
}

storiesOf('app.Dashboard', module)
.add('default', () => (
<Dashboard startOrder={() => console.log('start the machine')} />
<Dashboard actions={actions} />
))
2 changes: 1 addition & 1 deletion app/stories/Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import Navigation from '../components/Navigation'

storiesOf('app.Navigation', module)
.add('default', () => (
<Navigation />
<Navigation navigationRoutes={[]} />
))
File renamed without changes.
8 changes: 0 additions & 8 deletions app/styles/nav.js

This file was deleted.

21 changes: 21 additions & 0 deletions db/migrations/20170713153018_add-tasks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
exports.up = function (knex, Promise) {
return Promise.all([
knex.schema.createTableIfNotExists('taskPlans', function (table) {
table.increments('id')
table.string('taskRecipeId').notNullable()
table.string('assignee').notNullable()
}),
knex.schema.createTableIfNotExists('taskWorks', function (table) {
table.increments('id')
table.integer('taskPlanId').references('taskPlans.id').notNullable()
table.integer('workerAgentId').references('agents.id').notNullable()
})
])
}

exports.down = function (knex, Promise) {
return Promise.all([
knex.schema.dropTableIfExists('taskPlans'),
knex.schema.dropTableIfExists('taskWorks')
])
}
Loading