Skip to content

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

chore: fix sql editor issues (#9353)

boojack40224df085cf
diff --git a/frontend/src/components/ProvideSQLEditorContext.vue b/frontend/src/components/ProvideSQLEditorContext.vue
index fc54d9e58f..b4f1309105 100644
--- a/frontend/src/components/ProvideSQLEditorContext.vue
+++ b/frontend/src/components/ProvideSQLEditorContext.vue
@@ -1,9 +1,9 @@
<template>
- <slot />
+ <slot v-if="!isLoading" />
</template>
<script lang="ts" setup>
-import { onMounted, computed, watch } from "vue";
+import { onMounted, computed, watch, ref } from "vue";
import { useI18n } from "vue-i18n";
import { useRoute, useRouter } from "vue-router";
import {
@@ -44,6 +44,7 @@ import {
const route = useRoute();
const router = useRouter();
const { t } = useI18n();
+const isLoading = ref<boolean>(true);
const currentUserV1 = useCurrentUserV1();
const projectStpre = useProjectV1Store();
@@ -340,5 +341,6 @@ onMounted(async () => {
await useSettingV1Store().fetchSettingList();
syncURLWithConnection();
+ isLoading.value = false;
});
</script>
diff --git a/frontend/src/store/modules/v1/projectIamPolicy.ts b/frontend/src/store/modules/v1/projectIamPolicy.ts
index 8263f434ab..7d122cbbc3 100644
--- a/frontend/src/store/modules/v1/projectIamPolicy.ts
+++ b/frontend/src/store/modules/v1/projectIamPolicy.ts
@@ -4,7 +4,12 @@ import { computed, ref, unref, watch, watchEffect } from "vue";
import { projectServiceClient } from "@/grpcweb";
import { resolveCELExpr } from "@/plugins/cel";
import { hasFeature, usePolicyV1Store } from "@/store";
-import { ComposedDatabase, MaybeRef, PresetRoleType } from "@/types";
+import {
+ ALL_USERS_USER_NAME,
+ ComposedDatabase,
+ MaybeRef,
+ PresetRoleType,
+} from "@/types";
import { Expr } from "@/types/proto/google/api/expr/v1alpha1/syntax";
import { IamPolicy } from "@/types/proto/v1/iam_policy";
import {
@@ -230,7 +235,9 @@ export const useCurrentUserIamPolicy = () => {
if (
binding.role === PresetRoleType.OWNER &&
binding.members.find(
- (member) => member === `user:${currentUser.value.email}`
+ (member) =>
+ member === ALL_USERS_USER_NAME ||
+ member === `user:${currentUser.value.email}`
)
) {
return true;
@@ -238,7 +245,9 @@ export const useCurrentUserIamPolicy = () => {
if (
binding.role === PresetRoleType.QUERIER &&
binding.members.find(
- (member) => member === `user:${currentUser.value.email}`
+ (member) =>
+ member === ALL_USERS_USER_NAME ||
+ member === `user:${currentUser.value.email}`
)
) {
if (binding.parsedExpr?.expr) {
@@ -290,7 +299,9 @@ export const useCurrentUserIamPolicy = () => {
if (
binding.role === PresetRoleType.OWNER &&
binding.members.find(
- (member) => member === `user:${currentUser.value.email}`
+ (member) =>
+ member === ALL_USERS_USER_NAME ||
+ member === `user:${currentUser.value.email}`
)
) {
return true;
@@ -298,7 +309,9 @@ export const useCurrentUserIamPolicy = () => {
if (
binding.role === PresetRoleType.EXPORTER &&
binding.members.find(
- (member) => member === `user:${currentUser.value.email}`
+ (member) =>
+ member === ALL_USERS_USER_NAME ||
+ member === `user:${currentUser.value.email}`
)
) {
if (binding.parsedExpr?.expr) {
diff --git a/frontend/src/utils/v1/database.ts b/frontend/src/utils/v1/database.ts
index 739b720f16..3f86db927c 100644
--- a/frontend/src/utils/v1/database.ts
+++ b/frontend/src/utils/v1/database.ts
@@ -158,28 +158,6 @@ export const isDatabaseV1Queryable = (
// The current plan doesn't have access control feature.
// Fallback to true.
return true;
- } else {
- const name = `${policyNamePrefix}${policyTypeToJSON(
- PolicyType.WORKSPACE_IAM
- )}`;
- const policy = usePolicyV1Store().getPolicyByName(name);
- if (policy) {
- const bindings = policy.workspaceIamPolicy?.bindings;
- if (bindings) {
- const querierBinding = bindings.find(
- (binding) => binding.role === "roles/QUERIER"
- );
- if (querierBinding) {
- const simpleExpr = resolveCELExpr(
- querierBinding.parsedExpr?.expr || Expr.fromPartial({})
- );
- const envNameList = extractEnvironmentNameListFromExpr(simpleExpr);
- if (envNameList.includes(database.effectiveEnvironment)) {
- return true;
- }
- }
- }
- }
}
if (
@@ -198,6 +176,28 @@ export const isDatabaseV1Queryable = (
return true;
}
+ const name = `${policyNamePrefix}${policyTypeToJSON(
+ PolicyType.WORKSPACE_IAM
+ )}`;
+ const policy = usePolicyV1Store().getPolicyByName(name);
+ if (policy) {
+ const bindings = policy.workspaceIamPolicy?.bindings;
+ if (bindings) {
+ const querierBinding = bindings.find(
+ (binding) => binding.role === "roles/QUERIER"
+ );
+ if (querierBinding) {
+ const simpleExpr = resolveCELExpr(
+ querierBinding.parsedExpr?.expr || Expr.fromPartial({})
+ );
+ const envNameList = extractEnvironmentNameListFromExpr(simpleExpr);
+ if (envNameList.includes(database.effectiveEnvironment)) {
+ return true;
+ }
+ }
+ }
+ }
+
// denied otherwise
return false;
};
diff --git a/frontend/src/views/sql-editor/AsidePanel/DatabaseTree.vue b/frontend/src/views/sql-editor/AsidePanel/DatabaseTree.vue
index 65c7d20151..103cdf07a1 100644
--- a/frontend/src/views/sql-editor/AsidePanel/DatabaseTree.vue
+++ b/frontend/src/views/sql-editor/AsidePanel/DatabaseTree.vue
@@ -458,8 +458,6 @@ watch(
const db = databaseStore.getDatabaseByUID(databaseId);
treeStore.expandNodes("database", db);
}
-
- // scrollToConnectedNode(instanceId, databaseId);
},
{ immediate: true }
);
@@ -524,5 +522,6 @@ watch(
.sql-editor-tree :deep(.n-tree-node--selected),
.sql-editor-tree :deep(.n-tree-node--selected:hover) {
background-color: var(--n-node-color-active) !important;
+ font-weight: 500;
}
</style>
diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/TableCell.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/TableCell.vue
index 025eb27bf4..53d7955a4c 100644
--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/TableCell.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/TableCell.vue
@@ -7,7 +7,12 @@
v-html="html"
></div>
<div v-if="clickable" class="absolute right-1 top-1/2 translate-y-[-45%]">
- <NButton size="tiny" circle class="dark:!bg-dark-bg" @click="showDetail">
+ <NButton
+ size="tiny"
+ circle
+ class="dark:!bg-dark-bg"
+ @click.stop="showDetail"
+ >
<template #icon>
<heroicons:arrows-pointing-out class="w-3 h-3" />
</template>