Skip to content

Commit

Permalink
Merge branch 'main' of github.com:earvinpiamonte/jira-software-tool i…
Browse files Browse the repository at this point in the history
…nto main
  • Loading branch information
earvinpiamonte committed Jun 13, 2021
2 parents a1a9245 + cb6af32 commit 3a4630e
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 36 deletions.
16 changes: 9 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"@testing-library/jest-dom": "^5.11.9",
"@testing-library/react": "^11.2.3",
"@testing-library/user-event": "^12.6.2",
"@types/chrome": "0.0.128",
"@types/chrome": "^0.0.145",
"@types/jest": "^26.0.20",
"@types/node": "^14.14.22",
"@types/react": "^17.0.0",
Expand Down
13 changes: 4 additions & 9 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"manifest_version": 2,
"manifest_version": 3,
"name": "Jira Software Tool",
"short_name": "jira-software-tool",
"description": "A Google Chrome extension for Jira Software. Easily copy issue/ ticket ID, title and URL to clipboard.",
Expand All @@ -8,15 +8,10 @@
"permissions": [
"activeTab",
"tabs",
"declarativeContent"
"declarativeContent",
"scripting"
],
"background": {
"scripts": [
"chrome/background.js"
],
"persistent": false
},
"page_action": {
"action": {
"default_popup": "index.html?page=Popup",
"default_title": "Open Jira Software Tool"
},
Expand Down
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ErrorBoundary from "./boundaries/ErrorBoundary";
import ThemeProvider from "./providers/ThemeProvider";
import useChromeManifest from "./hooks/useChromeManifest";

const App = ({ page }: { page: string }) => {
const App = ({ page = "Options" }: { page: string }) => {
const manifest = useChromeManifest();
const Page = React.lazy(() => import(`./pages/${page}`));

Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useChromeManifest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const useChromeManifest = () => {

const loadManifest = async () => {
const manifestData =
typeof chrome.runtime.getManifest === "function"
typeof chrome.runtime?.getManifest === "function"
? chrome.runtime.getManifest()
: // Fallback to get manifest via `fetch` if `chrome.runtime.getManifest` is undefined
await import("../utils/ApiRequests").then(({ getManifest }) =>
Expand Down
39 changes: 24 additions & 15 deletions src/hooks/useTicketWithChrome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,31 @@ const useTicketWithChrome = () => {

React.useEffect(() => {
if (typeof chrome.tabs !== "undefined") {
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
// console.log(tabs);
// Get ticket details result from DOM
chrome.tabs.executeScript(
{ code: `(${getTicketFromDOM})();` },
(results) => {
const ticket = results[0];
const { issueTitle, issueID, issueURL } = ticket;
chrome.tabs.query({ active: true, currentWindow: true }, ([tab]) => {
try {
// Get ticket details result from DOM
chrome.scripting.executeScript(
{
target: {
tabId: tab.id ?? chrome.tabs.TAB_ID_NONE,
allFrames: true,
},
function: getTicketFromDOM,
},
(results) => {
const { result } = results[0];
const { issueTitle, issueID, issueURL } = result;

setTicket({
issueTitle,
issueID,
issueURL,
});
}
);
setTicket({
issueTitle,
issueID,
issueURL,
});
}
);
} catch (error) {
console.log("Script execution error: ", error);
}
});
}
}, []);
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.chrome.webpack.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"outDir": "./build/chrome/",
"outDir": "./build/",
"noImplicitAny": true,
"module": "esnext",
"target": "es5",
Expand Down
2 changes: 1 addition & 1 deletion webpack.chrome.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = {
},
output: {
filename: "[name].js",
path: path.resolve(__dirname, "./build/chrome/"),
path: path.resolve(__dirname, "./build/"),
},
module: {
rules: [
Expand Down

0 comments on commit 3a4630e

Please sign in to comment.