From 0735afc4b09d7cbb9bad804da53b616684adbba2 Mon Sep 17 00:00:00 2001 From: Wroud Date: Wed, 3 Aug 2022 17:24:00 +0300 Subject: [PATCH] fix: CB-2372 folders creation access --- .../src/ConnectionForm/ConnectionFormState.ts | 2 +- .../NavNodes/ConnectionFoldersBootstrap.ts | 35 +++++++++++-------- .../PublicConnectionFormService.ts | 5 ++- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/webapp/packages/plugin-connections/src/ConnectionForm/ConnectionFormState.ts b/webapp/packages/plugin-connections/src/ConnectionForm/ConnectionFormState.ts index 2206918902..6be41db8f9 100644 --- a/webapp/packages/plugin-connections/src/ConnectionForm/ConnectionFormState.ts +++ b/webapp/packages/plugin-connections/src/ConnectionForm/ConnectionFormState.ts @@ -9,7 +9,7 @@ import { action, computed, makeObservable, observable } from 'mobx'; import type { IFormStateInfo } from '@cloudbeaver/core-blocks'; -import { createConnectionParam, DatabaseConnection, EConnectionFeature, IConnectionInfoParams, IConnectionsResource } from '@cloudbeaver/core-connections'; +import { createConnectionParam, DatabaseConnection, IConnectionInfoParams, IConnectionsResource } from '@cloudbeaver/core-connections'; import { Executor, IExecutionContextProvider, IExecutor } from '@cloudbeaver/core-executor'; import type { ConnectionConfig, ResourceKey } from '@cloudbeaver/core-sdk'; import { MetadataMap, uuid } from '@cloudbeaver/core-utils'; diff --git a/webapp/packages/plugin-connections/src/NavNodes/ConnectionFoldersBootstrap.ts b/webapp/packages/plugin-connections/src/NavNodes/ConnectionFoldersBootstrap.ts index 92ef15a812..3673fd8e2d 100644 --- a/webapp/packages/plugin-connections/src/NavNodes/ConnectionFoldersBootstrap.ts +++ b/webapp/packages/plugin-connections/src/NavNodes/ConnectionFoldersBootstrap.ts @@ -100,29 +100,34 @@ export class ConnectionFoldersBootstrap extends Bootstrap { this.actionService.addHandler({ id: 'tree-tools-menu-folders-handler', isActionApplicable: (context, action) => { - const tree = context.tryGet(DATA_CONTEXT_ELEMENTS_TREE); - - if (tree?.baseRoot !== ROOT_NODE_PATH || !this.userInfoResource.data) { + if (action !== ACTION_NEW_FOLDER) { return false; } - return [ACTION_NEW_FOLDER].includes(action); - }, - isDisabled: (context, action) => { const tree = context.tryGet(DATA_CONTEXT_ELEMENTS_TREE); - if (!tree) { - return true; + if (!tree || !this.userInfoResource.data) { + return false; } + const targetNode = this.getTargetNode(tree); - if (action === ACTION_NEW_FOLDER) { - const targetNode = this.getTargetNode(tree); - - return targetNode === undefined; - } - - return false; + return targetNode !== undefined; }, + // isDisabled: (context, action) => { + // const tree = context.tryGet(DATA_CONTEXT_ELEMENTS_TREE); + + // if (!tree) { + // return true; + // } + + // if (action === ACTION_NEW_FOLDER) { + // const targetNode = this.getTargetNode(tree); + + // return targetNode === undefined; + // } + + // return false; + // }, handler: this.elementsTreeActionHandler.bind(this), }); diff --git a/webapp/packages/plugin-connections/src/PublicConnectionForm/PublicConnectionFormService.ts b/webapp/packages/plugin-connections/src/PublicConnectionForm/PublicConnectionFormService.ts index 192d1010da..2d58a5395e 100644 --- a/webapp/packages/plugin-connections/src/PublicConnectionForm/PublicConnectionFormService.ts +++ b/webapp/packages/plugin-connections/src/PublicConnectionForm/PublicConnectionFormService.ts @@ -67,7 +67,10 @@ export class PublicConnectionFormService { } this.formState - .setOptions(config.connectionId ? 'edit' : 'create', 'public') + .setOptions( + config.connectionId ? 'edit' : 'create', + 'public' + ) .setConfig(projectId, config) .setAvailableDrivers(availableDrivers || []);