Skip to content

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

chore: support change project from the header (#9593)

ecmadao91a5a4da7b83
diff --git a/frontend/src/components/Breadcrumb.vue b/frontend/src/components/Breadcrumb.vue
deleted file mode 100644
index 27387b7589..0000000000
--- a/frontend/src/components/Breadcrumb.vue
+++ /dev/null
@@ -1,297 +0,0 @@
-<template>
- <nav
- class="flex flex-row items-center justify-between"
- aria-label="Breadcrumb"
- data-label="bb-breadcrumb"
- >
- <div class="flex flex-row grow items-center">
- <div v-for="(item, index) in breadcrumbList" :key="index">
- <div class="flex items-center space-x-2">
- <router-link
- v-if="index == 0"
- to="/"
- class="text-control-light hover:text-control-light-hover"
- active-class="link"
- exact-active-class="link"
- >
- <!-- Heroicon name: solid/home -->
- <heroicons-solid:home class="flex-shrink-0 h-4 w-4" />
- <span class="sr-only">Home</span>
- </router-link>
- <heroicons-solid:chevron-right
- class="ml-2 flex-shrink-0 h-4 w-4 text-control-light"
- />
- <router-link
- v-if="item.path"
- :to="item.path"
- class="text-sm anchor-link max-w-prose truncate"
- active-class="anchor-link"
- exact-active-class="anchor-link"
- >{{ item.name }}</router-link
- >
- <div v-else class="text-sm max-w-prose truncate">
- {{ item.name }}
- </div>
- <span
- v-if="isTenantProject && index == 1"
- class="flex-shrink-0 h-4 w-4"
- >
- <TenantIcon class="ml-1 text-control" />
- </span>
- </div>
- </div>
- </div>
-
- <NTooltip v-if="helpName">
- <template #trigger>
- <HelpTriggerIcon :id="helpName" class="ml-1" :is-guide="true" />
- </template>
- {{ $t("common.show-help") }}
- </NTooltip>
- </nav>
-</template>
-
-<script lang="ts" setup>
-import { useTitle } from "@vueuse/core";
-import { NTooltip } from "naive-ui";
-import { computed, ComputedRef, watchEffect, ref } from "vue";
-import { useI18n } from "vue-i18n";
-import { useRouter } from "vue-router";
-import HelpTriggerIcon from "@/components/HelpTriggerIcon.vue";
-import TenantIcon from "@/components/TenantIcon.vue";
-import { useRouterStore, useProjectV1Store, useDatabaseV1Store } from "@/store";
-import { RouteMapList } from "@/types";
-import { TenantMode } from "@/types/proto/v1/project_service";
-import { databaseV1Slug, idFromSlug, projectV1Slug } from "../utils";
-
-interface BreadcrumbItem {
- name: string;
- path?: string;
-}
-
-const routerStore = useRouterStore();
-const currentRoute = useRouter().currentRoute;
-const { t } = useI18n();
-const projectV1Store = useProjectV1Store();
-
-const documentTitle = useTitle(null, { observe: true });
-
-const routeHelpNameMapList = ref<RouteMapList>([]);
-const helpName = computed(
- () =>
- routeHelpNameMapList.value.find(
- (pair) => pair.routeName === currentRoute.value.name
- )?.helpName
-);
-
-watchEffect(async () => {
- const res = await fetch("/help/routeMapList.json");
- routeHelpNameMapList.value = await res.json();
-});
-
-const isTenantProject: ComputedRef<boolean> = computed(() => {
- const routeSlug = routerStore.routeSlug(currentRoute.value);
- const projectSlug = routeSlug.projectSlug;
- if (projectSlug === undefined) {
- return false;
- }
- const project = projectV1Store.getProjectByUID(
- String(idFromSlug(projectSlug))
- );
- return project.tenantMode == TenantMode.TENANT_MODE_ENABLED;
-});
-
-const breadcrumbList = computed(() => {
- const route = currentRoute.value;
- const routeSlug = routerStore.routeSlug(currentRoute.value);
- const environmentSlug = routeSlug.environmentSlug;
- const projectSlug = routeSlug.projectSlug;
- const projectWebhookSlug = routeSlug.projectWebhookSlug;
- const instanceSlug = routeSlug.instanceSlug;
- const databaseSlug = routeSlug.databaseSlug;
- const tableName = routeSlug.tableName;
- const vcsSlug = routeSlug.vcsSlug;
- const sqlReviewPolicySlug = routeSlug.sqlReviewPolicySlug;
- const ssoName = routeSlug.ssoName;
-
- const changelistName = routeSlug.changelistName;
- const databaseGroupName = routeSlug.databaseGroupName;
- const schemaGroupName = routeSlug.schemaGroupName;
-
- const list: Array<BreadcrumbItem> = [];
- if (environmentSlug) {
- list.push({
- name: t("common.environments"),
- path: "/environment",
- });
- } else if (projectSlug) {
- list.push({
- name: t("common.projects"),
- path: "/project",
- });
-
- const project = projectV1Store.getProjectByUID(
- String(idFromSlug(projectSlug))
- );
-
- if (projectWebhookSlug) {
- list.push({
- name: `${project.title}`,
- path: `/project/${projectSlug}`,
- });
- } else if (databaseGroupName) {
- list.push(
- {
- name: project.title,
- path: `/project/${projectV1Slug(project)}`,
- },
- {
- name: t("common.database-groups"),
- path: `/project/${projectSlug}#database-groups`,
- }
- );
-
- if (schemaGroupName) {
- list.push(
- {
- name: databaseGroupName,
- path: `/project/${projectSlug}/database-groups/${databaseGroupName}`,
- },
- {
- name: `Tables - ${schemaGroupName}`,
- }
- );
- } else {
- list.push({
- name: databaseGroupName,
- });
- }
- } else if (changelistName) {
- list.push(
- {
- name: project.title,
- path: `/project/${projectV1Slug(project)}`,
- },
- {
- name: t("changelist.self"),
- path: `/project/${projectSlug}#changelists`,
- }
- );
- } else if (route.name === "workspace.branch.detail") {
- list.push(
- {
- name: project.title,
- path: `/project/${projectV1Slug(project)}`,
- },
- {
- name: t("common.branches"),
- path: `/project/${projectV1Slug(project)}#branches`,
- }
- );
- }
- } else if (instanceSlug) {
- list.push({
- name: t("common.instances"),
- path: "/instance",
- });
- } else if (databaseSlug) {
- const database = useDatabaseV1Store().getDatabaseByUID(
- String(idFromSlug(databaseSlug))
- );
-
- list.push(
- {
- name: t("common.projects"),
- path: "/project",
- },
- {
- name: `${database.projectEntity.title}`,
- path: `/project/${projectV1Slug(database.projectEntity)}`,
- },
- {
- name: t("common.databases"),
- path: "/db",
- }
- );
-
- if (tableName) {
- list.push({
- name: database.databaseName,
- path: `/db/${databaseSlug}`,
- });
- }
- } else if (vcsSlug) {
- list.push({
- name: t("common.gitops"),
- path: "/setting/gitops",
- });
- } else if (sqlReviewPolicySlug) {
- list.push({
- name: t("sql-review.title"),
- path: "/setting/sql-review",
- });
- } else if (ssoName) {
- if (route.name !== "setting.workspace.sso.create") {
- list.push({
- name: t("settings.sidebar.sso"),
- path: "/setting/sso",
- });
- }
- }
- if (route.name === "workspace.database.history.detail") {
- const parent = `instances/${route.params.instance}/databases/${route.params.database}`;
- const database = useDatabaseV1Store().getDatabaseByName(parent);
-
- list.push(
- {
- name: t("common.projects"),
- path: "/project",
- },
- {
- name: `${database.projectEntity.title}`,
- path: `/project/${projectV1Slug(database.projectEntity)}`,
- },
- {
- name: t("common.databases"),
- path: "/db",
- },
- {
- name: database.databaseName,
- path: `/db/${databaseV1Slug(database)}`,
- },
- {
- name: t("common.change"),
- path: `/db/${databaseV1Slug(database)}#change-history`,
- }
- );
- } else if ((route.name ?? "")?.toString().startsWith("setting.")) {
- list.push({
- name: t("common.settings"),
- });
- }
-
- const { title: routeTitle, overrideTitle, overrideBreadcrumb } = route.meta;
-
- // Dynamic title priorities
- // 1. documentTitle - if (overrideTitle === true)
- // 2. routeTitle - if (routeTitle !== undefined)
- // 3. nothing - otherwise
- const title = overrideTitle
- ? documentTitle.value ?? ""
- : routeTitle?.(route) ?? "";
- if (title) {
- if (overrideBreadcrumb && overrideBreadcrumb(route)) {
- list.length = 0; // empty the array
- }
- list.push({
- name: title,
- // Set empty path for the current route to make the link not clickable.
- // We do this because clicking the current route path won't trigger reload and would
- // confuse user since UI won't change while we may have cleared all query parameters.
- path: "",
- });
- }
-
- return list;
-});
-</script>
diff --git a/frontend/src/components/IdentityProviderTable.vue b/frontend/src/components/IdentityProviderTable.vue
index c8a45d4187..6117ef7930 100644
--- a/frontend/src/components/IdentityProviderTable.vue
+++ b/frontend/src/components/IdentityProviderTable.vue
@@ -25,7 +25,7 @@
</template>
<script lang="ts" setup>
-import { computed, defineProps } from "vue";
+import { computed } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import { IdentityProvider } from "@/types/proto/v1/idp_service";
diff --git a/frontend/src/components/Project/ProjectGeneralSettingPanel.vue b/frontend/src/components/Project/ProjectGeneralSettingPanel.vue
index 9726187fee..02292d7000 100644
--- a/frontend/src/components/Project/ProjectGeneralSettingPanel.vue
+++ b/frontend/src/components/Project/ProjectGeneralSettingPanel.vue
@@ -9,14 +9,11 @@
{{ $t("common.name") }} <span class="text-red-600">*</span>
</dt>
<dd class="mt-1 text-sm text-main">
- <input
+ <NInput
id="projectName"
- v-model="state.title"
+ v-model:value="state.title"
:disabled="!allowEdit"
required
- autocomplete="off"
- type="text"
- class="textfield"
/>
</dd>
<div class="mt-1">
@@ -40,14 +37,12 @@
<span class="text-red-600">*</span>
</dt>
<dd class="mt-1 text-sm text-main">
- <input
+ <NInput
id="projectKey"
- v-model="state.key"
+ v-model:value="state.key"
:disabled="!allowEdit"
required
- autocomplete="off"
- type="text"
- class="textfield uppercase"
+ @update:value="(val: string) => state.key = val.toUpperCase()"
/>
</dd>
</dl>
diff --git a/frontend/src/components/Project/ProjectSidebar.vue b/frontend/src/components/Project/ProjectSidebar.vue
index aa206bb902..989283e042 100644
--- a/frontend/src/components/Project/ProjectSidebar.vue
+++ b/frontend/src/components/Project/ProjectSidebar.vue
@@ -9,7 +9,7 @@
<script setup lang="ts">
import { defineAction, useRegisterActions } from "@bytebase/vue-kbar";
-import { computedAsync, useLocalStorage } from "@vueuse/core";
+import { useLocalStorage } from "@vueuse/core";
import { startCase } from "lodash-es";
import {
Database,
@@ -25,22 +25,12 @@ import { computed, VNode, h, reactive, watch, nextTick } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter, useRoute } from "vue-router";
import { SidebarItem } from "@/components/CommonSidebar.vue";
-import {
- useCurrentUserIamPolicy,
- useProjectV1Store,
- useDatabaseV1Store,
- experimentalFetchIssueByUID,
-} from "@/store";
-import {
- DEFAULT_PROJECT_V1_NAME,
- unknownProject,
- unknownDatabase,
- UNKNOWN_ID,
- EMPTY_ID,
-} from "@/types";
+import { useCurrentUserIamPolicy } from "@/store";
+import { DEFAULT_PROJECT_V1_NAME } from "@/types";
import { TenantMode } from "@/types/proto/v1/project_service";
-import { idFromSlug, projectSlugV1 } from "@/utils";
+import { projectSlugV1 } from "@/utils";
import { useProjectDatabaseActions } from "../KBar/useDatabaseActions";
+import { useCurrentProject } from "./useCurrentProject";
const projectHashList = [
"databases",
@@ -81,26 +71,6 @@ const props = defineProps<{
}>();
const route = useRoute();
-const database = computed(() => {
- if (props.changeHistorySlug) {
- const parent = `instances/${route.params.instance}/databases/${route.params.database}`;
- return useDatabaseV1Store().getDatabaseByName(parent);
- } else if (props.databaseSlug) {
- return useDatabaseV1Store().getDatabaseByUID(
- String(idFromSlug(props.databaseSlug))
- );
- }
- return unknownDatabase();
-});
-
-const cachedLastPage = useLocalStorage<ProjectHash>(
- `bb.project.${props.projectSlug}.page`,
- "databases"
-);
-
-const defaultHash = computed((): ProjectHash => {
- return cachedLastPage.value;
-});
interface LocalState {
selectedHash: ProjectHash;
@@ -108,45 +78,44 @@ interface LocalState {
const { t } = useI18n();
const router = useRouter();
-const projectV1Store = useProjectV1Store();
const state = reactive<LocalState>({
- selectedHash: defaultHash.value,
+ selectedHash: "databases",
+});
+
+const params = computed(() => {
+ return {
+ projectSlug: props.projectSlug,
+ issueSlug: props.issueSlug,
+ databaseSlug: props.databaseSlug,
+ changeHistorySlug: props.changeHistorySlug,
+ };
+});
+
+const { project } = useCurrentProject(params);
+
+const cachedLastPage = computed(() => {
+ const cache = useLocalStorage<ProjectHash>(
+ `bb.project.${projectSlugV1(project.value)}.page`,
+ "databases"
+ );
+ return cache;
+});
+
+const defaultHash = computed((): ProjectHash => {
+ return cachedLastPage.value.value;
});
watch(
() => state.selectedHash,
- (hash) => (cachedLastPage.value = hash)
+ (hash) => (cachedLastPage.value.value = hash)
);
-const issueUID = computed(() => {
- const slug = props.issueSlug;
- if (!slug) return String(UNKNOWN_ID);
- if (props.issueSlug.toLowerCase() === "new") return String(EMPTY_ID);
- const uid = Number(idFromSlug(slug));
- if (uid > 0) return String(uid);
- return String(UNKNOWN_ID);
-});
-
-const project = computedAsync(async () => {
- if (issueUID.value !== String(UNKNOWN_ID)) {
- if (issueUID.value === String(EMPTY_ID)) {
- const projectUID = route.query.project as string;
- if (!projectUID) return unknownProject();
- return await useProjectV1Store().getOrFetchProjectByUID(projectUID);
- }
+watch(
+ () => cachedLastPage.value,
+ (cache) => (state.selectedHash = cache.value)
+);
- const existedIssue = await experimentalFetchIssueByUID(issueUID.value);
- return existedIssue.projectEntity;
- } else if (props.projectSlug) {
- return projectV1Store.getProjectByUID(
- String(idFromSlug(props.projectSlug))
- );
- } else if (props.databaseSlug || props.changeHistorySlug) {
- return database.value.projectEntity;
- }
- return unknownProject();
-}, unknownProject());
const currentUserIamPolicy = useCurrentUserIamPolicy();
const isDefaultProject = computed((): boolean => {
diff --git a/frontend/src/components/Project/ProjectSwitchModal.vue b/frontend/src/components/Project/ProjectSwitchModal.vue
new file mode 100644
index 0000000000..5db13d16e9
--- /dev/null
+++ b/frontend/src/components/Project/ProjectSwitchModal.vue
@@ -0,0 +1,75 @@
+<template>
+ <BBModal
+ :close-on-esc="true"
+ :mask-closable="true"
+ :trap-focus="false"
+ :title="$t('project.select')"
+ class="w-[48rem] max-w-full h-128 max-h-full"
+ @close="$emit('dismiss')"
+ >
+ <div class="space-y-2 my-4">
+ <div class="w-full sticky top-0 mb-4">
+ <div class="flex items-center justify-between space-x-2">
+ <SearchBox
+ v-model:value="state.searchText"
+ :placeholder="$t('common.filter-by-name')"
+ :autofocus="false"
+ style="flex: 1 1 0%"
+ />
+ <NButton @click="state.showCreateDrawer = true">
+ {{ $t("quick-action.new-project") }}
+ </NButton>
+ </div>
+ </div>
+ <ProjectV1Table
+ :project-list="filteredProjectList"
+ class="border"
+ @click="$emit('dismiss')"
+ />
+ </div>
+ </BBModal>
+ <Drawer
+ :auto-focus="true"
+ :close-on-esc="true"
+ :show="state.showCreateDrawer"
+ @close="state.showCreateDrawer = false"
+ >
+ <ProjectCreatePanel @dismiss="onCreate" />
+ </Drawer>
+</template>
+
+<script lang="ts" setup>
+import { computed, reactive } from "vue";
+import { SearchBox, ProjectV1Table } from "@/components/v2";
+import { Drawer } from "@/components/v2";
+import { useProjectV1ListByCurrentUser } from "@/store";
+import { DEFAULT_PROJECT_ID } from "@/types";
+import { filterProjectV1ListByKeyword } from "@/utils";
+
+interface LocalState {
+ searchText: string;
+ showCreateDrawer: boolean;
+}
+
+const emit = defineEmits<{
+ (event: "dismiss"): void;
+}>();
+
+const state = reactive<LocalState>({
+ searchText: "",
+ showCreateDrawer: false,
+});
+const { projectList } = useProjectV1ListByCurrentUser();
+
+const filteredProjectList = computed(() => {
+ const list = projectList.value.filter(
+ (project) => project.uid !== String(DEFAULT_PROJECT_ID)
+ );
+ return filterProjectV1ListByKeyword(list, state.searchText);
+});
+
+const onCreate = () => {
+ state.showCreateDrawer = false;
+ emit("dismiss");
+};
+</script>
diff --git a/frontend/src/components/Project/useCurrentProject.ts b/frontend/src/components/Project/useCurrentProject.ts
new file mode 100644
index 0000000000..15aaf74b2f
--- /dev/null
+++ b/frontend/src/components/Project/useCurrentProject.ts
@@ -0,0 +1,66 @@
+import { computedAsync } from "@vueuse/core";
+import { computed, unref, ComputedRef } from "vue";
+import { useRoute } from "vue-router";
+import {
+ useProjectV1Store,
+ useDatabaseV1Store,
+ experimentalFetchIssueByUID,
+} from "@/store";
+import { unknownProject, unknownDatabase, UNKNOWN_ID, EMPTY_ID } from "@/types";
+import { idFromSlug } from "@/utils";
+
+export const useCurrentProject = (
+ params: ComputedRef<{
+ projectSlug?: string;
+ issueSlug?: string;
+ databaseSlug?: string;
+ changeHistorySlug?: string;
+ }>
+) => {
+ const route = useRoute();
+
+ const issueUID = computed(() => {
+ const slug = unref(params).issueSlug;
+ if (!slug) return String(UNKNOWN_ID);
+ if (slug.toLowerCase() === "new") return String(EMPTY_ID);
+ const uid = Number(idFromSlug(slug));
+ if (uid > 0) return String(uid);
+ return String(UNKNOWN_ID);
+ });
+
+ const database = computed(() => {
+ if (unref(params).changeHistorySlug) {
+ const parent = `instances/${route.params.instance}/databases/${route.params.database}`;
+ return useDatabaseV1Store().getDatabaseByName(parent);
+ } else if (unref(params).databaseSlug) {
+ return useDatabaseV1Store().getDatabaseByUID(
+ String(idFromSlug(unref(params).databaseSlug!))
+ );
+ }
+ return unknownDatabase();
+ });
+
+ const project = computedAsync(async () => {
+ if (issueUID.value !== String(UNKNOWN_ID)) {
+ if (issueUID.value === String(EMPTY_ID)) {
+ const projectUID = route.query.project as string;
+ if (!projectUID) return unknownProject();
+ return await useProjectV1Store().getOrFetchProjectByUID(projectUID);
+ }
+
+ const existedIssue = await experimentalFetchIssueByUID(issueUID.value);
+ return existedIssue.projectEntity;
+ } else if (unref(params).projectSlug) {
+ return useProjectV1Store().getProjectByUID(
+ String(idFromSlug(unref(params).projectSlug!))
+ );
+ } else if (unref(params).databaseSlug || unref(params).changeHistorySlug) {
+ return database.value.projectEntity;
+ }
+ return unknownProject();
+ }, unknownProject());
+
+ return {
+ project,
+ };
+};
diff --git a/frontend/src/components/v2/Model/DatabaseV1Table/ProjectCol.vue b/frontend/src/components/v2/Model/DatabaseV1Table/ProjectCol.vue
index 211e647e2e..3916dbf75d 100644
--- a/frontend/src/components/v2/Model/DatabaseV1Table/ProjectCol.vue
+++ b/frontend/src/components/v2/Model/DatabaseV1Table/ProjectCol.vue
@@ -26,14 +26,6 @@
{{ $t("database.gitops-enabled") }}
</span>
</NTooltip>
- <svg
- v-else-if="project.workflow === Workflow.UI"
- class="w-4 h-4"
- fill="none"
- stroke="currentColor"
- viewBox="0 0 24 24"
- xmlns="http://www.w3.org/2000/svg"
- ></svg>
<NTooltip v-if="project.state === State.DELETED">
<template #trigger>
diff --git a/frontend/src/components/v2/Model/ProjectV1Table.vue b/frontend/src/components/v2/Model/ProjectV1Table.vue
index 884aeb7aa2..065b745de2 100644
--- a/frontend/src/components/v2/Model/ProjectV1Table.vue
+++ b/frontend/src/components/v2/Model/ProjectV1Table.vue
@@ -24,7 +24,7 @@
</template>
<script lang="ts" setup>
-import { PropType, computed } from "vue";
+import { computed } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import { BBGridColumn, BBGridRow, BBGrid } from "@/bbkit";
@@ -33,12 +33,13 @@ import { projectV1Slug } from "@/utils";
export type ProjectGridRow = BBGridRow<Project>;
-defineProps({
- projectList: {
- required: true,
- type: Object as PropType<Project[]>,
- },
-});
+defineProps<{
+ projectList: Project[];
+}>();
+
+const emit = defineEmits<{
+ (event: "click"): void;
+}>();
const router = useRouter();
const { t } = useI18n();
@@ -65,5 +66,6 @@ const clickProject = function (
} else {
router.push(url);
}
+ emit("click");
};
</script>
diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts
index 3f8aff3019..2491ce1452 100644
--- a/frontend/src/router/index.ts
+++ b/frontend/src/router/index.ts
@@ -664,14 +664,6 @@ const routes: Array<RouteRecordRaw> = [
path: "",
name: "workspace.project.detail",
meta: {
- overrideBreadcrumb: (route: RouteLocationNormalized) => {
- const slug = route.params.projectSlug as string;
- const projectId = idFromSlug(slug);
- if (projectId === DEFAULT_PROJECT_ID) {
- return true;
- }
- return false;
- },
title: (route: RouteLocationNormalized) => {
const slug = route.params.projectSlug as string;
const projectId = idFromSlug(slug);
diff --git a/frontend/src/shims-vue-router.d.ts b/frontend/src/shims-vue-router.d.ts
index 28a819b70d..6e7c0e519b 100644
--- a/frontend/src/shims-vue-router.d.ts
+++ b/frontend/src/shims-vue-router.d.ts
@@ -8,7 +8,6 @@ declare module "vue-router" {
quickActionListByRole?: (
route: RouteLocationNormalized
) => Map<RoleType, QuickActionType[]>;
- overrideBreadcrumb?: (route: RouteLocationNormalized) => boolean;
overrideTitle?: boolean;
}
}
diff --git a/frontend/src/views/DashboardHeader.vue b/frontend/src/views/DashboardHeader.vue
index 37278b895b..90710d68da 100644
--- a/frontend/src/views/DashboardHeader.vue
+++ b/frontend/src/views/DashboardHeader.vue
@@ -2,13 +2,26 @@
<div class="flex items-center justify-between h-10 pl-2 pr-4 space-x-3">
<div class="flex items-center">
<BytebaseLogo class="block md:hidden" />
- <div v-if="showBreadcrumb" class="hidden md:block">
- <Breadcrumb />
+
+ <div
+ class="hidden sm:flex max-w-full w-64 px-2 py-0.5 border border-control-border text-sm rounded-sm items-center justify-between hover:bg-control-bg-hover cursor-pointer ml-2 space-x-2"
+ @click="state.showProjectModal = true"
+ >
+ <ProjectCol
+ v-if="project.uid !== `${UNKNOWN_ID}`"
+ mode="ALL_SHORT"
+ :project="project"
+ :show-tenant-icon="true"
+ />
+ <div v-else class="text-control-placeholder text-sm">
+ {{ $t("project.select") }}
+ </div>
+ <ChevronDownIcon class="h-6 text-gray-400" />
</div>
</div>
<div class="flex-1 flex justify-end items-center space-x-3">
<button
- class="hidden w-full max-w-xs md:flex items-center justify-between rounded-md border border-control-border bg-white hover:bg-control-bg-hover pl-2 pr-1 py-0.5 outline-none"
+ class="hidden w-full max-w-xs md:flex items-center justify-between rounded-sm border border-control-border bg-white hover:bg-control-bg-hover pl-2 pr-1 py-0.5 outline-none"
@click="onClickSearchButton"
>
<span class="text-control-placeholder text-sm">
@@ -16,7 +29,7 @@
</span>
<span class="flex items-center space-x-1">
<kbd
- class="h-5 flex items-center justify-center bg-black bg-opacity-10 rounded text-sm px-1 text-control overflow-y-hidden"
+ class="h-6 flex items-center justify-center bg-black bg-opacity-10 rounded text-sm px-1 text-control overflow-y-hidden"
>
<span v-if="isMac" class="text-xl px-0.5">⌘</span>
<span v-else class="tracking-tighter transform scale-x-90">
@@ -66,16 +79,22 @@
alt="bb_helper"
/>
</BBModal>
+
+ <ProjectSwitchModal
+ v-if="state.showProjectModal"
+ @dismiss="state.showProjectModal = false"
+ />
</template>
<script lang="ts" setup>
import { defineAction, useRegisterActions } from "@bytebase/vue-kbar";
import { useKBarHandler } from "@bytebase/vue-kbar";
-import { Settings } from "lucide-vue-next";
+import { Settings, ChevronDownIcon } from "lucide-vue-next";
import { storeToRefs } from "pinia";
import { computed, reactive, watchEffect } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
+import { useCurrentProject } from "@/components/Project/useCurrentProject";
import {
useSubscriptionV1Store,
useInboxV1Store,
@@ -91,6 +110,7 @@ import { UNKNOWN_ID } from "../types";
interface LocalState {
showQRCodeModal: boolean;
+ showProjectModal: boolean;
}
const { t } = useI18n();
@@ -101,13 +121,21 @@ const { locale } = useLanguage();
const state = reactive<LocalState>({
showQRCodeModal: false,
+ showProjectModal: false,
});
-const showBreadcrumb = computed(() => {
- const name = router.currentRoute.value.name;
- return !(name === "workspace.home" || name === "workspace.profile");
+const params = computed(() => {
+ const route = router.currentRoute.value;
+ return {
+ projectSlug: route.params.projectSlug as string,
+ issueSlug: route.params.issueSlug as string,
+ databaseSlug: route.params.databaseSlug as string,
+ changeHistorySlug: route.params.changeHistorySlug as string,
+ };
});
+const { project } = useCurrentProject(params);
+
const isMac = navigator.platform.match(/mac/i);
const handler = useKBarHandler();
const onClickSearchButton = () => {
diff --git a/frontend/src/views/DatabaseDetail.vue b/frontend/src/views/DatabaseDetail.vue
index 3cfcbf52da..75960c736c 100644
--- a/frontend/src/views/DatabaseDetail.vue
+++ b/frontend/src/views/DatabaseDetail.vue
@@ -331,15 +331,12 @@ const currentUserIamPolicy = useCurrentUserIamPolicy();
watch(
() => route.hash,
(hash) => {
- let targetHash = hash.replace(/^#?/g, "") as DatabaseHash;
- if (!isDatabaseHash(targetHash)) {
- targetHash = "overview";
+ const targetHash = hash.replace(/^#?/g, "") as DatabaseHash;
+ if (isDatabaseHash(targetHash)) {
+ state.selectedTab = targetHash;
}
- state.selectedTab = targetHash;
},
- {
- immediate: true,
- }
+ { immediate: true }
);
watch(