mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-01 03:53:57 +00:00
refresh DB - don't offer incremental analysis when not supported
This commit is contained in:
1
packages/types/engines.d.ts
vendored
1
packages/types/engines.d.ts
vendored
@@ -238,6 +238,7 @@ export interface EngineDriver<TClient = any, TDataBase = any> extends FilterBeha
|
||||
supportsDatabaseRestore?: boolean;
|
||||
supportsServerSummary?: boolean;
|
||||
supportsDatabaseProfiler?: boolean;
|
||||
supportsIncrementalAnalysis?: boolean;
|
||||
requiresDefaultSortCriteria?: boolean;
|
||||
profilerFormatterFunction?: string;
|
||||
profilerTimestampFunction?: string;
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import _ from 'lodash';
|
||||
import { currentDatabase, getCurrentDatabase } from '../stores';
|
||||
import { currentDatabase, getCurrentDatabase, getExtensions } from '../stores';
|
||||
import getElectron from '../utility/getElectron';
|
||||
import registerCommand from './registerCommand';
|
||||
import { apiCall } from '../utility/api';
|
||||
import { getDatabasStatusMenu, switchCurrentDatabase } from '../utility/common';
|
||||
import { __t } from '../translations';
|
||||
import { findEngineDriver } from 'dbgate-tools';
|
||||
|
||||
registerCommand({
|
||||
id: 'database.changeState',
|
||||
@@ -18,7 +19,8 @@ registerCommand({
|
||||
conid: connection._id,
|
||||
database: name,
|
||||
};
|
||||
const driver = findEngineDriver(connection, getExtensions());
|
||||
|
||||
return getDatabasStatusMenu(dbid);
|
||||
return getDatabasStatusMenu(dbid, driver);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -155,12 +155,12 @@ export function getKeyTextFromEvent(e) {
|
||||
return keyText;
|
||||
}
|
||||
|
||||
export function getDatabasStatusMenu(dbid) {
|
||||
export function getDatabasStatusMenu(dbid, driver = null) {
|
||||
function callSchemalListChanged() {
|
||||
apiCall('database-connections/dispatch-database-changed-event', { event: 'schema-list-changed', ...dbid });
|
||||
}
|
||||
return [
|
||||
{
|
||||
return _.compact([
|
||||
driver?.supportsIncrementalAnalysis && {
|
||||
text: _t('command.database.refreshIncremental', { defaultMessage: 'Refresh DB structure (incremental)' }),
|
||||
onClick: () => {
|
||||
apiCall('database-connections/sync-model', dbid);
|
||||
@@ -168,7 +168,9 @@ export function getDatabasStatusMenu(dbid) {
|
||||
},
|
||||
},
|
||||
{
|
||||
text: _t('command.database.refreshFull', { defaultMessage: 'Refresh DB structure (full)' }),
|
||||
text: driver?.supportsIncrementalAnalysis
|
||||
? _t('command.database.refreshFull', { defaultMessage: 'Refresh DB structure (full)' })
|
||||
: _t('command.database.refresh', { defaultMessage: 'Refresh DB structure' }),
|
||||
onClick: () => {
|
||||
apiCall('database-connections/sync-model', { ...dbid, isFullRefresh: true });
|
||||
callSchemalListChanged();
|
||||
@@ -189,5 +191,5 @@ export function getDatabasStatusMenu(dbid) {
|
||||
switchCurrentDatabase(null);
|
||||
},
|
||||
},
|
||||
];
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@
|
||||
}
|
||||
|
||||
function createRefreshDatabaseMenu() {
|
||||
return getDatabasStatusMenu({ conid, database });
|
||||
return getDatabasStatusMenu({ conid, database }, driver);
|
||||
}
|
||||
|
||||
function handleFullRefreshDatabase() {
|
||||
|
||||
@@ -147,6 +147,7 @@ const driver = {
|
||||
dialect,
|
||||
engine: 'clickhouse@dbgate-plugin-clickhouse',
|
||||
title: 'ClickHouse',
|
||||
supportsIncrementalAnalysis: true,
|
||||
showConnectionField: (field, values) => {
|
||||
return ['databaseUrl', 'defaultDatabase', 'singleDatabase', 'isReadOnly', 'user', 'password'].includes(field);
|
||||
},
|
||||
|
||||
@@ -171,6 +171,7 @@ const driver = {
|
||||
defaultPort: 1433,
|
||||
defaultAuthTypeName: 'tedious',
|
||||
supportsTransactions: true,
|
||||
supportsIncrementalAnalysis: true,
|
||||
// databaseUrlPlaceholder: 'e.g. server=localhost&authentication.type=default&authentication.type.user=myuser&authentication.type.password=pwd&options.database=mydb',
|
||||
|
||||
getNewObjectTemplates() {
|
||||
|
||||
@@ -184,6 +184,7 @@ const mysqlDriverBase = {
|
||||
defaultAuthTypeName: 'hostPort',
|
||||
defaultSocketPath: '/var/run/mysqld/mysqld.sock',
|
||||
supportsTransactions: true,
|
||||
supportsIncrementalAnalysis: true,
|
||||
|
||||
getNewObjectTemplates() {
|
||||
return [
|
||||
|
||||
@@ -121,6 +121,7 @@ const dialect = {
|
||||
const postgresDriverBase = {
|
||||
...driverBase,
|
||||
supportsTransactions: true,
|
||||
supportsIncrementalAnalysis: true,
|
||||
dumperClass: Dumper,
|
||||
dialect,
|
||||
// showConnectionField: (field, values) =>
|
||||
|
||||
@@ -48,6 +48,7 @@ const sqliteDriverBase = {
|
||||
dialect,
|
||||
readOnlySessions: true,
|
||||
supportsTransactions: true,
|
||||
supportsIncrementalAnalysis: true,
|
||||
|
||||
getQuerySplitterOptions: (usage) =>
|
||||
usage == 'editor'
|
||||
|
||||
Reference in New Issue
Block a user