feat: List accounts in an auth method

This commit is contained in:
Susmitha Girumala committed 2020-09-14 15:58:06 -04:00
1 parent 252dbaa75b
commit 3352e02e0e
11 files changed
+144 -42

No files matched your search

+3 -1
View File
@@ -72,7 +72,9 @@ Router.map(function () {
});
this.route('auth-methods', function() {
this.route('auth-method', { path: ':auth_method_id' }, function() {});
this.route('auth-method', { path: ':auth_method_id' }, function() {
this.route('accounts');
});
this.route('new');
});
@@ -12,4 +12,28 @@ export default class ScopesScopeAuthMethodsAuthMethodRoute extends Route {
async model({ auth_method_id }) {
return this.store.findRecord('auth-method', auth_method_id);
}
/**
* Renders the auth-method specific templates for header, navigation,
* and actions page sections.
* @override
*/
renderTemplate() {
super.renderTemplate(...arguments);
this.render('scopes/scope/auth-methods/auth-method/-header', {
into: 'scopes/scope/auth-methods/auth-method',
outlet: 'header',
});
this.render('scopes/scope/auth-methods/auth-method/-navigation', {
into: 'scopes/scope/auth-methods/auth-method',
outlet: 'navigation',
});
this.render('scopes/scope/auth-methods/auth-method/-actions', {
into: 'scopes/scope/auth-methods/auth-method',
outlet: 'actions',
});
}
}
@@ -0,0 +1,15 @@
import Route from '@ember/routing/route';
export default class ScopesScopeAuthMethodsAuthMethodAccountsRoute extends Route {
// =methods
/**
* Returns accounts in current auth method.
* @return {Promise{[AccountModel]}}
*/
model() {
const { id: auth_method_id } = this.modelFor('scopes.scope.auth-methods.auth-method');
return this.store.query('account', { auth_method_id });
}
}
@@ -1 +1,25 @@
{{outlet}}
{{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 @@
<Rose::Dropdown @text="{{t 'actions.manage'}}" @dropdownRight={{true}} as |dropdown|>
<dropdown.button
@style="danger"
@disabled={{@model.canSave}}
{{on "click" (route-action "delete" @model)}}
>
{{t 'actions.delete-auth-method'}}
</dropdown.button>
</Rose::Dropdown>
@@ -0,0 +1,4 @@
<h2>{{t "resources.auth-method"}}</h2>
<Rose::Badge>
{{t (concat 'auth.method-types.' @model.type)}}
</Rose::Badge>
@@ -0,0 +1,8 @@
<Rose::Nav::Tabs as |nav|>
<nav.link @route='scopes.scope.auth-methods.auth-method.index'>
{{t 'titles.details'}}
</nav.link>
<nav.link @route='scopes.scope.auth-methods.auth-method.accounts'>
{{t 'titles.accounts'}}
</nav.link>
</Rose::Nav::Tabs>
@@ -0,0 +1,37 @@
{{title (t 'titles.accounts')}}
{{#if @model}}
<Rose::Table as |table|>
<table.header as |header|>
<header.row as |row|>
<row.headerCell>{{t 'form.label.name'}}</row.headerCell>
<row.headerCell>{{t 'form.label.id'}}</row.headerCell>
</header.row>
</table.header>
<table.body as |body|>
{{#each @model as |account|}}
<body.row as |row|>
<row.headerCell>
{{account.name}}
<p>{{account.description}}</p>
</row.headerCell>
<row.cell>
<code>{{account.id}}</code>
</row.cell>
</body.row>
{{/each}}
</table.body>
</Rose::Table>
{{else}}
<Rose::Layout::Centered>
<Rose::Message @title={{t "titles.auth-method-accounts-welcome"}} as |message|>
<message.description>
{{t "descriptions.auth-method-accounts-welcome"}}
</message.description>
</Rose::Message>
</Rose::Layout::Centered>
{{/if}}
@@ -1,40 +1,5 @@
<Rose::Layout::Page as |page|>
<page.header>
<h2>{{t "resources.auth-method"}}</h2>
<Rose::Badge>
{{t (concat 'auth.method-types.' @model.type)}}
</Rose::Badge>
</page.header>
<page.breadcrumbs>
<BreadCrumbs />
</page.breadcrumbs>
<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.actions>
<Rose::Dropdown @text="{{t 'actions.manage'}}" @dropdownRight={{true}} as |dropdown|>
<dropdown.button
@style="danger"
@disabled={{@model.canSave}}
{{on "click" (route-action "delete" @model)}}
>
{{t 'actions.delete-auth-method'}}
</dropdown.button>
</Rose::Dropdown>
</page.actions>
<page.body>
<Form::AuthMethod
@model={{@model}}
@submit={{route-action "save" @model}}
@cancel={{route-action "cancel" @model}}
/>
</page.body>
</Rose::Layout::Page>
<Form::AuthMethod
@model={{@model}}
@submit={{route-action "save" @model}}
@cancel={{route-action "cancel" @model}}
/>
@@ -0,0 +1,11 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Route | scopes/scope/auth-methods/auth-method/accounts', function(hooks) {
setupTest(hooks);
test('it exists', function(assert) {
let route = this.owner.lookup('route:scopes/scope/auth-methods/auth-method/accounts');
assert.ok(route);
});
});
+3
View File
@@ -102,6 +102,8 @@ titles:
members: Members
group-members-welcome: Welcome to Members
no-available-users: No Users Available
accounts: Accounts
auth-method-accounts-welcome: Welcome to Accounts
descriptions:
host-catalogs: Overview of collections of hosts and host sets.
empty-set: There are no items to display yet. You may be able to add items or try back later.
@@ -122,6 +124,7 @@ descriptions:
no-principals-available: Principals are not available for assignment.
group-members-welcome: Users belonging to this group appear here.
no-available-users: No users are available to add to this group.
auth-method-accounts-welcome: No accounts are available in this auth method.
states:
info: Info
success: Success