diff --git a/ui/core/app/components/form/group/add-members/index.hbs b/ui/core/app/components/form/group/add-members/index.hbs
new file mode 100644
index 000000000..fef2f383c
--- /dev/null
+++ b/ui/core/app/components/form/group/add-members/index.hbs
@@ -0,0 +1,48 @@
+{{#if this.availableUsers}}
+
+
+
+
+
+
+
+ {{t 'form.label.id'}}
+ {{t 'form.label.name'}}
+
+
+
+ {{#each this.availableUsers as |user|}}
+
+
+
+
+ {{user.name}}
+
+ {{/each}}
+
+
+
+
+{{/if}}
+
+{{#unless this.availableUsers}}
+
+
+
+ {{t "descriptions.no-available-users"}}
+
+
+
+{{/unless}}
diff --git a/ui/core/app/components/form/group/add-members/index.js b/ui/core/app/components/form/group/add-members/index.js
new file mode 100644
index 000000000..dbf5256bb
--- /dev/null
+++ b/ui/core/app/components/form/group/add-members/index.js
@@ -0,0 +1,42 @@
+import Component from '@glimmer/component';
+import { computed, action } from '@ember/object';
+import { A } from '@ember/array';
+
+export default class FormGroupAddMembersComponent extends Component {
+
+ // =properties
+
+ /**
+ * Array of selected user IDs.
+ * @type {EmberArray}
+ */
+ selectedMemberIDs = A();
+
+ /**
+ * Host sets not already added to the target.
+ * @type {[UserModel]}
+ */
+ @computed('args.{model.members_ids.[],users.[]}')
+ get availableUsers() {
+ const memberIDs = this.args.model.member_ids;
+ const users = this.args.users;
+ return users.filter(({ id }) => !memberIDs.includes(id));
+ }
+
+ // =actions
+
+ @action
+ toggleMember(user) {
+ if (!this.selectedMemberIDs.includes(user.id)) {
+ this.selectedMemberIDs.addObject(user.id);
+ } else {
+ this.selectedMemberIDs.removeObject(user.id);
+ }
+ }
+
+ @action
+ submit(fn) {
+ fn(this.selectedMemberIDs);
+ }
+
+}
diff --git a/ui/core/app/controllers/scopes/scope/groups/group/add-members.js b/ui/core/app/controllers/scopes/scope/groups/group/add-members.js
new file mode 100644
index 000000000..7a94c1034
--- /dev/null
+++ b/ui/core/app/controllers/scopes/scope/groups/group/add-members.js
@@ -0,0 +1,20 @@
+import Controller from '@ember/controller';
+import { inject as service } from '@ember/service';
+
+export default class ScopesScopeGroupsGroupAddMembersController extends Controller {
+
+ // =services
+
+ @service intl;
+
+ // =attributes
+
+ /**
+ * Translated new group breadcrumb
+ * @type {string}
+ */
+ get breadCrumb() {
+ return this.intl.t('actions.add-members');
+ }
+
+}
diff --git a/ui/core/app/router.js b/ui/core/app/router.js
index 6800b5103..a8699d517 100644
--- a/ui/core/app/router.js
+++ b/ui/core/app/router.js
@@ -56,6 +56,7 @@ Router.map(function () {
this.route('groups', function () {
this.route('group', { path: ':group_id' }, function () {
this.route('members');
+ this.route('add-members');
});
this.route('new');
});
diff --git a/ui/core/app/routes/scopes/scope/groups/group.js b/ui/core/app/routes/scopes/scope/groups/group.js
index 6231ab13f..bd638b343 100644
--- a/ui/core/app/routes/scopes/scope/groups/group.js
+++ b/ui/core/app/routes/scopes/scope/groups/group.js
@@ -1,6 +1,7 @@
import Route from '@ember/routing/route';
export default class ScopesScopeGroupsGroupRoute extends Route {
+
// =methods
/**
@@ -9,10 +10,33 @@ export default class ScopesScopeGroupsGroupRoute extends Route {
* @param {string} params.group_id
* @return {groupModel}
*/
- async model({ group_id }) {
+ model({ group_id }) {
const { id: scopeID } = this.modelFor('scopes.scope');
return this.store.findRecord('group', group_id, {
adapterOptions: { scopeID },
});
}
+
+ /**
+ * Renders the route-set specific page sections
+ * @override
+ */
+ renderTemplate() {
+ super.renderTemplate(...arguments);
+
+ this.render('scopes/scope/groups/group/-header', {
+ into: 'scopes/scope/groups/group',
+ outlet: 'header'
+ });
+
+ this.render('scopes/scope/groups/group/-actions', {
+ into: 'scopes/scope/groups/group',
+ outlet: 'actions'
+ });
+
+ this.render('scopes/scope/groups/group/-navigation', {
+ into: 'scopes/scope/groups/group',
+ outlet: 'navigation'
+ });
+ }
}
diff --git a/ui/core/app/routes/scopes/scope/groups/group/add-members.js b/ui/core/app/routes/scopes/scope/groups/group/add-members.js
new file mode 100644
index 000000000..f3b8717a9
--- /dev/null
+++ b/ui/core/app/routes/scopes/scope/groups/group/add-members.js
@@ -0,0 +1,85 @@
+import Route from '@ember/routing/route';
+import { inject as service } from '@ember/service';
+import { action } from '@ember/object';
+import { hash } from 'rsvp';
+
+export default class ScopesScopeGroupsGroupAddMembersRoute extends Route {
+
+ // =services
+
+ @service intl;
+ @service notify;
+
+ // =methods
+
+ /**
+ * Emtpy out any previously loaded users.
+ */
+ beforeModel() {
+ this.store.unloadAll('user');
+ }
+
+ /**
+ * Loads all users and returns them with the group.
+ * @return {Promise{GroupModel, [UserModel]}}
+ */
+ model() {
+ const { id: scopeID } = this.modelFor('scopes.scope');
+ return hash({
+ group: this.modelFor('scopes.scope.groups.group'),
+ users: this.store.findAll('user', { adapterOptions: { scopeID } })
+ });
+ }
+
+ /**
+ * Renders the route-set specific page sections
+ * @override
+ */
+ renderTemplate() {
+ super.renderTemplate(...arguments);
+
+ this.render('scopes/scope/groups/group/add-members/-header', {
+ into: 'scopes/scope/groups/group',
+ outlet: 'header'
+ });
+
+ this.render('-empty', {
+ into: 'scopes/scope/groups/group',
+ outlet: 'actions'
+ });
+
+ this.render('-empty', {
+ into: 'scopes/scope/groups/group',
+ outlet: 'navigation'
+ });
+ }
+
+ // =actions
+
+ /**
+ * Adds members to the group and saves, replaces with the members index
+ * route, and notifies the user of success or error.
+ * @param {GroupModel} group
+ * @param {[string]} userIDs
+ */
+ @action
+ async addMembers(group, userIDs) {
+ try {
+ await group.addMembers(userIDs);
+ await this.replaceWith('scopes.scope.groups.group.members');
+ this.notify.success(this.intl.t('notify.save-success'));
+ } catch (error) {
+ // TODO: replace with translated strings
+ this.notify.error(error.message, { closeAfter: null });
+ }
+ }
+
+ /**
+ * Redirect to group members as if nothing ever happened.
+ */
+ @action
+ cancel() {
+ this.replaceWith('scopes.scope.groups.group.members');
+ }
+
+}
diff --git a/ui/core/app/templates/scopes/scope/groups/group.hbs b/ui/core/app/templates/scopes/scope/groups/group.hbs
index bb0ba8b8a..2a878ff51 100644
--- a/ui/core/app/templates/scopes/scope/groups/group.hbs
+++ b/ui/core/app/templates/scopes/scope/groups/group.hbs
@@ -7,30 +7,15 @@
- {{t "resources.group"}}
+ {{outlet "header"}}
-
-
- {{t 'titles.details'}}
-
-
- {{t 'titles.members'}}
-
-
+ {{outlet "navigation"}}
-
-
- {{t 'actions.delete-group'}}
-
-
+ {{outlet "actions"}}
diff --git a/ui/core/app/templates/scopes/scope/groups/group/-actions.hbs b/ui/core/app/templates/scopes/scope/groups/group/-actions.hbs
new file mode 100644
index 000000000..1ebd9d2c6
--- /dev/null
+++ b/ui/core/app/templates/scopes/scope/groups/group/-actions.hbs
@@ -0,0 +1,12 @@
+
+
+ {{t "actions.add-members"}}
+
+
+ {{t 'actions.delete-group'}}
+
+
diff --git a/ui/core/app/templates/scopes/scope/groups/group/-header.hbs b/ui/core/app/templates/scopes/scope/groups/group/-header.hbs
new file mode 100644
index 000000000..6631940a3
--- /dev/null
+++ b/ui/core/app/templates/scopes/scope/groups/group/-header.hbs
@@ -0,0 +1 @@
+{{t "resources.group"}}
diff --git a/ui/core/app/templates/scopes/scope/groups/group/-navigation.hbs b/ui/core/app/templates/scopes/scope/groups/group/-navigation.hbs
new file mode 100644
index 000000000..6dc45b637
--- /dev/null
+++ b/ui/core/app/templates/scopes/scope/groups/group/-navigation.hbs
@@ -0,0 +1,8 @@
+
+
+ {{t 'titles.details'}}
+
+
+ {{t 'titles.members'}}
+
+
diff --git a/ui/core/app/templates/scopes/scope/groups/group/add-members.hbs b/ui/core/app/templates/scopes/scope/groups/group/add-members.hbs
new file mode 100644
index 000000000..6f674b02d
--- /dev/null
+++ b/ui/core/app/templates/scopes/scope/groups/group/add-members.hbs
@@ -0,0 +1,8 @@
+{{title (t "actions.add-members")}}
+
+
diff --git a/ui/core/app/templates/scopes/scope/groups/group/add-members/-header.hbs b/ui/core/app/templates/scopes/scope/groups/group/add-members/-header.hbs
new file mode 100644
index 000000000..48dca079b
--- /dev/null
+++ b/ui/core/app/templates/scopes/scope/groups/group/add-members/-header.hbs
@@ -0,0 +1 @@
+{{t "actions.add-members"}}
diff --git a/ui/core/tests/acceptance/groups-test.js b/ui/core/tests/acceptance/groups-test.js
index c33014378..a6ad6ccd9 100644
--- a/ui/core/tests/acceptance/groups-test.js
+++ b/ui/core/tests/acceptance/groups-test.js
@@ -221,5 +221,17 @@ module('Acceptance | groups', function (hooks) {
test('can view group members', async function (assert) {
assert.expect(0);
});
-
+
+ test('can delete members', async function(assert) {
+ assert.expect(0);
+ });
+
+ test('select and save members to add', async function (assert) {
+ assert.expect(0);
+ });
+
+ test('select and cancel members to add', async function (assert) {
+ assert.expect(0);
+ });
+
});
diff --git a/ui/core/tests/unit/controllers/scopes/scope/groups/group/add-members-test.js b/ui/core/tests/unit/controllers/scopes/scope/groups/group/add-members-test.js
new file mode 100644
index 000000000..17daef1db
--- /dev/null
+++ b/ui/core/tests/unit/controllers/scopes/scope/groups/group/add-members-test.js
@@ -0,0 +1,12 @@
+import { module, test } from 'qunit';
+import { setupTest } from 'ember-qunit';
+
+module('Unit | Controller | scopes/scope/groups/group/add-members', function(hooks) {
+ setupTest(hooks);
+
+ // Replace this with your real tests.
+ test('it exists', function(assert) {
+ let controller = this.owner.lookup('controller:scopes/scope/groups/group/add-members');
+ assert.ok(controller);
+ });
+});
diff --git a/ui/core/tests/unit/routes/scopes/scope/groups/group/add-members-test.js b/ui/core/tests/unit/routes/scopes/scope/groups/group/add-members-test.js
new file mode 100644
index 000000000..8500b2957
--- /dev/null
+++ b/ui/core/tests/unit/routes/scopes/scope/groups/group/add-members-test.js
@@ -0,0 +1,11 @@
+import { module, test } from 'qunit';
+import { setupTest } from 'ember-qunit';
+
+module('Unit | Route | scopes/scope/groups/group/add-members', function(hooks) {
+ setupTest(hooks);
+
+ test('it exists', function(assert) {
+ let route = this.owner.lookup('route:scopes/scope/groups/group/add-members');
+ assert.ok(route);
+ });
+});
diff --git a/ui/core/translations/en-us.yaml b/ui/core/translations/en-us.yaml
index d33ec0514..581610766 100644
--- a/ui/core/translations/en-us.yaml
+++ b/ui/core/translations/en-us.yaml
@@ -23,6 +23,7 @@ actions:
add-host-set: Create Host Set
add-host: Create Host
add-host-sets: Add Host Sets
+ add-members: Add Members
auth:
titles:
no-scopes: No Scopes Available
@@ -95,6 +96,7 @@ titles:
role-principals-welcome: No Principals Associated
members: Members
group-members-welcome: Welcome to Members
+ no-available-users: No Users Available
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.
@@ -112,6 +114,7 @@ descriptions:
no-host-sets-for-target: No host sets are available to add to this target.
role-principals-welcome: No principals are available in this role.
group-members-welcome: Users belonging to this group appear here.
+ no-available-users: No users are available to add to this group.
states:
info: Info
success: Success