Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion webapp/packages/core-connections/src/ConnectionInfoResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { action, makeObservable, observable, runInAction, toJS } from 'mobx';
import { AppAuthService, UserInfoResource } from '@cloudbeaver/core-authentication';
import { injectable } from '@cloudbeaver/core-di';
import { Executor, ExecutorInterrupter, type ISyncExecutor, SyncExecutor } from '@cloudbeaver/core-executor';
import { NodeManagerUtils } from '@cloudbeaver/core-navigation-tree';
import { NavTreeResource, NodeManagerUtils } from '@cloudbeaver/core-navigation-tree';
import { ProjectInfoResource, ProjectsService } from '@cloudbeaver/core-projects';
import {
CachedMapAllKey,
Expand Down Expand Up @@ -90,6 +90,7 @@ export interface IConnectionInfoMetadata extends ICachedResourceMetadata {
ConnectionInfoEventHandler,
ConnectionStateEventHandler,
UserInfoResource,
NavTreeResource,
])
export class ConnectionInfoResource extends CachedMapResource<IConnectionInfoParams, Connection, ConnectionInfoIncludes, IConnectionInfoMetadata> {
readonly onConnectionCreate: Executor<Connection>;
Expand All @@ -109,6 +110,7 @@ export class ConnectionInfoResource extends CachedMapResource<IConnectionInfoPar
connectionInfoEventHandler: ConnectionInfoEventHandler,
connectionStateEventHandler: ConnectionStateEventHandler,
userInfoResource: UserInfoResource,
navTreeResource: NavTreeResource,
) {
super();

Expand Down Expand Up @@ -155,6 +157,14 @@ export class ConnectionInfoResource extends CachedMapResource<IConnectionInfoPar
this.markOutdated();
});

navTreeResource.onNodeRename.addHandler(data => {
const connection = this.getConnectionForNode(data.nodeId);

if (connection) {
this.markOutdated(createConnectionParam(connection));
}
});

connectionInfoEventHandler.onEvent<ResourceKeyList<IConnectionInfoParams>>(
ServerEventId.CbDatasourceCreated,
async key => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import { NavTreeSettingsService } from '../NavTreeSettingsService.js';
import type { NavNode } from './EntityTypes.js';
import { NavNodeInfoResource, ROOT_NODE_PATH } from './NavNodeInfoResource.js';
import { EObjectFeature } from './EObjectFeature.js';

// TODO: so much dirty
export interface NodePath {
Expand Down Expand Up @@ -278,7 +279,7 @@
await this.onNodeMove.execute({ key, target });
}

async setFilter(nodePath: string, include?: string[], exclude?: string[]) {

Check warning on line 282 in webapp/packages/core-navigation-tree/src/NodesManager/NavTreeResource.ts

View workflow job for this annotation

GitHub Actions / Frontend / Lint

Missing return type on function
await this.graphQLService.sdk.navSetFolderFilter({
nodePath,
exclude,
Expand All @@ -301,14 +302,18 @@
newName: name,
});

const parts = node.id.split('/');
parts.splice(parts.length - 1, 1, name);
const path = parts.join('/');

this.markOutdated(parentId);
this.markLoaded(node.id);
this.onDataOutdated.execute(parentId);

if (node.objectFeatures.includes(EObjectFeature.dataSource)) {
return node.id;
}

const parts = node.id.split('/');
parts.splice(parts.length - 1, 1, name);
const path = parts.join('/');
Comment on lines +309 to +315
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it possible we should avoid such conditions in the generic places

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can ignore it on the subscription level, but then we need to do it in every place, the connection node is just a node which id behaves differently when renaming, i think it would be strange to submit event with invalid nodeId,

I think the best optoin is to return new id from backend

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree, best option is to get new id from the backend


return path;
} finally {
this.markLoading(node.id, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { LocalizationService } from '@cloudbeaver/core-localization';
import {
DATA_CONTEXT_NAV_NODE,
ENodeFeature,
EObjectFeature,
getNodePlainName,
type INodeActions,
isConnectionFolder,
Expand Down Expand Up @@ -113,7 +114,7 @@ export class NavNodeContextMenuService extends Bootstrap {

if (NodeManagerUtils.isDatabaseObject(node.id) || isConnectionFolder(node)) {
if (action === ACTION_RENAME) {
return node.features?.includes(ENodeFeature.canRename) ?? false;
return (node.features?.includes(ENodeFeature.canRename) || node.objectFeatures.includes(EObjectFeature.dataSource)) ?? false;
Comment on lines -116 to +117
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems strange, why backend will not send canRename feature?

}

if (action === ACTION_DELETE) {
Expand Down
Loading