Skip to content

Commit

Permalink
CB-5712 adds loaders for administration menu items (#3011)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
sergeyteleshev and dariamarutkina authored Oct 24, 2024
1 parent 1782ce4 commit c7af629
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -84,6 +86,7 @@ export interface IAdministrationItemOptions {
replace?: IAdministrationItemReplaceOptions;
defaultSub?: string;
defaultParam?: string;
getLoader?: () => ILoadableState[] | ILoadableState;
getDrawerComponent: () => AdministrationItemDrawerComponent;
getContentComponent: () => AdministrationItemContentComponent;
onLoad?: AdministrationItemEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -95,6 +97,9 @@ export const Administration = observer<React.PropsWithChildren<Props>>(function
const OptionsPanel = optionsPanelService.getPanelComponent();
const visibleItems = administrationItemService.getActiveItems(configurationWizard);
const onlyActiveItem = administrationItemService.items.find(filterOnlyActive(configurationWizard));
const loaders = administrationItemService.items.reduce<ILoadableState[]>((acc, item) => [...acc, item.getLoader?.() || []].flat(), []);

useAutoLoad(Administration, loaders);

useLayoutEffect(() => {
contentRef.current?.scrollTo({ top: 0, left: 0 });
Expand Down

0 comments on commit c7af629

Please sign in to comment.