mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-03 16:23:58 +00:00
This commit is contained in:
@@ -54,6 +54,7 @@ export abstract class GridDisplay {
|
|||||||
sortable = false;
|
sortable = false;
|
||||||
filterable = false;
|
filterable = false;
|
||||||
editable = false;
|
editable = false;
|
||||||
|
isLoadedCorrectly = true;
|
||||||
|
|
||||||
setColumnVisibility(uniquePath: string[], isVisible: boolean) {
|
setColumnVisibility(uniquePath: string[], isVisible: boolean) {
|
||||||
const uniqueName = uniquePath.join('.');
|
const uniqueName = uniquePath.join('.');
|
||||||
|
|||||||
@@ -29,6 +29,11 @@ export class TableGridDisplay extends GridDisplay {
|
|||||||
this.table = this.cache.tables.basetbl;
|
this.table = this.cache.tables.basetbl;
|
||||||
if (!this.table) {
|
if (!this.table) {
|
||||||
this.loadTableIntoCache('basetbl', tableName);
|
this.loadTableIntoCache('basetbl', tableName);
|
||||||
|
this.isLoadedCorrectly = false;
|
||||||
|
} else {
|
||||||
|
if (!this.table.columns || this.table.columns.length == 0) {
|
||||||
|
this.isLoadedCorrectly = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.columns = this.getDisplayColumns(this.table, []);
|
this.columns = this.getDisplayColumns(this.table, []);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import engines from '@dbgate/engines';
|
|||||||
import useUndoReducer from '../utility/useUndoReducer';
|
import useUndoReducer from '../utility/useUndoReducer';
|
||||||
import usePropsCompare from '../utility/usePropsCompare';
|
import usePropsCompare from '../utility/usePropsCompare';
|
||||||
import { useUpdateDatabaseForTab } from '../utility/globalState';
|
import { useUpdateDatabaseForTab } from '../utility/globalState';
|
||||||
|
import useSocket from '../utility/SocketProvider';
|
||||||
|
|
||||||
export default function TableDataTab({ conid, database, schemaName, pureName, tabVisible, toolbarPortalRef }) {
|
export default function TableDataTab({ conid, database, schemaName, pureName, tabVisible, toolbarPortalRef }) {
|
||||||
const [config, setConfig] = React.useState(createGridConfig());
|
const [config, setConfig] = React.useState(createGridConfig());
|
||||||
@@ -36,6 +37,23 @@ export default function TableDataTab({ conid, database, schemaName, pureName, ta
|
|||||||
[connection, config, cache]
|
[connection, config, cache]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const handleDatabaseStructureChanged = React.useCallback(() => {
|
||||||
|
setCache(createGridCache());
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const socket = useSocket();
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (display && !display.isLoadedCorrectly) {
|
||||||
|
if (conid && socket) {
|
||||||
|
socket.on(`database-structure-changed-${conid}-${database}`, handleDatabaseStructureChanged);
|
||||||
|
return () => {
|
||||||
|
socket.off(`database-structure-changed-${conid}-${database}`, handleDatabaseStructureChanged);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [conid, database, display]);
|
||||||
|
|
||||||
if (!display) return null;
|
if (!display) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user