Skip to content

Commit

Permalink
add ability to unlink repo
Browse files Browse the repository at this point in the history
  • Loading branch information
ayoung19 committed Nov 27, 2020
1 parent e21fb1f commit 28b36bf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions css/welcome.css
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ body {
a
{
color: white !important;
cursor: pointer;
}
27 changes: 25 additions & 2 deletions scripts/welcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,11 @@ var link_repo = (token, name)=>{
/* Change mode type to commit */
chrome.storage.sync.set({"mode_type": "commit"}, data=>{
$("#error").hide();
$("#success").html(`Successfully linked <a target="blank" href="${res['html_url']}">${name}</a> to LeetHub. Start <a href="http://leetcode.com">LeetCoding</a> now!`);
$("#success").html(`Successfully linked <a target="blank" href="${res['html_url']}">${name}</a> to LeetHub. Start <a href="http://leetcode.com">LeetCoding</a> now! <br /> Linked the wrong repo? <a id="unlink">Unlink</a>.`);
$("#unlink").on('click', () => {
unlink_repo();
$("#success").hide();
});
$("#success").show();
});
/* Set Repo Hook */
Expand Down Expand Up @@ -229,6 +233,21 @@ var link_repo = (token, name)=>{
xhr.send();
}

var unlink_repo = () => {
/* Set mode type to hook */
chrome.storage.sync.set({ "mode_type": "hook" }, data => {
console.log(`Unlinking repo`);
});
/* Set Repo Hook to NONE */
chrome.storage.sync.set({ "leethub_hook": null }, data => {
console.log("Defaulted repo hook to NONE");
});

/* Hide accordingly */
document.getElementById("hook_mode").style.display = "inherit";
document.getElementById("commit_mode").style.display = "none";
}

/* Status codes for linking of repo */
var link_status_code = (status, name)=>{
let bool = false;
Expand Down Expand Up @@ -296,7 +315,11 @@ var status_code = (res, status, name)=>{
/* Change mode type to commit */
chrome.storage.sync.set({"mode_type": "commit"}, data=>{
$("#error").hide();
$("#success").html(`Successfully created <a target="blank" href="${res['html_url']}">${name}</a>. Start <a href="http://leetcode.com">LeetCoding</a>!`);
$("#success").html(`Successfully created <a target="blank" href="${res['html_url']}">${name}</a>. Start <a href="http://leetcode.com">LeetCoding</a>! <br /> Linked the wrong repo? <a id="unlink">Unlink</a>.`);
$("#unlink").on('click', () => {
unlink_repo();
$("#success").hide();
});
$("#success").show();
/* Show new layout */
document.getElementById("hook_mode").style.display = "none";
Expand Down

0 comments on commit 28b36bf

Please sign in to comment.