Skip to content

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

Delete shortcut on bookmark sidebar

Tianzhou Chenf33f5e73d343
diff --git a/frontend/src/components/BookmarkListSidePanel.vue b/frontend/src/components/BookmarkListSidePanel.vue
index 2f9255d296..dd784ae315 100644
--- a/frontend/src/components/BookmarkListSidePanel.vue
+++ b/frontend/src/components/BookmarkListSidePanel.vue
@@ -10,22 +10,48 @@
class="mt-2 space-y-1"
role="group"
aria-labelledby="bookmark-headline"
- v-for="item in bookmarkList"
+ v-for="(item, index) in bookmarkList"
:key="item.id"
+ @mouseenter="state.hoverIndex = index"
+ @mouseleave="state.hoverIndex = -1"
>
<router-link
:to="item.link"
- class="sidebar-link group flex items-center px-3 py-1 text-sm"
+ class="sidebar-link group flex justify-between items-center px-3 py-1 text-sm"
>
<span class="truncate">{{ item.name }}</span>
+ <button
+ v-if="index == state.hoverIndex"
+ class="focus:outline-none"
+ @click.prevent="deleteItem(item)"
+ >
+ <svg
+ class="w-4 h-4 hover:text-control-hover"
+ fill="none"
+ stroke="currentColor"
+ viewBox="0 0 24 24"
+ xmlns="http://www.w3.org/2000/svg"
+ >
+ <path
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="2"
+ d="M6 18L18 6M6 6l12 12"
+ ></path>
+ </svg>
+ </button>
</router-link>
</div>
</template>
<script lang="ts">
-import { watchEffect, computed } from "vue";
+interface LocalState {
+ hoverIndex: number;
+}
+
+import { watchEffect, computed, reactive } from "vue";
import { useStore } from "vuex";
-import { User } from "../types";
+import { Bookmark, User } from "../types";
export default {
name: "BookmarkListSidePanel",
@@ -33,6 +59,10 @@ export default {
setup(props, ctx) {
const store = useStore();
+ const state = reactive({
+ hoverIndex: -1,
+ });
+
const currentUser: User = computed(() =>
store.getters["auth/currentUser"]()
).value;
@@ -40,8 +70,17 @@ export default {
const bookmarkList = computed(() =>
store.getters["bookmark/bookmarkListByUser"](currentUser.id)
);
+
+ const deleteItem = (bookmark: Bookmark) => {
+ store.dispatch("bookmark/deleteBookmark", bookmark).catch((error) => {
+ console.log(error);
+ });
+ };
+
return {
+ state,
bookmarkList,
+ deleteItem,
};
},
};