diff --git a/addons/core/translations/resources/en-us.yaml b/addons/core/translations/resources/en-us.yaml index 74fd773ad..8ec4ff544 100644 --- a/addons/core/translations/resources/en-us.yaml +++ b/addons/core/translations/resources/en-us.yaml @@ -193,6 +193,8 @@ org: title: Welcome to Orgs settings: title: Org Settings + titles: + new: New Org actions: delete: Delete Org project: @@ -204,6 +206,8 @@ project: title: Welcome to Projects settings: title: Project Settings + titles: + new: New Project actions: delete: Delete Project user: diff --git a/ui/admin/app/controllers/scopes/scope/scopes/new.js b/ui/admin/app/controllers/scopes/scope/scopes/new.js new file mode 100644 index 000000000..f5e1343d9 --- /dev/null +++ b/ui/admin/app/controllers/scopes/scope/scopes/new.js @@ -0,0 +1,27 @@ +import Controller from '@ember/controller'; +import { inject as service } from '@ember/service'; +import { computed } from '@ember/object'; + +export default class ScopesScopeScopesNewController extends Controller { + // =services + + @service intl; + + // =attributes + + /** + * @type {string} + */ + @computed('intl', 'model.{currentScope,isOrg,isProject}') + get breadCrumb() { + if (this.model.isOrg) { + return this.intl.t('resources.org.titles.new'); + } + /* istanbul ignore else */ + if (this.model.isProject) { + return this.intl.t('resources.project.titles.new'); + } + /* istanbul ignore next */ + return null; + } +} diff --git a/ui/admin/app/router.js b/ui/admin/app/router.js index 3e158c4f4..b3865f84b 100644 --- a/ui/admin/app/router.js +++ b/ui/admin/app/router.js @@ -18,9 +18,10 @@ Router.map(function () { }); }); - this.route('scopes', function () {}); + this.route('scopes', function () { + this.route('new'); + }); this.route('edit'); - this.route('new'); this.route('users', function () { this.route('user', { path: ':user_id' }, function () { diff --git a/ui/admin/app/routes/onboarding/quick-setup/choose-path.js b/ui/admin/app/routes/onboarding/quick-setup/choose-path.js index 9e8a9397a..f953c18e0 100644 --- a/ui/admin/app/routes/onboarding/quick-setup/choose-path.js +++ b/ui/admin/app/routes/onboarding/quick-setup/choose-path.js @@ -17,7 +17,7 @@ export default class OnboardingQuickSetupChoosePathRoute extends Route { break; case 'manual': default: - this.router.transitionTo('scopes.scope.new', 'global'); + this.router.transitionTo('scopes.scope.scopes.new', 'global'); break; } } diff --git a/ui/admin/app/routes/scopes/scope.js b/ui/admin/app/routes/scopes/scope.js index c92df4829..bcca939b1 100644 --- a/ui/admin/app/routes/scopes/scope.js +++ b/ui/admin/app/routes/scopes/scope.js @@ -2,6 +2,7 @@ import Route from '@ember/routing/route'; import { inject as service } from '@ember/service'; import { A } from '@ember/array'; import { action } from '@ember/object'; +import { next } from '@ember/runloop'; import { loading } from 'ember-loading'; import { confirm } from 'core/decorators/confirm'; import { notifySuccess, notifyError } from 'core/decorators/notify'; @@ -105,8 +106,10 @@ export default class ScopesScopeRoute extends Route { @action cancel(scope) { const { isNew } = scope; - scope.rollbackAttributes(); - if (isNew) this.router.transitionTo('scopes.scope'); + next(() => { + scope.rollbackAttributes(); + if (isNew) this.router.transitionTo('scopes.scope'); + }); } /** diff --git a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets.js b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets.js index 16cec5477..a6f73a431 100644 --- a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets.js +++ b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets.js @@ -24,7 +24,7 @@ export default class ScopesScopeHostCatalogsHostCatalogHostSetsRoute extends Rou 'scopes.scope.host-catalogs.host-catalog' ); const { id: host_catalog_id } = hostCatalog; - let hostSets + let hostSets; if ( this.can.can('list model', hostCatalog, { @@ -36,8 +36,8 @@ export default class ScopesScopeHostCatalogsHostCatalogHostSetsRoute extends Rou return { hostCatalog, - hostSets - } + hostSets, + }; } // =actions diff --git a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/hosts.js b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/hosts.js index d00d32627..a7a4cf1ca 100644 --- a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/hosts.js +++ b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/hosts.js @@ -37,7 +37,7 @@ export default class ScopesScopeHostCatalogsHostCatalogHostsRoute extends Route return { hostCatalog, hosts, - } + }; } // =actions diff --git a/ui/admin/app/routes/scopes/scope/new.js b/ui/admin/app/routes/scopes/scope/scopes/new.js similarity index 93% rename from ui/admin/app/routes/scopes/scope/new.js rename to ui/admin/app/routes/scopes/scope/scopes/new.js index c5de307ba..163482862 100644 --- a/ui/admin/app/routes/scopes/scope/new.js +++ b/ui/admin/app/routes/scopes/scope/scopes/new.js @@ -1,7 +1,7 @@ import Route from '@ember/routing/route'; import { inject as service } from '@ember/service'; -export default class ScopesScopeNewRoute extends Route { +export default class ScopesScopeScopesNewRoute extends Route { // =services @service session; diff --git a/ui/admin/app/templates/scopes/scope/new.hbs b/ui/admin/app/templates/scopes/scope/new.hbs deleted file mode 100644 index ead78ec21..000000000 --- a/ui/admin/app/templates/scopes/scope/new.hbs +++ /dev/null @@ -1,27 +0,0 @@ -{{page-title (t 'titles.new')}} - - - - - - - - -

- {{t 'titles.new'}} - -

-
- - - - - -
\ No newline at end of file diff --git a/ui/admin/app/templates/scopes/scope/scopes/index.hbs b/ui/admin/app/templates/scopes/scope/scopes/index.hbs index 5c2546baf..da0614977 100644 --- a/ui/admin/app/templates/scopes/scope/scopes/index.hbs +++ b/ui/admin/app/templates/scopes/scope/scopes/index.hbs @@ -13,8 +13,7 @@ {{#if @model.subScopes}}

{{t 'resources.org.description'}}

{{/if}} - {{/if}} - {{#if @model.currentScope.isOrg}} + {{else if @model.currentScope.isOrg}}

{{t 'resources.project.title_plural'}} @@ -28,8 +27,12 @@ {{#if (can 'create model' @model.currentScope collection='scopes')}} {{#if @model.subScopes}} - - {{t 'titles.new'}} + + {{#if @model.currentScope.isGlobal}} + {{t 'resources.org.titles.new'}} + {{else if @model.currentScope.isOrg}} + {{t 'resources.project.titles.new'}} + {{/if}} {{/if}} {{/if}} @@ -68,7 +71,7 @@ {{t 'resources.org.description'}} {{#if (can 'create model' @model.currentScope collection='scopes')}} - + {{t 'titles.new'}} @@ -87,7 +90,7 @@ {{t 'resources.project.description'}} {{#if (can 'create model' @model.currentScope collection='scopes')}} - + {{t 'titles.new'}} diff --git a/ui/admin/app/templates/scopes/scope/scopes/new.hbs b/ui/admin/app/templates/scopes/scope/scopes/new.hbs new file mode 100644 index 000000000..cc045162c --- /dev/null +++ b/ui/admin/app/templates/scopes/scope/scopes/new.hbs @@ -0,0 +1,33 @@ +{{page-title (t 'titles.new')}} + + + + + + + + + {{#if @model.isOrg}} +

+ {{t 'resources.org.titles.new'}} + +

+

{{t 'resources.org.description'}}

+ {{else if @model.isProject}} +

+ {{t 'resources.project.titles.new'}} + +

+

{{t 'resources.project.description'}}

+ {{/if}} +
+ + + + + +
\ No newline at end of file diff --git a/ui/admin/tests/acceptance/authentication-test.js b/ui/admin/tests/acceptance/authentication-test.js index 130a40d84..af3be277b 100644 --- a/ui/admin/tests/acceptance/authentication-test.js +++ b/ui/admin/tests/acceptance/authentication-test.js @@ -95,7 +95,7 @@ module('Acceptance | authentication', function (hooks) { changePasswordURL = `/account/change-password`; orgsURL = `/scopes/global/scopes`; orgEditURL = `/scopes/${orgScopeID}/edit`; - newProjectURL = `/scopes/${orgScopeID}/new`; + newProjectURL = `/scopes/${orgScopeID}/scopes/new`; projectsURL = `/scopes/${orgScopeID}/scopes`; usersURL = `/scopes/${orgScopeID}/users`; groupsURL = `/scopes/${orgScopeID}/groups`; diff --git a/ui/admin/tests/acceptance/onboarding/choose-path-test.js b/ui/admin/tests/acceptance/onboarding/choose-path-test.js index 81cb43e5d..7c4226850 100644 --- a/ui/admin/tests/acceptance/onboarding/choose-path-test.js +++ b/ui/admin/tests/acceptance/onboarding/choose-path-test.js @@ -10,7 +10,7 @@ module('Acceptance | onboarding | choose-path', function (hooks) { const urls = { choosePath: '/onboarding/quick-setup/choose-path', - newOrg: '/scopes/global/new', + newOrg: '/scopes/global/scopes/new', createResources: '/onboarding/quick-setup/create-resources', }; diff --git a/ui/admin/tests/acceptance/scopes-test.js b/ui/admin/tests/acceptance/scopes-test.js index 7c38f8b2b..009562e41 100644 --- a/ui/admin/tests/acceptance/scopes-test.js +++ b/ui/admin/tests/acceptance/scopes-test.js @@ -59,12 +59,12 @@ module('Acceptance | scopes', function (hooks) { }); // Generate route URLs for resources urls.globalScope = `/scopes/global/scopes`; - urls.newOrgScope = `/scopes/global/new`; + urls.newOrgScope = `/scopes/global/scopes/new`; urls.orgScope = `/scopes/${instances.scopes.org.id}/scopes`; urls.org2Scope = `/scopes/${instances.scopes.org2.id}/scopes`; urls.orgScopeEdit = `/scopes/${instances.scopes.org.id}/edit`; urls.org2ScopeEdit = `/scopes/${instances.scopes.org2.id}/edit`; - urls.newProjectScope = `/scopes/${instances.scopes.org.id}/new`; + urls.newProjectScope = `/scopes/${instances.scopes.org.id}/scopes/new`; urls.projectScope = `/scopes/${instances.scopes.project.id}`; urls.project2Scope = `/scopes/${instances.scopes.project2.id}`; urls.projectScopeEdit = `/scopes/${instances.scopes.project.id}/edit`; diff --git a/ui/admin/tests/unit/controllers/scopes/scope/scopes/new-test.js b/ui/admin/tests/unit/controllers/scopes/scope/scopes/new-test.js new file mode 100644 index 000000000..4742088b8 --- /dev/null +++ b/ui/admin/tests/unit/controllers/scopes/scope/scopes/new-test.js @@ -0,0 +1,12 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Controller | scopes/scope/scopes/new', function (hooks) { + setupTest(hooks); + + // TODO: Replace this with your real tests. + test('it exists', function (assert) { + let controller = this.owner.lookup('controller:scopes/scope/scopes/new'); + assert.ok(controller); + }); +}); diff --git a/ui/admin/tests/unit/routes/scopes/scope/new-test.js b/ui/admin/tests/unit/routes/scopes/scope/scopes/new-test.js similarity index 55% rename from ui/admin/tests/unit/routes/scopes/scope/new-test.js rename to ui/admin/tests/unit/routes/scopes/scope/scopes/new-test.js index b765958b4..7451b7ec1 100644 --- a/ui/admin/tests/unit/routes/scopes/scope/new-test.js +++ b/ui/admin/tests/unit/routes/scopes/scope/scopes/new-test.js @@ -1,11 +1,11 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -module('Unit | Route | scopes/scope/new', function (hooks) { +module('Unit | Route | scopes/scope/scopes/new', function (hooks) { setupTest(hooks); test('it exists', function (assert) { - let route = this.owner.lookup('route:scopes/scope/new'); + let route = this.owner.lookup('route:scopes/scope/scopes/new'); assert.ok(route); }); });