mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-29 22:55: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
@@ -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>>;
|
||||
};
|
||||
}
|
||||
@@ -8,7 +8,11 @@ import {
|
||||
type TabProps,
|
||||
type TermixApp,
|
||||
} from "@termix/plugin-sdk/frontend";
|
||||
import { GRID_SIZE } from "./homepage/homepage.js";
|
||||
import {
|
||||
GRID_SIZE,
|
||||
type FileManagerWidgetConfig,
|
||||
type WidgetDefinition,
|
||||
} from "./homepage/homepage.js";
|
||||
import { FileManager } from "./FileManager.tsx";
|
||||
import FileManagerApp from "./FileManagerApp.tsx";
|
||||
import { SftpTransferTab } from "./SftpTransferTab.tsx";
|
||||
@@ -113,7 +117,7 @@ export function activate(app: TermixApp): void {
|
||||
fileManagerHostSetting(host, "enableFileManager", true),
|
||||
});
|
||||
|
||||
app.registerHomepageWidget({
|
||||
app.registerExtension("homepage.widgets", {
|
||||
id: "file_manager_widget",
|
||||
name: "File Manager",
|
||||
description: "Embedded SFTP file manager for a configured host",
|
||||
@@ -122,9 +126,11 @@ export function activate(app: TermixApp): void {
|
||||
defaultConfig: { hostId: 0 },
|
||||
defaultSize: { w: GRID_SIZE * 20, h: GRID_SIZE * 14 },
|
||||
minSize: { w: GRID_SIZE * 10, h: GRID_SIZE * 8 },
|
||||
component: FileManagerWidget as never,
|
||||
editFormComponent: FileManagerWidgetEditForm as never,
|
||||
});
|
||||
components: {
|
||||
view: FileManagerWidget,
|
||||
editForm: FileManagerWidgetEditForm,
|
||||
},
|
||||
} satisfies WidgetDefinition<FileManagerWidgetConfig>);
|
||||
|
||||
const openHost = ((host: PluginHostRecord | null, path?: string) =>
|
||||
openHostAction(app, host, path)) as never;
|
||||
|
||||
Reference in new issue
Block a user