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" 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; 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/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; 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