Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into fix/org-choices
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng committed Nov 29, 2024
2 parents 262c3a0 + b52f2db commit ae9b1a3
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 54 deletions.
2 changes: 1 addition & 1 deletion static/scripts/config-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down
8 changes: 7 additions & 1 deletion static/scripts/rendering/config-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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";
}
});
}

Expand Down
79 changes: 27 additions & 52 deletions static/scripts/rendering/write-add-remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
});
}

Expand All @@ -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,
});
}

Expand Down

0 comments on commit ae9b1a3

Please sign in to comment.