Skip to content

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

feat: redesign issue list filters to GitHub-style UI (#18083)

p0ny150604bc3e32
diff --git a/frontend/src/components/IssueV1/components/IssueSearch/IssueSearch.vue b/frontend/src/components/IssueV1/components/IssueSearch/IssueSearch.vue
index a2f3018f66..f787f983b1 100644
--- a/frontend/src/components/IssueV1/components/IssueSearch/IssueSearch.vue
+++ b/frontend/src/components/IssueV1/components/IssueSearch/IssueSearch.vue
@@ -1,9 +1,7 @@
<template>
- <div class="flex flex-col gap-y-1">
- <div
- v-if="components.includes('searchbox')"
- class="flex flex-row items-center gap-x-2"
- >
+ <div class="flex flex-col gap-y-2">
+ <!-- Advanced Search Bar - Always Visible -->
+ <div class="flex flex-row items-center gap-x-2">
<AdvancedSearch
class="flex-1"
:params="params"
@@ -19,22 +17,26 @@
/>
<slot name="searchbox-suffix" />
</div>
+
<slot name="default" />
+ <!-- Preset Buttons + Status Row -->
<div
- v-if="!componentProps?.status?.hidden"
- class="flex flex-col md:flex-row md:items-center gap-y-1"
+ v-if="components.includes('presets') && !componentProps?.presets?.hidden"
+ class="flex items-center justify-between"
>
- <div class="flex-1 flex items-start w-full">
- <Status
- v-if="components.includes('status')"
- :params="params"
- v-bind="componentProps?.status"
- @update:params="$emit('update:params', $event)"
- />
- <slot name="primary" />
- </div>
+ <PresetButtons
+ :params="params"
+ @update:params="$emit('update:params', $event)"
+ />
+ <Status
+ v-if="components.includes('status')"
+ :params="params"
+ @update:params="$emit('update:params', $event)"
+ />
</div>
+
+ <slot name="primary" />
</div>
</template>
@@ -44,10 +46,11 @@ import AdvancedSearch from "@/components/AdvancedSearch";
import TimeRange from "@/components/AdvancedSearch/TimeRange.vue";
import type { SearchParams, SearchScopeId } from "@/utils";
import { UIIssueFilterScopeIdList } from "@/utils";
+import PresetButtons from "./PresetButtons.vue";
import Status from "./Status.vue";
import { useIssueSearchScopeOptions } from "./useIssueSearchScopeOptions";
-export type SearchComponent = "searchbox" | "status" | "time-range";
+export type SearchComponent = "searchbox" | "presets" | "status" | "time-range";
const props = withDefaults(
defineProps<{
@@ -59,10 +62,11 @@ const props = withDefaults(
}>(),
{
overrideScopeIdList: () => [],
- components: () => ["searchbox", "time-range", "status"],
+ components: () => ["searchbox", "time-range", "presets", "status"],
componentProps: undefined,
}
);
+
defineEmits<{
(event: "update:params", params: SearchParams): void;
}>();
diff --git a/frontend/src/components/IssueV1/components/IssueSearch/PresetButtons.vue b/frontend/src/components/IssueV1/components/IssueSearch/PresetButtons.vue
new file mode 100644
index 0000000000..6688435fcf
--- /dev/null
+++ b/frontend/src/components/IssueV1/components/IssueSearch/PresetButtons.vue
@@ -0,0 +1,126 @@
+<template>
+ <div class="shrink-0">
+ <NTabs
+ :value="activePreset"
+ :type="'line'"
+ :size="'small'"
+ @update:value="selectPreset"
+ >
+ <NTab v-for="preset in presets" :key="preset.value" :name="preset.value">
+ {{ preset.label }}
+ </NTab>
+ </NTabs>
+ </div>
+</template>
+
+<script lang="ts" setup>
+import { NTabs, NTab } from "naive-ui";
+import { computed } from "vue";
+import { useI18n } from "vue-i18n";
+import { useCurrentUserV1 } from "@/store";
+import type { SearchParams } from "@/utils";
+import {
+ getValueFromSearchParams,
+ getSemanticIssueStatusFromSearchParams,
+ upsertScope,
+} from "@/utils";
+
+type PresetValue = "WAITING_APPROVAL" | "CREATED" | "ALL";
+
+interface Preset {
+ value: PresetValue;
+ label: string;
+}
+
+const props = defineProps<{
+ params: SearchParams;
+}>();
+
+const emit = defineEmits<{
+ (event: "update:params", params: SearchParams): void;
+}>();
+
+const { t } = useI18n();
+const me = useCurrentUserV1();
+
+const presets = computed((): Preset[] => [
+ {
+ value: "WAITING_APPROVAL",
+ label: t("issue.waiting-approval"),
+ },
+ {
+ value: "CREATED",
+ label: t("common.created"),
+ },
+ {
+ value: "ALL",
+ label: t("common.all"),
+ },
+]);
+
+const activePreset = computed((): PresetValue | "" => {
+ const preset = presets.value.find((p) => isActive(p.value));
+ return preset ? preset.value : "";
+});
+
+const isActive = (preset: PresetValue): boolean => {
+ const myEmail = me.value.email;
+
+ if (preset === "WAITING_APPROVAL") {
+ return (
+ getSemanticIssueStatusFromSearchParams(props.params) === "OPEN" &&
+ getValueFromSearchParams(props.params, "approval") === "pending" &&
+ getValueFromSearchParams(props.params, "approver") === myEmail &&
+ props.params.scopes.filter((s) => !s.readonly).length === 3
+ );
+ }
+
+ if (preset === "CREATED") {
+ return (
+ getSemanticIssueStatusFromSearchParams(props.params) === "OPEN" &&
+ getValueFromSearchParams(props.params, "creator") === myEmail &&
+ props.params.scopes.filter((s) => !s.readonly).length === 2
+ );
+ }
+
+ if (preset === "ALL") {
+ return props.params.scopes.filter((s) => !s.readonly).length === 0;
+ }
+
+ return false;
+};
+
+const selectPreset = (preset: PresetValue | string) => {
+ if (!["WAITING_APPROVAL", "CREATED", "ALL"].includes(preset)) return;
+
+ const myEmail = me.value.email;
+ const readonlyScopes = props.params.scopes.filter((s) => s.readonly);
+
+ let newParams: SearchParams = {
+ query: "",
+ scopes: [...readonlyScopes],
+ };
+
+ if (preset === "WAITING_APPROVAL") {
+ newParams = upsertScope({
+ params: newParams,
+ scopes: [
+ { id: "status", value: "OPEN" },
+ { id: "approval", value: "pending" },
+ { id: "approver", value: myEmail },
+ ],
+ });
+ } else if (preset === "CREATED") {
+ newParams = upsertScope({
+ params: newParams,
+ scopes: [
+ { id: "status", value: "OPEN" },
+ { id: "creator", value: myEmail },
+ ],
+ });
+ }
+ // "ALL" preset keeps only readonly scopes (already done above)
+
+ emit("update:params", newParams);
+};
+</script>
diff --git a/frontend/src/components/IssueV1/components/IssueSearch/Status.vue b/frontend/src/components/IssueV1/components/IssueSearch/Status.vue
index d6fbfc7404..9b5e21316c 100644
--- a/frontend/src/components/IssueV1/components/IssueSearch/Status.vue
+++ b/frontend/src/components/IssueV1/components/IssueSearch/Status.vue
@@ -1,14 +1,16 @@
<template>
- <NTabs
- :value="tab"
- :type="'line'"
- :size="'small'"
- @update:value="updateStatus"
- >
- <NTab v-for="item in tabItemList" :key="item.value" :name="item.value">
- {{ item.label }}
- </NTab>
- </NTabs>
+ <div class="shrink-0">
+ <NTabs
+ :value="tab"
+ :type="'line'"
+ :size="'small'"
+ @update:value="updateStatus"
+ >
+ <NTab v-for="item in tabItemList" :key="item.value" :name="item.value">
+ {{ item.label }}
+ </NTab>
+ </NTabs>
+ </div>
</template>
<script lang="ts" setup>
@@ -45,7 +47,7 @@ const tabItemList = computed(() => {
});
const tab = computed(() => {
- return getSemanticIssueStatusFromSearchParams(props.params);
+ return getSemanticIssueStatusFromSearchParams(props.params) ?? "";
});
const updateStatus = (value: SemanticIssueStatus) => {
diff --git a/frontend/src/components/IssueV1/components/IssueSearch/index.ts b/frontend/src/components/IssueV1/components/IssueSearch/index.ts
index 7c083bd0c9..58fc4b1473 100644
--- a/frontend/src/components/IssueV1/components/IssueSearch/index.ts
+++ b/frontend/src/components/IssueV1/components/IssueSearch/index.ts
@@ -1,3 +1,2 @@
-import IssueSearch from "./IssueSearch.vue";
-
-export default IssueSearch;
+export { default as IssueSearch } from "./IssueSearch.vue";
+export { default as PresetButtons } from "./PresetButtons.vue";
diff --git a/frontend/src/components/IssueV1/components/index.ts b/frontend/src/components/IssueV1/components/index.ts
index 2d99090324..4118ec3646 100644
--- a/frontend/src/components/IssueV1/components/index.ts
+++ b/frontend/src/components/IssueV1/components/index.ts
@@ -2,7 +2,7 @@ import BannerSection from "./BannerSection.vue";
import DescriptionSection from "./DescriptionSection";
import HeaderSection from "./HeaderSection";
import IssueCommentSection from "./IssueCommentSection";
-import IssueSearch from "./IssueSearch";
+import { IssueSearch } from "./IssueSearch";
import PlanCheckSection from "./PlanCheckSection";
import Sidebar from "./Sidebar";
import StageSection from "./StageSection";
diff --git a/frontend/src/components/Project/ProjectIssuesPanel.vue b/frontend/src/components/Project/ProjectIssuesPanel.vue
index 84be888f1b..d536f901cd 100644
--- a/frontend/src/components/Project/ProjectIssuesPanel.vue
+++ b/frontend/src/components/Project/ProjectIssuesPanel.vue
@@ -2,59 +2,13 @@
<div class="flex flex-col gap-y-2">
<IssueSearch
v-model:params="state.params"
- :components="
- state.advanced ? ['searchbox', 'time-range', 'status'] : ['status']
- "
- :component-props="{ status: { hidden: statusTabDisabled } }"
- >
- <template v-if="!state.advanced" #default>
- <div class="h-[34px] flex items-center gap-x-2">
- <div class="flex-1 overflow-auto">
- <TabFilter
- :value="tab"
- :items="tabItemList"
- @update:value="selectTab($event as TabValue)"
- />
- </div>
- <div class="flex items-center">
- <div
- class="flex items-center gap-x-1 normal-link whitespace-nowrap text-sm"
- @click="toggleAdvancedSearch(true)"
- >
- <SearchIcon class="w-4 h-4" />
- <span class="hidden md:block">
- {{ $t("issue.advanced-search.self") }}
- </span>
- </div>
- </div>
- </div>
- </template>
- <template v-if="state.advanced" #searchbox-suffix>
- <NTooltip>
- <template #trigger>
- <NButton
- style="--n-padding: 0 6px; --n-icon-size: 24px"
- @click="toggleAdvancedSearch(false)"
- >
- <template #icon>
- <ChevronDownIcon class="w-5 h-5" />
- </template>
- </NButton>
- </template>
- <template #default>
- <div class="whitespace-nowrap">
- {{ $t("issue.advanced-search.hide") }}
- </div>
- </template>
- </NTooltip>
- </template>
- </IssueSearch>
+ :components="['searchbox', 'time-range', 'presets', 'status']"
+ />
<div class="relative min-h-80">
<PagedTable
ref="issuePagedTable"
- :key="keyForTab(tab)"
- :session-key="`bb.issue-table.${project.name}.${keyForTab(tab)}`"
+ session-key="bb.issue-table.project-issues"
:fetch-list="fetchIssueList"
>
<template #table="{ list, loading }">
@@ -72,61 +26,40 @@
<script lang="ts" setup>
import { type UseStorageOptions } from "@vueuse/core";
-import { cloneDeep } from "lodash-es";
-import { ChevronDownIcon, SearchIcon } from "lucide-vue-next";
-import { NButton, NTooltip } from "naive-ui";
-import { reactive, computed, watch, ref } from "vue";
+import { reactive, computed, watch, ref, onMounted } from "vue";
import type { ComponentExposed } from "vue-component-type-helpers";
-import { useI18n } from "vue-i18n";
import { useRoute, useRouter } from "vue-router";
import IssueTableV1 from "@/components/IssueV1/components/IssueTableV1.vue";
-import { TabFilter, type TabFilterItem } from "@/components/v2";
import PagedTable from "@/components/v2/Model/PagedTable.vue";
import { useCurrentUserV1 } from "@/store";
import { useIssueV1Store, useRefreshIssueList } from "@/store";
import type { ComposedIssue } from "@/types";
import type { Project } from "@/types/proto-es/v1/project_service_pb";
-import type {
- SearchParams,
- SearchScope,
- SearchScopeId,
- SemanticIssueStatus,
-} from "@/utils";
+import type { SearchParams, SearchScope, SemanticIssueStatus } from "@/utils";
import {
buildIssueFilterBySearchParams,
buildUIIssueFilterBySearchParams,
extractProjectResourceName,
getSemanticIssueStatusFromSearchParams,
- getValueFromSearchParams,
- upsertScope,
useDynamicLocalStorage,
applyUIIssueFilter,
+ buildSearchTextBySearchParams,
+ buildSearchParamsBySearchText,
+ mergeSearchParams,
} from "@/utils";
import { IssueSearch } from "../IssueV1/components";
-const TABS = [
- "CREATED",
- "WAITING_APPROVAL",
- "WAITING_ROLLOUT",
- "ALL",
- "",
-] as const;
-
-type TabValue = (typeof TABS)[number];
-
interface LocalState {
params: SearchParams;
- advanced: boolean;
}
const props = defineProps<{
project: Project;
}>();
-const me = useCurrentUserV1();
-const { t } = useI18n();
const route = useRoute();
const router = useRouter();
+const me = useCurrentUserV1();
const issueStore = useIssueV1Store();
const issuePagedTable =
ref<ComponentExposed<typeof PagedTable<ComposedIssue>>>();
@@ -140,33 +73,6 @@ const readonlyScopes = computed((): SearchScope[] => {
},
];
});
-const tabItemList = computed((): TabFilterItem<TabValue>[] => {
- const items: TabFilterItem<TabValue>[] = [
- {
- value: "WAITING_APPROVAL",
- label: t("issue.waiting-approval"),
- },
- { value: "CREATED", label: t("common.created") },
- { value: "ALL", label: t("common.all") },
- ];
- return items;
-});
-const storedTab = useDynamicLocalStorage<TabValue>(
- computed(() => `bb.project.issue-list-tab.${me.value.name}`),
- "WAITING_APPROVAL",
- window.localStorage,
- {
- serializer: {
- read(raw: TabValue) {
- if (!TABS.includes(raw)) return "WAITING_APPROVAL";
- return raw;
- },
- write(value) {
- return value;
- },
- },
- } as UseStorageOptions<TabValue>
-);
const storedStatus = useDynamicLocalStorage<SemanticIssueStatus>(
computed(() => `bb.project.issue-list-status.${me.value.name}`),
@@ -185,136 +91,21 @@ const storedStatus = useDynamicLocalStorage<SemanticIssueStatus>(
} as UseStorageOptions<SemanticIssueStatus>
);
-const keyForTab = (tab: TabValue) => {
- if (tab === "CREATED") return "project-issues-created";
- if (tab === "WAITING_APPROVAL") return "project-issues-waiting-approval";
- if (tab === "WAITING_ROLLOUT") return "project-issues-waiting-rollout";
- if (tab === "ALL") return "project-issues-all";
-
- return "project-issues-unknown";
-};
-
-const defaultSearchParams = () => {
- const params: SearchParams = {
+const defaultSearchParams = (): SearchParams => {
+ const myEmail = me.value.email;
+ return {
query: "",
scopes: [
...readonlyScopes.value,
- { id: "status", value: storedStatus.value },
+ { id: "status", value: "OPEN" },
+ { id: "approval", value: "pending" },
+ { id: "approver", value: myEmail },
],
};
- return params;
-};
-const defaultScopeIds = computed(() => {
- return new Set(defaultSearchParams().scopes.map((s) => s.id));
-});
-const mergeSearchParamsByTab = (params: SearchParams, tab: TabValue) => {
- const common = cloneDeep(params);
- if (tab === "" || tab === "ALL") {
- return common;
- }
- if (tab === "CREATED") {
- return upsertScope({
- params: common,
- scopes: {
- id: "creator",
- value: me.value.email,
- },
- });
- }
- if (tab === "WAITING_APPROVAL") {
- return upsertScope({
- params: common,
- scopes: [
- {
- id: "status",
- value: "OPEN",
- },
- {
- id: "approval",
- value: "pending",
- },
- ],
- });
- }
- if (tab === "WAITING_ROLLOUT") {
- return upsertScope({
- params: common,
- scopes: [
- {
- id: "status",
- value: "OPEN",
- },
- {
- id: "approval",
- value: "approved",
- },
- ],
- });
- }
- console.error("[mergeSearchParamsByTab] should never reach this line", tab);
- return common;
-};
-const guessTabValueFromSearchParams = (params: SearchParams): TabValue => {
- const verifyScopes = (scopes: SearchScopeId[]) => {
- const allowed = new Set(scopes);
- return params.scopes.every(
- (s) => allowed.has(s.id) || defaultScopeIds.value.has(s.id)
- );
- };
-
- if (
- verifyScopes(["creator"]) &&
- getValueFromSearchParams(params, "creator") === me.value.email
- ) {
- return "CREATED";
- }
-
- if (
- verifyScopes(["approval"]) &&
- getSemanticIssueStatusFromSearchParams(params) === "OPEN" &&
- getValueFromSearchParams(params, "approval") === "pending"
- ) {
- return "WAITING_APPROVAL";
- }
- if (
- verifyScopes(["approval"]) &&
- getSemanticIssueStatusFromSearchParams(params) === "OPEN" &&
- getValueFromSearchParams(params, "approval") === "approved"
- ) {
- return "WAITING_ROLLOUT";
- }
-
- if (params.scopes.every((s) => defaultScopeIds.value.has(s.id))) {
- return "ALL";
- }
- return "";
-};
-const initializeSearchParamsFromQueryOrLocalStorage = () => {
- return {
- params: mergeSearchParamsByTab(defaultSearchParams(), storedTab.value),
- advanced: false,
- };
};
const state = reactive<LocalState>({
- ...initializeSearchParamsFromQueryOrLocalStorage(),
-});
-
-const tab = computed<TabValue>({
- set(tab) {
- if (tab === "") return;
- const base = cloneDeep(state.params);
- base.scopes = base.scopes.filter((s) => defaultScopeIds.value.has(s.id));
- state.params = mergeSearchParamsByTab(base, tab);
- },
- get() {
- return guessTabValueFromSearchParams(state.params);
- },
-});
-
-const statusTabDisabled = computed(() => {
- if (state.advanced) return true;
- return ["WAITING_APPROVAL", "WAITING_ROLLOUT"].includes(tab.value);
+ params: defaultSearchParams(),
});
const mergedIssueFilter = computed(() => {
@@ -348,43 +139,6 @@ watch(
);
useRefreshIssueList(() => issuePagedTable.value?.refresh());
-const selectTab = (target: TabValue) => {
- if (target === "") return;
- storedTab.value = target;
- tab.value = target;
-};
-
-const toggleAdvancedSearch = (on: boolean) => {
- state.advanced = on;
- if (!on) {
- if (storedTab.value !== "") {
- selectTab(storedTab.value);
- } else {
- selectTab(tabItemList.value[0].value);
- }
- state.params.query = "";
- }
-};
-
-watch(
- tab,
- () => {
- if (tab.value === "WAITING_APPROVAL" || tab.value === "WAITING_ROLLOUT") {
- if (getSemanticIssueStatusFromSearchParams(state.params) === "CLOSED") {
- upsertScope({
- params: state.params,
- scopes: {
- id: "status",
- value: "OPEN",
- },
- mutate: true,
- });
- }
- }
- },
- { immediate: true }
-);
-
watch(
() => props.project.name,
() => {
@@ -392,27 +146,88 @@ watch(
}
);
-watch(
- () => tab.value,
- () => {
- const hash = route.hash;
- if (tab.value !== "") {
- // using custom advanced search query, sync the search query string
- // to URL
- const query = cloneDeep(route.query);
- delete query["qs"];
- router.replace({
- query,
- hash,
- });
- }
- }
-);
-
watch(
() => getSemanticIssueStatusFromSearchParams(state.params),
(status) => {
storedStatus.value = status;
}
);
+
+// 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;
+};
+
+// Track the initial URL query string to distinguish between user-provided URLs
+// and programmatic navigation to default state
+const initialQueryString = ref<string | null>(null);
+
+// Initialize params from URL query on mount
+onMounted(() => {
+ const queryString = route.query.q as string;
+ initialQueryString.value = queryString || null;
+
+ if (queryString) {
+ const urlParams = buildSearchParamsBySearchText(queryString);
+ // Only add readonly scopes (project), don't merge with default preset
+ const readonlyParams: SearchParams = {
+ query: "",
+ scopes: [...readonlyScopes.value],
+ };
+ state.params = mergeSearchParams(readonlyParams, urlParams);
+ }
+ // No else - keep URL clean for default preset
+});
+
+// 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.value) {
+ // 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/locales/en-US.json b/frontend/src/locales/en-US.json
index 7c835e2f6b..9c16cdd35f 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -942,8 +942,7 @@
"title": "Engine",
"description": "Filter by engines"
}
- },
- "hide": "Hide advanced search"
+ }
},
"table": {
"open": "Open",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 4761b981b0..96e02d0248 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -246,7 +246,7 @@
"collapse": "Colapsar",
"line": "Línea",
"column": "Columna",
- "apply-to-database": "Aplicar a la base de datos"
+ "apply-to-database": "Aplicar a la base de datos",
},
"error-page": {
"go-back-home": "Volver al inicio"
@@ -942,8 +942,7 @@
"title": "Motor",
"description": "Filtrar por motores"
}
- },
- "hide": "Ocultar búsqueda avanzada"
+ }
},
"table": {
"open": "Abierto",
@@ -2917,4 +2916,4 @@
"last-visit": "Última visita",
"changelog-for-version": "Registro de cambios para {version}"
}
-}
\ No newline at end of file
+}
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 5a565f23bb..81a70093a6 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -246,7 +246,7 @@
"collapse": "閉じる",
"line": "行",
"column": "列",
- "apply-to-database": "データベースに適用"
+ "apply-to-database": "データベースに適用",
},
"error-page": {
"go-back-home": "ホームページに戻る"
@@ -942,8 +942,7 @@
"title": "エンジン",
"description": "エンジンでフィルタリング"
}
- },
- "hide": "詳細検索を非表示にする"
+ }
},
"table": {
"open": "オープン",
@@ -2917,4 +2916,4 @@
"last-visit": "最終訪問",
"changelog-for-version": "{version} の変更履歴"
}
-}
\ No newline at end of file
+}
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 79d5b159f9..2252b51c37 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -246,7 +246,7 @@
"collapse": "Sụp đổ",
"line": "Dòng",
"column": "Cột",
- "apply-to-database": "Áp dụng cho cơ sở dữ liệu"
+ "apply-to-database": "Áp dụng cho cơ sở dữ liệu",
},
"error-page": {
"go-back-home": "Về trang chủ"
@@ -942,8 +942,7 @@
"title": "Động cơ",
"description": "Lọc theo động cơ"
}
- },
- "hide": "Ẩn tìm kiếm nâng cao"
+ }
},
"table": {
"open": "Mở",
@@ -2917,4 +2916,4 @@
"last-visit": "Lần truy cập cuối",
"changelog-for-version": "Nhật ký thay đổi cho phiên bản {version}"
}
-}
\ No newline at end of file
+}
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index c44d24a12e..15562224f6 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -246,7 +246,7 @@
"collapse": "收起",
"line": "行",
"column": "列",
- "apply-to-database": "应用到数据库"
+ "apply-to-database": "应用到数据库",
},
"error-page": {
"go-back-home": "回到主页"
@@ -942,8 +942,7 @@
"title": "引擎",
"description": "按引擎过滤"
}
- },
- "hide": "隐藏高级搜索"
+ }
},
"table": {
"open": "开启中",
@@ -2917,4 +2916,4 @@
"last-visit": "上次访问",
"changelog-for-version": "{version} 的更新日志"
}
-}
\ No newline at end of file
+}
diff --git a/frontend/src/views/MyIssues.vue b/frontend/src/views/MyIssues.vue
index 73c9c96de7..072fc57a9d 100644
--- a/frontend/src/views/MyIssues.vue
+++ b/frontend/src/views/MyIssues.vue
@@ -2,60 +2,14 @@
<div :key="viewId" class="flex flex-col">
<IssueSearch
v-model:params="state.params"
- :components="
- state.advanced ? ['searchbox', 'time-range', 'status'] : ['status']
- "
- :component-props="{ status: { hidden: statusTabHidden } }"
+ :components="['searchbox', 'time-range', 'presets', 'status']"
class="px-4 pb-2"
- >
- <template v-if="!state.advanced" #default>
- <div class="flex items-center gap-x-2">
- <div class="flex-1 overflow-auto">
- <TabFilter
- :value="tab"
- :items="tabItemList"
- @update:value="selectTab($event as TabValue)"
- />
- </div>
- <div class="flex items-center">
- <div
- class="flex items-center gap-x-1 normal-link whitespace-nowrap text-sm"
- @click="toggleAdvancedSearch(true)"
- >
- <SearchIcon class="w-4 h-4" />
- <span class="hidden md:block">
- {{ $t("issue.advanced-search.self") }}
- </span>
- </div>
- </div>
- </div>
- </template>
- <template v-if="state.advanced" #searchbox-suffix>
- <NTooltip>
- <template #trigger>
- <NButton
- style="--n-padding: 0 6px; --n-icon-size: 24px"
- @click="toggleAdvancedSearch(false)"
- >
- <template #icon>
- <ChevronDownIcon class="w-5 h-5" />
- </template>
- </NButton>
- </template>
- <template #default>
- <div class="whitespace-nowrap">
- {{ $t("issue.advanced-search.hide") }}
- </div>
- </template>
- </NTooltip>
- </template>
- </IssueSearch>
+ />
<div class="relative min-h-80">
<PagedTable
ref="issuePagedTable"
- :key="keyForTab(tab)"
- :session-key="`bb.issue-table.${keyForTab(tab)}`"
+ session-key="bb.issue-table.my-issues"
:fetch-list="fetchIssueList"
>
<template #table="{ list, loading }">
@@ -74,17 +28,11 @@
<script lang="ts" setup>
import { useLocalStorage, type UseStorageOptions } from "@vueuse/core";
-import { cloneDeep } from "lodash-es";
-import { ChevronDownIcon, SearchIcon } from "lucide-vue-next";
-import { NButton, NTooltip } from "naive-ui";
-import { reactive, computed, watch, ref } from "vue";
+import { reactive, computed, watch, ref, onMounted } from "vue";
import type { ComponentExposed } from "vue-component-type-helpers";
-import { useI18n } from "vue-i18n";
import { useRoute, useRouter } from "vue-router";
import { IssueSearch } from "@/components/IssueV1/components";
import IssueTableV1 from "@/components/IssueV1/components/IssueTableV1.vue";
-import type { TabFilterItem } from "@/components/v2";
-import { TabFilter } from "@/components/v2";
import PagedTable from "@/components/v2/Model/PagedTable.vue";
import { WORKSPACE_ROUTE_MY_ISSUES } from "@/router/dashboard/workspaceRoutes";
import {
@@ -93,31 +41,25 @@ import {
useRefreshIssueList,
} from "@/store";
import { type ComposedIssue } from "@/types";
-import type { SearchParams, SearchScopeId, SemanticIssueStatus } from "@/utils";
+import type { SearchParams, SemanticIssueStatus } from "@/utils";
import {
buildIssueFilterBySearchParams,
buildUIIssueFilterBySearchParams,
getSemanticIssueStatusFromSearchParams,
- getValueFromSearchParams,
- upsertScope,
useDynamicLocalStorage,
applyUIIssueFilter,
+ buildSearchTextBySearchParams,
+ buildSearchParamsBySearchText,
} from "@/utils";
import { getComponentIdLocalStorageKey } from "@/utils/localStorage";
-const TABS = ["WAITING_APPROVAL", "CREATED", "ALL", ""] as const;
-
-type TabValue = (typeof TABS)[number];
-
interface LocalState {
params: SearchParams;
- advanced: boolean;
}
-const { t } = useI18n();
-const me = useCurrentUserV1();
const route = useRoute();
const router = useRouter();
+const me = useCurrentUserV1();
const issueStore = useIssueV1Store();
const issuePagedTable =
ref<ComponentExposed<typeof PagedTable<ComposedIssue>>>();
@@ -144,149 +86,20 @@ const storedStatus = useDynamicLocalStorage<SemanticIssueStatus>(
} as UseStorageOptions<SemanticIssueStatus>
);
-const defaultSearchParams = () => {
- const params: SearchParams = {
+const defaultSearchParams = (): SearchParams => {
+ const myEmail = me.value.email;
+ return {
query: "",
scopes: [
- {
- id: "status",
- value: storedStatus.value,
- },
+ { id: "status", value: "OPEN" },
+ { id: "approval", value: "pending" },
+ { id: "approver", value: myEmail },
],
};
- return params;
-};
-const defaultScopeIds = computed(() => {
- return new Set(defaultSearchParams().scopes.map((s) => s.id));
-});
-const tabItemList = computed((): TabFilterItem<TabValue>[] => {
- const items: TabFilterItem<TabValue>[] = [
- {
- value: "WAITING_APPROVAL",
- label: t("issue.waiting-approval"),
- },
- { value: "CREATED", label: t("common.created") },
- { value: "ALL", label: t("common.all") },
- ];
- return items;
-});
-const storedTab = useDynamicLocalStorage<TabValue>(
- computed(() => `bb.home.issue-list-tab.${me.value.name}`),
- "WAITING_APPROVAL",
- window.localStorage,
- {
- serializer: {
- read(raw: TabValue) {
- if (!TABS.includes(raw)) return "WAITING_APPROVAL";
- return raw;
- },
- write(value) {
- return value;
- },
- },
- } as UseStorageOptions<TabValue>
-);
-const keyForTab = (tab: TabValue) => {
- if (tab === "WAITING_APPROVAL") return "my-issues-waiting-approval";
- if (tab === "CREATED") return "my-issues-created";
- if (tab === "ALL") return "my-issues-all";
-
- return "my-issues-unknown";
-};
-const mergeSearchParamsByTab = (params: SearchParams, tab: TabValue) => {
- const common = cloneDeep(params);
- if (tab === "" || tab === "ALL") {
- return common;
- }
-
- const myEmail = me.value.email;
- if (tab === "CREATED") {
- return upsertScope({
- params: common,
- scopes: {
- id: "creator",
- value: myEmail,
- },
- });
- }
- if (tab === "WAITING_APPROVAL") {
- return upsertScope({
- params: common,
- scopes: [
- {
- id: "status",
- value: "OPEN",
- },
- {
- id: "approval",
- value: "pending",
- },
- {
- id: "approver",
- value: myEmail,
- },
- ],
- });
- }
- console.error("[mergeSearchParamsByTab] should never reach this line", tab);
- return common;
-};
-const guessTabValueFromSearchParams = (params: SearchParams): TabValue => {
- const myEmail = me.value.email;
-
- const verifyScopes = (scopes: SearchScopeId[]) => {
- const allowed = new Set([...scopes]);
- return params.scopes.every(
- (s) => allowed.has(s.id) || defaultScopeIds.value.has(s.id)
- );
- };
-
- if (
- verifyScopes(["creator"]) &&
- getValueFromSearchParams(params, "creator") === myEmail
- ) {
- return "CREATED";
- }
- if (
- verifyScopes(["approval", "approver"]) &&
- getSemanticIssueStatusFromSearchParams(params) === "OPEN" &&
- getValueFromSearchParams(params, "approval") === "pending" &&
- getValueFromSearchParams(params, "approver") === myEmail
- ) {
- return "WAITING_APPROVAL";
- }
-
- if (params.scopes.every((s) => defaultScopeIds.value.has(s.id))) {
- return "ALL";
- }
- return "";
-};
-const initializeSearchParamsFromQueryOrLocalStorage = () => {
- return {
- params: mergeSearchParamsByTab(defaultSearchParams(), storedTab.value),
- advanced: false,
- };
};
const state = reactive<LocalState>({
- ...initializeSearchParamsFromQueryOrLocalStorage(),
-});
-
-const tab = computed<TabValue>({
- set(tab) {
- if (tab === "") return;
- const base = cloneDeep(state.params);
- base.scopes = base.scopes.filter((s) => defaultScopeIds.value.has(s.id));
- state.params = mergeSearchParamsByTab(base, tab);
- },
- get() {
- return guessTabValueFromSearchParams(state.params);
- },
-});
-
-const statusTabHidden = computed(() => {
- if (state.advanced) return true;
- return tab.value === "WAITING_APPROVAL";
+ params: defaultSearchParams(),
});
const mergedIssueFilter = computed(() => {
@@ -320,62 +133,84 @@ watch(
);
useRefreshIssueList(() => issuePagedTable.value?.refresh());
-const selectTab = (target: TabValue) => {
- if (target === "") return;
- storedTab.value = target;
- tab.value = target;
+watch(
+ () => getSemanticIssueStatusFromSearchParams(state.params),
+ (status) => {
+ storedStatus.value = status;
+ }
+);
+
+// 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;
};
-const toggleAdvancedSearch = (on: boolean) => {
- state.advanced = on;
- if (!on) {
- if (storedTab.value !== "") {
- selectTab(storedTab.value);
- } else {
- selectTab(tabItemList.value[0].value);
- }
- state.params.query = "";
+// Track the initial URL query string to distinguish between user-provided URLs
+// and programmatic navigation to default state
+const initialQueryString = ref<string | null>(null);
+
+// Initialize params from URL query on mount
+onMounted(() => {
+ const queryString = route.query.q as string;
+ initialQueryString.value = queryString || null;
+
+ if (queryString) {
+ const urlParams = buildSearchParamsBySearchText(queryString);
+ // Use URL params directly, don't merge with defaults
+ state.params = urlParams;
}
-};
+ // No else - keep URL clean for default preset
+});
+// Sync params to URL query when params change
+let isUpdatingFromUrl = false;
watch(
- [tab],
- () => {
- if (tab.value === "WAITING_APPROVAL") {
- if (getSemanticIssueStatusFromSearchParams(state.params) === "CLOSED") {
- upsertScope({
- params: state.params,
- scopes: {
- id: "status",
- value: "OPEN",
- },
- mutate: true,
- });
- }
+ () => state.params,
+ (params) => {
+ if (isUpdatingFromUrl) {
+ return;
}
- },
- { immediate: true }
-);
-watch(
- () => tab.value,
- () => {
- if (tab.value !== "") {
- // using custom advanced search query, sync the search query string
- // to URL
- const query = cloneDeep(route.query);
- delete query["qs"];
- router.replace({
- query,
- });
+ 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.value) {
+ // 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;
+ });
+ }
}
- }
-);
-
-watch(
- () => getSemanticIssueStatusFromSearchParams(state.params),
- (status) => {
- storedStatus.value = status;
- }
+ },
+ { deep: true }
);
</script>