Skip to content

The IDE you know, rebuilt in Rust. IntelliJ IDEA–style keymap, tool windows and search-everywhere in a fast native app: editor, code insight, debugger, Git, terminal, database and HTTP clients for 60+ languages.

feat(plugins): tool-window web views can draw their own header (#2047)

Deng Liubd1a3ce1e3b2
diff --git a/crates/ide-host/src/plugins/ui_points.rs b/crates/ide-host/src/plugins/ui_points.rs
index 597eb8b35..b2bf25f7e 100644
--- a/crates/ide-host/src/plugins/ui_points.rs
+++ b/crates/ide-host/src/plugins/ui_points.rs
@@ -407,6 +407,9 @@ struct ViewDecl {
/// Show the selected tree/list item's detail-provider tabs beside it.
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
detail: bool,
+ /// `default` or `none` (tool-window web views that render their own header row).
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ header: Option<String>,
/// A web page of the package (`web/index.html`) instead of content the code renders.
#[serde(default, skip_serializing_if = "Option::is_none")]
web: Option<String>,
@@ -452,6 +455,18 @@ pub(super) fn view(pkg: &Package, decl: toml::Value) -> Result<UiDecl, String> {
return Err(format!("view {:?}: `detail` needs a tree or list rendered by the plugin (no `web`)", d.id));
}
}
+ if let Some(header) = &d.header {
+ pkg.manifest.needs_api("contributes.views.header", 3)?;
+ if header != "default" && header != "none" {
+ return Err(format!("view {:?}: `header` is default or none", d.id));
+ }
+ if header == "none" && (d.web.is_none() || d.group.is_some()) {
+ return Err(format!(
+ "view {:?}: `header = \"none\"` is only for ungrouped tool-window web views (`web`)",
+ d.id
+ ));
+ }
+ }
if d.icon.as_ref().is_some_and(|i| i.len() > 64) {
return Err(format!("view {:?}: icon names are up to 64 bytes", d.id));
}
diff --git a/crates/ide-host/tests/plugins.rs b/crates/ide-host/tests/plugins.rs
index 011d611cb..00b22406e 100644
--- a/crates/ide-host/tests/plugins.rs
+++ b/crates/ide-host/tests/plugins.rs
@@ -5128,3 +5128,31 @@ fn files_changed_filters_each_category_before_waking_idle_plugins() {
}]
);
}
+
+#[test]
+fn view_header_none_needs_api_1_3_and_an_ungrouped_web_view() {
+ let f = fixture(Limits::default());
+ let tmp = tempfile::tempdir().unwrap();
+ let pkg = tmp.path().join("headerless");
+ std::fs::create_dir_all(pkg.join("web")).unwrap();
+ std::fs::write(pkg.join("web/index.html"), "<!doctype html><p>hi</p>").unwrap();
+ let manifest = |engine: &str, view_fields: &str| {
+ format!(
+ "id = \"headerless\"\nname = \"Headerless\"\nversion = \"1.0.0\"\nengines.openidea = \"{engine}\"\n[[contributes.views]]\nid = \"panel\"\ntitle = \"Panel\"\nlocation = \"bottom\"\n{view_fields}\n"
+ )
+ };
+ for (engine, fields, expected) in [
+ ("^1.2", "web = \"web/index.html\"\nheader = \"none\"", "new in plugin API 1.3"),
+ ("^1.3", "web = \"web/index.html\"\nheader = \"custom\"", "default or none"),
+ ("^1.3", "header = \"none\"", "give a web page"),
+ ("^1.3", "web = \"web/index.html\"\ngroup = \"g\"\nheader = \"none\"", "ungrouped"),
+ ] {
+ std::fs::write(pkg.join("plugin.toml"), manifest(engine, fields)).unwrap();
+ let err = f.host.install_from_dir(&pkg, &Consent::all()).unwrap_err().message;
+ assert!(err.contains(expected), "{fields}: {err}");
+ }
+ std::fs::write(pkg.join("plugin.toml"), manifest("^1.3", "web = \"web/index.html\"\nheader = \"none\"")).unwrap();
+ let info = f.install(&pkg);
+ assert_eq!(info.status, PluginStatus::Static, "{:?}", info.error);
+ assert_eq!(f.host.ui_items("views")[0].decl["header"], "none");
+}
diff --git a/plugins/README.md b/plugins/README.md
index 2ecf64836..ad00046db 100644
--- a/plugins/README.md
+++ b/plugins/README.md
@@ -1046,6 +1046,23 @@ Save, the dirty mark and Undo are the document's, as for every custom editor.
IDE shortcuts the page doesn't handle itself (Save, Close, Find Action…) still
work while it has focus; editing keys (⌘C, ⌘V, ⌘Z…) stay with the page. With
the `clipboard` capability the page may use `navigator.clipboard`.
+An ungrouped tool-window web view that renders its own top bar can declare
+`header = "none"` (API 1.3: `engines.openidea = "^1.3"`): once the page is
+ready, the IDE replaces the standard tool-window header with top-right corner
+actions (`Options` and `Hide`) and sets `--openidea-corner-inset-width` (`64px`)
+and `--openidea-corner-inset-height` (`34px`) on the frame's root element (and
+in `openidea.theme.vars`) so the page can pad its top bar around them. Loading
+and error states keep the standard tool-window header.
+Omitting `header` (or setting `header = "default"`) keeps the standard header.
+For example, a page can reserve the corner in its own toolbar:
+
+```css
+.toolbar {
+ min-height: var(--openidea-corner-inset-height, 0px);
+ padding-right: var(--openidea-corner-inset-width, 0px);
+}
+```
+
`plugins/official/excalidraw` is a complete example: a Vite + React page in
`web-src/`, built into `web/` by `plugins/build.sh`. `plugins/official/graphviz`
pairs a page with code: the page renders (Graphviz compiled to WebAssembly) and
diff --git a/src/features/plugins/__tests__/webViews.test.tsx b/src/features/plugins/__tests__/webViews.test.tsx
index e60b0792d..024964fe3 100644
--- a/src/features/plugins/__tests__/webViews.test.tsx
+++ b/src/features/plugins/__tests__/webViews.test.tsx
@@ -1,8 +1,12 @@
import { afterEach, describe, expect, it, vi } from "vitest";
-import { act, render, waitFor } from "@testing-library/react";
+import { act, fireEvent, render, screen, waitFor } from "@testing-library/react";
+import userEvent from "@testing-library/user-event";
import type { PluginInfo, ViewEvent } from "@/bindings";
import { addFileIconProvider, fileIconName, registerExternalIcons } from "@/ui";
import { provideEditorService, type EditorInput, type EditorService } from "@/workbench/contributions";
+import { useProject } from "@/platform/project";
+import { isToolWindowVisible, resetToolWindowLayout, showToolWindow } from "@/workbench/toolwindows/store";
+import { ToolWindowLayout } from "@/workbench/toolwindows/ToolWindows";
import {
addContributedFileTemplate,
fileTemplates,
@@ -375,6 +379,155 @@ describe("WebView", () => {
expect(events).toEqual([]);
view.unmount();
});
+
+ it("keeps the standard tool-window header unless header = 'none', preserves it while loading or on error, and renders keyboard-operable corner actions with inset vars when ready", async () => {
+ resetToolWindowLayout();
+ const prevProject = useProject.getState().project;
+ useProject.setState({ project: { root: "/proj", name: "proj", trusted: true } as never });
+ const undefine = defineViewUiPoints();
+ try {
+ let resolveUrl!: (url: string) => void;
+ let rejectUrl!: (err: Error) => void;
+ let mode: "pending" | "ready" | "error" = "ready";
+ setPluginsBackend({
+ ...createMemoryPluginsBackend([]),
+ webPageUrl: () =>
+ mode === "ready"
+ ? Promise.resolve("about:blank")
+ : mode === "error"
+ ? Promise.reject(new Error("page missing"))
+ : new Promise<string>((res, rej) => {
+ resolveUrl = res;
+ rejectUrl = rej;
+ }),
+ });
+ const plugin = { id: "acme.kube", version: "1.0.0", hasCode: false, capabilities: [] } as unknown as PluginInfo;
+ usePlugins.setState({ plugins: [plugin] });
+
+ // 1. Default web view (without header = "none"): keeps the standard <header>.
+ syncUiContributions(
+ [
+ {
+ pluginId: "acme.kube",
+ point: "views",
+ key: "normal",
+ decl: { id: "normal", title: "Normal View", location: "bottom", web: "web/index.html" },
+ },
+ ],
+ [plugin],
+ );
+ showToolWindow("plugin.acme.kube.normal");
+ const first = render(<ToolWindowLayout editor={null} />);
+ const normal = await frameOf(first.container);
+ fireEvent.load(normal.frame);
+ expect(
+ normal.posted.some((m) => (m.theme as { vars: Record<string, string> })?.vars["--openidea-corner-inset-width"]),
+ ).toBe(false);
+ expect(first.container.querySelector('[data-toolwindow="plugin.acme.kube.normal"] header')).not.toBeNull();
+ expect(screen.getByText("Normal View")).toBeInTheDocument();
+ first.unmount();
+ clearUiContributions();
+
+ // 2. Loading state with header = "none": keeps the standard <header> (title + Options + Hide) until ready.
+ mode = "pending";
+ syncUiContributions(
+ [
+ {
+ pluginId: "acme.kube",
+ point: "views",
+ key: "cluster",
+ decl: {
+ id: "cluster",
+ title: "Cluster Explorer",
+ location: "bottom",
+ web: "web/index.html",
+ header: "none",
+ },
+ },
+ ],
+ [plugin],
+ );
+ showToolWindow("plugin.acme.kube.cluster");
+ const second = render(<ToolWindowLayout editor={null} />);
+ expect(second.container.querySelector('[data-toolwindow="plugin.acme.kube.cluster"] header')).not.toBeNull();
+ expect(screen.getByText("Cluster Explorer")).toBeInTheDocument();
+ expect(screen.getByRole("button", { name: "Options" })).toBeInTheDocument();
+ expect(screen.getByRole("button", { name: "Hide" })).toBeInTheDocument();
+
+ // A resolved URL is still loading until the iframe has loaded.
+ act(() => resolveUrl("https://plugin.invalid/revision-1"));
+ const { frame, posted } = await frameOf(second.container);
+ expect(second.container.querySelector('[data-toolwindow="plugin.acme.kube.cluster"] header')).not.toBeNull();
+ fireEvent.load(frame);
+ await waitFor(() =>
+ expect(second.container.querySelector('[data-toolwindow="plugin.acme.kube.cluster"] header')).toBeNull(),
+ );
+ expect(second.container.querySelector("iframe")).toBe(frame);
+ await waitFor(() =>
+ expect(
+ posted.some(
+ (m) =>
+ (m.theme as { vars?: Record<string, string> } | undefined)?.vars?.["--openidea-corner-inset-width"] ===
+ "64px" &&
+ (m.theme as { vars?: Record<string, string> } | undefined)?.vars?.["--openidea-corner-inset-height"] ===
+ "34px",
+ ),
+ ).toBe(true),
+ );
+
+ act(() => usePlugins.setState({ plugins: [{ ...plugin, version: "1.0.1" }] }));
+ act(() => resolveUrl("https://plugin.invalid/revision-2"));
+ await waitFor(() => expect(frame).toHaveAttribute("src", "https://plugin.invalid/revision-2"));
+ expect(second.container.querySelector('[data-toolwindow="plugin.acme.kube.cluster"] header')).not.toBeNull();
+ expect(second.container.querySelector("iframe")).toBe(frame);
+ fireEvent.load(frame);
+ expect(second.container.querySelector('[data-toolwindow="plugin.acme.kube.cluster"] header')).toBeNull();
+
+ act(() => usePlugins.setState({ plugins: [{ ...plugin, version: "1.0.2" }] }));
+ act(() => rejectUrl(new Error("page missing")));
+ await waitFor(() => expect(screen.getByText("page missing")).toBeInTheDocument());
+ expect(second.container.querySelector('[data-toolwindow="plugin.acme.kube.cluster"] header')).not.toBeNull();
+ act(() => usePlugins.setState({ plugins: [{ ...plugin, version: "1.0.3" }] }));
+ act(() => resolveUrl("https://plugin.invalid/revision-2"));
+ const recovered = await frameOf(second.container);
+ expect(second.container.querySelector('[data-toolwindow="plugin.acme.kube.cluster"] header')).not.toBeNull();
+ fireEvent.load(recovered.frame);
+ expect(second.container.querySelector('[data-toolwindow="plugin.acme.kube.cluster"] header')).toBeNull();
+
+ const user = userEvent.setup();
+ const optionsBtn = screen.getByRole("button", { name: "Options" });
+ optionsBtn.focus();
+ expect(document.activeElement).toBe(optionsBtn);
+ await user.keyboard("{Enter}");
+ expect(optionsBtn).toHaveAttribute("aria-expanded", "true");
+ await user.keyboard("{Escape}");
+ expect(optionsBtn).toHaveAttribute("aria-expanded", "false");
+
+ const hideBtn = screen.getByRole("button", { name: "Hide" });
+ await user.tab();
+ expect(document.activeElement).toBe(hideBtn);
+ await user.keyboard(" ");
+ expect(isToolWindowVisible("plugin.acme.kube.cluster")).toBe(false);
+ second.unmount();
+
+ // 4. Error state with header = "none": keeps the standard <header> so the user still has title, Options, and Hide.
+ mode = "pending";
+ act(() => usePlugins.setState({ plugins: [{ ...plugin, version: "1.0.1" }] }));
+ showToolWindow("plugin.acme.kube.cluster");
+ const third = render(<ToolWindowLayout editor={null} />);
+ act(() => rejectUrl(new Error("page missing")));
+ await waitFor(() => expect(screen.getByText("page missing")).toBeInTheDocument());
+ expect(third.container.querySelector('[data-toolwindow="plugin.acme.kube.cluster"] header')).not.toBeNull();
+ expect(screen.getByText("Cluster Explorer")).toBeInTheDocument();
+ expect(screen.getByRole("button", { name: "Hide" })).toBeInTheDocument();
+ third.unmount();
+ } finally {
+ clearUiContributions();
+ undefine();
+ useProject.setState({ project: prevProject });
+ resetToolWindowLayout();
+ }
+ });
});
describe("contributed file icons and templates", () => {
diff --git a/src/features/plugins/uiPoints.tsx b/src/features/plugins/uiPoints.tsx
index 856377fba..ba21f8621 100644
--- a/src/features/plugins/uiPoints.tsx
+++ b/src/features/plugins/uiPoints.tsx
@@ -368,6 +368,7 @@ interface ViewDecl {
icon?: string | null;
location: ToolWindowAnchor | "services";
detail?: boolean;
+ header?: "default" | "none" | null;
web?: string;
group?: string | null;
when?: string | null;
@@ -476,7 +477,12 @@ function projectView(pluginId: string, decl: ViewDecl, index: number): () => voi
initialIcon,
() =>
decl.web ? (
- <WebView pluginId={pluginId} view={decl.id} label={decl.title} />
+ <WebView
+ pluginId={pluginId}
+ view={decl.id}
+ label={decl.title}
+ header={decl.header === "none" ? "none" : "default"}
+ />
) : (
<PluginView pluginId={pluginId} view={decl.id} detail={decl.detail} label={decl.title} itemMenu={itemMenu} />
),
diff --git a/src/features/plugins/views/PluginView.module.css b/src/features/plugins/views/PluginView.module.css
index d90af139f..808529405 100644
--- a/src/features/plugins/views/PluginView.module.css
+++ b/src/features/plugins/views/PluginView.module.css
@@ -193,6 +193,19 @@
color: var(--fg-muted);
}
+.webWrap {
+ position: relative;
+ width: 100%;
+ height: 100%;
+}
+
+.cornerActions {
+ position: absolute;
+ top: 5px;
+ right: 8px;
+ z-index: 20;
+}
+
.frame {
border: none;
width: 100%;
diff --git a/src/features/plugins/views/WebView.tsx b/src/features/plugins/views/WebView.tsx
index 74a6660a2..4c5ebd8ea 100644
--- a/src/features/plugins/views/WebView.tsx
+++ b/src/features/plugins/views/WebView.tsx
@@ -21,9 +21,10 @@ import { useProject } from "@/platform/project";
import { subscribeTheme, themeKey } from "@/platform/themeWatch";
import { EmptyState, Spinner } from "@/ui";
import { editorService } from "@/workbench/contributions";
+import { ToolWindowCornerActions, useOwnToolWindowHeader } from "@/workbench/toolwindows/ToolWindows";
import { pluginsBackend, type FileFilter } from "../backend";
import { errorText, usePlugins } from "../store";
-import { FRAME_TAG, frameTheme, frameThemeMessage } from "./frame";
+import { FRAME_TAG, HEADERLESS_CORNER_INSET, frameTheme, frameThemeMessage } from "./frame";
import { PLUGIN_LOG_EDITOR_KIND } from "./logEditor";
import { logTabData } from "./logTab";
import { webPtyBackend } from "./ptyBackend";
@@ -133,15 +134,21 @@ export interface WebViewProps {
pluginId: string;
view: string;
label: string;
+ /** `none` hides the tool window's header row once the frame is ready and overlays corner actions. */
+ header?: "default" | "none";
/** The custom editor's document; none in a tool window. */
document?: FrameDocument | null;
/** The backend document, for messages to the plugin's code. */
doc?: number | null;
}
-export function WebView({ pluginId, view, label, document = null, doc = null }: WebViewProps) {
+export function WebView({ pluginId, view, label, header = "default", document = null, doc = null }: WebViewProps) {
const plugin = usePlugins((s) => s.plugins.find((p) => p.id === pluginId));
const page = usePageUrl(pluginId, view, plugin);
+ const [loadedPage, setLoadedPage] = useState<PageState | null>(null);
+ const ownHeader = !document && header === "none";
+ const headless = ownHeader && page !== null && "url" in page && loadedPage === page;
+ useOwnToolWindowHeader(headless);
const hasCode = plugin?.hasCode ?? false;
const clipboard = plugin?.capabilities.some((c) => c.id === "clipboard" && c.granted) ?? false;
const frame = useRef<HTMLIFrameElement>(null);
@@ -149,7 +156,14 @@ export function WebView({ pluginId, view, label, document = null, doc = null }:
const post = useCallback((message: object, transfer: Transferable[] = []) => {
frame.current?.contentWindow?.postMessage({ tag: FRAME_TAG, ...message }, "*", transfer);
}, []);
- const postTheme = useCallback(() => post(frameThemeMessage(frameTheme())), [post]);
+ const postTheme = useCallback(() => {
+ const t = frameTheme();
+ if (ownHeader) {
+ t.vars["--openidea-corner-inset-width"] = `${HEADERLESS_CORNER_INSET.width}px`;
+ t.vars["--openidea-corner-inset-height"] = `${HEADERLESS_CORNER_INSET.height}px`;
+ }
+ post(frameThemeMessage(t));
+ }, [ownHeader, post]);
const theme = useSyncExternalStore(subscribeTheme, themeKey, () => "");
useEffect(postTheme, [theme, postTheme]);
@@ -308,7 +322,7 @@ export function WebView({ pluginId, view, label, document = null, doc = null }:
</EmptyState>
);
// No `allow-same-origin`: an opaque origin without access to the IDE. `onLoad` sends the theme.
- return (
+ const iframe = (
<iframe
ref={frame}
className={styles.frame}
@@ -316,7 +330,17 @@ export function WebView({ pluginId, view, label, document = null, doc = null }:
sandbox="allow-scripts"
allow={clipboard ? "clipboard-read; clipboard-write" : undefined}
src={page.url}
- onLoad={postTheme}
+ onLoad={() => {
+ postTheme();
+ setLoadedPage(page);
+ }}
/>
);
+ if (!ownHeader) return iframe;
+ return (
+ <div className={styles.webWrap}>
+ {headless && <ToolWindowCornerActions className={styles.cornerActions} />}
+ {iframe}
+ </div>
+ );
}
diff --git a/src/features/plugins/views/frame.ts b/src/features/plugins/views/frame.ts
index 5b4b71b6a..103642350 100644
--- a/src/features/plugins/views/frame.ts
+++ b/src/features/plugins/views/frame.ts
@@ -76,6 +76,9 @@ export function frameTheme(root: HTMLElement = document.documentElement): FrameT
return { dark: root.dataset.theme !== "light", vars };
}
+/** Top-right space reserved for `ToolWindowCornerActions` when a web view uses `header = "none"`. */
+export const HEADERLESS_CORNER_INSET = { width: 64, height: 34 } as const;
+
/** The message that updates a loaded frame's theme. */
export const frameThemeMessage = (theme: FrameTheme) => ({ tag: FRAME_TAG, theme });
diff --git a/src/workbench/toolwindows/ToolWindows.tsx b/src/workbench/toolwindows/ToolWindows.tsx
index eb425dc4f..f4628773c 100644
--- a/src/workbench/toolwindows/ToolWindows.tsx
+++ b/src/workbench/toolwindows/ToolWindows.tsx
@@ -618,6 +618,72 @@ export function ToolWindowHeader({
);
}
+/**
+ * The Options (`⋮` Move To / Maximize / Hide) and Hide (`—`) buttons of a tool
+ * window that uses `useOwnToolWindowHeader` without a full `ToolWindowHeader`.
+ */
+export function ToolWindowCornerActions({ className }: { className?: string }) {
+ const tw = useContext(ToolWindowFrame)?.tw;
+ if (!tw) return null;
+ return <ToolWindowActionsBar tw={tw} className={className} />;
+}
+
+function ToolWindowActionsBar({ tw, className }: { tw: ToolWindowContribution; className?: string }) {
+ const maximized = useToolWindowLayout((s) => s.maximized === tw.anchor);
+ const [moreOpen, setMoreOpen] = useState(false);
+ const moreRef = useRef<HTMLButtonElement>(null);
+ const Actions = tw.headerActions;
+
+ const useHeaderMenu = typeof tw.headerMenu === "function" ? tw.headerMenu : staticHeaderMenu(tw.headerMenu);
+ const own = useHeaderMenu(tw.id);
+ const more: MenuItem[] = [
+ ...own,
+ ...(own.length ? [{ kind: "separator" } as MenuItem] : []),
+ moveToMenu(tw),
+ {
+ label: maximized ? "Restore Size" : "Maximize",
+ icon: maximized ? "minimize" : "maximize",
+ run: () => toggleMaximizeToolWindow(tw.id),
+ },
+ { kind: "separator" },
+ { label: "Hide", icon: "hide", shortcut: shortcutLabel("toolwindow.hideActive"), run: () => hideToolWindow(tw.id) },
+ ];
+
+ return (
+ <>
+ <div className={clsx(styles.headerActions, className)}>
+ {Actions && <Actions id={tw.id} />}
+ <IconButton
+ ref={moreRef}
+ icon="more"
+ title="Options"
+ size="small"
+ iconSize={16}
+ aria-haspopup="menu"
+ aria-expanded={moreOpen}
+ onClick={() => setMoreOpen((v) => !v)}
+ />
+ <IconButton
+ icon="minus"
+ title="Hide"
+ shortcut={shortcutLabel("toolwindow.hideActive")}
+ size="small"
+ iconSize={16}
+ onClick={() => hideToolWindow(tw.id)}
+ />
+ </div>
+ <Menu
+ open={moreOpen}
+ onClose={() => setMoreOpen(false)}
+ anchor={moreRef}
+ items={more}
+ placement="bottom-end"
+ aria-label={tx`${titleOf(tw)} options`}
+ />
+ </>
+ );
+}
+
function HeaderRow({
tw,
title,
@@ -629,12 +695,8 @@ function HeaderRow({
actions: boolean;
children?: ReactNode;
}) {
- const maximized = useToolWindowLayout((s) => s.maximized === tw.anchor);
- const [moreOpen, setMoreOpen] = useState(false);
const [titleOpen, setTitleOpen] = useState(false);
- const moreRef = useRef<HTMLButtonElement>(null);
const titleRef = useRef<HTMLButtonElement>(null);
- const Actions = tw.headerActions;
const showTitle = title && !(tw.headerContent && tw.tabsReplaceTitle);
const useHeaderMenu = typeof tw.headerMenu === "function" ? tw.headerMenu : staticHeaderMenu(tw.headerMenu);
@@ -642,18 +704,6 @@ function HeaderRow({
const useTitleMenu = tw.titleMenu ?? noTitleMenu;
const titleMenu = useTitleMenu(tw.id);
const titleItems = titleMenu?.items ?? own;
- const more: MenuItem[] = [
- ...own,
- ...(own.length ? [{ kind: "separator" } as MenuItem] : []),
- moveToMenu(tw),
- {
- label: maximized ? "Restore Size" : "Maximize",
- icon: maximized ? "minimize" : "maximize",
- run: () => toggleMaximizeToolWindow(tw.id),
- },
- { kind: "separator" },
- { label: "Hide", icon: "hide", shortcut: shortcutLabel("toolwindow.hideActive"), run: () => hideToolWindow(tw.id) },
- ];
return (
<header
@@ -694,39 +744,7 @@ function HeaderRow({
)}
{children && <div className={clsx(styles.headerContent, !showTitle && styles.headerContentOnly)}>{children}</div>}
<div className={styles.headerSpacer} />
- {actions && (
- <>
- <div className={styles.headerActions}>
- {Actions && <Actions id={tw.id} />}
- <IconButton
- ref={moreRef}
- icon="more"
- title="Options"
- size="small"
- iconSize={16}
- aria-haspopup="menu"
- aria-expanded={moreOpen}
- onClick={() => setMoreOpen((v) => !v)}
- />
- <IconButton
- icon="minus"
- title="Hide"
- shortcut={shortcutLabel("toolwindow.hideActive")}
- size="small"
- iconSize={16}
- onClick={() => hideToolWindow(tw.id)}
- />
- </div>
- <Menu
- open={moreOpen}
- onClose={() => setMoreOpen(false)}
- anchor={moreRef}
- items={more}
- placement="bottom-end"
- aria-label={tx`${titleOf(tw)} options`}
- />
- </>
- )}
+ {actions && <ToolWindowActionsBar tw={tw} />}
</header>
);
}