mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-29 14:45: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
@@ -57,6 +57,5 @@ export const dockerWidget: WidgetDefinition<DockerWidgetConfig> = {
|
||||
defaultConfig: { hostId: 0 },
|
||||
defaultSize: { w: GRID_SIZE * 20, h: GRID_SIZE * 14 },
|
||||
minSize: { w: GRID_SIZE * 10, h: GRID_SIZE * 8 },
|
||||
component: DockerWidget,
|
||||
editFormComponent: DockerWidgetEditForm,
|
||||
components: { view: DockerWidget, editForm: DockerWidgetEditForm },
|
||||
};
|
||||
@@ -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;
|
||||
@@ -18,7 +19,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>>;
|
||||
};
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
import type { ComponentType } from "react";
|
||||
import { Box } from "lucide-react";
|
||||
import type {
|
||||
HomepageWidgetContribution,
|
||||
StandaloneViewProps,
|
||||
TabProps,
|
||||
TermixApp,
|
||||
@@ -57,9 +56,7 @@ export function activate(app: TermixApp): void {
|
||||
when: (host) => canUse && !!host.enableSsh && dockerEnabled(host),
|
||||
});
|
||||
|
||||
app.registerHomepageWidget(
|
||||
dockerWidget as unknown as HomepageWidgetContribution,
|
||||
);
|
||||
app.registerExtension("homepage.widgets", dockerWidget);
|
||||
|
||||
app.registerSlotContribution("onboarding.features", {
|
||||
actionId: "docker.feature",
|
||||
|
||||
Reference in new issue
Block a user