added "Delete Local Repo" option

This commit is contained in:
Steven Hugg 2019-05-16 10:08:09 -04:00
parent 3e2a3ddee7
commit 61ffe2ae79
4 changed files with 38 additions and 4 deletions

View File

@ -147,7 +147,6 @@ TODO:
- test edge/failure cases
- what to do about included files?
- what if files already open in editor
- un-bind from repo? delete repo?
- can published files retain path?
- what if import interrupted and partial files?
- CORS for some blobs?

View File

@ -69,6 +69,7 @@ if (window.location.host.endsWith('8bitworkshop.com')) {
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#" id="item_github_import">Import Project from GitHub...</a></li>
<li><a class="dropdown-item" href="#" id="item_github_publish">Publish Project on GitHub...</a></li>
<li><a class="dropdown-item" href="#" id="item_repo_delete">Delete Local Repository...</a></li>
<hr>
<li><a class="dropdown-item" href="#" id="item_github_push">Push Changes to Repository...</a></li>
<hr>

View File

@ -10,8 +10,8 @@ declare var jsnes : any;
const JSNES_PRESETS = [
{id:'hello.c', name:'Hello World'},
{id:'scroll.c', name:'Scrolling'},
{id:'attributes.c', name:'Attribute Table'},
{id:'scroll.c', name:'Scrolling'},
{id:'vrambuffer.c', name:'VRAM Buffer'},
{id:'sprites.c', name:'Sprites'},
{id:'metasprites.c', name:'Metasprites'},

View File

@ -410,7 +410,7 @@ function getGithubService() {
function getBoundGithubURL() : string {
var toks = (repo_id||'').split('/');
if (toks.length != 2) {
alertError("You are not in a GitHub repository. Choose one from the pulldown, or Import or Publish one.");
alertError("<p>You are not in a GitHub repository.</p><p>Choose one from the pulldown, or Import or Publish one.</p>");
return null;
}
return 'https://github.com/' + toks[0] + '/' + toks[1];
@ -532,7 +532,7 @@ function confirmCommit(sess) : Promise<GHSession> {
msg += f.filename + ": " + f.status;
if (f.additions || f.deletions || f.changes) {
msg += " (" + f.additions + " additions, " + f.deletions + " deletions, " + f.changes + " changes)";
}
};
msg += "<br/>";
}
// show dialog, continue when yes
@ -578,6 +578,39 @@ function pushChangesToGithub(message:string) {
});
}
function _deleteRepository() {
var ghurl = getBoundGithubURL();
if (!ghurl) return;
bootbox.prompt("<p>Are you sure you want to delete this repository (" + ghurl + ") from browser storage?</p><p>All changes since last commit will be lost.</p><p>Type YES to proceed.<p>", (yes) => {
if (yes.trim().toUpperCase() == "YES") {
deleteRepository();
}
});
}
function deleteRepository() {
var ghurl = getBoundGithubURL();
var gh;
setWaitDialog(true);
// delete all keys in storage
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();
});
}
function _shareEmbedLink(e) {
if (current_output == null) { // TODO
alertError("Please fix errors before sharing.");
@ -1372,6 +1405,7 @@ function setupDebugControls() {
$("#item_github_publish").click(_publishProjectToGithub);
$("#item_github_push").click(_pushProjectToGithub);
$("#item_github_pull").click(_pullProjectFromGithub);
$("#item_repo_delete").click(_deleteRepository);
$("#item_share_file").click(_shareEmbedLink);
$("#item_reset_file").click(_revertFile);
$("#item_rename_file").click(_renameFile);