Skip to content

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

fix: the readonly scope not update after switch the project (#15499)

ecmadao27e4408b9fbd
diff --git a/frontend/src/components/AdvancedSearch/AdvancedSearch.vue b/frontend/src/components/AdvancedSearch/AdvancedSearch.vue
index 52d2922ecb..17c50d4b9c 100644
--- a/frontend/src/components/AdvancedSearch/AdvancedSearch.vue
+++ b/frontend/src/components/AdvancedSearch/AdvancedSearch.vue
@@ -30,7 +30,6 @@
<ScopeTags
:params="params"
:focused-tag-id="focusedTagId"
- :readonly-scopes="readonlyScopes"
@select-scope="selectScopeFromTag"
@remove-scope="removeScope"
/>
@@ -92,7 +91,7 @@ import scrollIntoView from "scroll-into-view-if-needed";
import { zindexable as vZindexable } from "vdirs";
import { reactive, watch, onMounted, ref, computed, nextTick } from "vue";
import { useRoute, useRouter } from "vue-router";
-import type { SearchParams, SearchScope, SearchScopeId } from "@/utils";
+import type { SearchParams, SearchScopeId } from "@/utils";
import {
emptySearchParams,
getValueFromSearchParams,
@@ -111,12 +110,10 @@ const props = withDefaults(
params: SearchParams;
scopeOptions: ScopeOption[];
placeholder?: string | undefined;
- readonlyScopes?: SearchScope[];
autofocus?: boolean;
}>(),
{
scopeOptions: () => [],
- readonlyScopes: () => [],
autofocus: false,
placeholder: undefined,
}
@@ -138,9 +135,11 @@ const router = useRouter();
const defaultSearchParams = () => {
const params = emptySearchParams();
- props.readonlyScopes.forEach((s) => {
- params.scopes.push({ ...s });
- });
+ for (const scope of props.params.scopes) {
+ if (scope.readonly) {
+ params.scopes.push({ ...scope });
+ }
+ }
return params;
};
@@ -165,11 +164,9 @@ const inputRef = ref<InputInst>();
const menuIndex = ref(0);
const { width: containerWidth } = useElementSize(containerRef);
const focusedTagId = ref<SearchScopeId>();
-const readonlyScopeIds = computed(() => {
- return new Set(props.readonlyScopes.map((s) => s.id));
-});
+
const editableScopes = computed(() => {
- return props.params.scopes.filter((s) => !readonlyScopeIds.value.has(s.id));
+ return props.params.scopes.filter((s) => !s.readonly);
});
watch(
diff --git a/frontend/src/components/AdvancedSearch/ScopeTags.vue b/frontend/src/components/AdvancedSearch/ScopeTags.vue
index 23c06b6270..a340149dec 100644
--- a/frontend/src/components/AdvancedSearch/ScopeTags.vue
+++ b/frontend/src/components/AdvancedSearch/ScopeTags.vue
@@ -2,8 +2,8 @@
<NTag
v-for="(scope, i) in params.scopes"
:key="scope.id"
- :closable="!isReadonlyScope(scope)"
- :disabled="isReadonlyScope(scope)"
+ :closable="!scope.readonly"
+ :disabled="scope.readonly"
:data-search-scope-id="scope.id"
:bordered="false"
size="small"
@@ -22,7 +22,6 @@
import dayjs from "dayjs";
import type { TagProps } from "naive-ui";
import { NTag } from "naive-ui";
-import { computed } from "vue";
import { useI18n } from "vue-i18n";
import { UNKNOWN_ID } from "@/types";
import type { SearchParams, SearchScope, SearchScopeId } from "@/utils";
@@ -31,7 +30,6 @@ import { callCssVariable, extractDatabaseResourceName } from "@/utils";
const props = defineProps<{
params: SearchParams;
focusedTagId?: SearchScopeId;
- readonlyScopes?: SearchScope[];
}>();
const emit = defineEmits<{
@@ -41,14 +39,6 @@ const emit = defineEmits<{
const { t } = useI18n();
-const readonlyScopeIds = computed(() => {
- return new Set((props.readonlyScopes ?? []).map((s) => s.id));
-});
-
-const isReadonlyScope = (scope: SearchScope) => {
- return readonlyScopeIds.value.has(scope.id);
-};
-
const tagProps = (scope: SearchScope): TagProps => {
if (props.focusedTagId !== scope.id) {
return {};
@@ -76,7 +66,7 @@ const renderValue = (scope: SearchScope, _index: number) => {
};
const handleClick = (scope: SearchScope) => {
- if (isReadonlyScope(scope)) {
+ if (scope.readonly) {
return;
}
diff --git a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue
index 1a0fa286b1..4ad0ad1e81 100644
--- a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue
+++ b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue
@@ -23,7 +23,6 @@
:autofocus="false"
:placeholder="$t('database.filter-database')"
:scope-options="scopeOptions"
- :readonly-scopes="readonlyScopes"
/>
</div>
@@ -171,7 +170,11 @@ const schemaEditorContext = ref<{
});
const readonlyScopes = computed((): SearchScope[] => [
- { id: "project", value: extractProjectResourceName(props.projectName) },
+ {
+ id: "project",
+ value: extractProjectResourceName(props.projectName),
+ readonly: true,
+ },
]);
const state = reactive<LocalState>({
diff --git a/frontend/src/components/AuditLog/AuditLogSearch/AuditLogSearch.vue b/frontend/src/components/AuditLog/AuditLogSearch/AuditLogSearch.vue
index 578819c492..6ad4e16de3 100644
--- a/frontend/src/components/AuditLog/AuditLogSearch/AuditLogSearch.vue
+++ b/frontend/src/components/AuditLog/AuditLogSearch/AuditLogSearch.vue
@@ -3,7 +3,6 @@
<AdvancedSearch
class="flex-1"
:params="params"
- :readonly-scopes="readonlyScopes"
:scope-options="scopeOptions"
@update:params="$emit('update:params', $event)"
/>
@@ -39,18 +38,11 @@ import {
getDefaultPagination,
extractProjectResourceName,
type SearchParams,
- type SearchScope,
} from "@/utils";
-withDefaults(
- defineProps<{
- params: SearchParams;
- readonlyScopes?: SearchScope[];
- }>(),
- {
- readonlyScopes: () => [],
- }
-);
+defineProps<{
+ params: SearchParams;
+}>();
defineEmits<{
(event: "update:params", params: SearchParams): void;
}>();
diff --git a/frontend/src/components/DataExportPrepForm/DataExportPrepForm.vue b/frontend/src/components/DataExportPrepForm/DataExportPrepForm.vue
index 850958168e..ff2bd4f000 100644
--- a/frontend/src/components/DataExportPrepForm/DataExportPrepForm.vue
+++ b/frontend/src/components/DataExportPrepForm/DataExportPrepForm.vue
@@ -17,7 +17,6 @@
v-model:params="state.params"
:placeholder="$t('database.filter-database')"
:scope-options="scopeOptions"
- :readonly-scopes="readonlyScopes"
/>
</div>
@@ -88,7 +87,11 @@ const router = useRouter();
const databaseV1Store = useDatabaseV1Store();
const readonlyScopes = computed((): SearchScope[] => [
- { id: "project", value: extractProjectResourceName(props.projectName) },
+ {
+ id: "project",
+ value: extractProjectResourceName(props.projectName),
+ readonly: true,
+ },
]);
const state = reactive<LocalState>({
params: {
diff --git a/frontend/src/components/DatabaseAndGroupSelector/DatabaseAndGroupSelector.vue b/frontend/src/components/DatabaseAndGroupSelector/DatabaseAndGroupSelector.vue
index b7fc7111ee..70ff38b169 100644
--- a/frontend/src/components/DatabaseAndGroupSelector/DatabaseAndGroupSelector.vue
+++ b/frontend/src/components/DatabaseAndGroupSelector/DatabaseAndGroupSelector.vue
@@ -7,7 +7,6 @@
:autofocus="false"
:placeholder="$t('database.filter-database')"
:scope-options="scopeOptions"
- :readonly-scopes="readonlyScopes"
/>
<PagedDatabaseTable
mode="PROJECT"
@@ -71,7 +70,11 @@ const emit = defineEmits<{
}>();
const readonlyScopes = computed((): SearchScope[] => [
- { id: "project", value: extractProjectResourceName(props.project.name) },
+ {
+ id: "project",
+ value: extractProjectResourceName(props.project.name),
+ readonly: true,
+ },
]);
const searchParams = ref<SearchParams>({
diff --git a/frontend/src/components/IssueV1/components/IssueSearch/IssueSearch.vue b/frontend/src/components/IssueV1/components/IssueSearch/IssueSearch.vue
index 69c149c9a3..0bdc26c113 100644
--- a/frontend/src/components/IssueV1/components/IssueSearch/IssueSearch.vue
+++ b/frontend/src/components/IssueV1/components/IssueSearch/IssueSearch.vue
@@ -7,7 +7,6 @@
<AdvancedSearch
class="flex-1"
:params="params"
- :readonly-scopes="readonlyScopes"
:scope-options="scopeOptions"
@update:params="$emit('update:params', $event)"
/>
@@ -46,7 +45,7 @@ import TimeRange from "@/components/AdvancedSearch/TimeRange.vue";
import { useUserStore } from "@/store";
import { State, stateToJSON } from "@/types/proto/v1/common";
import { User, UserType, userTypeToJSON } from "@/types/proto/v1/user_service";
-import type { SearchParams, SearchScope, SearchScopeId } from "@/utils";
+import type { SearchParams, SearchScopeId } from "@/utils";
import {
getDefaultPagination,
UIIssueFilterScopeIdList,
@@ -60,14 +59,12 @@ export type SearchComponent = "searchbox" | "status" | "time-range";
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,
diff --git a/frontend/src/components/Project/ProjectIssuesPanel.vue b/frontend/src/components/Project/ProjectIssuesPanel.vue
index cc3d157f7e..8668e6de3a 100644
--- a/frontend/src/components/Project/ProjectIssuesPanel.vue
+++ b/frontend/src/components/Project/ProjectIssuesPanel.vue
@@ -2,7 +2,6 @@
<div class="flex flex-col gap-y-2">
<IssueSearch
v-model:params="state.params"
- :readonly-scopes="readonlyScopes"
:components="
state.advanced ? ['searchbox', 'time-range', 'status'] : ['status']
"
@@ -134,7 +133,11 @@ const issuePagedTable =
const readonlyScopes = computed((): SearchScope[] => {
return [
- { id: "project", value: extractProjectResourceName(props.project.name) },
+ {
+ id: "project",
+ value: extractProjectResourceName(props.project.name),
+ readonly: true,
+ },
];
});
const tabItemList = computed((): TabFilterItem<TabValue>[] => {
diff --git a/frontend/src/components/ProjectDatabasesPanel.vue b/frontend/src/components/ProjectDatabasesPanel.vue
index be67fe7f95..dcaaf25741 100644
--- a/frontend/src/components/ProjectDatabasesPanel.vue
+++ b/frontend/src/components/ProjectDatabasesPanel.vue
@@ -9,7 +9,6 @@
:autofocus="false"
:placeholder="$t('database.filter-database')"
:scope-options="scopeOptions"
- :readonly-scopes="readonlyScopes"
/>
<NButton
v-if="allowToCreateDB"
@@ -55,7 +54,7 @@
<script lang="ts" setup>
import { PlusIcon } from "lucide-vue-next";
import { NButton } from "naive-ui";
-import { reactive, computed, ref } from "vue";
+import { reactive, computed, ref, watch } from "vue";
import { CreateDatabasePrepPanel } from "@/components/CreateDatabasePrepForm";
import { Drawer } from "@/components/v2";
import { PagedDatabaseTable } from "@/components/v2/Model/DatabaseV1Table";
@@ -88,7 +87,11 @@ const props = defineProps<{
}>();
const readonlyScopes = computed((): SearchScope[] => [
- { id: "project", value: extractProjectResourceName(props.project.name) },
+ {
+ id: "project",
+ value: extractProjectResourceName(props.project.name),
+ readonly: true,
+ },
]);
const databaseStore = useDatabaseV1Store();
@@ -101,6 +104,17 @@ const state = reactive<LocalState>({
},
showCreateDrawer: false,
});
+
+watch(
+ () => props.project.name,
+ () => {
+ state.params = {
+ query: "",
+ scopes: [...readonlyScopes.value],
+ };
+ }
+);
+
const pagedDatabaseTableRef = ref<InstanceType<typeof PagedDatabaseTable>>();
const allowToCreateDB = computed(() => {
diff --git a/frontend/src/components/Rollout/RolloutDetail/Panels/TaskAdvancedSearch/TaskAdvancedSearch.vue b/frontend/src/components/Rollout/RolloutDetail/Panels/TaskAdvancedSearch/TaskAdvancedSearch.vue
index 1af45b38f7..877ba7c4d8 100644
--- a/frontend/src/components/Rollout/RolloutDetail/Panels/TaskAdvancedSearch/TaskAdvancedSearch.vue
+++ b/frontend/src/components/Rollout/RolloutDetail/Panels/TaskAdvancedSearch/TaskAdvancedSearch.vue
@@ -2,7 +2,6 @@
<AdvancedSearch
class="flex-1"
:params="params"
- :readonly-scopes="readonlyScopes"
:scope-options="scopeOptions"
@update:params="$emit('update:params', $event)"
/>
@@ -15,19 +14,13 @@ import { useI18n } from "vue-i18n";
import AdvancedSearch from "@/components/AdvancedSearch";
import type { ScopeOption } from "@/components/AdvancedSearch/types";
import { Task_Status } from "@/types/proto/v1/rollout_service";
-import { type SearchParams, type SearchScope } from "@/utils";
+import { type SearchParams } from "@/utils";
import { useRolloutDetailContext } from "../../context";
import { databaseForTask } from "../../utils";
-withDefaults(
- defineProps<{
- params: SearchParams;
- readonlyScopes?: SearchScope[];
- }>(),
- {
- readonlyScopes: () => [],
- }
-);
+defineProps<{
+ params: SearchParams;
+}>();
defineEmits<{
(event: "update:params", params: SearchParams): void;
@@ -112,37 +105,37 @@ const scopeOptions = computed((): ScopeOption[] => {
Task_Status.CANCELED,
Task_Status.SKIPPED,
].map((status) => {
- let statusTitle;
- switch (status) {
- case Task_Status.NOT_STARTED:
- statusTitle = t("task.status.not-started");
- break;
- case Task_Status.PENDING:
- statusTitle = t("task.status.pending");
- break;
- case Task_Status.RUNNING:
- statusTitle = t("task.status.running");
- break;
- case Task_Status.DONE:
- statusTitle = t("task.status.done");
- break;
- case Task_Status.FAILED:
- statusTitle = t("task.status.failed");
- break;
- case Task_Status.CANCELED:
- statusTitle = t("task.status.canceled");
- break;
- case Task_Status.SKIPPED:
- statusTitle = t("task.status.skipped");
- break;
- default:
- statusTitle = status;
- }
- return {
- value: status,
- keywords: [status],
- render: () => statusTitle,
- };
+ let statusTitle;
+ switch (status) {
+ case Task_Status.NOT_STARTED:
+ statusTitle = t("task.status.not-started");
+ break;
+ case Task_Status.PENDING:
+ statusTitle = t("task.status.pending");
+ break;
+ case Task_Status.RUNNING:
+ statusTitle = t("task.status.running");
+ break;
+ case Task_Status.DONE:
+ statusTitle = t("task.status.done");
+ break;
+ case Task_Status.FAILED:
+ statusTitle = t("task.status.failed");
+ break;
+ case Task_Status.CANCELED:
+ statusTitle = t("task.status.canceled");
+ break;
+ case Task_Status.SKIPPED:
+ statusTitle = t("task.status.skipped");
+ break;
+ default:
+ statusTitle = status;
+ }
+ return {
+ value: status,
+ keywords: [status],
+ render: () => statusTitle,
+ };
}),
},
];
diff --git a/frontend/src/components/SyncDatabaseSchemaV1/TargetDatabasesSelectPanel.vue b/frontend/src/components/SyncDatabaseSchemaV1/TargetDatabasesSelectPanel.vue
index 7dde926273..8d81c2ca5c 100644
--- a/frontend/src/components/SyncDatabaseSchemaV1/TargetDatabasesSelectPanel.vue
+++ b/frontend/src/components/SyncDatabaseSchemaV1/TargetDatabasesSelectPanel.vue
@@ -17,7 +17,6 @@
:autofocus="false"
:placeholder="$t('database.filter-database')"
:scope-options="scopeOptions"
- :readonly-scopes="readonlyScopes"
/>
<PagedDatabaseTable
@@ -70,7 +69,7 @@
<script setup lang="ts">
import { NButton, NTooltip } from "naive-ui";
-import { computed, reactive } from "vue";
+import { computed, reactive, watch } from "vue";
import { Drawer, DrawerContent } from "@/components/v2";
import { useDatabaseV1Store } from "@/store";
import {
@@ -97,7 +96,11 @@ const props = defineProps<{
}>();
const readonlyScopes = computed((): SearchScope[] => [
- { id: "project", value: extractProjectResourceName(props.project) },
+ {
+ id: "project",
+ value: extractProjectResourceName(props.project),
+ readonly: true,
+ },
]);
const emit = defineEmits<{
@@ -115,6 +118,16 @@ const state = reactive<LocalState>({
},
});
+watch(
+ () => props.project,
+ () => {
+ state.params = {
+ query: "",
+ scopes: [...readonlyScopes.value],
+ };
+ }
+);
+
const scopeOptions = useCommonSearchScopeOptions(
computed(() => state.params),
[...CommonFilterScopeIdList]
diff --git a/frontend/src/utils/v1/advanced-search/common.ts b/frontend/src/utils/v1/advanced-search/common.ts
index 3751ebd623..31e1d2eb17 100644
--- a/frontend/src/utils/v1/advanced-search/common.ts
+++ b/frontend/src/utils/v1/advanced-search/common.ts
@@ -57,6 +57,7 @@ export type SearchScopeId =
export type SearchScope = {
id: SearchScopeId;
value: string;
+ readonly?: boolean;
};
export interface SearchParams {
diff --git a/frontend/src/views/ExportCenter/index.vue b/frontend/src/views/ExportCenter/index.vue
index 7162a8d491..f0e1fe200d 100644
--- a/frontend/src/views/ExportCenter/index.vue
+++ b/frontend/src/views/ExportCenter/index.vue
@@ -7,7 +7,6 @@
<IssueSearch
v-model:params="state.params"
class="flex-1"
- :readonly-scopes="readonlyScopes"
:override-scope-id-list="overrideSearchScopeIdList"
>
<template #searchbox-suffix>
@@ -107,6 +106,7 @@ const readonlyScopes = computed((): SearchScope[] => {
{
id: "project",
value: extractProjectResourceName(specificProject.value.name),
+ readonly: true,
},
];
});
@@ -124,6 +124,14 @@ const state = reactive<LocalState>({
showRequestExportPanel: false,
params: defaultSearchParams(),
});
+
+watch(
+ () => props.projectId,
+ () => {
+ state.params = defaultSearchParams();
+ }
+);
+
const issueStore = useIssueV1Store();
const issuePagedTable =
ref<ComponentExposed<typeof PagedTable<ComposedIssue>>>();
diff --git a/frontend/src/views/InstanceDetail.vue b/frontend/src/views/InstanceDetail.vue
index 4687c94ea5..70a8412482 100644
--- a/frontend/src/views/InstanceDetail.vue
+++ b/frontend/src/views/InstanceDetail.vue
@@ -45,7 +45,6 @@
:autofocus="false"
:placeholder="$t('database.filter-database')"
:scope-options="scopeOptions"
- :readonly-scopes="readonlyScopes"
/>
</div>
<DatabaseOperations
@@ -167,7 +166,7 @@ const databaseChangeMode = useAppFeature("bb.feature.database-change-mode");
const pagedDatabaseTableRef = ref<InstanceType<typeof PagedDatabaseTable>>();
const readonlyScopes = computed((): SearchScope[] => [
- { id: "instance", value: props.instanceId },
+ { id: "instance", value: props.instanceId, readonly: true },
]);
const state = reactive<LocalState>({
diff --git a/frontend/src/views/ReviewCenter/index.vue b/frontend/src/views/ReviewCenter/index.vue
index bb4eb57fd4..1581eec36e 100644
--- a/frontend/src/views/ReviewCenter/index.vue
+++ b/frontend/src/views/ReviewCenter/index.vue
@@ -7,7 +7,6 @@
<AdvancedSearch
v-model:params="state.params"
class="flex-1"
- :readonly-scopes="readonlyScopes"
:scope-options="scopeOptions"
/>
<NDropdown
@@ -102,6 +101,7 @@ const readonlyScopes = computed((): SearchScope[] => {
{
id: "project",
value: extractProjectResourceName(specificProject.value.name),
+ readonly: true,
},
];
});
@@ -119,6 +119,12 @@ const currentUser = useCurrentUserV1();
const state = reactive<LocalState>({
params: defaultSearchParams(),
});
+
+watch(
+ () => props.projectId,
+ () => (state.params = defaultSearchParams())
+);
+
const planStore = usePlanStore();
const planPagedTable = ref<ComponentExposed<typeof PagedTable<ComposedPlan>>>();
diff --git a/frontend/src/views/project/ProjectAuditLogDashboard.vue b/frontend/src/views/project/ProjectAuditLogDashboard.vue
index b9060a8e79..84a1b75f18 100644
--- a/frontend/src/views/project/ProjectAuditLogDashboard.vue
+++ b/frontend/src/views/project/ProjectAuditLogDashboard.vue
@@ -1,10 +1,7 @@
<template>
<div class="w-full space-y-4">
<FeatureAttention feature="bb.feature.audit-log" />
- <AuditLogSearch
- v-model:params="state.params"
- :readonly-scopes="readonlyScopes"
- >
+ <AuditLogSearch v-model:params="state.params">
<template #searchbox-suffix>
<DataExportButton
size="medium"
@@ -75,7 +72,7 @@ const props = defineProps<{
}>();
const readonlyScopes = computed((): SearchScope[] => {
- return [{ id: "project", value: props.projectId }];
+ return [{ id: "project", value: props.projectId, readonly: true }];
});
const defaultSearchParams = () => {
@@ -89,6 +86,12 @@ const defaultSearchParams = () => {
const state = reactive<LocalState>({
params: defaultSearchParams(),
});
+
+watch(
+ () => props.projectId,
+ () => (state.params = defaultSearchParams())
+);
+
const { t } = useI18n();
const hasAuditLogFeature = featureToRef("bb.feature.audit-log");
const auditLogPagedTable = ref<ComponentExposed<typeof PagedTable<AuditLog>>>();