mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
chore: remove deprecated code
This commit is contained in:
@@ -23,7 +23,7 @@ export class ConnectionInfoResource extends CachedMapResource<string, Connection
|
||||
}
|
||||
|
||||
async init(id: string, credentials?: any): Promise<Connection> {
|
||||
const connection = await this.performUpdate(id, async () => {
|
||||
await this.performUpdate(id, async () => {
|
||||
const connection = await this.setActivePromise(id, this.initConnection(id, credentials));
|
||||
this.set(id, connection);
|
||||
return connection;
|
||||
@@ -64,7 +64,7 @@ export class ConnectionInfoResource extends CachedMapResource<string, Connection
|
||||
}
|
||||
|
||||
protected async loader(connectionId: string): Promise<Map<string, Connection>> {
|
||||
const { connection } = await this.graphQLService.gql.connectionState({ id: connectionId });
|
||||
const { connection } = await this.graphQLService.gql.connectionInfo({ id: connectionId });
|
||||
|
||||
const oldConnection = this.get(connectionId) || {};
|
||||
this.set(connectionId, { ...oldConnection, ...connection });
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
query connectionAuthProperties($id: ID!) {
|
||||
connection: connectionState(id: $id) {
|
||||
connection: connectionInfo(id: $id) {
|
||||
authProperties {
|
||||
id
|
||||
displayName
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
query connectionState($id: ID!) {
|
||||
connection: connectionState(id: $id) {
|
||||
query connectionInfo($id: ID!) {
|
||||
connection: connectionInfo(id: $id) {
|
||||
id
|
||||
name
|
||||
description
|
||||
@@ -1,15 +0,0 @@
|
||||
mutation openConnection($config: ConnectionConfig!) {
|
||||
connection: openConnection(config: $config) {
|
||||
id
|
||||
name
|
||||
description
|
||||
driverId
|
||||
connected
|
||||
readOnly
|
||||
|
||||
features
|
||||
|
||||
authNeeded
|
||||
authModel
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,6 @@ query serverConfig {
|
||||
name
|
||||
version
|
||||
productConfiguration
|
||||
supportsPredefinedConnections
|
||||
supportsProvidedConnections
|
||||
supportsCustomConnections
|
||||
supportsConnectionBrowser
|
||||
supportsWorkspaces
|
||||
|
||||
@@ -35,6 +35,8 @@ export type Query = {
|
||||
deleteRole?: Maybe<Scalars['Boolean']>;
|
||||
deleteUser?: Maybe<Scalars['Boolean']>;
|
||||
driverList: Array<DriverInfo>;
|
||||
getConnectionAccess: Array<AdminSubjectInfo>;
|
||||
getSubjectAccess: Array<Scalars['ID']>;
|
||||
grantUserRole?: Maybe<Scalars['Boolean']>;
|
||||
listPermissions: Array<Maybe<AdminPermissionInfo>>;
|
||||
listRoles: Array<Maybe<AdminRoleInfo>>;
|
||||
@@ -51,6 +53,7 @@ export type Query = {
|
||||
sessionState: SessionInfo;
|
||||
sessionUser?: Maybe<UserAuthInfo>;
|
||||
setConnectionAccess?: Maybe<Scalars['Boolean']>;
|
||||
setSubjectAccess?: Maybe<Scalars['Boolean']>;
|
||||
setSubjectPermissions?: Maybe<Scalars['Boolean']>;
|
||||
setUserCredentials?: Maybe<Scalars['Boolean']>;
|
||||
sqlCompletionProposals?: Maybe<Array<Maybe<SqlCompletionProposal>>>;
|
||||
@@ -118,6 +121,14 @@ export type QueryDriverListArgs = {
|
||||
id?: Maybe<Scalars['ID']>;
|
||||
};
|
||||
|
||||
export type QueryGetConnectionAccessArgs = {
|
||||
connectionId?: Maybe<Scalars['ID']>;
|
||||
};
|
||||
|
||||
export type QueryGetSubjectAccessArgs = {
|
||||
subject?: Maybe<Scalars['ID']>;
|
||||
};
|
||||
|
||||
export type QueryGrantUserRoleArgs = {
|
||||
userId: Scalars['ID'];
|
||||
roleId: Scalars['ID'];
|
||||
@@ -171,6 +182,11 @@ export type QuerySetConnectionAccessArgs = {
|
||||
subjects: Array<Scalars['ID']>;
|
||||
};
|
||||
|
||||
export type QuerySetSubjectAccessArgs = {
|
||||
subjectId: Scalars['ID'];
|
||||
connections: Array<Scalars['ID']>;
|
||||
};
|
||||
|
||||
export type QuerySetSubjectPermissionsArgs = {
|
||||
roleId: Scalars['ID'];
|
||||
permissions: Array<Scalars['ID']>;
|
||||
@@ -675,6 +691,16 @@ export type SqlResultRow = {
|
||||
updateValues?: Maybe<Scalars['Object']>;
|
||||
};
|
||||
|
||||
export enum AdminSubjectType {
|
||||
User = 'user',
|
||||
Role = 'role'
|
||||
}
|
||||
|
||||
export type AdminSubjectInfo = {
|
||||
subjectId: Scalars['ID'];
|
||||
subjectType: AdminSubjectType;
|
||||
};
|
||||
|
||||
export type AdminUserInfo = {
|
||||
userId: Scalars['ID'];
|
||||
metaParameters: Scalars['Object'];
|
||||
@@ -858,11 +884,11 @@ export type ConnectionAuthPropertiesQueryVariables = Exact<{
|
||||
|
||||
export type ConnectionAuthPropertiesQuery = { connection: { authProperties: Array<Pick<ObjectPropertyInfo, 'id' | 'displayName' | 'description' | 'category' | 'dataType' | 'value' | 'validValues' | 'defaultValue' | 'features'>> } };
|
||||
|
||||
export type ConnectionStateQueryVariables = Exact<{
|
||||
export type ConnectionInfoQueryVariables = Exact<{
|
||||
id: Scalars['ID'];
|
||||
}>;
|
||||
|
||||
export type ConnectionStateQuery = { connection: Pick<ConnectionInfo, 'id' | 'name' | 'description' | 'driverId' | 'connected' | 'readOnly' | 'features' | 'authNeeded' | 'authModel'> };
|
||||
export type ConnectionInfoQuery = { connection: Pick<ConnectionInfo, 'id' | 'name' | 'description' | 'driverId' | 'connected' | 'readOnly' | 'features' | 'authNeeded' | 'authModel'> };
|
||||
|
||||
export type CreateConnectionMutationVariables = Exact<{
|
||||
config: ConnectionConfig;
|
||||
@@ -909,12 +935,6 @@ export type InitConnectionMutationVariables = Exact<{
|
||||
|
||||
export type InitConnectionMutation = { connection: Pick<ConnectionInfo, 'id' | 'name' | 'description' | 'driverId' | 'connected' | 'readOnly' | 'features' | 'authNeeded' | 'authModel'> };
|
||||
|
||||
export type OpenConnectionMutationVariables = Exact<{
|
||||
config: ConnectionConfig;
|
||||
}>;
|
||||
|
||||
export type OpenConnectionMutation = { connection: Pick<ConnectionInfo, 'id' | 'name' | 'description' | 'driverId' | 'connected' | 'readOnly' | 'features' | 'authNeeded' | 'authModel'> };
|
||||
|
||||
export type GetTemplateConnectionsQueryVariables = Exact<{ [key: string]: never }>;
|
||||
|
||||
export type GetTemplateConnectionsQuery = { connections: Array<Pick<ConnectionInfo, 'id' | 'name' | 'description' | 'driverId' | 'connected' | 'readOnly' | 'features' | 'authNeeded' | 'authModel'>> };
|
||||
@@ -1151,7 +1171,7 @@ export type ReadSessionLogQuery = { log: Array<Pick<LogEntry, 'time' | 'type' |
|
||||
export type ServerConfigQueryVariables = Exact<{ [key: string]: never }>;
|
||||
|
||||
export type ServerConfigQuery = { serverConfig: (
|
||||
Pick<ServerConfig, 'name' | 'version' | 'productConfiguration' | 'supportsPredefinedConnections' | 'supportsProvidedConnections' | 'supportsCustomConnections' | 'supportsConnectionBrowser' | 'supportsWorkspaces' | 'anonymousAccessEnabled' | 'authenticationEnabled'>
|
||||
Pick<ServerConfig, 'name' | 'version' | 'productConfiguration' | 'supportsCustomConnections' | 'supportsConnectionBrowser' | 'supportsWorkspaces' | 'anonymousAccessEnabled' | 'authenticationEnabled'>
|
||||
& { supportedLanguages: Array<Pick<ServerLanguage, 'isoCode' | 'displayName' | 'nativeName'>>; defaultNavigatorSettings: Pick<NavigatorSettings, 'showSystemObjects' | 'showUtilityObjects' | 'showOnlyEntities' | 'mergeEntities' | 'hideFolders' | 'hideSchemas' | 'hideVirtualModel'> }
|
||||
); };
|
||||
|
||||
@@ -1389,7 +1409,7 @@ export const CloseConnectionDocument = `
|
||||
`;
|
||||
export const ConnectionAuthPropertiesDocument = `
|
||||
query connectionAuthProperties($id: ID!) {
|
||||
connection: connectionState(id: $id) {
|
||||
connection: connectionInfo(id: $id) {
|
||||
authProperties {
|
||||
id
|
||||
displayName
|
||||
@@ -1404,9 +1424,9 @@ export const ConnectionAuthPropertiesDocument = `
|
||||
}
|
||||
}
|
||||
`;
|
||||
export const ConnectionStateDocument = `
|
||||
query connectionState($id: ID!) {
|
||||
connection: connectionState(id: $id) {
|
||||
export const ConnectionInfoDocument = `
|
||||
query connectionInfo($id: ID!) {
|
||||
connection: connectionInfo(id: $id) {
|
||||
id
|
||||
name
|
||||
description
|
||||
@@ -1516,21 +1536,6 @@ export const InitConnectionDocument = `
|
||||
}
|
||||
}
|
||||
`;
|
||||
export const OpenConnectionDocument = `
|
||||
mutation openConnection($config: ConnectionConfig!) {
|
||||
connection: openConnection(config: $config) {
|
||||
id
|
||||
name
|
||||
description
|
||||
driverId
|
||||
connected
|
||||
readOnly
|
||||
features
|
||||
authNeeded
|
||||
authModel
|
||||
}
|
||||
}
|
||||
`;
|
||||
export const GetTemplateConnectionsDocument = `
|
||||
query getTemplateConnections {
|
||||
connections: templateConnections {
|
||||
@@ -1921,8 +1926,6 @@ export const ServerConfigDocument = `
|
||||
name
|
||||
version
|
||||
productConfiguration
|
||||
supportsPredefinedConnections
|
||||
supportsProvidedConnections
|
||||
supportsCustomConnections
|
||||
supportsConnectionBrowser
|
||||
supportsWorkspaces
|
||||
@@ -2059,8 +2062,8 @@ export function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper =
|
||||
connectionAuthProperties(variables: ConnectionAuthPropertiesQueryVariables): Promise<ConnectionAuthPropertiesQuery> {
|
||||
return withWrapper(() => client.request<ConnectionAuthPropertiesQuery>(ConnectionAuthPropertiesDocument, variables));
|
||||
},
|
||||
connectionState(variables: ConnectionStateQueryVariables): Promise<ConnectionStateQuery> {
|
||||
return withWrapper(() => client.request<ConnectionStateQuery>(ConnectionStateDocument, variables));
|
||||
connectionInfo(variables: ConnectionInfoQueryVariables): Promise<ConnectionInfoQuery> {
|
||||
return withWrapper(() => client.request<ConnectionInfoQuery>(ConnectionInfoDocument, variables));
|
||||
},
|
||||
createConnection(variables: CreateConnectionMutationVariables): Promise<CreateConnectionMutation> {
|
||||
return withWrapper(() => client.request<CreateConnectionMutation>(CreateConnectionDocument, variables));
|
||||
@@ -2083,9 +2086,6 @@ export function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper =
|
||||
initConnection(variables: InitConnectionMutationVariables): Promise<InitConnectionMutation> {
|
||||
return withWrapper(() => client.request<InitConnectionMutation>(InitConnectionDocument, variables));
|
||||
},
|
||||
openConnection(variables: OpenConnectionMutationVariables): Promise<OpenConnectionMutation> {
|
||||
return withWrapper(() => client.request<OpenConnectionMutation>(OpenConnectionDocument, variables));
|
||||
},
|
||||
getTemplateConnections(variables?: GetTemplateConnectionsQueryVariables): Promise<GetTemplateConnectionsQuery> {
|
||||
return withWrapper(() => client.request<GetTemplateConnectionsQuery>(GetTemplateConnectionsDocument, variables));
|
||||
},
|
||||
|
||||
+12
-27
@@ -6,18 +6,17 @@
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
|
||||
import { observable, action } from 'mobx';
|
||||
import { observable } from 'mobx';
|
||||
|
||||
import {
|
||||
DBDriverResource, Connection, DatabaseAuthModelsResource
|
||||
DBDriverResource, Connection, DatabaseAuthModelsResource, ConnectionInfoResource
|
||||
} from '@cloudbeaver/core-connections';
|
||||
import { injectable, IInitializableController, IDestructibleController } from '@cloudbeaver/core-di';
|
||||
import { CommonDialogService } from '@cloudbeaver/core-dialogs';
|
||||
import { NotificationService } from '@cloudbeaver/core-events';
|
||||
import { ErrorDetailsDialog } from '@cloudbeaver/core-notifications';
|
||||
import { ConnectionConfig, GQLError, DatabaseAuthModel } from '@cloudbeaver/core-sdk';
|
||||
import { GQLError, DatabaseAuthModel } from '@cloudbeaver/core-sdk';
|
||||
|
||||
import { TemplateConnectionService } from '../TemplateConnectionService';
|
||||
import { TemplateConnectionsResource } from '../TemplateConnectionsResource';
|
||||
|
||||
export enum ConnectionStep {
|
||||
@@ -27,7 +26,7 @@ export enum ConnectionStep {
|
||||
|
||||
export interface IConnectionController {
|
||||
template: Connection | null;
|
||||
config: ConnectionConfig;
|
||||
credentials: any;
|
||||
isConnecting: boolean;
|
||||
onConnect(): void;
|
||||
}
|
||||
@@ -40,9 +39,7 @@ implements IInitializableController, IDestructibleController, IConnectionControl
|
||||
@observable isConnecting = false;
|
||||
@observable template: Connection | null = null
|
||||
@observable authModel?: DatabaseAuthModel;
|
||||
@observable config: ConnectionConfig = {
|
||||
credentials: {},
|
||||
}
|
||||
@observable credentials: any = { }
|
||||
@observable hasDetails = false
|
||||
@observable responseMessage: string | null = null
|
||||
|
||||
@@ -67,8 +64,8 @@ implements IInitializableController, IDestructibleController, IConnectionControl
|
||||
|
||||
constructor(
|
||||
private dbDriverResource: DBDriverResource,
|
||||
private connectionInfoResource: ConnectionInfoResource,
|
||||
private templateConnectionsResource: TemplateConnectionsResource,
|
||||
private templateConnectionService: TemplateConnectionService,
|
||||
private notificationService: NotificationService,
|
||||
private commonDialogService: CommonDialogService,
|
||||
private dbAuthModelsResource: DatabaseAuthModelsResource
|
||||
@@ -93,10 +90,14 @@ implements IInitializableController, IDestructibleController, IConnectionControl
|
||||
}
|
||||
|
||||
onConnect = async () => {
|
||||
if (!this.template) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.isConnecting = true;
|
||||
this.clearError();
|
||||
try {
|
||||
const connection = await this.templateConnectionService.openConnectionAsync(this.getConnectionConfig());
|
||||
const connection = await this.connectionInfoResource.init(this.template.id, this.credentials);
|
||||
|
||||
this.notificationService.logInfo({ title: `Connection ${connection.name} established` });
|
||||
this.onClose();
|
||||
@@ -112,7 +113,7 @@ implements IInitializableController, IDestructibleController, IConnectionControl
|
||||
|
||||
await this.loadAuthModel();
|
||||
this.clearError();
|
||||
this.seTemplateDefaults();
|
||||
this.credentials = {};
|
||||
|
||||
this.step = ConnectionStep.Connection;
|
||||
if (!this.authModel) {
|
||||
@@ -126,22 +127,6 @@ implements IInitializableController, IDestructibleController, IConnectionControl
|
||||
}
|
||||
}
|
||||
|
||||
private getConnectionConfig(): ConnectionConfig {
|
||||
const config: ConnectionConfig = {};
|
||||
config.templateId = this.config.templateId;
|
||||
config.authModelId = this.config.authModelId;
|
||||
config.credentials = this.config.credentials;
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
@action
|
||||
private seTemplateDefaults() {
|
||||
this.config.templateId = this.template?.id;
|
||||
this.config.authModelId = this.dbDriver?.defaultAuthModel;
|
||||
this.config.credentials = {};
|
||||
}
|
||||
|
||||
private clearError() {
|
||||
this.responseMessage = null;
|
||||
this.hasDetails = false;
|
||||
|
||||
+1
-1
@@ -86,7 +86,7 @@ export const ConnectionDialog = observer(function ConnectionDialog({
|
||||
prefix={`auth_${controller.template?.id || ''}`}
|
||||
autofillToken={`section-${controller.template?.id || ''} section-auth`}
|
||||
properties={controller.authModel.properties}
|
||||
credentials={controller.config.credentials}
|
||||
credentials={controller.credentials}
|
||||
processing={controller.isConnecting}
|
||||
/>
|
||||
</SubmittingForm>
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* cloudbeaver - Cloud Database Manager
|
||||
* Copyright (C) 2020 DBeaver Corp and others
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0.
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
|
||||
import { Connection, ConnectionsManagerService } from '@cloudbeaver/core-connections';
|
||||
import { injectable } from '@cloudbeaver/core-di';
|
||||
import { ConnectionConfig, GraphQLService } from '@cloudbeaver/core-sdk';
|
||||
|
||||
@injectable()
|
||||
export class TemplateConnectionService {
|
||||
|
||||
constructor(
|
||||
private graphQLService: GraphQLService,
|
||||
private connectionsManagerService: ConnectionsManagerService
|
||||
) {
|
||||
}
|
||||
|
||||
async openConnectionAsync(config: ConnectionConfig): Promise<Connection> {
|
||||
const { connection } = await this.graphQLService.gql.openConnection({ config });
|
||||
this.connectionsManagerService.addOpenedConnection(connection);
|
||||
return connection;
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@ import { PluginManifest } from '@cloudbeaver/core-di';
|
||||
|
||||
import { LocaleService } from './LocaleService';
|
||||
import { TemplateConnectionPluginBootstrap } from './TemplateConnectionPluginBootstrap';
|
||||
import { TemplateConnectionService } from './TemplateConnectionService';
|
||||
import { TemplateConnectionsResource } from './TemplateConnectionsResource';
|
||||
|
||||
export const connectionTemplate: PluginManifest = {
|
||||
@@ -19,7 +18,6 @@ export const connectionTemplate: PluginManifest = {
|
||||
},
|
||||
|
||||
providers: [
|
||||
TemplateConnectionService,
|
||||
TemplateConnectionsResource,
|
||||
LocaleService,
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user