Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
refactor(frontend): ship to environment v1 API (#6089)
Liu Jib708af0d8c99
diff --git a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vueindex 2516c6f3d3..8127c53035 100644--- a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue+++ b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue@@ -226,13 +226,13 @@ import {allowUsingSchemaEditor,instanceHasAlterSchema,filterDatabaseByKeyword,- sortDatabaseList,+ sortDatabaseListByEnvironmentV1,} from "@/utils";import {hasFeature,useCurrentUser,useDatabaseStore,- useEnvironmentList,+ useEnvironmentV1List,useProjectStore,} from "@/store";import ProjectStandardView, {@@ -317,7 +317,7 @@ if (isTenantProject.value) {state.alterType = "TENANT";}-const environmentList = useEnvironmentList(["NORMAL"]);+const environmentList = useEnvironmentV1List(false /* !showDeleted */);const databaseList = computed(() => {const databaseStore = useDatabaseStore();@@ -340,7 +340,10 @@ const databaseList = computed(() => {]));- return sortDatabaseList(cloneDeep(list), environmentList.value);+ return sortDatabaseListByEnvironmentV1(+ cloneDeep(list),+ environmentList.value+ );});const schemaDatabaseList = computed(() => {diff --git a/frontend/src/components/AlterSchemaPrepForm/CommonTenantView.vue b/frontend/src/components/AlterSchemaPrepForm/CommonTenantView.vueindex 6838b6ec1a..b22b0d21de 100644--- a/frontend/src/components/AlterSchemaPrepForm/CommonTenantView.vue+++ b/frontend/src/components/AlterSchemaPrepForm/CommonTenantView.vue@@ -29,12 +29,13 @@<script lang="ts" setup>import { computed } from "vue";-import { Database, Environment, Project, ProjectId } from "../../types";+import { Database, Project, ProjectId } from "../../types";import ProjectSelect, { Mode as ProjectMode } from "../ProjectSelect.vue";import ProjectTenantView, {State as ProjectTenantState,} from "./ProjectTenantView.vue";import { useProjectStore } from "@/store";+import { Environment } from "@/types/proto/v1/environment_service";export type State = ProjectTenantState & {tenantProjectId: ProjectId | undefined;diff --git a/frontend/src/components/AlterSchemaPrepForm/ProjectStandardView.vue b/frontend/src/components/AlterSchemaPrepForm/ProjectStandardView.vueindex 60554c9f93..a1057ad1dd 100644--- a/frontend/src/components/AlterSchemaPrepForm/ProjectStandardView.vue+++ b/frontend/src/components/AlterSchemaPrepForm/ProjectStandardView.vue@@ -15,7 +15,7 @@<NCollapsearrow-placement="left":default-expanded-names="- databaseListGroupByEnvironment.map((group) => group.environment.id)+ databaseListGroupByEnvironment.map((group) => group.environment.uid)"><NCollapseItem@@ -23,8 +23,8 @@environment,databaseList: databaseListInEnvironment,} in databaseListGroupByEnvironment"- :key="environment.id"- :name="environment.id"+ :key="environment.uid"+ :name="environment.uid"><template #header><label class="flex items-center gap-x-2" @click.stop="">@@ -46,11 +46,7 @@)"/>- <div>{{ environment.name }}</div>- <ProductionEnvironmentIcon- class="w-4 h-4 -ml-1"- :environment="environment"- />+ <EnvironmentV1Name :environment="environment" :link="false" /></label></template>@@ -88,10 +84,10 @@:checked="isDatabaseSelectedForEnvironment(database.id,- environment.id+ environment.uid)"- @input="(e: any) => toggleDatabaseIdForEnvironment(database.id, environment.id, e.target.checked)"+ @input="(e: any) => toggleDatabaseIdForEnvironment(database.id, environment.uid, e.target.checked)"/><spanclass="font-medium ml-2 text-main"@@ -126,156 +122,134 @@</template></template>-<script lang="ts">+<script lang="ts" setup>/* eslint-disable vue/no-mutating-props */-import { defineComponent, PropType, computed } from "vue";+import { PropType, computed } from "vue";import { NCollapse, NCollapseItem } from "naive-ui";-import {- Database,- DatabaseId,- Environment,- EnvironmentId,- Project,-} from "../../types";+import { Database, DatabaseId, Project } from "../../types";+import { Environment } from "@/types/proto/v1/environment_service";+import { EnvironmentV1Name } from "@/components/v2";export type AlterType = "SINGLE_DB" | "MULTI_DB" | "TENANT";export type State = {alterType: AlterType;- selectedDatabaseIdListForEnvironment: Map<EnvironmentId, DatabaseId[]>;+ selectedDatabaseIdListForEnvironment: Map<string, DatabaseId[]>;};-export default defineComponent({- name: "ProjectStandardView",- components: {- NCollapse,- NCollapseItem,+const props = defineProps({+ state: {+ type: Object as PropType<State>,+ required: true,},- props: {- state: {- type: Object as PropType<State>,- required: true,- },- project: {- type: Object as PropType<Project>,- default: undefined,- },- databaseList: {- type: Array as PropType<Database[]>,- required: true,- },- environmentList: {- type: Array as PropType<Environment[]>,- required: true,- },+ project: {+ type: Object as PropType<Project>,+ default: undefined,},- emits: ["select-database"],- setup(props, { emit }) {- const databaseListGroupByEnvironment = computed(() => {- const listByEnv = props.environmentList.map((environment) => {- const databaseList = props.databaseList.filter(- (db) => db.instance.environment.id === environment.id- );- return {- environment,- databaseList,- };- });-- return listByEnv.filter((group) => group.databaseList.length > 0);- });-- const toggleDatabaseIdForEnvironment = (- databaseId: DatabaseId,- environmentId: EnvironmentId,- selected: boolean- ) => {- const map = props.state.selectedDatabaseIdListForEnvironment;- const list = map.get(environmentId) || [];- const index = list.indexOf(databaseId);- if (selected) {- // push the databaseId in if needed- if (index < 0) {- list.push(databaseId);- }- } else {- // remove the databaseId if exists- if (index >= 0) {- list.splice(index, 1);- }- }- // Set or remove the list to the map- if (list.length > 0) {- map.set(environmentId, list);- } else {- map.delete(environmentId);- }- };-- const isDatabaseSelectedForEnvironment = (- databaseId: DatabaseId,- environmentId: EnvironmentId- ) => {- const map = props.state.selectedDatabaseIdListForEnvironment;- const list = map.get(environmentId) || [];- return list.includes(databaseId);+ databaseList: {+ type: Array as PropType<Database[]>,+ required: true,+ },+ environmentList: {+ type: Array as PropType<Environment[]>,+ required: true,+ },+});+const emit = defineEmits<{+ (event: "select-database", db: Database): void;+}>();++const databaseListGroupByEnvironment = computed(() => {+ const listByEnv = props.environmentList.map((environment) => {+ const databaseList = props.databaseList.filter(+ (db) => String(db.instance.environment.id) === environment.uid+ );+ return {+ environment,+ databaseList,};+ });- const getAllSelectionStateForEnvironment = (- environment: Environment,- databaseList: Database[]- ): { checked: boolean; indeterminate: boolean } => {- const set = new Set(- props.state.selectedDatabaseIdListForEnvironment.get(environment.id) ??- []- );- const checked = databaseList.every((db) => set.has(db.id));- const indeterminate =- !checked && databaseList.some((db) => set.has(db.id));+ return listByEnv.filter((group) => group.databaseList.length > 0);+});- return {- checked,- indeterminate,- };- };+const toggleDatabaseIdForEnvironment = (+ databaseId: DatabaseId,+ environmentId: string,+ selected: boolean+) => {+ const map = props.state.selectedDatabaseIdListForEnvironment;+ const list = map.get(environmentId) || [];+ const index = list.indexOf(databaseId);+ if (selected) {+ // push the databaseId in if needed+ if (index < 0) {+ list.push(databaseId);+ }+ } else {+ // remove the databaseId if exists+ if (index >= 0) {+ list.splice(index, 1);+ }+ }+ // Set or remove the list to the map+ if (list.length > 0) {+ map.set(environmentId, list);+ } else {+ map.delete(environmentId);+ }+};- const toggleAllDatabasesSelectionForEnvironment = (- environment: Environment,- databaseList: Database[],- on: boolean- ) => {- databaseList.forEach((db) =>- toggleDatabaseIdForEnvironment(db.id, environment.id, on)- );- };+const isDatabaseSelectedForEnvironment = (+ databaseId: DatabaseId,+ environmentId: string+) => {+ const map = props.state.selectedDatabaseIdListForEnvironment;+ const list = map.get(environmentId) || [];+ return list.includes(databaseId);+};- const selectDatabase = (db: Database) => {- emit("select-database", db);- };+const getAllSelectionStateForEnvironment = (+ environment: Environment,+ databaseList: Database[]+): { checked: boolean; indeterminate: boolean } => {+ const set = new Set(+ props.state.selectedDatabaseIdListForEnvironment.get(environment.uid) ?? []+ );+ const checked = databaseList.every((db) => set.has(db.id));+ const indeterminate = !checked && databaseList.some((db) => set.has(db.id));++ return {+ checked,+ indeterminate,+ };+};- const getSelectionStateSummaryForEnvironment = (- environment: Environment,- databaseList: Database[]- ) => {- const set = new Set(- props.state.selectedDatabaseIdListForEnvironment.get(environment.id)- );- const selected = databaseList.filter((db) => set.has(db.id)).length;- const total = databaseList.length;+const toggleAllDatabasesSelectionForEnvironment = (+ environment: Environment,+ databaseList: Database[],+ on: boolean+) => {+ databaseList.forEach((db) =>+ toggleDatabaseIdForEnvironment(db.id, environment.uid, on)+ );+};- return { selected, total };- };+const selectDatabase = (db: Database) => {+ emit("select-database", db);+};- return {- databaseListGroupByEnvironment,- toggleDatabaseIdForEnvironment,- isDatabaseSelectedForEnvironment,- getAllSelectionStateForEnvironment,- toggleAllDatabasesSelectionForEnvironment,- selectDatabase,- getSelectionStateSummaryForEnvironment,- };- },-});+const getSelectionStateSummaryForEnvironment = (+ environment: Environment,+ databaseList: Database[]+) => {+ const set = new Set(+ props.state.selectedDatabaseIdListForEnvironment.get(environment.uid)+ );+ const selected = databaseList.filter((db) => set.has(db.id)).length;+ const total = databaseList.length;++ return { selected, total };+};</script>diff --git a/frontend/src/components/AlterSchemaPrepForm/ProjectTenantView.vue b/frontend/src/components/AlterSchemaPrepForm/ProjectTenantView.vueindex 9bcf88db18..e953cc4b06 100644--- a/frontend/src/components/AlterSchemaPrepForm/ProjectTenantView.vue+++ b/frontend/src/components/AlterSchemaPrepForm/ProjectTenantView.vue@@ -56,17 +56,12 @@import { computed, watchEffect, h } from "vue";import { Translation, useI18n } from "vue-i18n";import { RouterLink } from "vue-router";-import type {- Database,- DatabaseId,- Environment,- LabelKeyType,- Project,-} from "@/types";+import type { Database, DatabaseId, LabelKeyType, Project } from "@/types";import { DeployDatabaseTable } from "../TenantDatabaseTable";import { getPipelineFromDeploymentScheduleV1, projectSlug } from "@/utils";import { useDeploymentConfigV1ByProject } from "@/store";import { useOverrideSubtitle } from "@/bbkit/BBModal.vue";+import { Environment } from "@/types/proto/v1/environment_service";export type State = {selectedDatabaseIdListForTenantMode: Set<DatabaseId>;diff --git a/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/template.ts b/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/template.tsindex 8de451e583..7149899820 100644--- a/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/template.ts+++ b/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/template.ts@@ -2,10 +2,11 @@ import { computed } from "vue";import { first, last } from "lodash-es";import { ConditionGroupExpr, wrapAsGroup } from "@/plugins/cel";-import { useEnvironmentList } from "@/store";+import { useEnvironmentV1List } from "@/store";import { PresetRiskLevel } from "@/types";import { Risk_Source } from "@/types/proto/v1/risk_service";import { t, te } from "@/plugins/i18n";+import { extractEnvironmentResourceName } from "@/utils";/*@@ -34,7 +35,7 @@ export type RuleTemplate = {};export const useRuleTemplates = () => {- const environmentList = useEnvironmentList();+ const environmentList = useEnvironmentV1List();const dev = computed(() => first(environmentList.value));const prod = computed(() => last(environmentList.value));@@ -46,7 +47,10 @@ export const useRuleTemplates = () => {key: "environment-prod-high",expr: wrapAsGroup({operator: "_==_",- args: ["environment_id", prod.value.resourceId],+ args: [+ "environment_id",+ extractEnvironmentResourceName(prod.value.name),+ ],}),level: PresetRiskLevel.HIGH,source: Risk_Source.SOURCE_UNSPECIFIED,@@ -58,7 +62,10 @@ export const useRuleTemplates = () => {key: "environment-dev-low",expr: wrapAsGroup({operator: "_==_",- args: ["environment_id", dev.value.resourceId],+ args: [+ "environment_id",+ extractEnvironmentResourceName(dev.value.name),+ ],}),level: PresetRiskLevel.LOW,source: Risk_Source.SOURCE_UNSPECIFIED,@@ -74,7 +81,10 @@ export const useRuleTemplates = () => {args: [{operator: "_==_",- args: ["environment_id", prod.value.resourceId],+ args: [+ "environment_id",+ extractEnvironmentResourceName(prod.value.name),+ ],},{operator: "_>_",@@ -98,7 +108,10 @@ export const useRuleTemplates = () => {key: "create-database-in-environment-prod-moderate",expr: wrapAsGroup({operator: "_==_",- args: ["environment_id", prod.value.resourceId],+ args: [+ "environment_id",+ extractEnvironmentResourceName(prod.value.name),+ ],}),level: PresetRiskLevel.MODERATE,source: Risk_Source.CREATE_DATABASE,diff --git a/frontend/src/components/DatabasesSelectPanel.vue b/frontend/src/components/DatabasesSelectPanel.vueindex d055d2ef62..8d6118c411 100644--- a/frontend/src/components/DatabasesSelectPanel.vue+++ b/frontend/src/components/DatabasesSelectPanel.vue@@ -21,7 +21,7 @@class="overflow-y-auto"arrow-placement="left":default-expanded-names="- databaseListGroupByEnvironment.map((group) => group.environment.id)+ databaseListGroupByEnvironment.map((group) => group.environment.uid)"><NCollapseItem@@ -29,8 +29,8 @@environment,databaseList: databaseListInEnvironment,} in databaseListGroupByEnvironment"- :key="environment.id"- :name="environment.id"+ :key="environment.uid"+ :name="environment.uid"><template #header><label class="flex items-center gap-x-2" @click.stop="">@@ -52,11 +52,7 @@)"/>- <div>{{ environment.name }}</div>- <ProductionEnvironmentIcon- class="w-4 h-4 -ml-1"- :environment="environment"- />+ <EnvironmentV1Name :environment="environment" :link="false" /></label></template>@@ -135,8 +131,9 @@ import {NDrawerContent,} from "naive-ui";import { computed, reactive, PropType } from "vue";-import { useDatabaseStore, useEnvironmentStore } from "@/store";-import { Database, DatabaseId, Environment, ProjectId } from "@/types";+import { useDatabaseStore, useEnvironmentV1Store } from "@/store";+import { Database, DatabaseId, ProjectId } from "@/types";+import { Environment } from "@/types/proto/v1/environment_service";type LocalState = {searchText: string;@@ -159,7 +156,7 @@ const emit = defineEmits<{(event: "update", databaseIdList: DatabaseId[]): void;}>();-const environmentStore = useEnvironmentStore();+const environmentV1Store = useEnvironmentV1Store();const databaseStore = useDatabaseStore();const state = reactive<LocalState>({searchText: "",@@ -173,9 +170,9 @@ const databaseListGroupByEnvironment = computed(() => {databaseStore.databaseListByProjectId.get(props.projectId)?.filter((db) => db.name.includes(state.searchText)) || [];- const listByEnv = environmentStore.environmentList.map((environment) => {+ const listByEnv = environmentV1Store.environmentList.map((environment) => {const list = databaseList.filter(- (db) => db.instance.environment.id === environment.id+ (db) => String(db.instance.environment.id) === environment.uid);return {environment,@@ -214,7 +211,7 @@ const toggleAllDatabasesSelectionForEnvironment = (on: boolean) => {databaseList- .filter((db) => db.instance.environment.id === environment.id)+ .filter((db) => db.instance.environment.id === environment.uid).forEach((db) => toggleDatabaseSelected(db.id, on));};@@ -224,7 +221,7 @@ const getAllSelectionStateForEnvironment = (): { checked: boolean; indeterminate: boolean } => {const set = new Set(state.selectedDatabaseList- .filter((db) => db.instance.environment.id === environment.id)+ .filter((db) => db.instance.environment.id === environment.uid).map((db) => db.id));const checked = databaseList.every((db) => set.has(db.id));@@ -242,7 +239,7 @@ const getSelectionStateSummaryForEnvironment = () => {const set = new Set(state.selectedDatabaseList- .filter((db) => db.instance.environment.id === environment.id)+ .filter((db) => db.instance.environment.id === environment.uid).map((db) => db.id));const selected = databaseList.filter((db) => set.has(db.id)).length;diff --git a/frontend/src/components/DeploymentConfigTool/DeploymentMatrix.vue b/frontend/src/components/DeploymentConfigTool/DeploymentMatrix.vueindex c2562da297..b855877d48 100644--- a/frontend/src/components/DeploymentConfigTool/DeploymentMatrix.vue+++ b/frontend/src/components/DeploymentConfigTool/DeploymentMatrix.vue@@ -37,10 +37,11 @@<script lang="ts" setup>import { computed, reactive } from "vue";-import { Environment, Database, LabelKeyType } from "@/types";+import { Database, LabelKeyType } from "@/types";import { DeployDatabaseTable } from "../TenantDatabaseTable";import { filterDatabaseByKeyword } from "@/utils";import { DeploymentConfig } from "@/types/proto/v1/project_service";+import { Environment } from "@/types/proto/v1/environment_service";const props = withDefaults(defineProps<{diff --git a/frontend/src/components/EnvironmentForm.vue b/frontend/src/components/EnvironmentForm.vueindex ad703ee710..e6edd2a881 100644--- a/frontend/src/components/EnvironmentForm.vue+++ b/frontend/src/components/EnvironmentForm.vue@@ -319,13 +319,7 @@ import { Status } from "nice-grpc-common";import { useRouter } from "vue-router";import { useI18n } from "vue-i18n";-import type {- EnvironmentCreate,- EnvironmentPatch,- ResourceId,- SQLReviewPolicy,- ValidatedMessage,-} from "../types";+import type { ResourceId, SQLReviewPolicy, ValidatedMessage } from "../types";import { useEnvironmentV1Store } from "@/store/modules/v1/environment";import { environmentNamePrefix } from "@/store/modules/v1/common";import { getErrorCode } from "@/utils/grpcweb";@@ -352,7 +346,7 @@ import {import { State } from "@/types/proto/v1/common";interface LocalState {- environment: Environment | EnvironmentCreate;+ environment: Environment;approvalPolicy: Policy;backupPolicy: Policy;environmentTier: EnvironmentTier;@@ -367,7 +361,7 @@ const props = defineProps({},environment: {required: true,- type: Object as PropType<Environment | EnvironmentCreate>,+ type: Object as PropType<Environment>,},approvalPolicy: {required: true,@@ -379,7 +373,7 @@ const props = defineProps({},environmentTier: {required: true,- type: Object as PropType<EnvironmentTier>,+ type: Number as PropType<EnvironmentTier>,},});@@ -453,7 +447,7 @@ const onSQLReviewPolicyClick = () => {watch(() => props.environment,- (cur: Environment | EnvironmentCreate) => {+ (cur) => {state.environment = cloneDeep(cur);});@@ -594,12 +588,12 @@ const createEnvironment = () => {};const updateEnvironment = () => {- const env = props.environment as Environment;+ const env = props.environment;if (- state.environment.title != env.title ||- state.environmentTier != env.tier+ state.environment.title !== env.title ||+ state.environmentTier !== env.tier) {- const patchedEnvironment: EnvironmentPatch = {+ const patchedEnvironment = {title: state.environment.title,tier: state.environmentTier,};diff --git a/frontend/src/components/EnvironmentSelect.vue b/frontend/src/components/EnvironmentSelect.vueindex 31d849715e..2213bd0e41 100644--- a/frontend/src/components/EnvironmentSelect.vue+++ b/frontend/src/components/EnvironmentSelect.vue@@ -5,21 +5,20 @@:disabled="disabled":placeholder="$t('environment.select')":show-prefix-item="true"- @select-item="(env: Environment) => $emit('select-environment-id', env.id)"+ @select-item="(env: Environment) => $emit('select-environment-id', env.uid)"><template #menuItem="{ item: environment }">- <div class="flex items-center">- {{ environmentName(environment) }}- <ProductionEnvironmentIcon class="ml-1" :environment="environment" />- </div>+ <EnvironmentV1Name :environment="environment" :link="false" /></template></BBSelect></template><script lang="ts">import { computed, defineComponent, onMounted, reactive, watch } from "vue";-import { Environment } from "../types";-import { useEnvironmentList } from "@/store";+import { useEnvironmentV1List } from "@/store";+import { State } from "@/types/proto/v1/common";+import { Environment } from "@/types/proto/v1/environment_service";+import { EnvironmentV1Name } from "@/components/v2";interface LocalState {selectedEnvironment?: Environment;@@ -27,9 +26,10 @@ interface LocalState {export default defineComponent({name: "EnvironmentSelect",+ components: { EnvironmentV1Name },props: {selectedId: {- type: Number,+ type: String,default: undefined,},selectDefault: {@@ -47,17 +47,17 @@ export default defineComponent({selectedEnvironment: undefined,});- const rawEnvironmentList = useEnvironmentList(["NORMAL", "ARCHIVED"]);+ const rawEnvironmentList = useEnvironmentV1List(true /* showDeleted */);const environmentList = computed(() => {const list = [...rawEnvironmentList.value].reverse();return list.filter((env) => {- if (env.rowStatus === "NORMAL") {+ if (env.state === State.ACTIVE) {return true;}// env.rowStatus === "ARCHIVED"- if (env.id === state.selectedEnvironment?.id) {+ if (env.uid === state.selectedEnvironment?.uid) {return true;}return false;@@ -73,14 +73,14 @@ export default defineComponent({if (list.length > 0) {if (!props.selectedId ||- !list.find((item: Environment) => item.id == props.selectedId)+ !list.find((item: Environment) => item.uid === props.selectedId)) {// auto select the first NORMAL environmentconst defaultEnvironment = list.find(- (env) => env.rowStatus === "NORMAL"+ (env) => env.state === State.ACTIVE);state.selectedEnvironment = defaultEnvironment;- emit("select-environment-id", defaultEnvironment?.id);+ emit("select-environment-id", defaultEnvironment?.uid);}}};@@ -93,7 +93,7 @@ export default defineComponent({if (state.selectedEnvironment &&!environmentList.value.find(- (item: Environment) => item.id == state.selectedEnvironment?.id+ (item: Environment) => item.uid == state.selectedEnvironment?.uid)) {state.selectedEnvironment = undefined;@@ -106,7 +106,7 @@ export default defineComponent({(selectedId) => {invalidateSelectionIfNeeded();state.selectedEnvironment = environmentList.value.find(- (env) => env.id === selectedId+ (env) => env.uid === selectedId);},{ immediate: true }diff --git a/frontend/src/components/EnvironmentTabFilter.vue b/frontend/src/components/EnvironmentTabFilter.vuedeleted file mode 100644index b5a7db79fa..0000000000--- a/frontend/src/components/EnvironmentTabFilter.vue+++ /dev/null@@ -1,93 +0,0 @@-<template>- <BBTabFilter- :tab-item-list="tabItemList"- :selected-index="state.selectedIndex"- @select-index="- (index) => {- state.selectedIndex = index;- $emit(- 'select-environment',- index == 0 ? null : environmentList[index - 1]- );- }- "- />-</template>--<script lang="ts">-import { computed, defineComponent, reactive, watch } from "vue";-import { cloneDeep } from "lodash-es";-import { Environment } from "../types";-import { BBTabFilterItem } from "../bbkit/types";-import { useI18n } from "vue-i18n";-import { useEnvironmentList } from "@/store";--interface LocalState {- selectedIndex: number;-}--export default defineComponent({- name: "EnvironmentTabFilter",- components: {},- props: {- selectedId: {- type: Number,- default: undefined,- },- },- emits: ["select-environment"],- setup(props) {- const { t } = useI18n();-- // Usually env is ordered by ascending importance (dev -> test -> staging -> prod),- // thus we reverse the order to put more important ones first.- const rawEnvironmentList = useEnvironmentList();- const environmentList = computed(() =>- cloneDeep(rawEnvironmentList.value).reverse()- );-- const state = reactive<LocalState>({- selectedIndex: props.selectedId- ? environmentList.value.findIndex(- (environment: Environment) => environment.id == props.selectedId- ) + 1- : 0,- });-- watch(- () => props.selectedId,- () => {- state.selectedIndex = props.selectedId- ? environmentList.value.findIndex(- (environment: Environment) => environment.id == props.selectedId- ) + 1- : 0;- }- );-- const tabItemList = computed((): BBTabFilterItem[] => {- const list: BBTabFilterItem[] = [- {- title: t("common.all"),- alert: false,- },- ];- list.push(- ...environmentList.value.map((environment: Environment) => {- return {- title: environment.name,- alert: false,- };- })- );- return list;- });-- return {- state,- environmentList,- tabItemList,- };- },-});-</script>diff --git a/frontend/src/components/ProjectDatabasesPanel.vue b/frontend/src/components/ProjectDatabasesPanel.vueindex 790ff80d7e..ff2eb6015f 100644--- a/frontend/src/components/ProjectDatabasesPanel.vue+++ b/frontend/src/components/ProjectDatabasesPanel.vue@@ -51,19 +51,13 @@ import { reactive, PropType, computed } from "vue";import { NInputGroup } from "naive-ui";import { uniqBy } from "lodash-es";-import {- Database,- EnvironmentId,- Instance,- InstanceId,- UNKNOWN_ID,-} from "../types";+import { Database, Instance, InstanceId, UNKNOWN_ID } from "../types";import { filterDatabaseByKeyword } from "@/utils";import DatabaseTable from "../components/DatabaseTable.vue";import { EnvironmentTabFilter, InstanceSelect, SearchBox } from "./v2";interface LocalState {- environment: EnvironmentId;+ environment: string;instance: InstanceId;keyword: string;}@@ -76,7 +70,7 @@ const props = defineProps({});const state = reactive<LocalState>({- environment: UNKNOWN_ID,+ environment: String(UNKNOWN_ID),instance: UNKNOWN_ID,keyword: "",});@@ -85,8 +79,8 @@ const filteredDatabaseList = computed(() => {return props.databaseList.filter((db) => {return (- state.environment === UNKNOWN_ID ||- db.instance.environment.id === state.environment+ state.environment === String(UNKNOWN_ID) ||+ String(db.instance.environment.id) === state.environment);}).filter((db) => {diff --git a/frontend/src/components/ProjectDeploymentConfigPanel.vue b/frontend/src/components/ProjectDeploymentConfigPanel.vueindex c7c9582f19..63b016d85a 100644--- a/frontend/src/components/ProjectDeploymentConfigPanel.vue+++ b/frontend/src/components/ProjectDeploymentConfigPanel.vue@@ -147,11 +147,14 @@ import { useI18n } from "vue-i18n";import { NPopover, useDialog } from "naive-ui";import { Database } from "../types";import DeploymentConfigTool, { DeploymentMatrix } from "./DeploymentConfigTool";-import { validateDeploymentConfigV1 } from "../utils";+import {+ extractEnvironmentResourceName,+ validateDeploymentConfigV1,+} from "../utils";import {pushNotification,useDeploymentConfigV1Store,- useEnvironmentList,+ useEnvironmentV1List,useProjectV1Store,} from "@/store";import {@@ -208,7 +211,7 @@ const allowUpdateDeploymentConfig = computed((): boolean => {return true;});-const environmentList = useEnvironmentList();+const environmentList = useEnvironmentV1List();const resetStates = async () => {await nextTick(); // Waiting for all watchers done@@ -239,7 +242,8 @@ const addStage = () => {values: [],};if (environmentList.value.length > 0) {- rule.values.push(environmentList.value[0].resourceId);+ const name = extractEnvironmentResourceName(environmentList.value[0].name);+ rule.values.push(name);}state.deployment.schedule?.deployments.push({diff --git a/frontend/src/components/ProvideDashboardContext.vue b/frontend/src/components/ProvideDashboardContext.vueindex aa3fca8187..d636eaa35a 100644--- a/frontend/src/components/ProvideDashboardContext.vue+++ b/frontend/src/components/ProvideDashboardContext.vue@@ -4,7 +4,6 @@<script lang="ts">import {- useEnvironmentStore,useEnvironmentV1Store,useMemberStore,useRoleStore,@@ -33,7 +32,6 @@ export default defineComponent({// We also need this to render the proper inbox and activity entry.usePrincipalStore().fetchPrincipalList(),useUserStore().fetchUserList(),- useEnvironmentStore().fetchEnvironmentList(),useEnvironmentV1Store().fetchEnvironments(),// The default project hosts databases not explicitly assigned to other users project.useProjectStore().fetchProjectById(DEFAULT_PROJECT_ID),diff --git a/frontend/src/components/RequestDatabasePrepForm.vue b/frontend/src/components/RequestDatabasePrepForm.vueindex e413dc73a7..c44c01663b 100644--- a/frontend/src/components/RequestDatabasePrepForm.vue+++ b/frontend/src/components/RequestDatabasePrepForm.vue@@ -5,12 +5,11 @@<label for="project" class="textlabel">Project <span style="color: red">*</span></label>- <!-- eslint-disable vue/attribute-hyphenation --><ProjectSelectid="project"class="mt-1"name="project"- :selectedId="state.projectId"+ :selected-id="state.projectId as number"@select-project-id="(projectId) => {state.projectId = projectId;@@ -23,12 +22,11 @@<label for="environment" class="textlabel">Environment <span style="color: red">*</span></label>- <!-- eslint-disable vue/attribute-hyphenation --><EnvironmentSelectid="environment"class="mt-1 w-full"name="environment"- :selectedId="state.environmentId"+ :selected-id="state.environmentId"@select-environment-id="(environmentId) => {state.environmentId = environmentId;@@ -78,15 +76,14 @@:required="true":value="state.databaseName":placeholder="'New database name'"- @end-editing="(text) => (state.databaseName = text)"+ @end-editing="(text: string) => (state.databaseName = text)"@input="state.databaseName = $event.target.value"/><div v-else class="flex flex-row space-x-4">- <!-- eslint-disable vue/attribute-hyphenation --><DatabaseSelect- :selectedId="state.databaseId"+ :selected-id="state.databaseId as number":mode="'ENVIRONMENT'"- :environmentId="state.environmentId"+ :environment-id="state.environmentId"@select-database-id="(databaseId) => {state.databaseId = databaseId;@@ -97,7 +94,7 @@:label="'Read only'":value="state.readonly"@toggle="- (on) => {+ (on: boolean) => {state.readonly = on;}"@@ -140,12 +137,16 @@ import isEmpty from "lodash-es/isEmpty";import ProjectSelect from "../components/ProjectSelect.vue";import DatabaseSelect from "../components/DatabaseSelect.vue";import EnvironmentSelect from "../components/EnvironmentSelect.vue";-import { DatabaseId, EnvironmentId, ProjectId, UNKNOWN_ID } from "../types";+import { DatabaseId, ProjectId, UNKNOWN_ID } from "../types";import { allowDatabaseAccess } from "../utils";-import { useCurrentUser, useDatabaseStore, useEnvironmentStore } from "@/store";+import {+ useCurrentUser,+ useDatabaseStore,+ useEnvironmentV1Store,+} from "@/store";interface LocalState {- environmentId: EnvironmentId;+ environmentId: string;projectId: ProjectId;// Radio button only accept string valuecreate: "ON" | "OFF";@@ -179,7 +180,7 @@ export default defineComponent({});const state = reactive<LocalState>({- environmentId: UNKNOWN_ID,+ environmentId: String(UNKNOWN_ID),projectId: UNKNOWN_ID,create: "ON",databaseName: "",@@ -206,7 +207,7 @@ export default defineComponent({const allowRequest = computed(() => {return (- state.environmentId != UNKNOWN_ID &&+ state.environmentId !== String(UNKNOWN_ID) &&state.projectId != UNKNOWN_ID &&((state.create == "ON" && !isEmpty(state.databaseName)) ||(state.create == "OFF" && state.databaseId != UNKNOWN_ID)) &&@@ -221,7 +222,7 @@ export default defineComponent({const request = () => {emit("dismiss");- const environment = useEnvironmentStore().getEnvironmentById(+ const environment = useEnvironmentV1Store().getEnvironmentByUID(state.environmentId);if (state.create == "ON") {diff --git a/frontend/src/components/SQLReview/SQLReviewPolicyTable.vue b/frontend/src/components/SQLReview/SQLReviewPolicyTable.vueindex 55f86e995e..212883a551 100644--- a/frontend/src/components/SQLReview/SQLReviewPolicyTable.vue+++ b/frontend/src/components/SQLReview/SQLReviewPolicyTable.vue@@ -13,12 +13,11 @@}"><div class="bb-grid-cell">- <router-link :to="`/environment/${environment.uid}`">- {{ environmentTitleV1(environment) }}- <ProductionEnvironmentIcon- :tier="environmentTierToJSON(environment.tier)"- />- </router-link>+ <EnvironmentV1Name+ :environment="environment"+ :link="true"+ :plain="true"+ /></div><div class="bb-grid-cell"><template v-if="review">@@ -83,12 +82,8 @@ import {} from "@/store";import { hasWorkspacePermission, sqlReviewPolicySlug } from "@/utils";import { SQLReviewPolicy } from "@/types";-import ProductionEnvironmentIcon from "../Environment/ProductionEnvironmentIcon.vue";-import {- Environment,- environmentTierToJSON,-} from "@/types/proto/v1/environment_service";-import { environmentTitleV1 } from "@/utils";+import { Environment } from "@/types/proto/v1/environment_service";+import { EnvironmentV1Name } from "@/components/v2";type EnvironmentReviewPolicy = {environment: Environment;diff --git a/frontend/src/components/SQLReview/components/SQLReviewTemplateSelector.vue b/frontend/src/components/SQLReview/components/SQLReviewTemplateSelector.vueindex c2a524db59..06e35bfcdb 100644--- a/frontend/src/components/SQLReview/components/SQLReviewTemplateSelector.vue+++ b/frontend/src/components/SQLReview/components/SQLReviewTemplateSelector.vue@@ -25,10 +25,9 @@</span><p class="text-sm"><span class="mr-2">{{ $t("common.environment") }}:</span>- <span>{{ environmentTitleV1(template.review.environment) }}</span>- <ProductionEnvironmentIcon- :tier="environmentTierToJSON(template.review.environment.tier)"- class="ml-1 !text-current"+ <EnvironmentV1Name+ :environment="template.review.environment"+ :link="false"/></p><p class="text-sm">@@ -96,10 +95,8 @@ import { computed, watch } from "vue";import { SQLReviewPolicyTemplate } from "@/types";import { TEMPLATE_LIST as builtInTemplateList, RuleLevel } from "@/types";import { useSQLReviewPolicyList } from "@/store";-import { environmentTitleV1 } from "@/utils";-import ProductionEnvironmentIcon from "@/components/Environment/ProductionEnvironmentIcon.vue";import { rulesToTemplate } from "./utils";-import { environmentTierToJSON } from "@/types/proto/v1/environment_service";+import { EnvironmentV1Name } from "@/components/v2";const props = withDefaults(defineProps<{diff --git a/frontend/src/components/SlowQuery/Panel/LogFilter.vue b/frontend/src/components/SlowQuery/Panel/LogFilter.vueindex 1b0bcb1bee..515b9382d1 100644--- a/frontend/src/components/SlowQuery/Panel/LogFilter.vue+++ b/frontend/src/components/SlowQuery/Panel/LogFilter.vue@@ -10,7 +10,7 @@<EnvironmentTabFilterv-if="filterTypes.includes('environment')"class="flex-1"- :environment="params.environment?.id ?? UNKNOWN_ID"+ :environment="params.environment?.uid ?? String(UNKNOWN_ID)":include-all="true":disabled="loading"@update:environment="changeEnvironmentId"@@ -35,7 +35,7 @@<InstanceSelectv-if="filterTypes.includes('instance')":instance="params.instance?.id ?? UNKNOWN_ID"- :environment="params.environment?.id"+ :environment="params.environment?.uid":include-all="true":filter="instanceFilter":disabled="loading"@@ -44,7 +44,7 @@<DatabaseSelectv-if="filterTypes.includes('database')":database="params.database?.id ?? UNKNOWN_ID"- :environment="params.environment?.id"+ :environment="params.environment?.uid":instance="params.instance?.id":project="params.project?.id":include-all="true"@@ -106,7 +106,7 @@ import {import {useCurrentUser,useDatabaseStore,- useEnvironmentStore,+ useEnvironmentV1Store,useInstanceStore,useProjectStore,useSlowQueryPolicyList,@@ -141,7 +141,7 @@ const canVisitDefaultProject = computed(() => {});const changeEnvironmentId = (id: EnvironmentId) => {- const environment = useEnvironmentStore().getEnvironmentById(id);+ const environment = useEnvironmentV1Store().getEnvironmentByUID(id);update({ environment });};const changeInstanceId = (id: InstanceId | undefined) => {@@ -213,7 +213,7 @@ const instanceFilter = (instance: Instance) => {if (!policy) {return false;}- return policy.slowQueryPolicy?.active;+ return !!policy.slowQueryPolicy?.active;};const isDateDisabled = (date: number) => {diff --git a/frontend/src/components/SlowQuery/Panel/types.ts b/frontend/src/components/SlowQuery/Panel/types.tsindex 4e4c92fcbe..84ef2bc891 100644--- a/frontend/src/components/SlowQuery/Panel/types.ts+++ b/frontend/src/components/SlowQuery/Panel/types.ts@@ -1,6 +1,7 @@import dayjs from "dayjs";-import { Environment, Instance, Database, Project, UNKNOWN_ID } from "@/types";+import { Instance, Database, Project, UNKNOWN_ID } from "@/types";import { ListSlowQueriesRequest } from "@/types/proto/v1/database_service";+import { Environment } from "@/types/proto/v1/environment_service";export type SlowQueryFilterParams = {project: Project | undefined; // undefined to "All"@@ -45,9 +46,9 @@ export const buildListSlowQueriesRequest = (filter: SlowQueryFilterParams) => {request.parent = `instances/${database.instance.resourceId}/databases/${database.name}`;} else if (instance && instance.id !== UNKNOWN_ID) {request.parent = `instances/${instance.resourceId}/databases/-`;- } else if (environment && environment.id !== UNKNOWN_ID) {+ } else if (environment && parseInt(environment.uid) !== UNKNOWN_ID) {request.parent = `instances/-/databases/-`;- query.push(`environment = "environments/${environment.resourceId}"`);+ query.push(`environment = "${environment.name}"`);}if (project) {diff --git a/frontend/src/components/SlowQuery/Settings/SlowQuerySettings.vue b/frontend/src/components/SlowQuery/Settings/SlowQuerySettings.vueindex 85a5c1abff..9ebdd6fe6d 100644--- a/frontend/src/components/SlowQuery/Settings/SlowQuerySettings.vue+++ b/frontend/src/components/SlowQuery/Settings/SlowQuerySettings.vue@@ -22,7 +22,7 @@</div><div class="flex items-center justify-between"><EnvironmentTabFilter- :environment="state.filter.environment?.id ?? UNKNOWN_ID"+ :environment="state.filter.environment?.uid ?? String(UNKNOWN_ID)":include-all="true"@update:environment="changeEnvironment"/>@@ -48,24 +48,19 @@ import { orderBy } from "lodash-es";import { BBAttention } from "@/bbkit";import {pushNotification,- useEnvironmentList,+ useEnvironmentV1List,useInstanceStore,useSlowQueryPolicyStore,useSlowQueryStore,} from "@/store";-import {- ComposedSlowQueryPolicy,- Environment,- EnvironmentId,- Instance,- UNKNOWN_ID,-} from "@/types";+import { ComposedSlowQueryPolicy, Instance, UNKNOWN_ID } from "@/types";import { EnvironmentTabFilter, SearchBox } from "@/components/v2";import { SlowQueryPolicyTable } from "./components";import { instanceSupportSlowQuery } from "@/utils";import { useGracefulRequest } from "@/store/modules/utils";import LearnMoreLink from "@/components/LearnMoreLink.vue";import { getInstancePathByLegacyInstance } from "@/store/modules/v1/common";+import { Environment } from "@/types/proto/v1/environment_service";type LocalState = {ready: boolean;@@ -89,7 +84,7 @@ const { t } = useI18n();const slowQueryPolicyStore = useSlowQueryPolicyStore();const slowQueryStore = useSlowQueryStore();const instanceStore = useInstanceStore();-const environmentList = useEnvironmentList(["NORMAL"]);+const environmentList = useEnvironmentV1List(false /* !showDeleted */);const policyList = computed(() => {return slowQueryPolicyStore.getPolicyList();@@ -118,9 +113,9 @@ const composedSlowQueryPolicyList = computed(() => {const filteredComposedSlowQueryPolicyList = computed(() => {let list = [...composedSlowQueryPolicyList.value];const { environment } = state.filter;- if (environment && environment.id !== UNKNOWN_ID) {+ if (environment && environment.uid !== String(UNKNOWN_ID)) {list = list.filter(- (item) => item.instance.environment.id === environment.id+ (item) => String(item.instance.environment.id) === environment.uid);}const keyword = state.filter.keyword.trim().toLowerCase();@@ -148,8 +143,10 @@ const prepare = async () => {}};-const changeEnvironment = (id: EnvironmentId | undefined) => {- state.filter.environment = environmentList.value.find((env) => env.id === id);+const changeEnvironment = (id: string | undefined) => {+ state.filter.environment = environmentList.value.find(+ (env) => env.uid === id+ );};const patchInstanceSlowQueryPolicy = async (diff --git a/frontend/src/components/SlowQuery/Settings/components/SlowQueryPolicyTable.vue b/frontend/src/components/SlowQuery/Settings/components/SlowQueryPolicyTable.vueindex 4f84c18df5..856dc4cb91 100644--- a/frontend/src/components/SlowQuery/Settings/components/SlowQueryPolicyTable.vue+++ b/frontend/src/components/SlowQuery/Settings/components/SlowQueryPolicyTable.vue@@ -8,11 +8,14 @@><template #item="{ item }: { item: ComposedSlowQueryPolicy }"><div class="bb-grid-cell">- <InstanceName :instance="item.instance" />+ <InstanceName :instance="item.instance" :link="false" /></div><div class="bb-grid-cell">- <EnvironmentName :environment="item.instance.environment" />+ <EnvironmentName+ :environment="item.instance.environment"+ :link="false"+ /></div><div class="bb-grid-cell"><SpinnerSwitchdiff --git a/frontend/src/components/TenantDatabaseTable/DatabaseMatrix.vue b/frontend/src/components/TenantDatabaseTable/DatabaseMatrix.vueindex a740a3a363..22f049e9ec 100644--- a/frontend/src/components/TenantDatabaseTable/DatabaseMatrix.vue+++ b/frontend/src/components/TenantDatabaseTable/DatabaseMatrix.vue@@ -60,12 +60,7 @@<script lang="ts">import { computed, defineComponent, PropType, ref, watchEffect } from "vue";-import {- Database,- Environment,- LabelKeyType,- LabelValueType,-} from "../../types";+import { Database, LabelKeyType, LabelValueType } from "../../types";import DatabaseMatrixItem from "./DatabaseMatrixItem.vue";import { groupBy, last } from "lodash-es";import {@@ -74,6 +69,7 @@ import {getLabelValuesFromDatabaseList,LABEL_VALUE_EMPTY,} from "../../utils";+import { Environment } from "@/types/proto/v1/environment_service";type DatabaseMatrix = {labelValue: LabelValueType;diff --git a/frontend/src/components/TenantDatabaseTable/DeployDatabaseTable.vue b/frontend/src/components/TenantDatabaseTable/DeployDatabaseTable.vueindex 53ff5c0432..e7907f712b 100644--- a/frontend/src/components/TenantDatabaseTable/DeployDatabaseTable.vue+++ b/frontend/src/components/TenantDatabaseTable/DeployDatabaseTable.vue@@ -99,7 +99,7 @@<script lang="ts" setup>import { groupBy } from "lodash-es";import { computed, withDefaults } from "vue";-import type { Database, Environment, LabelKeyType } from "../../types";+import type { Database, LabelKeyType } from "../../types";import {hidePrefix,getLabelValue,@@ -109,6 +109,7 @@ import {import { NPopover } from "naive-ui";import { DeploymentStage } from "../DeploymentConfigTool";import { DeploymentConfig } from "@/types/proto/v1/project_service";+import { Environment } from "@/types/proto/v1/environment_service";const props = withDefaults(defineProps<{diff --git a/frontend/src/components/TransferDatabaseForm.vue b/frontend/src/components/TransferDatabaseForm.vueindex 6a9c233192..76538f0898 100644--- a/frontend/src/components/TransferDatabaseForm.vue+++ b/frontend/src/components/TransferDatabaseForm.vue@@ -48,14 +48,14 @@ import {buildDatabaseNameRegExpByTemplate,filterDatabaseByKeyword,PRESET_LABEL_KEY_PLACEHOLDERS,- sortDatabaseList,+ sortDatabaseListByEnvironmentV1,useWorkspacePermission,} from "../utils";import {pushNotification,useCurrentUser,useDatabaseStore,- useEnvironmentList,+ useEnvironmentV1List,useProjectStore,} from "@/store";@@ -105,7 +105,7 @@ const prepare = async () => {onBeforeMount(prepare);-const environmentList = useEnvironmentList(["NORMAL"]);+const environmentList = useEnvironmentV1List(false /* !showDeleted */);const rawDatabaseList = computed(() => {if (state.transferSource == "DEFAULT") {@@ -140,7 +140,7 @@ const filteredDatabaseList = computed(() => {list = list.filter((db) => db.instance.id === state.instanceFilter?.id);}- return sortDatabaseList(list, environmentList.value);+ return sortDatabaseListByEnvironmentV1(list, environmentList.value);});const transferDatabase = async (databaseList: Database[]) => {diff --git a/frontend/src/components/v2/Model/EnvironmentV1Name.vue b/frontend/src/components/v2/Model/EnvironmentV1Name.vueindex 1685833d26..57ea041485 100644--- a/frontend/src/components/v2/Model/EnvironmentV1Name.vue+++ b/frontend/src/components/v2/Model/EnvironmentV1Name.vue@@ -3,7 +3,7 @@:is="link ? 'router-link' : tag"v-bind="bindings"class="inline-flex items-center gap-x-1"- :class="link && 'normal-link'"+ :class="link && !plain && 'normal-link'"><span>{{ environmentV1Name(environment) }}</span><ProductionEnvironmentV1Icon@@ -25,10 +25,12 @@ const props = withDefaults(environment: Environment;tag?: string;link?: boolean;+ plain?: boolean;}>(),{tag: "span",link: true,+ plain: false,});diff --git a/frontend/src/components/v2/Model/ProductionEnvironmentV1Icon.vue b/frontend/src/components/v2/Model/ProductionEnvironmentV1Icon.vueindex 48a8d3ec41..b8f29f22be 100644--- a/frontend/src/components/v2/Model/ProductionEnvironmentV1Icon.vue+++ b/frontend/src/components/v2/Model/ProductionEnvironmentV1Icon.vue@@ -28,7 +28,7 @@ import {} from "@/types/proto/v1/environment_service";export default defineComponent({- name: "ProductionEnvironmentIcon",+ name: "ProductionEnvironmentV1Icon",inheritAttrs: false,props: {environment: {diff --git a/frontend/src/components/v2/TabFilter/EnvironmentTabFilter.vue b/frontend/src/components/v2/TabFilter/EnvironmentTabFilter.vueindex 321c7ed534..9f247713fc 100644--- a/frontend/src/components/v2/TabFilter/EnvironmentTabFilter.vue+++ b/frontend/src/components/v2/TabFilter/EnvironmentTabFilter.vue@@ -6,7 +6,7 @@><template #label="{ item }"><template v-if="item.value === UNKNOWN_ID">{{ item.label }}</template>- <EnvironmentName v-else :environment="item.environment" :link="false" />+ <EnvironmentV1Name v-else :environment="item.environment" :link="false" /></template></TabFilter></template>@@ -15,18 +15,19 @@import { computed } from "vue";import { useI18n } from "vue-i18n";-import { useEnvironmentList } from "@/store";-import { Environment, EnvironmentId, UNKNOWN_ID, unknown } from "@/types";+import { useEnvironmentV1List } from "@/store";+import { UNKNOWN_ID, unknownEnvironment } from "@/types";import { TabFilterItem } from "./types";-import { EnvironmentName } from "../Model";+import { EnvironmentV1Name } from "../Model";+import { Environment } from "@/types/proto/v1/environment_service";-interface EnvironmentTabFilterItem extends TabFilterItem<EnvironmentId> {+interface EnvironmentTabFilterItem extends TabFilterItem<string> {environment: Environment;}const props = withDefaults(defineProps<{- environment: EnvironmentId; // UNKNOWN_ID(-1) to "ALL"+ environment: string; // UNKNOWN_ID(-1) to "ALL"includeAll?: boolean;}>(),{@@ -35,25 +36,29 @@ const props = withDefaults();defineEmits<{- (event: "update:environment", id: EnvironmentId): void;+ (event: "update:environment", id: string): void;}>();const { t } = useI18n();-const environmentList = useEnvironmentList(["NORMAL"]);+const environmentList = useEnvironmentV1List(false /* !showDeleted */);const items = computed(() => {const reversedEnvironmentList = [...environmentList.value].reverse();const environmentItems =reversedEnvironmentList.map<EnvironmentTabFilterItem>((env) => ({- value: env.id,- label: env.name,+ value: env.uid,+ label: env.title,environment: env,}));- if (props.environment === UNKNOWN_ID || props.includeAll) {+ if (props.environment === String(UNKNOWN_ID) || props.includeAll) {+ const dummyAll = {+ ...unknownEnvironment(),+ title: t("common.all"),+ };environmentItems.unshift({- value: UNKNOWN_ID,- label: t("common.all"),- environment: unknown("ENVIRONMENT"),+ value: dummyAll.uid,+ label: dummyAll.title,+ environment: dummyAll,});}return environmentItems;diff --git a/frontend/src/store/modules/environment.ts b/frontend/src/store/modules/environment.tsindex 4568ec58c2..9dfcf15b39 100644--- a/frontend/src/store/modules/environment.ts+++ b/frontend/src/store/modules/environment.ts@@ -1,19 +1,5 @@import { defineStore } from "pinia";-import axios from "axios";-import { computed } from "vue";-import {- empty,- EMPTY_ID,- Environment,- EnvironmentId,- EnvironmentState,- ResourceObject,- RowStatus,- unknown,-} from "@/types";-import { usePolicyV1Store } from "./v1/policy";-import { getEnvironmentPathByLegacyEnvironment } from "@/store/modules/v1/common";-import { PolicyType } from "@/types/proto/v1/org_policy_service";+import { Environment, ResourceObject } from "@/types";function convert(environment: ResourceObject,@@ -25,10 +11,8 @@ function convert(};}-export const useEnvironmentStore = defineStore("environment", {- state: (): EnvironmentState => ({- environmentList: [],- }),+export const useLegacyEnvironmentStore = defineStore("environment", {+ state: () => ({}),actions: {convert(environment: ResourceObject,@@ -36,97 +20,5 @@ export const useEnvironmentStore = defineStore("environment", {): Environment {return convert(environment, includedList);},- getEnvironmentList(rowStatusList?: RowStatus[]): Environment[] {- return this.environmentList.filter((environment: Environment) => {- return (- (!rowStatusList && environment.rowStatus == "NORMAL") ||- (rowStatusList && rowStatusList.includes(environment.rowStatus))- );- });- },- getEnvironmentById(environmentId: EnvironmentId): Environment {- if (environmentId == EMPTY_ID) {- return empty("ENVIRONMENT") as Environment;- }-- for (const environment of this.environmentList) {- if (environment.id == environmentId) {- return environment;- }- }- return unknown("ENVIRONMENT") as Environment;- },- upsertEnvironmentList(environmentList: Environment[]) {- for (const environment of environmentList) {- const i = this.environmentList.findIndex(- (item: Environment) => item.id == environment.id- );- if (i != -1) {- this.environmentList[i] = environment;- } else {- this.environmentList.push(environment);- }-- this.environmentList.sort((a, b) => a.order - b.order);- }- },- async fetchEnvironmentList(rowStatusList?: RowStatus[]) {- const path =- "/api/environment" +- (rowStatusList ? "?rowstatus=" + rowStatusList.join(",") : "");- const data = (await axios.get(path)).data;- const environmentList: Environment[] = data.data.map(- (env: ResourceObject) => {- return convert(env, data.included);- }- );- this.upsertEnvironmentList(environmentList);-- const policyStore = usePolicyV1Store();-- await Promise.all(- environmentList.map((environment) => {- return policyStore.getOrFetchPolicyByParentAndType({- parentPath: getEnvironmentPathByLegacyEnvironment(environment),- policyType: PolicyType.DEPLOYMENT_APPROVAL,- refresh: true,- });- })- );-- return environmentList;- },- async reorderEnvironmentList(orderedEnvironmentList: Environment[]) {- const list: any[] = [];- orderedEnvironmentList.forEach((item, index) => {- list.push({- // Server uses google/jsonapi which expects a string type for the special id field.- // Afterwards, server will automatically serialize into int as declared by the EnvironmentPatch interface.- id: item.id.toString(),- type: "environmentPatch",- attributes: {- order: index,- },- });- });- const data = (- await axios.patch(`/api/environment/reorder`, {- data: list,- })- ).data;- const environmentList: Environment[] = data.data.map(- (env: ResourceObject) => {- return convert(env, data.included);- }- );- this.upsertEnvironmentList(environmentList);-- return environmentList;- },},});--export const useEnvironmentList = (rowStatusList?: RowStatus[]) => {- const store = useEnvironmentStore();- return computed(() => store.getEnvironmentList(rowStatusList));-};diff --git a/frontend/src/store/modules/instance.ts b/frontend/src/store/modules/instance.tsindex 900508f7d1..80a925f904 100644--- a/frontend/src/store/modules/instance.ts+++ b/frontend/src/store/modules/instance.ts@@ -26,7 +26,7 @@ import {UNKNOWN_ID,} from "@/types";import { InstanceUser } from "@/types/InstanceUser";-import { useEnvironmentStore } from "./environment";+import { useLegacyEnvironmentStore } from "./environment";import { useDataSourceStore } from "./dataSource";import { useSQLStore } from "./sql";@@ -59,7 +59,7 @@ function convert(dataSourceList: [],};- const environmentStore = useEnvironmentStore();+ const legacyEnvironmentStore = useLegacyEnvironmentStore();const dataSourceStore = useDataSourceStore();for (const item of includedList || []) {if (@@ -67,7 +67,7 @@ function convert((instance.relationships!.environment.data as ResourceIdentifier).id ==item.id) {- environment = environmentStore.convert(item, includedList);+ environment = legacyEnvironmentStore.convert(item, includedList);}if (diff --git a/frontend/src/store/modules/sqlReview.ts b/frontend/src/store/modules/sqlReview.tsindex 151339e81c..7502fa44d4 100644--- a/frontend/src/store/modules/sqlReview.ts+++ b/frontend/src/store/modules/sqlReview.ts@@ -32,8 +32,8 @@ import {const getEnvironmentById = async (environmentId: IdType): Promise<Environment> => {- const environmentStore = useEnvironmentV1Store();- const environment = await environmentStore.getOrFetchEnvironmentByName(+ const environmentV1Store = useEnvironmentV1Store();+ const environment = await environmentV1Store.getOrFetchEnvironmentByName(`${environmentNamePrefix}${environmentId}`);return environment;diff --git a/frontend/src/store/modules/stage.ts b/frontend/src/store/modules/stage.tsindex 1965fa3d73..d75ccc5249 100644--- a/frontend/src/store/modules/stage.ts+++ b/frontend/src/store/modules/stage.ts@@ -10,7 +10,7 @@ import {Pipeline,Environment,} from "@/types";-import { useEnvironmentStore } from "./environment";+import { useLegacyEnvironmentStore } from "./environment";import { useTaskStore } from "./task";function convertPartial(@@ -40,14 +40,14 @@ function convertPartial(}}- const environmentStore = useEnvironmentStore();+ const legacyEnvironmentStore = useLegacyEnvironmentStore();for (const item of includedList || []) {if (item.type == "environment" &&(stage.relationships!.environment.data as ResourceIdentifier).id ==item.id) {- environment = environmentStore.convert(item, includedList);+ environment = legacyEnvironmentStore.convert(item, includedList);}}diff --git a/frontend/src/store/modules/v1/environment.ts b/frontend/src/store/modules/v1/environment.tsindex 3375b40e90..02c60c4fc6 100644--- a/frontend/src/store/modules/v1/environment.ts+++ b/frontend/src/store/modules/v1/environment.ts@@ -1,12 +1,13 @@import { defineStore } from "pinia";import { computed } from "vue";+import { isEqual, isUndefined, orderBy } from "lodash-es";+import { environmentServiceClient } from "@/grpcweb";import {Environment,EnvironmentTier,} from "@/types/proto/v1/environment_service";import { ResourceId, EnvironmentId } from "@/types";-import { isEqual, isUndefined } from "lodash-es";import { State } from "@/types/proto/v1/common";import { environmentNamePrefix } from "@/store/modules/v1/common";@@ -20,7 +21,11 @@ export const useEnvironmentV1Store = defineStore("environment_v1", {}),getters: {environmentList(state) {- return Array.from(state.environmentMapByName.values());+ return orderBy(+ Array.from(state.environmentMapByName.values()),+ (env) => env.order,+ "asc"+ );},},actions: {@@ -87,6 +92,23 @@ export const useEnvironmentV1Store = defineStore("environment_v1", {this.environmentMapByName.set(environment.name, environment);return environment;},+ async reorderEnvironmentList(orderedEnvironmentList: Environment[]) {+ const updatedEnvironmentList = await Promise.all(+ orderedEnvironmentList.map((environment, order) => {+ return environmentServiceClient.updateEnvironment({+ environment: {+ ...environment,+ order,+ },+ updateMask: ["order"],+ });+ })+ );+ updatedEnvironmentList.forEach((environment) => {+ this.environmentMapByName.set(environment.name, environment);+ });+ return updatedEnvironmentList;+ },async getOrFetchEnvironmentByName(name: string) {const cachedData = this.environmentMapByName.get(name);if (cachedData) {diff --git a/frontend/src/types/store.ts b/frontend/src/types/store.tsindex fe1f884079..5fa0fa2ddc 100644--- a/frontend/src/types/store.ts+++ b/frontend/src/types/store.ts@@ -1,9 +1,6 @@import { RemovableRef } from "@vueuse/core";import {- EnvironmentId,MigrationHistoryId,- Policy,- PolicyType,QueryHistory,Sheet,OnboardingGuideType,@@ -14,7 +11,6 @@ import { Bookmark } from "./bookmark";import { Command } from "./common";import { Database } from "./database";import { DataSource } from "./dataSource";-import { Environment } from "./environment";import {CommandId,DatabaseId,@@ -98,18 +94,10 @@ export interface StageState {}// eslint-disable-next-line @typescript-eslint/no-empty-interfaceexport interface TaskState {}-export interface PolicyState {- policyMapByEnvironmentId: Map<EnvironmentId, Map<PolicyType, Policy>>;-}-export interface ProjectState {projectById: Map<ProjectId, Project>;}-export interface EnvironmentState {- environmentList: Environment[];-}-export interface InstanceState {instanceById: Map<InstanceId, Instance>;instanceUserListById: Map<InstanceId, InstanceUser[]>;diff --git a/frontend/src/types/v1/environment.ts b/frontend/src/types/v1/environment.tsnew file mode 100644index 0000000000..eed11637df--- /dev/null+++ b/frontend/src/types/v1/environment.ts@@ -0,0 +1,25 @@+import { EMPTY_ID, UNKNOWN_ID } from "../const";+import { State } from "../proto/v1/common";+import { Environment, EnvironmentTier } from "../proto/v1/environment_service";++export const ENVIRONMENT_ALL_NAME = "environments/-";++export const emptyEnvironment = () => {+ return Environment.fromJSON({+ name: `environments/${EMPTY_ID}`,+ uid: String(EMPTY_ID),+ title: "",+ state: State.ACTIVE,+ order: 0,+ tier: EnvironmentTier.UNPROTECTED,+ });+};++export const unknownEnvironment = () => {+ return {+ ...emptyEnvironment(),+ name: `environments/${UNKNOWN_ID}`,+ uid: String(UNKNOWN_ID),+ title: "<<Unknown environment>>",+ };+};diff --git a/frontend/src/types/v1/index.ts b/frontend/src/types/v1/index.tsindex 0e85ce1f25..f47993a7c6 100644--- a/frontend/src/types/v1/index.ts+++ b/frontend/src/types/v1/index.ts@@ -1,2 +1,3 @@+export * from "./environment";export * from "./project";export * from "./projectWebhook";diff --git a/frontend/src/utils/database.ts b/frontend/src/utils/database.tsindex 50badb6614..c9a8587315 100644--- a/frontend/src/utils/database.ts+++ b/frontend/src/utils/database.ts@@ -1,3 +1,5 @@+import { Environment as EnvironmentV1 } from "@/types/proto/v1/environment_service";+import { keyBy } from "lodash-es";import type {Database,DataSourceType,@@ -63,6 +65,22 @@ export function sortDatabaseList(});}+// Sort the list to put prod items first.+export function sortDatabaseListByEnvironmentV1(+ list: Database[],+ environmentList: EnvironmentV1[]+): Database[] {+ const environmentMap = keyBy(environmentList, (env) => env.uid);+ return list.sort((a: Database, b: Database) => {+ const aEnvOrder =+ environmentMap[String(a.instance.environment.id)]?.order ?? -1;+ const bEnvOrder =+ environmentMap[String(b.instance.environment.id)]?.order ?? -1;++ return bEnvOrder - aEnvOrder;+ });+}+const MIN_GHOST_SUPPORT_MYSQL_VERSION = "5.7.0";export function allowGhostMigration(databaseList: Database[]): boolean {diff --git a/frontend/src/utils/instance.ts b/frontend/src/utils/instance.tsindex 334d0202d4..9e29da1678 100644--- a/frontend/src/utils/instance.ts+++ b/frontend/src/utils/instance.ts@@ -1,4 +1,6 @@import { computed, unref } from "vue";+import { keyBy } from "lodash-es";+import {EngineType,Environment,@@ -7,6 +9,7 @@ import {languageOfEngine,MaybeRef,} from "../types";+import { Environment as EnvironmentV1 } from "@/types/proto/v1/environment_service";export const supportedEngineList = () => {const engines: EngineType[] = [@@ -60,6 +63,21 @@ export function sortInstanceList(});}+// Sort the list to put prod items first.+export function sortInstanceListByEnvironmentV1(+ list: Instance[],+ environmentList: EnvironmentV1[]+): Instance[] {+ const environmentMap = keyBy(environmentList, (env) => env.uid);++ return list.sort((a, b) => {+ const aEnvOrder = environmentMap[String(a.environment.id)]?.order ?? -1;+ const bEnvOrder = environmentMap[String(b.environment.id)]?.order ?? -1;++ return bEnvOrder - aEnvOrder;+ });+}+export const useInstanceEditorLanguage = (instance: MaybeRef<Instance | undefined>) => {diff --git a/frontend/src/utils/label.ts b/frontend/src/utils/label.tsindex 8578aa771a..8aa3fc06f2 100644--- a/frontend/src/utils/label.ts+++ b/frontend/src/utils/label.ts@@ -1,5 +1,5 @@-import { useEnvironmentStore } from "@/store";import { countBy, groupBy, uniq, uniqBy } from "lodash-es";+import { useEnvironmentV1Store } from "@/store";import {Database,DatabaseLabel,@@ -7,6 +7,7 @@ import {LabelKeyType,LabelValueType,} from "../types";+import { extractEnvironmentResourceName } from "./v1";export const MAX_LABEL_VALUE_LENGTH = 63;@@ -152,8 +153,10 @@ export const getLabelValuesFromDatabaseList = (withEmptyValue = false): string[] => {if (key === "bb.environment") {- const environmentList = useEnvironmentStore().getEnvironmentList();- return environmentList.map((env) => env.resourceId);+ const environmentList = useEnvironmentV1Store().getEnvironmentList();+ return environmentList.map((env) =>+ extractEnvironmentResourceName(env.name)+ );}const labelList = databaseList.flatMap((db) =>diff --git a/frontend/src/views/AnomalyCenterDashboard.vue b/frontend/src/views/AnomalyCenterDashboard.vueindex 3b65ba6e18..77aad19f7d 100644--- a/frontend/src/views/AnomalyCenterDashboard.vue+++ b/frontend/src/views/AnomalyCenterDashboard.vue@@ -75,7 +75,7 @@:tab-item-list="tabItemList":selected-index="state.selectedIndex"@select-index="- (index) => {+ (index: number) => {state.selectedIndex = index;}"@@ -91,7 +91,7 @@: $t('common.instance'),})"- @change-text="(text) => changeSearchText(text)"+ @change-text="(text:string) => changeSearchText(text)"/></div><template v-if="state.selectedIndex == DATABASE_TAB">@@ -130,13 +130,13 @@ import { computed, defineComponent, reactive, watchEffect } from "vue";import { useI18n } from "vue-i18n";import AnomalyTable from "../components/AnomalyTable.vue";-import { Anomaly, EnvironmentId, UNKNOWN_ID } from "../types";+import { Anomaly, UNKNOWN_ID } from "../types";import {databaseSlug,instanceSlug,hasWorkspacePermission,- sortDatabaseList,- sortInstanceList,+ sortDatabaseListByEnvironmentV1,+ sortInstanceListByEnvironmentV1,} from "../utils";import { BBTabFilterItem, BBTableSectionDataSource } from "../bbkit/types";import { cloneDeep } from "lodash-es";@@ -145,7 +145,7 @@ import {useAnomalyList,useCurrentUser,useDatabaseStore,- useEnvironmentList,+ useEnvironmentV1List,useInstanceList,} from "@/store";@@ -183,7 +183,7 @@ export default defineComponent({searchText: "",});- const environmentList = useEnvironmentList(["NORMAL"]);+ const environmentList = useEnvironmentV1List(false /* !showDeleted */);const prepareDatabaseList = () => {// It will also be called when user logout@@ -221,7 +221,7 @@ export default defineComponent({}}- sortDatabaseList(dbList, environmentList.value);+ sortDatabaseListByEnvironmentV1(dbList, environmentList.value);for (const database of dbList) {const anomalyListOfDatabase = allAnomalyList.value.filter(@@ -260,7 +260,7 @@ export default defineComponent({}}- sortInstanceList(insList, environmentList.value);+ sortInstanceListByEnvironmentV1(insList, environmentList.value);for (const instance of insList) {const anomalyListOfInstance = allAnomalyList.value.filter(@@ -280,7 +280,7 @@ export default defineComponent({);const databaseAnomalySummaryList = computed((): Summary[] => {- const envMap: Map<EnvironmentId, Summary> = new Map();+ const envMap: Map<string, Summary> = new Map();for (const database of databaseList.value) {let criticalCount = 0;let highCount = 0;@@ -301,13 +301,13 @@ export default defineComponent({break;}}- const summary = envMap.get(database.instance.environment.id);+ const summary = envMap.get(String(database.instance.environment.id));if (summary) {summary.criticalCount += criticalCount;summary.highCount += highCount;summary.mediumCount += mediumCount;} else {- envMap.set(database.instance.environment.id, {+ envMap.set(String(database.instance.environment.id), {environmentName: database.instance.environment.name,criticalCount,highCount,@@ -318,7 +318,7 @@ export default defineComponent({const list: Summary[] = [];for (const environment of environmentList.value) {- const summary = envMap.get(environment.id);+ const summary = envMap.get(environment.uid);if (summary) {list.push(summary);}@@ -328,7 +328,7 @@ export default defineComponent({});const instanceAnomalySummaryList = computed((): Summary[] => {- const envMap: Map<EnvironmentId, Summary> = new Map();+ const envMap: Map<string, Summary> = new Map();for (const instance of instanceList.value) {let criticalCount = 0;let highCount = 0;@@ -349,13 +349,13 @@ export default defineComponent({break;}}- const summary = envMap.get(instance.environment.id);+ const summary = envMap.get(String(instance.environment.id));if (summary) {summary.criticalCount += criticalCount;summary.highCount += highCount;summary.mediumCount += mediumCount;} else {- envMap.set(instance.environment.id, {+ envMap.set(String(instance.environment.id), {environmentName: instance.environment.name,criticalCount,highCount,@@ -366,7 +366,7 @@ export default defineComponent({const list: Summary[] = [];for (const environment of environmentList.value) {- const summary = envMap.get(environment.id);+ const summary = envMap.get(environment.uid);if (summary) {list.push(summary);}diff --git a/frontend/src/views/DatabaseDashboard.vue b/frontend/src/views/DatabaseDashboard.vueindex 87eb011d60..c67be13312 100644--- a/frontend/src/views/DatabaseDashboard.vue+++ b/frontend/src/views/DatabaseDashboard.vue@@ -3,7 +3,7 @@<div class="px-5 py-2 flex justify-between items-center"><EnvironmentTabFilter:include-all="true"- :environment="selectedEnvironment?.id ?? UNKNOWN_ID"+ :environment="selectedEnvironment?.uid ?? String(UNKNOWN_ID)"@update:environment="changeEnvironmentId"/>@@ -33,7 +33,7 @@<InstanceSelect:instance="state.instanceFilter":include-all="true"- :environment="selectedEnvironment?.id"+ :environment="selectedEnvironment?.uid"@update:instance="state.instanceFilter = $event ?? UNKNOWN_ID"/><SearchBox@@ -79,12 +79,12 @@ import {import {filterDatabaseByKeyword,hasWorkspacePermission,- sortDatabaseList,+ sortDatabaseListByEnvironmentV1,} from "../utils";import {useCurrentUser,useDatabaseStore,- useEnvironmentStore,+ useEnvironmentV1Store,useProjectV1ListByCurrentUser,useUIStateStore,} from "@/store";@@ -97,7 +97,7 @@ interface LocalState {}const uiStateStore = useUIStateStore();-const environmentStore = useEnvironmentStore();+const environmentV1Store = useEnvironmentV1Store();const router = useRouter();const route = useRoute();@@ -114,7 +114,7 @@ const { projectList } = useProjectV1ListByCurrentUser();const selectedEnvironment = computed(() => {const { environment } = route.query;return environment- ? environmentStore.getEnvironmentById(parseInt(environment as string, 10))+ ? environmentV1Store.getEnvironmentByUID(environment as string): undefined;});@@ -142,11 +142,11 @@ const prepareDatabaseList = () => {useDatabaseStore().fetchDatabaseList().then((list) => {- state.databaseList = sortDatabaseList(+ state.databaseList = sortDatabaseListByEnvironmentV1(cloneDeep(list).filter((db) =>projectIdList.includes(String(db.projectId))),- environmentStore.getEnvironmentList()+ environmentV1Store.getEnvironmentList());}).finally(() => {@@ -176,8 +176,10 @@ const filteredList = computed(() => {const { databaseList, searchText } = state;let list = [...databaseList];const environment = selectedEnvironment.value;- if (environment && environment.id !== UNKNOWN_ID) {- list = list.filter((db) => db.instance.environment.id === environment.id);+ if (environment && parseInt(environment.uid, 10) !== UNKNOWN_ID) {+ list = list.filter(+ (db) => String(db.instance.environment.id) === environment.uid+ );}if (state.instanceFilter !== UNKNOWN_ID) {list = list.filter((db) => db.instance.id === state.instanceFilter);diff --git a/frontend/src/views/EnvironmentDashboard.vue b/frontend/src/views/EnvironmentDashboard.vueindex c6ac8b7821..5a97bbf373 100644--- a/frontend/src/views/EnvironmentDashboard.vue+++ b/frontend/src/views/EnvironmentDashboard.vue@@ -12,13 +12,13 @@><div class="flex items-center">{{ item.title }}- <ProductionEnvironmentIcon :environment="item.data!" class="ml-1" />+ <ProductionEnvironmentV1Icon :environment="item.data!" class="ml-1" /></div></template><BBTabPanel- v-for="(item, index) in environmentList"- :key="item.id"+ v-for="(env, index) in environmentList"+ :key="env.uid":active="index == state.selectedIndex"><div v-if="state.reorder" class="flex justify-center pt-5">@@ -40,7 +40,7 @@</div><EnvironmentDetailv-else- :environment-slug="environmentSlug(item)"+ :environment-slug="environmentV1Slug(env)"@archive="doArchive"/></BBTabPanel>@@ -72,24 +72,23 @@<script lang="ts" setup>import { onMounted, computed, reactive, watch } from "vue";import { useRouter } from "vue-router";-import { arraySwap } from "../utils";+import { arraySwap, environmentV1Slug } from "../utils";import EnvironmentDetail from "../views/EnvironmentDetail.vue";import EnvironmentForm from "../components/EnvironmentForm.vue";-import type { Environment, EnvironmentCreate } from "../types";import type { BBTabItem } from "../bbkit/types";import {useRegisterCommand,useUIStateStore,hasFeature,- useEnvironmentStore,- useEnvironmentList,-} from "@/store";-import ProductionEnvironmentIcon from "../components/Environment/ProductionEnvironmentIcon.vue";-import {useEnvironmentV1Store,defaultEnvironmentTier,-} from "@/store/modules/v1/environment";-import { EnvironmentTier } from "@/types/proto/v1/environment_service";+ useEnvironmentV1List,+} from "@/store";+import { ProductionEnvironmentV1Icon } from "@/components/v2";+import {+ Environment,+ EnvironmentTier,+} from "@/types/proto/v1/environment_service";import {usePolicyV1Store,defaultBackupSchedule,@@ -102,6 +101,7 @@ import {PolicyType,PolicyResourceType,} from "@/types/proto/v1/org_policy_service";+import { emptyEnvironment } from "@/types";// The default value should be consistent with the GetDefaultPolicy from the backend.const DEFAULT_NEW_APPROVAL_POLICY: Policy = getDefaultDeploymentApprovalPolicy(@@ -126,7 +126,6 @@ interface LocalState {| "bb.feature.environment-tier-policy";}-const environmentStore = useEnvironmentStore();const environmentV1Store = useEnvironmentV1Store();const uiStateStore = useUIStateStore();const policyV1Store = usePolicyV1Store();@@ -144,8 +143,8 @@ const selectEnvironmentOnHash = () => {if (router.currentRoute.value.hash) {for (let i = 0; i < environmentList.value.length; i++) {if (- environmentList.value[i].id ===- parseInt(router.currentRoute.value.hash.slice(1), 10)+ environmentList.value[i].uid ===+ router.currentRoute.value.hash.slice(1)) {selectEnvironment(i);break;@@ -192,27 +191,24 @@ watch(});-const environmentList = useEnvironmentList();+const environmentList = useEnvironmentV1List();const tabItemList = computed((): BBTabItem[] => {if (environmentList.value) {const list = state.reorder? state.reorderedEnvironmentList: environmentList.value;- return list.map((item: Environment, index: number): BBTabItem => {- const title = `${index + 1}. ${item.name}`;- const id = item.id.toString();+ return list.map((item, index: number): BBTabItem => {+ const title = `${index + 1}. ${item.title}`;+ const id = item.uid;return { title, id, data: item };});}return [];});-const getEnvironmentCreate = (): EnvironmentCreate => {- return {- title: "",- name: "",- };+const getEnvironmentCreate = () => {+ return emptyEnvironment();};const createEnvironment = () => {@@ -221,7 +217,7 @@ const createEnvironment = () => {};const doCreate = async (- newEnvironment: EnvironmentCreate,+ newEnvironment: Environment,approvalPolicy: Policy,backupPolicy: Policy,environmentTier: EnvironmentTier@@ -257,7 +253,7 @@ const doCreate = async (});// After creating with v1 store, we need to fetch the latest data in old store.// TODO(steven): using grpc store.- await environmentStore.fetchEnvironmentList();+ await environmentV1Store.fetchEnvironments();const requests = [policyV1Store.upsertPolicy({@@ -308,7 +304,7 @@ const reorderEnvironment = (sourceIndex: number, targetIndex: number) => {const orderChanged = computed(() => {for (let i = 0; i < state.reorderedEnvironmentList.length; i++) {- if (state.reorderedEnvironmentList[i].id != environmentList.value[i].id) {+ if (state.reorderedEnvironmentList[i].uid != environmentList.value[i].uid) {return true;}}@@ -320,7 +316,7 @@ const discardReorder = () => {};const doReorder = () => {- environmentStore+ environmentV1Store.reorderEnvironmentList(state.reorderedEnvironmentList).then(() => {stopReorder();@@ -337,7 +333,7 @@ const selectEnvironment = (index: number) => {state.selectedIndex = index;router.replace({name: "workspace.environment",- hash: "#" + environmentList.value[index].id,+ hash: "#" + environmentList.value[index].uid,});};</script>diff --git a/frontend/src/views/EnvironmentDetail.vue b/frontend/src/views/EnvironmentDetail.vueindex d966087248..73a3653363 100644--- a/frontend/src/views/EnvironmentDetail.vue+++ b/frontend/src/views/EnvironmentDetail.vue@@ -52,7 +52,6 @@import { computed, reactive, watchEffect } from "vue";import ArchiveBanner from "../components/ArchiveBanner.vue";import EnvironmentForm from "../components/EnvironmentForm.vue";-import { EnvironmentPatch } from "../types";import { idFromSlug } from "../utils";import { hasFeature, pushNotification, useBackupStore } from "@/store";import { useI18n } from "vue-i18n";@@ -154,15 +153,12 @@ const assignEnvironment = (environment: Environment) => {state.environment = environment;};-const doUpdate = (environmentPatch: EnvironmentPatch) => {+const doUpdate = (environmentPatch: Environment) => {const pendingUpdate = cloneDeep(state.environment);- if (environmentPatch.title) {+ if (environmentPatch.title !== pendingUpdate.title) {pendingUpdate.title = environmentPatch.title;}- if (environmentPatch.order) {- pendingUpdate.order = environmentPatch.order;- }- if (environmentPatch.tier) {+ if (environmentPatch.tier !== pendingUpdate.tier) {if (pendingUpdate.tier !== defaultEnvironmentTier &&!hasFeature("bb.feature.environment-tier-policy")@@ -180,7 +176,7 @@ const doUpdate = (environmentPatch: EnvironmentPatch) => {module: "bytebase",style: "SUCCESS",title: t("environment.successfully-updated-environment", {- name: environment.name,+ name: environment.title,}),});});diff --git a/frontend/src/views/Home.vue b/frontend/src/views/Home.vueindex 86409a828e..c604b0c23a 100644--- a/frontend/src/views/Home.vue+++ b/frontend/src/views/Home.vue@@ -3,7 +3,7 @@<div class="px-4 py-2 flex justify-between items-center"><EnvironmentTabFilter:include-all="true"- :environment="selectedEnvironment?.id ?? UNKNOWN_ID"+ :environment="selectedEnvironment?.uid ?? String(UNKNOWN_ID)"@update:environment="changeEnvironmentId"/><SearchBox@@ -190,11 +190,11 @@import { reactive, computed } from "vue";import { useRoute, useRouter } from "vue-router";import { activeEnvironment, isDatabaseRelatedIssueType } from "../utils";-import { UNKNOWN_ID, Issue, planTypeToString, EnvironmentId } from "../types";+import { UNKNOWN_ID, Issue, planTypeToString } from "../types";import { EnvironmentTabFilter, SearchBox } from "@/components/v2";import {useCurrentUser,- useEnvironmentStore,+ useEnvironmentV1Store,useSubscriptionStore,useOnboardingStateStore,featureToRef,@@ -213,7 +213,7 @@ interface LocalState {const OPEN_ISSUE_LIST_PAGE_SIZE = 10;const MAX_CLOSED_ISSUE = 5;-const environmentStore = useEnvironmentStore();+const environmentV1Store = useEnvironmentV1Store();const subscriptionStore = useSubscriptionStore();const onboardingStateStore = useOnboardingStateStore();const router = useRouter();@@ -244,19 +244,24 @@ const planImage = computed(() => {const selectedEnvironment = computed(() => {const { environment } = route.query;return environment- ? environmentStore.getEnvironmentById(parseInt(environment as string, 10))+ ? environmentV1Store.getEnvironmentByUID(+ parseInt(environment as string, 10)+ ): undefined;});const keywordAndEnvironmentFilter = (issue: Issue) => {if (selectedEnvironment.value &&- selectedEnvironment.value.id !== UNKNOWN_ID+ selectedEnvironment.value.uid !== String(UNKNOWN_ID)) {if (!isDatabaseRelatedIssueType(issue.type)) {return false;}- if (activeEnvironment(issue.pipeline).id !== selectedEnvironment.value.id) {+ if (+ String(activeEnvironment(issue.pipeline).id) !==+ selectedEnvironment.value.uid+ ) {return false;}}@@ -269,8 +274,8 @@ const keywordAndEnvironmentFilter = (issue: Issue) => {return true;};-const changeEnvironmentId = (environment: EnvironmentId | undefined) => {- if (environment && environment !== UNKNOWN_ID) {+const changeEnvironmentId = (environment: string | undefined) => {+ if (environment && environment !== String(UNKNOWN_ID)) {router.replace({name: "workspace.home",query: {diff --git a/frontend/src/views/InstanceDashboard.vue b/frontend/src/views/InstanceDashboard.vueindex 2058e5f8af..b213d7ab94 100644--- a/frontend/src/views/InstanceDashboard.vue+++ b/frontend/src/views/InstanceDashboard.vue@@ -7,15 +7,15 @@:description="instanceCountAttention"/><div class="px-5 py-2 flex justify-between items-center">- <!-- eslint-disable vue/attribute-hyphenation --><EnvironmentTabFilter- :selectedId="state.selectedEnvironment?.id"- @select-environment="selectEnvironment"+ :environment="state.selectedEnvironment?.uid ?? String(UNKNOWN_ID)"+ :include-all="true"+ @update:environment="selectEnvironment"/><BBTableSearchref="searchField":placeholder="$t('instance.search-instance-name')"- @change-text="(text) => changeSearchText(text)"+ @change-text="(text: string) => changeSearchText(text)"/></div><InstanceTable :instance-list="filteredList(instanceList)" />@@ -25,20 +25,22 @@<script lang="ts">import { computed, onMounted, reactive, ref, defineComponent } from "vue";import { useRouter } from "vue-router";-import EnvironmentTabFilter from "../components/EnvironmentTabFilter.vue";-import InstanceTable from "../components/InstanceTable.vue";-import { Environment, Instance } from "../types";import { cloneDeep } from "lodash-es";-import { sortInstanceList } from "../utils";import { useI18n } from "vue-i18n";++import { EnvironmentTabFilter } from "@/components/v2";+import InstanceTable from "../components/InstanceTable.vue";+import { Instance, UNKNOWN_ID } from "../types";+import { sortInstanceListByEnvironmentV1 } from "../utils";import {useUIStateStore,useSubscriptionStore,- useEnvironmentStore,- useEnvironmentList,+ useEnvironmentV1Store,useInstanceList,useInstanceStore,+ useEnvironmentV1List,} from "@/store";+import { Environment } from "@/types/proto/v1/environment_service";interface LocalState {searchText: string;@@ -60,13 +62,13 @@ export default defineComponent({const router = useRouter();const { t } = useI18n();- const environmentList = useEnvironmentList(["NORMAL"]);+ const environmentList = useEnvironmentV1List(false /* !showDeleted */);const state = reactive<LocalState>({searchText: "",selectedEnvironment: router.currentRoute.value.query.environment- ? useEnvironmentStore().getEnvironmentById(- parseInt(router.currentRoute.value.query.environment as string, 10)+ ? useEnvironmentV1Store().getEnvironmentByUID(+ router.currentRoute.value.query.environment as string): undefined,});@@ -83,14 +85,16 @@ export default defineComponent({}});- const selectEnvironment = (environment: Environment) => {- state.selectedEnvironment = environment;- if (environment) {+ const selectEnvironment = (environmentId: string | undefined) => {+ if (environmentId && environmentId !== String(UNKNOWN_ID)) {router.replace({name: "workspace.instance",- query: { environment: environment.id },+ query: { environment: environmentId },});+ state.selectedEnvironment =+ useEnvironmentV1Store().getEnvironmentByUID(environmentId);} else {+ state.selectedEnvironment = undefined;router.replace({ name: "workspace.instance" });}};@@ -102,27 +106,27 @@ export default defineComponent({const rawInstanceList = useInstanceList();const instanceList = computed(() => {- return sortInstanceList(+ return sortInstanceListByEnvironmentV1(cloneDeep(rawInstanceList.value),environmentList.value);});const filteredList = (list: Instance[]) => {- if (!state.selectedEnvironment && !state.searchText) {- // Select "All"- return list;+ const environment = state.selectedEnvironment;+ if (environment && environment.uid !== String(UNKNOWN_ID)) {+ list = list.filter(+ (instance) => String(instance.environment.id) === environment.uid+ );}- return list.filter((instance) => {- return (- (!state.selectedEnvironment ||- instance.environment.id == state.selectedEnvironment.id) &&- (!state.searchText ||- instance.name- .toLowerCase()- .includes(state.searchText.toLowerCase()))++ const keyword = state.searchText.trim().toLowerCase();+ if (keyword) {+ list = list.filter((instance) =>+ instance.name.toLowerCase().includes(keyword));- });+ }+ return list;};const instanceQuota = computed((): number => {@@ -157,6 +161,7 @@ export default defineComponent({});return {+ UNKNOWN_ID,searchField,state,instanceList,diff --git a/frontend/src/views/IssueDashboard.vue b/frontend/src/views/IssueDashboard.vueindex 30f10db594..8423a6d670 100644--- a/frontend/src/views/IssueDashboard.vue+++ b/frontend/src/views/IssueDashboard.vue@@ -3,7 +3,7 @@<div class="px-4 py-2 flex justify-between items-center"><EnvironmentTabFilter:include-all="true"- :environment="selectedEnvironment?.id ?? UNKNOWN_ID"+ :environment="selectedEnvironment?.uid ?? String(UNKNOWN_ID)"@update:environment="changeEnvironmentId($event)"/><div class="flex flex-row space-x-4">@@ -98,8 +98,6 @@ import {} from "@/components/v2";import { IssueTable } from "../components/Issue";import {- type Environment,- type EnvironmentId,type Issue,type PrincipalId,type ProjectId,@@ -113,10 +111,11 @@ import {} from "../utils";import {useCurrentUser,- useEnvironmentStore,+ useEnvironmentV1Store,useProjectV1Store,} from "@/store";import PagedIssueTable from "@/components/Issue/table/PagedIssueTable.vue";+import { Environment } from "@/types/proto/v1/environment_service";interface LocalState {searchText: string;@@ -127,7 +126,7 @@ const route = useRoute();const currentUser = useCurrentUser();const projectV1Store = useProjectV1Store();-const environmentStore = useEnvironmentStore();+const environmentV1Store = useEnvironmentV1Store();const statusList = computed((): string[] =>route.query.status ? (route.query.status as string).split(",") : []@@ -188,7 +187,7 @@ const selectedPrincipalId = computed((): PrincipalId => {const selectedEnvironment = computed((): Environment | undefined => {const { environment } = route.query;return environment- ? environmentStore.getEnvironmentById(parseInt(environment as string, 10))+ ? environmentV1Store.getEnvironmentByUID(environment as string): undefined;});@@ -202,7 +201,10 @@ const filter = (issue: Issue) => {if (!isDatabaseRelatedIssueType(issue.type)) {return false;}- if (activeEnvironment(issue.pipeline).id !== selectedEnvironment.value.id) {+ if (+ String(activeEnvironment(issue.pipeline).id) !==+ selectedEnvironment.value.uid+ ) {return false;}}@@ -215,8 +217,8 @@ const filter = (issue: Issue) => {return true;};-const changeEnvironmentId = (environment: EnvironmentId | undefined) => {- if (environment && environment !== UNKNOWN_ID) {+const changeEnvironmentId = (environment: string | undefined) => {+ if (environment && environment !== String(UNKNOWN_ID)) {router.replace({name: "workspace.issue",query: {diff --git a/frontend/src/views/ProjectDetail.vue b/frontend/src/views/ProjectDetail.vueindex 396a30970b..8c95cb581d 100644--- a/frontend/src/views/ProjectDetail.vue+++ b/frontend/src/views/ProjectDetail.vue@@ -57,7 +57,7 @@ import { cloneDeep } from "lodash-es";import { useRoute } from "vue-router";import { DEFAULT_PROJECT_ID } from "@/types";-import { idFromSlug, sortDatabaseList } from "../utils";+import { idFromSlug, sortDatabaseListByEnvironmentV1 } from "../utils";import ProjectActivityPanel from "../components/ProjectActivityPanel.vue";import ProjectMigrationHistoryPanel from "../components/ProjectMigrationHistoryPanel.vue";import ProjectSlowQueryPanel from "../components/ProjectSlowQueryPanel.vue";@@ -69,7 +69,7 @@ import ProjectSettingPanel from "../components/ProjectSettingPanel.vue";import ProjectDeploymentConfigPanel from "../components/ProjectDeploymentConfigPanel.vue";import {useDatabaseStore,- useEnvironmentList,+ useEnvironmentV1List,useProjectStore,useProjectV1Store,} from "@/store";@@ -116,7 +116,7 @@ export default defineComponent({return projectV1Store.getProjectByUID(idFromSlug(props.projectSlug));});- const environmentList = useEnvironmentList(["NORMAL"]);+ const environmentList = useEnvironmentV1List(false /* !showDeleted */);const prepareDatabaseList = () => {databaseStore.fetchDatabaseListByProjectId(project.value.id);@@ -130,7 +130,7 @@ export default defineComponent({.getDatabaseListByProjectId(project.value.id).filter((db) => db.syncStatus === "OK"));- return sortDatabaseList(list, environmentList.value);+ return sortDatabaseListByEnvironmentV1(list, environmentList.value);});const isTenantProject = computed(() => {diff --git a/frontend/src/views/SettingWorkspaceSQLReviewDetail.vue b/frontend/src/views/SettingWorkspaceSQLReviewDetail.vueindex 25d06b14e0..ba491b3646 100644--- a/frontend/src/views/SettingWorkspaceSQLReviewDetail.vue+++ b/frontend/src/views/SettingWorkspaceSQLReviewDetail.vue@@ -24,10 +24,9 @@:can-remove="false":link="`/environment/${reviewPolicy.environment.uid}`">- {{ environmentTitleV1(reviewPolicy.environment) }}- <ProductionEnvironmentIcon- :tier="environmentTierToJSON(reviewPolicy.environment.tier)"- class="!text-current ml-1"+ <EnvironmentV1Name+ :environment="reviewPolicy.environment"+ :link="false"/></BBBadge><div@@ -151,6 +150,8 @@import { computed, reactive, toRef, watch } from "vue";import { useI18n } from "vue-i18n";import { useRouter } from "vue-router";+import { cloneDeep } from "lodash-es";+import { idFromSlug, hasWorkspacePermission } from "@/utils";import {unknown,@@ -178,11 +179,8 @@ import {useSQLRuleFilter,SQLRuleTable,} from "../components/SQLReview/components";-import ProductionEnvironmentIcon from "@/components/Environment/ProductionEnvironmentIcon.vue";+import { EnvironmentV1Name } from "@/components/v2";import { PayloadValueType } from "@/components/SQLReview/components/RuleConfigComponents";-import { cloneDeep } from "lodash-es";-import { environmentTierToJSON } from "@/types/proto/v1/environment_service";-import { environmentTitleV1 } from "@/utils";const props = defineProps({sqlReviewPolicySlug: {diff --git a/frontend/src/views/SlowQuery/utils.ts b/frontend/src/views/SlowQuery/utils.tsindex c23e7f3a98..c59145bba6 100644--- a/frontend/src/views/SlowQuery/utils.ts+++ b/frontend/src/views/SlowQuery/utils.ts@@ -6,7 +6,7 @@ import {} from "@/components/SlowQuery";import {useDatabaseStore,- useEnvironmentStore,+ useEnvironmentV1Store,useInstanceStore,useProjectStore,} from "@/store";@@ -16,8 +16,8 @@ export const wrapQueryFromFilterParams = (params: SlowQueryFilterParams) => {if (params.project && params.project.id !== UNKNOWN_ID) {query.project = params.project.id;}- if (params.environment && params.environment.id !== UNKNOWN_ID) {- query.environment = params.environment.id;+ if (params.environment && params.environment.uid !== String(UNKNOWN_ID)) {+ query.environment = params.environment.uid;}if (params.instance && params.instance.id !== UNKNOWN_ID) {query.instance = params.instance.id;@@ -47,9 +47,9 @@ export const extractSlowQueryLogFilterFromQuery = async () => {const params: SlowQueryFilterParams = defaultSlowQueryFilterParams();if (query.environment) {- const id = parseInt(query.environment as string, 10) ?? UNKNOWN_ID;- const environment = useEnvironmentStore().getEnvironmentById(id);- if (environment && environment.id !== UNKNOWN_ID) {+ const id = (query.environment as string) ?? String(UNKNOWN_ID);+ const environment = useEnvironmentV1Store().getEnvironmentByUID(id);+ if (environment && environment.uid !== String(UNKNOWN_ID)) {params.environment = environment;}}diff --git a/frontend/src/views/SyncDatabaseSchema/SelectTargetDatabasesView.vue b/frontend/src/views/SyncDatabaseSchema/SelectTargetDatabasesView.vueindex bbf80805e9..14fe3cb0bd 100644--- a/frontend/src/views/SyncDatabaseSchema/SelectTargetDatabasesView.vue+++ b/frontend/src/views/SyncDatabaseSchema/SelectTargetDatabasesView.vue@@ -15,8 +15,8 @@<span>{{ $t("common.environment") }} - </span><aclass="normal-link inline-flex items-center"- :href="`/environment#${environment.id}`"- >{{ environment.name }}</a+ :href="`/environment#${environment.uid}`"+ >{{ environment.title }}</a></div></div>@@ -191,7 +191,7 @@<TargetDatabasesSelectPanelv-if="state.showSelectDatabasePanel":project-id="projectId"- :environment-id="sourceSchema.environmentId"+ :environment-id="String(sourceSchema.environmentId)":database-id="sourceSchema.databaseId":selected-database-id-list="state.selectedDatabaseIdList"@close="state.showSelectDatabasePanel = false"@@ -209,7 +209,7 @@ import { useI18n } from "vue-i18n";import {pushNotification,useDatabaseStore,- useEnvironmentStore,+ useEnvironmentV1Store,useProjectStore,} from "@/store";import {@@ -253,7 +253,7 @@ const props = defineProps({const { t } = useI18n();const projectStore = useProjectStore();-const environmentStore = useEnvironmentStore();+const environmentV1Store = useEnvironmentV1Store();const databaseStore = useDatabaseStore();const diffViewerRef = ref<HTMLDivElement>();const state = reactive<LocalState>({@@ -278,7 +278,9 @@ const project = computed(() => {return projectStore.getProjectById(props.projectId);});const environment = computed(() => {- return environmentStore.getEnvironmentById(props.sourceSchema.environmentId);+ return environmentV1Store.getEnvironmentByUID(+ props.sourceSchema.environmentId+ );});const sourceDatabase = computed(() => {return databaseStore.getDatabaseById(props.sourceSchema.databaseId);diff --git a/frontend/src/views/SyncDatabaseSchema/TargetDatabasesSelectPanel.vue b/frontend/src/views/SyncDatabaseSchema/TargetDatabasesSelectPanel.vueindex 0c00e5891d..4649d4b432 100644--- a/frontend/src/views/SyncDatabaseSchema/TargetDatabasesSelectPanel.vue+++ b/frontend/src/views/SyncDatabaseSchema/TargetDatabasesSelectPanel.vue@@ -21,7 +21,7 @@class="overflow-y-auto"arrow-placement="left":default-expanded-names="- databaseListGroupByEnvironment.map((group) => group.environment.id)+ databaseListGroupByEnvironment.map((group) => group.environment.uid)"><NCollapseItem@@ -29,8 +29,8 @@environment,databaseList: databaseListInEnvironment,} in databaseListGroupByEnvironment"- :key="environment.id"- :name="environment.id"+ :key="environment.uid"+ :name="environment.uid"><template #header><label class="flex items-center gap-x-2" @click.stop="">@@ -52,11 +52,7 @@)"/>- <div>{{ environment.name }}</div>- <ProductionEnvironmentIcon- class="w-4 h-4 -ml-1"- :environment="environment"- />+ <EnvironmentV1Name :environment="environment" :link="false" /></label></template>@@ -127,6 +123,7 @@</template><script setup lang="ts">+import { computed, reactive, PropType } from "vue";import {NCollapse,NCollapseItem,@@ -134,15 +131,10 @@ import {NDrawer,NDrawerContent,} from "naive-ui";-import { computed, reactive, PropType } from "vue";-import { useDatabaseStore, useEnvironmentStore } from "@/store";-import {- Database,- DatabaseId,- Environment,- EnvironmentId,- ProjectId,-} from "@/types";+import { useDatabaseStore, useEnvironmentV1Store } from "@/store";+import { Database, DatabaseId, ProjectId } from "@/types";+import { Environment } from "@/types/proto/v1/environment_service";+import { EnvironmentV1Name } from "@/components/v2";type LocalState = {searchText: string;@@ -155,7 +147,7 @@ const props = defineProps({required: true,},environmentId: {- type: Number as PropType<EnvironmentId>,+ type: String,required: true,},databaseId: {@@ -173,7 +165,7 @@ const emit = defineEmits<{(event: "update", databaseIdList: DatabaseId[]): void;}>();-const environmentStore = useEnvironmentStore();+const environmentV1Store = useEnvironmentV1Store();const databaseStore = useDatabaseStore();const state = reactive<LocalState>({searchText: "",@@ -194,9 +186,9 @@ const databaseListGroupByEnvironment = computed(() => {.filter((db) => db.instance.engine === sourceDatabase.value.instance.engine) || [];- const listByEnv = environmentStore.environmentList.map((environment) => {+ const listByEnv = environmentV1Store.environmentList.map((environment) => {const list = databaseList.filter(- (db) => db.instance.environment.id === environment.id+ (db) => String(db.instance.environment.id) === environment.uid);return {environment,@@ -235,7 +227,7 @@ const toggleAllDatabasesSelectionForEnvironment = (on: boolean) => {databaseList- .filter((db) => db.instance.environment.id === environment.id)+ .filter((db) => String(db.instance.environment.id) === environment.uid).forEach((db) => toggleDatabaseSelected(db.id, on));};@@ -245,7 +237,7 @@ const getAllSelectionStateForEnvironment = (): { checked: boolean; indeterminate: boolean } => {const set = new Set(state.selectedDatabaseList- .filter((db) => db.instance.environment.id === environment.id)+ .filter((db) => String(db.instance.environment.id) === environment.uid).map((db) => db.id));const checked = databaseList.every((db) => set.has(db.id));@@ -263,7 +255,7 @@ const getSelectionStateSummaryForEnvironment = () => {const set = new Set(state.selectedDatabaseList- .filter((db) => db.instance.environment.id === environment.id)+ .filter((db) => String(db.instance.environment.id) === environment.uid).map((db) => db.id));const selected = databaseList.filter((db) => set.has(db.id)).length;