Skip to content
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.

Commit

Permalink
fix(routing): use only direct imports (no LL)
Browse files Browse the repository at this point in the history
fix(routing): use only direct imports (no LL)
  • Loading branch information
Metnew committed Nov 3, 2017
1 parent 5d0d3bf commit 53c479d
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions src/common/routing/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import RouteAuth from 'components/addons/RouteAuth'
import {asyncComponent} from 'react-async-component'
import {Loader, Dimmer, Header, Icon} from 'semantic-ui-react'
import _ from 'lodash'
import Dashboard from 'containers/Dashboard'
import Links from 'containers/Links'
import Login from 'containers/Login'
import NotFound from 'containers/NotFound'
import type {RouteItem} from 'types'

function asyncComponentCreator (url) {
Expand Down Expand Up @@ -46,6 +50,15 @@ function asyncComponentCreator (url) {
}

function routingFnCreator (useFor: 'sidebar' | 'routing' | 'all' = 'all') {
const [AsyncDashoard, AsyncLinks, AsyncLogin, AsyncNotFound] = [
'Dashboard',
'Links',
'Login',
'NotFound'
].map(a => {
return asyncComponentCreator(a)
})

const routes: Array<RouteItem> = [
{
path: '/',
Expand All @@ -54,7 +67,7 @@ function routingFnCreator (useFor: 'sidebar' | 'routing' | 'all' = 'all') {
name: 'Dashboard',
sidebarVisible: true,
tag: RouteAuth,
component: asyncComponentCreator('Dashboard')
component: Dashboard
},
{
path: '/links',
Expand All @@ -63,7 +76,7 @@ function routingFnCreator (useFor: 'sidebar' | 'routing' | 'all' = 'all') {
icon: 'bookmark',
sidebarVisible: true,
tag: RouteAuth,
component: asyncComponentCreator('Links')
component: Links
},
{
external: true,
Expand All @@ -77,13 +90,13 @@ function routingFnCreator (useFor: 'sidebar' | 'routing' | 'all' = 'all') {
name: 'Auth',
exact: true,
tag: Route,
component: asyncComponentCreator('Login')
component: Login
},
// find the way to add/remove routes conditionally
// Find the way to add/remove routes conditionally
{
name: '404',
tag: RouteAuth,
component: asyncComponentCreator('NotFound')
component: NotFound
},
{
tag: Redirect,
Expand All @@ -104,7 +117,17 @@ function routingFnCreator (useFor: 'sidebar' | 'routing' | 'all' = 'all') {
routing (x: Array<RouteItem> = routes) {
return x
.filter(a => !!a.tag)
.map(a => _.pick(a, ['path', 'name', 'strict', 'exact', 'component', 'tag']))
.map(a =>
_.pick(a, [
'path',
'name',
'strict',
'exact',
'component',
'tag',
'to'
])
)
},
all () {
return routes
Expand Down

0 comments on commit 53c479d

Please sign in to comment.