Skip to content

Commit

Permalink
refactor: remove main-layout mobx
Browse files Browse the repository at this point in the history
refactor: remove main-layout mobx
  • Loading branch information
Ricbet committed Nov 1, 2024
1 parent 01cd2c5 commit d6ff3ea
Show file tree
Hide file tree
Showing 12 changed files with 318 additions and 314 deletions.
17 changes: 12 additions & 5 deletions packages/ai-native/src/browser/layout/tabbar.view.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import cls from 'classnames';
import React, { useCallback, useEffect, useMemo } from 'react';

import { ComponentRegistryInfo, SlotLocation, useContextMenus, useInjectable } from '@opensumi/ide-core-browser';
import {
ComponentRegistryInfo,
SlotLocation,
useAutorun,
useContextMenus,
useInjectable,
} from '@opensumi/ide-core-browser';
import { EDirection } from '@opensumi/ide-core-browser/lib/components';
import {
EnhanceIcon,
Expand Down Expand Up @@ -102,25 +108,26 @@ export const AILeftTabRenderer = ({
}) => <DesignLeftTabRenderer className={className} components={components} tabbarView={AILeftTabbarRenderer} />;

const AILeftTabbarRenderer: React.FC = () => {
const tabbarService: TabbarService = useInjectable(TabbarServiceFactory)(SlotLocation.right);
const layoutService = useInjectable<IMainLayoutService>(IMainLayoutService);

const tabbarService: TabbarService = useInjectable(TabbarServiceFactory)(SlotLocation.right);
const currentContainerId = useAutorun(tabbarService.currentContainerId);

const extraMenus = React.useMemo(() => layoutService.getExtraMenu(), [layoutService]);
const [navMenu] = useContextMenus(extraMenus);

const renderOtherVisibleContainers = useCallback(
({ renderContainers }) => {
const { currentContainerId, handleTabClick } = tabbarService;
const visibleContainers = tabbarService.visibleContainers.filter((container) => !container.options?.hideTab);

return (
<>
{visibleContainers.length > 0 && <HorizontalVertical margin={'8px auto 0px'} width={'60%'} />}
{visibleContainers.map((component) => renderContainers(component, handleTabClick, currentContainerId))}
{visibleContainers.map((component) => renderContainers(component, currentContainerId))}
</>
);
},
[tabbarService],
[currentContainerId, tabbarService],
);

return (
Expand Down
2 changes: 1 addition & 1 deletion packages/design/src/browser/menu-bar/menu-bar.view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export const DesignMenuBarView = () => {

const isVisiable = React.useCallback(() => {
const tabbarService = mainLayoutService.getTabbarService(SlotLocation.left);
return !!tabbarService.currentContainerId;
return !!tabbarService.currentContainerId.get();
}, [mainLayoutService]);

return (
Expand Down
1 change: 1 addition & 0 deletions packages/main-layout/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@opensumi/ide-theme": "workspace:*"
},
"devDependencies": {
"@opensumi/ide-monaco": "workspace:*",
"@opensumi/ide-dev-tool": "workspace:*"
}
}
Loading

0 comments on commit d6ff3ea

Please sign in to comment.