diff --git a/charts/kubedbcom-mysql-editor/ui/edit-ui.yaml b/charts/kubedbcom-mysql-editor/ui/edit-ui.yaml index 93fed0a04..16babd045 100644 --- a/charts/kubedbcom-mysql-editor/ui/edit-ui.yaml +++ b/charts/kubedbcom-mysql-editor/ui/edit-ui.yaml @@ -1277,4 +1277,20 @@ steps: type: single-step-form id: storage-autoscaler title: steps.10.label +- form: + discriminator: + binding: + default: false + type: boolean + elements: + - computed: isBindingAlreadyOn + label: + text: Expose Binding + onChange: addOrRemoveBinding + type: switch + schema: + $ref: discriminator#/properties/binding + type: single-step-form + id: binding + title: steps.11.label type: multi-step-form diff --git a/charts/kubedbcom-mysql-editor/ui/functions.js b/charts/kubedbcom-mysql-editor/ui/functions.js index 621f39691..3b0ef4dbe 100644 --- a/charts/kubedbcom-mysql-editor/ui/functions.js +++ b/charts/kubedbcom-mysql-editor/ui/functions.js @@ -2349,6 +2349,27 @@ function objectCopy(obj) { return JSON.parse(temp) } +function isBindingAlreadyOn({ model, getValue }) { + const value = getValue(model, '/resources') + const keys = Object.keys(value) + isExposeBinding = !!keys.find((str) => str === 'catalogAppscodeComMySQLBinding') + console.log(isExposeBinding, keys) + return isExposeBinding +} + +function addOrRemoveBinding({ commit, model, getValue, discriminator }) { + const value = getValue(discriminator, `/binding`) + const resources = getValue(model, '/resources') + + if (value) { + commit('wizard/model$update', { + path: '/resources/kubedbComMySQL/spec/storage/storageClassName', + value: storageClass, + force: true, + }) + } +} + return { handleUnit, isConsole, @@ -2495,4 +2516,6 @@ return { onArchiverChange, onBackupTypeChange, getNamespaceArray, + isBindingAlreadyOn, + addOrRemoveBinding, }