Skip to content

Commit

Permalink
chore: single push method, commit title update
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng committed Nov 27, 2024
1 parent c2c587a commit 728218d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 53 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
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 728218d

Please sign in to comment.