Skip to content

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

User router-link for BBOutline to leverage router-link’s active-class

Tianzhou Chen14e32db61e4e
diff --git a/frontend/src/bbkit/BBOutline.vue b/frontend/src/bbkit/BBOutline.vue
index 0f3bdda71a..4f3833e3ab 100644
--- a/frontend/src/bbkit/BBOutline.vue
+++ b/frontend/src/bbkit/BBOutline.vue
@@ -32,11 +32,11 @@
@mouseenter="state.hoverIndex = index"
@mouseleave="state.hoverIndex = -1"
>
- <div
+ <router-link
+ :to="item.link"
class="outline-item flex justify-between px-3 py-1"
- @click.prevent="$emit('click-index', index)"
>
- <span class="truncate">{{ item }}</span>
+ <span class="truncate">{{ item.name }}</span>
<button
v-if="allowDelete && index == state.hoverIndex"
class="focus:outline-none"
@@ -57,7 +57,7 @@
></path>
</svg>
</button>
- </div>
+ </router-link>
</div>
</div>
</template>
@@ -69,12 +69,17 @@ interface LocalState {
expandState: boolean;
}
+type OutlineItem = {
+ name: string;
+ link: string;
+};
+
import { computed, reactive, PropType } from "vue";
import { useStore } from "vuex";
export default {
name: "BBOutline",
- emits: ["click-index", "delete-index"],
+ emits: ["delete-index"],
props: {
// Used for storing the expand state.
// Empty id means not to store expand state.
@@ -88,7 +93,7 @@ export default {
},
itemList: {
required: true,
- type: Object as PropType<any[]>,
+ type: Object as PropType<OutlineItem[]>,
},
allowDelete: {
default: false,
diff --git a/frontend/src/components/BookmarkListSidePanel.vue b/frontend/src/components/BookmarkListSidePanel.vue
index a7289ace44..b08ecaa88a 100644
--- a/frontend/src/components/BookmarkListSidePanel.vue
+++ b/frontend/src/components/BookmarkListSidePanel.vue
@@ -2,10 +2,13 @@
<BBOutline
:id="'bookmark'"
:title="'Bookmarks'"
- :itemList="bookmarkList.map((item) => item.name)"
+ :itemList="
+ bookmarkList.map((item) => {
+ return { name: item.name, link: item.link };
+ })
+ "
:allowDelete="true"
:allowCollapse="true"
- @click-index="clickIndex"
@delete-index="deleteIndex"
/>
</template>
@@ -14,7 +17,7 @@
import { computed } from "vue";
import { useStore } from "vuex";
import { useRouter } from "vue-router";
-import { Bookmark, User } from "../types";
+import { User } from "../types";
export default {
name: "BookmarkListSidePanel",
@@ -31,10 +34,6 @@ export default {
store.getters["bookmark/bookmarkListByUser"](currentUser.id)
);
- const clickIndex = (index: number) => {
- router.push(bookmarkList.value[index].link);
- };
-
const deleteIndex = (index: number) => {
store
.dispatch("bookmark/deleteBookmark", bookmarkList.value[index])
@@ -45,7 +44,6 @@ export default {
return {
bookmarkList,
- clickIndex,
deleteIndex,
};
},
diff --git a/frontend/src/views/SettingSidebar.vue b/frontend/src/views/SettingSidebar.vue
index 136763467c..bf0106fa7f 100644
--- a/frontend/src/views/SettingSidebar.vue
+++ b/frontend/src/views/SettingSidebar.vue
@@ -104,11 +104,7 @@
Billing
</router-link>
<div class="pl-9 mt-1">
- <BBOutline
- :title="'Integrations'"
- :itemList="integrationList.map((item) => item.name)"
- @click-index="goToIntegration"
- />
+ <BBOutline :title="'Integrations'" :itemList="integrationList" />
</div>
</div>
</div>
@@ -148,18 +144,13 @@ export default {
const integrationList = [
{
name: "Slack",
- path: "/setting/integration/slack",
+ link: "/setting/integration/slack",
},
];
- const goToIntegration = (index: number) => {
- router.push(integrationList[index].path);
- };
-
return {
state,
integrationList,
- goToIntegration,
goBack,
toggleExpand,
};