Skip to content

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

Support project in the /issue query parameter

天舟593ace74c365
diff --git a/frontend/src/components/ProjectOverviewPanel.vue b/frontend/src/components/ProjectOverviewPanel.vue
index 34cd674d55..3314bf813f 100644
--- a/frontend/src/components/ProjectOverviewPanel.vue
+++ b/frontend/src/components/ProjectOverviewPanel.vue
@@ -19,6 +19,12 @@
},
]"
/>
+ <router-link
+ :to="`/issue?status=closed&project=${project.id}`"
+ class="mt-2 flex justify-end normal-link"
+ >
+ View all closed
+ </router-link>
</div>
</div>
</template>
@@ -77,7 +83,9 @@ export default {
const prepareIssueList = () => {
store
- .dispatch("issue/fetchIssueListForProject", props.project.id)
+ .dispatch("issue/fetchIssueList", {
+ projectId: props.project.id,
+ })
.then((issueList: Issue[]) => {
state.progressIssueList = [];
state.closedIssueList = [];
diff --git a/frontend/src/store/modules/issue.ts b/frontend/src/store/modules/issue.ts
index 48b220b482..7aa706beee 100644
--- a/frontend/src/store/modules/issue.ts
+++ b/frontend/src/store/modules/issue.ts
@@ -75,21 +75,36 @@ const getters = {
};
const actions = {
- async fetchIssueListForUser(
+ async fetchIssueList(
{ rootGetters }: any,
{
- userId,
issueStatusList,
+ userId,
+ projectId,
limit,
}: {
- userId: PrincipalId;
- issueStatusList: IssueStatus[];
+ issueStatusList?: IssueStatus[];
+ userId?: PrincipalId;
+ projectId?: ProjectId;
limit?: number;
}
) {
- var url = `/api/issue?user=${userId}&status=${issueStatusList.join(",")}`;
+ var queryList = [];
+ if (issueStatusList) {
+ queryList.push(`status=${issueStatusList.join(",")}`);
+ }
+ if (userId) {
+ queryList.push(`user=${userId}`);
+ }
+ if (projectId) {
+ queryList.push(`project=${projectId}`);
+ }
if (limit) {
- url += `&limit=${limit}`;
+ queryList.push(`limit=${limit}`);
+ }
+ var url = "/api/issue";
+ if (queryList.length > 0) {
+ url += `?${queryList.join("&")}`;
}
const data = (await axios.get(url)).data;
const issueList = data.data.map((issue: ResourceObject) => {
@@ -100,16 +115,6 @@ const actions = {
return issueList;
},
- async fetchIssueListForProject({ rootGetters }: any, projectId: ProjectId) {
- const data = (await axios.get(`/api/issue?project=${projectId}`)).data;
- const issueList = data.data.map((issue: ResourceObject) => {
- return convert(issue, data.included, rootGetters);
- });
-
- // The caller consumes directly, so we don't store it.
- return issueList;
- },
-
async fetchIssueById({ commit, rootGetters }: any, issueId: IssueId) {
const data = (await axios.get(`/api/issue/${issueId}`)).data;
const issue = convert(data.data, data.included, rootGetters);
diff --git a/frontend/src/views/Home.vue b/frontend/src/views/Home.vue
index 0ca5fdc79b..e3375664c1 100644
--- a/frontend/src/views/Home.vue
+++ b/frontend/src/views/Home.vue
@@ -104,9 +104,9 @@ export default {
// It will also be called when user logout
if (currentUser.value.id != UNKNOWN_ID) {
store
- .dispatch("issue/fetchIssueListForUser", {
- userId: currentUser.value.id,
+ .dispatch("issue/fetchIssueList", {
issueStatusList: ["OPEN"],
+ userId: currentUser.value.id,
})
.then((issueList: Issue[]) => {
state.assignedList = [];
@@ -126,9 +126,9 @@ export default {
});
store
- .dispatch("issue/fetchIssueListForUser", {
- userId: currentUser.value.id,
+ .dispatch("issue/fetchIssueList", {
issueStatusList: ["DONE", "CANCELED"],
+ userId: currentUser.value.id,
limit: MAX_CLOSED_ISSUE_COUNT,
})
.then((issueList: Issue[]) => {
diff --git a/frontend/src/views/IssueDashboard.vue b/frontend/src/views/IssueDashboard.vue
index 66d12e187a..e59331e592 100644
--- a/frontend/src/views/IssueDashboard.vue
+++ b/frontend/src/views/IssueDashboard.vue
@@ -8,6 +8,7 @@
/>
<div class="flex flex-row space-x-4">
<MemberSelect
+ v-if="scopeByPrincipal"
:selectedId="state.selectedPrincipalId"
@select-principal-id="selectPrincipal"
/>
@@ -35,7 +36,7 @@ import { useStore } from "vuex";
import EnvironmentTabFilter from "../components/EnvironmentTabFilter.vue";
import IssueTable from "../components/IssueTable.vue";
import MemberSelect from "../components/MemberSelect.vue";
-import { Environment, Issue, PrincipalId, UNKNOWN_ID } from "../types";
+import { Environment, Issue, PrincipalId, ProjectId } from "../types";
import { computed, onMounted, watchEffect } from "@vue/runtime-core";
import { activeEnvironment } from "../utils";
import { BBTableSectionDataSource } from "../bbkit/types";
@@ -46,8 +47,9 @@ interface LocalState {
openList: Issue[];
closedList: Issue[];
searchText: string;
- selectedEnvironment?: Environment;
selectedPrincipalId: PrincipalId;
+ selectedEnvironment?: Environment;
+ selectedProjectId?: ProjectId;
}
export default {
@@ -71,12 +73,15 @@ export default {
openList: [],
closedList: [],
searchText: "",
+ selectedPrincipalId: currentUser.value.id,
selectedEnvironment: router.currentRoute.value.query.environment
? store.getters["environment/environmentById"](
router.currentRoute.value.query.environment
)
: undefined,
- selectedPrincipalId: currentUser.value.id,
+ selectedProjectId: router.currentRoute.value.query.project
+ ? parseInt(router.currentRoute.value.query.project as string)
+ : undefined,
});
onMounted(() => {
@@ -84,14 +89,26 @@ export default {
searchField.value.$el.querySelector("#search").focus();
});
+ // Applies principal scope if we explicitly specify user in the query parameter
+ // or project is NOT present in the query parameter.
+ // In other words, if only project is present in the query parameter, then
+ // we do NOT apply principal scope, which is the case if we want to list all issues
+ // for a particular project.
+ const scopeByPrincipal = computed(() => {
+ return router.currentRoute.value.query.user || !state.selectedProjectId;
+ });
+
const prepareIssueList = () => {
// We call open and close separately because normally the number of open issues is limited
// while the closed issues could be a lot.
if (state.showOpen) {
store
- .dispatch("issue/fetchIssueListForUser", {
- userId: state.selectedPrincipalId,
+ .dispatch("issue/fetchIssueList", {
issueStatusList: ["OPEN"],
+ userId: scopeByPrincipal.value
+ ? state.selectedPrincipalId
+ : undefined,
+ projectId: state.selectedProjectId,
})
.then((issueList: Issue[]) => {
state.openList = issueList;
@@ -100,60 +117,21 @@ export default {
if (state.showClosed) {
store
- .dispatch("issue/fetchIssueListForUser", {
- userId: state.selectedPrincipalId,
+ .dispatch("issue/fetchIssueList", {
issueStatusList: ["DONE", "CANCELED"],
+ userId: scopeByPrincipal.value
+ ? state.selectedPrincipalId
+ : undefined,
+ projectId: state.selectedProjectId,
})
.then((issueList: Issue[]) => {
- state.closedList = [];
- for (const issue of issueList) {
- // "DONE" or "CANCELED"
- if (issue.status === "DONE" || issue.status === "CANCELED") {
- if (
- issue.creator.id === state.selectedPrincipalId ||
- issue.assignee?.id === state.selectedPrincipalId ||
- issue.subscriberIdList.includes(state.selectedPrincipalId)
- ) {
- state.closedList.push(issue);
- }
- }
- }
+ state.closedList = issueList;
});
}
};
watchEffect(prepareIssueList);
- const selectEnvironment = (environment: Environment) => {
- state.selectedEnvironment = environment;
- if (environment) {
- router.replace({
- name: "workspace.issue",
- query: {
- ...router.currentRoute.value.query,
- environment: environment.id,
- },
- });
- } else {
- router.replace({ name: "workspace.issue" });
- }
- };
-
- const selectPrincipal = (principalId: PrincipalId) => {
- state.selectedPrincipalId = principalId;
- router.replace({
- name: "workspace.issue",
- query: {
- ...router.currentRoute.value.query,
- user: principalId,
- },
- });
- };
-
- const changeSearchText = (searchText: string) => {
- state.searchText = searchText;
- };
-
const filteredList = (list: Issue[]) => {
if (!state.selectedEnvironment && !state.searchText) {
// Select "All"
@@ -191,9 +169,40 @@ export default {
return list;
});
+ const selectEnvironment = (environment: Environment) => {
+ state.selectedEnvironment = environment;
+ if (environment) {
+ router.replace({
+ name: "workspace.issue",
+ query: {
+ ...router.currentRoute.value.query,
+ environment: environment.id,
+ },
+ });
+ } else {
+ router.replace({ name: "workspace.issue" });
+ }
+ };
+
+ const selectPrincipal = (principalId: PrincipalId) => {
+ state.selectedPrincipalId = principalId;
+ router.replace({
+ name: "workspace.issue",
+ query: {
+ ...router.currentRoute.value.query,
+ user: principalId,
+ },
+ });
+ };
+
+ const changeSearchText = (searchText: string) => {
+ state.searchText = searchText;
+ };
+
return {
searchField,
state,
+ scopeByPrincipal,
sectionList,
selectEnvironment,
selectPrincipal,