Skip to content

Commit

Permalink
CB-4112 feat: require authentication for nav-tree
Browse files Browse the repository at this point in the history
  • Loading branch information
Wroud committed Oct 31, 2023
1 parent b2c41f7 commit e2ed653
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,6 @@ export class AuthenticationService extends Bootstrap {
this.authProviderService.requestAuthProvider.addHandler(this.requestAuthProviderHandler);
}

load(): void {}

private async authSessionAction(data: ISessionAction | null, contexts: IExecutionContextProvider<ISessionAction | null>) {
const action = contexts.getContext(sessionActionContext);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2023 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 { injectable } from '@cloudbeaver/core-di';
import { Executor, type IExecutor } from '@cloudbeaver/core-executor';

export interface IElementsTreeLoadData {
nodeId: string;
manual: boolean;
}

@injectable()
export class ElementsTreeService {
readonly onLoad: IExecutor<IElementsTreeLoadData>;

constructor() {
this.onLoad = new Executor();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ import { getComputed, IFolderExplorerContext, useExecutor, useObjectRef, useObse
import { ConnectionInfoActiveProjectKey, ConnectionInfoResource } from '@cloudbeaver/core-connections';
import { useService } from '@cloudbeaver/core-di';
import { NotificationService } from '@cloudbeaver/core-events';
import { ISyncExecutor, SyncExecutor } from '@cloudbeaver/core-executor';
import { ExecutorInterrupter, ISyncExecutor, SyncExecutor } from '@cloudbeaver/core-executor';
import { type NavNode, NavNodeInfoResource, NavTreeResource, ROOT_NODE_PATH } from '@cloudbeaver/core-navigation-tree';
import { ProjectInfoResource, ProjectsService } from '@cloudbeaver/core-projects';
import { CachedMapAllKey, CachedResourceOffsetPageKey, getNextPageOffset, ResourceKeyUtils } from '@cloudbeaver/core-resource';
import type { IDNDData } from '@cloudbeaver/core-ui';
import { ILoadableState, MetadataMap, throttle } from '@cloudbeaver/core-utils';

import { ElementsTreeService } from './ElementsTreeService';
import type { IElementsTreeAction } from './IElementsTreeAction';
import type { INavTreeNodeInfo } from './INavTreeNodeInfo';
import type { NavigationNodeRendererComponent } from './NavigationNodeComponent';
Expand Down Expand Up @@ -137,6 +138,7 @@ export function useElementsTree(options: IOptions): IElementsTree {
const navNodeInfoResource = useService(NavNodeInfoResource);
const navTreeResource = useService(NavTreeResource);
const connectionInfoResource = useService(ConnectionInfoResource);
const elementsTreeService = useService(ElementsTreeService);

const [localTreeNodesState] = useState(
() =>
Expand All @@ -156,6 +158,12 @@ export function useElementsTree(options: IOptions): IElementsTree {

async function handleLoadChildren(id: string, manual: boolean): Promise<boolean> {
try {
const context = await elementsTreeService.onLoad.execute({ nodeId: id, manual });

if (ExecutorInterrupter.isInterrupted(context)) {
return false;
}

return await options.loadChildren(id, manual);
} catch (exception: any) {
notificationService.logException(exception);
Expand Down
1 change: 1 addition & 0 deletions webapp/packages/plugin-navigation-tree/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export * from './NavigationTree/ElementsTree/useElementsTree';
export * from './NavigationTree/ElementsTree/ElementsTreeTools/MENU_ELEMENTS_TREE_TOOLS';
export * from './NavigationTree/ElementsTree/ElementsTreeTools/ElementsTreeToolsMenuService';
export * from './NavigationTree/ElementsTree/elementsTreeNameFilter';
export * from './NavigationTree/ElementsTree/ElementsTreeService';
export * from './NavigationTree/NavigationTreeBootstrap';
export * from './NavigationTree/NavigationTreeService';
export { default as ElementsTreeToolsStyles } from './NavigationTree/ElementsTree/ElementsTreeTools/ElementsTreeTools.m.css';
Expand Down
2 changes: 2 additions & 0 deletions webapp/packages/plugin-navigation-tree/src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import type { PluginManifest } from '@cloudbeaver/core-di';

import { LocaleService } from './LocaleService';
import { ElementsTreeService } from './NavigationTree/ElementsTree/ElementsTreeService';
import { ElementsTreeToolsMenuService } from './NavigationTree/ElementsTree/ElementsTreeTools/ElementsTreeToolsMenuService';
import { ElementsTreeSettingsService } from './NavigationTree/ElementsTree/ElementsTreeTools/NavigationTreeSettings/ElementsTreeSettingsService';
import { NavigationTreeBootstrap } from './NavigationTree/NavigationTreeBootstrap';
Expand All @@ -27,5 +28,6 @@ export const navigationTreePlugin: PluginManifest = {
NavNodeViewService,
ElementsTreeSettingsService,
NavigationTreeSettingsService,
ElementsTreeService,
],
};

0 comments on commit e2ed653

Please sign in to comment.