mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
Merge pull request #80 from dbeaver/feat-data-refresh
refactor(core): rename loadConnection in CSMS
This commit is contained in:
+32
-24
@@ -142,7 +142,7 @@ export class ConnectionSchemaManagerService {
|
||||
return;
|
||||
}
|
||||
this.activeItem.changeConnectionId(connectionId, this.activeItem.context);
|
||||
this.loadConnection(connectionId);
|
||||
this.updateContainer(connectionId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,7 +153,7 @@ export class ConnectionSchemaManagerService {
|
||||
throw new Error('The try to change catalog without connection');
|
||||
}
|
||||
this.activeItem.changeCatalogId(catalogId, this.activeItem.context);
|
||||
this.loadConnection(this.currentConnectionId!, catalogId);
|
||||
this.updateContainer(this.currentConnectionId, catalogId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -166,6 +166,35 @@ export class ConnectionSchemaManagerService {
|
||||
this.activeItem.changeSchemaId(schemaId, this.activeItem.context);
|
||||
}
|
||||
|
||||
async updateContainer(connectionId?: string, catalogId?: string) {
|
||||
if (!connectionId) {
|
||||
connectionId = this.currentConnectionId;
|
||||
}
|
||||
if (!catalogId) {
|
||||
catalogId = this.currentObjectCatalogId;
|
||||
}
|
||||
if (!connectionId) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await this.connectionsManagerService.dbDrivers.load();
|
||||
} catch (exception) {
|
||||
this.notificationService.logException(exception, 'Can\'t load database drivers', true);
|
||||
}
|
||||
|
||||
if (this.activeItem?.changeCatalogId || this.activeItem?.changeSchemaId) {
|
||||
try {
|
||||
await this.connectionsManagerService.loadObjectContainer(connectionId, catalogId);
|
||||
} catch (exception) {
|
||||
this.notificationService.logException(
|
||||
exception,
|
||||
`Can't load objectContainers for ${connectionId}@${catalogId}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private onNodeSelect([navNodeId, selected]: [string, boolean]) {
|
||||
if (selected) {
|
||||
const item: IActiveItem<string> = {
|
||||
@@ -238,31 +267,10 @@ export class ConnectionSchemaManagerService {
|
||||
this.activeItem = item;
|
||||
this.activeItemHistory.push(item);
|
||||
|
||||
if (this.currentConnectionId) {
|
||||
this.loadConnection(this.currentConnectionId, this.currentObjectCatalogId);
|
||||
}
|
||||
this.updateContainer();
|
||||
}
|
||||
|
||||
private clearHistory(id: string) {
|
||||
this.activeItemHistory = this.activeItemHistory.filter(item => item.id !== id);
|
||||
}
|
||||
|
||||
private async loadConnection(connectionId: string, catalogId?: string) {
|
||||
try {
|
||||
await this.connectionsManagerService.dbDrivers.load();
|
||||
} catch (exception) {
|
||||
this.notificationService.logException(exception, 'Can\'t load database drivers', true);
|
||||
}
|
||||
|
||||
if (this.activeItem?.changeCatalogId || this.activeItem?.changeSchemaId) {
|
||||
try {
|
||||
await this.connectionsManagerService.loadObjectContainer(connectionId, catalogId);
|
||||
} catch (exception) {
|
||||
this.notificationService.logException(
|
||||
exception,
|
||||
`Can't load objectContainers for ${connectionId}@${catalogId}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -55,7 +55,10 @@ export const ConnectionSelector = observer(function ConnectionSelector() {
|
||||
<connection-selector as="div" {...use({ isVisible: controller.isConnectionSelectorVisible })}>
|
||||
<ConnectionMenu menuItem={controller.connectionMenu} style={[menuStyles, connectionMenu]}/>
|
||||
{controller.isObjectContainerSelectorVisible && (
|
||||
<SchemaOrCatalogMenu menuItem={controller.objectContainerMenu} style={[menuStyles]}/>
|
||||
<SchemaOrCatalogMenu
|
||||
menuItem={controller.objectContainerMenu}
|
||||
style={[menuStyles]}
|
||||
/>
|
||||
)}
|
||||
</connection-selector>
|
||||
);
|
||||
|
||||
+4
-2
@@ -71,8 +71,10 @@ export class ConnectionSelectorController {
|
||||
return 'database';
|
||||
}
|
||||
|
||||
constructor(private connectionSelectorService: ConnectionSchemaManagerService,
|
||||
private connectionsManagerService: ConnectionsManagerService) {
|
||||
constructor(
|
||||
private connectionSelectorService: ConnectionSchemaManagerService,
|
||||
private connectionsManagerService: ConnectionsManagerService,
|
||||
) {
|
||||
|
||||
this.connectionMenu = new ComputedMenuItemModel({
|
||||
id: 'connectionsDropdown',
|
||||
|
||||
Reference in New Issue
Block a user