Skip to content

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

chore: migrate issue list API and components (#8155)

Liu Jic4d3780fb6ce
diff --git a/frontend/src/components/IssueV1/components/ActivitySection/ActivityList.vue b/frontend/src/components/IssueV1/components/ActivitySection/ActivityList.vue
index 1b4db674b6..1ae4e8feeb 100644
--- a/frontend/src/components/IssueV1/components/ActivitySection/ActivityList.vue
+++ b/frontend/src/components/IssueV1/components/ActivitySection/ActivityList.vue
@@ -122,18 +122,13 @@ import {
} from "@/components/Issue/activity";
import MarkdownEditor from "@/components/MarkdownEditor.vue";
import { IssueBuiltinFieldId } from "@/plugins";
-import {
- useActivityV1Store,
- useCurrentUserV1,
- useIssueV1Store,
- useIssueStore,
-} from "@/store";
+import { useActivityV1Store, useCurrentUserV1, useIssueV1Store } from "@/store";
import { getLogId } from "@/store/modules/v1/common";
import {
ActivityIssueCommentCreatePayload,
ActivityIssueFieldUpdatePayload,
} from "@/types";
-import type { Issue as LegacyIssue } from "@/types";
+import type { ComposedIssue } from "@/types";
import { LogEntity, LogEntity_Action } from "@/types/proto/v1/logging_service";
import { extractUserResourceName } from "@/utils";
import { doSubscribeIssue, useIssueContext } from "../../logic";
@@ -150,7 +145,7 @@ const activityV1Store = useActivityV1Store();
const route = useRoute();
const { issue } = useIssueContext();
-const issueList = ref<LegacyIssue[]>([]);
+const issueList = ref<ComposedIssue[]>([]);
const state = reactive<LocalState>({
editCommentMode: false,
@@ -160,17 +155,18 @@ const state = reactive<LocalState>({
const currentUser = useCurrentUserV1();
const issueV1Store = useIssueV1Store();
-const issueLegacyStore = useIssueStore();
const prepareActivityList = async () => {
const [_, list] = await Promise.all([
activityV1Store.fetchActivityListForIssueV1(issue.value),
- // TODO: deprecate the legacy store.
- issueLegacyStore.fetchIssueList({
- projectId: issue.value.projectEntity.uid,
+ issueV1Store.listIssues({
+ find: {
+ project: issue.value.project,
+ query: "",
+ },
}),
]);
- issueList.value = list;
+ issueList.value = list.issues;
};
watchEffect(prepareActivityList);
diff --git a/frontend/src/components/IssueV1/components/IssueTableV1.vue b/frontend/src/components/IssueV1/components/IssueTableV1.vue
index fac33e9d9e..9bf0af956c 100644
--- a/frontend/src/components/IssueV1/components/IssueTableV1.vue
+++ b/frontend/src/components/IssueV1/components/IssueTableV1.vue
@@ -99,26 +99,6 @@
</NTooltip>
</div>
</div>
- <div class="bb-grid-cell">
- <div v-if="isDatabaseRelatedIssue(issue)" class="flex items-center">
- {{ activeEnvironmentForIssue(issue)?.title }}
- <ProductionEnvironmentV1Icon
- class="ml-1"
- :environment="activeEnvironmentForIssue(issue)"
- />
- </div>
- <div v-else>-</div>
- </div>
- <div class="hidden sm:bb-grid-cell">
- <BBStepBar
- :step-list="taskStepList(issue)"
- @click-step="
- (step: any) => {
- clickIssueStep(issue, step);
- }
- "
- />
- </div>
<div class="hidden md:bb-grid-cell w-36">
{{ humanizeTs((issue.updateTime?.getTime() ?? 0) / 1000) }}
</div>
@@ -174,25 +154,16 @@ import { reactive, computed, watch, ref } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import { BBGridColumn } from "@/bbkit";
-import type { BBStep, BBStepStatus } from "@/bbkit/types";
import BatchIssueActionsV1 from "@/components/IssueV1/components/BatchIssueActionsV1.vue";
import CurrentApproverV1 from "@/components/IssueV1/components/CurrentApproverV1.vue";
import IssueStatusIcon from "@/components/IssueV1/components/IssueStatusIcon.vue";
import { useElementVisibilityInScrollParent } from "@/composables/useElementVisibilityInScrollParent";
-import { useCurrentUserV1, useEnvironmentV1Store } from "@/store";
-import type { Task, ComposedIssue } from "@/types";
-import { IssueStatus, issueStatusToJSON } from "@/types/proto/v1/issue_service";
+import { useCurrentUserV1 } from "@/store";
+import type { ComposedIssue } from "@/types";
+import { IssueStatus } from "@/types/proto/v1/issue_service";
import { Workflow } from "@/types/proto/v1/project_service";
-import {
- Task_Status,
- task_StatusToJSON,
-} from "@/types/proto/v1/rollout_service";
-import {
- issueSlug,
- stageSlug,
- activeTaskInStageV1,
- activeEnvironmentInRollout,
-} from "@/utils";
+import { Task_Status } from "@/types/proto/v1/rollout_service";
+import { issueSlug } from "@/utils";
import { isDatabaseRelatedIssue, activeTaskInRollout } from "@/utils";
type Mode = "ALL" | "PROJECT";
@@ -213,14 +184,6 @@ const columnList = computed((): BBGridColumn[] => {
title: t("issue.table.name"),
width: "minmax(auto, 1fr)",
},
- {
- title: t("issue.table.environment"),
- width: "minmax(auto, 10rem)",
- },
- {
- title: t("issue.table.progress"),
- width: "minmax(auto, 10rem)",
- },
{
title: t("issue.table.updated"),
width: "minmax(auto, 5rem)",
@@ -259,16 +222,21 @@ const props = withDefaults(
title: string;
issueList: ComposedIssue[];
mode?: Mode;
- leftBordered: boolean;
- rightBordered: boolean;
- topBordered: boolean;
- bottomBordered: boolean;
- highlightText: string;
- showPlaceholder: boolean;
+ leftBordered?: boolean;
+ rightBordered?: boolean;
+ topBordered?: boolean;
+ bottomBordered?: boolean;
+ highlightText?: string;
+ showPlaceholder?: boolean;
}>(),
{
mode: "ALL",
+ leftBordered: false,
+ rightBordered: false,
+ topBordered: false,
+ bottomBordered: false,
highlightText: "",
+ showPlaceholder: false,
}
);
@@ -279,7 +247,6 @@ const state = reactive<LocalState>({
selectedIssueIdList: new Set(),
});
const currentUserV1 = useCurrentUserV1();
-const environmentStore = useEnvironmentV1Store();
const tableRef = ref<HTMLTableElement>();
const isTableInViewport = useElementVisibilityInScrollParent(tableRef);
@@ -299,44 +266,6 @@ const issueTaskStatus = (issue: ComposedIssue) => {
return activeTaskInRollout(issue.rolloutEntity).status;
};
-const activeEnvironmentForIssue = (issue: ComposedIssue) => {
- const environmentName = activeEnvironmentInRollout(issue.rolloutEntity);
- return environmentStore.getEnvironmentByName(environmentName);
-};
-
-const taskStepList = function (issue: ComposedIssue): BBStep[] {
- if (!isDatabaseRelatedIssue(issue)) {
- return [
- {
- status:
- issue.status === IssueStatus.OPEN
- ? "PENDING_APPROVAL_ACTIVE"
- : (issueStatusToJSON(issue.status) as BBStepStatus),
- payload: undefined,
- },
- ];
- }
-
- const res = issue.rolloutEntity.stages.map((stage) => {
- const task = activeTaskInStageV1(stage);
- let status = task_StatusToJSON(task.status) as BBStepStatus;
- if (status == "PENDING" || status == "NOT_STARTED") {
- if (activeTaskInRollout(issue.rolloutEntity).uid == task.uid) {
- status =
- status == "PENDING" ? "PENDING_ACTIVE" : "PENDING_APPROVAL_ACTIVE";
- } else {
- status = "PENDING_APPROVAL";
- }
- }
- return {
- status,
- payload: task,
- };
- });
-
- return res;
-};
-
const isIssueSelected = (issue: ComposedIssue): boolean => {
return state.selectedIssueIdList.has(issue.uid);
};
@@ -404,31 +333,6 @@ const clickIssue = (
}
};
-const clickIssueStep = (issue: ComposedIssue, step: BBStep) => {
- if (!isDatabaseRelatedIssue(issue)) {
- router.push({
- name: "workspace.issue.detail",
- params: {
- issueSlug: issueSlug(issue.name, issue.uid),
- },
- });
- return;
- }
-
- const task = step.payload as Task;
- const stageIndex = issue.rolloutEntity.stages.findIndex((item) => {
- return item.uid === `${task.stage.id}`;
- });
-
- router.push({
- name: "workspace.issue.detail",
- params: {
- issueSlug: issueSlug(issue.name, issue.uid),
- },
- query: { stage: stageSlug(task.stage.name, stageIndex) },
- });
-};
-
watch(
() => props.issueList,
(list) => {
diff --git a/frontend/src/components/IssueV1/components/PagedIssueTableV1.vue b/frontend/src/components/IssueV1/components/PagedIssueTableV1.vue
index a4c2b94311..3bb96e07ac 100644
--- a/frontend/src/components/IssueV1/components/PagedIssueTableV1.vue
+++ b/frontend/src/components/IssueV1/components/PagedIssueTableV1.vue
@@ -27,7 +27,12 @@
<script lang="ts" setup>
import { useSessionStorage } from "@vueuse/core";
import { computed, PropType, reactive, watch } from "vue";
-import { useIsLoggedIn, useIssueV1Store, useRefreshIssueList } from "@/store";
+import {
+ ListIssueParams,
+ useIsLoggedIn,
+ useIssueV1Store,
+ useRefreshIssueList,
+} from "@/store";
import { IssueFilter, ComposedIssue } from "@/types";
type LocalState = {
@@ -55,6 +60,10 @@ const MAX_PAGE_SIZE = 1000;
const SESSION_LIFE = 1 * 60 * 1000; // 1 minute
const props = defineProps({
+ method: {
+ type: String as PropType<"SEARCH" | "LIST">,
+ default: "SEARCH",
+ },
// A unique key to identify the session state.
sessionKey: {
type: String,
@@ -111,12 +120,17 @@ const fetchData = (refresh = false) => {
: // Always load one page if NOT the first fetch
limit.value;
- issueStore
- .searchIssues({
- find: props.issueFilter,
- pageSize: props.pageSize,
- pageToken: state.paginationToken,
- })
+ const params: ListIssueParams = {
+ find: props.issueFilter,
+ pageSize: props.pageSize,
+ pageToken: state.paginationToken,
+ };
+ const request =
+ props.method === "SEARCH"
+ ? issueStore.searchIssues(params)
+ : issueStore.listIssues(params);
+
+ request
.then(({ nextPageToken, issues }) => {
if (refresh) {
state.issueList = issues;
diff --git a/frontend/src/components/IssueV1/components/WaitingForMyApprovalIssueTableV1.vue b/frontend/src/components/IssueV1/components/WaitingForMyApprovalIssueTableV1.vue
new file mode 100644
index 0000000000..f6ee2bbcc2
--- /dev/null
+++ b/frontend/src/components/IssueV1/components/WaitingForMyApprovalIssueTableV1.vue
@@ -0,0 +1,49 @@
+<template>
+ <PagedIssueTableV1
+ method="LIST"
+ :session-key="sessionKey"
+ :page-size="20"
+ :issue-filter="{
+ project: 'projects/-',
+ query: '',
+ statusList: [IssueStatus.OPEN],
+ }"
+ >
+ <template #table="{ issueList, loading }">
+ <slot
+ name="table"
+ :issue-list="issueList.filter(filter)"
+ :loading="loading"
+ />
+ </template>
+ </PagedIssueTableV1>
+</template>
+
+<script lang="ts" setup>
+import { computed } from "vue";
+import { useAuthStore } from "@/store";
+import type { ComposedIssue } from "@/types";
+import { IssueStatus } from "@/types/proto/v1/issue_service";
+import { extractReviewContext, useWrappedReviewStepsV1 } from "../logic";
+import PagedIssueTableV1 from "./PagedIssueTableV1.vue";
+
+defineProps<{
+ sessionKey: string;
+}>();
+
+const currentUserName = computed(() => useAuthStore().currentUser.name);
+
+const filter = (issue: ComposedIssue) => {
+ const issueRef = computed(() => issue);
+ const reviewContext = extractReviewContext(issueRef);
+ const steps = useWrappedReviewStepsV1(issueRef, reviewContext);
+
+ const currentStep = steps.value?.find((step) => step.status === "CURRENT");
+ if (!currentStep) return false;
+ return (
+ currentStep.candidates.findIndex(
+ (user) => user.name === currentUserName.value
+ ) >= 0
+ );
+};
+</script>
diff --git a/frontend/src/components/IssueV1/logic/initialize/create.ts b/frontend/src/components/IssueV1/logic/initialize/create.ts
index fbe5457d8f..9a1c742027 100644
--- a/frontend/src/components/IssueV1/logic/initialize/create.ts
+++ b/frontend/src/components/IssueV1/logic/initialize/create.ts
@@ -211,6 +211,7 @@ export const buildStepsViaDeploymentConfig = async (
params,
sheetUID
);
+ maybeSetInitialSQLForSpec(spec, 0, params);
const step = Plan_Step.fromPartial({
specs: [spec],
});
diff --git a/frontend/src/components/MarkdownEditor.vue b/frontend/src/components/MarkdownEditor.vue
index 7b3c9feccb..22f68f48ae 100644
--- a/frontend/src/components/MarkdownEditor.vue
+++ b/frontend/src/components/MarkdownEditor.vue
@@ -85,7 +85,7 @@
<ul class="text-sm rounded divide-y divide-solid">
<li
v-for="issue in filterIssueList"
- :key="issue.id"
+ :key="issue.uid"
class="p-3 rounded hover:bg-blue-500 hover:text-white cursor-pointer flex items-center gap-x-2"
@click="onIssueSelect(issue)"
>
@@ -93,9 +93,9 @@
:issue-status="issue.status"
:task-status="issueTaskStatus(issue)"
/>
- <span class="opacity-60">#{{ issue.id }}</span>
+ <span class="opacity-60">#{{ issue.uid }}</span>
<div class="whitespace-nowrap">
- {{ issue.name }}
+ {{ issue.title }}
</div>
</li>
</ul>
@@ -111,10 +111,15 @@ import codeStyle from "highlight.js/styles/github.css";
import MarkdownIt from "markdown-it";
import { computed, nextTick, ref, reactive, watch } from "vue";
import { useI18n } from "vue-i18n";
-import { Issue } from "@/types";
-import { sizeToFit } from "@/utils";
-import { activeTask, isDatabaseRelatedIssueType } from "@/utils";
+import { ComposedIssue } from "@/types";
+import { Task_Status } from "@/types/proto/v1/rollout_service";
+import {
+ activeTaskInRollout,
+ isDatabaseRelatedIssue,
+ sizeToFit,
+} from "@/utils";
import markdownStyle from "../assets/css/github-markdown-style.css";
+import IssueStatusIcon from "./IssueV1/components/IssueStatusIcon.vue";
const md = new MarkdownIt({
html: true,
@@ -149,7 +154,7 @@ type EditorMode = "editor" | "preview";
const props = defineProps<{
content: string;
mode: EditorMode;
- issueList: Issue[];
+ issueList: ComposedIssue[];
}>();
const emit = defineEmits<{
(event: "change", value: string): void;
@@ -196,7 +201,7 @@ const markdownContent = computed(() => {
const contentTextArea = ref<HTMLTextAreaElement>();
const contentPreviewArea = ref<HTMLIFrameElement>();
const issuePanel = ref<HTMLDivElement>();
-const filterIssueList = ref<Issue[]>([]);
+const filterIssueList = ref<ComposedIssue[]>([]);
watch(
() => state.content,
@@ -459,7 +464,7 @@ const clearIssuePanel = () => {
// onIssueSelect will replace the input issue id with the selected issue id.
// For example, if the text is "#12|" (| is the cursor position), and select the issue with id 1234,
// we will replace the "#12|" with "#1234 |"
-const onIssueSelect = (issue: Issue) => {
+const onIssueSelect = (issue: ComposedIssue) => {
if (!contentTextArea.value) {
return false;
}
@@ -479,7 +484,7 @@ const onIssueSelect = (issue: Issue) => {
replaceStart++;
const content = state.content.split("");
- const issueId = `${issue.id} `;
+ const issueId = `${issue.uid} `;
content.splice(replaceStart, start - replaceStart, issueId);
state.content = content.join("");
@@ -500,13 +505,13 @@ const onIssueSelect = (issue: Issue) => {
return;
};
-const issueTaskStatus = (issue: Issue) => {
- // For grant request issue, we always show the status as "PENDING_APPROVAL" as task status.
- if (!isDatabaseRelatedIssueType(issue.type)) {
- return "PENDING_APPROVAL";
+const issueTaskStatus = (issue: ComposedIssue) => {
+ // For grant request issue, we always show the status as "NOT_STARTED" as task status.
+ if (!isDatabaseRelatedIssue(issue)) {
+ return Task_Status.NOT_STARTED;
}
- return activeTask(issue.pipeline!).status;
+ return activeTaskInRollout(issue.rolloutEntity).status;
};
const adjustIssuePanelWithPosition = () => {
@@ -532,7 +537,7 @@ const adjustIssuePanelWithPosition = () => {
const id = matches[0].slice(1).trimEnd();
filterIssueList.value = props.issueList
- .filter((issue) => `${issue.id}`.startsWith(id))
+ .filter((issue) => `${issue.uid}`.startsWith(id))
.slice(0, 5);
const position = getIssuePanelPosition(contentTextArea.value);
diff --git a/frontend/src/components/ProjectOverviewPanel.vue b/frontend/src/components/ProjectOverviewPanel.vue
index 57a38257f5..758a2d7727 100644
--- a/frontend/src/components/ProjectOverviewPanel.vue
+++ b/frontend/src/components/ProjectOverviewPanel.vue
@@ -63,35 +63,37 @@
</div>
<div>
- <WaitingForMyApprovalIssueTable
+ <WaitingForMyApprovalIssueTableV1
v-if="hasCustomApprovalFeature"
session-key="project-waiting-approval"
- :issue-find="{
- statusList: ['OPEN'],
- projectId: project.uid,
+ method="LIST"
+ :issue-filter="{
+ ...commonIssueFilter,
+ statusList: [IssueStatus.OPEN],
}"
>
<template #table="{ issueList, loading }">
- <IssueTable
+ <IssueTableV1
:mode="'PROJECT'"
:show-placeholder="!loading"
:title="$t('issue.waiting-approval')"
:issue-list="issueList"
/>
</template>
- </WaitingForMyApprovalIssueTable>
+ </WaitingForMyApprovalIssueTableV1>
<!-- show OPEN issues with pageSize=10 -->
- <PagedIssueTable
+ <PagedIssueTableV1
session-key="project-open"
- :issue-find="{
- statusList: ['OPEN'],
- projectId: project.uid,
+ method="LIST"
+ :issue-filter="{
+ ...commonIssueFilter,
+ statusList: [IssueStatus.OPEN],
}"
:page-size="10"
>
<template #table="{ issueList, loading }">
- <IssueTable
+ <IssueTableV1
class="-mt-px"
:mode="'PROJECT'"
:title="$t('project.overview.in-progress')"
@@ -99,21 +101,22 @@
:show-placeholder="!loading"
/>
</template>
- </PagedIssueTable>
+ </PagedIssueTableV1>
<!-- show the first 5 DONE or CANCELED issues -->
<!-- But won't show "Load more", since we have a "View all closed" link below -->
- <PagedIssueTable
+ <PagedIssueTableV1
session-key="project-closed"
- :issue-find="{
- statusList: ['DONE', 'CANCELED'],
- projectId: project.uid,
+ method="LIST"
+ :issue-filter="{
+ ...commonIssueFilter,
+ statusList: [IssueStatus.DONE, IssueStatus.CANCELED],
}"
:page-size="5"
:hide-load-more="true"
>
<template #table="{ issueList, loading }">
- <IssueTable
+ <IssueTableV1
class="-mt-px"
:mode="'PROJECT'"
:title="$t('project.overview.recently-closed')"
@@ -121,7 +124,7 @@
:show-placeholder="!loading"
/>
</template>
- </PagedIssueTable>
+ </PagedIssueTableV1>
<div class="w-full flex justify-end mt-2 px-4">
<router-link
@@ -137,21 +140,21 @@
</template>
<script lang="ts" setup>
-import { reactive, PropType } from "vue";
+import { reactive, PropType, computed } from "vue";
import { useRouter } from "vue-router";
-import PagedIssueTable from "@/components/Issue/table/PagedIssueTable.vue";
import { featureToRef } from "@/store";
+import { IssueStatus } from "@/types/proto/v1/issue_service";
import { Project } from "@/types/proto/v1/project_service";
-import { IssueTable } from "../components/Issue";
-import { Issue } from "../types";
+import { IssueFilter } from "../types";
+import IssueTableV1 from "./IssueV1/components/IssueTableV1.vue";
+import PagedIssueTableV1 from "./IssueV1/components/PagedIssueTableV1.vue";
+import WaitingForMyApprovalIssueTableV1 from "./IssueV1/components/WaitingForMyApprovalIssueTableV1.vue";
interface LocalState {
isFetchingActivityList: boolean;
- progressIssueList: Issue[];
- closedIssueList: Issue[];
}
-defineProps({
+const props = defineProps({
project: {
required: true,
type: Object as PropType<Project>,
@@ -160,10 +163,15 @@ defineProps({
const state = reactive<LocalState>({
isFetchingActivityList: false,
- progressIssueList: [],
- closedIssueList: [],
});
const router = useRouter();
const hasCustomApprovalFeature = featureToRef("bb.feature.custom-approval");
+
+const commonIssueFilter = computed((): IssueFilter => {
+ return {
+ project: props.project.name,
+ query: "",
+ };
+});
</script>
diff --git a/frontend/src/store/modules/v1/experimental-issue.ts b/frontend/src/store/modules/v1/experimental-issue.ts
index 0f4636f16c..55c1002129 100644
--- a/frontend/src/store/modules/v1/experimental-issue.ts
+++ b/frontend/src/store/modules/v1/experimental-issue.ts
@@ -16,7 +16,11 @@ import { Issue } from "@/types/proto/v1/issue_service";
import { Plan, Rollout } from "@/types/proto/v1/rollout_service";
import { extractProjectResourceName, extractUserResourceName } from "@/utils";
-export const composeIssue = async (rawIssue: Issue): Promise<ComposedIssue> => {
+export const composeIssue = async (
+ rawIssue: Issue,
+ withPlan = true,
+ withRollout = true
+): Promise<ComposedIssue> => {
const userStore = useUserStore();
const project = `projects/${extractProjectResourceName(rawIssue.name)}`;
@@ -39,7 +43,19 @@ export const composeIssue = async (rawIssue: Issue): Promise<ComposedIssue> => {
creatorEntity,
};
- if (issue.rollout) {
+ if (withPlan && issue.plan) {
+ if (issue.plan) {
+ const plan = await rolloutServiceClient.getPlan({
+ name: issue.plan,
+ });
+ issue.planEntity = plan;
+ const { planCheckRuns } = await rolloutServiceClient.listPlanCheckRuns({
+ parent: plan.name,
+ });
+ issue.planCheckRunList = planCheckRuns;
+ }
+ }
+ if (withRollout && issue.rollout) {
issue.rolloutEntity = await rolloutServiceClient.getRollout({
name: issue.rollout,
});
@@ -49,16 +65,6 @@ export const composeIssue = async (rawIssue: Issue): Promise<ComposedIssue> => {
});
issue.rolloutTaskRunList = taskRuns;
}
- if (issue.plan) {
- const plan = await rolloutServiceClient.getPlan({
- name: issue.plan,
- });
- issue.planEntity = plan;
- const { planCheckRuns } = await rolloutServiceClient.listPlanCheckRuns({
- parent: plan.name,
- });
- issue.planCheckRunList = planCheckRuns;
- }
if (issue.assignee) {
const assigneeEntity = userStore.getUserByEmail(
@@ -72,6 +78,12 @@ export const composeIssue = async (rawIssue: Issue): Promise<ComposedIssue> => {
return issue;
};
+export const shallowComposeIssue = async (
+ rawIssue: Issue
+): Promise<ComposedIssue> => {
+ return composeIssue(rawIssue, false, false);
+};
+
export const experimentalFetchIssueByUID = async (uid: string) => {
if (uid === "undefined") {
console.warn("undefined issue uid");
diff --git a/frontend/src/store/modules/v1/issue.ts b/frontend/src/store/modules/v1/issue.ts
index 3c8f3a10d9..5faaad5710 100644
--- a/frontend/src/store/modules/v1/issue.ts
+++ b/frontend/src/store/modules/v1/issue.ts
@@ -23,7 +23,7 @@ import { useProjectV1Store } from ".";
import { useUserStore } from "../user";
import { useActivityV1Store } from "./activity";
import { projectNamePrefix, issueNamePrefix } from "./common";
-import { composeIssue } from "./experimental-issue";
+import { shallowComposeIssue } from "./experimental-issue";
const issueName = (legacyIssue: LegacyIssue) => {
return `projects/${legacyIssue.project.id}/issues/${legacyIssue.id}`;
@@ -36,6 +36,12 @@ const emptyIssue = (legacyIssue: LegacyIssue) => {
});
};
+export type ListIssueParams = {
+ find: IssueFilter;
+ pageSize?: number;
+ pageToken?: string;
+};
+
export const buildIssueFilter = (find: IssueFilter): string => {
const filter: string[] = [];
if (find.principal) {
@@ -174,15 +180,28 @@ export const useIssueV1Store = defineStore("issue_v1", () => {
await useActivityV1Store().fetchActivityListByIssueId(issueId);
};
+ const listIssues = async ({ find, pageSize, pageToken }: ListIssueParams) => {
+ const resp = await issueServiceClient.listIssues({
+ parent: find.project,
+ filter: buildIssueFilter(find),
+ pageSize,
+ pageToken,
+ });
+
+ const composedIssues = await Promise.all(
+ resp.issues.map((issue) => shallowComposeIssue(issue))
+ );
+ return {
+ nextPageToken: resp.nextPageToken,
+ issues: composedIssues,
+ };
+ };
+
const searchIssues = async ({
find,
pageSize,
pageToken,
- }: {
- find: IssueFilter;
- pageSize?: number;
- pageToken?: string;
- }) => {
+ }: ListIssueParams) => {
const resp = await issueServiceClient.searchIssues({
parent: find.project,
query: find.query,
@@ -192,7 +211,7 @@ export const useIssueV1Store = defineStore("issue_v1", () => {
});
const composedIssues = await Promise.all(
- resp.issues.map((issue) => composeIssue(issue))
+ resp.issues.map((issue) => shallowComposeIssue(issue))
);
return {
nextPageToken: resp.nextPageToken,
@@ -206,6 +225,7 @@ export const useIssueV1Store = defineStore("issue_v1", () => {
approveIssue,
rejectIssue,
requestIssue,
+ listIssues,
searchIssues,
regenerateReview,
regenerateReviewV1,
diff --git a/frontend/src/views/Home.vue b/frontend/src/views/Home.vue
index b344a39f7b..a261bb5b13 100644
--- a/frontend/src/views/Home.vue
+++ b/frontend/src/views/Home.vue
@@ -1,11 +1,7 @@
<template>
<div class="flex flex-col">
<div class="px-4 py-2 flex justify-between items-center">
- <EnvironmentTabFilter
- :include-all="true"
- :environment="selectedEnvironment?.name"
- @update:environment="changeEnvironment"
- />
+ <div><!-- empty --></div>
<SearchBox
:value="state.searchText"
:placeholder="$t('issue.search-issue-name')"
@@ -14,109 +10,109 @@
/>
</div>
- <WaitingForMyApprovalIssueTable
+ <WaitingForMyApprovalIssueTableV1
v-if="hasCustomApprovalFeature"
session-key="home-waiting-approval"
- :issue-find="{
- statusList: ['OPEN'],
- }"
>
<template #table="{ issueList, loading }">
- <IssueTable
- :left-bordered="false"
- :right-bordered="false"
+ <IssueTableV1
:show-placeholder="!loading"
:title="$t('issue.waiting-approval')"
- :issue-list="issueList.filter(keywordAndEnvironmentFilter)"
+ :issue-list="issueList.filter(keywordFilter)"
+ :highlight-text="state.searchText"
/>
</template>
- </WaitingForMyApprovalIssueTable>
+ </WaitingForMyApprovalIssueTableV1>
<!-- show OPEN Assigned issues with pageSize=10 -->
- <PagedIssueTable
+ <PagedIssueTableV1
+ method="LIST"
session-key="home-assigned"
- :issue-find="{
- statusList: ['OPEN'],
- assigneeId: Number(currentUserUID),
+ :issue-filter="{
+ ...commonIssueFilter,
+ statusList: [IssueStatus.OPEN],
+ assignee: `users/${currentUserV1.email}`,
}"
:page-size="OPEN_ISSUE_LIST_PAGE_SIZE"
>
<template #table="{ issueList, loading }">
- <IssueTable
+ <IssueTableV1
class="-mt-px"
- :left-bordered="false"
- :right-bordered="false"
:show-placeholder="!loading"
:title="$t('issue.waiting-rollout')"
- :issue-list="issueList.filter(keywordAndEnvironmentFilter)"
+ :issue-list="issueList.filter(keywordFilter)"
+ :highlight-text="state.searchText"
/>
</template>
- </PagedIssueTable>
+ </PagedIssueTableV1>
<!-- show OPEN Created issues with pageSize=10 -->
- <PagedIssueTable
+ <PagedIssueTableV1
session-key="home-created"
- :issue-find="{
- statusList: ['OPEN'],
- creatorId: Number(currentUserUID),
+ method="LIST"
+ :issue-filter="{
+ ...commonIssueFilter,
+ statusList: [IssueStatus.OPEN],
+ creator: `users/${currentUserV1.email}`,
}"
:page-size="OPEN_ISSUE_LIST_PAGE_SIZE"
>
<template #table="{ issueList, loading }">
- <IssueTable
+ <IssueTableV1
class="-mt-px"
- :left-bordered="false"
- :right-bordered="false"
:show-placeholder="!loading"
:title="$t('common.created')"
- :issue-list="issueList.filter(keywordAndEnvironmentFilter)"
+ :issue-list="issueList.filter(keywordFilter)"
+ :highlight-text="state.searchText"
/>
</template>
- </PagedIssueTable>
+ </PagedIssueTableV1>
<!-- show OPEN Subscribed issues with pageSize=10 -->
- <PagedIssueTable
+ <PagedIssueTableV1
session-key="home-subscribed"
- :issue-find="{
- statusList: ['OPEN'],
- subscriberId: Number(currentUserUID),
+ method="LIST"
+ :issue-filter="{
+ ...commonIssueFilter,
+ statusList: [IssueStatus.OPEN],
+ subscriber: `users/${currentUserV1.email}`,
}"
:page-size="OPEN_ISSUE_LIST_PAGE_SIZE"
>
<template #table="{ issueList, loading }">
- <IssueTable
+ <IssueTableV1
class="-mt-px"
- :left-bordered="false"
- :right-bordered="false"
:show-placeholder="!loading"
:title="$t('common.subscribed')"
- :issue-list="issueList.filter(keywordAndEnvironmentFilter)"
+ :issue-list="issueList.filter(keywordFilter)"
+ :highlight-text="state.searchText"
/>
</template>
- </PagedIssueTable>
+ </PagedIssueTableV1>
<!-- show the first 5 DONE or CANCELED issues -->
<!-- But won't show "Load more", since we have a "View all closed" link below -->
- <PagedIssueTable
+ <PagedIssueTableV1
session-key="home-closed"
- :issue-find="{
- statusList: ['DONE', 'CANCELED'],
- principalId: Number(currentUserUID),
+ method="LIST"
+ :issue-filter="{
+ ...commonIssueFilter,
+ statusList: [IssueStatus.DONE, IssueStatus.CANCELED],
+ principal: `users/${currentUserV1.email}`,
}"
:page-size="MAX_CLOSED_ISSUE"
:hide-load-more="true"
>
<template #table="{ issueList, loading }">
- <IssueTable
+ <IssueTableV1
class="-mt-px"
- :left-bordered="false"
- :right-bordered="false"
:show-placeholder="!loading"
:title="$t('project.overview.recently-closed')"
- :issue-list="issueList.filter(keywordAndEnvironmentFilter)"
+ :issue-list="issueList.filter(keywordFilter)"
+ :highlight-text="state.searchText"
/>
</template>
- </PagedIssueTable>
+ </PagedIssueTableV1>
</div>
<div class="w-full flex justify-end mt-2 px-4">
<router-link
@@ -192,31 +188,19 @@
<script lang="ts" setup>
import { reactive, computed } from "vue";
-import { useRoute, useRouter } from "vue-router";
+import IssueTableV1 from "@/components/IssueV1/components/IssueTableV1.vue";
+import PagedIssueTableV1 from "@/components/IssueV1/components/PagedIssueTableV1.vue";
+import WaitingForMyApprovalIssueTableV1 from "@/components/IssueV1/components/WaitingForMyApprovalIssueTableV1.vue";
+import { SearchBox } from "@/components/v2";
import {
- IssueTable,
- PagedIssueTable,
- WaitingForMyApprovalIssueTable,
-} from "@/components/Issue/table";
-import { EnvironmentTabFilter, SearchBox } from "@/components/v2";
-import {
- useEnvironmentV1Store,
useSubscriptionV1Store,
useOnboardingStateStore,
featureToRef,
useCurrentUserV1,
} from "@/store";
-import {
- UNKNOWN_ID,
- UNKNOWN_ENVIRONMENT_NAME,
- Issue,
- planTypeToString,
-} from "../types";
-import {
- activeEnvironment,
- extractUserUID,
- isDatabaseRelatedIssueType,
-} from "../utils";
+import { IssueStatus } from "@/types/proto/v1/issue_service";
+import { ComposedIssue, IssueFilter, planTypeToString } from "../types";
+import { extractUserUID } from "../utils";
interface LocalState {
searchText: string;
@@ -226,11 +210,8 @@ interface LocalState {
const OPEN_ISSUE_LIST_PAGE_SIZE = 10;
const MAX_CLOSED_ISSUE = 5;
-const environmentV1Store = useEnvironmentV1Store();
const subscriptionStore = useSubscriptionV1Store();
const onboardingStateStore = useOnboardingStateStore();
-const router = useRouter();
-const route = useRoute();
const state = reactive<LocalState>({
searchText: "",
@@ -255,57 +236,23 @@ const planImage = computed(() => {
).href;
});
-const selectedEnvironment = computed(() => {
- const { environment } = route.query;
- return environment
- ? environmentV1Store.getEnvironmentByName(environment as string)
- : undefined;
+const commonIssueFilter = computed((): IssueFilter => {
+ return {
+ project: "projects/-",
+ query: "",
+ };
});
-const keywordAndEnvironmentFilter = (issue: Issue) => {
- if (
- selectedEnvironment.value &&
- selectedEnvironment.value.uid !== String(UNKNOWN_ID)
- ) {
- if (!isDatabaseRelatedIssueType(issue.type)) {
- return false;
- }
- if (
- String(activeEnvironment(issue.pipeline).id) !==
- selectedEnvironment.value.uid
- ) {
- return false;
- }
- }
+const keywordFilter = (issue: ComposedIssue) => {
const keyword = state.searchText.trim().toLowerCase();
if (keyword) {
- if (!issue.name.toLowerCase().includes(keyword)) {
+ if (!issue.title.toLowerCase().includes(keyword)) {
return false;
}
}
return true;
};
-const changeEnvironment = (environment: string | undefined) => {
- if (environment && environment !== UNKNOWN_ENVIRONMENT_NAME) {
- router.replace({
- name: "workspace.home",
- query: {
- ...route.query,
- environment,
- },
- });
- } else {
- router.replace({
- name: "workspace.home",
- query: {
- ...route.query,
- environment: undefined,
- },
- });
- }
-};
-
const changeSearchText = (searchText: string) => {
state.searchText = searchText;
};
diff --git a/frontend/src/views/IssueDashboard.vue b/frontend/src/views/IssueDashboard.vue
index dec12b3110..6fc8f5494c 100644
--- a/frontend/src/views/IssueDashboard.vue
+++ b/frontend/src/views/IssueDashboard.vue
@@ -14,11 +14,7 @@
/>
<div class="px-4 py-2 flex justify-between items-center">
- <EnvironmentTabFilter
- :include-all="true"
- :environment="selectedEnvironment?.name"
- @update:environment="changeEnvironment($event)"
- />
+ <div><!-- empty --></div>
<div class="flex flex-row space-x-4">
<NButton v-if="project" @click="goProject">
{{ project.key }}
@@ -46,6 +42,7 @@
<PagedIssueTableV1
v-if="showOpen"
session-key="dashboard-open"
+ method="SEARCH"
:issue-filter="{
...issueFilter,
statusList: [IssueStatus.OPEN],
@@ -54,8 +51,6 @@
>
<template #table="{ issueList, loading }">
<IssueTableV1
- :left-bordered="false"
- :right-bordered="false"
:top-bordered="true"
:bottom-bordered="true"
:show-placeholder="!loading"
@@ -70,6 +65,7 @@
<PagedIssueTableV1
v-if="showClosed"
session-key="dashboard-closed"
+ method="SEARCH"
:issue-filter="{
...issueFilter,
statusList: [IssueStatus.DONE, IssueStatus.CANCELED],
@@ -79,8 +75,6 @@
<template #table="{ issueList, loading }">
<IssueTableV1
class="-mt-px"
- :left-bordered="false"
- :right-bordered="false"
:top-bordered="true"
:bottom-bordered="true"
:show-placeholder="!loading"
@@ -97,25 +91,17 @@
import { NInputGroup, NButton } from "naive-ui";
import { reactive, computed, watchEffect, onMounted } from "vue";
import { useRoute, useRouter } from "vue-router";
-import { SearchParams } from "@/components/AdvancedSearch.vue";
+import AdvancedSearch, { SearchParams } from "@/components/AdvancedSearch.vue";
import IssueTableV1 from "@/components/IssueV1/components/IssueTableV1.vue";
import PagedIssueTableV1 from "@/components/IssueV1/components/PagedIssueTableV1.vue";
-import { EnvironmentTabFilter, UserSelect, SearchBox } from "@/components/v2";
-import {
- useCurrentUserV1,
- useEnvironmentV1Store,
- useProjectV1Store,
- useUserStore,
-} from "@/store";
+import { UserSelect, SearchBox } from "@/components/v2";
+import { useCurrentUserV1, useProjectV1Store, useUserStore } from "@/store";
import { projectNamePrefix, userNamePrefix } from "@/store/modules/v1/common";
import { UNKNOWN_ID, IssueFilter, ComposedIssue } from "@/types";
-import { Environment } from "@/types/proto/v1/environment_service";
import { IssueStatus } from "@/types/proto/v1/issue_service";
import {
extractUserUID,
hasWorkspacePermissionV1,
- isDatabaseRelatedIssue,
- activeEnvironmentInRollout,
projectV1Slug,
} from "@/utils";
@@ -129,7 +115,6 @@ const route = useRoute();
const currentUserV1 = useCurrentUserV1();
const projectV1Store = useProjectV1Store();
-const environmentV1Store = useEnvironmentV1Store();
const statusList = computed((): string[] =>
route.query.status ? (route.query.status as string).split(",") : []
@@ -224,30 +209,12 @@ const selectedUser = computed(() => {
return useUserStore().getUserById(uid);
});
-const selectedEnvironment = computed((): Environment | undefined => {
- const { environment } = route.query;
- return environment
- ? environmentV1Store.getEnvironmentByName(environment as string)
- : undefined;
-});
-
const selectedProjectId = computed((): string | undefined => {
const { project } = route.query;
return project ? (project as string) : undefined;
});
const filter = (issue: ComposedIssue) => {
- if (selectedEnvironment.value) {
- if (!isDatabaseRelatedIssue(issue)) {
- return false;
- }
- if (
- activeEnvironmentInRollout(issue.rolloutEntity) !==
- selectedEnvironment.value.name
- ) {
- return false;
- }
- }
const keyword = state.filterText.trim().toLowerCase();
if (keyword) {
if (!issue.title.toLowerCase().includes(keyword)) {
@@ -257,26 +224,6 @@ const filter = (issue: ComposedIssue) => {
return true;
};
-const changeEnvironment = (environment: string | undefined) => {
- if (environment && environment !== String(UNKNOWN_ID)) {
- router.replace({
- name: "workspace.issue",
- query: {
- ...route.query,
- environment,
- },
- });
- } else {
- router.replace({
- name: "workspace.issue",
- query: {
- ...route.query,
- environment: undefined,
- },
- });
- }
-};
-
const changeUserUID = (user: string | undefined) => {
if (user === String(UNKNOWN_ID)) {
user = undefined;