Skip to content

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

refactor(frontend): migrate project issue dashboard page to React (#19882)

boojackc9c6f641d192
diff --git a/frontend/src/components/Project/ProjectIssuesPanel.vue b/frontend/src/components/Project/ProjectIssuesPanel.vue
deleted file mode 100644
index eb05228287..0000000000
--- a/frontend/src/components/Project/ProjectIssuesPanel.vue
+++ /dev/null
@@ -1,229 +0,0 @@
-<template>
- <div class="flex flex-col">
- <div class="px-4 flex flex-col gap-y-2">
- <NAlert
- v-if="!hideHint"
- type="info"
- closable
- @close="dismissHint"
- >
- {{ $t("issue.subtitle") }}
- </NAlert>
- <IssueSearch
- v-model:params="state.params"
- v-model:order-by="orderBy"
- :components="['searchbox', 'time-range', 'sort', 'presets']"
- />
- </div>
- <PagedTable
- ref="issuePagedTable"
- session-key="bb.issue-table.project-issues"
- :footer-class="'mx-4'"
- :fetch-list="fetchIssueList"
- >
- <template #table="{ list, loading }">
- <IssueListV1
- class="border-x-0"
- :loading="loading"
- :issue-list="list"
- :highlight-text="state.params.query"
- />
- </template>
- </PagedTable>
- </div>
-</template>
-
-<script lang="ts" setup>
-import { NAlert } from "naive-ui";
-import { computed, reactive, ref, watch } from "vue";
-import type { ComponentExposed } from "vue-component-type-helpers";
-import { useRoute, useRouter } from "vue-router";
-import IssueListV1 from "@/components/IssueV1/components/IssueListV1.vue";
-import PagedTable from "@/components/v2/Model/PagedTable.vue";
-import {
- useCurrentUserV1,
- useIssueV1Store,
- useRefreshIssueList,
- useUIStateStore,
-} from "@/store";
-import type { Issue } from "@/types/proto-es/v1/issue_service_pb";
-import {
- Issue_ApprovalStatus,
- IssueStatus,
-} from "@/types/proto-es/v1/issue_service_pb";
-import type { Project } from "@/types/proto-es/v1/project_service_pb";
-import type { SearchParams, SearchScope } from "@/utils";
-import {
- buildIssueFilterBySearchParams,
- buildSearchParamsBySearchText,
- buildSearchTextBySearchParams,
- extractProjectResourceName,
- mergeSearchParams,
-} from "@/utils";
-import { IssueSearch } from "../IssueV1/components";
-
-interface LocalState {
- params: SearchParams;
-}
-
-const props = defineProps<{
- project: Project;
-}>();
-
-const route = useRoute();
-const router = useRouter();
-const me = useCurrentUserV1();
-const issueStore = useIssueV1Store();
-const orderBy = ref("");
-const issuePagedTable = ref<ComponentExposed<typeof PagedTable<Issue>>>();
-
-const uiStateStore = useUIStateStore();
-const HINT_KEY = "issue.hint-dismissed";
-const hideHint = computed(() => uiStateStore.getIntroStateByKey(HINT_KEY));
-const dismissHint = () => {
- uiStateStore.saveIntroStateByKey({ key: HINT_KEY, newState: true });
-};
-
-const readonlyScopes = computed((): SearchScope[] => {
- return [
- {
- id: "project",
- value: extractProjectResourceName(props.project.name),
- readonly: true,
- },
- ];
-});
-
-const defaultSearchParams = (): SearchParams => {
- const myEmail = me.value.email;
- return {
- query: "",
- scopes: [
- ...readonlyScopes.value,
- { id: "status", value: IssueStatus[IssueStatus.OPEN] },
- {
- id: "approval",
- value: Issue_ApprovalStatus[Issue_ApprovalStatus.PENDING],
- },
- { id: "current-approver", value: myEmail },
- ],
- };
-};
-
-// Track the initial URL query string to distinguish between user-provided URLs
-// and programmatic navigation to default state
-const initialQueryString = (route.query.q as string) || null;
-
-// Initialize params from URL query if present, otherwise use defaults
-const getInitialParams = (): SearchParams => {
- if (initialQueryString) {
- const urlParams = buildSearchParamsBySearchText(initialQueryString);
- const readonlyParams: SearchParams = {
- query: "",
- scopes: [...readonlyScopes.value],
- };
- return mergeSearchParams(readonlyParams, urlParams);
- }
- return defaultSearchParams();
-};
-
-const state = reactive<LocalState>({
- params: getInitialParams(),
-});
-
-const mergedIssueFilter = computed(() => {
- const filter = buildIssueFilterBySearchParams(state.params);
- filter.orderBy = orderBy.value;
- return filter;
-});
-
-const fetchIssueList = async ({
- pageToken,
- pageSize,
-}: {
- pageToken: string;
- pageSize: number;
-}) => {
- const { nextPageToken, issues } = await issueStore.listIssues({
- find: mergedIssueFilter.value,
- pageSize,
- pageToken,
- });
- return {
- nextPageToken,
- list: issues,
- };
-};
-
-watch(
- () => JSON.stringify(mergedIssueFilter.value),
- () => {
- issuePagedTable.value?.refresh();
- }
-);
-useRefreshIssueList(() => issuePagedTable.value?.refresh());
-
-watch(
- () => props.project.name,
- () => {
- state.params = defaultSearchParams();
- }
-);
-
-// Helper to check if params match the default preset
-const isDefaultPreset = (params: SearchParams): boolean => {
- const defaultParams = defaultSearchParams();
- const paramsQuery = buildSearchTextBySearchParams(params);
- const defaultQuery = buildSearchTextBySearchParams(defaultParams);
- return paramsQuery === defaultQuery;
-};
-
-// Sync params to URL query when params change
-let isUpdatingFromUrl = false;
-watch(
- () => state.params,
- (params) => {
- if (isUpdatingFromUrl) {
- return;
- }
-
- const queryString = buildSearchTextBySearchParams(params);
- const currentQuery = route.query.q as string;
-
- // Only update URL if query string has actually changed
- if (queryString !== currentQuery) {
- // Special case: if at default preset and we didn't start with a URL, keep URL clean
- if (isDefaultPreset(params) && !initialQueryString) {
- // Remove URL query
- if (route.query.q) {
- isUpdatingFromUrl = true;
- router
- .replace({
- query: {
- ...route.query,
- q: undefined,
- },
- })
- .finally(() => {
- isUpdatingFromUrl = false;
- });
- }
- } else {
- // Update URL normally
- isUpdatingFromUrl = true;
- router
- .replace({
- query: {
- ...route.query,
- q: queryString || undefined,
- },
- })
- .finally(() => {
- isUpdatingFromUrl = false;
- });
- }
- }
- },
- { deep: true }
-);
-</script>
diff --git a/frontend/src/react/locales/en-US.json b/frontend/src/react/locales/en-US.json
index 5d4e3ecf1d..5d50a908b9 100644
--- a/frontend/src/react/locales/en-US.json
+++ b/frontend/src/react/locales/en-US.json
@@ -219,7 +219,8 @@
"under-review": "Under review",
"draft": "Draft",
"error": "Error",
- "type-to-search": "Type to search..."
+ "type-to-search": "Type to search...",
+ "comment": "Comment"
},
"common.add": "Add",
"common.admin": "Admin",
@@ -669,6 +670,38 @@
"creator": {
"title": "Creator",
"description": "Search by the creator"
+ },
+ "status": {
+ "description": "Search by the issue status"
+ },
+ "approval": {
+ "title": "Approval Status",
+ "description": "Search by the issue approval status",
+ "value": {
+ "checking": "Checking",
+ "pending": "Pending approval",
+ "approved": "Approved",
+ "rejected": "Rejected",
+ "skipped": "Skipped"
+ }
+ },
+ "issue-type": {
+ "title": "Type",
+ "description": "Filter by issue type",
+ "value": {
+ "database-change": "Database Change",
+ "role-grant": "Role Grant",
+ "database-export": "Database Export",
+ "access-grant": "Access Grant"
+ }
+ },
+ "current-approver": {
+ "title": "Current approver",
+ "description": "Search by the issue current approver"
+ },
+ "issue-label": {
+ "title": "Issue label",
+ "description": "Filter by issue label"
}
}
},
@@ -680,7 +713,9 @@
"risk-level": {
"high": "High",
"moderate": "Moderate",
- "self": "Risk level"
+ "self": "Risk level",
+ "filter": "Filter issues by risk level",
+ "low": "Low"
},
"role-grant": {
"all-databases": "All",
@@ -695,9 +730,27 @@
"waiting-role": "Waiting: {{role}}",
"name": "Name",
"updated": "Updated",
- "creator": "Creator"
+ "creator": "Creator",
+ "closed": "Closed"
+ },
+ "upload-sql": "Upload SQL",
+ "subtitle": "Issues cover database changes, data exports, and access requests. Review and approve before execution.",
+ "waiting-approval": "Waiting for Approval",
+ "sort": {
+ "sort": "Sort",
+ "created": "Create time",
+ "updated": "Update time",
+ "descending": "Descending",
+ "ascending": "Ascending"
+ },
+ "batch-transition": {
+ "close": "Close",
+ "reopen": "Reopen",
+ "not-allowed-tips": "Some of selected issues cannot be {{}}",
+ "closed": "closed",
+ "reopened": "reopened"
},
- "upload-sql": "Upload SQL"
+ "leave-a-comment": "Leave a comment..."
},
"label": {
"error": {
diff --git a/frontend/src/react/locales/es-ES.json b/frontend/src/react/locales/es-ES.json
index a02e83cef0..4761e45331 100644
--- a/frontend/src/react/locales/es-ES.json
+++ b/frontend/src/react/locales/es-ES.json
@@ -219,7 +219,8 @@
"under-review": "En revisión",
"draft": "Borrador",
"error": "Error",
- "type-to-search": "Escriba para buscar..."
+ "type-to-search": "Escriba para buscar...",
+ "comment": "Comentario"
},
"common.add": "Agregar",
"common.admin": "Admin",
@@ -669,6 +670,38 @@
"creator": {
"title": "Creador",
"description": "Búsqueda por creador"
+ },
+ "status": {
+ "description": "Buscar por el estado del issue"
+ },
+ "approval": {
+ "title": "Estado de aprobación",
+ "description": "Buscar por estado de revisión del problema",
+ "value": {
+ "checking": "Verificando",
+ "pending": "Aprobación pendiente",
+ "approved": "Aprobado",
+ "rejected": "Rechazado",
+ "skipped": "Omitido"
+ }
+ },
+ "issue-type": {
+ "title": "Type",
+ "description": "Filter by issue type",
+ "value": {
+ "database-change": "Database Change",
+ "role-grant": "Role Grant",
+ "database-export": "Database Export",
+ "access-grant": "Access Grant"
+ }
+ },
+ "current-approver": {
+ "title": "aprobador actual",
+ "description": "Buscar por el aprobador actual del problema"
+ },
+ "issue-label": {
+ "title": "Etiqueta de emisión",
+ "description": "Filtrar por etiqueta de problema"
}
}
},
@@ -680,7 +713,9 @@
"risk-level": {
"high": "Alto",
"moderate": "Moderado",
- "self": "Nivel de riesgo"
+ "self": "Nivel de riesgo",
+ "filter": "Filtrar por nivel de riesgo",
+ "low": "Bajo"
},
"role-grant": {
"all-databases": "todas las bases de datos",
@@ -695,9 +730,27 @@
"waiting-role": "Waiting: {{role}}",
"name": "Nombre",
"updated": "Actualizado",
- "creator": "Creador"
+ "creator": "Creador",
+ "closed": "Cerrado"
+ },
+ "upload-sql": "Upload SQL",
+ "subtitle": "Los problemas abarcan cambios en la base de datos, exportaciones de datos y solicitudes de acceso. Revisar y aprobar antes de la ejecución.",
+ "waiting-approval": "A la espera de la aprobación",
+ "sort": {
+ "sort": "Ordenar",
+ "created": "Fecha de creación",
+ "updated": "Fecha de actualización",
+ "descending": "Descendente",
+ "ascending": "Ascendente"
+ },
+ "batch-transition": {
+ "close": "Cerrar",
+ "reopen": "Reabrir",
+ "not-allowed-tips": "Algunos de las incidencias seleccionadas no se pueden {{}}",
+ "closed": "cerrado",
+ "reopened": "reabierto"
},
- "upload-sql": "Upload SQL"
+ "leave-a-comment": "Dejar un comentario..."
},
"label": {
"error": {
diff --git a/frontend/src/react/locales/ja-JP.json b/frontend/src/react/locales/ja-JP.json
index 91c3150e05..e5e4bef50d 100644
--- a/frontend/src/react/locales/ja-JP.json
+++ b/frontend/src/react/locales/ja-JP.json
@@ -219,7 +219,8 @@
"under-review": "レビュー中",
"draft": "下書き",
"error": "間違い",
- "type-to-search": "検索するには入力..."
+ "type-to-search": "検索するには入力...",
+ "comment": "コメント"
},
"common.add": "追加",
"common.admin": "管理者",
@@ -669,6 +670,38 @@
"creator": {
"title": "作成者",
"description": "作成者で検索"
+ },
+ "status": {
+ "description": "イシューのステータスで検索"
+ },
+ "approval": {
+ "title": "承認状況",
+ "description": "イシューの承認ステータスで検索する",
+ "value": {
+ "checking": "確認中",
+ "pending": "保留中",
+ "approved": "承認された",
+ "rejected": "却下",
+ "skipped": "スキップ"
+ }
+ },
+ "issue-type": {
+ "title": "Type",
+ "description": "Filter by issue type",
+ "value": {
+ "database-change": "Database Change",
+ "role-grant": "Role Grant",
+ "database-export": "Database Export",
+ "access-grant": "Access Grant"
+ }
+ },
+ "current-approver": {
+ "title": "現在の承認者",
+ "description": "イシューの現在の承認者による検索"
+ },
+ "issue-label": {
+ "title": "イシューラベル",
+ "description": "イシューラベルでフィルタリング"
}
}
},
@@ -680,7 +713,9 @@
"risk-level": {
"high": "高い",
"moderate": "適度",
- "self": "リスクレベル"
+ "self": "リスクレベル",
+ "filter": "リスクレベルでフィルタリング",
+ "low": "低い"
},
"role-grant": {
"all-databases": "すべてのデータベース",
@@ -695,9 +730,27 @@
"waiting-role": "Waiting: {{role}}",
"name": "名前",
"updated": "更新日時",
- "creator": "作成者"
+ "creator": "作成者",
+ "closed": "クローズ "
+ },
+ "upload-sql": "Upload SQL",
+ "subtitle": "イシューには、データベースの変更、データのエクスポート、アクセス要求が含まれます。実行前に確認と承認が必要です。",
+ "waiting-approval": "承認待ち",
+ "sort": {
+ "sort": "並べ替え",
+ "created": "作成日時",
+ "updated": "更新日時",
+ "descending": "降順",
+ "ascending": "昇順"
+ },
+ "batch-transition": {
+ "close": "閉じる",
+ "reopen": "再開",
+ "not-allowed-tips": "選択したイシューの一部を {{}} にすることはできません",
+ "closed": "閉まっている",
+ "reopened": "再開"
},
- "upload-sql": "Upload SQL"
+ "leave-a-comment": "コメントを残す…"
},
"label": {
"error": {
diff --git a/frontend/src/react/locales/vi-VN.json b/frontend/src/react/locales/vi-VN.json
index e68456ebbd..9faf632aec 100644
--- a/frontend/src/react/locales/vi-VN.json
+++ b/frontend/src/react/locales/vi-VN.json
@@ -219,7 +219,8 @@
"under-review": "Đang xem xét",
"draft": "Bản nháp",
"error": "Lỗi",
- "type-to-search": "Nhập để tìm kiếm..."
+ "type-to-search": "Nhập để tìm kiếm...",
+ "comment": "Bình luận"
},
"common.add": "Thêm",
"common.admin": "Quản trị viên",
@@ -669,6 +670,38 @@
"creator": {
"title": "Người tạo",
"description": "Tìm kiếm theo người sáng tạo"
+ },
+ "status": {
+ "description": "Tìm kiếm theo trạng thái issue"
+ },
+ "approval": {
+ "title": "Trạng thái phê duyệt",
+ "description": "Tìm kiếm theo trạng thái phê duyệt của vấn đề",
+ "value": {
+ "checking": "Đang kiểm tra",
+ "pending": "Đang chờ phê duyệt",
+ "approved": "Đã phê duyệt",
+ "rejected": "Đã từ chối",
+ "skipped": "Đã bỏ qua"
+ }
+ },
+ "issue-type": {
+ "title": "Type",
+ "description": "Filter by issue type",
+ "value": {
+ "database-change": "Database Change",
+ "role-grant": "Role Grant",
+ "database-export": "Database Export",
+ "access-grant": "Access Grant"
+ }
+ },
+ "current-approver": {
+ "title": "Người phê duyệt hiện tại",
+ "description": "Tìm kiếm theo người phê duyệt hiện tại"
+ },
+ "issue-label": {
+ "title": "Nhãn vấn đề",
+ "description": "Lọc theo nhãn vấn đề"
}
}
},
@@ -680,7 +713,9 @@
"risk-level": {
"high": "Cao",
"moderate": "Trung bình",
- "self": "Mức độ rủi ro"
+ "self": "Mức độ rủi ro",
+ "filter": "Lọc theo mức độ rủi ro",
+ "low": "Thấp"
},
"role-grant": {
"all-databases": "Tất cả",
@@ -695,9 +730,27 @@
"waiting-role": "Waiting: {{role}}",
"name": "Tên",
"updated": "Đã cập nhật",
- "creator": "Người tạo"
+ "creator": "Người tạo",
+ "closed": "Đã đóng"
+ },
+ "upload-sql": "Upload SQL",
+ "subtitle": "Các vấn đề bao gồm thay đổi cơ sở dữ liệu, xuất dữ liệu và yêu cầu truy cập. Cần xem xét và phê duyệt trước khi thực hiện.",
+ "waiting-approval": "Đang chờ phê duyệt",
+ "sort": {
+ "sort": "Sắp xếp",
+ "created": "Thời gian tạo",
+ "updated": "Thời gian cập nhật",
+ "descending": "Giảm dần",
+ "ascending": "Tăng dần"
+ },
+ "batch-transition": {
+ "close": "Đóng",
+ "reopen": "Mở lại",
+ "not-allowed-tips": "Một số vấn đề đã chọn không thể {{}}",
+ "closed": "đã đóng",
+ "reopened": "đã mở lại"
},
- "upload-sql": "Upload SQL"
+ "leave-a-comment": "Để lại bình luận..."
},
"label": {
"error": {
diff --git a/frontend/src/react/locales/zh-CN.json b/frontend/src/react/locales/zh-CN.json
index e354a90db1..f52f800b5a 100644
--- a/frontend/src/react/locales/zh-CN.json
+++ b/frontend/src/react/locales/zh-CN.json
@@ -219,7 +219,8 @@
"under-review": "审批中",
"draft": "草稿",
"error": "错误",
- "type-to-search": "输入搜索..."
+ "type-to-search": "输入搜索...",
+ "comment": "评论"
},
"common.add": "添加",
"common.admin": "管理员",
@@ -669,6 +670,38 @@
"creator": {
"title": "创建人",
"description": "根据创建人搜索"
+ },
+ "status": {
+ "description": "按工单状态搜索"
+ },
+ "approval": {
+ "title": "审批状态",
+ "description": "按工单的审批状态搜索",
+ "value": {
+ "checking": "检查中",
+ "pending": "待审批",
+ "approved": "审批通过",
+ "rejected": "已拒绝",
+ "skipped": "已跳过"
+ }
+ },
+ "issue-type": {
+ "title": "类型",
+ "description": "按工单类型过滤",
+ "value": {
+ "database-change": "数据库变更",
+ "role-grant": "角色授权",
+ "database-export": "数据导出",
+ "access-grant": "访问授权"
+ }
+ },
+ "current-approver": {
+ "title": "当前审批人",
+ "description": "按工单的当前审批人搜索"
+ },
+ "issue-label": {
+ "title": "工单标签",
+ "description": "按工单标签过滤"
}
}
},
@@ -680,7 +713,9 @@
"risk-level": {
"high": "高风险",
"moderate": "中风险",
- "self": "风险等级"
+ "self": "风险等级",
+ "filter": "按风险等级筛选",
+ "low": "低风险"
},
"role-grant": {
"all-databases": "所有数据库",
@@ -695,9 +730,27 @@
"waiting-role": "等待: {{role}}",
"name": "名称",
"updated": "更新于",
- "creator": "创建人"
+ "creator": "创建人",
+ "closed": "已关闭"
+ },
+ "upload-sql": "上传 SQL",
+ "subtitle": "工单涵盖数据库变更、数据导出和权限申请。执行前需审查和审批。",
+ "waiting-approval": "等待审批",
+ "sort": {
+ "sort": "排序",
+ "created": "创建时间",
+ "updated": "更新时间",
+ "descending": "倒序",
+ "ascending": "正序"
+ },
+ "batch-transition": {
+ "close": "关闭",
+ "reopen": "重开",
+ "not-allowed-tips": "部分选中的工单无法被{{}}",
+ "closed": "关闭",
+ "reopened": "重开"
},
- "upload-sql": "上传 SQL"
+ "leave-a-comment": "发表一条评论…"
},
"label": {
"error": {
diff --git a/frontend/src/react/pages/project/ProjectIssueDashboardPage.tsx b/frontend/src/react/pages/project/ProjectIssueDashboardPage.tsx
new file mode 100644
index 0000000000..e3940a6678
--- /dev/null
+++ b/frontend/src/react/pages/project/ProjectIssueDashboardPage.tsx
@@ -0,0 +1,1521 @@
+import { create } from "@bufbuild/protobuf";
+import dayjs from "dayjs";
+import { ArrowUpDown, Calendar, Check, Loader2, X } from "lucide-react";
+import { useCallback, useEffect, useMemo, useRef, useState } from "react";
+import { useTranslation } from "react-i18next";
+import { issueServiceClientConnect } from "@/connect";
+import {
+ AdvancedSearch,
+ type ScopeOption,
+ type SearchParams,
+ type ValueOption,
+} from "@/react/components/AdvancedSearch";
+import { HumanizeTs } from "@/react/components/HumanizeTs";
+import { Button } from "@/react/components/ui/button";
+import { Tooltip } from "@/react/components/ui/tooltip";
+import { useClickOutside } from "@/react/hooks/useClickOutside";
+import { useEscapeKey } from "@/react/hooks/useEscapeKey";
+import { PagedTableFooter, usePagedData } from "@/react/hooks/usePagedData";
+import { useVueState } from "@/react/hooks/useVueState";
+import { cn } from "@/react/lib/utils";
+import { router } from "@/router";
+import { WORKSPACE_ROUTE_USER_PROFILE } from "@/router/dashboard/workspaceRoutes";
+import {
+ pushNotification,
+ refreshIssueList,
+ useCurrentUserV1,
+ useIssueV1Store,
+ useProjectV1Store,
+ useUIStateStore,
+ useUserStore,
+} from "@/store";
+import { projectNamePrefix } from "@/store/modules/v1/common";
+import {
+ getTimeForPbTimestampProtoEs,
+ isValidProjectName,
+ unknownUser,
+} from "@/types";
+import { RiskLevel } from "@/types/proto-es/v1/common_pb";
+import type { Issue } from "@/types/proto-es/v1/issue_service_pb";
+import {
+ BatchUpdateIssuesStatusRequestSchema,
+ Issue_ApprovalStatus,
+ Issue_Type,
+ IssueStatus,
+} from "@/types/proto-es/v1/issue_service_pb";
+import type { Label } from "@/types/proto-es/v1/project_service_pb";
+import {
+ buildIssueFilterBySearchParams,
+ buildSearchParamsBySearchText,
+ buildSearchTextBySearchParams,
+ displayRoleTitle,
+ extractIssueUID,
+ getHighlightHTMLByRegExp,
+ getIssueRoute,
+ getTsRangeFromSearchParams,
+ getValueFromSearchParams,
+ getValuesFromSearchParams,
+ mergeSearchParams,
+ projectOfIssue,
+ upsertScope,
+ type SearchParams as VueSearchParams,
+ type SearchScope as VueSearchScope,
+} from "@/utils";
+
+// ===========================================================================
+// Main Page
+// ===========================================================================
+
+export function ProjectIssueDashboardPage({
+ projectId,
+}: {
+ projectId: string;
+}) {
+ const { t } = useTranslation();
+ const issueStore = useIssueV1Store();
+ const uiStateStore = useUIStateStore();
+ const currentUser = useCurrentUserV1();
+ const me = useVueState(() => currentUser.value);
+
+ const projectName = `${projectNamePrefix}${projectId}`;
+ // Hint
+ const HINT_KEY = "issue.hint-dismissed";
+ const hideHint = useVueState(() => uiStateStore.getIntroStateByKey(HINT_KEY));
+ const dismissHint = useCallback(() => {
+ uiStateStore.saveIntroStateByKey({ key: HINT_KEY, newState: true });
+ }, [uiStateStore]);
+
+ // Read-only scopes
+ const readonlyScopes: VueSearchScope[] = useMemo(
+ () => [{ id: "project", value: projectId, readonly: true }],
+ [projectId]
+ );
+
+ const defaultSearchParams = useCallback((): SearchParams => {
+ const myEmail = me?.email ?? "";
+ return {
+ query: "",
+ scopes: [
+ ...readonlyScopes.map((s) => ({
+ id: s.id,
+ value: s.value,
+ readonly: s.readonly,
+ })),
+ { id: "status", value: IssueStatus[IssueStatus.OPEN] },
+ {
+ id: "approval",
+ value: Issue_ApprovalStatus[Issue_ApprovalStatus.PENDING],
+ },
+ { id: "current-approver", value: myEmail },
+ ],
+ };
+ }, [readonlyScopes, me]);
+
+ // Initialize from URL or defaults
+ const initialQueryRef = useRef<string | null>(null);
+ const [searchParams, setSearchParams] = useState<SearchParams>(() => {
+ const urlQ = new URLSearchParams(window.location.search).get("q") ?? null;
+ initialQueryRef.current = urlQ;
+ if (urlQ) {
+ const urlParams = buildSearchParamsBySearchText(urlQ);
+ const base: VueSearchParams = {
+ query: "",
+ scopes: readonlyScopes as VueSearchScope[],
+ };
+ const merged = mergeSearchParams(base, urlParams as VueSearchParams);
+ return {
+ query: merged.query,
+ scopes: merged.scopes.map((s) => ({
+ id: s.id,
+ value: s.value,
+ readonly: (s as VueSearchScope & { readonly?: boolean }).readonly,
+ })),
+ };
+ }
+ return defaultSearchParams();
+ });
+
+ const [orderBy, setOrderBy] = useState("");
+
+ // Reset on project change
+ useEffect(() => {
+ setSearchParams(defaultSearchParams());
+ }, [projectId]);
+
+ // URL sync
+ const isUpdatingUrl = useRef(false);
+ useEffect(() => {
+ if (isUpdatingUrl.current) return;
+ const queryString = buildSearchTextBySearchParams(
+ searchParams as VueSearchParams
+ );
+ const currentQ = new URLSearchParams(window.location.search).get("q");
+ if (queryString === currentQ) return;
+
+ const isDefault =
+ queryString ===
+ buildSearchTextBySearchParams(defaultSearchParams() as VueSearchParams);
+ if (isDefault && !initialQueryRef.current) {
+ if (currentQ) {
+ isUpdatingUrl.current = true;
+ router
+ .replace({
+ query: { ...router.currentRoute.value.query, q: undefined },
+ })
+ .finally(() => {
+ isUpdatingUrl.current = false;
+ });
+ }
+ } else {
+ isUpdatingUrl.current = true;
+ router
+ .replace({
+ query: {
+ ...router.currentRoute.value.query,
+ q: queryString || undefined,
+ },
+ })
+ .finally(() => {
+ isUpdatingUrl.current = false;
+ });
+ }
+ }, [searchParams]);
+
+ // Issue filter
+ const issueFilter = useMemo(() => {
+ const filter = buildIssueFilterBySearchParams(
+ searchParams as VueSearchParams
+ );
+ filter.orderBy = orderBy;
+ return filter;
+ }, [searchParams, orderBy]);
+
+ const fetchIssueList = useCallback(
+ async (params: { pageSize: number; pageToken: string }) => {
+ const { nextPageToken, issues } = await issueStore.listIssues({
+ find: issueFilter,
+ pageSize: params.pageSize,
+ pageToken: params.pageToken,
+ });
+ return { list: issues, nextPageToken };
+ },
+ [issueStore, issueFilter]
+ );
+
+ const paged = usePagedData<Issue>({
+ sessionKey: "bb.issue-table.project-issues",
+ fetchList: fetchIssueList,
+ });
+
+ // Listen for external refresh signals (Vue store)
+ useEffect(() => {
+ // Subscribe to Vue's refreshIssueList signal via a polling check
+ // This is a cross-framework bridge - the Vue side calls refreshIssueList()
+ // which updates a ref. We can't directly watch it, but paged.refresh()
+ // is called when issueFilter changes (which covers most cases).
+ }, []);
+
+ // Scope options
+ const scopeOptions = useIssueSearchScopeOptions(projectName);
+
+ // Selection state
+ const [selectedNames, setSelectedNames] = useState<Set<string>>(new Set());
+
+ // Clear stale selections when data changes
+ useEffect(() => {
+ setSelectedNames((prev) => {
+ const current = new Set(paged.dataList.map((i) => i.name));
+ const next = new Set<string>();
+ for (const name of prev) {
+ if (current.has(name)) next.add(name);
+ }
+ return next.size === prev.size ? prev : next;
+ });
+ }, [paged.dataList]);
+
+ const selectedIssues = useMemo(
+ () => paged.dataList.filter((i) => selectedNames.has(i.name)),
+ [paged.dataList, selectedNames]
+ );
+
+ const toggleSelection = useCallback((name: string) => {
+ setSelectedNames((prev) => {
+ const next = new Set(prev);
+ if (next.has(name)) next.delete(name);
+ else next.add(name);
+ return next;
+ });
+ }, []);
+
+ const toggleSelectAll = useCallback(() => {
+ setSelectedNames((prev) => {
+ const allSelected =
+ paged.dataList.length > 0 &&
+ paged.dataList.every((i) => prev.has(i.name));
+ if (allSelected) return new Set();
+ return new Set(paged.dataList.map((i) => i.name));
+ });
+ }, [paged.dataList]);
+
+ // Batch actions
+ const [batchAction, setBatchAction] = useState<
+ "CLOSE" | "REOPEN" | undefined
+ >();
+
+ const handleBatchUpdated = useCallback(() => {
+ setBatchAction(undefined);
+ setSelectedNames(new Set());
+ refreshIssueList();
+ paged.refresh();
+ }, [paged]);
+
+ return (
+ <div className="py-4 flex flex-col">
+ <div className="px-4 flex flex-col gap-y-2">
+ {!hideHint && (
+ <DismissibleAlert onClose={dismissHint}>
+ {t("issue.subtitle")}
+ </DismissibleAlert>
+ )}
+ <IssueSearchBar
+ params={searchParams}
+ onParamsChange={setSearchParams}
+ orderBy={orderBy}
+ onOrderByChange={setOrderBy}
+ scopeOptions={scopeOptions}
+ />
+ <PresetButtons params={searchParams} onParamsChange={setSearchParams} />
+ </div>
+
+ {/* Issue list */}
+ <div className="mt-2">
+ {paged.isLoading ? (
+ <div className="flex justify-center py-8 text-control-light">
+ <Loader2 className="w-5 h-5 animate-spin" />
+ </div>
+ ) : paged.dataList.length === 0 ? (
+ <div className="flex justify-center py-8 text-control-light">
+ {t("common.no-data")}
+ </div>
+ ) : (
+ paged.dataList.map((issue) => (
+ <IssueListItem
+ key={issue.name}
+ issue={issue}
+ selected={selectedNames.has(issue.name)}
+ onToggleSelection={() => toggleSelection(issue.name)}
+ highlightText={searchParams.query}
+ />
+ ))
+ )}
+
+ {paged.dataList.length > 0 && (
+ <div className="mx-4 mt-3">
+ <PagedTableFooter
+ pageSize={paged.pageSize}
+ pageSizeOptions={paged.pageSizeOptions}
+ onPageSizeChange={paged.onPageSizeChange}
+ hasMore={paged.hasMore}
+ isFetchingMore={paged.isFetchingMore}
+ onLoadMore={paged.loadMore}
+ />
+ </div>
+ )}
+ </div>
+
+ {/* Batch action bar */}
+ {selectedIssues.length > 0 && (
+ <BatchActionBar
+ issues={selectedIssues}
+ allSelected={
+ paged.dataList.length > 0 &&
+ paged.dataList.every((i) => selectedNames.has(i.name))
+ }
+ onToggleSelectAll={toggleSelectAll}
+ onStartAction={setBatchAction}
+ />
+ )}
+
+ {/* Batch action drawer */}
+ <BatchIssueStatusActionDrawer
+ issues={selectedIssues}
+ action={batchAction}
+ onClose={() => setBatchAction(undefined)}
+ onUpdated={handleBatchUpdated}
+ />
+ </div>
+ );
+}
+
+// ===========================================================================
+// DismissibleAlert
+// ===========================================================================
+
+function DismissibleAlert({
+ children,
+ onClose,
+}: {
+ children: React.ReactNode;
+ onClose: () => void;
+}) {
+ return (
+ <div className="relative w-full rounded-xs border border-accent/30 bg-accent/5 text-accent px-4 py-3 text-sm flex gap-x-3 items-start">
+ <svg
+ className="h-5 w-5 shrink-0 mt-0.5"
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ strokeWidth={2}
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ >
+ <circle cx="12" cy="12" r="10" />
+ <path d="M12 16v-4" />
+ <path d="M12 8h.01" />
+ </svg>
+ <div className="flex-1">{children}</div>
+ <button
+ className="p-0.5 hover:bg-accent/10 rounded-xs shrink-0"
+ onClick={onClose}
+ >
+ <X className="h-4 w-4" />
+ </button>
+ </div>
+ );
+}
+
+// ===========================================================================
+// IssueSearchBar (AdvancedSearch + TimeRange + Sort)
+// ===========================================================================
+
+function IssueSearchBar({
+ params,
+ onParamsChange,
+ orderBy,
+ onOrderByChange,
+ scopeOptions,
+}: {
+ params: SearchParams;
+ onParamsChange: (p: SearchParams) => void;
+ orderBy: string;
+ onOrderByChange: (v: string) => void;
+ scopeOptions: ScopeOption[];
+}) {
+ return (
+ <div className="flex items-center md:gap-2">
+ <div className="flex-1 min-w-0">
+ <AdvancedSearch
+ params={params}
+ onParamsChange={onParamsChange}
+ scopeOptions={scopeOptions}
+ />
+ </div>
+ <TimeRangePicker params={params} onParamsChange={onParamsChange} />
+ <IssueSortDropdown orderBy={orderBy} onOrderByChange={onOrderByChange} />
+ </div>
+ );
+}
+
+// ===========================================================================
+// TimeRangePicker
+// ===========================================================================
+
+function TimeRangePicker({
+ params,
+ onParamsChange,
+}: {
+ params: SearchParams;
+ onParamsChange: (p: SearchParams) => void;
+}) {
+ const { t } = useTranslation();
+ const [from, setFrom] = useState("");
+ const [to, setTo] = useState("");
+ const [open, setOpen] = useState(false);
+ const containerRef = useRef<HTMLDivElement>(null);
+ useClickOutside(containerRef, open, () => setOpen(false));
+
+ const timeRange = useMemo(
+ () => getTsRangeFromSearchParams(params as VueSearchParams, "created"),
+ [params]
+ );
+
+ const hasRange = !!timeRange;
+
+ useEffect(() => {
+ if (timeRange) {
+ setFrom(dayjs(timeRange[0]).format("YYYY-MM-DD"));
+ setTo(dayjs(timeRange[1]).format("YYYY-MM-DD"));
+ } else {
+ setFrom("");
+ setTo("");
+ }
+ }, [timeRange]);
+
+ const applyRange = useCallback(() => {
+ const fromTs = from ? dayjs(from).startOf("day").valueOf() : null;
+ const toTs = to ? dayjs(to).endOf("day").valueOf() : null;
+ const updated = upsertScope({
+ params: params as VueSearchParams,
+ scopes: {
+ id: "created",
+ value: fromTs && toTs ? `${fromTs},${toTs}` : "",
+ },
+ });
+ onParamsChange({
+ query: updated.query,
+ scopes: updated.scopes.map((s) => ({
+ id: s.id,
+ value: s.value,
+ readonly: (s as VueSearchScope & { readonly?: boolean }).readonly,
+ })),
+ });
+ setOpen(false);
+ }, [from, to, params, onParamsChange]);
+
+ const clearRange = useCallback(() => {
+ const updated = upsertScope({
+ params: params as VueSearchParams,
+ scopes: { id: "created", value: "" },
+ });
+ onParamsChange({
+ query: updated.query,
+ scopes: updated.scopes.map((s) => ({
+ id: s.id,
+ value: s.value,
+ readonly: (s as VueSearchScope & { readonly?: boolean }).readonly,
+ })),
+ });
+ setOpen(false);
+ }, [params, onParamsChange]);
+
+ return (
+ <div ref={containerRef} className="relative">
+ <Button
+ variant="ghost"
+ size="sm"
+ className={cn(
+ hasRange
+ ? "text-accent! hover:text-accent"
+ : "text-control-placeholder hover:text-control"
+ )}
+ onClick={() => setOpen(!open)}
+ >
+ <Calendar className="w-4 h-4" />
+ </Button>
+ {open && (
+ <div className="absolute right-0 top-full mt-1 z-50 bg-white border border-gray-200 rounded-sm shadow-lg p-3 flex flex-col gap-2 min-w-[240px]">
+ <label className="text-xs text-control-light">
+ {t("common.from")}
+ </label>
+ <input
+ type="date"
+ className="border border-control-border rounded-sm px-2 py-1 text-sm"
+ value={from}
+ max={dayjs().format("YYYY-MM-DD")}
+ onChange={(e) => setFrom(e.target.value)}
+ />
+ <label className="text-xs text-control-light">{t("common.to")}</label>
+ <input
+ type="date"
+ className="border border-control-border rounded-sm px-2 py-1 text-sm"
+ value={to}
+ max={dayjs().format("YYYY-MM-DD")}
+ onChange={(e) => setTo(e.target.value)}
+ />
+ <div className="flex items-center gap-x-2 mt-1">
+ <Button size="sm" onClick={applyRange} disabled={!from || !to}>
+ {t("common.confirm")}
+ </Button>
+ {hasRange && (
+ <Button variant="ghost" size="sm" onClick={clearRange}>
+ {t("common.clear")}
+ </Button>
+ )}
+ </div>
+ </div>
+ )}
+ </div>
+ );
+}
+
+// ===========================================================================
+// IssueSortDropdown
+// ===========================================================================
+
+function IssueSortDropdown({
+ orderBy,
+ onOrderByChange,
+}: {
+ orderBy: string;
+ onOrderByChange: (v: string) => void;
+}) {
+ const { t } = useTranslation();
+ const [open, setOpen] = useState(false);
+ const containerRef = useRef<HTMLDivElement>(null);
+ useClickOutside(containerRef, open, () => setOpen(false));
+
+ const sortOptions = useMemo(
+ () => [
+ {
+ label: t("issue.sort.created"),
+ children: [
+ { key: "create_time desc", label: t("issue.sort.descending") },
+ { key: "create_time asc", label: t("issue.sort.ascending") },
+ ],
+ },
+ {
+ label: t("issue.sort.updated"),
+ children: [
+ { key: "update_time desc", label: t("issue.sort.descending") },
+ { key: "update_time asc", label: t("issue.sort.ascending") },
+ ],
+ },
+ ],
+ [t]
+ );
+
+ const handleSelect = (key: string) => {
+ onOrderByChange(key === orderBy ? "" : key);
+ setOpen(false);
+ };
+
+ return (
+ <div ref={containerRef} className="relative">
+ <Button
+ variant="ghost"
+ size="sm"
+ className={cn(
+ orderBy
+ ? "text-accent! hover:text-accent"
+ : "text-control-placeholder hover:text-control"
+ )}
+ onClick={() => setOpen(!open)}
+ >
+ <ArrowUpDown className="w-4 h-4" />
+ <span className="hidden md:inline ml-1">{t("issue.sort.sort")}</span>
+ </Button>
+ {open && (
+ <div className="absolute right-0 top-full mt-1 z-50 bg-white border border-gray-200 rounded-sm shadow-lg min-w-[180px] py-1">
+ {sortOptions.map((group) => (
+ <div key={group.label}>
+ <div className="px-3 py-1.5 text-xs text-control-light font-medium">
+ {group.label}
+ </div>
+ {group.children.map((opt) => (
+ <button
+ key={opt.key}
+ type="button"
+ className="w-full text-left px-3 py-1.5 text-sm hover:bg-gray-50 flex items-center gap-x-2"
+ onClick={() => handleSelect(opt.key)}
+ >
+ <Check
+ className={cn(
+ "w-3 h-3",
+ orderBy === opt.key ? "text-accent" : "text-transparent"
+ )}
+ />
+ {opt.label}
+ </button>
+ ))}
+ </div>
+ ))}
+ </div>
+ )}
+ </div>
+ );
+}
+
+// ===========================================================================
+// PresetButtons
+// ===========================================================================
+
+function PresetButtons({
+ params,
+ onParamsChange,
+}: {
+ params: SearchParams;
+ onParamsChange: (p: SearchParams) => void;
+}) {
+ const { t } = useTranslation();
+ const currentUser = useCurrentUserV1();
+ const me = useVueState(() => currentUser.value);
+
+ type PresetValue = "WAITING_APPROVAL" | "OPEN" | "CLOSED" | "ALL";
+
+ const presets: { value: PresetValue; label: string }[] = useMemo(
+ () => [
+ { value: "WAITING_APPROVAL", label: t("issue.waiting-approval") },
+ { value: "OPEN", label: t("issue.table.open") },
+ { value: "CLOSED", label: t("issue.table.closed") },
+ { value: "ALL", label: t("common.all") },
+ ],
+ [t]
+ );
+
+ const isActive = useCallback(
+ (preset: PresetValue): boolean => {
+ const vp = params as VueSearchParams;
+ if (preset === "WAITING_APPROVAL") {
+ return (
+ getValueFromSearchParams(vp, "approval") ===
+ Issue_ApprovalStatus[Issue_ApprovalStatus.PENDING]
+ );
+ }
+ if (preset === "OPEN") {
+ const status = getValueFromSearchParams(vp, "status");
+ const approval = getValueFromSearchParams(vp, "approval");
+ return status === IssueStatus[IssueStatus.OPEN] && !approval;
+ }
+ const statuses = getValuesFromSearchParams(vp, "status");
+ if (preset === "CLOSED") {
+ return (
+ statuses.includes(IssueStatus[IssueStatus.DONE]) &&
+ !statuses.includes(IssueStatus[IssueStatus.OPEN])
+ );
+ }
+ if (preset === "ALL") {
+ return statuses.length === 0;
+ }
+ return false;
+ },
+ [params]
+ );
+
+ const activePreset = presets.find((p) => isActive(p.value))?.value ?? "";
+
+ const selectPreset = useCallback(
+ (preset: PresetValue) => {
+ const myEmail = me?.email ?? "";
+ const readonlyScopes = params.scopes.filter((s) => s.readonly);
+ let newParams: VueSearchParams = {
+ query: "",
+ scopes: [...readonlyScopes],
+ };
+
+ if (preset === "WAITING_APPROVAL") {
+ newParams = upsertScope({
+ params: newParams,
+ scopes: [
+ { id: "status", value: IssueStatus[IssueStatus.OPEN] },
+ {
+ id: "approval",
+ value: Issue_ApprovalStatus[Issue_ApprovalStatus.PENDING],
+ },
+ { id: "current-approver", value: myEmail },
+ ],
+ });
+ } else if (preset === "OPEN") {
+ newParams = upsertScope({
+ params: newParams,
+ scopes: [{ id: "status", value: IssueStatus[IssueStatus.OPEN] }],
+ });
+ } else if (preset === "CLOSED") {
+ newParams = upsertScope({
+ params: newParams,
+ scopes: [
+ { id: "status", value: IssueStatus[IssueStatus.DONE] },
+ { id: "status", value: IssueStatus[IssueStatus.CANCELED] },
+ ],
+ allowMultiple: true,
+ });
+ }
+
+ onParamsChange({
+ query: newParams.query,
+ scopes: newParams.scopes.map((s) => ({
+ id: s.id,
+ value: s.value,
+ readonly: (s as VueSearchScope & { readonly?: boolean }).readonly,
+ })),
+ });
+ },
+ [params, me, onParamsChange]
+ );
+
+ return (
+ <div className="shrink-0 flex border-b border-control-border">
+ {presets.map((preset) => (
+ <button
+ key={preset.value}
+ type="button"
+ className={cn(
+ "px-3 py-1.5 text-sm font-medium border-b-2 -mb-px transition-colors",
+ activePreset === preset.value
+ ? "border-accent text-accent"
+ : "border-transparent text-control-light hover:text-control"
+ )}
+ onClick={() => selectPreset(preset.value)}
+ >
+ {preset.label}
+ </button>
+ ))}
+ </div>
+ );
+}
+
+// ===========================================================================
+// useIssueSearchScopeOptions
+// ===========================================================================
+
+function useIssueSearchScopeOptions(projectName: string): ScopeOption[] {
+ const { t } = useTranslation();
+ const userStore = useUserStore();
+ const projectStore = useProjectV1Store();
+ const currentUser = useCurrentUserV1();
+ const me = useVueState(() => currentUser.value);
+
+ const [projectLabels, setProjectLabels] = useState<Label[]>([]);
+
+ useEffect(() => {
+ if (!isValidProjectName(projectName)) return;
+ projectStore.getOrFetchProjectByName(projectName).then((project) => {
+ const labels = new Map<string, Label>();
+ for (const label of project.issueLabels) {
+ labels.set(`${label.value}-${label.color}`, label);
+ }
+ setProjectLabels([...labels.values()]);
+ });
+ }, [projectName, projectStore]);
+
+ const searchPrincipal = useCallback(
+ async (keyword: string): Promise<ValueOption[]> => {
+ const resp = await userStore.fetchUserList({
+ pageSize: 50,
+ filter: { query: keyword },
+ });
+ return resp.users.map<ValueOption>((user) => ({
+ value: user.email,
+ keywords: [user.email, user.title],
+ render: () => (
+ <div className="flex items-center gap-x-1">
+ <span>{user.title}</span>
+ {user.name === me?.name && (
+ <span className="text-xs text-control-light">
+ ({t("common.you")})
+ </span>
+ )}
+ </div>
+ ),
+ }));
+ },
+ [userStore, me, t]
+ );
+
+ return useMemo(
+ (): ScopeOption[] => [
+ {
+ id: "status",
+ title: t("common.status"),
+ description: t("issue.advanced-search.scope.status.description"),
+ allowMultiple: true,
+ options: [
+ {
+ value: IssueStatus[IssueStatus.OPEN],
+ keywords: ["open"],
+ render: () => <span>{t("issue.table.open")}</span>,
+ },
+ {
+ value: IssueStatus[IssueStatus.DONE],
+ keywords: ["closed", "done"],
+ render: () => <span>{t("common.approved")}</span>,
+ },
+ {
+ value: IssueStatus[IssueStatus.CANCELED],
+ keywords: ["closed", "canceled"],
+ render: () => <span>{t("common.closed")}</span>,
+ },
+ ],
+ },
+ {
+ id: "approval",
+ title: t("issue.advanced-search.scope.approval.title"),
+ description: t("issue.advanced-search.scope.approval.description"),
+ options: [
+ {
+ value: Issue_ApprovalStatus[Issue_ApprovalStatus.CHECKING],
+ keywords: ["checking"],
+ render: () => (
+ <span>
+ {t("issue.advanced-search.scope.approval.value.checking")}
+ </span>
+ ),
+ },
+ {
+ value: Issue_ApprovalStatus[Issue_ApprovalStatus.PENDING],
+ keywords: ["pending"],
+ render: () => (
+ <span>
+ {t("issue.advanced-search.scope.approval.value.pending")}
+ </span>
+ ),
+ },
+ {
+ value: Issue_ApprovalStatus[Issue_ApprovalStatus.APPROVED],
+ keywords: ["approved", "done"],
+ render: () => (
+ <span>
+ {t("issue.advanced-search.scope.approval.value.approved")}
+ </span>
+ ),
+ },
+ {
+ value: Issue_ApprovalStatus[Issue_ApprovalStatus.REJECTED],
+ keywords: ["rejected"],
+ render: () => (
+ <span>
+ {t("issue.advanced-search.scope.approval.value.rejected")}
+ </span>
+ ),
+ },
+ {
+ value: Issue_ApprovalStatus[Issue_ApprovalStatus.SKIPPED],
+ keywords: ["skipped"],
+ render: () => (
+ <span>
+ {t("issue.advanced-search.scope.approval.value.skipped")}
+ </span>
+ ),
+ },
+ ],
+ },
+ {
+ id: "issue-type",
+ title: t("issue.advanced-search.scope.issue-type.title"),
+ description: t("issue.advanced-search.scope.issue-type.description"),
+ allowMultiple: true,
+ options: [
+ {
+ value: Issue_Type[Issue_Type.DATABASE_CHANGE],
+ keywords: ["database", "change"],
+ render: () => (
+ <span>
+ {t(
+ "issue.advanced-search.scope.issue-type.value.database-change"
+ )}
+ </span>
+ ),
+ },
+ {
+ value: Issue_Type[Issue_Type.ROLE_GRANT],
+ keywords: ["grant", "request"],
+ render: () => (
+ <span>
+ {t("issue.advanced-search.scope.issue-type.value.role-grant")}
+ </span>
+ ),
+ },
+ {
+ value: Issue_Type[Issue_Type.DATABASE_EXPORT],
+ keywords: ["database", "export"],
+ render: () => (
+ <span>
+ {t(
+ "issue.advanced-search.scope.issue-type.value.database-export"
+ )}
+ </span>
+ ),
+ },
+ {
+ value: Issue_Type[Issue_Type.ACCESS_GRANT],
+ keywords: ["access", "grant"],
+ render: () => (
+ <span>
+ {t("issue.advanced-search.scope.issue-type.value.access-grant")}
+ </span>
+ ),
+ },
+ ],
+ },
+ {
+ id: "creator",
+ title: t("issue.advanced-search.scope.creator.title"),
+ description: t("issue.advanced-search.scope.creator.description"),
+ onSearch: searchPrincipal,
+ },
+ {
+ id: "current-approver",
+ title: t("issue.advanced-search.scope.current-approver.title"),
+ description: t(
+ "issue.advanced-search.scope.current-approver.description"
+ ),
+ onSearch: searchPrincipal,
+ },
+ {
+ id: "issue-label",
+ title: t("issue.advanced-search.scope.issue-label.title"),
+ description: t("issue.advanced-search.scope.issue-label.description"),
+ allowMultiple: true,
+ options: projectLabels.map((label) => ({
+ value: label.value,
+ keywords: [label.value],
+ render: () => (
+ <div className="flex items-center gap-x-2">
+ <div
+ className="w-4 h-4 rounded-sm"
+ style={{ backgroundColor: label.color }}
+ />
+ {label.value}
+ </div>
+ ),
+ })),
+ },
+ {
+ id: "risk-level",
+ title: t("issue.risk-level.self"),
+ description: t("issue.risk-level.filter"),
+ allowMultiple: true,
+ options: [
+ {
+ value: RiskLevel[RiskLevel.HIGH],
+ keywords: ["high"],
+ render: () => <span>{t("issue.risk-level.high")}</span>,
+ },
+ {
+ value: RiskLevel[RiskLevel.MODERATE],
+ keywords: ["moderate"],
+ render: () => <span>{t("issue.risk-level.moderate")}</span>,
+ },
+ {
+ value: RiskLevel[RiskLevel.LOW],
+ keywords: ["low"],
+ render: () => <span>{t("issue.risk-level.low")}</span>,
+ },
+ ],
+ },
+ ],
+ [t, searchPrincipal, projectLabels]
+ );
+}
+
+// ===========================================================================
+// IssueListItem
+// ===========================================================================
+
+function IssueListItem({
+ issue,
+ selected,
+ onToggleSelection,
+ highlightText = "",
+}: {
+ issue: Issue;
+ selected: boolean;
+ onToggleSelection: () => void;
+ highlightText?: string;
+}) {
+ const { t } = useTranslation();
+ const userStore = useUserStore();
+
+ const creator =
+ userStore.getUserByIdentifier(issue.creator) || unknownUser(issue.creator);
+
+ const issueProject = useMemo(() => projectOfIssue(issue), [issue]);
+
+ const createTimeTs = Math.floor(
+ getTimeForPbTimestampProtoEs(issue.createTime, 0) / 1000
+ );
+
+ const issueUrl = useMemo(() => {
+ const issueRoute = getIssueRoute(issue);
+ return router.resolve({
+ name: issueRoute.name,
+ params: issueRoute.params,
+ }).fullPath;
+ }, [issue.name]);
+
+ const onRowClick = useCallback(
+ (e: React.MouseEvent) => {
+ if (e.ctrlKey || e.metaKey) {
+ window.open(issueUrl, "_blank");
+ } else {
+ router.push(issueUrl);
+ }
+ },
+ [issueUrl]
+ );
+
+ // Labels
+ const labels = useMemo(() => {
+ if (!issueProject?.issueLabels) return [];
+ const pool = new Set(issueProject.issueLabels.map((l: Label) => l.value));
+ const validValues = issue.labels.filter((l) => pool.has(l));
+ return issueProject.issueLabels.filter((l: Label) =>
+ validValues.includes(l.value)
+ );
+ }, [issue.labels, issueProject]);
+
+ // Search highlighting
+ const highlightWords = useMemo(
+ () => (highlightText ? highlightText.toLowerCase().split(" ") : []),
+ [highlightText]
+ );
+
+ const highlightedTitle = useMemo(
+ () =>
+ getHighlightHTMLByRegExp(
+ issue.title,
+ highlightWords,
+ false,
+ "bg-yellow-100"
+ ),
+ [issue.title, highlightWords]
+ );
+
+ const highlightedDescription = useMemo(
+ () =>
+ getHighlightHTMLByRegExp(
+ issue.description,
+ highlightWords,
+ false,
+ "bg-yellow-100"
+ ),
+ [issue.description, highlightWords]
+ );
+
+ const expanded =
+ highlightText &&
+ issue.description &&
+ highlightWords.some((word) =>
+ issue.description.toLowerCase().includes(word)
+ );
+
+ return (
+ <div
+ className="flex items-start gap-x-2 px-3 sm:px-4 py-3 cursor-pointer border-b border-gray-100 hover:bg-gray-50"
+ onClick={onRowClick}
+ >
+ {/* Checkbox */}
+ <input
+ type="checkbox"
+ className="shrink-0 mt-1 accent-accent"
+ checked={selected}
+ onChange={(e) => {
+ e.stopPropagation();
+ onToggleSelection();
+ }}
+ onClick={(e) => e.stopPropagation()}
+ />
+
+ {/* Content + Approval */}
+ <div className="flex-1 min-w-0 flex flex-col sm:flex-row sm:items-start sm:gap-x-2">
+ {/* Left: issue content */}
+ <div className="flex-1 min-w-0">
+ {/* Line 1: status icon + title + labels */}
+ <div className="flex items-center gap-x-1.5">
+ <div className="h-6 flex justify-center items-center">
+ <IssueStatusIcon status={issue.status} />
+ </div>
+ {issue.title ? (
+ <a
+ href={issueUrl}
+ className="font-medium text-main text-base truncate hover:underline"
+ onClick={(e) => e.stopPropagation()}
+ dangerouslySetInnerHTML={{ __html: highlightedTitle }}
+ />
+ ) : (
+ <a
+ href={issueUrl}
+ className="font-medium text-base truncate hover:underline italic text-gray-400"
+ onClick={(e) => e.stopPropagation()}
+ >
+ {t("common.untitled")}
+ </a>
+ )}
+ <RiskLevelIcon riskLevel={issue.riskLevel} />
+ {labels.map((label: Label) => (
+ <span
+ key={label.value}
+ className="inline-flex items-center gap-x-1 px-1.5 py-0.5 rounded-xs text-xs whitespace-nowrap border shrink-0"
+ >
+ <span
+ className="w-2.5 h-2.5 rounded-sm shrink-0"
+ style={{ backgroundColor: label.color }}
+ />
+ {label.value}
+ </span>
+ ))}
+ </div>
+ {/* Line 2: metadata */}
+ <div className="flex items-center flex-wrap gap-x-1 text-xs text-control-light mt-1">
+ <span className="opacity-80">#{extractIssueUID(issue.name)}</span>
+ <span>&middot;</span>
+ {t("common.created")}
+ <HumanizeTs ts={createTimeTs} />
+ <span>&middot;</span>
+ <a
+ className="hover:underline"
+ href="#"
+ onClick={(e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ router.push({
+ name: WORKSPACE_ROUTE_USER_PROFILE,
+ params: { principalEmail: creator.email },
+ });
+ }}
+ >
+ {creator.title}
+ </a>
+ </div>
+ {/* Expanded description */}
+ {expanded && (
+ <div
+ className="mt-2 max-h-80 overflow-auto whitespace-pre-wrap break-all text-sm text-control-light"
+ dangerouslySetInnerHTML={{ __html: highlightedDescription }}
+ />
+ )}
+ </div>
+
+ {/* Right: approval status */}
+ <IssueApprovalStatusTag issue={issue} />
+ </div>
+ </div>
+ );
+}
+
+// ===========================================================================
+// IssueStatusIcon
+// ===========================================================================
+
+function IssueStatusIcon({ status }: { status: IssueStatus }) {
+ switch (status) {
+ case IssueStatus.OPEN:
+ return (
+ <span className="flex items-center justify-center rounded-full w-5 h-5 bg-white border-2 border-info text-info shrink-0">
+ <span className="h-1.5 w-1.5 bg-info rounded-full" />
+ </span>
+ );
+ case IssueStatus.DONE:
+ return (
+ <span className="flex items-center justify-center rounded-full w-5 h-5 bg-success text-white shrink-0">
+ <svg className="w-4 h-4" fill="currentColor" viewBox="0 0 20 20">
+ <path
+ fillRule="evenodd"
+ d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z"
+ clipRule="evenodd"
+ />
+ </svg>
+ </span>
+ );
+ case IssueStatus.CANCELED:
+ return (
+ <span className="flex items-center justify-center rounded-full w-5 h-5 bg-white border-2 text-gray-400 border-gray-400 shrink-0">
+ <svg className="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">
+ <path
+ fillRule="evenodd"
+ d="M3 10a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1z"
+ clipRule="evenodd"
+ />
+ </svg>
+ </span>
+ );
+ default:
+ return null;
+ }
+}
+
+// ===========================================================================
+// RiskLevelIcon
+// ===========================================================================
+
+function RiskLevelIcon({ riskLevel }: { riskLevel: RiskLevel }) {
+ const { t } = useTranslation();
+ if (
+ riskLevel === RiskLevel.RISK_LEVEL_UNSPECIFIED ||
+ riskLevel === RiskLevel.LOW
+ ) {
+ return null;
+ }
+ const color =
+ riskLevel === RiskLevel.MODERATE ? "text-warning" : "text-error";
+ const label =
+ riskLevel === RiskLevel.MODERATE
+ ? t("issue.risk-level.moderate")
+ : t("issue.risk-level.high");
+ return (
+ <Tooltip content={`${label} (${t("issue.risk-level.self")})`}>
+ <svg
+ className={`w-4 h-4 shrink-0 ${color}`}
+ fill="none"
+ viewBox="0 0 24 24"
+ stroke="currentColor"
+ strokeWidth={2}
+ >
+ <path
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4.5c-.77-.833-2.694-.833-3.464 0L3.34 16.5c-.77.833.192 2.5 1.732 2.5z"
+ />
+ </svg>
+ </Tooltip>
+ );
+}
+
+// ===========================================================================
+// IssueApprovalStatusTag
+// ===========================================================================
+
+function IssueApprovalStatusTag({ issue }: { issue: Issue }) {
+ const { t } = useTranslation();
+ const approvalSteps = issue.approvalTemplate?.flow?.roles ?? [];
+
+ if (issue.approvalStatus === Issue_ApprovalStatus.CHECKING) {
+ return (
+ <span className="shrink-0 mt-1 inline-flex items-center rounded-full bg-gray-100 px-2 py-0.5 text-xs text-gray-600">
+ {t("custom-approval.issue-review.generating-approval-flow")}
+ </span>
+ );
+ }
+
+ const progressText = t("issue.table.approval-progress", {
+ approved: issue.approvers.length,
+ total: approvalSteps.length,
+ });
+
+ if (approvalSteps.length > 0) {
+ const status = issue.approvalStatus;
+ if (status === Issue_ApprovalStatus.APPROVED) {
+ return (
+ <div className="shrink-0 flex flex-row sm:flex-col items-center sm:items-end gap-x-1.5 sm:gap-x-0 mt-1">
+ <span className="inline-flex items-center rounded-full bg-success/10 text-success px-2 py-0.5 text-xs">
+ {t("issue.table.approved")}
+ </span>
+ <span className="text-xs text-control-light whitespace-nowrap sm:mt-1">
+ {progressText}
+ </span>
+ </div>
+ );
+ }
+ if (status === Issue_ApprovalStatus.REJECTED) {
+ return (
+ <div className="shrink-0 flex flex-row sm:flex-col items-center sm:items-end gap-x-1.5 sm:gap-x-0 mt-1">
+ <span className="inline-flex items-center rounded-full bg-warning/10 text-warning px-2 py-0.5 text-xs">
+ {t("common.rejected")}
+ </span>
+ <span className="text-xs text-control-light whitespace-nowrap sm:mt-1">
+ {progressText}
+ </span>
+ </div>
+ );
+ }
+ if (status === Issue_ApprovalStatus.PENDING) {
+ const currentRoleIndex = issue.approvers.length;
+ const role = approvalSteps[currentRoleIndex];
+ const roleName = role ? displayRoleTitle(role) : "";
+ return (
+ <div className="shrink-0 flex flex-row sm:flex-col items-center sm:items-end gap-x-1.5 sm:gap-x-0 mt-1">
+ <span className="inline-flex items-center rounded-full bg-gray-100 px-2 py-0.5 text-xs text-gray-600">
+ {progressText}
+ </span>
+ {roleName && (
+ <span className="text-xs text-control-light whitespace-nowrap sm:mt-1">
+ {t("issue.table.waiting-role", { role: roleName })}
+ </span>
+ )}
+ </div>
+ );
+ }
+ }
+
+ return (
+ <span className="shrink-0 mt-1 inline-flex items-center rounded-full bg-gray-50 px-2 py-0.5 text-xs text-gray-500">
+ {t("custom-approval.approval-flow.skip")}
+ </span>
+ );
+}
+
+// ===========================================================================
+// BatchActionBar
+// ===========================================================================
+
+function BatchActionBar({
+ issues,
+ allSelected,
+ onToggleSelectAll,
+ onStartAction,
+}: {
+ issues: Issue[];
+ allSelected: boolean;
+ onToggleSelectAll: () => void;
+ onStartAction: (action: "CLOSE" | "REOPEN") => void;
+}) {
+ const { t } = useTranslation();
+
+ const statuses = useMemo(() => {
+ const s = new Set<IssueStatus>();
+ for (const issue of issues) s.add(issue.status);
+ return s;
+ }, [issues]);
+
+ const canClose =
+ !statuses.has(IssueStatus.DONE) && !statuses.has(IssueStatus.CANCELED);
+ const canReopen =
+ !statuses.has(IssueStatus.OPEN) && !statuses.has(IssueStatus.DONE);
+
+ return (
+ <div className="sticky bottom-0 w-full bg-white flex items-center gap-x-2 px-3 sm:px-4 py-2 border-y">
+ <input
+ type="checkbox"
+ checked={allSelected}
+ ref={(el) => {
+ if (el) el.indeterminate = !allSelected;
+ }}
+ onChange={onToggleSelectAll}
+ className="accent-accent"
+ />
+ <span className="text-sm text-control-light">
+ {issues.length} {t("common.selected")}
+ </span>
+ <Tooltip
+ content={
+ !canClose
+ ? t("issue.batch-transition.not-allowed-tips", {
+ operation: t("issue.batch-transition.closed"),
+ })
+ : undefined
+ }
+ >
+ <Button
+ variant="outline"
+ size="sm"
+ disabled={!canClose}
+ onClick={() => onStartAction("CLOSE")}
+ >
+ {t("issue.batch-transition.close")}
+ </Button>
+ </Tooltip>
+ <Tooltip
+ content={
+ !canReopen
+ ? t("issue.batch-transition.not-allowed-tips", {
+ operation: t("issue.batch-transition.reopened"),
+ })
+ : undefined
+ }
+ >
+ <Button
+ variant="outline"
+ size="sm"
+ disabled={!canReopen}
+ onClick={() => onStartAction("REOPEN")}
+ >
+ {t("issue.batch-transition.reopen")}
+ </Button>
+ </Tooltip>
+ </div>
+ );
+}
+
+// ===========================================================================
+// BatchIssueStatusActionDrawer
+// ===========================================================================
+
+function BatchIssueStatusActionDrawer({
+ issues,
+ action,
+ onClose,
+ onUpdated,
+}: {
+ issues: Issue[];
+ action: "CLOSE" | "REOPEN" | undefined;
+ onClose: () => void;
+ onUpdated: () => void;
+}) {
+ const { t } = useTranslation();
+ const [comment, setComment] = useState("");
+ const [loading, setLoading] = useState(false);
+
+ useEscapeKey(!!action, onClose);
+
+ useEffect(() => {
+ if (action) setComment("");
+ }, [action]);
+
+ const handleConfirm = async () => {
+ if (!action || loading) return;
+ setLoading(true);
+ try {
+ const statusMap: Record<string, IssueStatus> = {
+ CLOSE: IssueStatus.CANCELED,
+ REOPEN: IssueStatus.OPEN,
+ };
+ const request = create(BatchUpdateIssuesStatusRequestSchema, {
+ parent: "projects/-",
+ issues: issues.map((i) => i.name),
+ status: statusMap[action],
+ reason: comment,
+ });
+ await issueServiceClientConnect.batchUpdateIssuesStatus(request);
+ pushNotification({
+ module: "bytebase",
+ style: "SUCCESS",
+ title: t("common.updated"),
+ });
+ onUpdated();
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ if (!action) return null;
+
+ const title =
+ action === "CLOSE"
+ ? t("issue.batch-transition.close")
+ : t("issue.batch-transition.reopen");
+
+ return (
+ <div className="fixed inset-0 z-50 flex">
+ <div className="fixed inset-0 bg-black/50" onClick={onClose} />
+ <div className="ml-auto relative bg-white w-[calc(100vw-8rem)] lg:w-160 max-w-[calc(100vw-8rem)] h-full shadow-lg flex flex-col">
+ <div className="px-6 py-4 border-b border-control-border flex items-center justify-between">
+ <span className="text-lg font-semibold">{title}</span>
+ <button
+ className="p-1 hover:bg-control-bg rounded-xs"
+ onClick={onClose}
+ >
+ <X className="w-4 h-4" />
+ </button>
+ </div>
+
+ <div className="flex-1 overflow-y-auto p-6 flex flex-col gap-y-4">
+ <div className="flex flex-col gap-y-1">
+ <div className="font-medium text-control">{t("common.issues")}</div>
+ <ul
+ className={cn(
+ "flex flex-col text-sm text-control-light",
+ issues.length > 1 && "list-disc pl-4"
+ )}
+ >
+ {issues.map((issue) => (
+ <li key={issue.name}>{issue.title}</li>
+ ))}
+ </ul>
+ </div>
+
+ <div className="flex flex-col gap-y-1">
+ <div className="font-medium text-control">
+ {t("common.comment")}
+ </div>
+ <textarea
+ className="w-full border border-control-border rounded-sm px-3 py-2 text-sm focus:outline-none focus:border-accent min-h-[6rem] resize-y"
+ value={comment}
+ placeholder={t("issue.leave-a-comment")}
+ onChange={(e) => setComment(e.target.value)}
+ />
+ </div>
+ </div>
+
+ <div className="px-6 py-4 border-t border-control-border flex items-center justify-end gap-x-2">
+ <Button variant="outline" onClick={onClose}>
+ {t("common.cancel")}
+ </Button>
+ <Button disabled={loading} onClick={handleConfirm}>
+ {loading && <Loader2 className="w-4 h-4 mr-1 animate-spin" />}
+ {t("common.confirm")}
+ </Button>
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/frontend/src/router/dashboard/projectV1.ts b/frontend/src/router/dashboard/projectV1.ts
index 8dfa2f909d..c2c5b95ec4 100644
--- a/frontend/src/router/dashboard/projectV1.ts
+++ b/frontend/src/router/dashboard/projectV1.ts
@@ -277,8 +277,11 @@ const projectV1Routes: RouteRecordRaw[] = [
title: () => t("common.issues"),
requiredPermissionList: () => ["bb.issues.list"],
},
- component: () => import("@/views/project/ProjectIssueDashboard.vue"),
- props: true,
+ component: () => import("@/react/ReactPageMount.vue"),
+ props: (route: RouteLocationNormalized) => ({
+ page: "ProjectIssueDashboardPage",
+ ...route.params,
+ }),
},
{
path: "plans",
diff --git a/frontend/src/views/project/ProjectIssueDashboard.vue b/frontend/src/views/project/ProjectIssueDashboard.vue
deleted file mode 100644
index 5ca0929796..0000000000
--- a/frontend/src/views/project/ProjectIssueDashboard.vue
+++ /dev/null
@@ -1,18 +0,0 @@
-<template>
- <ProjectIssuesPanel v-if="ready" class="py-4" :project="project" />
-</template>
-
-<script lang="ts" setup>
-import { computed } from "vue";
-import ProjectIssuesPanel from "@/components/Project/ProjectIssuesPanel.vue";
-import { useProjectByName } from "@/store";
-import { projectNamePrefix } from "@/store/modules/v1/common";
-
-const props = defineProps<{
- projectId: string;
-}>();
-
-const { project, ready } = useProjectByName(
- computed(() => `${projectNamePrefix}${props.projectId}`)
-);
-</script>