Fix node driver issue

https://github.com/rancher/rancher/issues/12544
This commit is contained in:
loganhz 2018-04-19 12:55:34 +08:00
parent 2412563010
commit 8ded65a30c
2 changed files with 33 additions and 3 deletions

View File

@ -118,11 +118,13 @@ export default Component.extend(ViewNewEdit, ChildHook, {
reloadSchema: observer('needReloadSchema', function() {
if ( !get(this, 'reloadingSchema') && get(this, 'needReloadSchema') ) {
set(this, 'reloadingSchema', true);
get(this, 'globalStore').findAll('schema', {
url: '/v3/schemas',
forceReload: true
}).then(() => {
set(this, 'schemaReloaded', true);
set(this, 'reloadingSchema', false);
});
}
}),

View File

@ -1,7 +1,7 @@
import Component from '@ember/component';
import ModalBase from 'shared/mixins/modal-base';
import layout from './template';
import { get, set, computed } from '@ember/object';
import { get, set, computed, observer } from '@ember/object';
import { inject as service } from '@ember/service';
import { loadScript, loadStylesheet, proxifyUrl } from 'shared/utils/load-script';
import { empty } from '@ember/object/computed';
@ -21,6 +21,10 @@ export default Component.extend(ModalBase, {
editing: false,
allNodeDrivers: null,
needReloadSchema: false,
reloadingSchema: false,
schemaReloaded: false,
showPicker: empty('model.id'),
actions: {
@ -42,8 +46,32 @@ export default Component.extend(ModalBase, {
},
},
availableDrivers: computed('allNodeDrivers.@each.state', function() {
return get(this, 'allNodeDrivers').filterBy('state','active').sortBy('name');
availableDrivers: computed('allNodeDrivers.@each.state', 'schemaReloaded', function() {
const out = [];
const drivers = get(this, 'allNodeDrivers').filterBy('state','active').sortBy('name');
drivers.forEach((driver) => {
const configName = `${get(driver, 'name')}Config`;
const driverSchema = get(this, 'globalStore').getById('schema', configName.toLowerCase());
if ( driverSchema ) {
out.push(driver);
} else {
set(this, 'needReloadSchema', true);
}
});
return out;
}),
reloadSchema: observer('needReloadSchema', function() {
if ( !get(this, 'reloadingSchema') && get(this, 'needReloadSchema') ) {
set(this, 'reloadingSchema', true);
get(this, 'globalStore').findAll('schema', {
url: '/v3/schemas',
forceReload: true
}).then(() => {
set(this, 'schemaReloaded', true);
set(this, 'reloadingSchema', false);
});
}
}),
availableDriversGroups: computed('availableDrivers.@each.state', function() {