diff --git a/ui/core/app/router.js b/ui/core/app/router.js index 8c575ea0e..e2bb6acda 100644 --- a/ui/core/app/router.js +++ b/ui/core/app/router.js @@ -55,6 +55,7 @@ Router.map(function () { }); this.route('scopes', function() {}); this.route('edit'); + this.route('new'); }); }); diff --git a/ui/core/app/routes/scopes/scope/new.js b/ui/core/app/routes/scopes/scope/new.js new file mode 100644 index 000000000..c518a483a --- /dev/null +++ b/ui/core/app/routes/scopes/scope/new.js @@ -0,0 +1,18 @@ +import Route from '@ember/routing/route'; + +export default class ScopesScopeNewRoute extends Route { + // =methods + + /** + * Creates a new unsaved scope belonging to the current scope. + * @return {ScopeModel} + */ + model() { + const { id: scopeID, isOrg } = this.modelFor('scopes.scope'); + // NOTE: if the current scope is an org, we create a project, otherwise + // it must be global and we create an org. Boundary does not support + // scopes under a project, so such a case is ignored. + const type = isOrg ? 'project' : 'org'; + return this.store.createRecord('scope', { type, scopeID }); + } +} diff --git a/ui/core/app/templates/scopes/scope/new.hbs b/ui/core/app/templates/scopes/scope/new.hbs new file mode 100644 index 000000000..b33c28109 --- /dev/null +++ b/ui/core/app/templates/scopes/scope/new.hbs @@ -0,0 +1,27 @@ +{{title (t 'titles.new')}} + + + + + + + + +

+ {{t "titles.new"}} + +

+
+ + + + + +
diff --git a/ui/core/app/templates/scopes/scope/scopes/index.hbs b/ui/core/app/templates/scopes/scope/scopes/index.hbs index 8f4969c7d..0b92f707d 100644 --- a/ui/core/app/templates/scopes/scope/scopes/index.hbs +++ b/ui/core/app/templates/scopes/scope/scopes/index.hbs @@ -28,7 +28,7 @@ {{#if @model.subScopes}} {{t 'titles.new'}} diff --git a/ui/core/tests/unit/routes/scopes/scope/new-test.js b/ui/core/tests/unit/routes/scopes/scope/new-test.js new file mode 100644 index 000000000..76ed6531b --- /dev/null +++ b/ui/core/tests/unit/routes/scopes/scope/new-test.js @@ -0,0 +1,11 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Route | scopes/scope/new', function(hooks) { + setupTest(hooks); + + test('it exists', function(assert) { + let route = this.owner.lookup('route:scopes/scope/new'); + assert.ok(route); + }); +});