feat: 🎸 add new scope route
This commit is contained in:
5 files changed
+58
-1
No files matched your search
@@ -55,6 +55,7 @@ Router.map(function () {
|
||||
});
|
||||
this.route('scopes', function() {});
|
||||
this.route('edit');
|
||||
this.route('new');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -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 });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
{{title (t 'titles.new')}}
|
||||
|
||||
<Rose::Layout::Page as |page|>
|
||||
|
||||
<page.breadcrumbs>
|
||||
<BreadCrumbs />
|
||||
</page.breadcrumbs>
|
||||
|
||||
<page.header>
|
||||
<h2>
|
||||
{{t "titles.new"}}
|
||||
<DocLink
|
||||
@doc={{if @model.isOrg "org.new" "project.new"}}
|
||||
@iconSize="large"
|
||||
/>
|
||||
</h2>
|
||||
</page.header>
|
||||
|
||||
<page.body>
|
||||
<Form::Scope
|
||||
@model={{@model}}
|
||||
@submit={{route-action "save" @model}}
|
||||
@cancel={{route-action "cancel" @model}}
|
||||
/>
|
||||
</page.body>
|
||||
|
||||
</Rose::Layout::Page>
|
||||
@@ -28,7 +28,7 @@
|
||||
<page.actions>
|
||||
{{#if @model.subScopes}}
|
||||
<Rose::LinkButton
|
||||
@route="scopes.scope"
|
||||
@route="scopes.scope.new"
|
||||
@style="primary"
|
||||
>
|
||||
{{t 'titles.new'}}
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user