@unicorns/quick-dash-framework
Advanced tools
Comparing version 2.0.8-alpha to 2.0.9-alpha
{ | ||
"name": "@unicorns/quick-dash-framework", | ||
"version": "2.0.8-alpha", | ||
"version": "2.0.9-alpha", | ||
"description": "Quick Dashboard Framework", | ||
@@ -5,0 +5,0 @@ "author": "Unicorn Global et al", |
import Settings from '@/assets/icons/settings' | ||
import User from '@/assets/icons/user' | ||
import config from '@/config' | ||
export default [ | ||
const users = config.admin.users ? [ | ||
{ | ||
name: 'AllUsers', | ||
path: 'users', | ||
component: require('@/pages/Admin/Users/Index.vue').default, | ||
meta: { | ||
main: true, | ||
label: 'All Users', | ||
icon: User | ||
} | ||
}, | ||
{ | ||
name: 'UserDetails', | ||
path: 'users/:userId', | ||
component: require('@/pages/Admin/Users/UserDetails.vue').default, | ||
props: true | ||
} | ||
] : [] | ||
const settings = config.admin.settings.enabled ? [ | ||
{ | ||
name: 'Settings', | ||
path: 'settings', | ||
component: config.admin.settings.component, | ||
meta: { | ||
main: true, | ||
label: 'Settings', | ||
icon: Settings | ||
} | ||
} | ||
] : [] | ||
export default config.admin.enabled ? [ | ||
{ | ||
name: 'AdminAccount', | ||
@@ -15,30 +48,6 @@ path: 'admin', | ||
children: [ | ||
{ | ||
name: 'AllUsers', | ||
path: 'users', | ||
component: require('@/pages/Admin/Users/Index.vue').default, | ||
meta: { | ||
main: true, | ||
label: 'All Users', | ||
icon: User | ||
} | ||
}, | ||
{ | ||
name: 'UserDetails', | ||
path: 'users/:userId', | ||
component: require('@/pages/Admin/Users/UserDetails.vue').default, | ||
props: true | ||
}, | ||
{ | ||
name: 'Settings', | ||
path: 'settings', | ||
component: {template: '<router-view></router-view>'}, | ||
meta: { | ||
main: true, | ||
label: 'Settings', | ||
icon: Settings | ||
} | ||
} | ||
...users, | ||
...settings | ||
] | ||
} | ||
] | ||
] : [] |
@@ -5,2 +5,3 @@ import Vue from 'vue' | ||
import store from '@/store' | ||
import admin from '@/store/admin' | ||
import adminRoutes from '@/router/admin' | ||
@@ -14,2 +15,20 @@ import authRoutes from '@/router/auth' | ||
/** | ||
* These filenames are reserved for the time being. | ||
* | ||
* The future roadmap will allow the host application the ability | ||
* to overload the file and have their one loaded instead of the | ||
* base framework one. | ||
* | ||
* It's important to add the filenames of everything in the base | ||
* `/store` folder. | ||
*/ | ||
const reserved = [ | ||
'admin', | ||
'auth', | ||
'base', | ||
'index', | ||
'user' | ||
] | ||
/** | ||
* Custom routes | ||
@@ -33,22 +52,14 @@ * | ||
custom.keys().forEach(function(key) { | ||
const name = /\.\/(\S+)\.js/.exec(key)[1] | ||
/** | ||
* Do not load any index.js files that are placed in the host | ||
* applications `store` folder | ||
* Do not load any files with reserved names from the host | ||
* applications `router` folder and leave a warning. | ||
*/ | ||
if (key === './index.js') { | ||
console.warn('Do not place `index.js` files in your `/router` directory, they are ignored.') | ||
if (reserved.includes(name)) { | ||
console.warn(`Do not place '${name}.js' files in your '/router' directory, the filenames are reserved and ignored.`) | ||
return | ||
} | ||
if (key === './auth.js') { | ||
console.warn('Do not place `auth.js` files in your `/router` directory, they are ignored.') | ||
return | ||
} | ||
if (key === './base.js') { | ||
console.warn('Do not place `base.js` files in your `/router` directory, they are ignored.') | ||
return | ||
} | ||
console.log('Found custom routes: ', key) | ||
console.log('Found custom routes: ', name) | ||
const value = custom(key).default | ||
@@ -70,4 +81,9 @@ console.log('val', value) | ||
/** | ||
* If the user is an admin then we need to add the admin specific | ||
* routes _and_ the admin specific stores into the mix. | ||
*/ | ||
if (userHasRole(user, 'ADMIN')) { | ||
routes = [...routes, ...adminRoutes] | ||
store.registerModule('admin', admin) | ||
} | ||
@@ -80,2 +96,3 @@ | ||
store.commit('app/setRoutes', [appRoute]) | ||
return appRoute | ||
@@ -82,0 +99,0 @@ } |
import Home from '@/assets/icons/home' | ||
import User from '@/assets/icons/user' | ||
import config from '@/config' | ||
console.log(config) | ||
const home = config.router.home.enabled ? [{ | ||
name: 'Home', | ||
path: '', | ||
component: config.router.home.component, | ||
meta: { | ||
main: true, | ||
label: 'Home', | ||
icon: Home | ||
} | ||
}] : [] | ||
const account = config.router.account.enabled ? [{ | ||
name: 'Account', | ||
path: '/account', | ||
component: config.router.account.component, | ||
meta: { | ||
main: true, | ||
label: 'Account', | ||
icon: User | ||
} | ||
}] : [] | ||
export default [ | ||
{ | ||
name: 'Home', | ||
path: '', | ||
component: require('@/pages/User/Home/Home.vue').default, | ||
meta: { | ||
main: true, | ||
label: 'Home', | ||
icon: Home | ||
} | ||
}, | ||
{ | ||
name: 'Account', | ||
path: '/account', | ||
component: require('@/pages/User/Details.vue').default, | ||
meta: { | ||
main: true, | ||
label: 'Account', | ||
icon: User | ||
} | ||
} | ||
...home, | ||
...account | ||
] |
@@ -14,3 +14,2 @@ import Vue from 'vue' | ||
*/ | ||
import admin from '@/store/admin' | ||
import auth from '@/store/auth' | ||
@@ -104,5 +103,4 @@ import app from '@/store/app' | ||
app, | ||
auth, | ||
admin | ||
auth | ||
} | ||
}) |
3935584
158
3939