mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-11-25 18:33:11 +00:00
github: message after signing in, let login errors propogate, added Log Out
This commit is contained in:
parent
980c8beb89
commit
b190cb7cfd
@ -69,6 +69,8 @@ if (window.location.host.endsWith('8bitworkshop.com')) {
|
||||
<a tabindex="-1" href="#">Sync</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="#" id="item_github_login">Sign in to Github...</a></li>
|
||||
<li><a class="dropdown-item" href="#" id="item_github_logout">Log out</a></li>
|
||||
<hr>
|
||||
<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>
|
||||
|
@ -79,9 +79,21 @@ export class GithubService {
|
||||
this.recreateGithub();
|
||||
document.cookie = "__github_key=" + this.githubToken + ";path=/;max-age=31536000";
|
||||
console.log("Stored GitHub OAUTH key");
|
||||
}).catch( (error) => {
|
||||
console.log(error);
|
||||
bootbox.alert("Could not login to GitHub: " + error);
|
||||
});
|
||||
}
|
||||
|
||||
logout() : Promise<void> {
|
||||
// already logged out? return immediately
|
||||
if (!(this.githubToken && this.githubToken.length)) {
|
||||
return new Promise<void>( (yes,no) => {
|
||||
yes();
|
||||
});
|
||||
}
|
||||
// logout
|
||||
return firebase.auth().signOut().then(() => {
|
||||
document.cookie = "__github_key=;path=/;max-age=0";
|
||||
this.githubToken = null;
|
||||
this.recreateGithub();
|
||||
});
|
||||
}
|
||||
|
||||
|
13
src/ui.ts
13
src/ui.ts
@ -455,7 +455,15 @@ function importProjectFromGithub(githuburl:string) {
|
||||
}
|
||||
|
||||
function _loginToGithub(e) {
|
||||
getGithubService().login();
|
||||
getGithubService().login().then(() => {
|
||||
alertInfo("You are signed in to Github.");
|
||||
});
|
||||
}
|
||||
|
||||
function _logoutOfGithub(e) {
|
||||
getGithubService().logout().then(() => {
|
||||
alertInfo("You are logged out of Github.");
|
||||
});
|
||||
}
|
||||
|
||||
function _importProjectFromGithub(e) {
|
||||
@ -524,7 +532,7 @@ function _pushProjectToGithub(e) {
|
||||
function _pullProjectFromGithub(e) {
|
||||
var ghurl = getBoundGithubURL();
|
||||
if (!ghurl) return;
|
||||
bootbox.confirm("Pull from repository and replace all local files?", (ok) => {
|
||||
bootbox.confirm("Pull from repository and replace all local files? Any changes you've made will be overwritten.", (ok) => {
|
||||
if (ok) {
|
||||
setWaitDialog(true);
|
||||
getGithubService().pull(ghurl).then( (sess:GHSession) => {
|
||||
@ -1430,6 +1438,7 @@ function setupDebugControls() {
|
||||
$("#item_new_file").click(_createNewFile);
|
||||
$("#item_upload_file").click(_uploadNewFile);
|
||||
$("#item_github_login").click(_loginToGithub);
|
||||
$("#item_github_logout").click(_logoutOfGithub);
|
||||
$("#item_github_import").click(_importProjectFromGithub);
|
||||
$("#item_github_publish").click(_publishProjectToGithub);
|
||||
$("#item_github_push").click(_pushProjectToGithub);
|
||||
|
Loading…
Reference in New Issue
Block a user