From 6eee0bac3f08bf60b45dcf9cd0b9b860de8e8fb4 Mon Sep 17 00:00:00 2001 From: "israel.aristide" Date: Thu, 24 Apr 2025 21:59:20 -0400 Subject: [PATCH 1/4] add new bitbucket options --- src/html/options.html | 21 +++++++++++++++++++++ src/js/options.ts | 27 +++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/src/html/options.html b/src/html/options.html index 25d43385..232c116f 100644 --- a/src/html/options.html +++ b/src/html/options.html @@ -34,6 +34,27 @@

pattern="[Hh][Tt][Tt][Pp][Ss]?:\/\/(?:(?:[a-zA-Z\u00a1-\uffff0-9]+-?)*[a-zA-Z\u00a1-\uffff0-9]+)(?:\.(?:[a-zA-Z\u00a1-\uffff0-9]+-?)*[a-zA-Z\u00a1-\uffff0-9]+)*(?:\.(?:[a-zA-Z\u00a1-\uffff]{2,}))(?::\d{2,5})?(?:\/[^\s]*)?" /> + +

+

+

+ + https://bitbucket.org/ +

+ + +

diff --git a/src/js/options.ts b/src/js/options.ts index 8e7f1868..c0067ca1 100644 --- a/src/js/options.ts +++ b/src/js/options.ts @@ -6,6 +6,19 @@ const saveOptions = async (event: Event) => { const jiraInput = document.querySelector('.quiji-options-jira-url'); + const bitBucketInput = document.querySelector('.quiji-options-bitbucket-url'); + const bitBucketPrefixInput = document.querySelector('.quiji-options-bitbucket-prefix'); + + if (bitBucketInput && bitBucketPrefixInput) { + const bitbucket = bitBucketInput.value; + const prefix = bitBucketPrefixInput.value; + + await storage.set({ + bitbucketURL: bitbucket, + bitbucketPrefix: prefix, + }); + } + if (jiraInput) { // Check for null before accessing properties const jira = jiraInput.value; @@ -53,6 +66,8 @@ const restoreOptions = async () => { jiraURL: '', defaultOption: 0, trimSpaces: 0, + bitbucketURL: '', + bitbucketPrefix: '', } as Options, (options) => { // Type the options parameter @@ -61,6 +76,18 @@ const restoreOptions = async () => { jiraInput.value = (options as Options).jiraURL || ''; } + // Type the options parameter + const bitbucketInput = document.querySelector('.quiji-options-bitbucket-url'); + if (bitbucketInput) { + bitbucketInput.value = (options as Options).bitbucketURL || ''; + } + + // Type the options parameter + const prefixInput = document.querySelector('.quiji-options-bitbucket-prefix'); + if (prefixInput) { + prefixInput.value = (options as Options).bitbucketPrefix || ''; + } + // Map 0 to currentTab and 1 to newTab const selectElement = document.querySelector('select'); if (selectElement) { From b8a9e94b79cdb9bc0a983ac1fba64fb673a538e6 Mon Sep 17 00:00:00 2001 From: "israel.aristide" Date: Thu, 24 Apr 2025 21:59:38 -0400 Subject: [PATCH 2/4] add new text keys --- src/_locales/en/messages.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index f5379dd1..834b6392 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -67,6 +67,18 @@ "message": "For example:", "description": "Info text with an example JIRA URL. URL is followed after the sentence" }, + "bb_baseURL": { + "message": "Bitbucket base URL", + "description": "base URL you need to enter for a valid repo URL" + }, + "bb_baseURLDescription": { + "message": "Please enter here the Bitbucket URL for the Quick Search. Please keep in mind that the URL should end with a forward slash.", + "description": "Description text of the bitbucket base URL" + }, + "bb_baseURLExample": { + "message": "For example:", + "description": "Info text with an example Bitbucket URL. URL is followed after the sentence" + }, "baseURLMoreInfo": { "message": " More information regarding the JIRA Quick Search can be found here:", "description": "Info text for the JIRA QuickSearch function. URL is followed after the sentence" From ab30bb58a340c78778115842c6da6c49fcc0402a Mon Sep 17 00:00:00 2001 From: "israel.aristide" Date: Thu, 24 Apr 2025 21:59:53 -0400 Subject: [PATCH 3/4] styling --- src/css/style.css | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/css/style.css b/src/css/style.css index eb4a7eab..ffc18936 100644 --- a/src/css/style.css +++ b/src/css/style.css @@ -124,6 +124,13 @@ select { input[type='text'].quiji-options-jira-url { max-width: 600px; } +input[type='text'].quiji-options-bitbucket-url { + max-width: 600px; +} + +input[type='text'].quiji-options-bitbucket-prefix { + max-width: 200px; +} select { max-width: 250px; From f159b340d3324453f230be629e848cbd2c8f05ad Mon Sep 17 00:00:00 2001 From: "israel.aristide" Date: Thu, 24 Apr 2025 22:01:05 -0400 Subject: [PATCH 4/4] add background --- src/js/background.ts | 19 +++++++++++++++++++ src/js/helper.ts | 2 ++ 2 files changed, 21 insertions(+) diff --git a/src/js/background.ts b/src/js/background.ts index bd1f0819..9729a105 100644 --- a/src/js/background.ts +++ b/src/js/background.ts @@ -19,15 +19,34 @@ async function openTicket(ticket: string, newTab: boolean) { { jiraURL: '', trimSpaces: 0, + bitbucketURL: '', + bitbucketPrefix: '', }, (options) => { const jiraURL = (options as Options).jiraURL; + const bitbucketURL = (options as Options).bitbucketURL; + + let bitbucketPrefix = (options as Options).bitbucketPrefix; + bitbucketPrefix = encodeURIComponent(bitbucketPrefix); + const trimSpaces = options.trimSpaces !== 0; let newURL: string; if (trimSpaces) { ticket = decodeURIComponent(ticket).replace(/\s/g, ''); } + + if (ticket.startsWith(bitbucketPrefix)) { + console.log('Bitbucket ticket detected'); + if (!bitbucketURL) { + void _browser.runtime.openOptionsPage(); + } else { + newURL = ticket.replace(bitbucketPrefix, bitbucketURL); + void openURLInTab(newTab, newURL); + return; + } + } + void storage.set({ lastTicket: ticket, }); diff --git a/src/js/helper.ts b/src/js/helper.ts index ff92ef52..34049cf0 100644 --- a/src/js/helper.ts +++ b/src/js/helper.ts @@ -7,6 +7,8 @@ export const _browser: BrowserType = isFirefox ? browser : chrome; export const storage = _browser.storage.sync || _browser.storage.local; export interface Options { + bitbucketURL: string; + bitbucketPrefix: string; jiraURL: string; defaultOption: number; trimSpaces: number;