Skip to content

Commit

Permalink
CB-5955 hides folder creation for non authorized users
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyteleshev committed Dec 10, 2024
1 parent d1bd0cf commit f42eb5d
Showing 1 changed file with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,7 @@ export class ConnectionFoldersBootstrap extends Bootstrap {
this.actionService.addHandler({
id: 'tree-tools-menu-folders-handler',
contexts: [DATA_CONTEXT_ELEMENTS_TREE],
isActionApplicable: (context, action) => {
const tree = context.get(DATA_CONTEXT_ELEMENTS_TREE)!;

if (action !== ACTION_NEW_FOLDER || !this.userInfoResource.isAuthenticated() || tree.baseRoot !== ROOT_NODE_PATH) {
return false;
}

const targetNode = this.getTargetNode(tree);

return targetNode !== undefined;
},
isActionApplicable: this.isActionApplicable.bind(this),
handler: this.elementsTreeActionHandler.bind(this),
});

Expand All @@ -164,10 +154,23 @@ export class ConnectionFoldersBootstrap extends Bootstrap {
menus: [MENU_NAVIGATION_TREE_CREATE],
actions: [ACTION_CREATE_FOLDER],
contexts: [DATA_CONTEXT_ELEMENTS_TREE],
isActionApplicable: this.isActionApplicable.bind(this),
handler: this.elementsTreeActionHandler.bind(this),
});
}

private isActionApplicable(context: IDataContextProvider, action: IAction): boolean {
const tree = context.get(DATA_CONTEXT_ELEMENTS_TREE)!;

if (![ACTION_NEW_FOLDER, ACTION_CREATE_FOLDER].includes(action) || !this.userInfoResource.isAuthenticated() || tree.baseRoot !== ROOT_NODE_PATH) {
return false;
}

const targetNode = this.getTargetNode(tree);

return targetNode !== undefined;
}

private async moveConnectionToFolder({ type, targetNode, moveContexts }: INodeMoveData, contexts: IExecutionContextProvider<INodeMoveData>) {
if (![NAV_NODE_TYPE_PROJECT, NAV_NODE_TYPE_FOLDER].includes(targetNode.nodeType!)) {
return;
Expand Down

0 comments on commit f42eb5d

Please sign in to comment.