chore: 🤖 improve scopes/new titling - icu-6714 (#1407)

* chore: 🤖 improve scopes/new titling - icu-6714

✅ Closes: icu-6714

* chore: 🤖 improve new scope link text
This commit is contained in:
Randall Morey authored and GitHub committed 2022-11-03 18:37:42 -07:00
1 parent e8af948dc1
commit d32a854a94
16 files changed
+105 -49

No files matched your search

@@ -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;
}
}
+3 -2
View File
@@ -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 () {
@@ -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;
}
}
+5 -2
View File
@@ -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');
});
}
/**
@@ -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
@@ -37,7 +37,7 @@ export default class ScopesScopeHostCatalogsHostCatalogHostsRoute extends Route
return {
hostCatalog,
hosts,
}
};
}
// =actions
@@ -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;
@@ -1,27 +0,0 @@
{{page-title (t 'titles.new')}}
<Rose::Layout::Page as |page|>
<page.breadcrumbs>
<BreadCrumbs />
</page.breadcrumbs>
<page.header>
<h2>
{{t 'titles.new'}}
<DocLink
@doc={{if @model.isOrg 'org.new' 'project.new'}}
@iconSize='large'
/>
</h2>
</page.header>
<page.body>
<Form::Scope
@model={{@model}}
@submit={{route-action 'save' @model}}
@cancel={{route-action 'cancel' @model}}
/>
</page.body>
</Rose::Layout::Page>
@@ -13,8 +13,7 @@
{{#if @model.subScopes}}
<p>{{t 'resources.org.description'}}</p>
{{/if}}
{{/if}}
{{#if @model.currentScope.isOrg}}
{{else if @model.currentScope.isOrg}}
<h2>
{{t 'resources.project.title_plural'}}
<DocLink @doc='project' @iconSize='large' />
@@ -28,8 +27,12 @@
<page.actions>
{{#if (can 'create model' @model.currentScope collection='scopes')}}
{{#if @model.subScopes}}
<Rose::LinkButton @route='scopes.scope.new' @style='primary'>
{{t 'titles.new'}}
<Rose::LinkButton @route='scopes.scope.scopes.new' @style='primary'>
{{#if @model.currentScope.isGlobal}}
{{t 'resources.org.titles.new'}}
{{else if @model.currentScope.isOrg}}
{{t 'resources.project.titles.new'}}
{{/if}}
</Rose::LinkButton>
{{/if}}
{{/if}}
@@ -68,7 +71,7 @@
{{t 'resources.org.description'}}
</message.description>
{{#if (can 'create model' @model.currentScope collection='scopes')}}
<message.link @route='scopes.scope.new'>
<message.link @route='scopes.scope.scopes.new'>
<Rose::Icon @name='flight-icons/svg/plus-circle-16' />
{{t 'titles.new'}}
</message.link>
@@ -87,7 +90,7 @@
{{t 'resources.project.description'}}
</message.description>
{{#if (can 'create model' @model.currentScope collection='scopes')}}
<message.link @route='scopes.scope.new'>
<message.link @route='scopes.scope.scopes.new'>
<Rose::Icon @name='flight-icons/svg/plus-circle-16' />
{{t 'titles.new'}}
</message.link>
@@ -0,0 +1,33 @@
{{page-title (t 'titles.new')}}
<Rose::Layout::Page as |page|>
<page.breadcrumbs>
<BreadCrumbs />
</page.breadcrumbs>
<page.header>
{{#if @model.isOrg}}
<h2>
{{t 'resources.org.titles.new'}}
<DocLink @doc='org.new' @iconSize='large' />
</h2>
<p>{{t 'resources.org.description'}}</p>
{{else if @model.isProject}}
<h2>
{{t 'resources.project.titles.new'}}
<DocLink @doc='project.new' @iconSize='large' />
</h2>
<p>{{t 'resources.project.description'}}</p>
{{/if}}
</page.header>
<page.body>
<Form::Scope
@model={{@model}}
@submit={{route-action 'save' @model}}
@cancel={{route-action 'cancel' @model}}
/>
</page.body>
</Rose::Layout::Page>