CB-2660 add set resource property mutation to resource manager updated (#1214)

* CB-2660: Add set property mutation to resource manager

* CB-2660 fix: save resource property

* CB-2660 Modify graphql schema to allow properties in RMResource to be null

* CB-2660 fix: resource properties keys

* CB-2660 fix: codestyle

* CB-2660 Read resource properties in navigator model

* CB-2660 Respect nameMask parameter

* CB-2660 feat: bind execution context information

* CB-2660 fix: don't save properties for readonly scripts

* CB-2660 fix: don't link readonly scripts with datasource

* CB-2660 fix: script linking with datasource

* CB-2660 fix: sql editor context switch flickering

* CB-2660 fix(plugin-resource-manager): resource finding

Co-authored-by: Wroud <wroud@yandex.ru>
Co-authored-by: serge-rider <serge@jkiss.org>
Co-authored-by: Alexey <wrouds@gmail.com>
This commit is contained in:
Oksana Cherniavskaia
2022-10-17 23:06:28 +03:00
committed by GitHub
co-authored by Wroud serge-rider Alexey
parent 74b960ed57
commit 39987507a5
36 changed files with 783 additions and 146 deletions
@@ -59,7 +59,17 @@ export class ConnectionSchemaManagerBootstrap extends Bootstrap {
items = [...items];
const connections = this.connectionsManagerService.projectConnections
.filter(connection => !connection.template)
.filter(connection => {
if (
!this.connectionSchemaManagerService.isProjectChangeable
&& this.connectionSchemaManagerService.activeProjectId
&& connection.projectId !== this.connectionSchemaManagerService.activeProjectId
) {
return false;
}
return !connection.template;
})
.sort((a, b) => {
if (a.connected === b.connected) {
return compareConnectionsInfo(a, b);
@@ -13,6 +13,7 @@ import { injectable } from '@cloudbeaver/core-di';
import { NotificationService } from '@cloudbeaver/core-events';
import { ExtensionUtils, IExtension } from '@cloudbeaver/core-extensions';
import { type IObjectNavNodeProvider, type IDataContextActiveNode, isObjectNavNodeProvider } from '@cloudbeaver/core-navigation-tree';
import { IProjectProvider, IProjectSetter, IProjectSetterState, isProjectProvider, isProjectSetter, isProjectSetterState } from '@cloudbeaver/core-projects';
import { ITab, NavigationTabsService } from '@cloudbeaver/plugin-navigation-tabs';
@@ -25,10 +26,13 @@ interface IActiveItem<T> {
id: string;
context: T;
getCurrentNavNode?: IObjectNavNodeProvider<T>;
getProjectSetterState?: IProjectSetterState<T>;
getCurrentProjectId?: IProjectProvider<T>;
getCurrentConnectionId?: IConnectionProvider<T>;
getCurrentSchemaId?: IObjectSchemaProvider<T>;
getCurrentCatalogId?: IObjectCatalogProvider<T>;
changeConnectionId?: IConnectionSetter<T>;
changeProjectId?: IProjectSetter<T>;
changeCatalogId?: IObjectCatalogSetter<T>;
changeSchemaId?: IObjectSchemaSetter<T>;
}
@@ -44,6 +48,15 @@ export class ConnectionSchemaManagerService {
return this.activeItem.getCurrentNavNode(this.activeItem.context);
}
get activeProjectId(): string | null | undefined {
if (!this.activeItem?.getCurrentProjectId) {
return null;
}
return this.activeItem.getCurrentProjectId(this.activeItem.context);
}
get activeConnectionKey(): IConnectionInfoParams | null | undefined {
if (!this.activeItem?.getCurrentConnectionId) {
@@ -53,6 +66,14 @@ export class ConnectionSchemaManagerService {
return this.activeItem.getCurrentConnectionId(this.activeItem.context);
}
get currentProjectId(): string | null | undefined {
if (this.pendingProjectId !== null) {
return this.pendingProjectId;
}
return this.activeProjectId;
}
get currentConnectionKey(): IConnectionInfoParams | null | undefined {
if (this.pendingConnectionKey !== null) {
return this.pendingConnectionKey;
@@ -130,6 +151,10 @@ export class ConnectionSchemaManagerService {
});
}
get isProjectChangeable(): boolean {
return !!this.activeItem?.changeProjectId && !!this.activeItem.getProjectSetterState?.(this.activeItem.context);
}
get isConnectionChangeable(): boolean {
return !!this.activeItem?.changeConnectionId;
}
@@ -148,6 +173,10 @@ export class ConnectionSchemaManagerService {
);
}
get isChangingProject(): boolean {
return this.changingProjectId;
}
get isChangingConnection(): boolean {
return this.changingConnection;
}
@@ -177,9 +206,11 @@ export class ConnectionSchemaManagerService {
return item;
}
private pendingProjectId: string | null;
private pendingConnectionKey: IConnectionInfoParams | null;
private pendingCatalogId: string | null | undefined;
private pendingSchemaId: string | null | undefined;
private changingProjectId: boolean;
private changingConnection: boolean;
private changingConnectionContainer: boolean;
@@ -190,17 +221,21 @@ export class ConnectionSchemaManagerService {
private readonly dbDriverResource: DBDriverResource,
private readonly notificationService: NotificationService
) {
this.changingProjectId = false;
this.changingConnection = false;
this.changingConnectionContainer = false;
this.pendingConnectionKey = null;
this.pendingProjectId = null;
this.pendingCatalogId = null;
this.pendingSchemaId = null;
makeObservable<
ConnectionSchemaManagerService,
'activeItem'
| 'changingProjectId'
| 'changingConnection'
| 'changingConnectionContainer'
| 'pendingProjectId'
| 'pendingConnectionKey'
| 'pendingCatalogId'
| 'pendingSchemaId'
@@ -218,8 +253,10 @@ export class ConnectionSchemaManagerService {
isObjectCatalogChangeable: computed,
isObjectSchemaChangeable: computed,
activeItem: computed,
changingProjectId: observable,
changingConnection: observable,
changingConnectionContainer: observable,
pendingProjectId: observable,
pendingConnectionKey: observable,
pendingCatalogId: observable,
pendingSchemaId: observable,
@@ -227,6 +264,24 @@ export class ConnectionSchemaManagerService {
});
}
async selectProjectId(projectId: string): Promise<void> {
if (!this.activeItem?.changeProjectId) {
return;
}
try {
runInAction(() => {
this.changingProjectId = true;
this.pendingProjectId = projectId;
});
await this.activeItem.changeProjectId(projectId, this.activeItem.context);
} finally {
runInAction(() => {
this.changingProjectId = false;
this.pendingProjectId = null;
});
}
}
/**
* Trigger when user select connection in dropdown
*/
@@ -236,7 +291,9 @@ export class ConnectionSchemaManagerService {
}
try {
runInAction(() => {
this.changingProjectId = true;
this.changingConnection = true;
this.pendingProjectId = connectionKey.projectId;
this.pendingConnectionKey = connectionKey;
this.pendingSchemaId = undefined;
this.pendingCatalogId = undefined;
@@ -245,7 +302,9 @@ export class ConnectionSchemaManagerService {
await this.updateContainer(connectionKey);
} finally {
runInAction(() => {
this.changingProjectId = false;
this.changingConnection = false;
this.pendingProjectId = null;
this.pendingConnectionKey = null;
this.pendingSchemaId = null;
this.pendingCatalogId = null;
@@ -361,10 +420,13 @@ export class ConnectionSchemaManagerService {
private setExtensions<T>(item: IActiveItem<T>, extensions: Array<IExtension<T>>) {
ExtensionUtils.from(extensions)
.on(isObjectNavNodeProvider, extension => { item.getCurrentNavNode = extension; })
.on(isProjectSetterState, extension => { item.getProjectSetterState = extension; })
.on(isProjectProvider, extension => { item.getCurrentProjectId = extension; })
.on(isConnectionProvider, extension => { item.getCurrentConnectionId = extension; })
.on(isObjectCatalogProvider, extension => { item.getCurrentCatalogId = extension; })
.on(isObjectSchemaProvider, extension => { item.getCurrentSchemaId = extension; })
.on(isProjectSetter, extension => { item.changeProjectId = extension; })
.on(isConnectionSetter, extension => { item.changeConnectionId = extension; })
.on(isObjectCatalogSetter, extension => { item.changeCatalogId = extension; })
.on(isObjectSchemaSetter, extension => { item.changeSchemaId = extension; });