mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-30 07:05:24 +00:00
feat: replace core homepage widget registry with generic extension points
This commit is contained in:
1 parent
b8bbcd2196
commit
50d43e29fb
18 files changed
+242
-147
No files matched your search
@@ -236,8 +236,7 @@ export const metricsChartWidget: WidgetDefinition<MetricsChartConfig> = {
|
||||
},
|
||||
defaultSize: { w: GRID_SIZE * 12, h: GRID_SIZE * 6 },
|
||||
minSize: { w: GRID_SIZE * 6, h: GRID_SIZE * 4 },
|
||||
component: MetricsChartWidget,
|
||||
editFormComponent: MetricsChartEditForm,
|
||||
components: { view: MetricsChartWidget, editForm: MetricsChartEditForm },
|
||||
};
|
||||
|
||||
export { MetricsChartWidget };
|
||||
@@ -1,7 +1,6 @@
|
||||
import type { ComponentType } from "react";
|
||||
import { Activity, Server } from "lucide-react";
|
||||
import type {
|
||||
HomepageWidgetContribution,
|
||||
HostEditorSectionProps,
|
||||
PluginHostRecord,
|
||||
StandaloneViewProps,
|
||||
@@ -100,9 +99,7 @@ export async function activate(app: TermixApp): Promise<void> {
|
||||
component: MetricsHostSection,
|
||||
});
|
||||
|
||||
app.registerHomepageWidget(
|
||||
metricsChartWidget as unknown as HomepageWidgetContribution,
|
||||
);
|
||||
app.registerExtension("homepage.widgets", metricsChartWidget);
|
||||
|
||||
// Live CPU, memory and disk bars in the terminal toolbar's expanded view.
|
||||
app.registerSlotContribution("terminal.toolbarStatus", {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { HomepageWidgetContribution } from "@termix/plugin-sdk/frontend";
|
||||
import type { ComponentType, ReactNode } from "react";
|
||||
import type { ExtensionContribution } from "@termix/plugin-sdk/frontend";
|
||||
|
||||
/** The homepage's grid step, in pixels. */
|
||||
export const GRID_SIZE = 30;
|
||||
@@ -25,7 +26,18 @@ export interface WidgetEditFormProps<C> {
|
||||
onChange: (config: C) => void;
|
||||
}
|
||||
|
||||
export type WidgetDefinition<C> = Omit<
|
||||
HomepageWidgetContribution<C>,
|
||||
"defaultConfig"
|
||||
> & { defaultConfig: C };
|
||||
/** What app.registerExtension("homepage.widgets", ...) takes. */
|
||||
export interface WidgetDefinition<C> extends ExtensionContribution {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
category: "links" | "info" | "system" | "monitoring";
|
||||
icon: ReactNode;
|
||||
defaultConfig: C;
|
||||
defaultSize: { w: number; h: number };
|
||||
minSize: { w: number; h: number };
|
||||
components: {
|
||||
view: ComponentType<WidgetComponentProps<C>>;
|
||||
editForm?: ComponentType<WidgetEditFormProps<C>>;
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user