chore: Add auth-method index route
This commit is contained in:
12 files changed
+206
-2
No files matched your search
@@ -0,0 +1,47 @@
|
||||
<Rose::Form
|
||||
@onSubmit={{@submit}}
|
||||
@cancel={{@cancel}}
|
||||
@disabled={{@model.isSaving}}
|
||||
@error={{@model.errors.base}}
|
||||
as |form|
|
||||
>
|
||||
<form.input
|
||||
@name="name"
|
||||
@type="name"
|
||||
@value={{@model.name}}
|
||||
@label={{t "form.label.name"}}
|
||||
@error={{@model.errors.name}}
|
||||
readonly={{false}}
|
||||
as |field|>
|
||||
{{#if @model.errors.name}}
|
||||
<field.errors as |errors|>
|
||||
{{#each @model.errors.name as |error|}}
|
||||
<errors.message>{{error.message}}</errors.message>
|
||||
{{/each}}
|
||||
</field.errors>
|
||||
{{/if}}
|
||||
</form.input>
|
||||
|
||||
<form.textarea
|
||||
@name="description"
|
||||
@type="description"
|
||||
@value={{@model.description}}
|
||||
@label={{t "form.label.description"}}
|
||||
@error={{@model.errors.description}}
|
||||
disabled={{@model.isSaving}}
|
||||
readonly={{false}}
|
||||
as |field|>
|
||||
{{#if @model.errors.description}}
|
||||
<field.errors as |errors|>
|
||||
{{#each @model.errors.description as |error|}}
|
||||
<errors.message>{{error.message}}</errors.message>
|
||||
{{/each}}
|
||||
</field.errors>
|
||||
{{/if}}
|
||||
</form.textarea>
|
||||
|
||||
<form.actions
|
||||
@disabled={{if @model.cannotSave @model.cannotSave}}
|
||||
@submitText={{t "actions.save"}}
|
||||
@cancelText={{t "actions.cancel"}} />
|
||||
</Rose::Form>
|
||||
@@ -35,7 +35,9 @@ Router.map(function () {
|
||||
});
|
||||
this.route('new');
|
||||
});
|
||||
this.route('auth-methods', function() {});
|
||||
this.route('auth-methods', function() {
|
||||
this.route('auth-method', { path: ':auth_method_id' }, function() {});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,6 +1,13 @@
|
||||
import Route from '@ember/routing/route';
|
||||
import { inject as service } from '@ember/service';
|
||||
import { action } from '@ember/object';
|
||||
|
||||
export default class ScopesScopeAuthMethodsRoute extends Route {
|
||||
// =services
|
||||
|
||||
@service intl;
|
||||
@service notify;
|
||||
|
||||
// =methods
|
||||
|
||||
/**
|
||||
@@ -11,4 +18,53 @@ export default class ScopesScopeAuthMethodsRoute extends Route {
|
||||
const { id: scopeID} = this.modelFor('scopes.scope');
|
||||
return this.store.findAll('auth-method', { adapterOptions: { scopeID } });
|
||||
}
|
||||
|
||||
// =actions
|
||||
/**
|
||||
* Rollback changes to an auth-method.
|
||||
* @param {AuthMethodModel} authMethod
|
||||
*/
|
||||
@action
|
||||
cancel(authMethod) {
|
||||
const { isNew } = authMethod;
|
||||
authMethod.rollbackAttributes();
|
||||
if (isNew) this.transitionTo('scopes.scope.auth-methods');
|
||||
}
|
||||
|
||||
/**
|
||||
* Save an auth-method in current scope.
|
||||
* @param {AuthMethodModel} authMethod
|
||||
*/
|
||||
@action
|
||||
async save(authMethod) {
|
||||
const { isNew } = authMethod;
|
||||
try {
|
||||
await authMethod.save();
|
||||
this.refresh();
|
||||
this.notify.success(
|
||||
this.intl.t(isNew ? 'notify.create-success' : 'notify.save-success')
|
||||
);
|
||||
this.transitionTo('scopes.scope.auth-methods.auth-method');
|
||||
} catch (error) {
|
||||
//TODO: replace with translated strings
|
||||
this.notify.error(error.message, { closeAfter: null });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an auth-method in current scope and redirect to auth-methods
|
||||
* @param {AuthMethodModel} authMethod
|
||||
*/
|
||||
@action
|
||||
async delete(authMethod) {
|
||||
try {
|
||||
await authMethod.destroyRecord();
|
||||
this.refresh();
|
||||
this.notify.success(this.intl.t('notify.delete-success'));
|
||||
this.transitionTo('scopes.scope.auth-methods');
|
||||
} catch (error) {
|
||||
//TODO: replace with translated strings
|
||||
this.notify.error(error.message, { closeAfter: null });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import Route from '@ember/routing/route';
|
||||
|
||||
export default class ScopesScopeAuthMethodsAuthMethodRoute extends Route {
|
||||
// =methods
|
||||
|
||||
/**
|
||||
* Load a single auth-method in current scope.
|
||||
* @param {object} params
|
||||
* @param {string} params.auth_method_id
|
||||
* @return {authMethodModel}
|
||||
*/
|
||||
async model({ auth_method_id}) {
|
||||
const { id: scopeID } = this.modelFor('scopes.scope');
|
||||
return this.store.findRecord('auth-method', auth_method_id, { adapterOptions: { scopeID }});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import Route from '@ember/routing/route';
|
||||
|
||||
export default class ScopesScopeAuthMethodsAuthMethodIndexRoute extends Route {
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{{outlet}}
|
||||
@@ -0,0 +1,24 @@
|
||||
<Rose::Layout::Page as |page|>
|
||||
<page.header>
|
||||
<h2>{{t "resources.auth-method"}}</h2>
|
||||
</page.header>
|
||||
|
||||
<page.navigation>
|
||||
<Rose::Nav::Tabs as |nav|>
|
||||
<nav.link @route='scopes.scope.auth-methods.auth-method'>
|
||||
{{t 'titles.details'}}
|
||||
</nav.link>
|
||||
</Rose::Nav::Tabs>
|
||||
</page.navigation>
|
||||
|
||||
<page.body>
|
||||
|
||||
{{@model.type}}
|
||||
|
||||
<Form::AuthMethod
|
||||
@model={{@model}}
|
||||
@submit={{route-action "save" @model}}
|
||||
@cancel={{route-action "cancel" @model}}
|
||||
/>
|
||||
</page.body>
|
||||
</Rose::Layout::Page>
|
||||
@@ -18,7 +18,12 @@
|
||||
{{#each @model as |authMethod|}}
|
||||
<body.row as |row|>
|
||||
<row.cell>
|
||||
{{authMethod.name}}
|
||||
<LinkTo
|
||||
@route="scopes.scope.auth-methods.auth-method"
|
||||
@model={{authMethod}}
|
||||
>
|
||||
{{authMethod.name}}
|
||||
</LinkTo>
|
||||
{{authMethod.description}}
|
||||
</row.cell>
|
||||
<row.cell>
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupRenderingTest } from 'ember-qunit';
|
||||
import { render } from '@ember/test-helpers';
|
||||
import { hbs } from 'ember-cli-htmlbars';
|
||||
|
||||
module('Integration | Component | form/auth-method/index', function(hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
test('it renders', async function(assert) {
|
||||
// Set any properties with this.set('myProperty', 'value');
|
||||
// Handle any actions with this.set('myAction', function(val) { ... });
|
||||
|
||||
await render(hbs`<Form::AuthMethod::Index />`);
|
||||
|
||||
assert.equal(this.element.textContent.trim(), '');
|
||||
|
||||
// Template block usage:
|
||||
await render(hbs`
|
||||
<Form::AuthMethod::Index>
|
||||
template block text
|
||||
</Form::AuthMethod::Index>
|
||||
`);
|
||||
|
||||
assert.equal(this.element.textContent.trim(), 'template block text');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Route | scopes/scope/auth-methods/auth-method', function(hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function(assert) {
|
||||
let route = this.owner.lookup('route:scopes/scope/auth-methods/auth-method');
|
||||
assert.ok(route);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Route | scopes/scope/auth-methods/auth-method/index', function(hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function(assert) {
|
||||
let route = this.owner.lookup('route:scopes/scope/auth-methods/auth-method/index');
|
||||
assert.ok(route);
|
||||
});
|
||||
});
|
||||
@@ -31,6 +31,7 @@ resources:
|
||||
project: Project
|
||||
host-catalog: Host Catalog
|
||||
host-catalogs: Host Catalogs
|
||||
auth-method: Auth Method
|
||||
auth-methods: Auth Methods
|
||||
titles:
|
||||
iam: IAM
|
||||
|
||||
Reference in new issue
Block a user