Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Remove the table console url setting
天舟f106d40cf5ce
diff --git a/api/setting.go b/api/setting.goindex 0364854d49..4cc7776139 100644--- a/api/setting.go+++ b/api/setting.go@@ -9,17 +9,11 @@ type SettingName stringconst (SettingAuthSecret SettingName = "bb.auth.secret"- // The console URL for a particular database, it supports following variables+ // The console URL, it supports following variables// {{DB_NAME}}: the database name// e.g. For a phpmyadmin instance running on http://myphpadmin.example.com:8080, the setting would be:// http://myphpadmin.example.com:8080/index.php?route=/database/sql&db={{DB_NAME}}- SettingConsoleDatabase SettingName = "bb.console.database"- // The console URL for a particular table, it supports following variables- // {{DB_NAME}}: the database name- // {{TABLE_NAME}}: the table name- // e.g. For a phpmyadmin instance running on http://myphpadmin.example.com:8080, the setting would be:- // http://myphpadmin.example.com:8080/index.php?route=/table/sql&db={{DB_NAME}}&table={{TABLE_NAME}}- SettingConsoleTable SettingName = "bb.console.table"+ SettingConsoleURL SettingName = "bb.console.url")type Setting struct {diff --git a/bin/server/cmd/root.go b/bin/server/cmd/root.goindex ac9bf59ed7..f997303736 100644--- a/bin/server/cmd/root.go+++ b/bin/server/cmd/root.go@@ -238,22 +238,9 @@ func initSetting(settingService api.SettingService) (*config, error) {{configCreate := &api.SettingCreate{CreatorId: api.SYSTEM_BOT_ID,- Name: api.SettingConsoleDatabase,+ Name: api.SettingConsoleURL,Value: "",- Description: "URL for the external console (e.g. phpMyAdmin) pointing to a particular database.",- }- _, err := settingService.CreateSettingIfNotExist(context.Background(), configCreate)- if err != nil {- return nil, err- }- }-- {- configCreate := &api.SettingCreate{- CreatorId: api.SYSTEM_BOT_ID,- Name: api.SettingConsoleTable,- Value: "",- Description: "URL for the external console (e.g. phpMyAdmin) pointing to a particular table.",+ Description: "URL for the external console (e.g. phpMyAdmin).",}_, err := settingService.CreateSettingIfNotExist(context.Background(), configCreate)if err != nil {diff --git a/frontend/src/components/DatabaseTable.vue b/frontend/src/components/DatabaseTable.vueindex a0ddb44056..23df26b8fe 100644--- a/frontend/src/components/DatabaseTable.vue+++ b/frontend/src/components/DatabaseTable.vue@@ -64,7 +64,9 @@<BBTableCell v-if="showConsoleLink" class="w-4"><buttonclass="btn-icon"- @click.stop="window.open(consoleLink(database.name), '_blank')"+ @click.stop="+ window.open(databaseConsoleLink(database.name), '_blank')+ "><svgclass="w-4 h-4"@@ -90,7 +92,7 @@import { computed, PropType } from "vue";import { useStore } from "vuex";import { useRouter } from "vue-router";-import { databaseConsoleLink, databaseSlug, isDBAOrOwner } from "../utils";+import { consoleLink, databaseSlug, isDBAOrOwner } from "../utils";import { Database } from "../types";import { BBTableColumn } from "../bbkit/types";import { isEmpty } from "lodash";@@ -327,19 +329,16 @@ export default {return false;}- const consoleURL = store.getters["setting/settingByName"](- "bb.console.database"- ).value;- console.log("aaa", consoleURL);+ const consoleURL =+ store.getters["setting/settingByName"]("bb.console.url").value;return !isEmpty(consoleURL);});- const consoleLink = (databaseName: string) => {- const consoleURL = store.getters["setting/settingByName"](- "bb.console.database"- ).value;+ const databaseConsoleLink = (databaseName: string) => {+ const consoleURL =+ store.getters["setting/settingByName"]("bb.console.url").value;if (!isEmpty(consoleURL)) {- return databaseConsoleLink(consoleURL, databaseName);+ return consoleLink(consoleURL, databaseName);}return "";};@@ -360,7 +359,7 @@ export default {showMiscColumn,columnList,showConsoleLink,- consoleLink,+ databaseConsoleLink,clickDatabase,};},diff --git a/frontend/src/components/TableTable.vue b/frontend/src/components/TableTable.vueindex 7424608aed..23522acfa2 100644--- a/frontend/src/components/TableTable.vue+++ b/frontend/src/components/TableTable.vue@@ -30,29 +30,6 @@<BBTableCell class="w-16">{{ humanizeTs(table.lastSuccessfulSyncTs) }}</BBTableCell>- <BBTableCell v-if="showConsoleLink" class="w-4">- <button- class="btn-icon"- @click.stop="- window.open(consoleLink(table.database.name, table.name), '_blank')- "- >- <svg- class="w-4 h-4"- fill="none"- stroke="currentColor"- viewBox="0 0 24 24"- xmlns="http://www.w3.org/2000/svg"- >- <path- stroke-linecap="round"- stroke-linejoin="round"- stroke-width="2"- d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"- ></path>- </svg>- </button>- </BBTableCell></template></BBTable></template>@@ -61,13 +38,8 @@import { computed, PropType } from "vue";import { BBTableColumn } from "../bbkit/types";import { Table } from "../types";-import {- bytesToString,- databaseSlug,- databaseTableConsoleLink,-} from "../utils";+import { bytesToString, databaseSlug } from "../utils";import { useRouter } from "vue-router";-import { isEmpty } from "lodash";import { useStore } from "vuex";type Mode = "TABLE" | "VIEW";@@ -133,33 +105,9 @@ export default {const router = useRouter();const columnList = computed(() => {- const list = columnListMap.get(props.mode);- if (showConsoleLink.value) {- list?.push({ title: "SQL console" });- }-- return list;+ return columnListMap.get(props.mode);});- const showConsoleLink = computed(() => {- if (props.mode != "TABLE") {- return false;- }-- const consoleURL =- store.getters["setting/settingByName"]("bb.console.table").value;- return !isEmpty(consoleURL);- });-- const consoleLink = (databaseName: string, tableName: string) => {- const consoleURL =- store.getters["setting/settingByName"]("bb.console.table").value;- if (!isEmpty(consoleURL)) {- return databaseTableConsoleLink(consoleURL, databaseName, tableName);- }- return "";- };-const clickTable = (section: number, row: number) => {const table = props.tableList[row];router.push(`/db/${databaseSlug(table.database)}/table/${table.name}`);@@ -167,8 +115,6 @@ export default {return {columnList,- showConsoleLink,- consoleLink,bytesToString,clickTable,};diff --git a/frontend/src/types/setting.ts b/frontend/src/types/setting.tsindex 2a6e875e8c..5a3869483f 100644--- a/frontend/src/types/setting.ts+++ b/frontend/src/types/setting.ts@@ -1,7 +1,7 @@import { SettingId } from "./id";import { Principal } from "./principal";-export type SettingName = "bb.console.database" | "bb.console.table";+export type SettingName = "bb.console.url";export type Setting = {id: SettingId;diff --git a/frontend/src/utils/database.ts b/frontend/src/utils/database.tsindex 1ca7c1ea3f..25ecbe07ba 100644--- a/frontend/src/utils/database.ts+++ b/frontend/src/utils/database.ts@@ -70,23 +70,8 @@ export function sortDatabaseList(});}-// templateURL corresponds to the "bb.console.database" setting.-// This method replaces {{DB_NAME}} with the actual database/table name.-export function databaseConsoleLink(- templateURL: string,- databaseName: string-): string {+// templateURL corresponds to the "bb.console.url" setting.+// This method replaces {{DB_NAME}} with the actual database name.+export function consoleLink(templateURL: string, databaseName: string): string {return templateURL.replace("{{DB_NAME}}", databaseName);}--// templateURL corresponds to the "bb.console.table" setting.-// This method replaces {{DB_NAME}}/{{TABLE_NAME}} with the actual database/table name.-export function databaseTableConsoleLink(- templateURL: string,- databaseName: string,- tableName: string-): string {- return templateURL- .replace("{{DB_NAME}}", databaseName)- .replace("{{TABLE_NAME}}", tableName);-}diff --git a/frontend/src/views/DatabaseDetail.vue b/frontend/src/views/DatabaseDetail.vueindex db1d7fae23..95095e7073 100644--- a/frontend/src/views/DatabaseDetail.vue+++ b/frontend/src/views/DatabaseDetail.vue@@ -71,13 +71,15 @@</router-link></dd><dd- v-if="consoleLink.length > 0"+ v-if="databaseConsoleLink.length > 0"class="flex items-center text-sm md:mr-4"><span class="textlabel">SQL Console</span><buttonclass="ml-1 btn-icon"- @click.prevent="window.open(urlfy(consoleLink), '_blank')"+ @click.prevent="+ window.open(urlfy(databaseConsoleLink), '_blank')+ "><svgclass="w-4 h-4"@@ -374,12 +376,7 @@ import TableTable from "../components/TableTable.vue";import MigrationHistoryTable from "../components/MigrationHistoryTable.vue";import MemberSelect from "../components/MemberSelect.vue";import ProjectSelect from "../components/ProjectSelect.vue";-import {- databaseConsoleLink,- idFromSlug,- instanceSlug,- isDBAOrOwner,-} from "../utils";+import { consoleLink, idFromSlug, instanceSlug, isDBAOrOwner } from "../utils";import {DataSource,ProjectId,@@ -457,12 +454,11 @@ export default {watchEffect(prepareMigrationHistoryList);- const consoleLink = computed(() => {- const consoleURL = store.getters["setting/settingByName"](- "bb.console.database"- ).value;+ const databaseConsoleLink = computed(() => {+ const consoleURL =+ store.getters["setting/settingByName"]("bb.console.url").value;if (!isEmpty(consoleURL)) {- return databaseConsoleLink(consoleURL, database.value.name, "");+ return consoleLink(consoleURL, database.value.name);}return "";});@@ -625,7 +621,7 @@ export default {tableList,attentionTitle,migrationHistoryList,- consoleLink,+ databaseConsoleLink,hasDataSourceFeature,allowChangeProject,allowViewDataSource,diff --git a/frontend/src/views/SettingWorkspaceGeneral.vue b/frontend/src/views/SettingWorkspaceGeneral.vueindex 92ae3e2edd..bfefe24300 100644--- a/frontend/src/views/SettingWorkspaceGeneral.vue+++ b/frontend/src/views/SettingWorkspaceGeneral.vue@@ -1,58 +1,33 @@<template>- <div class="mt-2 space-y-8 divide-y divide-gray-200">+ <div class="mt-2 space-y-6 divide-y divide-gray-200"><div>- <h3 class="text-lg leading-6 font-medium text-main">SQL Console</h3>- <p class="mt-1 text-sm text-control-light">+ <h3 class="text-lg leading-6 font-medium text-main">SQL Console URL</h3>+ <p class="mt-1 textinfolabel">If your team use a separate SQL console such as phpMyAdmin, you canprovide its URL pattern here, so that Bytebase can surface the consolelink on the relevant database and table UI.- <a- href="https://docs.bytebase.com/settings/external-sql-console"- target="_blank"- class="normal-link"- >- detailed guide</a- ></p>- <div class="mt-6 grid grid-cols-1 gap-y-6 gap-x-4 sm:grid-cols-6">- <div class="sm:col-span-6">- <label for="databaseURL" class="textlabel"> Database URL </label>- <label for="databaseURL" class="textinfolabel">- use {{ DB_NAME_PLACEHOLDER }} as the placeholder for the actual- database name- </label>- <div class="mt-1">- <input- type="text"- id="databaseURL"- placeholder="http://phpmyadmin.example.com:8080/index.php?route=/database/sql&db={{DB_NAME}}"- autocomplete="off"- class="w-full textfield"- :disabled="!allowEdit"- v-model="state.databaseConsoleURL"- />- </div>- </div>- </div>- <div class="mt-6 grid grid-cols-1 gap-y-6 gap-x-4 sm:grid-cols-6">- <div class="sm:col-span-6">- <label for="tableURL" class="textlabel"> Table URL </label>- <label for="databaseURL" class="textinfolabel">- use {{ DB_NAME_PLACEHOLDER }} and {{ TABLE_NAME_PLACEHOLDER }} as- the placeholder for the actual database and table name- </label>- <div class="mt-1">- <input- type="text"- id="tableURL"- placeholder="http://phpmyadmin.example.com:8080/index.php?route=/table/sql&db={{DB_NAME}}&table={{TABLE_NAME}}"- autocomplete="off"- class="w-full textfield"- :disabled="!allowEdit"- v-model="state.tableConsoleURL"- />- </div>+ <div class="mt-4">+ <input+ type="text"+ id="databaseURL"+ placeholder="http://phpmyadmin.example.com:8080/index.php?route=/database/sql&db={{DB_NAME}}"+ autocomplete="off"+ class="w-full textfield"+ :disabled="!allowEdit"+ v-model="state.consoleURL"+ />+ <div for="databaseURL" class="mt-2 textinfolabel">+ Hint: Use {{ DB_NAME_PLACEHOLDER }} as the placeholder for the actual+ database name+ <a+ href="https://docs.bytebase.com/settings/external-sql-console"+ target="_blank"+ class="normal-link"+ >+ detailed guide</a+ >.</div></div></div>@@ -77,11 +52,9 @@ import { isOwner } from "../utils";import { Setting } from "../types/setting";const DB_NAME_PLACEHOLDER = "{{DB_NAME}}";-const TABLE_NAME_PLACEHOLDER = "{{TABLE_NAME}}";interface LocalState {- databaseConsoleURL: string;- tableConsoleURL: string;+ consoleURL: string;}export default {@@ -91,11 +64,8 @@ export default {const store = useStore();const state = reactive<LocalState>({- databaseConsoleURL: store.getters["setting/settingByName"](- "bb.console.database"- ).value,- tableConsoleURL:- store.getters["setting/settingByName"]("bb.console.table").value,+ consoleURL:+ store.getters["setting/settingByName"]("bb.console.url").value,});const currentUser = computed(() => store.getters["auth/currentUser"]());@@ -106,39 +76,23 @@ export default {const allowSave = computed((): boolean => {return (- state.databaseConsoleURL !=- store.getters["setting/settingByName"]("bb.console.database").value ||- state.tableConsoleURL !=- store.getters["setting/settingByName"]("bb.console.table").value+ state.consoleURL !=+ store.getters["setting/settingByName"]("bb.console.url").value);});const doSave = () => {if (- state.databaseConsoleURL !=- store.getters["setting/settingByName"]("bb.console.database").value- ) {- store- .dispatch("setting/updateSettingByName", {- name: "bb.console.database",- value: state.databaseConsoleURL,- })- .then((setting: Setting) => {- state.databaseConsoleURL = setting.value;- });- }-- if (- state.tableConsoleURL !=- store.getters["setting/settingByName"]("bb.console.table").value+ state.consoleURL !=+ store.getters["setting/settingByName"]("bb.console.url").value) {store.dispatch("setting/updateSettingByName", {- name: "bb.console.table",- value: state.tableConsoleURL,+ name: "bb.console.url",+ value: state.consoleURL,}).then((setting: Setting) => {- state.tableConsoleURL = setting.value;+ state.consoleURL = setting.value;});}};@@ -146,7 +100,6 @@ export default {return {state,DB_NAME_PLACEHOLDER,- TABLE_NAME_PLACEHOLDER,allowEdit,allowSave,doSave,diff --git a/frontend/src/views/TableDetail.vue b/frontend/src/views/TableDetail.vueindex 8964bc0005..fcd30cb608 100644--- a/frontend/src/views/TableDetail.vue+++ b/frontend/src/views/TableDetail.vue@@ -38,13 +38,6 @@md:space-y-0 md:flex-row md:flex-wrap">- <dt class="sr-only">Database</dt>- <dd class="flex items-center text-sm md:mr-4">- <span class="textlabel">Database - </span>- <router-link :to="`/db/${databaseSlug}`" class="normal-link">- {{ database.name }}- </router-link>- </dd><dt class="sr-only">Environment</dt><dd class="flex items-center text-sm md:mr-4"><span class="textlabel">Environment - </span>@@ -77,14 +70,19 @@{{ projectName(database.project) }}</router-link></dd>- <dd- v-if="consoleLink.length > 0"- class="flex items-center text-sm md:mr-4"- >- <span class="textlabel">SQL Console</span>+ <dt class="sr-only">Database</dt>+ <dd class="flex items-center text-sm md:mr-4">+ <span class="textlabel">Database - </span>+ <router-link :to="`/db/${databaseSlug}`" class="normal-link">+ {{ database.name }}+ </router-link>++ <span class="ml-2 textlabel">SQL Console</span><buttonclass="ml-1 btn-icon"- @click.prevent="window.open(urlfy(consoleLink), '_blank')"+ @click.prevent="+ window.open(urlfy(databaseConsoleLink), '_blank')+ "><svgclass="w-4 h-4"@@ -211,7 +209,7 @@ import { computed } from "@vue/runtime-core";import { useStore } from "vuex";import ColumnTable from "../components/ColumnTable.vue";import IndexTable from "../components/IndexTable.vue";-import { bytesToString, databaseTableConsoleLink, idFromSlug } from "../utils";+import { bytesToString, consoleLink, idFromSlug } from "../utils";import { isEmpty } from "lodash";export default {@@ -241,15 +239,11 @@ export default {return table.value.database;});- const consoleLink = computed(() => {+ const databaseConsoleLink = computed(() => {const consoleURL =- store.getters["setting/settingByName"]("bb.console.table").value;+ store.getters["setting/settingByName"]("bb.console.url").value;if (!isEmpty(consoleURL)) {- return databaseTableConsoleLink(- consoleURL,- database.value.name,- table.value.name- );+ return consoleLink(consoleURL, database.value.name);}return "";});@@ -257,7 +251,7 @@ export default {return {table,database,- consoleLink,+ databaseConsoleLink,bytesToString,};},diff --git a/server/setting.go b/server/setting.goindex c88ed92524..964788998a 100644--- a/server/setting.go+++ b/server/setting.go@@ -13,7 +13,7 @@ import (var (// Some settings contain secret info so we only return settings that are needed by the client.- whitelistSettings = []api.SettingName{api.SettingConsoleDatabase, api.SettingConsoleTable}+ whitelistSettings = []api.SettingName{api.SettingConsoleURL})func (s *Server) registerSettingRoutes(g *echo.Group) {