chore: Add new target route

This commit is contained in:
Susmitha Girumala committed 2020-08-21 13:14:21 -04:00
1 parent 56a059ba96
commit 286a994896
5 files changed
+62 -3

No files matched your search

+1
View File
@@ -31,6 +31,7 @@ Router.map(function () {
});
this.route('targets', function() {
this.route('target', { path: ':target_id' }, function() {});
this.route('new');
});
});
this.route('new');
@@ -0,0 +1,16 @@
import Route from '@ember/routing/route';
export default class ScopesScopeProjectsProjectTargetsNewRoute extends Route {
// =methods
/**
* Creates a new unsaved target in current project scope.
* @return {TargetModel}
*/
model() {
const scopeModel = this.modelFor('scopes.scope.projects.project');
return this.store.createRecord('target', { scopeModel });
}
}
@@ -4,6 +4,14 @@
<h2>{{t "resources.targets"}}</h2>
</page.header>
<page.actions>
{{#if @model}}
<Rose::LinkButton @route="scopes.scope.projects.project.targets.new" @style="primary">
{{t "titles.new"}}
</Rose::LinkButton>
{{/if}}
</page.actions>
<page.body>
{{#if @model}}
@@ -29,9 +37,11 @@
<p>{{target.description}}</p>
</row.cell>
<row.cell>
<Rose::Badge @style="outline">
{{t (concat "target.protocols." target.protocol)}}
</Rose::Badge>
{{#if target.protocol}}
<Rose::Badge @style="outline">
{{t (concat "target.protocols." target.protocol)}}
</Rose::Badge>
{{/if}}
</row.cell>
<row.cell>
<code>{{target.id}}</code>
@@ -48,6 +58,10 @@
<message.description>
{{t "descriptions.targets-welcome"}}
</message.description>
<message.link @route="scopes.scope.projects.project.targets.new">
<Rose::Icon @name="plus-circle-outline" />
{{t "titles.new"}}
</message.link>
</Rose::Message>
</Rose::Layout::Centered>
@@ -0,0 +1,17 @@
{{title (t 'titles.new')}}
<Rose::Layout::Page as |page|>
<page.header>
<h2>{{t "titles.new"}}</h2>
</page.header>
<page.body>
<Form::Target
@model={{@model}}
@submit={{route-action "save" @model}}
@cancel={{route-action "cancel" @model}}
/>
</page.body>
</Rose::Layout::Page>
@@ -0,0 +1,11 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Route | scopes/scope/projects/project/targets/new', function(hooks) {
setupTest(hooks);
test('it exists', function(assert) {
let route = this.owner.lookup('route:scopes/scope/projects/project/targets/new');
assert.ok(route);
});
});