Skip to content

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

fix: hide readonly scope tags from AdvancedSearch UI (#19562)

boojack46bb433fd750
diff --git a/frontend/src/components/AdvancedSearch/ScopeTags.vue b/frontend/src/components/AdvancedSearch/ScopeTags.vue
index cf4a9382a7..4bc8dd08f9 100644
--- a/frontend/src/components/AdvancedSearch/ScopeTags.vue
+++ b/frontend/src/components/AdvancedSearch/ScopeTags.vue
@@ -1,20 +1,19 @@
<template>
<NTag
- v-for="(scope, i) in params.scopes"
- :key="`${i}-${scope.id}`"
- :closable="!scope.readonly"
- :disabled="scope.readonly"
+ v-for="({ scope, originalIndex }, visibleIndex) in visibleScopes"
+ :key="`${originalIndex}-${scope.id}`"
+ closable
:data-search-scope-id="scope.id"
:bordered="false"
size="small"
style="--n-icon-size: 12px"
- v-bind="tagProps(i)"
- @close="$emit('remove-scope', i)"
- @click.stop.prevent="handleClick(scope)"
+ v-bind="tagProps(visibleIndex)"
+ @close="$emit('remove-scope', originalIndex)"
+ @click.stop.prevent="$emit('select-scope', scope)"
>
<div class="flex items-center gap-1">
<span class="text-control">{{ scope.id }}:</span>
- <component :is="() => renderValue(scope, i)" />
+ <component :is="() => renderValue(scope)" />
</div>
</NTag>
</template>
@@ -23,6 +22,7 @@
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 } from "@/utils";
@@ -35,13 +35,19 @@ const props = defineProps<{
focusedTagIndex?: number;
}>();
-const emit = defineEmits<{
+defineEmits<{
(event: "remove-scope", index: number): void;
(event: "select-scope", scope: SearchScope): void;
}>();
const { t } = useI18n();
+const visibleScopes = computed(() => {
+ return props.params.scopes
+ .map((scope, originalIndex) => ({ scope, originalIndex }))
+ .filter(({ scope }) => !scope.readonly);
+});
+
const tagProps = (index: number): TagProps => {
if (props.focusedTagIndex !== index) {
return {};
@@ -54,7 +60,7 @@ const tagProps = (index: number): TagProps => {
};
};
-const renderValue = (scope: SearchScope, _index: number) => {
+const renderValue = (scope: SearchScope) => {
const scopeOption = props.scopeOptions
.find((option) => option.id === scope.id)
?.options?.find((option) => option.value === scope.value);
@@ -73,12 +79,4 @@ const renderValue = (scope: SearchScope, _index: number) => {
}
return <span>{scope.value}</span>;
};
-
-const handleClick = (scope: SearchScope) => {
- if (scope.readonly) {
- return;
- }
-
- emit("select-scope", scope);
-};
</script>