Skip to content

Commit

Permalink
feat: add kafka schema registry
Browse files Browse the repository at this point in the history
DATATR-332

Signed-off-by: Jonathan Perchoc <[email protected]>
  • Loading branch information
jperchoc committed Aug 10, 2023
1 parent 218c88c commit d9d628e
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@
data-ng-click="$ctrl.trackKarapace($event)"
data-translate="pci_databases_general_information_kafka_rest_api_content"
data-translate-values="{
projectLink: '<a href=&quot' + $ctrl.KARAPACE_URL + '&quot>Karapace</a>'
projectLink: '<a href=&quot' + $ctrl.KARAPACE_URL + '&quot rel=&quotnoopener noreferrer&quot target=&quot_blank&quot>Karapace</a>'
}"
></p>
<div class="mb-3">
Expand Down Expand Up @@ -469,6 +469,48 @@
</oui-field>
</oui-tile-description>
</oui-tile-definition>
<oui-tile-definition
data-term="{{:: 'pci_databases_general_information_kafka_schema_registry_label' | translate }}"
data-ng-if="$ctrl.isFeatureActivated('schemaRegistry')"
>
<oui-tile-description>
<p
data-ng-click="$ctrl.trackKarapace($event)"
data-translate="pci_databases_general_information_kafka_schema_registry_content"
data-translate-values="{
projectLink: '<a href=&quot' + $ctrl.KARAPACE_URL + '&quot rel=&quotnoopener noreferrer&quot target=&quot_blank&quot>Karapace</a>'
}"
></p>
<div class="mb-3">
<oui-switch
class="d-inline-block"
name="schema-registry-switch"
model="$ctrl.enableSchemaRegistry"
on-change="$ctrl.onSchemaRegistryStatusChange(modelValue)"
data-disabled="$ctrl.loading.schemaRegistry || !$ctrl.database.isActive()"
>
</oui-switch>
<span
class="d-inline-block mx-2"
data-ng-bind="($ctrl.enableSchemaRegistry ? 'pci_databases_general_information_kafka_schema_registry_enable' : 'pci_databases_general_information_kafka_schema_registry_disable') | translate"
>
</span>
</div>
<oui-field
data-ng-if="$ctrl.enableSchemaRegistry && $ctrl.schemaRegistryServiceUri"
>
<label
data-translate="pci_databases_general_information_kafka_schema_registry_service_uri_label"
></label>
<oui-clipboard
data-model="$ctrl.schemaRegistryServiceUri"
data-id="schema-registry-service-uri"
data-name="schema-registry-service-uri"
data-ng-click="$ctrl.onSchemaRegistryServiceUriCopy($event)"
></oui-clipboard>
</oui-field>
</oui-tile-description>
</oui-tile-definition>
</oui-tile>
<oui-tile
data-heading="{{:: 'pci_databases_general_information_support_title' | translate }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@
"pci_databases_general_information_kafka_rest_api_disable": "Désactiver",
"pci_databases_general_information_kafka_rest_service_uri_label": "URI du service REST Kafka",
"pci_databases_general_information_kafka_rest_api_enable_disable_error": "Une erreur est survenue lors de l'activation/désactivation de Kafka REST API.",
"pci_databases_general_information_kafka_schema_registry_label": "Schema Registry",
"pci_databases_general_information_kafka_schema_registry_content": "Interface de service HTTP REST pour stocker les schémas Apache Kafka (basée sur le projet {{ projectLink }}).",
"pci_databases_general_information_kafka_schema_registry_enable": "Activer",
"pci_databases_general_information_kafka_schema_registry_disable": "Désactiver",
"pci_databases_general_information_kafka_schema_registry_service_uri_label": "URI du service Schema Registry",
"pci_databases_general_information_kafka_schema_registry_enable_disable_error": "Une erreur est survenue lors de l'activation/désactivation du service Schema Registry.",
"pci_databases_general_information_endpoint_label": "Service",
"pci_databases_general_information_scheme_label": "Protocole",
"pci_databases_general_information_path_label": "Path",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const features = {
],
replicationsTab: [DATABASE_TYPES.KAFKA_MIRROR_MAKER],
restApi: [DATABASE_TYPES.KAFKA],
schemaRegistry: [DATABASE_TYPES.KAFKA],
usersGroup: [DATABASE_TYPES.M3DB],
resetAdminUserFromDashboard: [DATABASE_TYPES.GRAFANA],
namespacesTab: [DATABASE_TYPES.M3DB],
Expand Down

0 comments on commit d9d628e

Please sign in to comment.