Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

Add a ping method to prepare for testing backend connectivity

天舟f3cc67cff7ba
diff --git a/frontend/src/components/ProfileDropdown.vue b/frontend/src/components/ProfileDropdown.vue
index 6bfa224839..0880febb3e 100644
--- a/frontend/src/components/ProfileDropdown.vue
+++ b/frontend/src/components/ProfileDropdown.vue
@@ -49,6 +49,14 @@
</a>
</div>
</div>
+ <div
+ v-if="isDevOrDemo"
+ @click.prevent="ping"
+ class="py-1 menu-item"
+ role="menuitem"
+ >
+ Ping
+ </div>
<div class="border-t border-gray-100"></div>
<div class="py-1">
<router-link to="/setting" class="menu-item" role="menuitem"
@@ -164,6 +172,16 @@ export default {
});
};
+ const ping = () => {
+ store.dispatch("debug/ping").then((message: string) => {
+ store.dispatch("notification/pushNotification", {
+ module: "bytebase",
+ style: "SUCCESS",
+ title: message,
+ });
+ });
+ };
+
return {
currentUser,
resetQuickstart,
@@ -171,6 +189,7 @@ export default {
switchToOwner,
switchToDBA,
switchToDeveloper,
+ ping,
};
},
};
diff --git a/frontend/src/miragejs/routes/index.js b/frontend/src/miragejs/routes/index.js
index c631bd6528..14a9b807d3 100644
--- a/frontend/src/miragejs/routes/index.js
+++ b/frontend/src/miragejs/routes/index.js
@@ -1,6 +1,7 @@
/*
* Mirage JS guide on Routes: https://miragejs.com/docs/route-handlers/functions
*/
+import { Response } from "miragejs";
import configurePrincipal from "./principal";
import configureAuth from "./auth";
import configureMember from "./member";
@@ -29,6 +30,11 @@ export default function routes() {
this.namespace = "api";
+ // Ping
+ this.get("/ping", function () {
+ return new Response(200, {}, "pong");
+ });
+
// Principal
configurePrincipal(this);
diff --git a/frontend/src/store/index.ts b/frontend/src/store/index.ts
index 8ff80387cd..581b2c7266 100644
--- a/frontend/src/store/index.ts
+++ b/frontend/src/store/index.ts
@@ -26,7 +26,10 @@ import router from "./modules/router";
import command from "./modules/command";
import notification from "./modules/notification";
-const debug = import.meta.env.NODE_ENV !== "production";
+// Debug module
+import debug from "./modules/debug";
+
+const isProd = import.meta.env.NODE_ENV == "production";
export const store: Store<any> = createStore({
modules: {
@@ -50,6 +53,7 @@ export const store: Store<any> = createStore({
router,
command,
notification,
+ debug,
},
- strict: debug,
+ strict: !isProd,
});
diff --git a/frontend/src/store/modules/debug.ts b/frontend/src/store/modules/debug.ts
new file mode 100644
index 0000000000..b39196fe9d
--- /dev/null
+++ b/frontend/src/store/modules/debug.ts
@@ -0,0 +1,19 @@
+import axios from "axios";
+
+const getters = {};
+
+const actions = {
+ async ping() {
+ const message = (await axios.get(`/api/ping`)).data;
+ return message;
+ },
+};
+
+const mutations = {};
+
+export default {
+ namespaced: true,
+ getters,
+ actions,
+ mutations,
+};