Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat: prevent repeat click (#3533)
Liu Ji66ad78807e4d
diff --git a/frontend/src/components/CreateInstanceForm.vue b/frontend/src/components/CreateInstanceForm.vueindex f577738e9f..49385ab655 100644--- a/frontend/src/components/CreateInstanceForm.vue+++ b/frontend/src/components/CreateInstanceForm.vue@@ -184,7 +184,7 @@<buttontype="button"class="btn-normal whitespace-nowrap items-center"- :disabled="!state.instance.host"+ :disabled="!state.instance.host || state.isPingingInstance"@click.prevent="testConnection">{{ $t("instance.test-connection") }}@@ -202,11 +202,15 @@v-if="state.isCreatingInstance":title="$t('common.creating')"/>+ <BBSpin+ v-if="state.isPingingInstance"+ :title="$t('common.connecting')"+ /><div class="ml-2"><buttontype="button"class="btn-normal py-2 px-4"- :disabled="state.isCreatingInstance"+ :disabled="state.isCreatingInstance || state.isPingingInstance"@click.prevent="cancel">{{ $t("common.cancel") }}@@ -214,7 +218,11 @@<buttontype="button"class="btn-primary ml-3 inline-flex justify-center py-2 px-4"- :disabled="!allowCreate || state.isCreatingInstance"+ :disabled="+ !allowCreate ||+ state.isCreatingInstance ||+ state.isPingingInstance+ "@click.prevent="tryCreate">{{ $t("common.create") }}@@ -264,6 +272,7 @@ import {interface LocalState {instance: InstanceCreate;+ isPingingInstance: boolean;isCreatingInstance: boolean;showCreateInstanceWarningModal: boolean;createInstanceWarning: string;@@ -303,6 +312,7 @@ const state = reactive<LocalState>({},showCreateInstanceWarningModal: false,createInstanceWarning: "",+ isPingingInstance: false,isCreatingInstance: false,});@@ -499,16 +509,23 @@ const tryCreate = () => {connectionInfo.sslCert = instance.sslCert ?? "";}- sqlStore.ping(connectionInfo).then((resultSet: SQLResultSet) => {- if (isEmpty(resultSet.error)) {- doCreate();- } else {- state.createInstanceWarning = t("instance.unable-to-connect", [- resultSet.error,- ]);- state.showCreateInstanceWarningModal = true;- }- });+ state.isPingingInstance = true;+ sqlStore+ .ping(connectionInfo)+ .then((resultSet: SQLResultSet) => {+ state.isPingingInstance = false;+ if (isEmpty(resultSet.error)) {+ doCreate();+ } else {+ state.createInstanceWarning = t("instance.unable-to-connect", [+ resultSet.error,+ ]);+ state.showCreateInstanceWarningModal = true;+ }+ })+ .catch(() => {+ state.isPingingInstance = false;+ });};// We will also create the database * denoting all databases@@ -556,31 +573,37 @@ const testConnection = () => {connectionInfo.sslCert = instance.sslCert ?? "";}- sqlStore.ping(connectionInfo).then((resultSet: SQLResultSet) => {- if (isEmpty(resultSet.error)) {- pushNotification({- module: "bytebase",- style: "SUCCESS",- title: t("instance.successfully-connected-instance"),- });- } else {- let title = t("instance.failed-to-connect-instance");- if (- connectionInfo.host == "localhost" ||- connectionInfo.host == "127.0.0.1"- ) {- title = t("instance.failed-to-connect-instance-localhost");+ state.isPingingInstance = true;+ sqlStore+ .ping(connectionInfo)+ .then((resultSet: SQLResultSet) => {+ if (isEmpty(resultSet.error)) {+ pushNotification({+ module: "bytebase",+ style: "SUCCESS",+ title: t("instance.successfully-connected-instance"),+ });+ } else {+ let title = t("instance.failed-to-connect-instance");+ if (+ connectionInfo.host == "localhost" ||+ connectionInfo.host == "127.0.0.1"+ ) {+ title = t("instance.failed-to-connect-instance-localhost");+ }+ pushNotification({+ module: "bytebase",+ style: "CRITICAL",+ title: title,+ description: resultSet.error,+ // Manual hide, because user may need time to inspect the error+ manualHide: true,+ });}- pushNotification({- module: "bytebase",- style: "CRITICAL",- title: title,- description: resultSet.error,- // Manual hide, because user may need time to inspect the error- manualHide: true,- });- }- });+ })+ .finally(() => {+ state.isPingingInstance = false;+ });};</script>diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex 71dd78359f..1120fa0a9c 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -138,6 +138,7 @@"Default": "Default","definition": "Definition","empty": "Empty",+ "connecting": "Connecting...","creating": "Creating...","updating": "Updating...","Address": "Address",diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 3b1fb8a7e1..85326eca29 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -138,6 +138,7 @@"Default": "默认","definition": "定义","empty": "空",+ "connecting": "连接中...","creating": "创建中...","updating": "更新中...","Address": "地址",