diff --git a/static/scripts/config-parser.ts b/static/scripts/config-parser.ts index 8f3ac27..25ea64e 100644 --- a/static/scripts/config-parser.ts +++ b/static/scripts/config-parser.ts @@ -142,7 +142,7 @@ export class ConfigParser { owner: org, repo: repo, path, - message: `chore: updating config`, + message: `chore: Plugin Installer UI - update`, content: btoa(this.newConfigYml), sha, }); diff --git a/static/scripts/rendering/config-editor.ts b/static/scripts/rendering/config-editor.ts index d3fd371..3c30f43 100644 --- a/static/scripts/rendering/config-editor.ts +++ b/static/scripts/rendering/config-editor.ts @@ -51,8 +51,10 @@ export function renderConfigEditor(renderer: ManifestRenderer, pluginManifest: M let value: string; - if (typeof currentObj === "object") { + if (typeof currentObj === "object" || Array.isArray(currentObj)) { value = JSON.stringify(currentObj, null, 2); + } else if (typeof currentObj === "boolean") { + value = currentObj ? "true" : "false"; } else { value = currentObj as string; } @@ -62,6 +64,10 @@ export function renderConfigEditor(renderer: ManifestRenderer, pluginManifest: M } else { (input as HTMLInputElement).value = value; } + + if (input.tagName === "INPUT" && (input as HTMLInputElement).type === "checkbox") { + (input as HTMLInputElement).checked = value === "true"; + } }); } diff --git a/static/scripts/rendering/write-add-remove.ts b/static/scripts/rendering/write-add-remove.ts index abfd3ca..f069d30 100644 --- a/static/scripts/rendering/write-add-remove.ts +++ b/static/scripts/rendering/write-add-remove.ts @@ -81,34 +81,7 @@ function handleAddPlugin(renderer: ManifestRenderer, plugin: Plugin, pluginManif type: "success", actionText: "Push to GitHub", shouldAutoDismiss: true, - action: async () => { - const octokit = renderer.auth.octokit; - if (!octokit) { - throw new Error("Octokit not found"); - } - - const org = localStorage.getItem("selectedOrg"); - - if (!org) { - throw new Error("No selected org found"); - } - - try { - await renderer.configParser.updateConfig(org, octokit); - } catch (error) { - console.error("Error pushing config to GitHub:", error); - toastNotification("An error occurred while pushing the configuration to GitHub.", { - type: "error", - shouldAutoDismiss: true, - }); - return; - } - - toastNotification("Configuration pushed to GitHub successfully.", { - type: "success", - shouldAutoDismiss: true, - }); - }, + action: () => notificationConfigPush(renderer), }); } @@ -118,34 +91,36 @@ function handleRemovePlugin(renderer: ManifestRenderer, plugin: Plugin, pluginMa type: "success", actionText: "Push to GitHub", shouldAutoDismiss: true, - action: async () => { - const octokit = renderer.auth.octokit; - if (!octokit) { - throw new Error("Octokit not found"); - } + action: () => notificationConfigPush(renderer), + }); +} + +async function notificationConfigPush(renderer: ManifestRenderer) { + const octokit = renderer.auth.octokit; + if (!octokit) { + throw new Error("Octokit not found"); + } - const org = localStorage.getItem("selectedOrg"); + const org = localStorage.getItem("selectedOrg"); - if (!org) { - throw new Error("No selected org found"); - } + if (!org) { + throw new Error("No selected org found"); + } - try { - await renderer.configParser.updateConfig(org, octokit); - } catch (error) { - console.error("Error pushing config to GitHub:", error); - toastNotification("An error occurred while pushing the configuration to GitHub.", { - type: "error", - shouldAutoDismiss: true, - }); - return; - } + try { + await renderer.configParser.updateConfig(org, octokit); + } catch (error) { + console.error("Error pushing config to GitHub:", error); + toastNotification("An error occurred while pushing the configuration to GitHub.", { + type: "error", + shouldAutoDismiss: true, + }); + return; + } - toastNotification("Configuration pushed to GitHub successfully.", { - type: "success", - shouldAutoDismiss: true, - }); - }, + toastNotification("Configuration pushed to GitHub successfully.", { + type: "success", + shouldAutoDismiss: true, }); }