fix: CB-2372 folders creation access

This commit is contained in:
Wroud
2022-08-03 17:24:00 +03:00
parent bcdd0f5a31
commit 0735afc4b0
3 changed files with 25 additions and 17 deletions
@@ -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';
@@ -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),
});
@@ -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 || []);