Skip to content

Commit 61dd682

Browse files
committed
Add settings icon to popup.html and redirect user to the settings modal in welcome.html
1 parent 10a6f3d commit 61dd682

4 files changed

Lines changed: 36 additions & 11 deletions

File tree

manifest.json

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "CodeHub",
33
"description": "Automatically pushes your Codewars submissions to GitHub",
44
"homepage_url": "https://github.com/FebinBellamy/CodeHub",
5-
"version": "1.0.1",
5+
"version": "2.0.1",
66
"author": "Febin Bellamy",
77
"action": {
88
"default_icon": {
@@ -23,17 +23,11 @@
2323
"type": "module",
2424
"persistent": false
2525
},
26-
"permissions": [
27-
"storage",
28-
"tabs",
29-
"scripting",
30-
"webNavigation",
31-
"activeTab"
32-
],
26+
"permissions": ["storage", "tabs", "scripting", "webNavigation", "activeTab"],
3327
"host_permissions": [
3428
"https://www.codewars.com/*",
3529
"https://github.com/*",
3630
"https://api.github.com/*"
3731
],
3832
"manifest_version": 3
39-
}
33+
}

popup.html

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ <h2>Automatically sync your code from Codewars to GitHub</h2>
4545
/>
4646
</svg>
4747
</a>
48-
4948
<a
5049
href="https://github.com/febinbellamy/CodeHub/labels/bug"
5150
target="_blank"
@@ -80,7 +79,6 @@ <h2>Automatically sync your code from Codewars to GitHub</h2>
8079
/>
8180
</svg>
8281
</a>
83-
8482
<a
8583
href="mailto:febinbellamy@gmail.com?subject=CodeHub"
8684
target="_blank"
@@ -98,6 +96,20 @@ <h2>Automatically sync your code from Codewars to GitHub</h2>
9896
/>
9997
</svg>
10098
</a>
99+
<a id="settings-icon">
100+
<svg
101+
xmlns="http://www.w3.org/2000/svg"
102+
width="20"
103+
height="20"
104+
fill="currentColor"
105+
class="bi bi-gear-fill"
106+
viewBox="0 0 16 16"
107+
>
108+
<path
109+
d="M9.405 1.05c-.413-1.4-2.397-1.4-2.81 0l-.1.34a1.464 1.464 0 0 1-2.105.872l-.31-.17c-1.283-.698-2.686.705-1.987 1.987l.169.311c.446.82.023 1.841-.872 2.105l-.34.1c-1.4.413-1.4 2.397 0 2.81l.34.1a1.464 1.464 0 0 1 .872 2.105l-.17.31c-.698 1.283.705 2.686 1.987 1.987l.311-.169a1.464 1.464 0 0 1 2.105.872l.1.34c.413 1.4 2.397 1.4 2.81 0l.1-.34a1.464 1.464 0 0 1 2.105-.872l.31.17c1.283.698 2.686-.705 1.987-1.987l-.169-.311a1.464 1.464 0 0 1 .872-2.105l.34-.1c1.4-.413 1.4-2.397 0-2.81l-.34-.1a1.464 1.464 0 0 1-.872-2.105l.17-.31c.698-1.283-.705-2.686-1.987-1.987l-.311.169a1.464 1.464 0 0 1-2.105-.872zM8 10.93a2.929 2.929 0 1 1 0-5.86 2.929 2.929 0 0 1 0 5.858z"
110+
/>
111+
</svg>
112+
</a>
101113
</div>
102114
</footer>
103115
</main>

popup.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const repoConnectedSection = document.querySelector("#repo-connected");
88
const aTagForRepoUrl = document.querySelector("#repo-url");
99
const starCodeHubButton = document.querySelector("#star-repo-button");
1010
const globeIcon = document.querySelector("#globe-icon");
11+
const settingsIcon = document.querySelector("#settings-icon");
1112

1213
authButton.addEventListener("click", () => {
1314
chrome.runtime.sendMessage({ action: "authenticateUser" });
@@ -25,6 +26,10 @@ starCodeHubButton.addEventListener("click", () => {
2526
chrome.tabs.create({ url: "http://www.github.com/febinbellamy/codehub" });
2627
});
2728

29+
settingsIcon.addEventListener("click", () => {
30+
chrome.tabs.create({ url: "welcome.html?openSettings=true" });
31+
});
32+
2833
updateUI(
2934
authRequestSection,
3035
linkRepoRequestSection,

scripts/welcome.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ document.addEventListener("DOMContentLoaded", () => {
2323
radio.checked = true;
2424
}
2525
});
26+
27+
const params = new URLSearchParams(window.location.search);
28+
if (params.get("openSettings") === "true") {
29+
settingsModal.style.display = "block";
30+
}
2631
});
2732

2833
authButton.addEventListener("click", () => {
@@ -41,22 +46,31 @@ settingsIcon.addEventListener("click", () => {
4146
settingsModal.style.display = "block";
4247
});
4348

49+
const removeOpenSettingsParam = () => {
50+
const url = new URL(window.location);
51+
url.searchParams.delete("openSettings");
52+
window.history.replaceState({}, document.title, url.pathname + url.search);
53+
};
54+
4455
saveSettingsBtn.addEventListener("click", () => {
4556
const selected = document.querySelector(
4657
'input[name="folder-structure"]:checked'
4758
).value;
4859
chrome.storage.local.set({ folderStructure: selected }, () => {
4960
settingsModal.style.display = "none";
61+
removeOpenSettingsParam();
5062
});
5163
});
5264

5365
closeModal.addEventListener("click", () => {
5466
settingsModal.style.display = "none";
67+
removeOpenSettingsParam();
5568
});
5669

5770
window.addEventListener("click", (event) => {
5871
if (event.target === settingsModal) {
5972
settingsModal.style.display = "none";
73+
removeOpenSettingsParam();
6074
}
6175
});
6276

0 commit comments

Comments
 (0)