Skip to content

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

fix: should show effected env in sql editor (#7536)

ecmadao8c60a1b4b3ec
diff --git a/frontend/src/components/DatabaseListSidePanel.vue b/frontend/src/components/DatabaseListSidePanel.vue
index 34f1919ff4..fba8499ee0 100644
--- a/frontend/src/components/DatabaseListSidePanel.vue
+++ b/frontend/src/components/DatabaseListSidePanel.vue
@@ -99,11 +99,7 @@ const databaseListByEnvironment = computed(() => {
return a.name.localeCompare(b.name);
});
for (const database of list) {
- const dbList = envToDbMap.get(
- String(
- database.environment || database.instanceEntity.environmentEntity.name
- )
- )!;
+ const dbList = envToDbMap.get(String(database.effectiveEnvironment))!;
// dbList may be undefined if the environment is archived
if (dbList) {
dbList.push({
diff --git a/frontend/src/views/sql-editor/AsidePanel/TreeNode/InstancePrefix.vue b/frontend/src/views/sql-editor/AsidePanel/TreeNode/InstancePrefix.vue
index 480cf8a8ac..4eebc55243 100644
--- a/frontend/src/views/sql-editor/AsidePanel/TreeNode/InstancePrefix.vue
+++ b/frontend/src/views/sql-editor/AsidePanel/TreeNode/InstancePrefix.vue
@@ -4,11 +4,11 @@
(
</span>
<ProductionEnvironmentV1Icon
- :environment="instance.environmentEntity"
+ :environment="environment"
class="w-4 h-4 text-inherit"
/>
<span class="text-sm" :class="[!disabled && 'text-gray-500']">
- {{ instance.environmentEntity.title }}
+ {{ environment.title }}
</span>
<span class="text-sm -ml-0.5" :class="[!disabled && 'text-gray-500']">
)
@@ -21,10 +21,12 @@ import {
ProductionEnvironmentV1Icon,
} from "@/components/v2";
import { ComposedInstance } from "@/types";
+import { Environment } from "@/types/proto/v1/environment_service";
withDefaults(
defineProps<{
instance: ComposedInstance;
+ environment: Environment;
disabled?: boolean;
}>(),
{
diff --git a/frontend/src/views/sql-editor/AsidePanel/TreeNode/Prefix.vue b/frontend/src/views/sql-editor/AsidePanel/TreeNode/Prefix.vue
index 2c58039be9..d788f46677 100644
--- a/frontend/src/views/sql-editor/AsidePanel/TreeNode/Prefix.vue
+++ b/frontend/src/views/sql-editor/AsidePanel/TreeNode/Prefix.vue
@@ -4,7 +4,11 @@
</template>
<template v-else-if="atom.type === 'instance'">
<span class="flex items-center gap-x-1">
- <InstancePrefix :instance="instance" :disabled="atom.disabled" />
+ <InstancePrefix
+ :instance="instance"
+ :environment="environment"
+ :disabled="atom.disabled"
+ />
</span>
</template>
<template v-else-if="atom.type === 'database'">
@@ -12,6 +16,7 @@
<InstancePrefix
v-if="connectionTreeStore.tree.mode === ConnectionTreeMode.PROJECT"
:instance="database.instanceEntity"
+ :environment="environment"
:disabled="atom.disabled"
/>
@@ -26,12 +31,14 @@ import {
useConnectionTreeStore,
useDatabaseV1Store,
useInstanceV1Store,
+ useEnvironmentV1Store,
} from "@/store";
import {
ConnectionAtom,
ConnectionTreeMode,
unknownInstance,
unknownDatabase,
+ unknownEnvironment,
} from "@/types";
import InstancePrefix from "./InstancePrefix.vue";
@@ -41,6 +48,7 @@ const props = defineProps<{
const instanceStore = useInstanceV1Store();
const databaseStore = useDatabaseV1Store();
+const environmentStore = useEnvironmentV1Store();
const connectionTreeStore = useConnectionTreeStore();
const instance = computed(() => {
@@ -59,4 +67,12 @@ const database = computed(() => {
}
return unknownDatabase();
});
+
+const environment = computed(() => {
+ return (
+ environmentStore.getEnvironmentByName(
+ database.value.effectiveEnvironment
+ ) ?? unknownEnvironment()
+ );
+});
</script>
diff --git a/frontend/src/views/sql-editor/EditorCommon/ConnectionPathBar.vue b/frontend/src/views/sql-editor/EditorCommon/ConnectionPathBar.vue
index 4c022c4526..b7e12db730 100644
--- a/frontend/src/views/sql-editor/EditorCommon/ConnectionPathBar.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/ConnectionPathBar.vue
@@ -31,9 +31,9 @@
v-if="selectedInstance.uid !== String(UNKNOWN_ID)"
class="flex items-center"
>
- <span class="">{{ selectedInstance.environmentEntity.title }}</span>
+ <span class="">{{ selectedEnvironment.title }}</span>
<ProductionEnvironmentV1Icon
- :environment="selectedInstance.environmentEntity"
+ :environment="selectedEnvironment"
class="ml-1"
:class="[isProductionEnvironment && '~!text-yellow-700']"
/>
@@ -82,14 +82,20 @@ import {
InstanceV1EngineIcon,
ProductionEnvironmentV1Icon,
} from "@/components/v2";
-import { useTabStore, useDatabaseV1ByUID, useInstanceV1ByUID } from "@/store";
-import { TabMode, UNKNOWN_ID } from "@/types";
+import {
+ useTabStore,
+ useDatabaseV1ByUID,
+ useInstanceV1ByUID,
+ useEnvironmentV1Store,
+} from "@/store";
+import { TabMode, UNKNOWN_ID, unknownEnvironment } from "@/types";
import { EnvironmentTier } from "@/types/proto/v1/environment_service";
import { DataSourceType } from "@/types/proto/v1/instance_service";
import { instanceV1Slug } from "@/utils";
const router = useRouter();
const tabStore = useTabStore();
+const environmentStore = useEnvironmentV1Store();
const connection = computed(() => tabStore.currentTab.connection);
@@ -101,9 +107,16 @@ const { database: selectedDatabaseV1 } = useDatabaseV1ByUID(
computed(() => String(connection.value.databaseId))
);
+const selectedEnvironment = computed(() => {
+ return (
+ environmentStore.getEnvironmentByName(
+ selectedDatabaseV1.value.effectiveEnvironment
+ ) ?? unknownEnvironment()
+ );
+});
+
const isProductionEnvironment = computed(() => {
- const instance = selectedInstance.value;
- return instance.environmentEntity.tier === EnvironmentTier.PROTECTED;
+ return selectedEnvironment.value.tier === EnvironmentTier.PROTECTED;
});
const isAdminMode = computed(() => {