mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-29 14:45:24 +00:00
feat: finish the remote-desktop plugin (B14)
This commit is contained in:
1 parent
0af2c94983
commit
14eb558b85
215 files changed
+30029
-3921
No files matched your search
@@ -17,7 +17,7 @@ import { SectionCard } from "@/components/section-card";
|
||||
import { PluginIcon } from "@/lib/plugin-icon";
|
||||
import { getPlugins, type PluginSummary } from "@/api/plugins-api";
|
||||
import { SettingsFieldRow } from "./SettingsFields";
|
||||
import { isFieldActive } from "./settings-fields-util";
|
||||
import { hasVisibleFields, isFieldActive } from "./settings-fields-util";
|
||||
|
||||
/** Values for every plugin on one host: { [pluginId]: { [key]: value } }. */
|
||||
export type HostPluginSettings = Record<string, Record<string, unknown>>;
|
||||
@@ -45,7 +45,7 @@ export function usePluginHostSections(): PluginSummary[] {
|
||||
plugins.filter((plugin) => {
|
||||
if (!plugin.enabled) return false;
|
||||
const host = plugin.contributes?.settings?.host;
|
||||
return !!host && (host.fields.length > 0 || !!host.enableKey);
|
||||
return !!host && (hasVisibleFields(host.fields) || !!host.enableKey);
|
||||
}),
|
||||
[plugins],
|
||||
);
|
||||
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
HostPluginSections,
|
||||
type HostPluginSettings,
|
||||
} from "./HostPluginSections";
|
||||
import { hasVisibleFields } from "./settings-fields-util";
|
||||
|
||||
export const HOST_PLUGINS_TAB_ID = "plugins";
|
||||
|
||||
@@ -38,7 +39,7 @@ export function syncHostPluginsTab(plugins: PluginSummary[]): boolean {
|
||||
const contributors = plugins.filter((plugin) => {
|
||||
if (!plugin.enabled) return false;
|
||||
const host = plugin.contributes?.settings?.host;
|
||||
return !!host && (host.fields.length > 0 || !!host.enableKey);
|
||||
return !!host && (hasVisibleFields(host.fields) || !!host.enableKey);
|
||||
});
|
||||
|
||||
if (contributors.length === 0) {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import type { PluginSettingsField } from "@/api/plugins-api";
|
||||
|
||||
/**
|
||||
* Whether a field's `requires` gate is satisfied.
|
||||
* Whether the generic form draws a field: not hidden (the plugin edits it in
|
||||
* its own UI) and its `requires` gate satisfied.
|
||||
*
|
||||
* Kept out of the component file so both the settings page and the host editor
|
||||
* section can import it without dragging a component along.
|
||||
@@ -10,6 +11,12 @@ export function isFieldActive(
|
||||
field: PluginSettingsField,
|
||||
values: Record<string, unknown>,
|
||||
): boolean {
|
||||
if (field.hidden) return false;
|
||||
if (!field.requires) return true;
|
||||
return values[field.requires] === true;
|
||||
}
|
||||
|
||||
/** Whether a plugin has any field the generic form would ever draw. */
|
||||
export function hasVisibleFields(fields: PluginSettingsField[]): boolean {
|
||||
return fields.some((field) => !field.hidden);
|
||||
}
|
||||
Reference in new issue
Block a user