Skip to content

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

fix: user id in [GET] /api/issue (#6003)

Liu Ji6e8b3edc9ef0
diff --git a/frontend/src/store/modules/v1/project.ts b/frontend/src/store/modules/v1/project.ts
index ccf6126f45..09bf333651 100644
--- a/frontend/src/store/modules/v1/project.ts
+++ b/frontend/src/store/modules/v1/project.ts
@@ -67,6 +67,15 @@ export const useProjectV1Store = defineStore("project_v1", () => {
}
return fetchProjectByName(name);
};
+ const getOrFetchProjectByUID = async (uid: IdType) => {
+ const cachedData = projectList.value.find(
+ (project) => parseInt(project.uid, 10) === uid
+ );
+ if (cachedData) {
+ return cachedData;
+ }
+ return fetchProjectByUID(uid);
+ };
const createProject = async (project: Project, resourceId: string) => {
const created = await projectServiceClient.createProject({
project,
@@ -106,6 +115,7 @@ export const useProjectV1Store = defineStore("project_v1", () => {
fetchProjectByName,
fetchProjectByUID,
getOrFetchProjectByName,
+ getOrFetchProjectByUID,
createProject,
updateProject,
archiveProject,
@@ -150,6 +160,21 @@ export const useProjectV1ListByUser = (
return { projectList, ready };
};
+export const useProjectV1ByUID = (uid: MaybeRef<IdType>) => {
+ const store = useProjectV1Store();
+ const ready = ref(false);
+ watchEffect(() => {
+ ready.value = false;
+ store.getOrFetchProjectByUID(unref(uid)).then(() => {
+ ready.value = true;
+ });
+ });
+ const project = computed(() => {
+ return store.getProjectByUID(unref(uid));
+ });
+ return { project, ready };
+};
+
const composeProjectIamPolicy = async (project: Project) => {
const policy = await useProjectIamPolicyStore().getOrFetchProjectIamPolicy(
project.name
diff --git a/frontend/src/utils/pipeline.ts b/frontend/src/utils/pipeline.ts
index 98ace03964..57f035436c 100644
--- a/frontend/src/utils/pipeline.ts
+++ b/frontend/src/utils/pipeline.ts
@@ -146,7 +146,10 @@ export function activeTaskInStage(stage: Stage): Task {
return empty("TASK") as Task;
}
-export function activeEnvironment(pipeline: Pipeline): Environment {
+export function activeEnvironment(pipeline: Pipeline | undefined): Environment {
+ if (!pipeline) {
+ return empty("ENVIRONMENT");
+ }
const stage: Stage = activeStage(pipeline);
if (stage.id == EMPTY_ID) {
return empty("ENVIRONMENT") as Environment;
diff --git a/frontend/src/views/Home.vue b/frontend/src/views/Home.vue
index 8a24822cb6..86409a828e 100644
--- a/frontend/src/views/Home.vue
+++ b/frontend/src/views/Home.vue
@@ -101,7 +101,6 @@
session-key="home-closed"
:issue-find="{
statusList: ['DONE', 'CANCELED'],
- principalId: currentUser.id,
}"
:page-size="MAX_CLOSED_ISSUE"
:hide-load-more="true"
diff --git a/frontend/src/views/IssueDashboard.vue b/frontend/src/views/IssueDashboard.vue
index 816300b662..30f10db594 100644
--- a/frontend/src/views/IssueDashboard.vue
+++ b/frontend/src/views/IssueDashboard.vue
@@ -13,6 +13,7 @@
<NInputGroup style="width: auto">
<PrincipalSelect
+ v-if="allowFilterUsers"
:principal="selectedPrincipalId"
:include-system-bot="true"
:include-all="allowSelectAllUsers"
@@ -86,7 +87,7 @@
</template>
<script lang="ts" setup>
-import { reactive, computed } from "vue";
+import { reactive, computed, watchEffect } from "vue";
import { useRoute, useRouter } from "vue-router";
import { NInputGroup, NButton } from "naive-ui";
@@ -108,9 +109,13 @@ import {
activeEnvironment,
hasWorkspacePermission,
isDatabaseRelatedIssueType,
- projectSlug,
+ projectV1Slug,
} from "../utils";
-import { useCurrentUser, useEnvironmentStore, useProjectStore } from "@/store";
+import {
+ useCurrentUser,
+ useEnvironmentStore,
+ useProjectV1Store,
+} from "@/store";
import PagedIssueTable from "@/components/Issue/table/PagedIssueTable.vue";
interface LocalState {
@@ -121,7 +126,7 @@ const router = useRouter();
const route = useRoute();
const currentUser = useCurrentUser();
-const projectStore = useProjectStore();
+const projectV1Store = useProjectV1Store();
const environmentStore = useEnvironmentStore();
const statusList = computed((): string[] =>
@@ -132,6 +137,13 @@ const state = reactive<LocalState>({
searchText: "",
});
+const project = computed(() => {
+ if (selectedProjectId.value) {
+ return projectV1Store.getProjectByUID(selectedProjectId.value);
+ }
+ return undefined;
+});
+
const showOpen = computed(
() => statusList.value.length === 0 || statusList.value.includes("open")
);
@@ -139,6 +151,18 @@ const showClosed = computed(
() => statusList.value.length === 0 || statusList.value.includes("closed")
);
+const allowFilterUsers = computed(() => {
+ if (
+ hasWorkspacePermission(
+ "bb.permission.workspace.manage-issue",
+ currentUser.value.role
+ )
+ ) {
+ return true;
+ }
+ return false;
+});
+
const allowSelectAllUsers = computed(() => {
return hasWorkspacePermission(
"bb.permission.workspace.manage-issue",
@@ -147,6 +171,11 @@ const allowSelectAllUsers = computed(() => {
});
const selectedPrincipalId = computed((): PrincipalId => {
+ if (!allowFilterUsers.value) {
+ // If current user is low-privileged. Don't filter by user id.
+ return UNKNOWN_ID;
+ }
+
const id = parseInt(route.query.user as string, 10);
if (id >= 0) {
return id;
@@ -168,13 +197,6 @@ const selectedProjectId = computed((): ProjectId | undefined => {
return project ? parseInt(project as string, 10) : undefined;
});
-const project = computed(() => {
- if (selectedProjectId.value) {
- return projectStore.getProjectById(selectedProjectId.value);
- }
- return undefined;
-});
-
const filter = (issue: Issue) => {
if (selectedEnvironment.value) {
if (!isDatabaseRelatedIssueType(issue.type)) {
@@ -235,8 +257,14 @@ const goProject = () => {
router.push({
name: "workspace.project.detail",
params: {
- projectSlug: projectSlug(project.value),
+ projectSlug: projectV1Slug(project.value),
},
});
};
+
+watchEffect(() => {
+ if (selectedProjectId.value) {
+ projectV1Store.getOrFetchProjectByUID(selectedProjectId.value);
+ }
+});
</script>