Skip to content

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

feat: don't show read-only datasource warning in admin mode (#4618)

Liu Jiac7501b04958
diff --git a/frontend/src/views/sql-editor/EditorCommon/ConnectionPathBar.vue b/frontend/src/views/sql-editor/EditorCommon/ConnectionPathBar.vue
index c34d69df21..2357a5c405 100644
--- a/frontend/src/views/sql-editor/EditorCommon/ConnectionPathBar.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/ConnectionPathBar.vue
@@ -5,10 +5,7 @@
:class="[isProtectedEnvironment && 'bg-yellow-50']"
>
<div class="flex justify-start items-center">
- <NPopover
- v-if="selectedInstance.id !== UNKNOWN_ID && !hasReadonlyDataSource"
- trigger="hover"
- >
+ <NPopover v-if="showReadonlyDatasourceWarning" trigger="hover">
<template #trigger>
<heroicons-outline:exclamation
class="h-6 w-6 flex-shrink-0 mr-2"
@@ -28,78 +25,43 @@
</p>
</NPopover>
- <NPopover trigger="hover" placement="bottom" :show-arrow="false">
- <template #trigger>
- <label class="flex items-center text-sm space-x-1">
- <div
- v-if="selectedInstance.id !== UNKNOWN_ID"
- class="flex items-center"
- >
- <span class="">{{ selectedInstance.environment.name }}</span>
- <ProtectedEnvironmentIcon
- :environment="selectedInstance.environment"
- class="ml-1"
- :class="[isProtectedEnvironment && '~!text-yellow-700']"
- />
- </div>
- <div
- v-if="selectedInstance.id !== UNKNOWN_ID"
- class="flex items-center"
- >
- <span class="mx-2">
- <heroicons-solid:chevron-right
- class="flex-shrink-0 h-4 w-4 text-control-light"
- />
- </span>
- <InstanceEngineIcon :instance="selectedInstance" show-status />
- <span class="ml-2">{{ selectedInstance.name }}</span>
- </div>
- <div
- v-if="selectedDatabase.id !== UNKNOWN_ID"
- class="flex items-center"
- >
- <span class="mx-2">
- <heroicons-solid:chevron-right
- class="flex-shrink-0 h-4 w-4 text-control-light"
- />
- </span>
- <heroicons-outline:database />
- <span class="ml-2">{{ selectedDatabase.name }}</span>
- </div>
- </label>
- </template>
- <section>
- <div class="space-y-2">
- <div
- v-if="selectedInstance.id !== UNKNOWN_ID"
- class="flex flex-col"
- >
- <h1 class="text-gray-400">{{ $t("common.environment") }}</h1>
- <span class="flex items-center">
- {{ selectedInstance.environment.name }}
- <ProtectedEnvironmentIcon
- :environment="selectedInstance.environment"
- class="ml-1"
- />
- </span>
- </div>
- <div
- v-if="selectedInstance.id !== UNKNOWN_ID"
- class="flex flex-col"
- >
- <h1 class="text-gray-400">{{ $t("common.instance") }}</h1>
- <span>{{ selectedInstance.name }}</span>
- </div>
- <div
- v-if="selectedDatabase.id !== UNKNOWN_ID"
- class="flex flex-col"
- >
- <h1 class="text-gray-400">{{ $t("common.database") }}</h1>
- <span>{{ selectedDatabase.name }}</span>
- </div>
- </div>
- </section>
- </NPopover>
+ <label class="flex items-center text-sm space-x-1">
+ <div
+ v-if="selectedInstance.id !== UNKNOWN_ID"
+ class="flex items-center"
+ >
+ <span class="">{{ selectedInstance.environment.name }}</span>
+ <ProtectedEnvironmentIcon
+ :environment="selectedInstance.environment"
+ class="ml-1"
+ :class="[isProtectedEnvironment && '~!text-yellow-700']"
+ />
+ </div>
+ <div
+ v-if="selectedInstance.id !== UNKNOWN_ID"
+ class="flex items-center"
+ >
+ <span class="mx-2">
+ <heroicons-solid:chevron-right
+ class="flex-shrink-0 h-4 w-4 text-control-light"
+ />
+ </span>
+ <InstanceEngineIcon :instance="selectedInstance" show-status />
+ <span class="ml-2">{{ selectedInstance.name }}</span>
+ </div>
+ <div
+ v-if="selectedDatabase.id !== UNKNOWN_ID"
+ class="flex items-center"
+ >
+ <span class="mx-2">
+ <heroicons-solid:chevron-right
+ class="flex-shrink-0 h-4 w-4 text-control-light"
+ />
+ </span>
+ <heroicons-outline:database />
+ <span class="ml-2">{{ selectedDatabase.name }}</span>
+ </div>
+ </label>
</div>
<div :class="[isProtectedEnvironment ? 'text-yellow-700' : 'text-main']">
@@ -116,7 +78,7 @@ import { NPopover } from "naive-ui";
import { useRouter } from "vue-router";
import { useTabStore, useInstanceById, useDatabaseById } from "@/store";
-import { UNKNOWN_ID } from "@/types";
+import { TabMode, UNKNOWN_ID } from "@/types";
import { instanceSlug } from "@/utils";
const router = useRouter();
@@ -144,6 +106,14 @@ const hasReadonlyDataSource = computed(() => {
return false;
});
+const showReadonlyDatasourceWarning = computed(() => {
+ return (
+ tabStore.currentTab.mode === TabMode.ReadOnly &&
+ selectedInstance.value.id !== UNKNOWN_ID &&
+ !hasReadonlyDataSource.value
+ );
+});
+
const gotoInstanceDetailPage = () => {
const route = router.resolve({
name: "workspace.instance.detail",