From d9d628e75edd066854803eec5a3a61af5ac1b72f Mon Sep 17 00:00:00 2001 From: Jonathan Perchoc Date: Thu, 10 Aug 2023 10:36:40 +0200 Subject: [PATCH] feat: add kafka schema registry DATATR-332 Signed-off-by: Jonathan Perchoc --- .../general-information.controller.js | 56 ++++++++++++++++++- .../general-information.html | 44 ++++++++++++++- .../translations/Messages_fr_FR.json | 6 ++ .../storages/databases/features.constants.js | 1 + 4 files changed, 105 insertions(+), 2 deletions(-) diff --git a/packages/manager/modules/pci/src/projects/project/storages/databases/database/general-information/general-information.controller.js b/packages/manager/modules/pci/src/projects/project/storages/databases/database/general-information/general-information.controller.js index 05d9de11027f..96e0f1f88de9 100644 --- a/packages/manager/modules/pci/src/projects/project/storages/databases/database/general-information/general-information.controller.js +++ b/packages/manager/modules/pci/src/projects/project/storages/databases/database/general-information/general-information.controller.js @@ -46,14 +46,22 @@ export default class { this.warningMessages = WARNING_MESSAGES; this.loading = { restApi: false, + schemaRegistry: false, }; if (this.isFeatureActivated('restApi')) { this.enableRestApi = this.database.restApi ?? false; this.restApiServiceUri = this.database.endpoints?.find( (endPoint) => endPoint.component === `${this.database.engine}RestApi`, )?.uri; - this.KARAPACE_URL = KARAPACE_URL; } + if (this.isFeatureActivated('schemaRegistry')) { + this.enableSchemaRegistry = this.database.schemaRegistry ?? false; + this.schemaRegistryServiceUri = this.database.endpoints?.find( + (endPoint) => + endPoint.component === `${this.database.engine}SchemaRegistry`, + )?.uri; + } + this.KARAPACE_URL = KARAPACE_URL; [this.endpoint] = this.database.endpoints; this.maintenanceTime = this.database.maintenanceTime; @@ -326,6 +334,40 @@ export default class { }); } + onSchemaRegistryStatusChange(enableSchemaRegistry) { + this.trackDashboard( + enableSchemaRegistry + ? 'general-information::kafka_schema_registry_enable' + : 'general-information::kafka_schema_registry_disable', + 'click', + ); + this.loading.schemaRegistry = true; + return this.DatabaseService.updateDatabaseEngineProperties( + this.projectId, + this.database.engine, + this.database.id, + { schemaRegistry: enableSchemaRegistry }, + ) + .then((databaseInfos) => { + this.schemaRegistryServiceUri = databaseInfos.endpoints?.find( + (endPoint) => + endPoint.component === `${this.database.engine}SchemaRegistry`, + )?.uri; + }) + .catch(() => { + this.enableSchemaRegistry = !enableSchemaRegistry; + return this.CucCloudMessage.error( + this.$translate.instant( + 'pci_databases_general_information_kafka_rest_api_enable_disable_error', + ), + this.messageContainer, + ); + }) + .finally(() => { + this.loading.schemaRegistry = false; + }); + } + getSSLKeyTranslation() { let sslTranslationKey = this.endpoint.sslMode; // if key exists in translation, return translation key. @@ -351,6 +393,18 @@ export default class { } } + onSchemaRegistryServiceUriCopy(event) { + // Clipboard has 2 elements input & button. Input event handler triggers click on button. + // So click event-handler on oui-clipboard will be triggered twice. + // For the expected behavior, considering only the click event on input element. + if (event.target.tagName === 'INPUT') { + this.trackDashboard( + 'general-information::kafka_schema_registry_copy_paste', + 'click', + ); + } + } + trackKarapace(event) { if (event.target.tagName?.toLowerCase() === 'a') { this.trackDashboard( diff --git a/packages/manager/modules/pci/src/projects/project/storages/databases/database/general-information/general-information.html b/packages/manager/modules/pci/src/projects/project/storages/databases/database/general-information/general-information.html index f4e5b5ec8739..e5a2fc969fd2 100644 --- a/packages/manager/modules/pci/src/projects/project/storages/databases/database/general-information/general-information.html +++ b/packages/manager/modules/pci/src/projects/project/storages/databases/database/general-information/general-information.html @@ -436,7 +436,7 @@ data-ng-click="$ctrl.trackKarapace($event)" data-translate="pci_databases_general_information_kafka_rest_api_content" data-translate-values="{ - projectLink: 'Karapace' + projectLink: 'Karapace' }" >

@@ -469,6 +469,48 @@ + + +

+
+ + + + +
+ + + + +
+