feat: List credential libraries for a target

This commit is contained in:
Susmitha Girumala committed 2021-07-23 16:33:45 -04:00
1 parent 2726538c41
commit af7e539f3d
8 files changed
+149

No files matched your search

@@ -267,6 +267,11 @@ target:
add:
title: Add Host Sets
description: Select host sets to assign to this target.
credential-library:
messages:
welcome:
title: Welcome to Credential Libraries
description: No credential libraries in this target.
credential-store:
title: Credential Store
title_plural: Credential Stores
@@ -0,0 +1,18 @@
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
export default class ScopesScopeTargetsTargetCredentialLibrariesController extends Controller {
// =services
@service intl;
// =attributes
/**
* Translated credential library breadcrumb
* @type {string}
*/
get breadCrumb() {
return this.intl.t('resources.credential-library.title_plural');
}
}
+1
View File
@@ -65,6 +65,7 @@ Router.map(function () {
this.route('target', { path: ':target_id' }, function () {
this.route('host-sets', function () {});
this.route('add-host-sets');
this.route('credential-libraries');
});
this.route('new');
});
@@ -0,0 +1,35 @@
import Route from '@ember/routing/route';
import { hash, all } from 'rsvp';
export default class ScopesScopeTargetsTargetCredentialLibrariesRoute extends Route {
// =methods
/**
* Loads all credential libraries under the current target
* and it's parent scope.
* @return {Promise{[CredentialLibraryModel]}}
*/
beforeModel() {
const { application_credential_library_ids: credential_library_ids } =
this.modelFor('scopes.scope.targets.target');
return hash({
credentialLibraries: all(
credential_library_ids.map((credential_library) =>
this.store.findRecord(
'credential-library',
credential_library.value,
{ reload: true }
)
)
),
});
}
/**
* Returns the previously loaded target instance.
* @return {TargetModel}
*/
model() {
return this.modelFor('scopes.scope.targets.target');
}
}
@@ -5,4 +5,7 @@
<nav.link @route='scopes.scope.targets.target.host-sets'>
{{t 'resources.host-set.title_plural'}}
</nav.link>
<nav.link @route='scopes.scope.targets.target.credential-libraries'>
{{t 'resources.credential-library.title_plural'}}
</nav.link>
</Rose::Nav::Tabs>
@@ -0,0 +1,54 @@
{{page-title (t 'resources.credential-library.title_plural')}}
{{#if @model.credentialLibraries}}
<Rose::Table as |table|>
<table.header as |header|>
<header.row as |row|>
<row.headerCell>{{t 'form.name.label'}}</row.headerCell>
<row.headerCell>{{t 'form.id.label'}}</row.headerCell>
</header.row>
</table.header>
<table.body as |body|>
{{#each @model.credentialLibraries as |credentialLibrary|}}
<body.row as |row|>
<row.headerCell>
<LinkTo
@route='scopes.scope.credential-stores.credential-store.credential-libraries.credential-library'
@models={{array
credentialLibrary.credential_store_id
credentialLibrary.id
}}
>
{{credentialLibrary.displayName}}
</LinkTo>
<p>{{credentialLibrary.description}}</p>
</row.headerCell>
<row.cell>
<Copyable
@text={{credentialLibrary.id}}
@buttonText={{t 'actions.copy-to-clipboard'}}
@acknowledgeText={{t 'states.copied'}}
>
<code>{{credentialLibrary.id}}</code>
</Copyable>
</row.cell>
</body.row>
{{/each}}
</table.body>
</Rose::Table>
{{else}}
<Rose::Layout::Centered>
<Rose::Message
@title={{t 'resources.target.credential-library.messages.welcome.title'}}
as |message|
>
<message.description>
{{t 'resources.target.credential-library.messages.welcome.description'}}
</message.description>
</Rose::Message>
</Rose::Layout::Centered>
{{/if}}
@@ -0,0 +1,17 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module(
'Unit | Controller | scopes/scope/targets/target/credential-libraries',
function (hooks) {
setupTest(hooks);
// TODO: Replace this with your real tests.
test('it exists', function (assert) {
let controller = this.owner.lookup(
'controller:scopes/scope/targets/target/credential-libraries'
);
assert.ok(controller);
});
}
);
@@ -0,0 +1,16 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module(
'Unit | Route | scopes/scope/targets/target/credential-libraries',
function (hooks) {
setupTest(hooks);
test('it exists', function (assert) {
let route = this.owner.lookup(
'route:scopes/scope/targets/target/credential-libraries'
);
assert.ok(route);
});
}
);