Skip to content

Commit

Permalink
feat: hide terminal right tab icon
Browse files Browse the repository at this point in the history
  • Loading branch information
Marckon committed Feb 7, 2025
1 parent 8e4dceb commit f84098b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/core-browser/src/layout/layout.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ export interface ExtViewContainerOptions {
hideIfEmpty?: boolean;
// 隐藏tab图标,仅挂载视图,视图切换交给其他逻辑控制
hideTab?: boolean;
// 隐藏指定位置的图标
hideLocationTab?: SlotLocation[];
noResize?: boolean;
fromExtension?: boolean;
// viewContainer 最小高度,默认 120
Expand Down
4 changes: 4 additions & 0 deletions packages/main-layout/src/browser/layout.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,10 @@ export class LayoutService extends WithEventBus implements IMainLayoutService {
this.logger.error(`cannot find container: ${containerId}`);
return;
}
if (!container.options?.draggable) {
this.logger.warn(`container: ${containerId} is not draggable`);
return;
}

const toTabbar = this.getTabbarService(to);

Expand Down
8 changes: 6 additions & 2 deletions packages/main-layout/src/browser/tabbar/bar.view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,15 @@ export const TabbarViewBase: React.FC<ITabbarViewProps> = (props) => {
});

const renderContainers = React.useCallback(
(component: ComponentRegistryInfo, tabbarService: TabbarService, currentContainerId?: string) => {
(component: ComponentRegistryInfo, tabbarService: TabbarService, currentContainerId?: string, side?: string) => {
const containerId = component.options?.containerId;
if (!containerId) {
return null;
}
if (side && component.options?.hideLocationTab?.includes(side)) {
return null;
}

tabbarService.updateTabInMoreKey(containerId, false);
let ref: HTMLLIElement | null;
return (
Expand Down Expand Up @@ -189,7 +193,7 @@ export const TabbarViewBase: React.FC<ITabbarViewProps> = (props) => {
return (
<div className={cls([styles_tab_bar, className])}>
<div className={styles_bar_content} style={{ flexDirection: Layout.getTabbarDirection(direction) }}>
{visibleContainers.map((component) => renderContainers(component, tabbarService, currentContainerId))}
{visibleContainers.map((component) => renderContainers(component, tabbarService, currentContainerId, side))}
{renderOtherVisibleContainers({ props, renderContainers })}
{hideContainers.length ? (
<li
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export class TerminalRenderContribution implements ComponentContribution, TabBar
containerId: TerminalRenderContribution.viewId,
titleComponent: TerminalTabs,
draggable: true,
hideLocationTab: ['right'],
},
);
}
Expand Down

0 comments on commit f84098b

Please sign in to comment.