From 98c7d003a08ac6140053614bda28585c3b02df3e Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Wed, 24 Jun 2020 17:07:32 -0400 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A4=96=20List=20groups=20under?= =?UTF-8?q?=20/groups=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/api/addon/adapters/group.js | 14 +++++ addons/api/app/adapters/group.js | 1 + addons/api/tests/unit/adapters/group-test.js | 12 ++++ ui/core/app/routes/orgs/org/groups.js | 9 +++ ui/core/app/routes/orgs/org/roles/index.js | 2 +- .../app/templates/orgs/org/groups/index.hbs | 60 ++++++++++++++++++- ui/core/mirage/config.js | 7 +++ ui/core/mirage/factories/group.js | 3 + ui/core/mirage/generated/factories/group.js | 16 +++++ ui/core/mirage/scenarios/default.js | 2 + ui/core/mirage/serializers/group.js | 5 ++ ui/core/translations/en-us.yaml | 2 + 12 files changed, 131 insertions(+), 2 deletions(-) create mode 100644 addons/api/addon/adapters/group.js create mode 100644 addons/api/app/adapters/group.js create mode 100644 addons/api/tests/unit/adapters/group-test.js create mode 100644 ui/core/mirage/factories/group.js create mode 100644 ui/core/mirage/generated/factories/group.js create mode 100644 ui/core/mirage/serializers/group.js diff --git a/addons/api/addon/adapters/group.js b/addons/api/addon/adapters/group.js new file mode 100644 index 000000000..b077634f4 --- /dev/null +++ b/addons/api/addon/adapters/group.js @@ -0,0 +1,14 @@ +import ApplicationAdapter from './application'; +import ScopeAdapterMixin from '../mixins/scope-adapter'; + +export default class GroupAdapter extends ApplicationAdapter.extend( + ScopeAdapterMixin +) { + // =attributes + + /** + * Group is scoped to org only, for now. + * @type {boolean} + */ + includeProject = false; +} diff --git a/addons/api/app/adapters/group.js b/addons/api/app/adapters/group.js new file mode 100644 index 000000000..bb77ff26c --- /dev/null +++ b/addons/api/app/adapters/group.js @@ -0,0 +1 @@ +export { default } from 'api/adapters/group'; diff --git a/addons/api/tests/unit/adapters/group-test.js b/addons/api/tests/unit/adapters/group-test.js new file mode 100644 index 000000000..d39297843 --- /dev/null +++ b/addons/api/tests/unit/adapters/group-test.js @@ -0,0 +1,12 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Adapter | group', function(hooks) { + setupTest(hooks); + + // Replace this with your real tests. + test('it exists', function(assert) { + let adapter = this.owner.lookup('adapter:group'); + assert.ok(adapter); + }); +}); diff --git a/ui/core/app/routes/orgs/org/groups.js b/ui/core/app/routes/orgs/org/groups.js index 1defe3d01..c17d210d1 100644 --- a/ui/core/app/routes/orgs/org/groups.js +++ b/ui/core/app/routes/orgs/org/groups.js @@ -1,4 +1,13 @@ import Route from '@ember/routing/route'; export default class OrgsOrgGroupsRoute extends Route { + // =methods + + /** + * Returns all roles from store. + * @return {Promise[RoleModel]} + */ + model() { + return this.store.findAll('group'); + } } diff --git a/ui/core/app/routes/orgs/org/roles/index.js b/ui/core/app/routes/orgs/org/roles/index.js index 89b868927..92a715a56 100644 --- a/ui/core/app/routes/orgs/org/roles/index.js +++ b/ui/core/app/routes/orgs/org/roles/index.js @@ -1,3 +1,3 @@ import Route from '@ember/routing/route'; -export default class OrgsOrgRolesIndexRoute extends Route { } +export default class OrgsOrgRolesIndexRoute extends Route {} diff --git a/ui/core/app/templates/orgs/org/groups/index.hbs b/ui/core/app/templates/orgs/org/groups/index.hbs index e2147cab0..c56fcb134 100644 --- a/ui/core/app/templates/orgs/org/groups/index.hbs +++ b/ui/core/app/templates/orgs/org/groups/index.hbs @@ -1 +1,59 @@ -{{outlet}} \ No newline at end of file + + + +

{{t "resources.groups"}}

+
+ + + {{#if @model}} + {{t 'titles.new'}} + {{/if}} + + + + + {{#if @model}} + + + + + {{t 'form.label.name'}} + {{t 'form.label.description'}} + + + + {{#each @model as |group|}} + + + + {{group.name}} + + + {{group.description}} + + {{/each}} + + + + {{else}} + + + + + {{t 'descriptions.groups-welcome'}} + + + + {{t 'titles.new'}} + + + + + {{/if}} + + + +
diff --git a/ui/core/mirage/config.js b/ui/core/mirage/config.js index 8a3e0f49c..0805efcea 100644 --- a/ui/core/mirage/config.js +++ b/ui/core/mirage/config.js @@ -47,6 +47,13 @@ export default function() { this.patch('/orgs/:org_id/roles/:id'); this.del('/orgs/:org_id/roles/:id'); + // group + this.get('/orgs/:org_id/groups'); + this.post('/orgs/:org_id/groups'); + this.get('/orgs/:org_id/groups/:id'); + this.patch('/orgs/:org_id/groups/:id'); + this.del('/orgs/:org_id/groups/:id'); + // Other resources // host-catalog diff --git a/ui/core/mirage/factories/group.js b/ui/core/mirage/factories/group.js new file mode 100644 index 000000000..e5f474099 --- /dev/null +++ b/ui/core/mirage/factories/group.js @@ -0,0 +1,3 @@ +import factory from '../generated/factories/group'; + +export default factory.extend(); diff --git a/ui/core/mirage/generated/factories/group.js b/ui/core/mirage/generated/factories/group.js new file mode 100644 index 000000000..7c78ee7ec --- /dev/null +++ b/ui/core/mirage/generated/factories/group.js @@ -0,0 +1,16 @@ +import { Factory } from 'ember-cli-mirage'; +import { random, date } from 'faker'; + +/** + * GeneratedGroupModelFactory + * Group contains all fields related to a Group resource + */ +export default Factory.extend({ + + name: () => random.words(), + description: () => random.words(), + created_time: () => date.recent(), + updated_time: () => date.recent(), + disabled: () => random.boolean(), + +}); diff --git a/ui/core/mirage/scenarios/default.js b/ui/core/mirage/scenarios/default.js index ef06c6ee4..904f43936 100644 --- a/ui/core/mirage/scenarios/default.js +++ b/ui/core/mirage/scenarios/default.js @@ -15,6 +15,8 @@ export default function(server) { // IAM // Roles server.createList('role', 5); + // Groups + server.createList('group', 5); // Other resources diff --git a/ui/core/mirage/serializers/group.js b/ui/core/mirage/serializers/group.js new file mode 100644 index 000000000..13ec42167 --- /dev/null +++ b/ui/core/mirage/serializers/group.js @@ -0,0 +1,5 @@ +import ApplicationSerializer from './application'; + +export default ApplicationSerializer.extend({ + modelName: 'group' +}); diff --git a/ui/core/translations/en-us.yaml b/ui/core/translations/en-us.yaml index 21882f489..2498e9983 100644 --- a/ui/core/translations/en-us.yaml +++ b/ui/core/translations/en-us.yaml @@ -23,12 +23,14 @@ titles: projects-welcome: Welcome to Projects host-catalogs-welcome: Welcome to Host Catalogs roles-welcome: Welcome to Roles + groups-welcome: Welcome to Groups 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. projects-welcome: Projects allow you to create and manage host catalogs. To start, create a project. host-catalogs-welcome: Host catalogs allow you to configure to collect and create hosts and host sets. To start, create a host catalog. roles-welcome: Roles are collections of capabilities that can be granted to user and/or groups. + groups-welcome: Groups are collections of users. states: info: Info success: Success