Skip to content

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

chore: handle null environment (#17158)

ecmadao4985e40468df
diff --git a/frontend/src/bbkit/BBAlert.vue b/frontend/src/bbkit/BBAlert.vue
index 86b090d5f3..96dcbff89d 100644
--- a/frontend/src/bbkit/BBAlert.vue
+++ b/frontend/src/bbkit/BBAlert.vue
@@ -7,6 +7,7 @@
:content="description"
:negative-text="cancelText"
:positive-text="okText"
+ :positive-button-props="positiveButtonProps"
@update:show="$emit('update:show', $event)"
@positive-click="() => $emit('ok')"
@negative-click="() => $emit('cancel')"
@@ -16,7 +17,7 @@
</template>
<script lang="ts" setup>
-import { NModal } from "naive-ui";
+import { NModal, type ButtonProps } from "naive-ui";
import { t } from "@/plugins/i18n";
withDefaults(
@@ -24,6 +25,7 @@ withDefaults(
show: boolean;
type: "info" | "warning";
title: string;
+ positiveButtonProps?: ButtonProps | undefined;
description?: string;
okText?: string;
cancelText?: string;
diff --git a/frontend/src/bbkit/BBButtonConfirm.vue b/frontend/src/bbkit/BBButtonConfirm.vue
index d53c25cbf3..d4caabe6af 100644
--- a/frontend/src/bbkit/BBButtonConfirm.vue
+++ b/frontend/src/bbkit/BBButtonConfirm.vue
@@ -30,6 +30,7 @@
:ok-text="okText"
:title="confirmTitle"
:description="confirmDescription"
+ :positive-button-props="positiveButtonProps"
@ok="
() => {
state.showModal = false;
@@ -44,7 +45,7 @@
<script lang="ts" setup>
import { ArchiveIcon, Trash2Icon, Undo2Icon } from "lucide-vue-next";
-import { NButton } from "naive-ui";
+import { NButton, type ButtonProps } from "naive-ui";
import { computed, reactive } from "vue";
import { useI18n } from "vue-i18n";
import BBAlert from "./BBAlert.vue";
@@ -55,6 +56,7 @@ const props = withDefaults(
type?: BBButtonConfirmType;
text?: boolean;
buttonText?: string;
+ positiveButtonProps?: ButtonProps | undefined;
requireConfirm?: boolean;
okText?: string;
confirmTitle?: string;
diff --git a/frontend/src/components/AdvancedSearch/AdvancedSearch.vue b/frontend/src/components/AdvancedSearch/AdvancedSearch.vue
index 65edba0664..af4879e38f 100644
--- a/frontend/src/components/AdvancedSearch/AdvancedSearch.vue
+++ b/frontend/src/components/AdvancedSearch/AdvancedSearch.vue
@@ -28,6 +28,7 @@
>
<ScopeTags
:params="params"
+ :scope-options="scopeOptions"
:focused-tag-id="focusedTagId"
@select-scope="selectScopeFromTag"
@remove-scope="removeScope"
diff --git a/frontend/src/components/AdvancedSearch/ScopeTags.vue b/frontend/src/components/AdvancedSearch/ScopeTags.vue
index a0a7a8d81a..80c1030719 100644
--- a/frontend/src/components/AdvancedSearch/ScopeTags.vue
+++ b/frontend/src/components/AdvancedSearch/ScopeTags.vue
@@ -26,9 +26,11 @@ import { useI18n } from "vue-i18n";
import { UNKNOWN_ID } from "@/types";
import type { SearchParams, SearchScope, SearchScopeId } from "@/utils";
import { callCssVariable, extractDatabaseResourceName } from "@/utils";
+import type { ScopeOption } from "./types";
const props = defineProps<{
params: SearchParams;
+ scopeOptions: ScopeOption[];
focusedTagId?: SearchScopeId;
}>();
@@ -52,6 +54,12 @@ const tagProps = (scope: SearchScope): TagProps => {
};
const renderValue = (scope: SearchScope, _index: number) => {
+ const scopeOption = props.scopeOptions
+ .find((option) => option.id === scope.id)
+ ?.options?.find((option) => option.value === scope.value);
+ if (scopeOption && scopeOption.render) {
+ return scopeOption.render();
+ }
if (scope.id === "created" || scope.id === "updated") {
const [begin, end] = scope.value.split(",").map((ts) => parseInt(ts, 10));
return [dayjs(begin).format("L"), dayjs(end).format("L")].join("-");
diff --git a/frontend/src/components/AdvancedSearch/ValueMenu.vue b/frontend/src/components/AdvancedSearch/ValueMenu.vue
index 8d328a13fd..50bba0cca0 100644
--- a/frontend/src/components/AdvancedSearch/ValueMenu.vue
+++ b/frontend/src/components/AdvancedSearch/ValueMenu.vue
@@ -48,7 +48,9 @@
@mouseenter.prevent.stop="$emit('hover-item', index)"
@mousedown.prevent.stop="$emit('select-value', option.value)"
>
- <component :is="option.render" class="text-control text-sm" />
+ <template v-if="option.render">
+ <component :is="option.render" class="text-control text-sm" />
+ </template>
<span v-if="!option.custom" class="text-control-light text-sm">
{{ option.value }}
</span>
diff --git a/frontend/src/components/AdvancedSearch/types.ts b/frontend/src/components/AdvancedSearch/types.ts
index 518cfd90d5..9d190e5d01 100644
--- a/frontend/src/components/AdvancedSearch/types.ts
+++ b/frontend/src/components/AdvancedSearch/types.ts
@@ -17,5 +17,5 @@ export type ValueOption = {
value: string;
keywords: string[];
custom?: boolean;
- render: RenderFunction;
+ render?: RenderFunction;
};
diff --git a/frontend/src/components/AdvancedSearch/useCommonSearchScopeOptions.ts b/frontend/src/components/AdvancedSearch/useCommonSearchScopeOptions.ts
index a0c82142f8..b62325fd92 100644
--- a/frontend/src/components/AdvancedSearch/useCommonSearchScopeOptions.ts
+++ b/frontend/src/components/AdvancedSearch/useCommonSearchScopeOptions.ts
@@ -15,10 +15,10 @@ import {
useProjectV1Store,
} from "@/store";
import type { MaybeRef } from "@/types";
+import { unknownEnvironment, UNKNOWN_ENVIRONMENT_NAME } from "@/types";
import { Engine } from "@/types/proto-es/v1/common_pb";
import type { SearchScopeId } from "@/utils";
import {
- environmentV1Name,
extractEnvironmentResourceName,
extractInstanceResourceName,
extractProjectResourceName,
@@ -123,11 +123,12 @@ export const useCommonSearchScopeOptions = (
link: false,
tooltip: false,
}),
- h(
- "span",
- {},
- `(${environmentV1Name(environmentStore.getEnvironmentByName(ins.environment ?? ""))})`
- ),
+ h(EnvironmentV1Name, {
+ environment: environmentStore.getEnvironmentByName(
+ ins.environment ?? ""
+ ),
+ link: false,
+ }),
]);
},
};
@@ -139,10 +140,11 @@ export const useCommonSearchScopeOptions = (
id: "environment",
title: t("issue.advanced-search.scope.environment.title"),
description: t("issue.advanced-search.scope.environment.description"),
- options: environmentList.value.map((env) => {
+ options: [unknownEnvironment(), ...environmentList.value].map((env) => {
return {
value: env.id,
keywords: [`${environmentNamePrefix}${env.id}`, env.title],
+ custom: env.name === UNKNOWN_ENVIRONMENT_NAME,
render: () =>
h(EnvironmentV1Name, {
environment: env,
diff --git a/frontend/src/components/AuditLog/AuditLogSearch/AuditLogSearch.vue b/frontend/src/components/AuditLog/AuditLogSearch/AuditLogSearch.vue
index 08181bbfe5..d725bf5469 100644
--- a/frontend/src/components/AuditLog/AuditLogSearch/AuditLogSearch.vue
+++ b/frontend/src/components/AuditLog/AuditLogSearch/AuditLogSearch.vue
@@ -151,7 +151,6 @@ const scopeOptions = computed((): ScopeOption[] => {
return {
value: method,
keywords: [method],
- render: () => "",
};
}),
},
@@ -165,7 +164,6 @@ const scopeOptions = computed((): ScopeOption[] => {
return {
value: severity,
keywords: [severity],
- render: () => "",
};
}),
},
diff --git a/frontend/src/components/DatabaseGroup/MatchedDatabaseView.vue b/frontend/src/components/DatabaseGroup/MatchedDatabaseView.vue
index 33ea8aa11b..654bc99816 100644
--- a/frontend/src/components/DatabaseGroup/MatchedDatabaseView.vue
+++ b/frontend/src/components/DatabaseGroup/MatchedDatabaseView.vue
@@ -36,12 +36,11 @@
:instance="database.instanceResource"
:link="false"
/>
- <NEllipsis
+ <EnvironmentV1Name
class="ml-1 text-sm text-gray-400 max-w-[124px]"
- line-clamp="1"
- >
- ({{ database.effectiveEnvironmentEntity.title }})
- </NEllipsis>
+ :environment="database.effectiveEnvironmentEntity"
+ :link="false"
+ />
</div>
</div>
</div>
@@ -62,11 +61,12 @@
<script lang="ts" setup>
import type { ConnectError } from "@connectrpc/connect";
import { useDebounceFn } from "@vueuse/core";
-import { NButton, NEllipsis, NCollapse, NCollapseItem } from "naive-ui";
+import { NButton, NCollapse, NCollapseItem } from "naive-ui";
import { watch, reactive } from "vue";
import { useI18n } from "vue-i18n";
import { BBSpin } from "@/bbkit";
import { DatabaseV1Name, InstanceV1Name } from "@/components/v2";
+import { EnvironmentV1Name } from "@/components/v2";
import type { ConditionGroupExpr } from "@/plugins/cel";
import { validateSimpleExpr } from "@/plugins/cel";
import { useDatabaseV1Store, useDBGroupStore } from "@/store";
diff --git a/frontend/src/components/EnvironmentForm/Form.vue b/frontend/src/components/EnvironmentForm/Form.vue
index 6e94770990..84acd5fa47 100644
--- a/frontend/src/components/EnvironmentForm/Form.vue
+++ b/frontend/src/components/EnvironmentForm/Form.vue
@@ -124,19 +124,33 @@
:confirm-title="
$t('environment.delete') + ` '${state.environment.title}'?`
"
- :confirm-description="
- isDev()
- ? $t('environment.delete-description')
- : $t('common.cannot-undo-this-action')
- "
+ :positive-button-props="{
+ disabled: existRelatedResource ? !confirmDelete : false,
+ }"
:require-confirm="true"
@confirm="deleteEnvironment"
- />
+ >
+ <div class="mt-3">
+ <NCheckbox
+ v-if="isDev() && existRelatedResource"
+ v-model:checked="confirmDelete"
+ class="mr-2"
+ />
+ <span>
+ {{
+ isDev() && existRelatedResource
+ ? $t("environment.delete-description")
+ : $t("common.cannot-undo-this-action")
+ }}
+ </span>
+ </div>
+ </BBButtonConfirm>
</div>
</div>
</template>
<script lang="tsx" setup>
+import { computedAsync } from "@vueuse/core";
import { NCheckbox, NInput, NColorPicker } from "naive-ui";
import { computed, ref, watch } from "vue";
import { useI18n } from "vue-i18n";
@@ -145,6 +159,8 @@ import { useEmitteryEventListener } from "@/composables/useEmitteryEventListener
import {
useEnvironmentV1List,
useEnvironmentV1Store,
+ useInstanceV1Store,
+ useDatabaseV1Store,
hasFeature,
pushNotification,
} from "@/store";
@@ -175,6 +191,7 @@ withDefaults(
}
);
+const confirmDelete = ref<boolean>(false);
const { t } = useI18n();
const {
create,
@@ -189,6 +206,8 @@ const {
} = useEnvironmentFormContext();
const environmentList = useEnvironmentV1List();
const environmentStore = useEnvironmentV1Store();
+const instanceStore = useInstanceV1Store();
+const databaseStore = useDatabaseV1Store();
const accessControlConfigureRef =
ref<InstanceType<typeof AccessControlConfigure>>();
@@ -217,6 +236,50 @@ const allowArchive = computed(() => {
return hasPermission("bb.settings.set") && environmentList.value.length > 1;
});
+const fetchInstances = async () => {
+ try {
+ const resp = await instanceStore.fetchInstanceList({
+ pageSize: 1,
+ filter: {
+ environment: environment.value.name,
+ },
+ });
+ return resp.instances;
+ } catch {
+ return [];
+ }
+};
+
+const fetchDatabases = async () => {
+ try {
+ const resp = await databaseStore.fetchDatabases({
+ pageSize: 1,
+ parent: "workspaces/-",
+ filter: {
+ environment: environment.value.name,
+ },
+ });
+ return resp.databases;
+ } catch {
+ return [];
+ }
+};
+
+const existRelatedResource = computedAsync(async () => {
+ if (create.value) {
+ return false;
+ }
+ if (!allowArchive.value) {
+ return false;
+ }
+
+ const [listInstance, listDatabase] = await Promise.all([
+ fetchInstances(),
+ fetchDatabases(),
+ ]);
+ return listInstance.length !== 0 || listDatabase.length !== 0;
+}, false);
+
const renderColorPicker = () => {
return (
<NColorPicker
diff --git a/frontend/src/components/IssueV1/components/Panel/TaskRolloutActionPanel.vue b/frontend/src/components/IssueV1/components/Panel/TaskRolloutActionPanel.vue
index ded042dd5f..37518ee92e 100644
--- a/frontend/src/components/IssueV1/components/Panel/TaskRolloutActionPanel.vue
+++ b/frontend/src/components/IssueV1/components/Panel/TaskRolloutActionPanel.vue
@@ -27,11 +27,12 @@
<label class="font-medium text-control">
{{ $t("common.stage") }}
</label>
- <span class="break-all">
- {{
- environmentStore.getEnvironmentByName(stage.environment).title
- }}
- </span>
+ <EnvironmentV1Name
+ :environment="
+ environmentStore.getEnvironmentByName(stage.environment)
+ "
+ :link="false"
+ />
</div>
</template>
<div
@@ -213,6 +214,7 @@ import {
} from "@/components/IssueV1/logic";
import PlanCheckRunBar from "@/components/PlanCheckRun/PlanCheckRunBar.vue";
import { planCheckRunSummaryForCheckRunList } from "@/components/PlanCheckRun/common";
+import { EnvironmentV1Name } from "@/components/v2";
import { rolloutServiceClientConnect } from "@/grpcweb";
import {
pushNotification,
diff --git a/frontend/src/components/IssueV1/components/Sidebar/IssueLabels.vue b/frontend/src/components/IssueV1/components/Sidebar/IssueLabels.vue
index 10ee57a5fb..41d3343c60 100644
--- a/frontend/src/components/IssueV1/components/Sidebar/IssueLabels.vue
+++ b/frontend/src/components/IssueV1/components/Sidebar/IssueLabels.vue
@@ -2,6 +2,7 @@
<div class="flex flex-col gap-y-1">
<div class="flex items-center gap-x-1 textlabel">
<span>{{ $t("common.labels") }}</span>
+ <RequiredStar v-if="project.forceIssueLabels" />
</div>
<IssueLabelSelector
:disabled="disabled"
@@ -15,6 +16,7 @@
<script setup lang="ts">
import IssueLabelSelector from "@/components/IssueV1/components/IssueLabelSelector.vue";
+import RequiredStar from "@/components/RequiredStar.vue";
import type { ComposedProject } from "@/types";
withDefaults(
diff --git a/frontend/src/components/IssueV1/components/StageSection/StageCard.vue b/frontend/src/components/IssueV1/components/StageSection/StageCard.vue
index e382befe08..2728f175d1 100644
--- a/frontend/src/components/IssueV1/components/StageSection/StageCard.vue
+++ b/frontend/src/components/IssueV1/components/StageSection/StageCard.vue
@@ -7,13 +7,23 @@
<div class="text" @click="handleClickStage">
<div
- class="text-sm min-w-32 lg:min-w-fit with-underline whitespace-nowrap"
+ class="text-sm min-w-32 flex items-center space-x-1 lg:min-w-fit with-underline whitespace-nowrap"
>
<heroicons:arrow-small-right
v-if="isActiveStage"
- class="w-5 h-5 inline-block mb-0.5 mr-1"
+ class="w-5 h-5 inline-block"
/>
- <span>{{ $t("common.stage") }}</span> - <span>{{ stageTitle }}</span>
+ <span>{{ $t("common.stage") }}</span>
+ <span>-</span>
+ <i18n-t
+ v-if="!isCreating && isActiveStage"
+ keypath="issue.stage-select.current"
+ >
+ <template #name>
+ <EnvironmentV1Name :environment="environment" :link="false" />
+ </template>
+ </i18n-t>
+ <span v-else>{{ environment.title }}</span>
</div>
<div class="text-xs flex gap-1 flex-row items-center">
<div class="whitespace-no-wrap with-underline">
@@ -63,13 +73,13 @@
import { first, uniqBy } from "lodash-es";
import { NTooltip } from "naive-ui";
import { computed } from "vue";
-import { useI18n } from "vue-i18n";
import {
isTaskFinished,
isValidStage,
useIssueContext,
} from "@/components/IssueV1/logic";
import { planCheckRunSummaryForCheckRunList } from "@/components/PlanCheckRun/common";
+import { EnvironmentV1Name } from "@/components/v2";
import { useEnvironmentV1Store } from "@/store";
import { EMPTY_TASK_NAME } from "@/types";
import { PlanCheckRun_Result_Status } from "@/types/proto-es/v1/plan_service_pb";
@@ -83,7 +93,6 @@ const props = defineProps<{
stage: Stage;
}>();
-const { t } = useI18n();
const {
isCreating,
selectedTask,
@@ -137,15 +146,9 @@ const stageClass = computed(() => {
return classList;
});
-const stageTitle = computed(() => {
- const { stage } = props;
- const environment = environmentStore.getEnvironmentByName(stage.environment);
- return !isCreating.value && isActiveStage.value
- ? t("issue.stage-select.current", {
- name: environment.title,
- })
- : environment.title;
-});
+const environment = computed(() =>
+ environmentStore.getEnvironmentByName(props.stage.environment)
+);
const planCheckStatus = computed((): PlanCheckRun_Result_Status => {
if (isCreating.value) return PlanCheckRun_Result_Status.STATUS_UNSPECIFIED;
diff --git a/frontend/src/components/MarkdownEditor/MarkdownEditor.vue b/frontend/src/components/MarkdownEditor/MarkdownEditor.vue
index 7444c716bd..18935ac46b 100644
--- a/frontend/src/components/MarkdownEditor/MarkdownEditor.vue
+++ b/frontend/src/components/MarkdownEditor/MarkdownEditor.vue
@@ -48,7 +48,7 @@
ref="contentTextArea"
v-model="state.content"
rows="3"
- class="textarea block w-full resize-none whitespace-pre-wrap bg-gray-100 rounded"
+ class="textarea block w-full resize-none whitespace-pre-wrap rounded"
:placeholder="$t('issue.leave-a-comment')"
@mousedown="clearIssuePanel"
@input="(e: any) => sizeToFit(e.target)"
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/panels/IssueCreationActionPanel.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/panels/IssueCreationActionPanel.vue
index 017a485b28..42805b3706 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/panels/IssueCreationActionPanel.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/panels/IssueCreationActionPanel.vue
@@ -33,7 +33,7 @@
<div class="flex flex-col gap-y-1">
<div class="text-control">
{{ $t("common.labels") }}
- <span v-if="project.forceIssueLabels" class="text-red-600">*</span>
+ <RequiredStar v-if="project.forceIssueLabels" />
</div>
<IssueLabelSelector
:disabled="false"
@@ -91,6 +91,7 @@ import CommonDrawer from "@/components/IssueV1/components/Panel/CommonDrawer.vue
import PlanCheckStatusCount from "@/components/Plan/components/PlanCheckStatusCount.vue";
import { ErrorList } from "@/components/Plan/components/common";
import { usePlanContext, usePlanCheckStatus } from "@/components/Plan/logic";
+import RequiredStar from "@/components/RequiredStar.vue";
import {
issueServiceClientConnect,
planServiceClientConnect,
diff --git a/frontend/src/components/Plan/components/IssueReviewView/OverviewSection.vue b/frontend/src/components/Plan/components/IssueReviewView/OverviewSection.vue
index 151e7d53cc..5598450bf3 100644
--- a/frontend/src/components/Plan/components/IssueReviewView/OverviewSection.vue
+++ b/frontend/src/components/Plan/components/IssueReviewView/OverviewSection.vue
@@ -37,9 +37,10 @@
size="small"
disabled
/>
- <span class="font-medium text-gray-700 whitespace-nowrap">
- {{ getEnvironmentTitle(stage.environment) }}
- </span>
+ <EnvironmentV1Name
+ :environment="getEnvironmentEntity(stage.environment)"
+ :link="false"
+ />
</div>
<span
v-if="index < rollout.stages.length - 1"
@@ -68,6 +69,7 @@
import { ref } from "vue";
import { useRouter } from "vue-router";
import TaskStatus from "@/components/Rollout/kits/TaskStatus.vue";
+import { EnvironmentV1Name } from "@/components/v2";
import { PROJECT_V1_ROUTE_ROLLOUT_DETAIL_STAGE_DETAIL } from "@/router/dashboard/projectV1";
import { useCurrentProjectV1, useEnvironmentV1Store } from "@/store";
import { PlanCheckRun_Result_Status } from "@/types/proto-es/v1/plan_service_pb";
@@ -86,9 +88,8 @@ const selectedResultStatus = ref<PlanCheckRun_Result_Status | undefined>(
undefined
);
-const getEnvironmentTitle = (environmentName: string) => {
- const environment = environmentStore.getEnvironmentByName(environmentName);
- return environment.title || environmentName;
+const getEnvironmentEntity = (environmentName: string) => {
+ return environmentStore.getEnvironmentByName(environmentName);
};
const navigateToStage = (stageName: string) => {
diff --git a/frontend/src/components/Plan/components/RolloutView/StageCard.vue b/frontend/src/components/Plan/components/RolloutView/StageCard.vue
index b14c1c015e..c35189d5af 100644
--- a/frontend/src/components/Plan/components/RolloutView/StageCard.vue
+++ b/frontend/src/components/Plan/components/RolloutView/StageCard.vue
@@ -14,16 +14,18 @@
>
<div class="flex items-start justify-between gap-4">
<!-- Left side: Stage title and status counts -->
- <div class="flex items-start gap-2">
+ <div class="flex-1 flex items-start gap-2">
<div class="flex items-start gap-2">
<TaskStatus :status="stageStatus" size="medium" />
<div class="flex flex-col gap-1">
<h3
- class="text-base font-medium text-gray-900 whitespace-nowrap w-24 truncate"
+ class="text-base font-medium text-gray-900 whitespace-nowrap truncate"
>
- {{
- environmentStore.getEnvironmentByName(stage.environment).title
- }}
+ <EnvironmentV1Name
+ :environment="
+ environmentStore.getEnvironmentByName(stage.environment)
+ "
+ />
</h3>
<Timestamp
v-if="latestUpdateTimestamp"
@@ -197,6 +199,7 @@ import DatabaseDisplay from "@/components/Plan/components/common/DatabaseDisplay
import { TASK_STATUS_FILTERS } from "@/components/Plan/constants/task";
import TaskStatus from "@/components/Rollout/kits/TaskStatus.vue";
import Timestamp from "@/components/misc/Timestamp.vue";
+import { EnvironmentV1Name } from "@/components/v2";
import {
PROJECT_V1_ROUTE_ROLLOUT_DETAIL_STAGE_DETAIL,
PROJECT_V1_ROUTE_ROLLOUT_DETAIL_TASK_DETAIL,
diff --git a/frontend/src/components/Plan/components/RolloutView/TaskRolloutActionPanel.vue b/frontend/src/components/Plan/components/RolloutView/TaskRolloutActionPanel.vue
index 3181d4c311..77d30d5680 100644
--- a/frontend/src/components/Plan/components/RolloutView/TaskRolloutActionPanel.vue
+++ b/frontend/src/components/Plan/components/RolloutView/TaskRolloutActionPanel.vue
@@ -52,12 +52,12 @@
<label class="font-medium text-control">
{{ $t("common.stage") }}
</label>
- <span class="break-all">
- {{
+ <EnvironmentV1Name
+ :environment="
environmentStore.getEnvironmentByName(targetStage.environment)
- .title
- }}
- </span>
+ "
+ :link="false"
+ />
</div>
<div
@@ -264,6 +264,7 @@ import { useI18n } from "vue-i18n";
import { semanticTaskType } from "@/components/IssueV1";
import CommonDrawer from "@/components/IssueV1/components/Panel/CommonDrawer.vue";
import { ErrorList } from "@/components/IssueV1/components/common";
+import { EnvironmentV1Name } from "@/components/v2";
import { rolloutServiceClientConnect } from "@/grpcweb";
import {
pushNotification,
diff --git a/frontend/src/components/Plan/components/common/DatabaseDisplay.vue b/frontend/src/components/Plan/components/common/DatabaseDisplay.vue
index ba1ce32187..98d186bd7a 100644
--- a/frontend/src/components/Plan/components/common/DatabaseDisplay.vue
+++ b/frontend/src/components/Plan/components/common/DatabaseDisplay.vue
@@ -87,7 +87,8 @@ const databaseDisplayName = computed(() => {
const environment = computed(() => {
const environmentName =
- databaseEntity.value.environment || instanceResource.value?.environment;
+ databaseEntity.value.effectiveEnvironment ||
+ instanceResource.value?.environment;
if (!environmentName) {
return undefined;
}
diff --git a/frontend/src/components/Rollout/RolloutDataTable.vue b/frontend/src/components/Rollout/RolloutDataTable.vue
index 4a60106d7f..e6339a3a21 100644
--- a/frontend/src/components/Rollout/RolloutDataTable.vue
+++ b/frontend/src/components/Rollout/RolloutDataTable.vue
@@ -20,6 +20,7 @@ import { useRouter } from "vue-router";
import { TASK_STATUS_FILTERS } from "@/components/Plan/constants/task";
import TaskStatus from "@/components/Rollout/kits/TaskStatus.vue";
import Timestamp from "@/components/misc/Timestamp.vue";
+import { EnvironmentV1Name } from "@/components/v2";
import { useEnvironmentV1Store } from "@/store";
import { type ComposedRollout } from "@/types";
import type { Task_Status } from "@/types/proto-es/v1/rollout_service_pb";
@@ -113,9 +114,10 @@ const columnList = computed(
size="small"
disabled
/>
- <span class="text-sm font-medium text-gray-700 whitespace-nowrap">
- {environment.title}
- </span>
+ <EnvironmentV1Name
+ environment={environment}
+ link={false}
+ />
</div>
),
default: () => {
diff --git a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue
index db48b4e4af..599056d052 100644
--- a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue
+++ b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue
@@ -237,18 +237,19 @@ const databaseSupportAlterSchema = computed(() => {
});
});
+const existDatabaseWithoutEnvironment = computed(() =>
+ props.databases.some((db) => !db.effectiveEnvironment)
+);
+
const allowEditSchema = computed(() => {
return props.databases.every((db) => {
- return (
- hasPermissionToCreateChangeDatabaseIssue(db) && !!db.effectiveEnvironment
- );
+ return hasPermissionToCreateChangeDatabaseIssue(db);
});
});
const allowChangeData = computed(() => {
- return props.databases.every(
- (db) =>
- hasPermissionToCreateChangeDatabaseIssue(db) && !!db.effectiveEnvironment
+ return props.databases.every((db) =>
+ hasPermissionToCreateChangeDatabaseIssue(db)
);
});
@@ -265,9 +266,7 @@ const allowTransferInProject = computedAsync(async () => {
const allowExportData = computed(() => {
return props.databases.every((db) => {
- return (
- hasPermissionToCreateDataExportIssue(db) && !!db.effectiveEnvironment
- );
+ return hasPermissionToCreateDataExportIssue(db);
});
});
@@ -448,6 +447,7 @@ const actions = computed((): DatabaseAction[] => {
text: t("custom-approval.risk-rule.risk.namespace.data_export"),
disabled:
!allowExportData.value ||
+ existDatabaseWithoutEnvironment.value ||
!selectedProjectName.value ||
props.databases.length < 1 ||
selectedProjectNames.value.has(DEFAULT_PROJECT_NAME),
@@ -458,6 +458,9 @@ const actions = computed((): DatabaseAction[] => {
action,
});
}
+ if (existDatabaseWithoutEnvironment.value) {
+ return t("database.batch-action-database-not-have-environment");
+ }
return "";
},
});
@@ -563,6 +566,7 @@ const actions = computed((): DatabaseAction[] => {
text: t("database.change-data"),
disabled:
!allowChangeData.value ||
+ existDatabaseWithoutEnvironment.value ||
!selectedProjectName.value ||
props.databases.length < 1 ||
selectedProjectNames.value.has(DEFAULT_PROJECT_NAME),
@@ -573,6 +577,9 @@ const actions = computed((): DatabaseAction[] => {
action,
});
}
+ if (existDatabaseWithoutEnvironment.value) {
+ return t("database.batch-action-database-not-have-environment");
+ }
return getDisabledTooltip(action);
},
});
@@ -584,6 +591,7 @@ const actions = computed((): DatabaseAction[] => {
disabled:
!databaseSupportAlterSchema.value ||
!allowEditSchema.value ||
+ existDatabaseWithoutEnvironment.value ||
!selectedProjectName.value ||
props.databases.length < 1 ||
selectedProjectNames.value.has(DEFAULT_PROJECT_NAME),
@@ -597,6 +605,9 @@ const actions = computed((): DatabaseAction[] => {
action,
});
}
+ if (existDatabaseWithoutEnvironment.value) {
+ return t("database.batch-action-database-not-have-environment");
+ }
return getDisabledTooltip(action);
},
});
diff --git a/frontend/src/components/v2/Model/EnvironmentV1Name.vue b/frontend/src/components/v2/Model/EnvironmentV1Name.vue
index 9455ab5020..1df602e50b 100644
--- a/frontend/src/components/v2/Model/EnvironmentV1Name.vue
+++ b/frontend/src/components/v2/Model/EnvironmentV1Name.vue
@@ -5,20 +5,22 @@
class="inline-flex items-center gap-x-1"
:class="[isLink && !plain && 'normal-link', isLink && 'hover:underline']"
>
- <span class="line-clamp-1 select-none" :class="textClass">
- {{ prefix }}
- <span v-if="isUnknown" class="text-gray-400 italic">
- NULL ENVIRONMENT
+ <NEllipsis :line-clamp="1">
+ <span class="select-none" :class="textClass">
+ {{ prefix }}
+ <span v-if="isUnknown" class="text-gray-400 italic">
+ NULL ENVIRONMENT
+ </span>
+ <HighlightLabelText
+ v-else
+ :text="environment.title"
+ :keyword="keyword"
+ />
+ <slot name="suffix">
+ {{ suffix }}
+ </slot>
</span>
- <HighlightLabelText
- v-else
- :text="environmentV1Name(environment)"
- :keyword="keyword"
- />
- <slot name="suffix">
- {{ suffix }}
- </slot>
- </span>
+ </NEllipsis>
<ProductionEnvironmentV1Icon
v-if="showIcon"
:environment="environment"
@@ -29,12 +31,13 @@
</template>
<script lang="ts" setup>
+import { NEllipsis } from "naive-ui";
import { computed } from "vue";
import { useRouter } from "vue-router";
import { UNKNOWN_ENVIRONMENT_NAME } from "@/types";
import type { Environment } from "@/types/v1/environment";
import type { VueClass } from "@/utils";
-import { autoEnvironmentRoute, environmentV1Name } from "@/utils";
+import { autoEnvironmentRoute } from "@/utils";
import HighlightLabelText from "./HighlightLabelText.vue";
import ProductionEnvironmentV1Icon from "./ProductionEnvironmentV1Icon.vue";
diff --git a/frontend/src/grpcweb/methods.ts b/frontend/src/grpcweb/methods.ts
index a8792b3cca..ccd08a3a96 100644
--- a/frontend/src/grpcweb/methods.ts
+++ b/frontend/src/grpcweb/methods.ts
@@ -63,15 +63,13 @@ export const ALL_METHODS_WITH_AUDIT = [
WorksheetService,
WorkspaceService,
]
- .map((service) => {
- const methods: string[] = [];
+ .reduce((list, service) => {
for (const method of service.methods) {
const auditOption = getOption(method, audit);
if (auditOption) {
- methods.push(`/${service.typeName}/${method.name}`);
+ list.push(`/${service.typeName}/${method.name}`);
}
}
- return methods;
- })
- .flat()
+ return list;
+ }, [] as string[])
.sort();
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index a07f62f2b8..c26c7c38ab 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1570,6 +1570,7 @@
"table-detail": "Table detail",
"batch-action-not-support-alter-schema": "Some databases don't support altering schema",
"batch-action-permission-denied": "Don't have permission to {action} for databases",
+ "batch-action-database-not-have-environment": "Exist databases which not bound with the environment",
"batch-action-disabled": "Can not {action} for the databases from different projects",
"batch-action-disabled-for-unassigned": "Can not {action} for unassigned database",
"successfully-transferred-databases": "Successfully transferred databases",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 7342556663..d00491e7b9 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -1570,6 +1570,7 @@
"table-detail": "Detalle de la tabla",
"batch-action-not-support-alter-schema": "Algunas bases de datos no admiten la modificación del esquema",
"batch-action-permission-denied": "No tengo permiso para {action} para bases de datos",
+ "batch-action-database-not-have-environment": "Existen bases de datos que no están vinculadas con el entorno",
"batch-action-disabled": "No se puede {action} para las bases de datos de diferentes proyectos",
"batch-action-disabled-for-unassigned": "No se puede {action} para una base de datos no asignada",
"successfully-transferred-databases": "Bases de datos transferidas exitosamente",
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 7f32a056da..174a03b164 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -1570,6 +1570,7 @@
"table-detail": "テーブルの詳細",
"batch-action-not-support-alter-schema": "一部のデータベースはテーブル構造の変更をサポートしていません",
"batch-action-permission-denied": "データベース {action} に対する権限がありません",
+ "batch-action-database-not-have-environment": "環境に縛られないデータベースが存在する",
"batch-action-disabled": "異なるプロジェクトのデータベース {action} を比較できません",
"batch-action-disabled-for-unassigned": "未割り当てのデータベース {action} にアクセスできません",
"successfully-transferred-databases": "データベースの移行が完了しました",
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index b85e08bf8c..6a6f9f8211 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -1570,6 +1570,7 @@
"table-detail": "Chi tiết bảng",
"batch-action-not-support-alter-schema": "Một số cơ sở dữ liệu không hỗ trợ thay đổi lược đồ",
"batch-action-permission-denied": "Không có quyền {action} đối với cơ sở dữ liệu",
+ "batch-action-database-not-have-environment": "Tồn tại các cơ sở dữ liệu không liên kết với môi trường",
"batch-action-disabled": "Không thể {action} đối với các cơ sở dữ liệu từ các dự án khác nhau",
"batch-action-disabled-for-unassigned": "Không thể {action} đối với cơ sở dữ liệu chưa được gán",
"successfully-transferred-databases": "Đã chuyển thành công cơ sở dữ liệu",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 4fbf4461e5..8c1be8a685 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -410,7 +410,7 @@
"form": {
"email": "邮箱",
"email-tips": "邮箱应该是唯一的,并且创建后不能更改。",
- "title": "标题",
+ "title": "名称",
"description": "描述",
"members": "成员",
"role": {
@@ -1570,6 +1570,7 @@
"table-detail": "表详情",
"batch-action-not-support-alter-schema": "一些数据库不支持修改表结构",
"batch-action-permission-denied": "没有权限对数据库{action}",
+ "batch-action-database-not-have-environment": "存在未与环境绑定的数据库",
"batch-action-disabled": "无法对来自不同项目的数据库{action}",
"batch-action-disabled-for-unassigned": "无法对未分配的数据库{action}",
"successfully-transferred-databases": "数据库转移完成",
diff --git a/frontend/src/store/modules/v1/database.ts b/frontend/src/store/modules/v1/database.ts
index 06d514331b..72d13960a4 100644
--- a/frontend/src/store/modules/v1/database.ts
+++ b/frontend/src/store/modules/v1/database.ts
@@ -10,6 +10,7 @@ import {
isValidProjectName,
isValidInstanceName,
isValidDatabaseName,
+ isValidEnvironmentName,
unknownDatabase,
unknownInstanceResource,
} from "@/types";
@@ -78,7 +79,9 @@ const getListDatabaseFilter = (filter: DatabaseFilter): string => {
params.push(`instance == "${filter.instance}"`);
}
if (filter.environment !== undefined) {
- params.push(`environment == "${filter.environment}"`);
+ params.push(
+ `environment == "${isValidEnvironmentName(filter.environment) ? filter.environment : ""}"`
+ );
}
if (filter.excludeUnassigned) {
params.push(`exclude_unassigned == true`);
diff --git a/frontend/src/store/modules/v1/instance.ts b/frontend/src/store/modules/v1/instance.ts
index eb6160862c..e0e5f82fbe 100644
--- a/frontend/src/store/modules/v1/instance.ts
+++ b/frontend/src/store/modules/v1/instance.ts
@@ -11,6 +11,7 @@ import {
unknownInstance,
isValidProjectName,
isValidInstanceName,
+ isValidEnvironmentName,
} from "@/types";
import { Engine } from "@/types/proto-es/v1/common_pb";
import { State } from "@/types/proto-es/v1/common_pb";
@@ -60,7 +61,9 @@ const getListInstanceFilter = (params: InstanceFilter) => {
list.push(`project == "${params.project}"`);
}
if (params.environment !== undefined) {
- list.push(`environment == "${params.environment}"`);
+ list.push(
+ `environment == "${isValidEnvironmentName(params.environment) ? params.environment : ""}"`
+ );
}
if (params.host) {
list.push(`host.matches("${params.host}")`);
diff --git a/frontend/src/utils/v1/environment.ts b/frontend/src/utils/v1/environment.ts
index 1e2992fbba..b36debdbbc 100644
--- a/frontend/src/utils/v1/environment.ts
+++ b/frontend/src/utils/v1/environment.ts
@@ -1,12 +1,5 @@
-import type { Environment } from "@/types/v1/environment";
-
export const extractEnvironmentResourceName = (name: string) => {
const pattern = /(?:^|\/)environments\/([^/]+)(?:$|\/)/;
const matches = name.match(pattern);
return matches?.[1] ?? "";
};
-
-export function environmentV1Name(environment: Environment) {
- const parts = [environment.title];
- return parts.join(" ");
-}
diff --git a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/tree.ts b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/tree.ts
index 5ded5f9a21..5e9e16a24d 100644
--- a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/tree.ts
+++ b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/tree.ts
@@ -18,7 +18,7 @@ import type {
SQLEditorTreeNode as TreeNode,
StatefulSQLEditorTreeFactor as StatefulFactor,
} from "@/types";
-import { DEBOUNCE_SEARCH_DELAY, UNKNOWN_ENVIRONMENT_NAME } from "@/types";
+import { DEBOUNCE_SEARCH_DELAY } from "@/types";
import {
isDatabaseV1Queryable,
getDefaultPagination,
@@ -93,8 +93,7 @@ export const useSQLEditorTreeByEnvironment = (
pageSize: getDefaultPagination(),
filter: {
...filter,
- environment:
- environment === UNKNOWN_ENVIRONMENT_NAME ? "" : environment,
+ environment,
},
});