mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-11-01 08:05:23 +00:00
feat: add descriptions to plugin host enable toggles
This commit is contained in:
1 parent
c7fd900732
commit
7b1e0294aa
18 files changed
+53
-6
No files matched your search
@@ -690,6 +690,10 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1
|
"minLength": 1
|
||||||
},
|
},
|
||||||
|
"enableDescriptionKey": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
"fields": {
|
"fields": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
|
|||||||
@@ -269,6 +269,7 @@ export interface PluginHostSettingsContribution {
|
|||||||
/** Boolean field rendered first, gating the rest of the section. */
|
/** Boolean field rendered first, gating the rest of the section. */
|
||||||
enableKey?: string;
|
enableKey?: string;
|
||||||
enableLabelKey?: string;
|
enableLabelKey?: string;
|
||||||
|
enableDescriptionKey?: string;
|
||||||
/** What the enable switch reads before a host saves it. Off by default. */
|
/** What the enable switch reads before a host saves it. Off by default. */
|
||||||
enableDefault?: boolean;
|
enableDefault?: boolean;
|
||||||
/** Host editor strip the generated tab sits in. Defaults to "top". */
|
/** Host editor strip the generated tab sits in. Defaults to "top". */
|
||||||
@@ -1143,6 +1144,7 @@ function validateSettings(settings: unknown, errors: string[]): void {
|
|||||||
[
|
[
|
||||||
"enableKey",
|
"enableKey",
|
||||||
"enableLabelKey",
|
"enableLabelKey",
|
||||||
|
"enableDescriptionKey",
|
||||||
"enableDefault",
|
"enableDefault",
|
||||||
"editorGroup",
|
"editorGroup",
|
||||||
"editorOrder",
|
"editorOrder",
|
||||||
@@ -1162,6 +1164,13 @@ function validateSettings(settings: unknown, errors: string[]): void {
|
|||||||
// An enable switch with no label is a blank row in the host editor.
|
// An enable switch with no label is a blank row in the host editor.
|
||||||
requireString(host.enableLabelKey, `${at}.enableLabelKey`, errors);
|
requireString(host.enableLabelKey, `${at}.enableLabelKey`, errors);
|
||||||
}
|
}
|
||||||
|
if ("enableDescriptionKey" in host) {
|
||||||
|
requireString(
|
||||||
|
host.enableDescriptionKey,
|
||||||
|
`${at}.enableDescriptionKey`,
|
||||||
|
errors,
|
||||||
|
);
|
||||||
|
}
|
||||||
if ("enableDefault" in host && typeof host.enableDefault !== "boolean") {
|
if ("enableDefault" in host && typeof host.enableDefault !== "boolean") {
|
||||||
errors.push(`${at}.enableDefault must be a boolean`);
|
errors.push(`${at}.enableDefault must be a boolean`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,7 +123,8 @@
|
|||||||
"settings": {
|
"settings": {
|
||||||
"host": {
|
"host": {
|
||||||
"enable": {
|
"enable": {
|
||||||
"label": "Enable Docker"
|
"label": "Enable Docker",
|
||||||
|
"description": "Manage containers on this host."
|
||||||
},
|
},
|
||||||
"containerRuntime": {
|
"containerRuntime": {
|
||||||
"label": "Container Runtime",
|
"label": "Container Runtime",
|
||||||
|
|||||||
@@ -57,6 +57,7 @@
|
|||||||
"editorOrder": 30,
|
"editorOrder": 30,
|
||||||
"enableKey": "enableDocker",
|
"enableKey": "enableDocker",
|
||||||
"enableLabelKey": "settings.host.enable.label",
|
"enableLabelKey": "settings.host.enable.label",
|
||||||
|
"enableDescriptionKey": "settings.host.enable.description",
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"key": "containerRuntime",
|
"key": "containerRuntime",
|
||||||
|
|||||||
@@ -12,7 +12,8 @@
|
|||||||
"settings": {
|
"settings": {
|
||||||
"host": {
|
"host": {
|
||||||
"enable": {
|
"enable": {
|
||||||
"label": "Enable File Manager"
|
"label": "Enable File Manager",
|
||||||
|
"description": "Browse and edit files on this host over SFTP."
|
||||||
},
|
},
|
||||||
"defaultPath": {
|
"defaultPath": {
|
||||||
"label": "Default Path"
|
"label": "Default Path"
|
||||||
|
|||||||
@@ -75,6 +75,7 @@
|
|||||||
"editorOrder": 60,
|
"editorOrder": 60,
|
||||||
"enableKey": "enableFileManager",
|
"enableKey": "enableFileManager",
|
||||||
"enableLabelKey": "settings.host.enable.label",
|
"enableLabelKey": "settings.host.enable.label",
|
||||||
|
"enableDescriptionKey": "settings.host.enable.description",
|
||||||
"enableDefault": true,
|
"enableDefault": true,
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,7 +21,8 @@
|
|||||||
},
|
},
|
||||||
"host": {
|
"host": {
|
||||||
"enable": {
|
"enable": {
|
||||||
"label": "Enable session recording"
|
"label": "Enable session recording",
|
||||||
|
"description": "Record terminal output for this host so you can play it back or download it later."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -63,6 +63,7 @@
|
|||||||
"editorOrder": 85,
|
"editorOrder": 85,
|
||||||
"enableKey": "enableSessionRecording",
|
"enableKey": "enableSessionRecording",
|
||||||
"enableLabelKey": "settings.host.enable.label",
|
"enableLabelKey": "settings.host.enable.label",
|
||||||
|
"enableDescriptionKey": "settings.host.enable.description",
|
||||||
"fields": []
|
"fields": []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -220,6 +220,7 @@
|
|||||||
"editorOrder": 12,
|
"editorOrder": 12,
|
||||||
"enableKey": "enableTerminal",
|
"enableKey": "enableTerminal",
|
||||||
"enableLabelKey": "settings.host.enableTerminal.label",
|
"enableLabelKey": "settings.host.enableTerminal.label",
|
||||||
|
"enableDescriptionKey": "settings.host.enableTerminal.description",
|
||||||
"enableDefault": true,
|
"enableDefault": true,
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,7 +20,8 @@
|
|||||||
"settings": {
|
"settings": {
|
||||||
"host": {
|
"host": {
|
||||||
"enable": {
|
"enable": {
|
||||||
"label": "Enable Tmux Monitor"
|
"label": "Enable Tmux Monitor",
|
||||||
|
"description": "Watch and attach to tmux sessions running on this host."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -50,6 +50,7 @@
|
|||||||
"host": {
|
"host": {
|
||||||
"enableKey": "enableTmuxMonitor",
|
"enableKey": "enableTmuxMonitor",
|
||||||
"enableLabelKey": "settings.host.enable.label",
|
"enableLabelKey": "settings.host.enable.label",
|
||||||
|
"enableDescriptionKey": "settings.host.enable.description",
|
||||||
"fields": []
|
"fields": []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -153,7 +153,8 @@
|
|||||||
"settings": {
|
"settings": {
|
||||||
"host": {
|
"host": {
|
||||||
"enable": {
|
"enable": {
|
||||||
"label": "Enable tunnels"
|
"label": "Enable tunnels",
|
||||||
|
"description": "Set up SSH tunnels through this host."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,6 +71,7 @@
|
|||||||
"host": {
|
"host": {
|
||||||
"enableKey": "enableTunnel",
|
"enableKey": "enableTunnel",
|
||||||
"enableLabelKey": "settings.host.enable.label",
|
"enableLabelKey": "settings.host.enable.label",
|
||||||
|
"enableDescriptionKey": "settings.host.enable.description",
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"key": "tunnelConnections",
|
"key": "tunnelConnections",
|
||||||
|
|||||||
@@ -175,6 +175,7 @@ export function declaredFields(
|
|||||||
key: host.enableKey,
|
key: host.enableKey,
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
labelKey: host.enableLabelKey,
|
labelKey: host.enableLabelKey,
|
||||||
|
descriptionKey: host.enableDescriptionKey,
|
||||||
default: host.enableDefault ?? false,
|
default: host.enableDefault ?? false,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -301,6 +301,21 @@ describe("contributes.settings", () => {
|
|||||||
expect(errors.join(" ")).toContain("enableLabelKey");
|
expect(errors.join(" ")).toContain("enableLabelKey");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("accepts an enableDescriptionKey and rejects an empty one", () => {
|
||||||
|
const host = { enableKey: "enableThing", enableLabelKey: "k", fields: [] };
|
||||||
|
|
||||||
|
expect(
|
||||||
|
validateManifest(
|
||||||
|
withSettings({ host: { ...host, enableDescriptionKey: "d" } }),
|
||||||
|
),
|
||||||
|
).toEqual([]);
|
||||||
|
expect(
|
||||||
|
validateManifest(
|
||||||
|
withSettings({ host: { ...host, enableDescriptionKey: "" } }),
|
||||||
|
).join(" "),
|
||||||
|
).toContain("enableDescriptionKey");
|
||||||
|
});
|
||||||
|
|
||||||
it("rejects a key that would not be index-safe", () => {
|
it("rejects a key that would not be index-safe", () => {
|
||||||
const errors = validateManifest(
|
const errors = validateManifest(
|
||||||
withSettings({
|
withSettings({
|
||||||
|
|||||||
@@ -183,13 +183,18 @@ describe("declaredFields", () => {
|
|||||||
host: {
|
host: {
|
||||||
enableKey: "enableThing",
|
enableKey: "enableThing",
|
||||||
enableLabelKey: "k",
|
enableLabelKey: "k",
|
||||||
|
enableDescriptionKey: "d",
|
||||||
fields: [{ key: "port", type: "number", labelKey: "k" }],
|
fields: [{ key: "port", type: "number", labelKey: "k" }],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const fields = declaredFields(withHost, "host");
|
const fields = declaredFields(withHost, "host");
|
||||||
expect(fields.map((f) => f.key)).toEqual(["enableThing", "port"]);
|
expect(fields.map((f) => f.key)).toEqual(["enableThing", "port"]);
|
||||||
expect(fields[0]).toMatchObject({ type: "boolean", default: false });
|
expect(fields[0]).toMatchObject({
|
||||||
|
type: "boolean",
|
||||||
|
default: false,
|
||||||
|
descriptionKey: "d",
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("finds a field by key", () => {
|
it("finds a field by key", () => {
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ export interface PluginSettingsField {
|
|||||||
export interface PluginHostSettingsContribution {
|
export interface PluginHostSettingsContribution {
|
||||||
enableKey?: string;
|
enableKey?: string;
|
||||||
enableLabelKey?: string;
|
enableLabelKey?: string;
|
||||||
|
enableDescriptionKey?: string;
|
||||||
enableDefault?: boolean;
|
enableDefault?: boolean;
|
||||||
editorGroup?: "top" | "ssh";
|
editorGroup?: "top" | "ssh";
|
||||||
editorOrder?: number;
|
editorOrder?: number;
|
||||||
|
|||||||
@@ -192,6 +192,7 @@ function HostPluginSection({
|
|||||||
key: enableKey,
|
key: enableKey,
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
labelKey: host.enableLabelKey,
|
labelKey: host.enableLabelKey,
|
||||||
|
descriptionKey: host.enableDescriptionKey,
|
||||||
}}
|
}}
|
||||||
values={shown}
|
values={shown}
|
||||||
setValue={setValue}
|
setValue={setValue}
|
||||||
|
|||||||
Reference in new issue
Block a user