mirror of https://github.com/rancher/ui.git
Should only be allow to enter 1 of each item
https://github.com/rancher/rancher/issues/14859
This commit is contained in:
parent
6dfec5dd9b
commit
06cc9d7630
|
|
@ -9,7 +9,7 @@ const VALID_ROUTES = ['authenticated.cluster.nodes', 'authenticated.cluster.stor
|
|||
'authenticated.cluster.storage.persistent-volumes', 'authenticated.cluster.notifier',
|
||||
'authenticated.cluster.alert', 'authenticated.cluster.logging',
|
||||
'authenticated.cluster.security.members.index', 'authenticated.cluster.projects',
|
||||
'authenticated.cluster.quotas', 'authenticated.cluster.pipeline'];
|
||||
'authenticated.cluster.quotas'];
|
||||
|
||||
export default Route.extend(Preload, {
|
||||
scope: service(),
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ export default Component.extend({
|
|||
actions: {
|
||||
addQuota() {
|
||||
get(this, 'quotaArray').pushObject({
|
||||
key: 'pods',
|
||||
key: '',
|
||||
value: '',
|
||||
});
|
||||
},
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
{{#each quotaArray as |quota|}}
|
||||
{{resource-quota-row
|
||||
quota=quota
|
||||
currentQuota=quotaArray
|
||||
editing=editing
|
||||
remove=(action "removeQuota")
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { get, set } from '@ember/object';
|
||||
import { get, set, observer } from '@ember/object';
|
||||
import { inject as service } from '@ember/service';
|
||||
import Component from '@ember/component';
|
||||
import { next } from '@ember/runloop';
|
||||
import layout from './template';
|
||||
|
||||
const IGNORED = ['requestsStorage', 'persistentVolumeClaims'];
|
||||
|
|
@ -13,13 +14,22 @@ export default Component.extend({
|
|||
tagName: 'TR',
|
||||
classNames: 'main-row',
|
||||
|
||||
resourceChoices: null,
|
||||
resourceChoices: null,
|
||||
allResourceChoices: null,
|
||||
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
this.initResourceChoices();
|
||||
},
|
||||
|
||||
currentQuotaDidChange: observer('currentQuota.@each.key', function() {
|
||||
set(this, 'resourceChoices', get(this, 'allResourceChoices').filter((choice) => this.doesExist(choice)));
|
||||
}),
|
||||
|
||||
doesExist(choice) {
|
||||
return get(choice, 'value') === get(this, 'quota.key') || !get(this, 'currentQuota').findBy('key', get(choice, 'value'));
|
||||
},
|
||||
|
||||
initResourceChoices() {
|
||||
const choices = [];
|
||||
const schema = get(this, 'globalStore').getById('schema', 'resourcequotalimit');
|
||||
|
|
@ -33,6 +43,14 @@ export default Component.extend({
|
|||
});
|
||||
}
|
||||
|
||||
set(this, 'resourceChoices', choices);
|
||||
set(this, 'allResourceChoices', choices);
|
||||
|
||||
set(this, 'resourceChoices', choices.filter((choice) => this.doesExist(choice)));
|
||||
|
||||
if ( get(this, 'resourceChoices.length') && !get(this, 'quota.key') ) {
|
||||
next(() => {
|
||||
set(this, 'quota.key', get(this, 'resourceChoices.firstObject.value'));
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue