github: fixed delete repository

This commit is contained in:
Steven Hugg 2023-02-06 13:46:17 -05:00
parent e724ccb7d2
commit 2f8a5bee84
2 changed files with 15 additions and 19 deletions

View File

@ -219,12 +219,13 @@ export class GithubService {
}
// check README for proper platform
// unless we use githubURL=
// TODO: cannot handle multiple URLs in README
const re8plat = /8bitworkshop.com[^)]+platform=([A-Za-z0-9._\-]+)/;
m = re8plat.exec(readme);
if (m) {
console.log("platform id: '" + m[1] + "'");
if (sess.platform_id && !sess.platform_id.startsWith(m[1]))
throw Error("Platform mismatch: Repository is " + m[1] + ", you have " + this.project.platform_id + " selected.");
throw Error("Platform mismatch: Repository is " + m[1] + ", you have " + sess.platform_id + " selected.");
sess.platform_id = m[1];
}
// bind to repository

View File

@ -882,37 +882,32 @@ async function pushChangesToGithub(message:string) {
});
}
function _deleteRepository() {
function _removeRepository() {
var ghurl = getBoundGithubURL();
if (!ghurl) return;
bootbox.prompt("<p>Are you sure you want to delete this repository (" + DOMPurify.sanitize(ghurl) + ") from browser storage?</p><p>All changes since last commit will be lost.</p><p>Type DELETE to proceed.<p>", (yes) => {
if (yes.trim().toUpperCase() == "DELETE") {
deleteRepository();
removeRepository();
}
});
}
function deleteRepository() {
async function removeRepository() {
var ghurl = getBoundGithubURL();
var gh;
setWaitDialog(true);
// delete all keys in storage
store.keys().then((keys:string[]) => {
let gh = await getGithubService();
let sess = await gh.getGithubSession(ghurl);
gh.bind(sess, false);
// delete all keys in (repo) storage
await store.keys().then((keys:string[]) => {
return Promise.all(keys.map((key) => {
return store.removeItem(key);
}));
}).then(() => {
gh = getGithubService();
return gh.getGithubSession(ghurl);
}).then((sess) => {
// un-bind repo from list
gh.bind(sess, false);
}).then(() => {
setWaitDialog(false);
// leave repository
qs = {repo:'/'};
gotoNewLocation();
});
setWaitDialog(false);
// leave repository
qs = {repo:'/'};
gotoNewLocation();
}
function _shareEmbedLink(e) {
@ -1929,7 +1924,7 @@ function setupDebugControls() {
$("#item_github_publish").click(_publishProjectToGithub);
$("#item_github_push").click(_pushProjectToGithub);
$("#item_github_pull").click(_pullProjectFromGithub);
$("#item_repo_delete").click(_deleteRepository);
$("#item_repo_delete").click(_removeRepository);
$("#item_share_file").click(_shareEmbedLink);
$("#item_reset_file").click(_revertFile);
$("#item_rename_file").click(_renameFile);