mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-11-04 17:45:24 +00:00
feat: add host sections, tab embeds and the operations client to the plugin ui
This commit is contained in:
1 parent
cc725c7889
commit
631f6ac9f7
12 files changed
+184
-3
No files matched your search
@@ -0,0 +1,43 @@
|
||||
import type { ComponentType } from "react";
|
||||
import type { Host } from "@/types/ui-types";
|
||||
import { byOrderThenId, createRegistry } from "@/lib/registry";
|
||||
import type { TabShellCallbacks } from "@/shell/tab-registry";
|
||||
|
||||
export interface HostSectionRenderProps {
|
||||
host: Host;
|
||||
isVisible: boolean;
|
||||
shell: TabShellCallbacks;
|
||||
}
|
||||
|
||||
/**
|
||||
* A card a plugin adds to a host page. The page itself belongs to a plugin;
|
||||
* core only keeps the list so any plugin can fill it.
|
||||
*/
|
||||
export interface HostSectionDef {
|
||||
id: string;
|
||||
pluginId?: string;
|
||||
titleKey: string;
|
||||
order?: number;
|
||||
when: (host: Host) => boolean;
|
||||
component: ComponentType<HostSectionRenderProps>;
|
||||
}
|
||||
|
||||
const sections = createRegistry<HostSectionDef>(byOrderThenId);
|
||||
|
||||
export const registerHostSection = sections.register;
|
||||
export const useHostSections = sections.useList;
|
||||
export const listHostSections = sections.list;
|
||||
export const resetHostSections = sections.reset;
|
||||
|
||||
export function hostSectionsFor(
|
||||
all: HostSectionDef[],
|
||||
host: Host,
|
||||
): HostSectionDef[] {
|
||||
return all.filter((section) => {
|
||||
try {
|
||||
return section.when(host);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user