feat: 🎸 Add managed groups read CRUD
Add managed groups Read CRUD operation
This commit is contained in:
1 parent
6bedc710d3
commit
b7bf44b997
18 files changed
+217
-3
No files matched your search
@@ -521,6 +521,7 @@ export default function () {
|
||||
return managedGroups.where({ authMethodId });
|
||||
}
|
||||
);
|
||||
this.get('/managed-groups/:id');
|
||||
|
||||
/* Uncomment the following line and the Response import above
|
||||
* Then change the response code to simulate error responses.
|
||||
|
||||
@@ -115,3 +115,5 @@ value:
|
||||
callback_url:
|
||||
label: Callback URL
|
||||
help: The URL to which the third-party provider sends the authentication response. Paste this into the provider configuration.
|
||||
filter:
|
||||
label: Filter
|
||||
@@ -354,3 +354,6 @@ scope:
|
||||
managed-group:
|
||||
title: Managed Group
|
||||
title_plural: Managed Groups
|
||||
description: A managed group is a resource that represents a collection of accounts.
|
||||
actions:
|
||||
delete: Delete Managed Group
|
||||
@@ -0,0 +1,54 @@
|
||||
<Rose::Form 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'}}
|
||||
@error={{@model.error.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.description.label'}}
|
||||
@error={{@model.errors.description}}
|
||||
@helperText={{t 'form.description.help'}}
|
||||
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.input
|
||||
@value={{@model.attributes.filter}}
|
||||
@label={{t 'form.filter.label'}}
|
||||
readonly={{true}}
|
||||
@disabled={{true}}
|
||||
/>
|
||||
</Rose::Form>
|
||||
@@ -55,7 +55,13 @@ Router.map(function () {
|
||||
});
|
||||
this.route('new');
|
||||
});
|
||||
this.route('managed-groups', function () {});
|
||||
this.route('managed-groups', function () {
|
||||
this.route(
|
||||
'managed-group',
|
||||
{ path: ':managed_group_id' },
|
||||
function () {}
|
||||
);
|
||||
});
|
||||
});
|
||||
this.route('new');
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import Route from '@ember/routing/route';
|
||||
import { action } from '@ember/object';
|
||||
|
||||
export default class ScopesScopeAuthMethodsAuthMethodManagedGroupsRoute extends Route {
|
||||
/**
|
||||
@@ -10,4 +11,18 @@ export default class ScopesScopeAuthMethodsAuthMethodManagedGroupsRoute extends
|
||||
const { id: auth_method_id } = authMethod;
|
||||
return this.store.query('managed-group', { auth_method_id });
|
||||
}
|
||||
|
||||
// =actions
|
||||
/**
|
||||
* Rollback changes on a managed group.
|
||||
* @param {ManagedGroupModel} managedGroup
|
||||
*/
|
||||
@action
|
||||
cancel(managedGroup) {
|
||||
const { isNew } = managedGroup;
|
||||
managedGroup.rollbackAttributes();
|
||||
if (isNew) {
|
||||
this.transitionTo('scopes.scope.auth-methods.auth-method.managed-groups');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,9 @@
|
||||
import Route from '@ember/routing/route';
|
||||
|
||||
export default class ScopesScopeAuthMethodsAuthMethodManagedGroupsIndexRoute extends Route {}
|
||||
export default class ScopesScopeAuthMethodsAuthMethodManagedGroupsIndexRoute extends Route {
|
||||
setupController(controller) {
|
||||
const authMethod = this.modelFor('scopes.scope.auth-methods.auth-method');
|
||||
super.setupController(...arguments);
|
||||
controller.setProperties({ authMethod });
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
import Route from '@ember/routing/route';
|
||||
|
||||
export default class ScopesScopeAuthMethodsAuthMethodManagedGroupsManagedGroupRoute extends Route {
|
||||
// =methods
|
||||
|
||||
/**
|
||||
* Load managed group by ID.
|
||||
* @param {object} params
|
||||
* @param {string} params.managed_group_id
|
||||
* @returns {ManagedGroupModel}
|
||||
*/
|
||||
model({ managed_group_id }) {
|
||||
return this.store.findRecord('managed-group', managed_group_id, {
|
||||
reload: true,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the route-set specific page sections
|
||||
* @override
|
||||
*/
|
||||
renderTemplate() {
|
||||
super.renderTemplate(...arguments);
|
||||
|
||||
this.render(
|
||||
'scopes/scope/auth-methods/auth-method/managed-groups/managed-group/-header',
|
||||
{
|
||||
into: 'scopes/scope/auth-methods/auth-method',
|
||||
outlet: 'header',
|
||||
}
|
||||
);
|
||||
|
||||
this.render(
|
||||
'scopes/scope/auth-methods/auth-method/managed-groups/managed-group/-actions',
|
||||
{
|
||||
into: 'scopes/scope/auth-methods/auth-method',
|
||||
outlet: 'actions',
|
||||
}
|
||||
);
|
||||
|
||||
this.render(
|
||||
'scopes/scope/auth-methods/auth-method/managed-groups/managed-group/-navigation',
|
||||
{
|
||||
into: 'scopes/scope/auth-methods/auth-method',
|
||||
outlet: 'navigation',
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import Route from '@ember/routing/route';
|
||||
|
||||
export default class ScopesScopeAuthMethodsAuthMethodManagedGroupsManagedGroupIndexRoute extends Route {}
|
||||
+10
-1
@@ -12,7 +12,16 @@
|
||||
<table.body as |body|>
|
||||
{{#each @model as |managed-group|}}
|
||||
<body.row as |row|>
|
||||
<row.headerCell>{{managed-group.name}}</row.headerCell>
|
||||
<row.headerCell>
|
||||
{{#if (can 'read model' managed-group)}}
|
||||
<LinkTo
|
||||
@route='scopes.scope.auth-methods.auth-method.managed-groups.managed-group'
|
||||
@model={{managed-group.id}}
|
||||
>
|
||||
{{managed-group.name}}
|
||||
</LinkTo>
|
||||
{{/if}}
|
||||
</row.headerCell>
|
||||
<row.cell>{{managed-group.description}}</row.cell>
|
||||
<row.cell>
|
||||
<Rose::Badge>{{managed-group.type}}</Rose::Badge>
|
||||
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
{{page-title 'ManagedGroup'}}
|
||||
{{outlet}}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
{{#if (can 'delete model' @model)}}
|
||||
<Rose::Dropdown
|
||||
@text={{t 'actions.manage'}}
|
||||
@dropdownRight={{true}}
|
||||
as |dropdown|
|
||||
>
|
||||
<dropdown.button @style='danger' @disabled={{@model.canSave}}>
|
||||
{{t 'resources.managed-group.actions.delete'}}
|
||||
</dropdown.button>
|
||||
</Rose::Dropdown>
|
||||
{{/if}}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
<h2>
|
||||
{{t 'resources.managed-group.title'}}
|
||||
<DocLink @doc='managed-groups' @iconSize='large' />
|
||||
</h2>
|
||||
<p>{{t 'resources.managed-group.description'}}</p>
|
||||
<Copyable
|
||||
@text={{@model.id}}
|
||||
@buttonText={{t 'actions.copy-to-clipboard'}}
|
||||
@acknowledgeText={{t 'states.copied'}}
|
||||
>
|
||||
<code>{{@model.id}}</code>
|
||||
</Copyable>
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<Rose::Nav::Tabs as |nav|>
|
||||
<nav.link
|
||||
@route='scopes.scope.auth-methods.auth-method.managed-groups.managed-group.index'
|
||||
>
|
||||
{{t 'titles.details'}}
|
||||
</nav.link>
|
||||
</Rose::Nav::Tabs>
|
||||
+1
@@ -0,0 +1 @@
|
||||
<Form::ManagedGroup @model={{@model}} />
|
||||
@@ -48,6 +48,7 @@ module.exports = function (environment) {
|
||||
account: '/accounts',
|
||||
'account.new': '/accounts/new',
|
||||
'auth-method': '/auth-methods',
|
||||
'managed-groups': '/managed-groups',
|
||||
group: '/groups',
|
||||
'group.add-members': '/groups/add-members',
|
||||
'host-catalog': '/host-catalogs',
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module(
|
||||
'Unit | Route | scopes/scope/auth-methods/auth-method/managed-groups/managed-group',
|
||||
function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function (assert) {
|
||||
let route = this.owner.lookup(
|
||||
'route:scopes/scope/auth-methods/auth-method/managed-groups/managed-group'
|
||||
);
|
||||
assert.ok(route);
|
||||
});
|
||||
}
|
||||
);
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module(
|
||||
'Unit | Route | scopes/scope/auth-methods/auth-method/managed-groups/managed-group/index',
|
||||
function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function (assert) {
|
||||
let route = this.owner.lookup(
|
||||
'route:scopes/scope/auth-methods/auth-method/managed-groups/managed-group/index'
|
||||
);
|
||||
assert.ok(route);
|
||||
});
|
||||
}
|
||||
);
|
||||
Reference in new issue
Block a user