open-consul/ui-v2/app/router.js
John Cowen 31f36ce096 ui: Namespace Support (#6639)
Adds namespace support to the UI:

1. Namespace CRUD/management
2. Show Namespace in relevant areas (intentions, upstreams)
3. Main navigation bar improvements
4. Logic/integration to interact with a new `internal/acl/authorize` endpoint
2019-12-18 12:26:47 +00:00

126 lines
2.8 KiB
JavaScript

import EmberRouter from '@ember/routing/router';
import { config } from 'consul-ui/env';
import walk from 'consul-ui/utils/routing/walk';
const Router = EmberRouter.extend({
location: config('locationType'),
rootURL: config('rootURL'),
});
export const routes = {
// Our parent datacenter resource sets the namespace
// for the entire application
dc: {
_options: { path: '/:dc' },
// Services represent a consul service
services: {
_options: { path: '/services' },
// Show an individual service
show: {
_options: { path: '/:name' },
},
instance: {
_options: { path: '/:name/:node/:id' },
},
},
// Nodes represent a consul node
nodes: {
_options: { path: '/nodes' },
// Show an individual node
show: {
_options: { path: '/:name' },
},
},
// Intentions represent a consul intention
intentions: {
_options: { path: '/intentions' },
edit: {
_options: { path: '/:id' },
},
create: {
_options: { path: '/create' },
},
},
// Key/Value
kv: {
_options: { path: '/kv' },
folder: {
_options: { path: '/*key' },
},
edit: {
_options: { path: '/*key/edit' },
},
create: {
_options: { path: '/*key/create' },
},
'root-create': {
_options: { path: '/create' },
},
},
// ACLs
acls: {
_options: { path: '/acls' },
edit: {
_options: { path: '/:id' },
},
create: {
_options: { path: '/create' },
},
policies: {
_options: { path: '/policies' },
edit: {
_options: { path: '/:id' },
},
create: {
_options: { path: '/create' },
},
},
roles: {
_options: { path: '/roles' },
edit: {
_options: { path: '/:id' },
},
create: {
_options: { path: '/create' },
},
},
tokens: {
_options: { path: '/tokens' },
edit: {
_options: { path: '/:id' },
},
create: {
_options: { path: '/create' },
},
},
},
},
// Shows a datacenter picker. If you only have one
// it just redirects you through.
index: {
_options: { path: '/' },
},
// The settings page is global.
settings: {
_options: { path: '/setting' },
},
notfound: {
_options: { path: '/*path' },
},
};
if (config('CONSUL_NSPACES_ENABLED')) {
routes.dc.nspaces = {
_options: { path: '/namespaces' },
edit: {
_options: { path: '/:name' },
},
create: {
_options: { path: '/create' },
},
};
routes.nspace = {
_options: { path: '/:nspace' },
dc: routes.dc,
};
}
export default Router.map(walk(routes));