Skip to content

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

Add the ProjectListSidePanel

天舟cc9349be331f
diff --git a/frontend/src/components/ProjectListSidePanel.vue b/frontend/src/components/ProjectListSidePanel.vue
new file mode 100644
index 0000000000..5a8c479805
--- /dev/null
+++ b/frontend/src/components/ProjectListSidePanel.vue
@@ -0,0 +1,64 @@
+<template>
+ <BBOutline
+ :id="'project'"
+ :title="'Projects'"
+ :itemList="outlineItemList"
+ :allowCollapse="false"
+ />
+</template>
+
+<script lang="ts">
+import { computed, reactive, watchEffect } from "vue";
+import { useStore } from "vuex";
+
+import { Project } from "../types";
+import { projectSlug } from "../utils";
+import { BBOutlineItem } from "../bbkit/types";
+
+interface LocalState {
+ projectList: Project[];
+}
+
+export default {
+ name: "ProjectListSidePanel",
+ props: {},
+ setup(props, ctx) {
+ const store = useStore();
+
+ const state = reactive<LocalState>({
+ projectList: [],
+ });
+
+ const currentUser = computed(() => store.getters["auth/currentUser"]());
+
+ const prepareProjectList = () => {
+ store
+ .dispatch("project/fetchProjectListByUser", currentUser.value.id)
+ .then((projectList: Project[]) => {
+ state.projectList = projectList;
+ })
+ .catch((error) => {
+ console.log(error);
+ });
+ };
+
+ const outlineItemList = computed((): BBOutlineItem[] => {
+ return state.projectList.map(
+ (item: Project): BBOutlineItem => {
+ return {
+ id: item.id,
+ name: item.name,
+ link: `/project/${projectSlug(item)}`,
+ };
+ }
+ );
+ });
+
+ watchEffect(prepareProjectList);
+
+ return {
+ outlineItemList,
+ };
+ },
+};
+</script>
diff --git a/frontend/src/views/DashboardSidebar.vue b/frontend/src/views/DashboardSidebar.vue
index e92a39e706..7aa72ab2e5 100644
--- a/frontend/src/views/DashboardSidebar.vue
+++ b/frontend/src/views/DashboardSidebar.vue
@@ -44,6 +44,9 @@
<div>
<BookmarkListSidePanel />
</div>
+ <div class="mt-1">
+ <ProjectListSidePanel />
+ </div>
<div class="mt-1">
<DatabaseListSidePanel :mode="'Owner'" />
</div>
@@ -57,6 +60,7 @@
import { computed } from "vue";
import { useStore } from "vuex";
import BookmarkListSidePanel from "../components/BookmarkListSidePanel.vue";
+import ProjectListSidePanel from "../components/ProjectListSidePanel.vue";
import DatabaseListSidePanel from "../components/DatabaseListSidePanel.vue";
import { Message } from "../types";
@@ -69,6 +73,7 @@ export default {
props: {},
components: {
BookmarkListSidePanel,
+ ProjectListSidePanel,
DatabaseListSidePanel,
},
setup(props, ctx) {