Skip to content

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

chore: refactor header and sidebar (#9506)

ecmadaof6118bc4c7ac
diff --git a/frontend/src/components/Breadcrumb.vue b/frontend/src/components/Breadcrumb.vue
index 986d649b9a..53d42632d1 100644
--- a/frontend/src/components/Breadcrumb.vue
+++ b/frontend/src/components/Breadcrumb.vue
@@ -271,6 +271,10 @@ export default defineComponent({
path: `/db/${databaseV1Slug(database)}#change-history`,
}
);
+ } else if ((route.name ?? "")?.toString().startsWith("setting.")) {
+ list.push({
+ name: t("common.settings"),
+ });
}
const {
diff --git a/frontend/src/layouts/BodyLayout.vue b/frontend/src/layouts/BodyLayout.vue
index 2c83455977..0cfed69a3b 100644
--- a/frontend/src/layouts/BodyLayout.vue
+++ b/frontend/src/layouts/BodyLayout.vue
@@ -6,7 +6,10 @@
<div v-if="state.showMobileOverlay" class="md:hidden">
<div class="fixed inset-0 flex z-40">
<div class="fixed inset-0">
- <div class="absolute inset-0 bg-gray-600 opacity-75"></div>
+ <div
+ class="absolute inset-0 bg-gray-600 opacity-75"
+ @click.prevent="state.showMobileOverlay = false"
+ ></div>
</div>
<div
tabindex="0"
@@ -25,7 +28,10 @@
</div>
<!-- Mobile Sidebar -->
<div class="flex-1 h-0 py-4 overflow-y-auto">
- <router-view name="leftSidebar" />
+ <router-view
+ name="leftSidebar"
+ @click="state.showMobileOverlay = false"
+ />
</div>
<div
class="flex-shrink-0 flex border-t border-block-border px-3 py-1.5"
@@ -89,7 +95,10 @@
<div class="flex flex-col w-52 bg-control-bg">
<!-- Sidebar component, swap this element with another sidebar if you like -->
<div class="flex-1 flex flex-col py-0 overflow-y-auto">
- <router-view name="leftSidebar" />
+ <router-view
+ name="leftSidebar"
+ @click="state.showMobileOverlay = false"
+ />
</div>
<div
class="flex-shrink-0 flex justify-between border-t border-block-border px-3 py-1.5"
diff --git a/frontend/src/views/DashboardHeader.vue b/frontend/src/views/DashboardHeader.vue
index 190753ffff..d237127dc7 100644
--- a/frontend/src/views/DashboardHeader.vue
+++ b/frontend/src/views/DashboardHeader.vue
@@ -1,43 +1,7 @@
<template>
- <div class="flex items-center justify-between h-10 pl-2 pr-4">
- <div class="flex items-center">
+ <div class="flex items-center justify-between h-10 pl-2 pr-4 space-x-2">
+ <div class="flex-1 flex items-center">
<BytebaseLogo class="block md:hidden" />
-
- <div class="hidden md:block">
- <div class="flex items-baseline space-x-1 whitespace-nowrap">
- <router-link
- to="/project"
- class="bar-link px-2 py-1 rounded-md"
- :class="getRouteLinkClass('/project')"
- data-label="bb-header-project-button"
- >
- {{ $t("common.projects") }}
- </router-link>
-
- <router-link
- to="/db"
- class="bar-link px-2 py-1 rounded-md"
- :class="getRouteLinkClass('/db')"
- data-label="bb-dashboard-header-database-entry"
- >{{ $t("common.databases") }}</router-link
- >
-
- <router-link
- v-if="shouldShowInstanceEntry"
- to="/instance"
- class="bar-link px-2 py-1 rounded-md"
- :class="getRouteLinkClass('/instance')"
- >{{ $t("common.instances") }}</router-link
- >
-
- <router-link
- to="/environment"
- class="bar-link px-2 py-1 rounded-md"
- :class="getRouteLinkClass('/environment')"
- >{{ $t("common.environments") }}</router-link
- >
- </div>
- </div>
</div>
<div>
<div class="flex items-center space-x-3">
@@ -67,49 +31,10 @@
<ProfileDropdown />
</ProfileBrandingLogo>
</div>
- <div class="ml-2 -mr-2 flex md: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>
- <!--
- Heroicon name: menu
-
- Menu open: "hidden", Menu closed: "block"
- -->
- <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">
- <router-link to="/project" class="bar-link rounded-md block px-3 py-1">
- {{ $t("common.projects") }}
- </router-link>
-
- <router-link to="/db" class="bar-link rounded-md block px-3 py-1">
- {{ $t("common.databases") }}
- </router-link>
-
- <router-link to="/instance" class="bar-link rounded-md block px-3 py-1">{{
- $t("common.instances")
- }}</router-link>
-
- <router-link
- to="/environment"
- class="bar-link rounded-md block px-3 py-1"
- >{{ $t("common.environments") }}</router-link
- >
- </div>
<BBModal
v-if="state.showQRCodeModal"
:title="$t('common.want-help')"
@@ -129,12 +54,11 @@ import { Settings } from "lucide-vue-next";
import { storeToRefs } from "pinia";
import { computed, reactive, watchEffect } from "vue";
import { useI18n } from "vue-i18n";
-import { useRoute, useRouter } from "vue-router";
+import { useRouter } from "vue-router";
import {
useCurrentUser,
useSubscriptionV1Store,
useInboxV1Store,
- useCurrentUserV1,
} from "@/store";
import { PlanType } from "@/types/proto/v1/subscription_service";
import BytebaseLogo from "../components/BytebaseLogo.vue";
@@ -142,10 +66,8 @@ import ProfileBrandingLogo from "../components/ProfileBrandingLogo.vue";
import ProfileDropdown from "../components/ProfileDropdown.vue";
import { useLanguage } from "../composables/useLanguage";
import { UNKNOWN_ID } from "../types";
-import { hasWorkspacePermissionV1 } from "../utils";
interface LocalState {
- showMobileMenu: boolean;
showQRCodeModal: boolean;
}
@@ -153,36 +75,16 @@ const { t } = useI18n();
const inboxV1Store = useInboxV1Store();
const subscriptionStore = useSubscriptionV1Store();
const router = useRouter();
-const route = useRoute();
const { locale } = useLanguage();
const state = reactive<LocalState>({
- showMobileMenu: false,
showQRCodeModal: false,
});
const currentUser = useCurrentUser();
-const currentUserV1 = useCurrentUserV1();
const { currentPlan } = storeToRefs(subscriptionStore);
-const getRouteLinkClass = (prefix: string): string[] => {
- const { path } = route;
- const isActiveRoute = path === prefix || path.startsWith(`${prefix}/`);
- const classes: string[] = [];
- if (isActiveRoute) {
- classes.push("router-link-active", "bg-link-hover");
- }
- return classes;
-};
-
-const shouldShowInstanceEntry = computed(() => {
- return hasWorkspacePermissionV1(
- "bb.permission.workspace.manage-instance",
- currentUserV1.value.userRole
- );
-});
-
const prepareInboxSummary = () => {
// It will also be called when user logout
if (currentUser.value.id != UNKNOWN_ID) {
diff --git a/frontend/src/views/DashboardSidebar.vue b/frontend/src/views/DashboardSidebar.vue
index 0ff43a3178..cbd3ee210d 100644
--- a/frontend/src/views/DashboardSidebar.vue
+++ b/frontend/src/views/DashboardSidebar.vue
@@ -27,62 +27,116 @@
class="outline-item group flex items-center px-2 py-1.5 capitalize"
data-label="bb-dashboard-sidebar-home-button"
>
- <heroicons-outline:home class="w-5 h-5 mr-2" />
+ <HomeIcon class="w-5 h-5 mr-2" />
{{ $t("issue.my-issues") }}
</div>
</router-link>
+
+ <router-link to="/project" class="outline-item group flex items-center">
+ <div
+ class="outline-item group flex items-center px-2 py-1.5 capitalize"
+ data-label="bb-dashboard-sidebar-home-button"
+ >
+ <GalleryHorizontalEndIcon class="w-5 h-5 mr-2" />
+ {{ $t("common.projects") }}
+ </div>
+ </router-link>
+
+ <router-link
+ v-if="shouldShowInstanceEntry"
+ to="/instance"
+ class="outline-item group flex items-center"
+ >
+ <div
+ class="outline-item group flex items-center px-2 py-1.5 capitalize"
+ data-label="bb-dashboard-sidebar-home-button"
+ >
+ <LayersIcon class="w-5 h-5 mr-2" />
+ {{ $t("common.instances") }}
+ </div>
+ </router-link>
+
+ <router-link to="/db" class="outline-item group flex items-center">
+ <div
+ class="outline-item group flex items-center px-2 py-1.5 capitalize"
+ data-label="bb-dashboard-sidebar-home-button"
+ >
+ <DatabaseIcon class="w-5 h-5 mr-2" />
+ {{ $t("common.databases") }}
+ </div>
+ </router-link>
+
+ <router-link
+ to="/environment"
+ class="outline-item group flex items-center"
+ >
+ <div
+ class="outline-item group flex items-center px-2 py-1.5 capitalize"
+ data-label="bb-dashboard-sidebar-home-button"
+ >
+ <SquareStackIcon class="w-5 h-5 mr-2" />
+ {{ $t("common.environments") }}
+ </div>
+ </router-link>
+
<router-link
v-if="shouldShowSyncSchemaEntry"
to="/sync-schema"
class="outline-item group flex items-center px-2 py-1.5 capitalize"
>
- <heroicons-outline:refresh class="w-5 h-5 mr-2" />
+ <RefreshCcwIcon class="w-5 h-5 mr-2" />
{{ $t("database.sync-schema.title") }}
</router-link>
<router-link
to="/slow-query"
class="outline-item group flex items-center px-2 py-1.5 capitalize"
>
- <img src="../assets/slow-query.svg" class="w-5 h-auto mr-2" />
+ <TurtleIcon class="w-5 h-auto mr-2" />
{{ $t("slow-query.slow-queries") }}
</router-link>
<router-link
to="/export-center"
class="outline-item group flex items-center px-2 py-1.5 capitalize"
>
- <heroicons-outline:download class="w-5 h-5 mr-2" />
+ <DownloadIcon class="w-5 h-5 mr-2" />
{{ $t("export-center.self") }}
</router-link>
<router-link
to="/anomaly-center"
class="outline-item group flex items-center px-2 py-1.5 capitalize"
>
- <heroicons-outline:shield-exclamation class="w-5 h-5 mr-2" />
+ <ShieldAlertIcon class="w-5 h-5 mr-2" />
{{ $t("anomaly-center") }}
</router-link>
- <div>
- <ProjectListSidePanel />
- </div>
- <div>
- <DatabaseListSidePanel />
- </div>
</div>
</nav>
</template>
<script lang="ts" setup>
import { useKBarHandler } from "@bytebase/vue-kbar";
+import {
+ HomeIcon,
+ DatabaseIcon,
+ TurtleIcon,
+ RefreshCcwIcon,
+ DownloadIcon,
+ ShieldAlertIcon,
+ GalleryHorizontalEndIcon,
+ LayersIcon,
+ SquareStackIcon,
+} from "lucide-vue-next";
import { computed } from "vue";
+import { RouterLink } from "vue-router";
import BytebaseLogo from "@/components/BytebaseLogo.vue";
-import DatabaseListSidePanel from "@/components/DatabaseListSidePanel.vue";
-import ProjectListSidePanel from "@/components/ProjectListSidePanel.vue";
import {
+ useCurrentUserV1,
useCurrentUserIamPolicy,
useProjectV1ListByCurrentUser,
} from "@/store";
+import { hasWorkspacePermissionV1 } from "../utils";
+const currentUserV1 = useCurrentUserV1();
const isMac = navigator.platform.match(/mac/i);
-
const handler = useKBarHandler();
// Only show sync schema if the user has permission to alter schema of at least one project.
@@ -99,4 +153,11 @@ const shouldShowSyncSchemaEntry = computed(() => {
const onClickSearchButton = () => {
handler.value.show();
};
+
+const shouldShowInstanceEntry = computed(() => {
+ return hasWorkspacePermissionV1(
+ "bb.permission.workspace.manage-instance",
+ currentUserV1.value.userRole
+ );
+});
</script>