From aa867f54d8df803b0068e0d8541f2327302842af Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Fri, 14 Aug 2020 17:40:31 -0400 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20implement=20initial=20or?= =?UTF-8?q?gs=20routes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/core/app/controllers/scopes/scope/orgs.js | 17 ++++++ .../app/controllers/scopes/scope/orgs/new.js | 17 ++++++ ui/core/app/router.js | 37 +++++++----- ui/core/app/routes/scopes/scope/orgs.js | 15 +++++ ui/core/app/routes/scopes/scope/orgs/index.js | 4 ++ ui/core/app/routes/scopes/scope/orgs/new.js | 18 ++++++ ui/core/app/templates/scopes/scope/orgs.hbs | 3 + .../app/templates/scopes/scope/orgs/index.hbs | 56 +++++++++++++++++++ .../app/templates/scopes/scope/orgs/new.hbs | 17 ++++++ .../controllers/scopes/scope/orgs-test.js | 12 ++++ .../controllers/scopes/scope/orgs/new-test.js | 12 ++++ .../unit/routes/scopes/scope/orgs-test.js | 11 ++++ .../routes/scopes/scope/orgs/index-test.js | 11 ++++ .../unit/routes/scopes/scope/orgs/new-test.js | 11 ++++ ui/core/translations/en-us.yaml | 2 + 15 files changed, 230 insertions(+), 13 deletions(-) create mode 100644 ui/core/app/controllers/scopes/scope/orgs.js create mode 100644 ui/core/app/controllers/scopes/scope/orgs/new.js create mode 100644 ui/core/app/routes/scopes/scope/orgs.js create mode 100644 ui/core/app/routes/scopes/scope/orgs/index.js create mode 100644 ui/core/app/routes/scopes/scope/orgs/new.js create mode 100644 ui/core/app/templates/scopes/scope/orgs.hbs create mode 100644 ui/core/app/templates/scopes/scope/orgs/index.hbs create mode 100644 ui/core/app/templates/scopes/scope/orgs/new.hbs create mode 100644 ui/core/tests/unit/controllers/scopes/scope/orgs-test.js create mode 100644 ui/core/tests/unit/controllers/scopes/scope/orgs/new-test.js create mode 100644 ui/core/tests/unit/routes/scopes/scope/orgs-test.js create mode 100644 ui/core/tests/unit/routes/scopes/scope/orgs/index-test.js create mode 100644 ui/core/tests/unit/routes/scopes/scope/orgs/new-test.js diff --git a/ui/core/app/controllers/scopes/scope/orgs.js b/ui/core/app/controllers/scopes/scope/orgs.js new file mode 100644 index 000000000..9e553d5a3 --- /dev/null +++ b/ui/core/app/controllers/scopes/scope/orgs.js @@ -0,0 +1,17 @@ +import Controller from '@ember/controller'; +import { inject as service } from '@ember/service'; + +export default class ScopesScopeOrgsController extends Controller { + // =services + + @service intl; + + // =attributes + + /** + * @type {string} + */ + get breadCrumb() { + return this.intl.t('resources.orgs'); + } +} diff --git a/ui/core/app/controllers/scopes/scope/orgs/new.js b/ui/core/app/controllers/scopes/scope/orgs/new.js new file mode 100644 index 000000000..d41b81a96 --- /dev/null +++ b/ui/core/app/controllers/scopes/scope/orgs/new.js @@ -0,0 +1,17 @@ +import Controller from '@ember/controller'; +import { inject as service } from '@ember/service'; + +export default class ScopesScopeOrgsNewController extends Controller { + // =services + + @service intl; + + // =attributes + + /** + * @type {string} + */ + get breadCrumb() { + return this.intl.t('titles.new'); + } +} diff --git a/ui/core/app/router.js b/ui/core/app/router.js index cf5cea5d6..4521a8b75 100644 --- a/ui/core/app/router.js +++ b/ui/core/app/router.js @@ -9,24 +9,15 @@ export default class Router extends EmberRouter { Router.map(function () { this.route('scopes', function () { this.route('scope', { path: ':scope_id' }, function () { + this.route('authenticate', function () { this.route('method', { path: ':auth_method_id' }); }); - this.route('users', function () { - this.route('user', { path: ':user_id' }, function () {}); - this.route('new'); - }); - this.route('groups', function () { - this.route('group', { path: ':group_id' }, function () {}); - this.route('new'); - }); - this.route('roles', function () { - this.route('role', { path: ':role_id' }, function () { - this.route('grants'); - this.route('principals'); - }); + + this.route('orgs', function() { this.route('new'); }); + this.route('projects', function() { this.route('project', { path: ':project_id' }, function() { this.route('host-catalogs', function() { @@ -36,7 +27,27 @@ Router.map(function () { }); this.route('new'); }); + + this.route('users', function () { + this.route('user', { path: ':user_id' }, function () {}); + this.route('new'); + }); + + this.route('groups', function () { + this.route('group', { path: ':group_id' }, function () {}); + this.route('new'); + }); + + this.route('roles', function () { + this.route('role', { path: ':role_id' }, function () { + this.route('grants'); + this.route('principals'); + }); + this.route('new'); + }); + this.route('auth-methods', function() {}); + }); }); }); diff --git a/ui/core/app/routes/scopes/scope/orgs.js b/ui/core/app/routes/scopes/scope/orgs.js new file mode 100644 index 000000000..e8b0375b9 --- /dev/null +++ b/ui/core/app/routes/scopes/scope/orgs.js @@ -0,0 +1,15 @@ +import Route from '@ember/routing/route'; + +export default class ScopesScopeOrgsRoute extends Route { + + // =methods + + /** + * Loads all scopes under the global scope. + * @return {Promise{[ScopeModel]}} + */ + async model() { + return this.store.query('scope', { scope_id: 'global' }); + } + +} diff --git a/ui/core/app/routes/scopes/scope/orgs/index.js b/ui/core/app/routes/scopes/scope/orgs/index.js new file mode 100644 index 000000000..4a344e13a --- /dev/null +++ b/ui/core/app/routes/scopes/scope/orgs/index.js @@ -0,0 +1,4 @@ +import Route from '@ember/routing/route'; + +export default class ScopesScopeOrgsIndexRoute extends Route { +} diff --git a/ui/core/app/routes/scopes/scope/orgs/new.js b/ui/core/app/routes/scopes/scope/orgs/new.js new file mode 100644 index 000000000..0337f2dce --- /dev/null +++ b/ui/core/app/routes/scopes/scope/orgs/new.js @@ -0,0 +1,18 @@ +import Route from '@ember/routing/route'; + +export default class ScopesScopeOrgsNewRoute extends Route { + + // =methods + + /** + * Creates a new unsaved org scope belonging to the global scope. + * @return {ScopeModel} + */ + model() { + return this.store.createRecord('scope', { + type: 'org', + scopeID: 'global', + }); + } + +} diff --git a/ui/core/app/templates/scopes/scope/orgs.hbs b/ui/core/app/templates/scopes/scope/orgs.hbs new file mode 100644 index 000000000..35fbae66b --- /dev/null +++ b/ui/core/app/templates/scopes/scope/orgs.hbs @@ -0,0 +1,3 @@ +{{title (t "resources.orgs")}} + +{{outlet}} diff --git a/ui/core/app/templates/scopes/scope/orgs/index.hbs b/ui/core/app/templates/scopes/scope/orgs/index.hbs new file mode 100644 index 000000000..9abc5722e --- /dev/null +++ b/ui/core/app/templates/scopes/scope/orgs/index.hbs @@ -0,0 +1,56 @@ + + + + + + + +

{{t "resources.orgs"}}

+
+ + + {{#if @model}} + + {{t 'titles.new'}} + + {{/if}} + + + + + {{#if @model}} + + + {{#each @model as |org|}} + + {{/each}} + + + {{else}} + + + + + {{t 'descriptions.orgs-welcome'}} + + + + {{t 'titles.new'}} + + + + + {{/if}} + + + +
diff --git a/ui/core/app/templates/scopes/scope/orgs/new.hbs b/ui/core/app/templates/scopes/scope/orgs/new.hbs new file mode 100644 index 000000000..0e12b352e --- /dev/null +++ b/ui/core/app/templates/scopes/scope/orgs/new.hbs @@ -0,0 +1,17 @@ +{{title (t 'titles.new')}} + + + + + + + + +

{{t "titles.new"}}

+
+ + + + + +
diff --git a/ui/core/tests/unit/controllers/scopes/scope/orgs-test.js b/ui/core/tests/unit/controllers/scopes/scope/orgs-test.js new file mode 100644 index 000000000..f89afd0fc --- /dev/null +++ b/ui/core/tests/unit/controllers/scopes/scope/orgs-test.js @@ -0,0 +1,12 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Controller | scopes/scope/orgs', function(hooks) { + setupTest(hooks); + + // Replace this with your real tests. + test('it exists', function(assert) { + let controller = this.owner.lookup('controller:scopes/scope/orgs'); + assert.ok(controller); + }); +}); diff --git a/ui/core/tests/unit/controllers/scopes/scope/orgs/new-test.js b/ui/core/tests/unit/controllers/scopes/scope/orgs/new-test.js new file mode 100644 index 000000000..c6631a1ab --- /dev/null +++ b/ui/core/tests/unit/controllers/scopes/scope/orgs/new-test.js @@ -0,0 +1,12 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Controller | scopes/scope/orgs/new', function(hooks) { + setupTest(hooks); + + // Replace this with your real tests. + test('it exists', function(assert) { + let controller = this.owner.lookup('controller:scopes/scope/orgs/new'); + assert.ok(controller); + }); +}); diff --git a/ui/core/tests/unit/routes/scopes/scope/orgs-test.js b/ui/core/tests/unit/routes/scopes/scope/orgs-test.js new file mode 100644 index 000000000..4b9d477c3 --- /dev/null +++ b/ui/core/tests/unit/routes/scopes/scope/orgs-test.js @@ -0,0 +1,11 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Route | scopes/scope/orgs', function(hooks) { + setupTest(hooks); + + test('it exists', function(assert) { + let route = this.owner.lookup('route:scopes/scope/orgs'); + assert.ok(route); + }); +}); diff --git a/ui/core/tests/unit/routes/scopes/scope/orgs/index-test.js b/ui/core/tests/unit/routes/scopes/scope/orgs/index-test.js new file mode 100644 index 000000000..c62bbc625 --- /dev/null +++ b/ui/core/tests/unit/routes/scopes/scope/orgs/index-test.js @@ -0,0 +1,11 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Route | scopes/scope/orgs/index', function(hooks) { + setupTest(hooks); + + test('it exists', function(assert) { + let route = this.owner.lookup('route:scopes/scope/orgs/index'); + assert.ok(route); + }); +}); diff --git a/ui/core/tests/unit/routes/scopes/scope/orgs/new-test.js b/ui/core/tests/unit/routes/scopes/scope/orgs/new-test.js new file mode 100644 index 000000000..3cfdb8522 --- /dev/null +++ b/ui/core/tests/unit/routes/scopes/scope/orgs/new-test.js @@ -0,0 +1,11 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Route | scopes/scope/orgs/new', function(hooks) { + setupTest(hooks); + + test('it exists', function(assert) { + let route = this.owner.lookup('route:scopes/scope/orgs/new'); + assert.ok(route); + }); +}); diff --git a/ui/core/translations/en-us.yaml b/ui/core/translations/en-us.yaml index 2fe1ad5f8..c64e37ceb 100644 --- a/ui/core/translations/en-us.yaml +++ b/ui/core/translations/en-us.yaml @@ -27,6 +27,8 @@ resources: roles: Roles group: Group groups: Groups + orgs: Orgs + org: Org projects: Projects project: Project host-catalog: Host Catalog