Merge pull request #642 from hashicorp/feature-credential-store-crud-detail

Edit credential store
This commit is contained in:
Carlos Alcaide Corvo authored and GitHub committed 2021-07-16 09:19:52 -07:00
commit 32bdf2acdc
16 files changed
+196 -5

No files matched your search

+1
View File
@@ -22,6 +22,7 @@ testem.log
yarn-error.log
storybook-static
**/.storybook/*.html
.watchman-cookie*
# ember-try
.node_modules.ember-try
+3
View File
@@ -464,6 +464,9 @@ export default function () {
credentialStores.where({ scopeId })
);
this.get('/credential-stores/:id');
this.patch('/credential-stores/:id');
// credential-libraries
this.get(
@@ -0,0 +1,38 @@
<Rose::Form
@onSubmit={{@submit}}
@cancel={{@cancel}}
@disabled={{@model.isSaving}}
@showEditToggle={{if @model.isNew false true}}
as |form|
>
<form.input
@value={{@model.type}}
@label={{t 'form.type.label'}}
readonly={{true}}
@disabled={{true}}
/>
<form.input
@name='name'
@type='name'
@value={{@model.name}}
@label={{t 'form.name.label'}}
@helperText={{t 'form.name.help'}}
readonly={{false}}
/>
<form.textarea
@name='description'
@type='description'
@value={{@model.description}}
@label={{t 'form.description.label'}}
@helperText={{t 'form.description.help'}}
/>
<form.actions
@disabled={{if @model.cannotSave @model.cannotSave}}
@enableEditText={{t 'actions.edit-form'}}
@submitText={{t 'actions.save'}}
@cancelText={{t 'actions.cancel'}}
/>
</Rose::Form>
@@ -0,0 +1,13 @@
import Controller from '@ember/controller';
export default class ScopesScopeCredentialStoresCredentialStoreController extends Controller {
// =attributes
/**
* A credential store breadcrumb
* @type {string}
*/
get breadCrumb() {
return this.model.displayName;
}
}
+5 -1
View File
@@ -87,7 +87,11 @@ Router.map(function () {
});
});
this.route('credential-stores', function () {
this.route('credential-store', { path: ':credential_store_id' });
this.route(
'credential-store',
{ path: ':credential_store_id' },
function () {}
);
});
});
});
@@ -1,6 +1,11 @@
import Route from '@ember/routing/route';
import { action } from '@ember/object';
import loading from 'ember-loading/decorator';
import { notifySuccess, notifyError } from 'core/decorators/notify';
export default class ScopesScopeCredentialStoresRoute extends Route {
// =methods
/**
* Load all credential stores under current scope
* @returns {Promise[CredentialStoreModel]}
@@ -9,4 +14,34 @@ export default class ScopesScopeCredentialStoresRoute extends Route {
const { id: scope_id } = this.modelFor('scopes.scope');
return this.store.query('credential-store', { scope_id });
}
// =actions
/**
* Handle save
* @param {CredentialStoreModel} credentialStore
*/
@action
@loading
@notifyError(({ message }) => message)
@notifySuccess('notifications.save-success')
async save(credentialStore) {
await credentialStore.save();
await this.transitionTo(
'scopes.scope.credential-stores.credential-store',
credentialStore
);
this.refresh();
}
/**
* Rollback changes on credential stores.
* @param {CredentialStoreModel} credentialStore
*/
@action
cancel(credentialStore) {
const { isNew } = credentialStore;
credentialStore.rollbackAttributes();
if (isNew) this.transitionTo('scopes.scope.credential-stores');
}
}
@@ -6,6 +6,24 @@ export default class ScopesScopeCredentialStoresCredentialStoreRoute extends Rou
* @return {Promise[CredentialStoreModel]}
*/
async model({ credential_store_id }) {
return this.route.findRecord('credential-store', credential_store_id);
return this.store.findRecord('credential-store', credential_store_id);
}
/**
* Render credential store header and navigation page sections.
* @override
*/
renderTemplate() {
super.renderTemplate(...arguments);
this.render('scopes/scope/credential-stores/credential-store/-header', {
into: 'scopes/scope/credential-stores/credential-store',
outlet: 'header',
});
this.render('scopes/scope/credential-stores/credential-store/-navigation', {
into: 'scopes/scope/credential-stores/credential-store',
outlet: 'navigation',
});
}
}
@@ -0,0 +1,3 @@
import Route from '@ember/routing/route';
export default class ScopesScopeCredentialStoresCredentialStoreIndexRoute extends Route {}
@@ -1,2 +1,24 @@
{{page-title 'CredentialStore'}}
{{outlet}}
{{page-title @model.displayName}}
<Rose::Layout::Page as |page|>
<page.breadcrumbs>
<BreadCrumbs />
</page.breadcrumbs>
<page.header>
{{outlet 'header'}}
</page.header>
<page.navigation>
{{outlet 'navigation'}}
</page.navigation>
<page.actions>
{{!-- {{outlet 'actions'}} --}}
</page.actions>
<page.body>
{{outlet}}
</page.body>
</Rose::Layout::Page>
@@ -0,0 +1,9 @@
<h2>{{t 'resources.credential-store.title'}}</h2>
<p>{{t 'resources.credential-store.description'}}</p>
<Copyable
@text={{@model.id}}
@buttonText={{t 'actions.copy-to-clipboard'}}
@acknowledgeText={{t 'states.copied'}}
>
<code>{{@model.id}}</code>
</Copyable>
@@ -0,0 +1,5 @@
<Rose::Nav::Tabs as |nav|>
<nav.link @route='scopes.scope.credential-stores.credential-store.index'>
{{t 'titles.details'}}
</nav.link>
</Rose::Nav::Tabs>
@@ -0,0 +1,5 @@
<Form::CredentialStore
@model={{@model}}
@submit={{route-action 'save' @model}}
@cancel={{route-action 'cancel' @model}}
/>
@@ -6,8 +6,9 @@
<page.header>
<h2>
{{t 'resources.credential-store.title_plural'}}
<DocLink @doc='credential-stores' @iconSize='large' />
</h2>
{{t 'resources.credential-store.description'}}
<p>{{t 'resources.credential-store.description'}}</p>
</page.header>
{{!-- <page.actions>
+1
View File
@@ -55,6 +55,7 @@ module.exports = function (environment) {
'host-set': '/host-sets',
'host-set.new': '/host-sets/new',
'host-set.add-hosts': '/host-sets/add-hosts',
'credential-stores': '/credential-stores',
host: '/hosts',
'host.new': '/hosts/new',
role: '/roles',
@@ -0,0 +1,17 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module(
'Unit | Controller | scopes/scope/credential-stores/credential-store',
function (hooks) {
setupTest(hooks);
// TODO: Replace this with your real tests.
test('it exists', function (assert) {
let controller = this.owner.lookup(
'controller:scopes/scope/credential-stores/credential-store'
);
assert.ok(controller);
});
}
);
@@ -0,0 +1,16 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module(
'Unit | Route | scopes/scope/credential-stores/credential-store/index',
function (hooks) {
setupTest(hooks);
test('it exists', function (assert) {
let route = this.owner.lookup(
'route:scopes/scope/credential-stores/credential-store/index'
);
assert.ok(route);
});
}
);