Skip to content

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

chore: delete /sheets route (#8704)

Tianzhou (天舟)997b28163744
diff --git a/frontend/src/layouts/SheetDashboardLayout.vue b/frontend/src/layouts/SheetDashboardLayout.vue
deleted file mode 100644
index 76952820ec..0000000000
--- a/frontend/src/layouts/SheetDashboardLayout.vue
+++ /dev/null
@@ -1,62 +0,0 @@
-<template>
- <div class="relative h-screen overflow-hidden flex flex-col">
- <template v-if="isDemo">
- <BannerDemo />
- </template>
- <template v-else-if="isExpired || isTrialing">
- <BannerSubscription />
- </template>
-
- <nav class="bg-white border-b border-block-border">
- <div class="max-w-full mx-auto px-4">
- <EditorHeader />
- </div>
- </nav>
-
- <!-- Suspense is experimental, be aware of the potential change -->
- <Suspense>
- <template #default>
- <router-view />
- </template>
- <template #fallback>
- <div class="flex flex-row justify-between p-4 space-x-2">
- <span class="items-center flex">Loading...</span>
- <button
- class="items-center flex justify-center btn-normal"
- @click.prevent="ping"
- >
- Ping
- </button>
- </div>
- </template>
- </Suspense>
- </div>
-</template>
-
-<script lang="ts" setup>
-import { storeToRefs } from "pinia";
-import {
- pushNotification,
- useActuatorV1Store,
- useSubscriptionV1Store,
-} from "@/store";
-import BannerDemo from "@/views/BannerDemo.vue";
-import BannerSubscription from "@/views/BannerSubscription.vue";
-import EditorHeader from "@/views/sql-editor/EditorHeader.vue";
-
-const actuatorStore = useActuatorV1Store();
-const subscriptionStore = useSubscriptionV1Store();
-
-const ping = () => {
- actuatorStore.fetchServerInfo().then((info) => {
- pushNotification({
- module: "bytebase",
- style: "SUCCESS",
- title: JSON.stringify(info, null, 4),
- });
- });
-};
-
-const { isDemo } = storeToRefs(actuatorStore);
-const { isExpired, isTrialing } = storeToRefs(subscriptionStore);
-</script>
diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts
index 68808eee5d..6521a84277 100644
--- a/frontend/src/router/index.ts
+++ b/frontend/src/router/index.ts
@@ -12,7 +12,6 @@ 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 SheetDashboardLayout from "@/layouts/SheetDashboardLayout.vue";
import SplashLayout from "@/layouts/SplashLayout.vue";
import { useConversationStore } from "@/plugins/ai/store";
import { t } from "@/plugins/i18n";
@@ -1053,37 +1052,6 @@ const routes: Array<RouteRecordRaw> = [
},
],
},
- {
- path: "/sheets",
- name: "sheets",
- component: SheetDashboardLayout,
- children: [
- {
- path: "",
- name: "sheets.dashboard",
- meta: { title: () => "Sheets" },
- component: () => import("../views/SheetDashboard.vue"),
- },
- {
- path: "my",
- name: "sheets.my",
- meta: { title: () => "Sheets" },
- component: () => import("../views/SheetDashboard.vue"),
- },
- {
- path: "shared",
- name: "sheets.shared",
- meta: { title: () => "Sheets" },
- component: () => import("../views/SheetDashboard.vue"),
- },
- {
- path: "starred",
- name: "sheets.starred",
- meta: { title: () => "Sheets" },
- component: () => import("../views/SheetDashboard.vue"),
- },
- ],
- },
];
export const router = createRouter({
diff --git a/frontend/src/views/SheetDashboard.vue b/frontend/src/views/SheetDashboard.vue
deleted file mode 100644
index 1305b1f0ee..0000000000
--- a/frontend/src/views/SheetDashboard.vue
+++ /dev/null
@@ -1,284 +0,0 @@
-<template>
- <div class="w-full h-full grid grid-cols-[212px_1fr] gap-0">
- <div
- class="w-full h-auto flex flex-col justify-start items-start px-4 pl-6 py-2 border-r"
- >
- <router-link
- v-for="nav in navigationList"
- :key="nav.path"
- :to="nav.path"
- class="text-base w-full p-2 px-3 rounded-lg mt-1 select-none hover:bg-gray-100"
- active-class="active-link"
- exact-active-class="active-link"
- >{{ nav.label }}</router-link
- >
- </div>
- <div
- class="w-full h-full flex flex-col justify-start items-start overflow-y-auto px-4 py-4"
- >
- <div class="w-full px-4 mb-2 flex flex-row justify-between items-center">
- <div class="flex flex-row justify-start items-center">
- <div class="grow flex flex-row justify-start items-center">
- <span class="text-sm mr-2 whitespace-nowrap"
- >{{ $t("common.project") }}:
- </span>
- <n-select
- v-model:value="projectSelectorValue"
- :consistent-menu-width="false"
- :options="projectSelectOptions"
- />
- </div>
- <div class="ml-4">
- <n-input
- v-model:value="sheetSearchValue"
- type="text"
- :placeholder="t('common.search')"
- >
- <template #prefix>
- <heroicons-outline:search class="w-4 h-auto text-gray-300" />
- </template>
- </n-input>
- </div>
- <div class="ml-4">
- <n-button
- v-show="shouldShowClearSearchBtn"
- text
- @click="handleClearSearchBtnClick"
- >
- {{ $t("common.clear-search") }}
- </n-button>
- </div>
- </div>
- <div>
- <n-button
- v-if="selectedProject?.workflow === Workflow.VCS"
- @click="handleSyncSheetFromVCS"
- >
- <heroicons-outline:refresh
- v-if="hasFeature('bb.feature.vcs-sheet-sync')"
- class="w-4 h-auto mr-1"
- />
- <FeatureBadge v-else feature="bb.feature.vcs-sheet-sync" />
- {{ $t("sheet.actions.sync-from-vcs") }}
- </n-button>
- </div>
- </div>
- <div class="w-full">
- <SheetTable
- :view="currentSheetViewMode"
- :sheet-list="shownSheetList"
- :loading="state.isLoading"
- @refresh="fetchSheetData"
- />
- </div>
- </div>
- </div>
-
- <FeatureModal
- feature="bb.feature.vcs-sheet-sync"
- :open="state.showFeatureModal"
- @cancel="state.showFeatureModal = false"
- />
-</template>
-
-<script lang="ts" setup>
-import { last } from "lodash-es";
-import { useDialog } from "naive-ui";
-import { computed, onMounted, reactive, ref, watch } from "vue";
-import { useRoute } from "vue-router";
-import { t } from "@/plugins/i18n";
-import {
- hasFeature,
- useUserStore,
- useSheetV1Store,
- useProjectV1ListByCurrentUser,
- useProjectV1Store,
- useEnvironmentV1Store,
-} from "@/store";
-import { Workflow } from "@/types/proto/v1/project_service";
-import { Sheet } from "@/types/proto/v1/sheet_service";
-import {
- type SheetViewMode,
- SheetTable,
- SheetViewModeList,
-} from "./sql-editor/Sheet";
-
-interface LocalState {
- isLoading: boolean;
- sheetList: Sheet[];
- showFeatureModal: boolean;
-}
-
-const route = useRoute();
-const dialog = useDialog();
-const state = reactive<LocalState>({
- isLoading: true,
- sheetList: [],
- showFeatureModal: false,
-});
-const sheetV1Store = useSheetV1Store();
-
-const projectSelectorValue = ref("");
-const sheetSearchValue = ref("");
-
-const navigationList = computed(() => {
- const list = [
- {
- path: "/sheets/my",
- label: t("sheet.my-sheets"),
- },
- {
- path: "/sheets/shared",
- label: t("sheet.shared-with-me"),
- },
- {
- path: "/sheets/starred",
- label: t("sheet.starred"),
- },
- ];
-
- return list;
-});
-
-const shownSheetList = computed(() => {
- let list = [...state.sheetList];
- const projectName = projectSelectorValue.value;
- if (projectName !== "") {
- list = list.filter((sheet) => sheet.name.startsWith(projectName));
- }
-
- const keyword = sheetSearchValue.value.trim().toLowerCase();
- if (keyword) {
- list = list.filter((sheet) => {
- return (
- sheet.name.toLowerCase().includes(keyword) ||
- new TextDecoder().decode(sheet.content).toLowerCase().includes(keyword)
- );
- });
- }
-
- return list.sort(
- (a, b) =>
- (b.updateTime ?? new Date()).getTime() -
- (a.updateTime ?? new Date()).getTime()
- );
-});
-
-const { projectList } = useProjectV1ListByCurrentUser(false /* !showDeleted */);
-
-const selectedProject = computed(() => {
- for (const project of projectList.value) {
- if (project.uid === projectSelectorValue.value) {
- return project;
- }
- }
-
- return null;
-});
-
-const projectSelectOptions = computed(() => {
- return [
- {
- label: t("common.all"),
- value: "",
- },
- ].concat(
- projectList.value.map((project) => {
- return {
- label: project.title,
- value: project.name,
- };
- })
- );
-});
-
-const shouldShowClearSearchBtn = computed(() => {
- return projectSelectorValue.value !== "" || sheetSearchValue.value !== "";
-});
-
-const currentSheetViewMode = computed((): SheetViewMode => {
- const { path } = route;
- const subPath = (last(path.split("/")) || "my") as SheetViewMode;
- if (SheetViewModeList.includes(subPath)) {
- return subPath;
- }
- return "my";
-});
-
-const fetchSheetData = async () => {
- await useUserStore().fetchUserList();
-
- // TODO: switching view mode very quickly will cause some
- // race condition problems.
- let sheetList: Sheet[] = [];
- if (currentSheetViewMode.value === "my") {
- sheetList = await sheetV1Store.fetchMySheetList();
- } else if (currentSheetViewMode.value === "starred") {
- sheetList = await sheetV1Store.fetchStarredSheetList();
- } else if (currentSheetViewMode.value === "shared") {
- sheetList = await sheetV1Store.fetchSharedSheetList();
- }
-
- state.sheetList = sheetList;
-};
-
-onMounted(async () => {
- // Initialize project list state for iam policy and `project` fields of sheets.
- await useProjectV1Store().fetchProjectList(true /* include archived */);
- // Initialize environment list for composing.
- await useEnvironmentV1Store().fetchEnvironments(true /* include archived */);
- await fetchSheetData();
- state.isLoading = false;
-});
-
-watch(
- () => route.path,
- async () => {
- await fetchSheetData();
- }
-);
-
-const handleClearSearchBtnClick = () => {
- projectSelectorValue.value = "";
- sheetSearchValue.value = "";
-};
-
-const handleSyncSheetFromVCS = () => {
- if (!hasFeature("bb.feature.vcs-sheet-sync")) {
- state.showFeatureModal = true;
- return;
- }
-
- if (
- selectedProject.value === null ||
- selectedProject.value.workflow !== Workflow.VCS
- ) {
- return;
- }
-
- const selectedProjectName = selectedProject.value.name;
- const dialogInstance = dialog.create({
- title: t("sheet.hint-tips.confirm-to-sync-sheet"),
- type: "info",
- autoFocus: false,
- closable: false,
- maskClosable: false,
- closeOnEsc: false,
- async onPositiveClick() {
- dialogInstance.closable = false;
- dialogInstance.loading = true;
- await sheetV1Store.syncSheetFromVCS(selectedProjectName);
- await fetchSheetData();
- dialogInstance.destroy();
- },
- positiveText: t("common.confirm"),
- showIcon: true,
- });
-};
-</script>
-
-<style scoped>
-.active-link {
- @apply bg-gray-100 text-accent;
-}
-</style>
diff --git a/frontend/src/views/sql-editor/EditorHeader.vue b/frontend/src/views/sql-editor/EditorHeader.vue
deleted file mode 100644
index c88fe1747b..0000000000
--- a/frontend/src/views/sql-editor/EditorHeader.vue
+++ /dev/null
@@ -1,223 +0,0 @@
-<template>
- <div class="flex items-center justify-between h-16">
- <div class="flex items-center h-full">
- <BytebaseLogo class="h-full overflow-y-hidden" />
-
- <div class="hidden sm:block">
- <div class="ml-4 flex items-baseline space-x-1">
- <router-link
- to="/sql-editor"
- class="router-link"
- exact-active-class="anchor-link"
- >{{ $t("sql-editor.self") }}</router-link
- >
- <router-link
- to="/sheets/my"
- class="router-link"
- exact-active-class="anchor-link"
- >{{ $t("sheet.self") }}</router-link
- >
- <router-link
- v-if="showAuditLogItem"
- :to="`/setting/audit-log?type=${sqlQueryAction}`"
- class="router-link"
- exact-active-class="anchor-link"
- >{{ $t("settings.sidebar.audit-log") }}</router-link
- >
- </div>
- </div>
- </div>
- <div>
- <div class="flex items-center space-x-3">
- <router-link to="/inbox">
- <span
- v-if="inboxSummary.unread > 0"
- class="absolute rounded-full ml-4 -mt-1 h-2.5 w-2.5 bg-accent opacity-75"
- ></span>
- <heroicons-outline:bell class="w-6 h-6" />
- </router-link>
- <div class="ml-2">
- <ProfileBrandingLogo>
- <ProfileDropdown />
- </ProfileBrandingLogo>
- </div>
- <div class="ml-2 -mr-2 flex sm:hidden">
- <!-- Mobile menu button -->
- <button
- class="icon-link inline-flex items-center justify-center rounded-md"
- @click.prevent="state.showMobileMenu = !state.showMobileMenu"
- >
- <span class="sr-only">Open main menu</span>
- <heroicons-solid:dots-vertical class="w-6 h-6" />
- </button>
- </div>
- </div>
- </div>
- </div>
-
- <!--
- Mobile menu, toggle classes based on menu state.
-
- Open: "block", closed: "hidden"
- -->
- <div v-if="state.showMobileMenu" class="block md:hidden space-y-1 pb-1">
- <router-link
- to="/sql-editor"
- class="bar-link rounded-md block px-3 py-2"
- exact-active-class="anchor-link"
- >
- {{ $t("sql-editor.self") }}
- </router-link>
- <router-link
- to="/sheets/my"
- class="bar-link rounded-md block px-3 py-2"
- exact-active-class="anchor-link"
- >
- {{ $t("sheet.self") }}
- </router-link>
- <router-link
- v-if="showAuditLogItem"
- :to="`/setting/audit-log?type=${sqlQueryAction}`"
- class="bar-link rounded-md block px-3 py-2"
- >
- {{ $t("settings.sidebar.audit-log") }}
- </router-link>
- </div>
-</template>
-
-<script lang="ts">
-import { defineAction, useRegisterActions } from "@bytebase/vue-kbar";
-import { useLocalStorage } from "@vueuse/core";
-import { computed, reactive, watchEffect, defineComponent } from "vue";
-import { useI18n } from "vue-i18n";
-import { useRouter } from "vue-router";
-import BytebaseLogo from "@/components/BytebaseLogo.vue";
-import ProfileBrandingLogo from "@/components/ProfileBrandingLogo.vue";
-import ProfileDropdown from "@/components/ProfileDropdown.vue";
-import { useCurrentUser, useCurrentUserV1, useInboxV1Store } from "@/store";
-import { useSettingV1Store } from "@/store/modules/v1/setting";
-import { UNKNOWN_ID } from "@/types";
-import { LogEntity_Action } from "@/types/proto/v1/logging_service";
-import { hasWorkspacePermissionV1 } from "@/utils";
-
-interface LocalState {
- showMobileMenu: boolean;
-}
-
-export default defineComponent({
- name: "EditorHeader",
- components: { BytebaseLogo, ProfileBrandingLogo, ProfileDropdown },
- setup() {
- const { t, availableLocales, locale } = useI18n();
- const inboxV1Store = useInboxV1Store();
- const settingV1Store = useSettingV1Store();
- const router = useRouter();
-
- const state = reactive<LocalState>({
- showMobileMenu: false,
- });
-
- const currentUser = useCurrentUser();
- const currentUserV1 = useCurrentUserV1();
-
- const logoUrl = computed((): string | undefined => {
- return settingV1Store.brandingLogo;
- });
-
- const showAuditLogItem = computed((): boolean => {
- return hasWorkspacePermissionV1(
- "bb.permission.workspace.audit-log",
- currentUserV1.value.userRole
- );
- });
-
- const prepareInboxSummary = () => {
- // It will also be called when user logout
- if (currentUser.value.id != UNKNOWN_ID) {
- inboxV1Store.fetchInboxSummary();
- }
- };
-
- watchEffect(prepareInboxSummary);
-
- const inboxSummary = computed(() => {
- return inboxV1Store.inboxSummary;
- });
-
- const kbarActions = computed(() => [
- defineAction({
- id: "bb.navigation.inbox",
- name: "Inbox",
- shortcut: ["g", "m"],
- section: t("kbar.navigation"),
- keywords: "navigation",
- perform: () => router.push({ name: "setting.inbox" }),
- }),
- ]);
- useRegisterActions(kbarActions);
-
- const storage = useLocalStorage("bytebase_options", {}) as any;
-
- const setLocale = (lang: string) => {
- locale.value = lang;
- storage.value = {
- appearance: {
- language: lang,
- },
- };
- };
-
- const I18N_CHANGE_ACTION_ID_NAMESPACE = "bb.preferences.locale";
- const i18nChangeAction = computed(() =>
- defineAction({
- // here `id` is "bb.preferences.locale"
- id: I18N_CHANGE_ACTION_ID_NAMESPACE,
- section: t("kbar.preferences.common"),
- name: t("kbar.preferences.change-language"),
- keywords: "language lang locale",
- })
- );
- const i18nActions = computed(() => [
- i18nChangeAction.value,
- ...availableLocales.map((lang) => {
- return defineAction({
- // here `id` looks like "bb.preferences.locale.en"
- id: `${I18N_CHANGE_ACTION_ID_NAMESPACE}.${lang}`,
- name: lang,
- parent: I18N_CHANGE_ACTION_ID_NAMESPACE,
- keywords: `language lang locale ${lang}`,
- perform: () => setLocale(lang),
- });
- }),
- ]);
- useRegisterActions(i18nActions);
-
- const goBack = () => {
- if (window.history.state?.back) {
- router.go(-1);
- } else {
- router.push("/");
- }
- };
-
- return {
- state,
- showAuditLogItem,
- inboxSummary,
- logoUrl,
- goBack,
- sqlQueryAction: LogEntity_Action.ACTION_DATABASE_SQL_EDITOR_QUERY,
- };
- },
-});
-</script>
-
-<style scoped>
-.router-link {
- @apply text-base ml-2 truncate px-2 py-2 rounded-lg no-underline hover:bg-gray-200;
-}
-
-.router-link-active {
- @apply bg-gray-200;
-}
-</style>