From 8b55714f2f3b574c9d7f3a2a97d3da98453a264c Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Tue, 23 Jun 2020 15:33:38 -0400 Subject: [PATCH] Add breadcrumbs to users --- ui/core/app/controllers/orgs/org/users.js | 18 +++++++++++ ui/core/app/controllers/orgs/org/users/new.js | 17 +++++++++++ .../app/controllers/orgs/org/users/user.js | 11 +++++++ ui/core/tests/acceptance/bread-crumbs-test.js | 30 +++++++++++++++++++ .../unit/controllers/orgs/org/users-test.js | 12 ++++++++ .../controllers/orgs/org/users/new-test.js | 12 ++++++++ .../controllers/orgs/org/users/user-test.js | 12 ++++++++ 7 files changed, 112 insertions(+) create mode 100644 ui/core/app/controllers/orgs/org/users.js create mode 100644 ui/core/app/controllers/orgs/org/users/new.js create mode 100644 ui/core/app/controllers/orgs/org/users/user.js create mode 100644 ui/core/tests/unit/controllers/orgs/org/users-test.js create mode 100644 ui/core/tests/unit/controllers/orgs/org/users/new-test.js create mode 100644 ui/core/tests/unit/controllers/orgs/org/users/user-test.js diff --git a/ui/core/app/controllers/orgs/org/users.js b/ui/core/app/controllers/orgs/org/users.js new file mode 100644 index 000000000..ae81e0302 --- /dev/null +++ b/ui/core/app/controllers/orgs/org/users.js @@ -0,0 +1,18 @@ +import Controller from '@ember/controller'; +import { inject as service } from '@ember/service'; + +export default class OrgsOrgUsersController extends Controller { + // =services + + @service intl; + + // =attributes + + /** + * @type {string} + */ + get breadCrumb() { + return this.intl.t('resources.users'); + } + +} diff --git a/ui/core/app/controllers/orgs/org/users/new.js b/ui/core/app/controllers/orgs/org/users/new.js new file mode 100644 index 000000000..5e047015a --- /dev/null +++ b/ui/core/app/controllers/orgs/org/users/new.js @@ -0,0 +1,17 @@ +import Controller from '@ember/controller'; +import { inject as service } from '@ember/service'; + +export default class OrgsOrgUsersNewController extends Controller { + // =services + + @service intl; + + // =attributes + + /** + * @type {string} + */ + get breadCrumb() { + return this.intl.t('titles.new'); + } +} diff --git a/ui/core/app/controllers/orgs/org/users/user.js b/ui/core/app/controllers/orgs/org/users/user.js new file mode 100644 index 000000000..7e0216636 --- /dev/null +++ b/ui/core/app/controllers/orgs/org/users/user.js @@ -0,0 +1,11 @@ +import Controller from '@ember/controller'; +import { alias } from '@ember/object/computed'; + +export default class OrgsOrgUsersUserController extends Controller { + // =attributes + + /** + * @type {string} + */ + @alias('model.name') breadCrumb; +} diff --git a/ui/core/tests/acceptance/bread-crumbs-test.js b/ui/core/tests/acceptance/bread-crumbs-test.js index 2b134ae0a..4d2b65f9b 100644 --- a/ui/core/tests/acceptance/bread-crumbs-test.js +++ b/ui/core/tests/acceptance/bread-crumbs-test.js @@ -9,6 +9,7 @@ module('Acceptance | breadcrumbs', function (hooks) { let org; let project; + let user; let hostCatalog; let projectsURL; let newProjectURL; @@ -16,12 +17,17 @@ module('Acceptance | breadcrumbs', function (hooks) { let hostCatalogsURL; let newHostCatalogURL; let hostCatalogURL; + let usersURL; + let newUserURL; + let userURL; let crumbPath; hooks.beforeEach(function () { org = this.server.create('org'); project = this.server.create('project'); + user = this.server.create('user'); + hostCatalog = this.server.create('host-catalog'); projectsURL = `/orgs/${org.id}/projects`; newProjectURL = `${projectsURL}/new`; @@ -29,6 +35,11 @@ module('Acceptance | breadcrumbs', function (hooks) { hostCatalogsURL = `${projectURL}/host-catalogs`; newHostCatalogURL = `${hostCatalogsURL}/new`; hostCatalogURL = `${hostCatalogsURL}/${hostCatalog.id}`; + + // Users + usersURL = `/orgs/${org.id}/users`; + newUserURL = `${usersURL}/${user.id}`; + userURL = `${usersURL}/new`; }); test('can navigate via breadcrumbs to projects from project', async function (assert) { @@ -81,4 +92,23 @@ module('Acceptance | breadcrumbs', function (hooks) { assert.equal(currentURL(), hostCatalogsURL, 'After navigating via breadcrumbs, we are one level up.'); }); + test('can navigate via breadcrumbs to users from user', async function (assert) { + assert.expect(3); + await visit(userURL); + assert.equal(currentURL(), userURL, 'We begin on the expected page.'); + crumbPath = new URL(find('.rose-nav-breadcrumbs-link:last-child').href).pathname; + assert.equal(crumbPath, userURL, 'Last crumb has expected URL.'); + await click(find('.rose-nav-breadcrumbs-link:first-child')); + assert.equal(currentURL(), usersURL, 'After navigating via breadcrumbs, we are one level up.'); + }); + + test('can navigate via breadcrumbs to users from new user', async function (assert) { + assert.expect(3); + await visit(newUserURL); + assert.equal(currentURL(), newUserURL, 'We begin on th expected page.'); + crumbPath = new URL(find('.rose-nav-breadcrumbs-link:last-child').href).pathname; + assert.equal(crumbPath, newUserURL, 'Last crumb has expected URL.'); + await click(find('.rose-nav-breadcrumbs-link:first-child')); + assert.equal(currentURL(), usersURL, 'After navigating via breadcrumbs, we are one level up.'); + }); }); diff --git a/ui/core/tests/unit/controllers/orgs/org/users-test.js b/ui/core/tests/unit/controllers/orgs/org/users-test.js new file mode 100644 index 000000000..c5be2fb52 --- /dev/null +++ b/ui/core/tests/unit/controllers/orgs/org/users-test.js @@ -0,0 +1,12 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Controller | orgs/org/users', function(hooks) { + setupTest(hooks); + + // Replace this with your real tests. + test('it exists', function(assert) { + let controller = this.owner.lookup('controller:orgs/org/users'); + assert.ok(controller); + }); +}); diff --git a/ui/core/tests/unit/controllers/orgs/org/users/new-test.js b/ui/core/tests/unit/controllers/orgs/org/users/new-test.js new file mode 100644 index 000000000..e6925b4d7 --- /dev/null +++ b/ui/core/tests/unit/controllers/orgs/org/users/new-test.js @@ -0,0 +1,12 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Controller | orgs/org/users/new', function(hooks) { + setupTest(hooks); + + // Replace this with your real tests. + test('it exists', function(assert) { + let controller = this.owner.lookup('controller:orgs/org/users/new'); + assert.ok(controller); + }); +}); diff --git a/ui/core/tests/unit/controllers/orgs/org/users/user-test.js b/ui/core/tests/unit/controllers/orgs/org/users/user-test.js new file mode 100644 index 000000000..f35f620fa --- /dev/null +++ b/ui/core/tests/unit/controllers/orgs/org/users/user-test.js @@ -0,0 +1,12 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Controller | orgs/org/users/user', function(hooks) { + setupTest(hooks); + + // Replace this with your real tests. + test('it exists', function(assert) { + let controller = this.owner.lookup('controller:orgs/org/users/user'); + assert.ok(controller); + }); +});