mirror of https://github.com/rancher/ui.git
Fix volumes reset when click 'expand All' in create workload
This commit is contained in:
parent
4688f13e49
commit
ccbf435235
|
|
@ -43,69 +43,7 @@ export default Component.extend({
|
||||||
name: 'saveVolumes',
|
name: 'saveVolumes',
|
||||||
key: '_volumeHooks'
|
key: '_volumeHooks'
|
||||||
});
|
});
|
||||||
},
|
this.initVolumes()
|
||||||
|
|
||||||
didReceiveAttrs() {
|
|
||||||
if (!get(this, 'expandFn')) {
|
|
||||||
set(this, 'expandFn', (item) => {
|
|
||||||
item.toggleProperty('expanded');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const out = [];
|
|
||||||
let entry;
|
|
||||||
|
|
||||||
(get(this, 'workload.volumes') || []).forEach((volume) => {
|
|
||||||
if (volume.persistentVolumeClaim) {
|
|
||||||
entry = {
|
|
||||||
mode: EXISTING_PVC,
|
|
||||||
volume,
|
|
||||||
};
|
|
||||||
} else if (volume.hostPath) {
|
|
||||||
entry = {
|
|
||||||
mode: BIND_MOUNT,
|
|
||||||
volume,
|
|
||||||
};
|
|
||||||
} else if ( volume.flexVolume && volume.flexVolume.driver === LOG_AGGREGATOR ) {
|
|
||||||
entry = {
|
|
||||||
mode: CUSTOM_LOG_PATH,
|
|
||||||
volume,
|
|
||||||
};
|
|
||||||
} else if (volume.secret) {
|
|
||||||
entry = {
|
|
||||||
mode: SECRET,
|
|
||||||
volume,
|
|
||||||
};
|
|
||||||
} else if (volume.configMap) {
|
|
||||||
entry = {
|
|
||||||
mode: CONFIG_MAP,
|
|
||||||
volume,
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
entry = {
|
|
||||||
mode: EXISTING_VOLUME,
|
|
||||||
volume,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
entry.mounts = [];
|
|
||||||
out.push(entry);
|
|
||||||
});
|
|
||||||
|
|
||||||
(get(this, 'launchConfig.volumeMounts') || []).forEach((mount) => {
|
|
||||||
entry = out.findBy('volume.name', mount.name);
|
|
||||||
|
|
||||||
if (entry) {
|
|
||||||
entry.mounts.push(mount);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// filter out custom log path volume when logging is disabled
|
|
||||||
if (!get(this, 'loggingEnabled')) {
|
|
||||||
set(this, 'volumesArray', out.filter((row) => row.mode !== CUSTOM_LOG_PATH));
|
|
||||||
} else {
|
|
||||||
set(this, 'volumesArray', out);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Create (ephermal) Volume -> volume entry on pod
|
// Create (ephermal) Volume -> volume entry on pod
|
||||||
|
|
@ -286,6 +224,69 @@ export default Component.extend({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
initVolumes() {
|
||||||
|
if (!get(this, 'expandFn')) {
|
||||||
|
set(this, 'expandFn', (item) => {
|
||||||
|
item.toggleProperty('expanded');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const out = [];
|
||||||
|
let entry;
|
||||||
|
|
||||||
|
(get(this, 'workload.volumes') || []).forEach((volume) => {
|
||||||
|
if (volume.persistentVolumeClaim) {
|
||||||
|
entry = {
|
||||||
|
mode: EXISTING_PVC,
|
||||||
|
volume,
|
||||||
|
};
|
||||||
|
} else if (volume.hostPath) {
|
||||||
|
entry = {
|
||||||
|
mode: BIND_MOUNT,
|
||||||
|
volume,
|
||||||
|
};
|
||||||
|
} else if ( volume.flexVolume && volume.flexVolume.driver === LOG_AGGREGATOR ) {
|
||||||
|
entry = {
|
||||||
|
mode: CUSTOM_LOG_PATH,
|
||||||
|
volume,
|
||||||
|
};
|
||||||
|
} else if (volume.secret) {
|
||||||
|
entry = {
|
||||||
|
mode: SECRET,
|
||||||
|
volume,
|
||||||
|
};
|
||||||
|
} else if (volume.configMap) {
|
||||||
|
entry = {
|
||||||
|
mode: CONFIG_MAP,
|
||||||
|
volume,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
entry = {
|
||||||
|
mode: EXISTING_VOLUME,
|
||||||
|
volume,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
entry.mounts = [];
|
||||||
|
out.push(entry);
|
||||||
|
});
|
||||||
|
|
||||||
|
(get(this, 'launchConfig.volumeMounts') || []).forEach((mount) => {
|
||||||
|
entry = out.findBy('volume.name', mount.name);
|
||||||
|
|
||||||
|
if (entry) {
|
||||||
|
entry.mounts.push(mount);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// filter out custom log path volume when logging is disabled
|
||||||
|
if (!get(this, 'loggingEnabled')) {
|
||||||
|
set(this, 'volumesArray', out.filter((row) => row.mode !== CUSTOM_LOG_PATH));
|
||||||
|
} else {
|
||||||
|
set(this, 'volumesArray', out);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
nextName() {
|
nextName() {
|
||||||
const volumes = get(this, 'workload.volumes') || [];
|
const volumes = get(this, 'workload.volumes') || [];
|
||||||
let num = get(this, 'nextNum');
|
let num = get(this, 'nextNum');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue