Skip to content

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

chore: update search scopes for data exporting issues (#11954)

boojack75b0a682f38f
diff --git a/frontend/src/components/AdvancedSearch/useCommonSearchScopeOptions.ts b/frontend/src/components/AdvancedSearch/useCommonSearchScopeOptions.ts
index ee6edbfcaa..7118228c09 100644
--- a/frontend/src/components/AdvancedSearch/useCommonSearchScopeOptions.ts
+++ b/frontend/src/components/AdvancedSearch/useCommonSearchScopeOptions.ts
@@ -1,11 +1,7 @@
-import { orderBy } from "lodash-es";
import type { Ref, VNode } from "vue";
import { computed, h, unref } from "vue";
import { useI18n } from "vue-i18n";
-import BBAvatar from "@/bbkit/BBAvatar.vue";
import GitIcon from "@/components/GitIcon.vue";
-import SystemBotTag from "@/components/misc/SystemBotTag.vue";
-import YouTag from "@/components/misc/YouTag.vue";
import {
InstanceV1Name,
ProjectV1Name,
@@ -13,15 +9,13 @@ import {
EnvironmentV1Name,
} from "@/components/v2";
import {
- useCurrentUserV1,
useDatabaseV1Store,
useInstanceV1List,
useSearchDatabaseV1List,
- useUserStore,
useEnvironmentV1List,
useProjectV1List,
} from "@/store";
-import { SYSTEM_BOT_EMAIL, UNKNOWN_ID, type MaybeRef } from "@/types";
+import { UNKNOWN_ID, type MaybeRef } from "@/types";
import { engineToJSON } from "@/types/proto/v1/common";
import { Workflow } from "@/types/proto/v1/project_service";
import type { SearchParams, SearchScopeId } from "@/utils";
@@ -38,8 +32,6 @@ export const useCommonSearchScopeOptions = (
supportOptionIdList: MaybeRef<SearchScopeId[]>
) => {
const { t } = useI18n();
- const me = useCurrentUserV1();
- const userStore = useUserStore();
const databaseV1Store = useDatabaseV1Store();
const environmentList = useEnvironmentV1List(false /* !showDeleted */);
const { projectList } = useProjectV1List();
@@ -48,34 +40,6 @@ export const useCommonSearchScopeOptions = (
filter: "instance = instances/-",
});
- const principalSearchValueOptions = computed(() => {
- // Put "you" to the top
- const sortedUsers = orderBy(
- userStore.activeUserList,
- (user) => (user.name === me.value.name ? -1 : 1),
- "asc"
- );
- return sortedUsers.map<ValueOption>((user) => {
- return {
- value: user.email,
- keywords: [user.email, user.title],
- render: () => {
- const children = [
- h(BBAvatar, { size: "TINY", username: user.title }),
- renderSpan(user.title),
- ];
- if (user.name === me.value.name) {
- children.push(h(YouTag));
- }
- if (user.email === SYSTEM_BOT_EMAIL) {
- children.push(h(SystemBotTag));
- }
- return h("div", { class: "flex items-center gap-x-1" }, children);
- },
- };
- });
- });
-
// fullScopeOptions provides full search scopes and options.
// we need this as the source of truth.
const fullScopeOptions = computed((): ScopeOption[] => {
@@ -101,12 +65,6 @@ export const useCommonSearchScopeOptions = (
};
}),
},
- {
- id: "creator",
- title: t("issue.advanced-search.scope.creator.title"),
- description: t("issue.advanced-search.scope.creator.description"),
- options: principalSearchValueOptions.value,
- },
{
id: "instance",
title: t("issue.advanced-search.scope.instance.title"),
diff --git a/frontend/src/components/IssueV1/components/IssueSearch/IssueSearch.vue b/frontend/src/components/IssueV1/components/IssueSearch/IssueSearch.vue
index 0851a85216..e9f70ab372 100644
--- a/frontend/src/components/IssueV1/components/IssueSearch/IssueSearch.vue
+++ b/frontend/src/components/IssueV1/components/IssueSearch/IssueSearch.vue
@@ -40,7 +40,7 @@
import { ref, computed } from "vue";
import AdvancedSearch from "@/components/AdvancedSearch";
import TimeRange from "@/components/AdvancedSearch/TimeRange.vue";
-import type { SearchParams, SearchScope } from "@/utils";
+import type { SearchParams, SearchScope, SearchScopeId } from "@/utils";
import { UIIssueFilterScopeIdList, SearchScopeIdList } from "@/utils";
import Status from "./Status.vue";
import { useIssueSearchScopeOptions } from "./useIssueSearchScopeOptions";
@@ -62,12 +62,14 @@ const props = withDefaults(
defineProps<{
params: SearchParams;
readonlyScopes?: SearchScope[];
+ overrideScopeIdList?: SearchScopeId[];
autofocus?: boolean;
components?: SearchComponent[];
componentProps?: Partial<Record<SearchComponent, any>>;
}>(),
{
readonlyScopes: () => [],
+ overrideScopeIdList: () => [],
components: () => ["searchbox", "time-range", "status"],
componentProps: undefined,
}
@@ -78,8 +80,15 @@ defineEmits<{
const showTimeRange = ref(false);
+const allowedScopes = computed(() => {
+ if (props.overrideScopeIdList && props.overrideScopeIdList.length > 0) {
+ return props.overrideScopeIdList;
+ }
+ return [...UIIssueFilterScopeIdList, ...SearchScopeIdList];
+});
+
const scopeOptions = useIssueSearchScopeOptions(
computed(() => props.params),
- computed(() => [...UIIssueFilterScopeIdList, ...SearchScopeIdList])
+ allowedScopes
);
</script>
diff --git a/frontend/src/views/ExportCenter/DataExportIssueDataTable/DataExportIssueDataTable.vue b/frontend/src/views/ExportCenter/DataExportIssueDataTable/DataExportIssueDataTable.vue
index 886d716897..a71fa56979 100644
--- a/frontend/src/views/ExportCenter/DataExportIssueDataTable/DataExportIssueDataTable.vue
+++ b/frontend/src/views/ExportCenter/DataExportIssueDataTable/DataExportIssueDataTable.vue
@@ -13,17 +13,18 @@
</div>
</template>
-<script lang="ts" setup>
+<script lang="tsx" setup>
import { useElementSize } from "@vueuse/core";
import { head } from "lodash-es";
import type { DataTableColumn } from "naive-ui";
import { NPerformantEllipsis, NDataTable } from "naive-ui";
-import { computed, watch, ref, h } from "vue";
+import { computed, watch, ref } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import DatabaseInfo from "@/components/DatabaseInfo.vue";
import { databaseForTask } from "@/components/IssueV1";
import IssueStatusIconWithTaskSummary from "@/components/IssueV1/components/IssueStatusIconWithTaskSummary.vue";
+import { ProjectNameCell } from "@/components/v2/Model/DatabaseV1Table/cells";
import { emitWindowEvent } from "@/plugins";
import { PROJECT_V1_ROUTE_ISSUE_DETAIL } from "@/router/dashboard/projectV1";
import { useSheetV1Store } from "@/store";
@@ -32,7 +33,6 @@ import {
issueSlug,
extractProjectResourceName,
humanizeTs,
- getHighlightHTMLByRegExp,
flattenTaskV1List,
} from "@/utils";
@@ -44,30 +44,36 @@ const columnList = computed((): DataTableColumn<ComposedIssue>[] => {
key: "title",
title: t("issue.table.name"),
resizable: true,
- render: (issue) =>
- h("div", { class: "flex items-center overflow-hidden space-x-2" }, [
- h(IssueStatusIconWithTaskSummary, { issue }),
- h(
- "div",
- { class: "whitespace-nowrap text-control" },
- `${issue.projectEntity.key}-${issue.uid}`
- ),
- h(
- NPerformantEllipsis,
- {
- class: `flex-1 truncate`,
- },
- {
- default: () => h("span", { innerHTML: highlight(issue.title) }),
- tooltip: () =>
- h(
- "div",
- { class: "whitespace-pre-wrap break-words break-all" },
- issue.title
+ render: (issue) => {
+ return (
+ <div class="flex items-center overflow-hidden space-x-2">
+ <IssueStatusIconWithTaskSummary issue={issue} />
+ <div class="whitespace-nowrap text-control">
+ {issue.projectEntity.key}-{issue.uid}
+ </div>
+ <NPerformantEllipsis class="flex-1 truncate">
+ {{
+ default: () => <span>{issue.title}</span>,
+ tooltip: () => (
+ <div class="whitespace-pre-wrap break-words break-all">
+ {issue.title}
+ </div>
),
- }
- ),
- ]),
+ }}
+ </NPerformantEllipsis>
+ </div>
+ );
+ },
+ },
+ {
+ key: "project",
+ title: t("common.project"),
+ width: 144,
+ resizable: true,
+ hide: !props.showProject,
+ render: (issue) => (
+ <ProjectNameCell project={issue.projectEntity} mode={"ALL_SHORT"} />
+ ),
},
{
key: "database",
@@ -80,7 +86,7 @@ const columnList = computed((): DataTableColumn<ComposedIssue>[] => {
if (!database) {
return "-";
}
- return h(DatabaseInfo, { database });
+ return <DatabaseInfo database={database} />;
},
},
{
@@ -109,12 +115,12 @@ const columnList = computed((): DataTableColumn<ComposedIssue>[] => {
const props = withDefaults(
defineProps<{
issueList: ComposedIssue[];
- highlightText?: string;
loading?: boolean;
+ showProject: boolean;
}>(),
{
- highlightText: "",
loading: true,
+ showProject: true,
}
);
@@ -187,20 +193,4 @@ watch(
}
}
);
-
-const highlights = computed(() => {
- if (!props.highlightText) {
- return [];
- }
- return props.highlightText.toLowerCase().split(" ");
-});
-
-const highlight = (content: string) => {
- return getHighlightHTMLByRegExp(
- content,
- highlights.value,
- /* !caseSensitive */ false,
- /* className */ "bg-yellow-100"
- );
-};
</script>
diff --git a/frontend/src/views/ExportCenter/index.vue b/frontend/src/views/ExportCenter/index.vue
index 19d87e623c..1be4354145 100644
--- a/frontend/src/views/ExportCenter/index.vue
+++ b/frontend/src/views/ExportCenter/index.vue
@@ -7,8 +7,8 @@
<IssueSearch
v-model:params="state.params"
class="flex-1"
- :placeholder="''"
:readonly-scopes="readonlyScopes"
+ :override-scope-id-list="overideSearchScopeIdList"
>
<template #searchbox-suffix>
<NTooltip :disabled="allowExportData">
@@ -43,6 +43,7 @@
:loading="loading"
:issue-list="issueList"
:highlight-text="state.params.query"
+ :show-project="!specificProject"
/>
</template>
</PagedIssueTableV1>
@@ -77,6 +78,7 @@ import {
hasPermissionToCreateDataExportIssueInProject,
type SearchParams,
type SearchScope,
+ type SearchScopeId,
} from "@/utils";
import DataExportIssueDataTable from "./DataExportIssueDataTable";
import type { ExportRecord } from "./types";
@@ -154,6 +156,18 @@ const dataExportIssueSearchParams = computed(() => {
} as SearchParams;
});
+const overideSearchScopeIdList = computed(() => {
+ const defaultScopeIdList: SearchScopeId[] = [
+ "status",
+ "instance",
+ "database",
+ ];
+ if (!specificProject.value) {
+ defaultScopeIdList.push("project");
+ }
+ return defaultScopeIdList;
+});
+
const mergedIssueFilter = computed(() => {
return buildIssueFilterBySearchParams(dataExportIssueSearchParams.value);
});