Skip to content

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

fix: list project (#6015)

boojacke1b2188671b5
diff --git a/frontend/src/components/ProjectSelect.vue b/frontend/src/components/ProjectSelect.vue
index ce945c64af..25458f3ca6 100644
--- a/frontend/src/components/ProjectSelect.vue
+++ b/frontend/src/components/ProjectSelect.vue
@@ -15,14 +15,7 @@
</template>
<script lang="ts">
-import {
- computed,
- defineComponent,
- PropType,
- reactive,
- watch,
- watchEffect,
-} from "vue";
+import { computed, defineComponent, PropType, reactive, watch } from "vue";
import {
Project,
UNKNOWN_ID,
@@ -30,7 +23,6 @@ import {
ProjectRoleType,
unknown,
} from "../types";
-import { hasWorkspacePermission } from "../utils";
import { useCurrentUser, useProjectStore } from "@/store";
interface LocalState {
@@ -79,15 +71,6 @@ export default defineComponent({
const currentUser = useCurrentUser();
const projectStore = useProjectStore();
- const prepareProjectList = () => {
- projectStore.fetchProjectListByUser({
- userId: currentUser.value.id,
- rowStatusList: ["NORMAL", "ARCHIVED"],
- });
- };
-
- watchEffect(prepareProjectList);
-
const rawProjectList = computed((): Project[] => {
let list = projectStore.getProjectListByUser(currentUser.value.id, [
"NORMAL",
@@ -104,29 +87,9 @@ export default defineComponent({
return false;
});
- if (
- hasWorkspacePermission(
- "bb.permission.workspace.manage-project",
- currentUser.value.role
- )
- ) {
- return list;
- }
-
return list.filter((project: Project) => {
- if (project.id == DEFAULT_PROJECT_ID) {
- return true;
- }
-
- for (const member of project.memberList) {
- if (
- currentUser.value.id == member.principal.id &&
- props.allowedRoleList.includes(member.role)
- ) {
- return true;
- }
- }
- return false;
+ // Do not show Default project in selector.
+ return project.id != DEFAULT_PROJECT_ID;
});
});
diff --git a/frontend/src/components/ProvideDashboardContext.vue b/frontend/src/components/ProvideDashboardContext.vue
index a30e04034d..e7754a5239 100644
--- a/frontend/src/components/ProvideDashboardContext.vue
+++ b/frontend/src/components/ProvideDashboardContext.vue
@@ -13,7 +13,8 @@ import {
useProjectStore,
useDebugStore,
useUserStore,
- useCurrentUser,
+ useDatabaseStore,
+ useProjectV1Store,
} from "@/store";
import { defineComponent } from "vue";
import { DEFAULT_PROJECT_ID } from "../types";
@@ -22,8 +23,6 @@ import { useEnvironmentV1Store } from "@/store/modules/v1/environment";
export default defineComponent({
name: "ProvideDashboardContext",
async setup() {
- const currentUser = useCurrentUser();
-
await Promise.all([
useSettingStore().fetchSetting(),
// Fetch so MemberSelect can have the data.
@@ -41,9 +40,9 @@ export default defineComponent({
// The default project hosts databases not explicitly assigned to other users project.
useProjectStore().fetchProjectById(DEFAULT_PROJECT_ID),
// For legacy project API support. Remove this after shipping to project v1.
- useProjectStore().fetchProjectListByUser({
- userId: currentUser.value.id,
- }),
+ useProjectStore().fetchAllProjectList(),
+ useProjectV1Store().fetchProjectList(),
+ useDatabaseStore().fetchDatabaseList(),
useUIStateStore().restoreState(),
useDebugStore().fetchDebug(),
]);
diff --git a/frontend/src/main.ts b/frontend/src/main.ts
index 13b8d7a569..6421646039 100644
--- a/frontend/src/main.ts
+++ b/frontend/src/main.ts
@@ -18,10 +18,7 @@ import {
pushNotification,
useActuatorStore,
useAuthStore,
- useDatabaseStore,
useIdentityProviderStore,
- useProjectStore,
- useProjectV1Store,
useSubscriptionStore,
} from "./store";
import {
@@ -173,15 +170,6 @@ const initIdentityProvider = () => {
const idpStore = useIdentityProviderStore();
return idpStore.fetchIdentityProviderList();
};
-const initProjectList = () => {
- const store = useProjectStore();
- const storeV1 = useProjectV1Store();
- return Promise.all([store.fetchProjectList(), storeV1.fetchProjectList()]);
-};
-const initDatabaseList = () => {
- const store = useDatabaseStore();
- return store.fetchDatabaseList();
-};
const restoreUser = () => {
const authStore = useAuthStore();
return authStore.restoreUser();
@@ -191,9 +179,6 @@ Promise.all([
initFeatureMatrix(),
initSubscription(),
initIdentityProvider(),
- // Initial project list and database list in global.
- initProjectList(),
- initDatabaseList(),
restoreUser(),
]).finally(() => {
// Install router after the necessary data fetching is complete.
diff --git a/frontend/src/store/modules/project.ts b/frontend/src/store/modules/project.ts
index 19d7812a32..b2bc0369e2 100644
--- a/frontend/src/store/modules/project.ts
+++ b/frontend/src/store/modules/project.ts
@@ -16,7 +16,6 @@ import {
UNKNOWN_ID,
} from "@/types";
import { getPrincipalFromIncludedList } from "./principal";
-import { isMemberOfProject } from "@/utils";
function convert(
project: ResourceObject,
@@ -105,9 +104,7 @@ export const useProjectStore = defineStore("project", {
(!rowStatusList && project.rowStatus == "NORMAL") ||
(rowStatusList && rowStatusList.includes(project.rowStatus))
) {
- if (isMemberOfProject(project, userId)) {
- result.push(project);
- }
+ result.push(project);
}
}
diff --git a/frontend/src/views/ProjectDashboard.vue b/frontend/src/views/ProjectDashboard.vue
index 8f56140e78..775e631939 100644
--- a/frontend/src/views/ProjectDashboard.vue
+++ b/frontend/src/views/ProjectDashboard.vue
@@ -16,32 +16,29 @@
<script lang="ts" setup>
import { computed, onMounted, reactive } from "vue";
-import {
- useUIStateStore,
- useProjectV1ListByUser,
- useCurrentUserV1,
-} from "@/store";
-import { SearchBox, ProjectV1Table } from "@/components/v2";
+import { useUIStateStore, useProjectV1List } from "@/store";
import { filterProjectV1ListByKeyword } from "@/utils";
+import { DEFAULT_PROJECT_ID } from "@/types";
+import { SearchBox, ProjectV1Table } from "@/components/v2";
interface LocalState {
searchText: string;
}
-const currentUserV1 = useCurrentUserV1();
-
const state = reactive<LocalState>({
searchText: "",
});
-const { projectList } = useProjectV1ListByUser(currentUserV1);
+const { projectList } = useProjectV1List();
const changeSearchText = (searchText: string) => {
state.searchText = searchText;
};
const filteredProjectList = computed(() => {
- const list = projectList.value;
+ const list = projectList.value.filter(
+ (project) => project.uid != String(DEFAULT_PROJECT_ID)
+ );
return filterProjectV1ListByKeyword(list, state.searchText);
});
diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultView.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultView.vue
index e25a801c52..6bddb7ad90 100644
--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultView.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultView.vue
@@ -46,7 +46,9 @@
>
{{ $t("sql-editor.visualize-explain") }}
</NButton>
+ <!-- In enterprise plan, we don't allow export data in SQL editor. -->
<NDropdown
+ v-if="!hasCustomRoleFeature"
trigger="hover"
:options="exportDropdownOptions"
@select="handleExportBtnClick"
@@ -108,7 +110,12 @@ import dayjs from "dayjs";
import type { SingleSQLResult } from "@/types";
import { createExplainToken, instanceHasStructuredQueryResult } from "@/utils";
-import { useInstanceStore, useTabStore, RESULT_ROWS_LIMIT } from "@/store";
+import {
+ useInstanceStore,
+ useTabStore,
+ RESULT_ROWS_LIMIT,
+ featureToRef,
+} from "@/store";
import DataTable from "./DataTable";
import EmptyView from "./EmptyView.vue";
import ErrorView from "./ErrorView.vue";
@@ -159,6 +166,8 @@ const showSearchFeature = computed(() => {
return instanceHasStructuredQueryResult(instance);
});
+const hasCustomRoleFeature = featureToRef("bb.feature.custom-role");
+
// use a debounced value to improve performance when typing rapidly
const keyword = debouncedRef(
computed(() => state.search),