From 7922f6a9a1da3dc7824dda15ee124dff1bc36eeb Mon Sep 17 00:00:00 2001 From: Daniel Pfeiffer Date: Sun, 7 Apr 2024 07:22:06 -0500 Subject: [PATCH] Adds a Custom URL action for Jira Query buttons (#11) Adds a new **Open URL** button action that allows a custom URL to be opened when tapping the Jira button. --- src/JiraPluginSettings.ts | 12 +++++++++++- src/actions/Query.ts | 20 ++++++++++++++------ src/inspectors/Query.html | 5 +++++ src/inspectors/Query.ts | 27 +++++++++++++++++++++++++-- 4 files changed, 55 insertions(+), 9 deletions(-) diff --git a/src/JiraPluginSettings.ts b/src/JiraPluginSettings.ts index a3e9728..1a467c3 100644 --- a/src/JiraPluginSettings.ts +++ b/src/JiraPluginSettings.ts @@ -10,7 +10,17 @@ export interface ViewInBrowserAction { limit: number; } -export type JQLQueryKeyAction = 'Refresh' | 'ViewFilter' | ViewInBrowserAction; +/** + * An action to open a custom URL. + */ +export interface OpenUrlAction { + /** + * The URL to open when the action is invoked. + */ + url: string; +} + +export type JQLQueryKeyAction = 'Refresh' | 'ViewFilter' | ViewInBrowserAction | OpenUrlAction; /** * Settings used by the JQL Query action. diff --git a/src/actions/Query.ts b/src/actions/Query.ts index b8adb36..2d7a63d 100644 --- a/src/actions/Query.ts +++ b/src/actions/Query.ts @@ -39,13 +39,21 @@ class Query extends BaseJiraAction, JQLQuerySe this.openURL(`https://${event.settings.domain}/issues/?jql=${encodeURIComponent(event.settings.jql)}`); break; default: { - const issues = this.getPollingClient()?.getLastResponse()?.data?.issues ?? []; + const action = event.settings.keyAction; + if ("limit" in action) { + const issues = this.getPollingClient()?.getLastResponse()?.data?.issues ?? []; - issues - .slice(0, event.settings.keyAction.limit ?? 5) - .forEach(issue => { - this.openURL(this.getIssueUrl(issue, event.settings)); - }); + issues + .slice(0, action.limit ?? 5) + .forEach(issue => { + this.openURL(this.getIssueUrl(issue, event.settings)); + }); + } else if ("url" in action) { + if (action.url) { + this.openURL(action.url); + } + } + break; } } diff --git a/src/inspectors/Query.html b/src/inspectors/Query.html index 6ebfe4b..1eebdba 100644 --- a/src/inspectors/Query.html +++ b/src/inspectors/Query.html @@ -17,9 +17,14 @@ + +
+
URL
+ +
diff --git a/src/inspectors/Query.ts b/src/inspectors/Query.ts index b2504da..9044c30 100644 --- a/src/inspectors/Query.ts +++ b/src/inspectors/Query.ts @@ -13,6 +13,7 @@ class QueryActionPropertyInspector extends PollingActionInspector