Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions agents/getters/getAgents.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const getAgents = (state) => state.agents

export default getAgents
2 changes: 1 addition & 1 deletion app/containers/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ 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'
import getDashboardProps from '../getters/getDashboardProps'

export default connect({
selector: getDashboardProps,
Expand Down
2 changes: 1 addition & 1 deletion app/containers/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { connect } from 'react-redux'

import Layout from '../components/Layout'

import { getLayoutProps } from '../getters'
import getLayoutProps from '../getters/getLayoutProps'

export default connect(
getLayoutProps,
Expand Down
2 changes: 1 addition & 1 deletion app/containers/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { connect } from 'react-redux'

import Home from '../components/home'

import { getHomeProps } from '../getters'
import getHomeProps from '../getters/getHomeProps'

export default connect(
getHomeProps
Expand Down
8 changes: 8 additions & 0 deletions app/getters/getAllRoutes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { pipe, nthArg, propOr } from 'ramda'

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

export default getAllRoutes
5 changes: 5 additions & 0 deletions app/getters/getConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { prop } from 'ramda'

const getConfig = prop('config')

export default getConfig
9 changes: 9 additions & 0 deletions app/getters/getDashboardProps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { createStructuredSelector } from 'reselect'

import getTaskPlans from '../../tasks/getters/getTaskPlans'

const getDashboardProps = createStructuredSelector({
taskPlans: getTaskPlans
})

export default getDashboardProps
3 changes: 3 additions & 0 deletions app/getters/getHomeProps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const getHomeProps = (state) => ({})

export default getHomeProps
13 changes: 13 additions & 0 deletions app/getters/getLayoutProps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { createStructuredSelector } from 'reselect'
import getCurrentAgent from 'dogstack-agents/agents/getters/getCurrentAgent'

import getRoutes from './getRoutes'
import getNavigationRoutes from './getNavigationRoutes'

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

export default getLayoutProps
25 changes: 25 additions & 0 deletions app/getters/getNavigationRoutes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { createSelector } from 'reselect'
import { indexBy, prop, filter, pipe, isNil, not, map, uncurryN } from 'ramda'

import getState from './getState'
import getRoutes from './getRoutes'

const indexByName = indexBy(prop('name'))
const filterNil = filter(pipe(isNil, not))

const getNavigationRoutes = createSelector(
getState,
getRoutes,
uncurryN(2, state => {
const mapRoutes = map(route => {
const { name, navigation } = route
if (isNil(navigation)) return
if (navigation === true) return route
const { selector } = navigation
if (isNil(selector) || selector(state)) return route
})
return pipe(mapRoutes, filterNil, indexByName)
})
)

export default getNavigationRoutes
16 changes: 16 additions & 0 deletions app/getters/getRoutes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { createSelector } from 'reselect'
import { uncurryN, filter, isNil } from 'ramda'

import getState from './getState'
import getAllRoutes from './getAllRoutes'

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

export default getRoutes
3 changes: 3 additions & 0 deletions app/getters/getState.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const getState = state => state

export default getState
Loading