Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat: support catalog with object schema (#15629)
ecmadao05e7a1b2a7ac
diff --git a/frontend/src/components/ColumnDataTable/SemanticTypeCell.vue b/frontend/src/components/ColumnDataTable/SemanticTypeCell.vueindex 8ea27a488b..625012fa92 100644--- a/frontend/src/components/ColumnDataTable/SemanticTypeCell.vue+++ b/frontend/src/components/ColumnDataTable/SemanticTypeCell.vue@@ -49,7 +49,6 @@ import { useSubscriptionV1Store } from "@/store";import type { ComposedDatabase } from "@/types";import FeatureModal from "../FeatureGuard/FeatureModal.vue";import SemanticTypesDrawer from "../SensitiveData/components/SemanticTypesDrawer.vue";-import { updateColumnCatalog } from "./utils";type LocalState = {showFeatureModal: boolean;@@ -57,24 +56,23 @@ type LocalState = {};const props = defineProps<{+ semanticTypeId: string;database: ComposedDatabase;- schema: string;- table: string;- column: string;readonly?: boolean;}>();+const emit = defineEmits<{+ (event: "apply", id: string): Promise<void>;+}>();+const state = reactive<LocalState>({showFeatureModal: false,showSemanticTypesDrawer: false,});const subscriptionV1Store = useSubscriptionV1Store();-const { semanticType, semanticTypeList } = useSemanticType({- database: props.database.name,- schema: props.schema,- table: props.table,- column: props.column,-});+const { semanticType, semanticTypeList } = useSemanticType(+ computed(() => props.semanticTypeId)+);const hasSensitiveDataFeature = computed(() => {return subscriptionV1Store.hasFeature("bb.feature.sensitive-data");@@ -97,13 +95,6 @@ const openSemanticTypeDrawer = () => {};const onSemanticTypeApply = async (semanticType: string) => {- await updateColumnCatalog({- database: props.database.name,- schema: props.schema,- table: props.table,- column: props.column,- columnCatalog: { semanticType },- notification: !semanticType ? "common.removed" : undefined,- });+ await emit("apply", semanticType);};</script>diff --git a/frontend/src/components/ColumnDataTable/index.vue b/frontend/src/components/ColumnDataTable/index.vueindex cd9d5049a1..8e58f6d25d 100644--- a/frontend/src/components/ColumnDataTable/index.vue+++ b/frontend/src/components/ColumnDataTable/index.vue@@ -149,12 +149,17 @@ const columns = computed(() => {resizable: true,width: 140,render: (column) => {+ const columnCatalog = getColumnCatalog(+ databaseCatalog.value,+ props.schema,+ props.table.name,+ column.name+ );return h(SemanticTypeCell, {database: props.database,- schema: props.schema,- table: props.table.name,- column: column.name,+ semanticTypeId: columnCatalog.semanticType,readonly: !hasDatabaseCatalogPermission.value,+ onApply: (id: string) => onSemanticTypeApply(column.name, id),});},},@@ -290,4 +295,15 @@ const onClassificationIdApply = async (notification: !classification ? "common.removed" : undefined,});};++const onSemanticTypeApply = async (column: string, semanticType: string) => {+ await updateColumnCatalog({+ database: props.database.name,+ schema: props.schema,+ table: props.table.name,+ column,+ columnCatalog: { semanticType },+ notification: !semanticType ? "common.removed" : undefined,+ });+};</script>diff --git a/frontend/src/components/Database/DatabaseOverviewInfo.vue b/frontend/src/components/Database/DatabaseOverviewInfo.vueindex d3c2dcb2ec..ce43246bae 100644--- a/frontend/src/components/Database/DatabaseOverviewInfo.vue+++ b/frontend/src/components/Database/DatabaseOverviewInfo.vue@@ -3,13 +3,7 @@class="grid grid-cols-1 gap-x-4 gap-y-4 sm:grid-cols-2"data-label="bb-database-overview-description-list">- <template- v-if="- databaseEngine !== Engine.CLICKHOUSE &&- databaseEngine !== Engine.SNOWFLAKE &&- databaseEngine !== Engine.MONGODB- "- >+ <template v-if="instanceV1HasCollationAndCharacterSet(databaseEngine)"><div class="col-span-1 col-start-1"><dt class="text-sm font-medium text-control-light">{{@@ -60,6 +54,7 @@ import { computed } from "vue";import { useDBSchemaV1Store } from "@/store";import { getDateForPbTimestamp, type ComposedDatabase } from "@/types";import { Engine, State } from "@/types/proto/v1/common";+import { instanceV1HasCollationAndCharacterSet } from "@/utils";const props = defineProps<{database: ComposedDatabase;diff --git a/frontend/src/components/Database/DatabaseSensitiveDataPanel.vue b/frontend/src/components/Database/DatabaseSensitiveDataPanel.vueindex aafcc1e5d5..fb2d114cb8 100644--- a/frontend/src/components/Database/DatabaseSensitiveDataPanel.vue+++ b/frontend/src/components/Database/DatabaseSensitiveDataPanel.vue@@ -8,34 +8,37 @@class="flex flex-col space-x-2 lg:flex-row gap-y-4 justify-between items-end lg:items-center"><SearchBox v-model:value="state.searchText" style="max-width: 100%" />- <div class="flex items-center space-x-2">- <NButton- type="primary"- :disabled="- state.pendingGrantAccessColumn.length === 0 ||- !hasPolicyPermission ||- !hasGetCatalogPermission- "- @click="onGrantAccessButtonClick"- >- <template #icon>- <ShieldCheckIcon v-if="hasSensitiveDataFeature" class="w-4" />- <FeatureBadge- v-else- feature="bb.feature.sensitive-data"- custom-class="text-white"- />- </template>- {{ $t("settings.sensitive-data.grant-access") }}- </NButton>- </div>+ <NButton+ v-if="!isMaskingForNoSQL"+ type="primary"+ :disabled="+ state.pendingGrantAccessColumn.length === 0 ||+ !hasPolicyPermission ||+ !hasGetCatalogPermission+ "+ @click="onGrantAccessButtonClick"+ >+ <template #icon>+ <ShieldCheckIcon v-if="hasSensitiveDataFeature" class="w-4" />+ <FeatureBadge+ v-else+ feature="bb.feature.sensitive-data"+ custom-class="text-white"+ />+ </template>+ {{ $t("settings.sensitive-data.grant-access") }}+ </NButton></div><SensitiveColumnTable:database="database":row-clickable="false"- :row-selectable="true"- :show-operation="hasUpdateCatalogPermission && hasSensitiveDataFeature"+ :row-selectable="!isMaskingForNoSQL"+ :show-operation="+ hasUpdateCatalogPermission &&+ hasSensitiveDataFeature &&+ !isMaskingForNoSQL+ ":column-list="filteredColumnList":checked-column-index-list="checkedColumnIndexList"@delete="onColumnRemove"@@ -92,8 +95,12 @@ import {useDatabaseCatalog,} from "@/store";import { type ComposedDatabase } from "@/types";+import {+ ObjectSchema_Type,+ type ObjectSchema,+} from "@/types/proto/v1/database_catalog_service";import { PolicyType } from "@/types/proto/v1/org_policy_service";-import { hasProjectPermissionV2 } from "@/utils";+import { hasProjectPermissionV2, instanceV1MaskingForNoSQL } from "@/utils";const props = defineProps<{database: ComposedDatabase;@@ -103,7 +110,7 @@ interface LocalState {searchText: string;showFeatureModal: boolean;isLoading: boolean;- sensitiveColumnList: MaskData[];+ sensitiveList: MaskData[];pendingGrantAccessColumn: MaskData[];showGrantAccessDrawer: boolean;}@@ -112,11 +119,15 @@ const state = reactive<LocalState>({searchText: "",showFeatureModal: false,isLoading: false,- sensitiveColumnList: [],+ sensitiveList: [],pendingGrantAccessColumn: [],showGrantAccessDrawer: false,});+const isMaskingForNoSQL = computed(() =>+ instanceV1MaskingForNoSQL(props.database.instanceResource)+);+const hasUpdateCatalogPermission = computed(() => {return hasProjectPermissionV2(props.database.projectEntity,@@ -152,9 +163,48 @@ const isMissingLicenseForInstance = computed(() =>const databaseCatalog = useDatabaseCatalog(props.database.name, false);+const flattenObjectSchema = (+ parentPath: string,+ objectSchema: ObjectSchema+): {+ column: string;+ semanticTypeId: string;+ target: ObjectSchema;+}[] => {+ switch (objectSchema.type) {+ case ObjectSchema_Type.OBJECT:+ const resp = [];+ for (const [key, schema] of Object.entries(+ objectSchema.structKind?.properties ?? {}+ )) {+ resp.push(+ ...flattenObjectSchema(+ [parentPath, key].filter((i) => i).join("."),+ schema+ )+ );+ }+ return resp;+ case ObjectSchema_Type.ARRAY:+ if (!objectSchema.arrayKind?.kind) {+ return [];+ }+ // TODO(ed): Currently, the object schemas of the element in array are the same.+ return flattenObjectSchema(parentPath, objectSchema.arrayKind?.kind);+ default:+ return [+ {+ column: parentPath,+ semanticTypeId: objectSchema.semanticType,+ target: objectSchema,+ },+ ];+ }+};+const updateList = async () => {state.isLoading = true;- const sensitiveColumnList: MaskData[] = [];+ const sensitiveList: MaskData[] = [];for (const schema of databaseCatalog.value.schemas) {for (const table of schema.tables) {@@ -162,25 +212,53 @@ const updateList = async () => {if (!column.semanticType && !column.classification) {continue;}- sensitiveColumnList.push({+ sensitiveList.push({schema: schema.name,table: table.name,column: column.name,semanticTypeId: column.semanticType,classificationId: column.classification,+ target: column,+ });+ }++ if (table.objectSchema) {+ const flattenItems = flattenObjectSchema("", table.objectSchema);+ sensitiveList.push(+ ...flattenItems.map((item) => ({+ ...item,+ schema: schema.name,+ table: table.name,+ classificationId: "",+ // TODO(ed/zp/danny): can we support classification for object schema?+ disableClassification: true,+ }))+ );+ }++ if (table.classification) {+ sensitiveList.push({+ schema: schema.name,+ table: table.name,+ column: "",+ semanticTypeId: "",+ // TODO(ed/zp/danny): can we support senamtic type for table catalog?+ disableSemanticType: true,+ classificationId: table.classification,+ target: table,});}}}- state.sensitiveColumnList = sensitiveColumnList;+ state.sensitiveList = sensitiveList;state.isLoading = false;};watch(databaseCatalog, updateList, { immediate: true, deep: true });const filteredColumnList = computed(() => {- let list = state.sensitiveColumnList;+ let list = state.sensitiveList;const searchText = state.searchText.trim().toLowerCase();if (searchText) {list = list.filter(diff --git a/frontend/src/components/IndexTable.vue b/frontend/src/components/IndexTable.vueindex a0079c6c00..325800be4f 100644--- a/frontend/src/components/IndexTable.vue+++ b/frontend/src/components/IndexTable.vue@@ -41,7 +41,7 @@<BBTableCell v-if="showVisibleColumn">{{ index.visible }}</BBTableCell>- <BBTableCell>+ <BBTableCell v-if="showCommentColumn">{{ index.comment }}</BBTableCell></template>diff --git a/frontend/src/components/SensitiveData/components/SensitiveColumnTable.vue b/frontend/src/components/SensitiveData/components/SensitiveColumnTable.vueindex f7c7d4f75d..2841cbfcc4 100644--- a/frontend/src/components/SensitiveData/components/SensitiveColumnTable.vue+++ b/frontend/src/components/SensitiveData/components/SensitiveColumnTable.vue@@ -22,6 +22,8 @@ import { updateColumnCatalog } from "@/components/ColumnDataTable/utils";import type { MaskData } from "@/components/SensitiveData/types";import { MiniActionButton } from "@/components/v2";import {+ pushNotification,+ useDatabaseCatalogV1Store,useSettingV1Store,useDatabaseCatalog,getColumnCatalog,@@ -50,6 +52,7 @@ const checkedColumnIndex = ref<Set<number>>(new Set(props.checkedColumnIndexList));const settingStore = useSettingV1Store();+const dbCatalogStore = useDatabaseCatalogV1Store();watch(() => props.columnList,@@ -127,7 +130,7 @@ const dataTableColumns = computed(() => {resizable: true,width: "minmax(min-content, auto)",render(item) {- return item.column;+ return item.column || "-";},},{@@ -139,10 +142,9 @@ const dataTableColumns = computed(() => {return (<SemanticTypeCelldatabase={props.database}- schema={item.schema}- table={item.table}- column={item.column}- readonly={!props.showOperation}+ semanticTypeId={item.semanticTypeId}+ readonly={!props.showOperation || item.disableSemanticType}+ onApply={(id: string) => onSemanticTypeApply(item, id)}/>);},@@ -164,7 +166,7 @@ const dataTableColumns = computed(() => {<ClassificationCellclassification={columnCatalog.classification}classificationConfig={classificationConfig.value}- readonly={!props.showOperation}+ readonly={!props.showOperation || item.disableClassification}onApply={(id: string) => onClassificationIdApply(item, id)}/>);@@ -226,6 +228,18 @@ const dataTableColumns = computed(() => {return columns;});+const onSemanticTypeApply = async (item: MaskData, semanticType: string) => {+ // TODO(ed): dirty but works.+ (item.target as any).semanticType = semanticType;+ await dbCatalogStore.updateDatabaseCatalog(databaseCatalog.value);++ pushNotification({+ module: "bytebase",+ style: "SUCCESS",+ title: t("common.updated"),+ });+};+const onClassificationIdApply = async (item: MaskData,classification: stringdiff --git a/frontend/src/components/SensitiveData/types.ts b/frontend/src/components/SensitiveData/types.tsindex b5f19dbf83..1967505701 100644--- a/frontend/src/components/SensitiveData/types.ts+++ b/frontend/src/components/SensitiveData/types.ts@@ -1,14 +1,22 @@import type { ComposedDatabase, DatabaseResource } from "@/types";-import { type User } from "@/types/proto/v1/user_service";+import type {+ TableCatalog,+ ColumnCatalog,+ ObjectSchema,+} from "@/types/proto/v1/database_catalog_service";import type { Group } from "@/types/proto/v1/group_service";import type { MaskingExceptionPolicy_MaskingException_Action } from "@/types/proto/v1/org_policy_service";+import { type User } from "@/types/proto/v1/user_service";export interface MaskData {schema: string;table: string;column: string;+ disableSemanticType?: boolean;semanticTypeId: string;+ disableClassification?: boolean;classificationId: string;+ target: TableCatalog | ColumnCatalog | ObjectSchema;}export interface SensitiveColumn {diff --git a/frontend/src/components/SensitiveData/useSemanticType.ts b/frontend/src/components/SensitiveData/useSemanticType.tsindex 42c5b75558..7f90bb4fd0 100644--- a/frontend/src/components/SensitiveData/useSemanticType.ts+++ b/frontend/src/components/SensitiveData/useSemanticType.ts@@ -1,17 +1,7 @@-import { computed } from "vue";-import { useSettingV1Store, useDatabaseCatalog, getColumnCatalog } from "@/store";+import { computed, unref, type MaybeRef } from "vue";+import { useSettingV1Store } from "@/store";-export const useSemanticType = ({- database,- schema,- table,- column,-}: {- database: string;- schema: string;- table: string;- column: string;-}) => {+export const useSemanticType = (semanticTypeId: MaybeRef<string>) => {const settingV1Store = useSettingV1Store();const semanticTypeList = computed(() => {@@ -21,16 +11,12 @@ export const useSemanticType = ({);});- const databaseCatalog = useDatabaseCatalog(database, false);-const semanticType = computed(() => {- const columnCatalog = getColumnCatalog(databaseCatalog.value, schema, table, column)- if (!columnCatalog.semanticType) {+ const id = unref(semanticTypeId);+ if (!id) {return;}- return semanticTypeList.value.find(- (data) => data.id === columnCatalog.semanticType- );+ return semanticTypeList.value.find((data) => data.id === id);});return {diff --git a/frontend/src/components/TableDataTable.vue b/frontend/src/components/TableDataTable.vueindex 26c44d2d2d..3b834eee33 100644--- a/frontend/src/components/TableDataTable.vue+++ b/frontend/src/components/TableDataTable.vue@@ -18,6 +18,10 @@:schema-name="schemaName":table-name="state.selectedTableName ?? ''":classification-config="classificationConfig"+ :allow-set-classification="!setClassificationFromComment"+ @apply-classification="+ (table: string, id: string) => onClassificationIdApply(table, id)+ "@dismiss="state.selectedTableName = undefined"/></template>diff --git a/frontend/src/components/TableDetailDrawer.vue b/frontend/src/components/TableDetailDrawer.vueindex 3824752f71..c853927f29 100644--- a/frontend/src/components/TableDetailDrawer.vue+++ b/frontend/src/components/TableDetailDrawer.vue@@ -122,10 +122,14 @@{{ $t("database.classification.self") }}</dt><dd class="mt-1 flex flex-row items-center">- <ClassificationLevelBadge+ <ClassificationCell:classification="tableCatalog.classification":classification-config="classificationConfig"- placeholder="-"+ :readonly="!allowSetClassification"+ @apply="+ (id: string) =>+ $emit('apply-classification', tableName, id)+ "/></dd></div>@@ -160,7 +164,9 @@</dd></div>- <template v-if="hasCollationProperty(instanceEngine)">+ <template+ v-if="instanceV1HasCollationAndCharacterSet(instanceEngine)"+ ><div class="col-span-1"><dt class="text-sm font-medium text-control-light">{{ $t("db.collation") }}@@ -193,8 +199,11 @@/></div>- <div v-if="shouldShowColumnTable" class="mt-6 px-6">- <div class="mb-4 w-full flex flex-row justify-between items-center">+ <div+ v-if="instanceV1SupportsColumn(instanceEngine)"+ class="mt-6 px-6 space-y-4"+ >+ <div class="w-full flex flex-row justify-between items-center"><div class="text-lg leading-6 font-medium text-main">{{ $t("database.columns") }}</div>@@ -218,8 +227,11 @@/></div>- <div v-if="instanceEngine !== Engine.SNOWFLAKE" class="mt-6 px-6">- <div class="text-lg leading-6 font-medium text-main mb-4">+ <div+ v-if="instanceV1SupportsIndex(instanceEngine)"+ class="mt-6 px-6 space-y-4"+ >+ <div class="text-lg leading-6 font-medium text-main">{{ $t("database.indexes") }}</div><IndexTable :database="database" :index-list="table.indexes" />@@ -227,9 +239,9 @@<divv-if="instanceV1SupportsTrigger(instanceEngine)"- class="mt-6 px-6"+ class="mt-6 px-6 space-y-4">- <div class="text-lg leading-6 font-medium text-main mb-4">+ <div class="text-lg leading-6 font-medium text-main">{{ $t("db.triggers") }}</div><TriggerDataTable@@ -239,6 +251,49 @@:trigger-list="table.triggers"/></div>++ <div+ v-if="instanceV1MaskingForNoSQL(instanceEngine)"+ class="mt-6 px-6 space-y-4"+ >+ <div>+ <div class="text-lg leading-6 font-medium text-main">+ {{ $t("common.catalog") }}+ </div>+ <span class="text-sm text-gray-400 -translate-y-2">+ {{ $t("db.catalog.description") }}+ <a+ href="https://api.bytebase.com/#tag/databasecatalogservice/PATCH/v1/instances/{instance}/databases/{database}/catalog"+ target="__blank"+ class="normal-link"+ >+ {{ $t("common.view-doc") }}+ </a>+ </span>+ </div>+ <NInput+ type="textarea"+ :autosize="{+ minRows: 15,+ maxRows: 50,+ }"+ :disabled="!hasDatabaseCatalogPermission"+ :value="JSON.stringify(state.tableCatalog, null, 4)"+ @update:value="onCatalogChange"+ />+ <div+ v-if="!isEqual(state.tableCatalog, tableCatalog)"+ class="w-full flex items-center justify-end space-x-2 mt-2"+ >+ <NButton+ type="primary"+ :loading="state.isUploading"+ @click="onCatalogUpload"+ >+ {{ $t("common.upload") }}+ </NButton>+ </div>+ </div></main></div></DrawerContent>@@ -247,10 +302,12 @@<script lang="ts" setup>import { computedAsync } from "@vueuse/core";+import { cloneDeep, isEqual } from "lodash-es";import { CodeIcon } from "lucide-vue-next";-import { NButton, NPopover } from "naive-ui";-import { computed, reactive, ref } from "vue";-import ClassificationLevelBadge from "@/components/SchemaTemplate/ClassificationLevelBadge.vue";+import { NButton, NPopover, NInput } from "naive-ui";+import { computed, reactive, ref, watch } from "vue";+import { useI18n } from "vue-i18n";+import ClassificationCell from "@/components/ColumnDataTable/ClassificationCell.vue";import TableSchemaViewer from "@/components/TableSchemaViewer.vue";import {DatabaseV1Name,@@ -266,18 +323,29 @@ import {useDatabaseCatalog,useDBSchemaV1Store,getTableCatalog,+ pushNotification,+ useDatabaseCatalogV1Store,} from "@/store";import { DEFAULT_PROJECT_NAME, defaultProject } from "@/types";import { Engine } from "@/types/proto/v1/common";+import {+ TableCatalog,+ ObjectSchema,+ ObjectSchema_Type,+ ObjectSchema_StructKind,+} from "@/types/proto/v1/database_catalog_service";import type { DataClassificationSetting_DataClassificationConfig } from "@/types/proto/v1/setting_service";import {bytesToString,- hasCollationProperty,+ instanceV1HasCollationAndCharacterSet,hasIndexSizeProperty,hasProjectPermissionV2,hasSchemaProperty,hasTableEngineProperty,instanceV1SupportsTrigger,+ instanceV1SupportsColumn,+ instanceV1SupportsIndex,+ instanceV1MaskingForNoSQL,isDatabaseV1Queryable,supportGetStringSchema,} from "@/utils";@@ -291,6 +359,8 @@ import MaskSpinner from "./misc/MaskSpinner.vue";interface LocalState {columnNameSearchKeyword: string;partitionTableNameSearchKeyword: string;+ tableCatalog: TableCatalog;+ isUploading: boolean;}const props = defineProps<{@@ -299,18 +369,34 @@ const props = defineProps<{databaseName: string;schemaName: string;tableName: string;+ allowSetClassification: boolean;classificationConfig?: DataClassificationSetting_DataClassificationConfig;}>();-defineEmits(["dismiss"]);+defineEmits<{+ (event: "dismiss"): void;+ (event: "apply-classification", table: string, id: string): void;+}>();+const { t } = useI18n();const databaseV1Store = useDatabaseV1Store();const dbSchemaStore = useDBSchemaV1Store();+const catalogStore = useDatabaseCatalogV1Store();+const state = reactive<LocalState>({columnNameSearchKeyword: "",partitionTableNameSearchKeyword: "",+ tableCatalog: TableCatalog.fromPartial({+ name: props.tableName,+ objectSchema: ObjectSchema.fromPartial({+ type: ObjectSchema_Type.OBJECT,+ structKind: ObjectSchema_StructKind.fromPartial({}),+ }),+ }),+ isUploading: false,});const isFetchingTableMetadata = ref(false);+const table = computedAsync(async () => {const { databaseName, tableName, schemaName } = props;@@ -336,6 +422,85 @@ const tableCatalog = computed(() =>getTableCatalog(databaseCatalog.value, props.schemaName, props.tableName));+const hasDatabaseCatalogPermission = computed(() => {+ return hasProjectPermissionV2(+ database.value.projectEntity,+ "bb.databaseCatalogs.update"+ );+});++watch(+ () => tableCatalog.value,+ (catalog) => {+ if (catalog) {+ state.tableCatalog = cloneDeep(catalog);+ // clear+ state.tableCatalog.columns = undefined;+ if (!state.tableCatalog.objectSchema) {+ state.tableCatalog.objectSchema = ObjectSchema.fromPartial({+ type: ObjectSchema_Type.OBJECT,+ structKind: ObjectSchema_StructKind.fromPartial({}),+ });+ }+ }+ },+ { immediate: true, deep: true }+);++const onCatalogChange = (value: string) => {+ try {+ const catalog = JSON.parse(value) as TableCatalog;+ state.tableCatalog = catalog;+ } catch (e) {+ pushNotification({+ module: "bytebase",+ style: "WARN",+ title: t("common.warning"),+ description: `Failed to parse catalog with error: ${e}`,+ });+ }+};++const onCatalogUpload = async () => {+ if (state.tableCatalog.name !== props.tableName) {+ pushNotification({+ module: "bytebase",+ style: "CRITICAL",+ title: t("common.error"),+ description: `catalog name must be ${props.tableName}`,+ });+ return;+ }+ state.isUploading = true;++ try {+ const pendingUploadCatalog = cloneDeep(databaseCatalog.value);+ for (const schemaCatalog of pendingUploadCatalog.schemas) {+ if (schemaCatalog.name !== props.schemaName) {+ continue;+ }+ const index = schemaCatalog.tables.findIndex(+ (t) => t.name === props.tableName+ );+ if (index >= 0) {+ schemaCatalog.tables[index] = state.tableCatalog;+ } else {+ schemaCatalog.tables.push(state.tableCatalog);+ }+ break;+ }+ await catalogStore.updateDatabaseCatalog(pendingUploadCatalog);++ pushNotification({+ module: "bytebase",+ style: "SUCCESS",+ title: t("common.updated"),+ });+ } finally {+ state.isUploading = false;+ }+};+const database = computed(() => {return databaseV1Store.getDatabaseByName(props.databaseName);});@@ -364,10 +529,6 @@ const shouldShowPartitionTablesDataTable = computed(() => {return hasPartitionTables.value;});-const shouldShowColumnTable = computed(() => {- return instanceEngine.value !== Engine.MONGODB;-});-const getTableName = (tableName: string) => {if (hasSchemaProperty(instanceEngine.value) && props.schemaName) {return `"${props.schemaName}"."${tableName}"`;diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex 19a8505bfb..65ad89b248 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -1055,6 +1055,9 @@},"schema": {"default": "Default"+ },+ "catalog": {+ "description": "Edit and upload the table catalog."}},"instance": {diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex 5e655aaa2e..644394845a 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -1055,6 +1055,9 @@},"schema": {"default": "Por defecto"+ },+ "catalog": {+ "description": "Editar y cargar el catálogo de tablas."}},"instance": {diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex 85e8892dde..be32d6da04 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -1055,6 +1055,9 @@},"schema": {"default": "デフォルト"+ },+ "catalog": {+ "description": "テーブルカタログを編集してアップロードします。"}},"instance": {diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex c8ac060459..085bc0068b 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -1055,6 +1055,9 @@},"schema": {"default": "Mặc định"+ },+ "catalog": {+ "description": "Chỉnh sửa và tải lên danh mục bảng."}},"instance": {diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 1e01f96406..42e784420d 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -1055,6 +1055,9 @@},"schema": {"default": "默认"+ },+ "catalog": {+ "description": "编辑并上传表的 Catalog"}},"instance": {@@ -2595,4 +2598,4 @@"last-visit": "上次访问","changelog-for-version": "{version} 的更新日志"}-}\ No newline at end of file+}diff --git a/frontend/src/utils/v1/instance.ts b/frontend/src/utils/v1/instance.tsindex 15c4d0bbf0..6a9f751405 100644--- a/frontend/src/utils/v1/instance.ts+++ b/frontend/src/utils/v1/instance.ts@@ -149,15 +149,20 @@ export const instanceV1HasCreateDatabase = (instanceOrEngine: Instance | InstanceResource | Engine): boolean => {const engine = engineOfInstanceV1(instanceOrEngine);- if (engine === Engine.REDIS) return false;- if (engine === Engine.ORACLE) return false;- if (engine === Engine.DM) return false;- if (engine === Engine.ELASTICSEARCH) return false;- if (engine === Engine.SPANNER) return false;- if (engine === Engine.BIGQUERY) return false;- if (engine === Engine.DYNAMODB) return false;- if (engine == Engine.DATABRICKS) return false;- return true;++ const excludedList: Engine[] = [+ Engine.REDIS,+ Engine.ORACLE,+ Engine.DM,+ Engine.ELASTICSEARCH,+ Engine.SPANNER,+ Engine.BIGQUERY,+ Engine.DYNAMODB,+ Engine.DATABRICKS,+ Engine.COSMOSDB,+ ];++ return !excludedList.includes(engine);};export const instanceV1HasStructuredQueryResult = (@@ -218,6 +223,7 @@ export const instanceV1HasCollationAndCharacterSet = (Engine.RISINGWAVE,Engine.STARROCKS,Engine.DORIS,+ Engine.COSMOSDB,];return !excludedList.includes(engine);};@@ -300,6 +306,27 @@ export const instanceV1SupportsTrigger = (return [Engine.MYSQL].includes(engine);};+export const instanceV1SupportsColumn = (+ instanceOrEngine: Instance | InstanceResource | Engine+) => {+ const engine = engineOfInstanceV1(instanceOrEngine);+ return ![Engine.MONGODB, Engine.COSMOSDB].includes(engine);+};++export const instanceV1SupportsIndex = (+ instanceOrEngine: Instance | InstanceResource | Engine+) => {+ const engine = engineOfInstanceV1(instanceOrEngine);+ return ![Engine.SNOWFLAKE].includes(engine);+};++export const instanceV1MaskingForNoSQL = (+ instanceOrEngine: Instance | InstanceResource | Engine+) => {+ const engine = engineOfInstanceV1(instanceOrEngine);+ return [Engine.MONGODB, Engine.COSMOSDB].includes(engine);+};+export const engineOfInstanceV1 = (instanceOrEngine: Instance | InstanceResource | Engine) => {@@ -388,27 +415,21 @@ export const hasTableEngineProperty = (instanceOrEngine: Instance | InstanceResource | Engine) => {const engine = engineOfInstanceV1(instanceOrEngine);- return ![Engine.POSTGRES, Engine.COCKROACHDB, Engine.SNOWFLAKE].includes(- engine- );+ return ![+ Engine.POSTGRES,+ Engine.COCKROACHDB,+ Engine.SNOWFLAKE,+ Engine.MONGODB,+ Engine.COSMOSDB,+ ].includes(engine);};+export const hasIndexSizeProperty = (instanceOrEngine: Instance | InstanceResource | Engine) => {const engine = engineOfInstanceV1(instanceOrEngine);return ![Engine.CLICKHOUSE, Engine.SNOWFLAKE].includes(engine);};-export const hasCollationProperty = (- instanceOrEngine: Instance | InstanceResource | Engine-) => {- const engine = engineOfInstanceV1(instanceOrEngine);- return ![- Engine.POSTGRES,- Engine.COCKROACHDB,- Engine.CLICKHOUSE,- Engine.SNOWFLAKE,- ].includes(engine);-};export const useInstanceV1EditorLanguage = (instance: MaybeRef<Instance | InstanceResource | undefined>diff --git a/frontend/src/views/DatabaseDetail/DatabaseDetail.vue b/frontend/src/views/DatabaseDetail/DatabaseDetail.vueindex 27fd4fa427..9eb98cba37 100644--- a/frontend/src/views/DatabaseDetail/DatabaseDetail.vue+++ b/frontend/src/views/DatabaseDetail/DatabaseDetail.vue@@ -25,7 +25,19 @@class="w-5 h-5"/></h1>- <span class="textinfolabel">{{ database.name }}</span>+ <div class="flex items-center">+ <span class="textinfolabel">+ {{ database.name }}+ </span>+ <NButton+ v-if="isSupported"+ quaternary+ size="tiny"+ @click="handleCopyDatabaseName(database.name)"+ >+ <ClipboardCopyIcon class="w-4 h-4" />+ </NButton>+ </div></div></div></div>@@ -192,8 +204,9 @@<script lang="ts" setup>import { useTitle } from "@vueuse/core";+import { useClipboard } from "@vueuse/core";import dayjs from "dayjs";-import { ArrowRightLeftIcon } from "lucide-vue-next";+import { ArrowRightLeftIcon, ClipboardCopyIcon } from "lucide-vue-next";import { NButton, NTabPane, NTabs } from "naive-ui";import { computed, reactive, watch, ref, watchEffect } from "vue";import { useRouter, useRoute } from "vue-router";@@ -224,6 +237,7 @@ import {useAppFeature,useEnvironmentV1Store,useDatabaseV1ByName,+ pushNotification,} from "@/store";import {databaseNamePrefix,@@ -409,4 +423,20 @@ const environment = computed(() => {});useTitle(computed(() => database.value.databaseName));++const { copy: copyTextToClipboard, isSupported } = useClipboard({+ legacy: true,+});+const handleCopyDatabaseName = (name: string) => {+ if (!isSupported.value) {+ return;+ }+ copyTextToClipboard(name).then(() => {+ pushNotification({+ module: "bytebase",+ style: "SUCCESS",+ title: "Database full name copied.",+ });+ });+};</script>diff --git a/frontend/src/views/SettingWorkspaceSubscription.vue b/frontend/src/views/SettingWorkspaceSubscription.vueindex 5fa217be33..609f8109b8 100644--- a/frontend/src/views/SettingWorkspaceSubscription.vue+++ b/frontend/src/views/SettingWorkspaceSubscription.vue@@ -101,7 +101,7 @@:disabled="!workspaceId"@click="handleCopyId">- <heroicons-outline:clipboard-document class="w-4 h-4" />+ <ClipboardCopyIcon class="w-4 h-4" /></NButton></div></div>@@ -156,6 +156,7 @@<script lang="ts" setup>import { useClipboard } from "@vueuse/core";+import { ClipboardCopyIcon } from "lucide-vue-next";import { NButton, NDivider, NInput } from "naive-ui";import { storeToRefs } from "pinia";import { computed, reactive, ref } from "vue";diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/TablesTable.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/TablesTable.vueindex 579d15774a..ecd78c2629 100644--- a/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/TablesTable.vue+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/TablesTable.vue@@ -31,7 +31,7 @@ import type {import {bytesToString,getHighlightHTMLByRegExp,- hasCollationProperty,+ instanceV1HasCollationAndCharacterSet,hasIndexSizeProperty,hasTableEngineProperty,useAutoHeightDataTable,@@ -112,7 +112,7 @@ const columns = computed(() => {{key: "collation",title: t("schema-editor.database.collation"),- hide: !hasCollationProperty(instanceEngine.value),+ hide: !instanceV1HasCollationAndCharacterSet(instanceEngine.value),resizable: true,minWidth: 120,maxWidth: 180,