Skip to content

Commit

Permalink
Change structure of project
Browse files Browse the repository at this point in the history
  • Loading branch information
maximmig committed Dec 3, 2024
1 parent 3e1e181 commit 89f0870
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 28 deletions.
4 changes: 2 additions & 2 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const handleMessage = (message, sender, sendResponse) => {
});

const { project, https, ssh } = message;
const url = encodeURI(`popups/clone.html?project=${project}&https=${https}&ssh=${ssh}`);
const url = encodeURI(`popups/clone/index.html?project=${project}&https=${https}&ssh=${ssh}`);
chrome.action.setPopup({
tabId: sender.tab.id,
popup: chrome.runtime.getURL(url),
Expand All @@ -81,7 +81,7 @@ const handleMessage = (message, sender, sendResponse) => {
});
chrome.action.setPopup({
tabId: sender.tab.id,
popup: chrome.runtime.getURL("popups/disabled.html"),
popup: chrome.runtime.getURL("popups/disabled/index.html"),
});
break;
case "get-protocol":
Expand Down
2 changes: 1 addition & 1 deletion manifests/chrome/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"action": {
"default_icon": "icons/icon-disabled-128.png",
"default_title": "JetBrains Toolbox Extension",
"default_popup": "popups/disabled.html"
"default_popup": "popups/disabled/index.html"
},
"background": {
"service_worker": "jetbrains-toolbox-background.js"
Expand Down
2 changes: 1 addition & 1 deletion manifests/firefox/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"action": {
"default_icon": "icons/icon-disabled-128.png",
"default_title": "JetBrains Toolbox Extension",
"default_popup": "popups/disabled.html"
"default_popup": "popups/disabled/index.html"
},
"background": {
"scripts": ["jetbrains-toolbox-background.js"]
Expand Down
8 changes: 8 additions & 0 deletions popups/assets/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@import url("../../styles/variables.css");
@import url("../../styles/common.css");

body {
font-size: 0.75rem;
line-height: 1.334;
width: 22rem;
}
16 changes: 4 additions & 12 deletions popups/clone.js → popups/clone/assets/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ const setToolActionClickHandler = (action) => {

chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
const toolTag = toolAction.dataset.tag;
const protocolInput = document.querySelector(
".js-protocol-input:checked",
);
const protocolInput = document.querySelector(".js-protocol-input:checked");
const protocol = protocolInput.value.toLowerCase();
const cloneUrl = toolAction.dataset[protocol];
chrome.tabs.sendMessage(tabs[0].id, {
Expand All @@ -63,9 +61,7 @@ const query = decodeURI(location.search)
return acc;
}, {});

const inputs = document.querySelectorAll(
'input[type="radio"][name="protocol"]',
);
const inputs = document.querySelectorAll('input[type="radio"][name="protocol"]');
inputs.forEach((input) => {
input.addEventListener("change", (e) => {
if (e.currentTarget.checked) {
Expand All @@ -81,9 +77,7 @@ chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
chrome.runtime
.sendMessage({ type: "get-protocol" })
.then((data) => {
const protocolInput = document.querySelector(
`.js-protocol-input[value="${data.protocol}"]`,
);
const protocolInput = document.querySelector(`.js-protocol-input[value="${data.protocol}"]`);
protocolInput.checked = true;
})
.catch((e) => {
Expand All @@ -99,9 +93,7 @@ chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {

const fragment = document.createDocumentFragment();
tools.forEach((tool) => {
fragment.append(
createOpenToolAction(tool, query.project, query.https, query.ssh),
);
fragment.append(createOpenToolAction(tool, query.project, query.https, query.ssh));
});
document.querySelector(".js-tool-action-placeholder").remove();
document.querySelector(".js-tool-actions").append(fragment);
Expand Down
4 changes: 2 additions & 2 deletions popups/clone.html → popups/clone/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8" />
<title>Open project in JetBrains IDEs</title>
<link rel="stylesheet" href="popup.css" />
<link rel="stylesheet" href="../assets/styles.css" />
<style>
@keyframes placeholder-animation {
0%,
Expand Down Expand Up @@ -184,6 +184,6 @@
</div>
</div>
</div>
<script src="clone.js"></script>
<script src="assets/scripts.js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion popups/disabled.html → popups/disabled/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8" />
<title>Extension is disabled on this page</title>
<link rel="stylesheet" href="popup.css" />
<link rel="stylesheet" href="../assets/styles.css" />
</head>
<body>
<div>
Expand Down
8 changes: 0 additions & 8 deletions popups/popup.css

This file was deleted.

2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default () => ({
patterns: [
{ from: "manifest.json", context: `manifests/${process.env.BROWSER}/` },
{ from: "icons/*" },
{ from: "popups/*" },
{ from: "popups/**/*" },
{ from: "providers/**/assets/*" },
{ from: "styles/*" },
],
Expand Down

0 comments on commit 89f0870

Please sign in to comment.