rework showManagementWarning to computed property only imported

This commit is contained in:
Westly Wright 2021-04-26 11:59:48 -07:00
parent 0770ea31a0
commit ea89a726d7
No known key found for this signature in database
GPG Key ID: 4FAB3D8673DC54A3
1 changed files with 13 additions and 8 deletions

View File

@ -28,12 +28,11 @@ export default Component.extend({
nodeVersions: null,
controlPlaneVersion: null,
upgradeVersion: false,
showManagementWarning: false,
init() {
this._super(...arguments);
const { nodePool, originalCluster } = this;
const { nodePool } = this;
setProperties(this, {
scopeConfig: {},
@ -55,12 +54,6 @@ export default Component.extend({
if (isEmpty(this?.nodePool?.version) && !isEmpty(this?.cluster?.gkeConfig?.kubernetesVersion)) {
set(this, 'nodePool.version', this?.cluster?.gkeConfig?.kubernetesVersion);
}
const isClusterImported = !isEmpty(originalCluster) && originalCluster?.gkeStatus?.upstreamSpec?.imported;
if (isClusterImported && !nodePool?.management?.autoRepair && !nodePool?.management?.autoUpgrade) {
set(this, 'showManagementWarning', true);
}
} else {
setProperties(this, {
oauthScopesSelection: this.google.oauthScopeOptions.DEFAULT,
@ -130,6 +123,18 @@ export default Component.extend({
set(this.nodePool.config, 'oauthScopes', this.google.mapOauthScopes(this.oauthScopesSelection, this.scopeConfig));
})),
showManagementWarning: computed('originalCluster.gkeStatus.upstreamSpec.imported', 'nodePool.management.{autoUpgrade,autoRepair}', function() {
const { nodePool, originalCluster } = this;
const isClusterImported = !isEmpty(originalCluster) && originalCluster?.gkeStatus?.upstreamSpec?.imported;
if (isClusterImported && ( !nodePool?.management?.autoRepair || !nodePool?.management?.autoUpgrade )) {
return true;
}
return false;
}),
originalClusterVersion: computed('originalCluster.gkeConfig.kubernetesVersion', 'originalCluster.gkeStatus.upstreamSpec.kubernetesVersion', function() {
if (!isEmpty(get(this, 'originalCluster.gkeConfig.kubernetesVersion'))) {
return get(this, 'originalCluster.gkeConfig.kubernetesVersion');