Merge pull request #666 from hashicorp/target-credential-libraries-list
List Credential Libraries in a Target
This commit is contained in:
8 files changed
+150
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');
|
||||
}
|
||||
}
|
||||
@@ -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,34 @@
|
||||
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.
|
||||
* @return {Promise{[CredentialLibraryModel]}}
|
||||
*/
|
||||
beforeModel() {
|
||||
const { application_credential_library_ids: credential_libraries } =
|
||||
this.modelFor('scopes.scope.targets.target');
|
||||
return hash({
|
||||
credentialLibraries: all(
|
||||
credential_libraries.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,9 @@
|
||||
<nav.link @route='scopes.scope.targets.target.host-sets'>
|
||||
{{t 'resources.host-set.title_plural'}}
|
||||
</nav.link>
|
||||
{{#if (feature-flag 'credential-store')}}
|
||||
<nav.link @route='scopes.scope.targets.target.credential-libraries'>
|
||||
{{t 'resources.credential-library.title_plural'}}
|
||||
</nav.link>
|
||||
{{/if}}
|
||||
</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}}
|
||||
+17
@@ -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);
|
||||
});
|
||||
}
|
||||
);
|
||||
Reference in new issue
Block a user