From c7af629d8ab5e64ba9621fc3b0b04c28a7485627 Mon Sep 17 00:00:00 2001 From: sergeyteleshev Date: Thu, 24 Oct 2024 10:04:23 +0200 Subject: [PATCH] CB-5712 adds loaders for administration menu items (#3011) * CB-5712 adds loaders for administration menu items * CB-5712 pr fixes * CB-5712 pr fix for preloading serverConfigResource in constructor * CB-5712 removes preload from AuthProviderResource --------- Co-authored-by: Daria Marutkina <125263541+dariamarutkina@users.noreply.github.com> --- .../src/AdministrationItem/IAdministrationItem.ts | 3 +++ .../src/Administration/Administration.tsx | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/webapp/packages/core-administration/src/AdministrationItem/IAdministrationItem.ts b/webapp/packages/core-administration/src/AdministrationItem/IAdministrationItem.ts index dce7254076..0ebcff7979 100644 --- a/webapp/packages/core-administration/src/AdministrationItem/IAdministrationItem.ts +++ b/webapp/packages/core-administration/src/AdministrationItem/IAdministrationItem.ts @@ -5,6 +5,8 @@ * Licensed under the Apache License, Version 2.0. * you may not use this file except in compliance with the License. */ +import type { ILoadableState } from '@cloudbeaver/core-utils'; + import type { IRouteParams } from './IRouteParams.js'; export enum AdministrationItemType { @@ -84,6 +86,7 @@ export interface IAdministrationItemOptions { replace?: IAdministrationItemReplaceOptions; defaultSub?: string; defaultParam?: string; + getLoader?: () => ILoadableState[] | ILoadableState; getDrawerComponent: () => AdministrationItemDrawerComponent; getContentComponent: () => AdministrationItemContentComponent; onLoad?: AdministrationItemEvent; diff --git a/webapp/packages/plugin-administration/src/Administration/Administration.tsx b/webapp/packages/plugin-administration/src/Administration/Administration.tsx index 14b075389a..f34bb5a942 100644 --- a/webapp/packages/plugin-administration/src/Administration/Administration.tsx +++ b/webapp/packages/plugin-administration/src/Administration/Administration.tsx @@ -24,10 +24,12 @@ import { type StyleRegistry, ToolsActionStyles, ToolsPanelStyles, + useAutoLoad, useS, } from '@cloudbeaver/core-blocks'; import { useService } from '@cloudbeaver/core-di'; import { OptionsPanelService, TabList, TabListStyles, TabsState, TabStyles } from '@cloudbeaver/core-ui'; +import type { ILoadableState } from '@cloudbeaver/core-utils'; import { CaptureView } from '@cloudbeaver/core-view'; import { AdministrationCaptureViewContext } from './AdministrationCaptureViewContext.js'; @@ -95,6 +97,9 @@ export const Administration = observer>(function const OptionsPanel = optionsPanelService.getPanelComponent(); const visibleItems = administrationItemService.getActiveItems(configurationWizard); const onlyActiveItem = administrationItemService.items.find(filterOnlyActive(configurationWizard)); + const loaders = administrationItemService.items.reduce((acc, item) => [...acc, item.getLoader?.() || []].flat(), []); + + useAutoLoad(Administration, loaders); useLayoutEffect(() => { contentRef.current?.scrollTo({ top: 0, left: 0 });