mirror of https://github.com/rancher/ui.git
Fix app launch double click & no errors
rancher/rancher#19168 rancher/rancher#19236
This commit is contained in:
parent
018f3c20d1
commit
3316235ee4
|
|
@ -14,8 +14,9 @@ import { isEmpty } from '@ember/utils';
|
||||||
import CatalogApp from 'shared/mixins/catalog-app';
|
import CatalogApp from 'shared/mixins/catalog-app';
|
||||||
import { isNumeric } from 'shared/utils/util';
|
import { isNumeric } from 'shared/utils/util';
|
||||||
import convertDotAnswersToYaml from 'shared/utils/convert-yaml';
|
import convertDotAnswersToYaml from 'shared/utils/convert-yaml';
|
||||||
|
import ChildHook from 'shared/mixins/child-hook';
|
||||||
|
|
||||||
export default Component.extend(NewOrEdit, CatalogApp, {
|
export default Component.extend(NewOrEdit, CatalogApp, ChildHook, {
|
||||||
catalog: service(),
|
catalog: service(),
|
||||||
intl: service(),
|
intl: service(),
|
||||||
scope: service(),
|
scope: service(),
|
||||||
|
|
@ -319,7 +320,11 @@ export default Component.extend(NewOrEdit, CatalogApp, {
|
||||||
set(get(this, 'catalogApp'), 'answers', get(this, 'answers'));
|
set(get(this, 'catalogApp'), 'answers', get(this, 'answers'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return this.applyHooks('_beforeSaveHooks').catch((err) => {
|
||||||
|
set(this, 'errors', [err.message]);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
// TODO 2.0 this is part of the volumes stuff so we need to investigate if this still works
|
// TODO 2.0 this is part of the volumes stuff so we need to investigate if this still works
|
||||||
// let versionId = null;
|
// let versionId = null;
|
||||||
|
|
|
||||||
|
|
@ -111,30 +111,20 @@
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
|
||||||
{{#unless (or customizeNamespace (not selectedTemplateModel))}}
|
|
||||||
<div class="col span-12">
|
|
||||||
{{t
|
|
||||||
"newCatalog.customizeNamespace"
|
|
||||||
namespaceId=(if requiredNamespace requiredNamespace primaryResource.name)
|
|
||||||
htmlSafe=true
|
|
||||||
}}
|
|
||||||
{{#unless (or editing requiredNamespace)}}
|
|
||||||
<button class="btn btn-sm bg-transparent pl-0" {{action "toogleNamespace"}}>
|
|
||||||
{{t "generic.customize"}}
|
|
||||||
</button>
|
|
||||||
{{/unless}}
|
|
||||||
</div>
|
|
||||||
{{/unless}}
|
|
||||||
<div class="col span-12">
|
|
||||||
{{#if customizeNamespace}}
|
|
||||||
<hr class="mt-20 mb-20"/>
|
|
||||||
|
|
||||||
|
<div class="over-hr">
|
||||||
|
<span>
|
||||||
|
{{t "generic.namespace"}}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col span-12">
|
||||||
{{form-namespace
|
{{form-namespace
|
||||||
namespace=primaryResource
|
namespace=primaryResource
|
||||||
errors=namespaceErrors
|
errors=namespaceErrors
|
||||||
|
registerHook=(action "registerHook")
|
||||||
}}
|
}}
|
||||||
{{/if}}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -244,15 +234,7 @@
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if errors.length}}
|
|
||||||
<section>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col span-12">
|
|
||||||
{{top-errors errors=errors}}
|
{{top-errors errors=errors}}
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
<div class="footer-actions">
|
<div class="footer-actions">
|
||||||
{{save-cancel
|
{{save-cancel
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,18 @@ export default Component.extend({
|
||||||
isReuse: equal('mode', REUSE),
|
isReuse: equal('mode', REUSE),
|
||||||
init() {
|
init() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
set(this, 'choices', get(this, 'clusterStore').all('namespace').filterBy('projectId', get(this, 'scope.currentProject.id')).sortBy('displayName'));
|
|
||||||
|
if (this.registerHook) {
|
||||||
|
this.registerHook(this.saveNamespace.bind(this), {
|
||||||
|
name: get(this, 'hookName'),
|
||||||
|
key: '_beforeSaveHooks'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const currentProjectsNamespaces = get(this, 'clusterStore').all('namespace').filterBy('projectId', get(this, 'scope.currentProject.id'));
|
||||||
|
|
||||||
|
set(this, 'choices', currentProjectsNamespaces).sortBy('displayName');
|
||||||
|
|
||||||
let all = get(this, 'choices');
|
let all = get(this, 'choices');
|
||||||
|
|
||||||
set(this, 'createNamespace', get(this, 'clusterStore').createRecord({
|
set(this, 'createNamespace', get(this, 'clusterStore').createRecord({
|
||||||
|
|
@ -46,8 +57,6 @@ export default Component.extend({
|
||||||
containerDefaultResourceLimit: get(this, 'scope.currentProject.containerDefaultResourceLimit'),
|
containerDefaultResourceLimit: get(this, 'scope.currentProject.containerDefaultResourceLimit'),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// TODO
|
|
||||||
// Find a namespace
|
|
||||||
if ( get(this, 'mode') === REUSE ) {
|
if ( get(this, 'mode') === REUSE ) {
|
||||||
let namespace = get(this, 'namespace') || // Passed in
|
let namespace = get(this, 'namespace') || // Passed in
|
||||||
all.findBy('isDefault', true) || // The default one
|
all.findBy('isDefault', true) || // The default one
|
||||||
|
|
@ -70,13 +79,6 @@ export default Component.extend({
|
||||||
this.updateNamespace();
|
this.updateNamespace();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.registerHook) {
|
|
||||||
this.registerHook(this.saveNamespace.bind(this), {
|
|
||||||
name: get(this, 'hookName'),
|
|
||||||
key: '_beforeSaveHooks'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,9 @@
|
||||||
{{field-required}}
|
{{field-required}}
|
||||||
</label>
|
</label>
|
||||||
<div class="pull-right text-small">
|
<div class="pull-right text-small">
|
||||||
<a role="button" class="btn bg-transparent p-0" {{action "toggle"}}>{{t (if isReuse 'formNamespace.toggle.create' 'formNamespace.toggle.reuse')}}</a>
|
<a role="button" class="btn bg-transparent p-0" {{action "toggle"}}>
|
||||||
|
{{t (if isReuse "formNamespace.toggle.create" "formNamespace.toggle.reuse")}}
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -13,16 +15,24 @@
|
||||||
{{#if isReuse}}
|
{{#if isReuse}}
|
||||||
{{new-select
|
{{new-select
|
||||||
content=choices
|
content=choices
|
||||||
prompt=(t 'formNamespace.reuse.prompt')
|
prompt=(t "formNamespace.reuse.prompt")
|
||||||
optionLabelPath="displayName"
|
optionLabelPath="displayName"
|
||||||
optionValuePath="id"
|
optionValuePath="id"
|
||||||
value=reuseNamespaceId
|
value=reuseNamespaceId
|
||||||
}}
|
}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{input classNames="new-name" placeholder=(t 'formNamespace.create.placeholder') value=createNamespace.name}}
|
{{input
|
||||||
|
classNames="new-name"
|
||||||
|
placeholder=(t "formNamespace.create.placeholder")
|
||||||
|
value=createNamespace.name
|
||||||
|
}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
{{else}}
|
{{else}}
|
||||||
<label class="acc-label pb-5">{{t 'formNamespace.label.reuse'}}</label>
|
<label class="acc-label pb-5">
|
||||||
<p class="mt-0">{{namespace.displayName}}</p>
|
{{t "formNamespace.label.reuse"}}
|
||||||
|
</label>
|
||||||
|
<p class="mt-0">
|
||||||
|
{{namespace.displayName}}
|
||||||
|
</p>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue