Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: split sql editor routes (#10249)
boojack358c5af476a2
diff --git a/frontend/src/App.vue b/frontend/src/App.vueindex 1b64773765..1e790694f7 100644--- a/frontend/src/App.vue+++ b/frontend/src/App.vue@@ -31,6 +31,7 @@ import NotificationContext from "./NotificationContext.vue";import KBarWrapper from "./components/KBar/KBarWrapper.vue";import OverlayStackManager from "./components/misc/OverlayStackManager.vue";import { t } from "./plugins/i18n";+import { AUTH_SIGNIN_MODULE } from "./router/auth";import { useAuthStore, useNotificationStore } from "./store";import { isDev } from "./utils";@@ -58,7 +59,7 @@ setInterval(() => {state.prevLoggedIn = loggedIn;if (!loggedIn) {authStore.logout().then(() => {- router.push({ name: "auth.signin" });+ router.push({ name: AUTH_SIGNIN_MODULE });});}}diff --git a/frontend/src/components/IssueV1/components/HeaderSection/Actions/request/TinySQLEditorButton.vue b/frontend/src/components/IssueV1/components/HeaderSection/Actions/request/TinySQLEditorButton.vueindex 6a70735ba8..b17cbb1843 100644--- a/frontend/src/components/IssueV1/components/HeaderSection/Actions/request/TinySQLEditorButton.vue+++ b/frontend/src/components/IssueV1/components/HeaderSection/Actions/request/TinySQLEditorButton.vue@@ -11,6 +11,10 @@import { NButton } from "naive-ui";import { useRouter } from "vue-router";import { useIssueContext } from "@/components/IssueV1/logic";+import {+ SQL_EDITOR_DETAIL_MODULE,+ SQL_EDITOR_HOME_MODULE,+} from "@/router/sqlEditor";import { useDatabaseV1Store } from "@/store";import { UNKNOWN_ID } from "@/types";import { connectionV1Slug } from "@/utils";@@ -36,7 +40,7 @@ const gotoSQLEditor = async () => {if (db.uid !== String(UNKNOWN_ID)) {const slug = connectionV1Slug(db.instanceEntity, db);const url = router.resolve({- name: "sql-editor.detail",+ name: SQL_EDITOR_DETAIL_MODULE,params: {connectionSlug: slug,},@@ -46,7 +50,7 @@ const gotoSQLEditor = async () => {}}const url = router.resolve({- name: "sql-editor.home",+ name: SQL_EDITOR_HOME_MODULE,});window.open(url.fullPath, "__BLANK");};diff --git a/frontend/src/components/ProfileDropdown.vue b/frontend/src/components/ProfileDropdown.vueindex 850952ff73..15b79d9271 100644--- a/frontend/src/components/ProfileDropdown.vue+++ b/frontend/src/components/ProfileDropdown.vue@@ -20,6 +20,7 @@ import { computed, ref, h } from "vue";import { useI18n } from "vue-i18n";import { useRouter } from "vue-router";import { useLanguage } from "@/composables/useLanguage";+import { AUTH_SIGNIN_MODULE } from "@/router/auth";import {useActuatorV1Store,useAuthStore,@@ -55,7 +56,7 @@ const { currentPlan } = storeToRefs(subscriptionStore);const logout = () => {authStore.logout().then(() => {- router.push({ name: "auth.signin" });+ router.push({ name: AUTH_SIGNIN_MODULE });});};diff --git a/frontend/src/components/ProvideSQLEditorContext.vue b/frontend/src/components/ProvideSQLEditorContext.vueindex 2812da7d5f..ba77cc4101 100644--- a/frontend/src/components/ProvideSQLEditorContext.vue+++ b/frontend/src/components/ProvideSQLEditorContext.vue@@ -13,6 +13,11 @@ import { NSpin } from "naive-ui";import { onMounted, computed, watch, ref } from "vue";import { useI18n } from "vue-i18n";import { useRoute, useRouter } from "vue-router";+import {+ SQL_EDITOR_DETAIL_MODULE,+ SQL_EDITOR_HOME_MODULE,+ SQL_EDITOR_SHARE_MODULE,+} from "@/router/sqlEditor";import {useEnvironmentV1Store,useInstanceV1Store,@@ -281,7 +286,7 @@ const syncURLWithConnection = () => {const sheet = sheetV1Store.getSheetByName(sheetName);if (sheet) {router.replace({- name: "sql-editor.share",+ name: SQL_EDITOR_SHARE_MODULE,params: {sheetSlug: sheetSlugV1(sheet),},@@ -310,7 +315,7 @@ const syncURLWithConnection = () => {},});router.replace({- name: "sql-editor.detail",+ name: SQL_EDITOR_DETAIL_MODULE,params: {connectionSlug: makeConnectionV1Slug(instance, database),},@@ -318,7 +323,7 @@ const syncURLWithConnection = () => {return;}router.replace({- name: "sql-editor.home",+ name: SQL_EDITOR_HOME_MODULE,});},{ immediate: true }diff --git a/frontend/src/grpcweb/middlewares/authInterceptorMiddleware.ts b/frontend/src/grpcweb/middlewares/authInterceptorMiddleware.tsindex 06c428fbad..caec0dec1b 100644--- a/frontend/src/grpcweb/middlewares/authInterceptorMiddleware.ts+++ b/frontend/src/grpcweb/middlewares/authInterceptorMiddleware.ts@@ -1,6 +1,7 @@import { ClientError, ServerError, Status } from "nice-grpc-common";import { ClientMiddleware } from "nice-grpc-web";import { router } from "@/router";+import { AUTH_SIGNIN_MODULE } from "@/router/auth";import { useAuthStore } from "@/store";export type IgnoreErrorsOptions = {@@ -37,7 +38,7 @@ export const authInterceptorMiddleware: ClientMiddleware<IgnoreErrorsOptions> =try {await useAuthStore().logout();} finally {- router.push({ name: "auth.signin" });+ router.push({ name: AUTH_SIGNIN_MODULE });}} else if (code === Status.PERMISSION_DENIED) {if (options.silent) return;diff --git a/frontend/src/layouts/SplashLayout.vue b/frontend/src/layouts/SplashLayout.vueindex 6c00d3caa2..3515e3ae65 100644--- a/frontend/src/layouts/SplashLayout.vue+++ b/frontend/src/layouts/SplashLayout.vue@@ -2,7 +2,7 @@<div class="min-h-screen overflow-hidden flex"><div class="hidden bg-white lg:block relative w-0 flex-1"><img- v-if="route == 'auth.signup'"+ v-if="route === AUTH_SIGNUP_MODULE"class="absolute inset-0 h-full w-full object-cover"src="@/assets/illustration/signup.webp"alt=""@@ -25,6 +25,7 @@<script lang="ts" setup>import { computed } from "vue";import { useRouter } from "vue-router";+import { AUTH_SIGNUP_MODULE } from "@/router/auth";const router = useRouter();diff --git a/frontend/src/main.ts b/frontend/src/main.tsindex 15466412c5..3763070d8f 100644--- a/frontend/src/main.ts+++ b/frontend/src/main.ts@@ -15,6 +15,7 @@ import i18n from "./plugins/i18n";import NaiveUI from "./plugins/naive-ui";import { isSilent } from "./plugins/silent-request";import { router } from "./router";+import { AUTH_SIGNIN_MODULE } from "./router/auth";import {pinia,pushNotification,@@ -94,7 +95,7 @@ axios.interceptors.response.use(try {await useAuthStore().logout();} finally {- router.push({ name: "auth.signin" });+ router.push({ name: AUTH_SIGNIN_MODULE });}}}diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.tsindex 872371ac06..b6e509cfa1 100644--- a/frontend/src/router/index.ts+++ b/frontend/src/router/index.ts@@ -12,7 +12,6 @@ import BodyLayout from "@/layouts/BodyLayout.vue";import DashboardLayout from "@/layouts/DashboardLayout.vue";import DatabaseLayout from "@/layouts/DatabaseLayout.vue";import InstanceLayout from "@/layouts/InstanceLayout.vue";-import SQLEditorLayout from "@/layouts/SQLEditorLayout.vue";import { t } from "@/plugins/i18n";import {hasFeature,@@ -61,9 +60,9 @@ import authRoutes, {AUTH_SIGNIN_MODULE,AUTH_SIGNUP_MODULE,} from "./auth";+import sqlEditorRoutes, { SQL_EDITOR_HOME_MODULE } from "./sqlEditor";const HOME_MODULE = "workspace.home";-const SQL_EDITOR_HOME_MODULE = "sql-editor.home";const routes: RouteRecordRaw[] = [{@@ -827,39 +826,11 @@ const routes: RouteRecordRaw[] = [},],},- {- path: "/sql-editor",- name: "sql-editor",- component: SQLEditorLayout,- children: [- {- path: "",- name: SQL_EDITOR_HOME_MODULE,- meta: { title: () => "Bytebase SQL Editor" },- component: () => import("../views/sql-editor/SQLEditorPage.vue"),- props: true,- },- {- path: ":connectionSlug",- name: "sql-editor.detail",- meta: { title: () => "Bytebase SQL Editor" },- component: () => import("../views/sql-editor/SQLEditorPage.vue"),- props: true,- },- {- path: "sheet/:sheetSlug",- name: "sql-editor.share",- meta: { title: () => "Bytebase SQL Editor" },- component: () => import("../views/sql-editor/SQLEditorPage.vue"),- props: true,- },- ],- },];export const router = createRouter({history: createWebHistory(import.meta.env.BASE_URL),- routes: [...authRoutes, ...routes],+ routes: [...authRoutes, ...routes, ...sqlEditorRoutes],linkExactActiveClass: "bg-link-hover",scrollBehavior(to /*, from, savedPosition */) {if (to.hash) {@@ -1047,7 +1018,7 @@ router.beforeEach((to, from, next) => {to.name === "workspace.database" ||to.name === "workspace.issue" ||to.name === "workspace.environment" ||- to.name === "sql-editor.home" ||+ to.name === SQL_EDITOR_HOME_MODULE ||(to.name?.toString().startsWith("setting") &&to.name?.toString() != "setting.workspace.gitops.detail" &&to.name?.toString() != "setting.workspace.sql-review.detail" &&diff --git a/frontend/src/router/sqlEditor.ts b/frontend/src/router/sqlEditor.tsnew file mode 100644index 0000000000..086dc0bd9a--- /dev/null+++ b/frontend/src/router/sqlEditor.ts@@ -0,0 +1,36 @@+import { RouteRecordRaw } from "vue-router";+import SQLEditorLayout from "@/layouts/SQLEditorLayout.vue";++export const SQL_EDITOR_HOME_MODULE = "sql-editor.home";+export const SQL_EDITOR_DETAIL_MODULE = "sql-editor.detail";+export const SQL_EDITOR_SHARE_MODULE = "sql-editor.share";++const sqlEditorRoutes: RouteRecordRaw[] = [+ {+ path: "/sql-editor",+ name: "sql-editor",+ component: SQLEditorLayout,+ children: [+ {+ path: "",+ name: SQL_EDITOR_HOME_MODULE,+ meta: { title: () => "Bytebase SQL Editor" },+ component: () => import("../views/sql-editor/SQLEditorPage.vue"),+ },+ {+ path: ":connectionSlug",+ name: SQL_EDITOR_DETAIL_MODULE,+ meta: { title: () => "Bytebase SQL Editor" },+ component: () => import("../views/sql-editor/SQLEditorPage.vue"),+ },+ {+ path: "sheet/:sheetSlug",+ name: SQL_EDITOR_SHARE_MODULE,+ meta: { title: () => "Bytebase SQL Editor" },+ component: () => import("../views/sql-editor/SQLEditorPage.vue"),+ },+ ],+ },+];++export default sqlEditorRoutes;diff --git a/frontend/src/views/OAuthCallback.vue b/frontend/src/views/OAuthCallback.vueindex 591c4abc7c..1e80ce37fa 100644--- a/frontend/src/views/OAuthCallback.vue+++ b/frontend/src/views/OAuthCallback.vue@@ -16,6 +16,7 @@import { parse } from "qs";import { onMounted, reactive } from "vue";import { useRoute, useRouter } from "vue-router";+import { AUTH_MFA_MODULE } from "@/router/auth";import { useAuthStore } from "@/store";import { OAuthState, OAuthWindowEventPayload } from "../types";@@ -95,7 +96,7 @@ const triggerAuthCallback = async () => {});if (mfaTempToken) {const route = router.resolve({- name: "auth.mfa",+ name: AUTH_MFA_MODULE,query: {mfaTempToken,redirect: oAuthState.redirect || "",diff --git a/frontend/src/views/TwoFactorRequired.vue b/frontend/src/views/TwoFactorRequired.vueindex a48e99cf32..b22470e5eb 100644--- a/frontend/src/views/TwoFactorRequired.vue+++ b/frontend/src/views/TwoFactorRequired.vue@@ -12,6 +12,7 @@<script lang="ts" setup>import { useRouter } from "vue-router";+import { AUTH_SIGNIN_MODULE } from "@/router/auth";import { useAuthStore } from "@/store";import TwoFactorSetup from "./TwoFactorSetup.vue";@@ -20,7 +21,7 @@ const authStore = useAuthStore();const handleSetupCancel = () => {authStore.logout().then(() => {- router.push({ name: "auth.signin" });+ router.push({ name: AUTH_SIGNIN_MODULE });});};</script>diff --git a/frontend/src/views/TwoFactorSetup.vue b/frontend/src/views/TwoFactorSetup.vueindex 82e359946f..4bcd37392a 100644--- a/frontend/src/views/TwoFactorSetup.vue+++ b/frontend/src/views/TwoFactorSetup.vue@@ -88,6 +88,7 @@ import LearnMoreLink from "@/components/LearnMoreLink.vue";import RecoveryCodesView from "@/components/RecoveryCodesView.vue";import TwoFactorSecretModal from "@/components/TwoFactorSecretModal.vue";import { StepTab } from "@/components/v2";+import { AUTH_2FA_SETUP_MODULE } from "@/router/auth";import { pushNotification, useAuthStore, useUserStore } from "@/store";import { UpdateUserRequest } from "@/types/proto/v1/auth_service";@@ -215,7 +216,7 @@ const tryFinishSetup = async () => {// When user is on the 2fa.setup page, we'd like to redirect to the home page.// Only happens when the workspace level 2fa-setup is enabled.- if (router.currentRoute.value.name === "2fa.setup") {+ if (router.currentRoute.value.name === AUTH_2FA_SETUP_MODULE) {router.replace({path: "/",});diff --git a/frontend/src/views/auth/Signin.vue b/frontend/src/views/auth/Signin.vueindex a627e836fa..983006f4be 100644--- a/frontend/src/views/auth/Signin.vue+++ b/frontend/src/views/auth/Signin.vue@@ -247,6 +247,7 @@import { storeToRefs } from "pinia";import { computed, onMounted, reactive } from "vue";import { useRoute, useRouter } from "vue-router";+import { AUTH_MFA_MODULE, AUTH_SIGNUP_MODULE } from "@/router/auth";import {useActuatorV1Store,useAuthStore,@@ -294,7 +295,7 @@ onMounted(async () => {// Unable to achieve it in router.beforeEach because actuator/info is fetched async and returns// after router has already made the decision on first page load.if (actuatorStore.needAdminSetup && !disallowSignup.value) {- router.push({ name: "auth.signup", replace: true });+ router.push({ name: AUTH_SIGNUP_MODULE, replace: true });}const url = new URL(window.location.href);@@ -330,7 +331,7 @@ const trySignin = async (idpName?: string) => {});if (mfaTempToken) {router.push({- name: "auth.mfa",+ name: AUTH_MFA_MODULE,query: {mfaTempToken,redirect: route.query.redirect as string,diff --git a/frontend/src/views/sql-editor/Sheet/SheetTable/SheetTable.vue b/frontend/src/views/sql-editor/Sheet/SheetTable/SheetTable.vueindex 792b64d2c1..dc7ac0df8d 100644--- a/frontend/src/views/sql-editor/Sheet/SheetTable/SheetTable.vue+++ b/frontend/src/views/sql-editor/Sheet/SheetTable/SheetTable.vue@@ -48,6 +48,7 @@ import dayjs from "dayjs";import { computed } from "vue";import { useI18n } from "vue-i18n";import { useRouter } from "vue-router";+import { SQL_EDITOR_SHARE_MODULE } from "@/router/sqlEditor";import { useUserStore, useProjectV1Store } from "@/store";import { Sheet } from "@/types/proto/v1/sheet_service";import { Sheet_Visibility } from "@/types/proto/v1/sheet_service";@@ -85,7 +86,7 @@ const showCreator = computed(() => {const handleSheetClick = (sheet: Sheet) => {router.push({- name: "sql-editor.share",+ name: SQL_EDITOR_SHARE_MODULE,params: {sheetSlug: sheetSlugV1(sheet),},