mirror of https://github.com/hashicorp/consul
Browse Source
* Add Partition to all our models * Add partitions into our serializers/fingerprinting * Make some amends to a few adapters ready for partitions * Amend blueprints to avoid linting error * Update all our repositories to include partitions, also Remove enabled/disable nspace repo and just use a nspace with conditionals * Ensure nspace and parition parameters always return '' no matter what * Ensure data-sink finds the model properly This will later be replaced by a @dataSink decorator but we are find kicking that can down the road a little more * Add all the new partition data layer * Add a way to set the title of the page from inside the route and make it accessibile via a route announcer * Make the Consul Route the default/basic one * Tweak nspace and partition abilities not to check the length * Thread partition through all the components that need it * Some ACL tweaks * Move the entire app to use partitions * Delete all the tests we no longer need * Update some Unit tests to use partition * Fix up KV title tests * Fix up a few more acceptance tests * Fixup and temporarily ignore some acceptance tests * Stop using ember-cli-page-objects fillable as it doesn't seem to work * Fix lint error * Remove old ACL related test * Add a tick after filling out forms * Fix token warning modal * Found some more places where we need a partition var * Fixup some more acceptance tests * Tokens still needs a repo service for CRUD * Remove acceptance tests we no longer need * Fixup and "FIXME ignore" a few tests * Remove an s * Disable blocking queries for KV to revert to previous release for now * Fixup adapter tests to follow async/function resolving interface * Fixup all the serializer integration tests * Fixup service/repo integration tests * Fixup deleting acceptance test * Fixup some ent tests * Make sure nspaces passes the dc through for when thats important * ...aaaand acceptance nspaces with the extra dc parampull/11026/head^2
John Cowen
3 years ago
committed by
GitHub
334 changed files with 3573 additions and 3295 deletions
@ -0,0 +1,28 @@
|
||||
import Adapter from './application'; |
||||
|
||||
// Blocking query support for partitions is currently disabled
|
||||
export default class PartitionAdapter extends Adapter { |
||||
// FIXME: Check overall hierarchy again
|
||||
async requestForQuery(request, { ns, dc, index }) { |
||||
const respond = await request` |
||||
GET /v1/partitions?${{ dc }} |
||||
|
||||
${{ index }} |
||||
`;
|
||||
await respond((headers, body) => delete headers['x-consul-index']); |
||||
return respond; |
||||
} |
||||
|
||||
async requestForQueryRecord(request, { ns, dc, index, id }) { |
||||
if (typeof id === 'undefined') { |
||||
throw new Error('You must specify an id'); |
||||
} |
||||
const respond = await request` |
||||
GET /v1/partition/${id}?${{ dc }} |
||||
|
||||
${{ index }} |
||||
`;
|
||||
await respond((headers, body) => delete headers['x-consul-index']); |
||||
return respond; |
||||
} |
||||
} |
@ -0,0 +1,28 @@
|
||||
<AppView> |
||||
<BlockSlot @name="header"> |
||||
<h1> |
||||
Tokens |
||||
</h1> |
||||
</BlockSlot> |
||||
<BlockSlot @name="content"> |
||||
<EmptyState data-test-acls-disabled> |
||||
<BlockSlot @name="header"> |
||||
<h2>Welcome to ACLs</h2> |
||||
</BlockSlot> |
||||
<BlockSlot @name="body"> |
||||
<p> |
||||
ACLs are not enabled in this Consul cluster. We strongly encourage the use of ACLs in production environments for the best security practices. |
||||
</p> |
||||
</BlockSlot> |
||||
<BlockSlot @name="actions"> |
||||
<li class="docs-link"> |
||||
<a href="{{env 'CONSUL_DOCS_URL'}}/acl/index.html" rel="noopener noreferrer" target="_blank">Read the documentation</a> |
||||
</li> |
||||
<li class="learn-link"> |
||||
<a href="{{env 'CONSUL_DOCS_LEARN_URL'}}/consul/security-networking/production-acls" rel="noopener noreferrer" target="_blank">Follow the guide</a> |
||||
</li> |
||||
</BlockSlot> |
||||
</EmptyState> |
||||
</BlockSlot> |
||||
</AppView> |
||||
|
@ -0,0 +1,73 @@
|
||||
# DataLoader |
||||
|
||||
`<DataLoader />` works similarly to, and uses, `<DataSource />` but additionally |
||||
exposes various common states based on the status of the loading of the data. |
||||
These states are exposed as slots to enable you to easily render different |
||||
elements based on the state of the data. |
||||
|
||||
|
||||
Use the `@dataSource` decorator in your repositories to define URI to async |
||||
method mapping. |
||||
|
||||
```javascript |
||||
class SomethingRepository extends Service { |
||||
@dataSource('/:partition/:nspace/:dc/services') |
||||
async youCouldCallItAnythingTodoWithGettingServices(params) { |
||||
console.log(params); |
||||
// {partition: "partition", nspace: "nspace", dc: "dc"} |
||||
return getTheThing(params); |
||||
} |
||||
} |
||||
``` |
||||
|
||||
```hbs preview-template |
||||
<DataLoader |
||||
@src="/partition/nspace/dc/services" |
||||
as |loader|> |
||||
<BlockSlot @name="loading"> |
||||
Loading... |
||||
</BlockSlot> |
||||
<BlockSlot @name="error"> |
||||
Error {{loader.error.status}} |
||||
</BlockSlot> |
||||
<BlockSlot @name="disconnected"> |
||||
Whilst we could load the initial data, something happened subsequently that |
||||
meant we could load longer load updates to the data. |
||||
</BlockSlot> |
||||
<BlockSlot @name="loaded"> |
||||
{{#each loader.data as |service|}} |
||||
{{service.Name}}<br /> |
||||
{{/each}} |
||||
</BlockSlot> |
||||
</DataLoader> |
||||
``` |
||||
|
||||
## Attributes |
||||
|
||||
| Argument | Type | Default | Description | |
||||
| --- | --- | --- | --- | |
||||
| `src` | `String` | | The source to subscribe to updates to, this should map to a string based URI | |
||||
|
||||
## Exports |
||||
|
||||
| Name | Description | |
||||
| --- | --- | |
||||
| `data` | The loaded dataset once any data has been loaded successfully | |
||||
| `error` | The error thrown if an error is encountered whilst loading data | |
||||
|
||||
## Slots |
||||
|
||||
| Name | Description | |
||||
| --- | --- | |
||||
| `loading` | Rendered whilst waiting for the initial data to load. | |
||||
| `error` | If there is an error only whilst waiting for the initial data to load, this slot is rendered. | |
||||
| `disconnected` | Rendered when the initial data has already loaded, but a subsequent set of loaded data causes an error to be thrown.| |
||||
| `loaded` | Rendered once the initial data is loaded and on subsequent successful loads of data. | |
||||
|
||||
## See |
||||
|
||||
- [DataSource](../data-source/README.mdx) |
||||
- [Component Source Code](./index.js) |
||||
- [Template Source Code](./index.hbs) |
||||
|
||||
--- |
@ -0,0 +1,3 @@
|
||||
{{page-title @title separator=(or @separator ' - ')}} |
||||
<PortalTarget @name="route-announcer" /> |
||||
|
@ -1,11 +1,12 @@
|
||||
{{did-insert this.connect}} |
||||
{{will-destroy this.disconnect}} |
||||
|
||||
{{#if this.title}} |
||||
{{page-title this.title separator=@titleSeparator}} |
||||
{{/if}} |
||||
|
||||
{{yield (hash |
||||
model=this.model |
||||
params=this.params |
||||
currentName=this.router.currentRoute.name |
||||
|
||||
refresh=this.refresh |
||||
|
||||
Title=(component "route/title") |
||||
Announcer=(component "route/announcer") |
||||
)}} |
@ -0,0 +1,15 @@
|
||||
{{page-title @title separator=@separator}} |
||||
{{#if (not-eq @render false)}} |
||||
{{@title}} |
||||
{{/if}} |
||||
<Portal @target="route-announcer"> |
||||
<div |
||||
class="route-title" |
||||
...attributes |
||||
aria-live="assertive" |
||||
aria-atomic="true" |
||||
> |
||||
{{! Using a handlebars concat here avoid whitespace issues}} |
||||
{{concat 'Navigated to ' @title}} |
||||
</div> |
||||
</Portal> |
@ -0,0 +1,6 @@
|
||||
%route-title { |
||||
@extend %visually-hidden; |
||||
} |
||||
.route-title { |
||||
@extend %route-title; |
||||
} |
@ -1,25 +0,0 @@
|
||||
import Controller from '@ember/controller'; |
||||
import { get, set } from '@ember/object'; |
||||
import { inject as service } from '@ember/service'; |
||||
|
||||
export default Controller.extend({ |
||||
dom: service('dom'), |
||||
actions: { |
||||
change: function(e, value, item) { |
||||
const event = this.dom.normalizeEvent(e, value); |
||||
// TODO: Switch to using forms like the rest of the app
|
||||
// setting utils/form/builder for things to be done before we
|
||||
// can do that. For the moment just do things normally its a simple
|
||||
// enough form at the moment
|
||||
|
||||
const target = event.target; |
||||
const blocking = get(this, 'item.client.blocking'); |
||||
switch (target.name) { |
||||
case 'client[blocking]': |
||||
set(this, 'item.client.blocking', !blocking); |
||||
this.send('update', 'client', this.item.client); |
||||
break; |
||||
} |
||||
}, |
||||
}, |
||||
}); |
@ -0,0 +1,8 @@
|
||||
import Route from 'consul-ui/routing/route'; |
||||
|
||||
export default { |
||||
name: 'routing', |
||||
initialize(application) { |
||||
application.register('route:basic', Route); |
||||
}, |
||||
}; |
@ -1,15 +0,0 @@
|
||||
export function initialize(container) { |
||||
const env = container.lookup('service:env'); |
||||
if (env.var('CONSUL_NSPACES_ENABLED')) { |
||||
// enable the nspace repo
|
||||
['dc', 'settings', 'dc.intentions.edit', 'dc.intentions.create'].forEach(function(item) { |
||||
container.inject(`route:${item}`, 'nspacesRepo', 'service:repository/nspace/enabled'); |
||||
container.inject(`route:nspace.${item}`, 'nspacesRepo', 'service:repository/nspace/enabled'); |
||||
}); |
||||
container.inject('route:application', 'nspacesRepo', 'service:repository/nspace/enabled'); |
||||
} |
||||
} |
||||
|
||||
export default { |
||||
initialize, |
||||
}; |
@ -1,26 +0,0 @@
|
||||
import Mixin from '@ember/object/mixin'; |
||||
import { get } from '@ember/object'; |
||||
|
||||
/** |
||||
* Used for create-type Routes |
||||
* |
||||
* 'repo' is standardized across the app |
||||
* 'item' is standardized across the app |
||||
* they could be replaced with `getRepo` and `getItem` |
||||
*/ |
||||
export default Mixin.create({ |
||||
beforeModel: function() { |
||||
this._super(...arguments); |
||||
this.repo.invalidate(); |
||||
}, |
||||
deactivate: function() { |
||||
this._super(...arguments); |
||||
// TODO: This is dependent on ember-changeset
|
||||
// Change changeset to support ember-data props
|
||||
const item = get(this.controller, 'item.data'); |
||||
// TODO: Look and see if rollbackAttributes is good here
|
||||
if (get(item, 'isNew')) { |
||||
item.destroyRecord(); |
||||
} |
||||
}, |
||||
}); |
@ -1,4 +0,0 @@
|
||||
import Mixin from '@ember/object/mixin'; |
||||
import WithBlockingActions from 'consul-ui/mixins/with-blocking-actions'; |
||||
|
||||
export default Mixin.create(WithBlockingActions, {}); |
@ -1,4 +0,0 @@
|
||||
import Mixin from '@ember/object/mixin'; |
||||
import WithBlockingActions from 'consul-ui/mixins/with-blocking-actions'; |
||||
|
||||
export default Mixin.create(WithBlockingActions, {}); |
@ -1,4 +0,0 @@
|
||||
import Mixin from '@ember/object/mixin'; |
||||
import WithBlockingActions from 'consul-ui/mixins/with-blocking-actions'; |
||||
|
||||
export default Mixin.create(WithBlockingActions, {}); |
@ -1,48 +0,0 @@
|
||||
import Mixin from '@ember/object/mixin'; |
||||
import WithBlockingActions from 'consul-ui/mixins/with-blocking-actions'; |
||||
import { get } from '@ember/object'; |
||||
import { inject as service } from '@ember/service'; |
||||
|
||||
export default Mixin.create(WithBlockingActions, { |
||||
settings: service('settings'), |
||||
actions: { |
||||
use: function(item) { |
||||
return this.repo |
||||
.findBySlug({ |
||||
dc: this.modelFor('dc').dc.Name, |
||||
ns: get(item, 'Namespace'), |
||||
id: get(item, 'AccessorID'), |
||||
}) |
||||
.then(item => { |
||||
return this.settings.persist({ |
||||
token: { |
||||
AccessorID: get(item, 'AccessorID'), |
||||
SecretID: get(item, 'SecretID'), |
||||
Namespace: get(item, 'Namespace'), |
||||
}, |
||||
}); |
||||
}); |
||||
}, |
||||
logout: function(item) { |
||||
return this.settings.delete('token'); |
||||
}, |
||||
clone: function(item) { |
||||
let cloned; |
||||
return this.feedback.execute(() => { |
||||
return this.repo |
||||
.clone(item) |
||||
.then(item => { |
||||
cloned = item; |
||||
// cloning is similar to delete in that
|
||||
// if you clone from the listing page, stay on the listing page
|
||||
// whereas if you clone from another token, take me back to the listing page
|
||||
// so I can see it
|
||||
return this.afterDelete(...arguments); |
||||
}) |
||||
.then(function() { |
||||
return cloned; |
||||
}); |
||||
}, 'clone'); |
||||
}, |
||||
}, |
||||
}); |
@ -0,0 +1,21 @@
|
||||
import Model from 'ember-data/model'; |
||||
import attr from 'ember-data/attr'; |
||||
|
||||
export const PRIMARY_KEY = 'uid'; |
||||
export const SLUG_KEY = 'Name'; |
||||
export const PARTITION_KEY = 'Partition'; |
||||
|
||||
export default class PartitionModel extends Model { |
||||
@attr('string') uid; |
||||
@attr('string') Name; |
||||
@attr('string') Description; |
||||
@attr('string') Datacenter; |
||||
|
||||
@attr('string') Namespace; // always ""
|
||||
// Partition is the same as Name but please don't alias as we want to keep
|
||||
// mutating the response here instead
|
||||
@attr('string') Partition; |
||||
|
||||
@attr('number') SyncTime; |
||||
@attr() meta; |
||||
} |
@ -1,93 +1,24 @@
|
||||
import Route from 'consul-ui/routing/route'; |
||||
import { inject as service } from '@ember/service'; |
||||
import { hash } from 'rsvp'; |
||||
import { action } from '@ember/object'; |
||||
|
||||
import WithBlockingActions from 'consul-ui/mixins/with-blocking-actions'; |
||||
|
||||
export default Route.extend(WithBlockingActions, { |
||||
router: service('router'), |
||||
nspacesRepo: service('repository/nspace/disabled'), |
||||
repo: service('repository/dc'), |
||||
settings: service('settings'), |
||||
model: function() { |
||||
return hash({ |
||||
router: this.router, |
||||
dcs: this.repo.findAll(), |
||||
nspaces: this.nspacesRepo.findAll().catch(function() { |
||||
return []; |
||||
}), |
||||
|
||||
// these properties are added to the controller from route/dc
|
||||
// as we don't have access to the dc and nspace params in the URL
|
||||
// until we get to the route/dc route
|
||||
// permissions also requires the dc param
|
||||
|
||||
// dc: null,
|
||||
// nspace: null
|
||||
// token: null
|
||||
// permissions: null
|
||||
}); |
||||
}, |
||||
setupController: function(controller, model) { |
||||
this._super(...arguments); |
||||
controller.setProperties(model); |
||||
}, |
||||
actions: { |
||||
error: function(e, transition) { |
||||
// TODO: Normalize all this better
|
||||
let error = { |
||||
status: e.code || e.statusCode || '', |
||||
message: e.message || e.detail || 'Error', |
||||
}; |
||||
if (e.errors && e.errors[0]) { |
||||
error = e.errors[0]; |
||||
error.message = error.message || error.title || error.detail || 'Error'; |
||||
} |
||||
if (error.status === '') { |
||||
error.message = 'Error'; |
||||
} |
||||
// Try and get the currently attempted dc, whereever that may be
|
||||
let model = this.modelFor('dc') || this.modelFor('nspace.dc'); |
||||
if (!model) { |
||||
const path = new URL(location.href).pathname |
||||
.substr(this.router.rootURL.length - 1) |
||||
.split('/') |
||||
.slice(1, 3); |
||||
model = { |
||||
nspace: { Name: 'default' }, |
||||
}; |
||||
if (path[0].startsWith('~')) { |
||||
model.nspace = { |
||||
Name: path.shift(), |
||||
}; |
||||
} |
||||
model.dc = { |
||||
Name: path[0], |
||||
}; |
||||
} |
||||
const app = this.modelFor('application') || {}; |
||||
const dcs = app.dcs || [model.dc]; |
||||
const nspaces = app.nspaces || [model.nspace]; |
||||
hash({ |
||||
dc: |
||||
error.status.toString().indexOf('5') !== 0 |
||||
? this.repo.getActive(model.dc.Name, dcs) |
||||
: { Name: 'Error' }, |
||||
dcs: dcs, |
||||
nspace: model.nspace, |
||||
nspaces: nspaces, |
||||
}) |
||||
.then(model => Promise.all([model, this.repo.clearActive()])) |
||||
.then(([model]) => { |
||||
// we can't use setupController as we received an error
|
||||
// so we do it manually instead
|
||||
this.controllerFor('application').setProperties(model); |
||||
this.controllerFor('error').setProperties({ error: error }); |
||||
}) |
||||
.catch(e => { |
||||
this.controllerFor('error').setProperties({ error: error }); |
||||
}); |
||||
return true; |
||||
}, |
||||
}, |
||||
}); |
||||
export default class ApplicationRoute extends Route.extend(WithBlockingActions) { |
||||
@action |
||||
error(e, transition) { |
||||
// TODO: Normalize all this better
|
||||
let error = { |
||||
status: e.code || e.statusCode || '', |
||||
message: e.message || e.detail || 'Error', |
||||
}; |
||||
if (e.errors && e.errors[0]) { |
||||
error = e.errors[0]; |
||||
error.message = error.message || error.title || error.detail || 'Error'; |
||||
} |
||||
if (error.status === '') { |
||||
error.message = 'Error'; |
||||
} |
||||
this.controllerFor('application').setProperties({ error: error }); |
||||
return true; |
||||
} |
||||
} |
||||
|
@ -1,36 +0,0 @@
|
||||
import { inject as service } from '@ember/service'; |
||||
import SingleRoute from 'consul-ui/routing/single'; |
||||
import { hash } from 'rsvp'; |
||||
|
||||
export default class ShowRoute extends SingleRoute { |
||||
@service('repository/auth-method') repo; |
||||
@service('repository/binding-rule') bindingRuleRepo; |
||||
|
||||
model(params) { |
||||
const dc = this.modelFor('dc').dc; |
||||
const nspace = this.optionalParams().nspace; |
||||
|
||||
return super.model(...arguments).then(model => { |
||||
return hash({ |
||||
...model, |
||||
...{ |
||||
item: this.repo.findBySlug({ |
||||
id: params.id, |
||||
dc: dc.Name, |
||||
ns: nspace, |
||||
}), |
||||
bindingRules: this.bindingRuleRepo.findAllByDatacenter({ |
||||
ns: nspace, |
||||
dc: dc.Name, |
||||
authmethod: params.id, |
||||
}), |
||||
}, |
||||
}); |
||||
}); |
||||
} |
||||
|
||||
setupController(controller, model) { |
||||
super.setupController(...arguments); |
||||
controller.setProperties(model); |
||||
} |
||||
} |
@ -1,16 +0,0 @@
|
||||
import Route from 'consul-ui/routing/route'; |
||||
|
||||
export default class AuthMethodRoute extends Route { |
||||
model(params) { |
||||
const parent = this.routeName |
||||
.split('.') |
||||
.slice(0, -1) |
||||
.join('.'); |
||||
return this.modelFor(parent); |
||||
} |
||||
|
||||
setupController(controller, model) { |
||||
super.setupController(...arguments); |
||||
controller.setProperties(model); |
||||
} |
||||
} |
@ -1,16 +0,0 @@
|
||||
import Route from 'consul-ui/routing/route'; |
||||
|
||||
export default class BindingRulesRoute extends Route { |
||||
model() { |
||||
const parent = this.routeName |
||||
.split('.') |
||||
.slice(0, -1) |
||||
.join('.'); |
||||
return this.modelFor(parent); |
||||
} |
||||
|
||||
setupController(controller, model) { |
||||
super.setupController(...arguments); |
||||
controller.setProperties(model); |
||||
} |
||||
} |
@ -1,6 +1,6 @@
|
||||
import Route from 'consul-ui/routing/route'; |
||||
import to from 'consul-ui/utils/routing/redirect-to'; |
||||
|
||||
export default Route.extend({ |
||||
redirect: to('auth-method'), |
||||
}); |
||||
export default class AuthMethodShowIndexRoute extends Route { |
||||
redirect = to('auth-method'); |
||||
} |
||||
|
@ -1,16 +0,0 @@
|
||||
import Route from 'consul-ui/routing/route'; |
||||
|
||||
export default class NspaceRulesRoute extends Route { |
||||
model() { |
||||
const parent = this.routeName |
||||
.split('.') |
||||
.slice(0, -1) |
||||
.join('.'); |
||||
return this.modelFor(parent); |
||||
} |
||||
|
||||
setupController(controller, model) { |
||||
super.setupController(...arguments); |
||||
controller.setProperties(model); |
||||
} |
||||
} |
@ -1,6 +1,5 @@
|
||||
import Route from './edit'; |
||||
import CreatingRoute from 'consul-ui/mixins/creating-route'; |
||||
|
||||
export default class CreateRoute extends Route.extend(CreatingRoute) { |
||||
export default class CreateRoute extends Route { |
||||
templateName = 'dc/acls/policies/edit'; |
||||
} |
||||
|
@ -1,48 +1,8 @@
|
||||
import { inject as service } from '@ember/service'; |
||||
import SingleRoute from 'consul-ui/routing/single'; |
||||
import { hash } from 'rsvp'; |
||||
import { get } from '@ember/object'; |
||||
import Route from 'consul-ui/routing/route'; |
||||
|
||||
import WithPolicyActions from 'consul-ui/mixins/policy/with-actions'; |
||||
import WithBlockingActions from 'consul-ui/mixins/with-blocking-actions'; |
||||
|
||||
export default class EditRoute extends SingleRoute.extend(WithPolicyActions) { |
||||
@service('repository/policy') |
||||
repo; |
||||
|
||||
@service('repository/token') |
||||
tokenRepo; |
||||
|
||||
model(params) { |
||||
const dc = this.modelFor('dc').dc.Name; |
||||
const nspace = this.optionalParams().nspace; |
||||
const tokenRepo = this.tokenRepo; |
||||
return super.model(...arguments).then(model => { |
||||
return hash({ |
||||
...model, |
||||
...{ |
||||
routeName: this.routeName, |
||||
items: tokenRepo |
||||
.findByPolicy({ |
||||
ns: nspace, |
||||
dc: dc, |
||||
id: get(model.item, 'ID'), |
||||
}) |
||||
.catch(function(e) { |
||||
switch (get(e, 'errors.firstObject.status')) { |
||||
case '403': |
||||
case '401': |
||||
// do nothing the SingleRoute will have caught it already
|
||||
return; |
||||
} |
||||
throw e; |
||||
}), |
||||
}, |
||||
}); |
||||
}); |
||||
} |
||||
|
||||
setupController(controller, model) { |
||||
super.setupController(...arguments); |
||||
controller.setProperties(model); |
||||
} |
||||
export default class EditRoute extends Route.extend(WithBlockingActions) { |
||||
@service('repository/policy') repo; |
||||
} |
||||
|
@ -1,6 +1,5 @@
|
||||
import Route from './edit'; |
||||
import CreatingRoute from 'consul-ui/mixins/creating-route'; |
||||
|
||||
export default class CreateRoute extends Route.extend(CreatingRoute) { |
||||
export default class CreateRoute extends Route { |
||||
templateName = 'dc/acls/roles/edit'; |
||||
} |
||||
|
@ -1,47 +1,8 @@
|
||||
import { inject as service } from '@ember/service'; |
||||
import SingleRoute from 'consul-ui/routing/single'; |
||||
import { hash } from 'rsvp'; |
||||
import { get } from '@ember/object'; |
||||
import Route from 'consul-ui/routing/route'; |
||||
|
||||
import WithRoleActions from 'consul-ui/mixins/role/with-actions'; |
||||
import WithBlockingActions from 'consul-ui/mixins/with-blocking-actions'; |
||||
|
||||
export default class EditRoute extends SingleRoute.extend(WithRoleActions) { |
||||
@service('repository/role') |
||||
repo; |
||||
|
||||
@service('repository/token') |
||||
tokenRepo; |
||||
|
||||
model(params) { |
||||
const dc = this.modelFor('dc').dc.Name; |
||||
const nspace = this.optionalParams().nspace; |
||||
const tokenRepo = this.tokenRepo; |
||||
return super.model(...arguments).then(model => { |
||||
return hash({ |
||||
...model, |
||||
...{ |
||||
items: tokenRepo |
||||
.findByRole({ |
||||
ns: nspace, |
||||
dc: dc, |
||||
id: get(model.item, 'ID'), |
||||
}) |
||||
.catch(function(e) { |
||||
switch (get(e, 'errors.firstObject.status')) { |
||||
case '403': |
||||
case '401': |
||||
// do nothing the SingleRoute will have caught it already
|
||||
return; |
||||
} |
||||
throw e; |
||||
}), |
||||
}, |
||||
}); |
||||
}); |
||||
} |
||||
|
||||
setupController(controller, model) { |
||||
super.setupController(...arguments); |
||||
controller.setProperties(model); |
||||
} |
||||
export default class EditRoute extends Route.extend(WithBlockingActions) { |
||||
@service('repository/role') repo; |
||||
} |
||||
|
@ -1,6 +1,5 @@
|
||||
import Route from './edit'; |
||||
import CreatingRoute from 'consul-ui/mixins/creating-route'; |
||||
|
||||
export default class CreateRoute extends Route.extend(CreatingRoute) { |
||||
export default class CreateRoute extends Route { |
||||
templateName = 'dc/acls/tokens/edit'; |
||||
} |
||||
|
@ -1,30 +1,15 @@
|
||||
import { inject as service } from '@ember/service'; |
||||
import SingleRoute from 'consul-ui/routing/single'; |
||||
import { hash } from 'rsvp'; |
||||
import Route from 'consul-ui/routing/route'; |
||||
|
||||
import WithTokenActions from 'consul-ui/mixins/token/with-actions'; |
||||
import WithBlockingActions from 'consul-ui/mixins/with-blocking-actions'; |
||||
|
||||
export default class EditRoute extends SingleRoute.extend(WithTokenActions) { |
||||
@service('repository/token') |
||||
repo; |
||||
export default class EditRoute extends Route.extend(WithBlockingActions) { |
||||
@service('repository/token') repo; |
||||
@service('settings') settings; |
||||
|
||||
@service('settings') |
||||
settings; |
||||
|
||||
model(params, transition) { |
||||
return super.model(...arguments).then(model => { |
||||
return hash({ |
||||
...model, |
||||
...{ |
||||
routeName: this.routeName, |
||||
token: this.settings.findBySlug('token'), |
||||
}, |
||||
}); |
||||
}); |
||||
} |
||||
|
||||
setupController(controller, model) { |
||||
super.setupController(...arguments); |
||||
controller.setProperties(model); |
||||
async model(params, transition) { |
||||
return { |
||||
token: await this.settings.findBySlug('token'), |
||||
}; |
||||
} |
||||
} |
||||
|
@ -1,7 +1,6 @@
|
||||
import Route from 'consul-ui/routing/route'; |
||||
import to from 'consul-ui/utils/routing/redirect-to'; |
||||
|
||||
export default class IndexRoute extends Route { |
||||
beforeModel() { |
||||
this.transitionTo('dc.services'); |
||||
} |
||||
redirect = to('services'); |
||||
} |
||||
|
@ -1,38 +0,0 @@
|
||||
import { inject as service } from '@ember/service'; |
||||
import Route from 'consul-ui/routing/route'; |
||||
|
||||
export default class EditRoute extends Route { |
||||
@service('repository/intention') repo; |
||||
@service('env') env; |
||||
|
||||
async model(params, transition) { |
||||
const dc = this.modelFor('dc').dc.Name; |
||||
const nspace = this.optionalParams().nspace; |
||||
|
||||
let item; |
||||
if (typeof params.intention_id !== 'undefined') { |
||||
item = await this.repo.findBySlug({ |
||||
ns: nspace, |
||||
dc: dc, |
||||
id: params.intention_id, |
||||
}); |
||||
} else { |
||||
const defaultNspace = this.env.var('CONSUL_NSPACES_ENABLED') ? '*' : 'default'; |
||||
item = await this.repo.create({ |
||||
SourceNS: nspace || defaultNspace, |
||||
DestinationNS: nspace || defaultNspace, |
||||
Datacenter: dc, |
||||
}); |
||||
} |
||||
return { |
||||
dc, |
||||
nspace, |
||||
item, |
||||
}; |
||||
} |
||||
|
||||
setupController(controller, model) { |
||||
super.setupController(...arguments); |
||||
controller.setProperties(model); |
||||
} |
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue