mirror of https://github.com/rancher/ui.git
Fix ingress port validation issue
https://github.com/rancher/rancher/issues/11822
This commit is contained in:
parent
849591c54c
commit
94f98fa526
|
|
@ -1,14 +1,17 @@
|
||||||
import { get, set, observer } from '@ember/object'
|
import { get, set, observer } from '@ember/object'
|
||||||
import Component from '@ember/component';
|
import Component from '@ember/component';
|
||||||
import layout from './template';
|
import layout from './template';
|
||||||
|
import { inject as service } from '@ember/service';
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
layout,
|
layout,
|
||||||
|
intl: service(),
|
||||||
|
|
||||||
ingress: null,
|
ingress: null,
|
||||||
rule: null,
|
rule: null,
|
||||||
checked: null,
|
checked: null,
|
||||||
editing: true,
|
editing: true,
|
||||||
|
errors: null,
|
||||||
|
|
||||||
pathArray: null,
|
pathArray: null,
|
||||||
|
|
||||||
|
|
@ -65,6 +68,23 @@ export default Component.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
validate: observer('pathArray.@each.{path,backendType,targetPort,serviceId}', function () {
|
||||||
|
let intl = this.get('intl');
|
||||||
|
let errors = [];
|
||||||
|
|
||||||
|
const pathArray = get(this, 'pathArray');
|
||||||
|
const invalid = pathArray.some(path => !path.targetPort);
|
||||||
|
if (invalid) {
|
||||||
|
errors.push(intl.t('validation.required', { key: intl.t('generic.port') }));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errors.length) {
|
||||||
|
this.set('errors', errors);
|
||||||
|
} else {
|
||||||
|
this.set('errors', null);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
|
||||||
pathsChanged: observer('pathArray.@each.{path,backendType,targetPort,serviceId}', 'checked', function () {
|
pathsChanged: observer('pathArray.@each.{path,backendType,targetPort,serviceId}', 'checked', function () {
|
||||||
if (get(this, 'checked')) {
|
if (get(this, 'checked')) {
|
||||||
this.setDefaultBackend();
|
this.setDefaultBackend();
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ export default Component.extend({
|
||||||
rules: null,
|
rules: null,
|
||||||
ingress: null,
|
ingress: null,
|
||||||
editing: true,
|
editing: true,
|
||||||
|
errors: null,
|
||||||
defaultBackend: null,
|
defaultBackend: null,
|
||||||
|
|
||||||
checked: false,
|
checked: false,
|
||||||
|
|
|
||||||
|
|
@ -30,5 +30,5 @@
|
||||||
<hr class="mt-20 mb-20" />
|
<hr class="mt-20 mb-20" />
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
|
|
||||||
{{form-ingress-backends ingress=ingress checked=checked rule=rule editing=editing}}
|
{{form-ingress-backends errors=errors ingress=ingress checked=checked rule=rule editing=editing}}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
removeRule=(action 'removeRule')
|
removeRule=(action 'removeRule')
|
||||||
updateDefaultBackend=(action 'updateDefaultBackend')
|
updateDefaultBackend=(action 'updateDefaultBackend')
|
||||||
defaultBackend=defaultBackend
|
defaultBackend=defaultBackend
|
||||||
|
errors=errors
|
||||||
rules=rules
|
rules=rules
|
||||||
rule=rule
|
rule=rule
|
||||||
ingress=ingress
|
ingress=ingress
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ export default Component.extend(NewOrEdit, {
|
||||||
namespacedCertificates: null,
|
namespacedCertificates: null,
|
||||||
certificates: null,
|
certificates: null,
|
||||||
|
|
||||||
ruleErrors: null,
|
ruleBackendErrors: null,
|
||||||
|
|
||||||
primaryResource: alias('ingress'),
|
primaryResource: alias('ingress'),
|
||||||
|
|
||||||
|
|
@ -80,7 +80,7 @@ export default Component.extend(NewOrEdit, {
|
||||||
let pr = get(this, 'primaryResource');
|
let pr = get(this, 'primaryResource');
|
||||||
let errors = pr.validationErrors() || [];
|
let errors = pr.validationErrors() || [];
|
||||||
|
|
||||||
errors.pushObjects(get(this, 'ruleErrors') || []);
|
errors.pushObjects(get(this, 'ruleBackendErrors') || []);
|
||||||
errors.pushObjects(get(this, 'namespaceErrors') || []);
|
errors.pushObjects(get(this, 'namespaceErrors') || []);
|
||||||
|
|
||||||
if (!get(this, 'ingress.rules.length') && !get(this, 'ingress.defaultBackend')) {
|
if (!get(this, 'ingress.rules.length') && !get(this, 'ingress.defaultBackend')) {
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
<section class="mt-40 horizontal-form container-fluid">
|
<section class="mt-40 horizontal-form container-fluid">
|
||||||
{{form-ingress-rule
|
{{form-ingress-rule
|
||||||
ingress=ingress
|
ingress=ingress
|
||||||
errors=ruleErrors
|
errors=ruleBackendErrors
|
||||||
editing=true
|
editing=true
|
||||||
}}
|
}}
|
||||||
<hr class="mt-30 mb-30" />
|
<hr class="mt-30 mb-30" />
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ generic:
|
||||||
none: None
|
none: None
|
||||||
owner: Owner
|
owner: Owner
|
||||||
paste: Paste
|
paste: Paste
|
||||||
|
port: Port
|
||||||
ports: Ports
|
ports: Ports
|
||||||
remove: Remove
|
remove: Remove
|
||||||
role: Role
|
role: Role
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue