Skip to content

Commit

Permalink
WIP extension:
Browse files Browse the repository at this point in the history
- Options UI and storage is working.
- Jira interaction is untested.
- Communication between content script and background worker is not working.
  • Loading branch information
willson556 committed Jan 8, 2024
1 parent e521a8a commit 96b3d84
Show file tree
Hide file tree
Showing 36 changed files with 1,643 additions and 1,508 deletions.
2,483 changes: 1,430 additions & 1,053 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 10 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
{
"name": "browser-extension",
"displayName": "Browser Extension",
"name": "jira-minute7-autocomplete",
"displayName": "Jira Minute7 Autocomplete",
"version": "2.0.0",
"description": "Browser Extension Boilerplate",
"description": "Autocompletes Jira items in Minute7",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/debdut/browser-extension.git"
"url": "git@github.com:StaflSystems/jira-minute7-autocomplete.git"
},
"scripts": {
"start": "ts-node-esm scripts/build.ts --dev",
"build": "ts-node-esm scripts/build.ts"
"start": "node --loader ts-node/esm scripts/build.ts --dev",
"build": "node --loader ts-node/esm scripts/build.ts"
},
"type": "module",
"dependencies": {
"@types/webextension-polyfill": "^0.10.0",
"jira.js": "^3.0.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.49.2",
"tributejs": "^5.1.3",
"ts-data-class": "^0.10.0",
"webextension-polyfill": "^0.10.0"
},
"devDependencies": {
Expand Down
4 changes: 4 additions & 0 deletions src/manifest/v3.mts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ const manifest: ManifestTypeV3 = {
matches: ["<all_urls>"],
},
],
permissions:[ "storage" ],
host_permissions: [
"https://*.atlassian.net/*",
]
};

function getManifestV3(pageDirMap: { [x: string]: any }): ManifestTypeV3 {
Expand Down
18 changes: 17 additions & 1 deletion src/pages/background/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
console.log("Service Worker 👋");
import browser from 'webextension-polyfill';
import { JiraIssue, JiraIssueRetriever } from '@src/utils/jira';

console.log("background script loaded");

const jiraIssueRetriever = new JiraIssueRetriever();

browser.runtime.onMessage.addListener(async function (message) {
console.log("here");
if (message.type === "jiraSuggestions") {
await jiraIssueRetriever.init();
const issues = await jiraIssueRetriever.getRecentlyUpdatedIssues();
return issues;
}
});

console.log("listener added");
38 changes: 0 additions & 38 deletions src/pages/bookmarks/Bookmarks.css

This file was deleted.

25 changes: 0 additions & 25 deletions src/pages/bookmarks/Bookmarks.tsx

This file was deleted.

13 changes: 0 additions & 13 deletions src/pages/bookmarks/index.css

This file was deleted.

12 changes: 0 additions & 12 deletions src/pages/bookmarks/index.html

This file was deleted.

13 changes: 0 additions & 13 deletions src/pages/bookmarks/index.tsx

This file was deleted.

51 changes: 26 additions & 25 deletions src/pages/content/index.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
import React from "react";
import { createRoot } from "react-dom/client";
import Tribute from "tributejs";
import { JiraIssueRetriever, JiraIssue } from "@src/utils/jira";
import browser from 'webextension-polyfill';

function Content(): JSX.Element {
return (
<div className="absolute top-0 left-0 right-0 bottom-0 text-center h-full p-3 bg-gray-800">
<header className="flex flex-col items-center justify-center text-white">
<p>
Edit <code>src/pages/content/index.jsx</code> and save to reload.
</p>
<a
className="text-blue-400"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React!
</a>
<p>Content styled</p>
</header>
</div>
);
}
import "./style.css";

async function init() {
console.log(document.URL)

if (!document.URL.startsWith("https://frontend.minute7.com")) {
return;
}

const issues: JiraIssue[] = await browser.runtime.sendMessage({ type: "jiraSuggestions" });

console.log(issues);
var tribute = new Tribute({
values: issues.map((issue: JiraIssue) => {
return {
key: issue.key + ": " + issue.summary,
value: issue.key + ": " + issue.summary,
};
})
});

function init() {
const rootContainer = document.body;
if (!rootContainer) throw new Error("Can't find Content root element");
const root = createRoot(rootContainer);
root.render(<Content />);
const te = document.getElementsByTagName("textarea")[0];
console.log(te);
tribute.attach(te);
}

document.addEventListener("DOMContentLoaded", init);
10 changes: 0 additions & 10 deletions src/pages/devtools/index.html

This file was deleted.

9 changes: 0 additions & 9 deletions src/pages/devtools/index.ts

This file was deleted.

38 changes: 0 additions & 38 deletions src/pages/history/History.css

This file was deleted.

25 changes: 0 additions & 25 deletions src/pages/history/History.tsx

This file was deleted.

13 changes: 0 additions & 13 deletions src/pages/history/index.css

This file was deleted.

12 changes: 0 additions & 12 deletions src/pages/history/index.html

This file was deleted.

13 changes: 0 additions & 13 deletions src/pages/history/index.tsx

This file was deleted.

38 changes: 0 additions & 38 deletions src/pages/newtab/Newtab.css

This file was deleted.

Loading

0 comments on commit 96b3d84

Please sign in to comment.