Skip to content

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

feat: allow to clear the last label (#8746)

Tianzhou (天舟)87228ced483e
diff --git a/frontend/src/views/sql-editor/AsidePanel/GroupingBar/FactorTag.vue b/frontend/src/views/sql-editor/AsidePanel/GroupingBar/FactorTag.vue
index dca959be80..44be10a02f 100644
--- a/frontend/src/views/sql-editor/AsidePanel/GroupingBar/FactorTag.vue
+++ b/frontend/src/views/sql-editor/AsidePanel/GroupingBar/FactorTag.vue
@@ -8,8 +8,11 @@
@click.stop="handleClick"
>
<span
- class="leading-6 hover:line-through"
- :class="factor.disabled && 'line-through'"
+ class="leading-6"
+ :class="[
+ factor.disabled && 'line-through',
+ allowDisable && 'hover:line-through',
+ ]"
>
{{ readableSQLEditorTreeFactor(factor.factor) }}
</span>
@@ -48,18 +51,15 @@ const allowDisable = computed(() => {
});
const allowRemove = computed(() => {
- if (factorList.value.length <= 1) {
- // Disallow to remove the only one factor
- return false;
- }
const { factor } = props;
- if (!factor.disabled) {
- if (filteredFactorList.value.length <= 1) {
- // Disallow to remove the only one enabled factor
- return false;
- }
+ // Always allow to remove the disabled factor
+ if (factor.disabled) {
+ return true;
}
- return true;
+
+ // Otherwise, we only allow to remove the enabled factor if this is the only factor
+ // or there exists other enabled factors
+ return factorList.value.length === 1 || filteredFactorList.value.length >= 2;
});
const clickable = computed(() => {
diff --git a/frontend/src/views/sql-editor/AsidePanel/GroupingBar/GroupingBar.vue b/frontend/src/views/sql-editor/AsidePanel/GroupingBar/GroupingBar.vue
index b93ceeab16..9376383773 100644
--- a/frontend/src/views/sql-editor/AsidePanel/GroupingBar/GroupingBar.vue
+++ b/frontend/src/views/sql-editor/AsidePanel/GroupingBar/GroupingBar.vue
@@ -89,6 +89,12 @@ const toggleDisabled = (factor: StatefulFactor, index: number) => {
const remove = (factor: StatefulFactor, index: number) => {
factorList.value.splice(index, 1);
+ if (factorList.value.length === 0) {
+ factorList.value.push({
+ factor: "project",
+ disabled: false,
+ });
+ }
treeStore.buildTree();
};