From 1c11be04e4d5d9d806de5d0f261a4cbf9f62fdb9 Mon Sep 17 00:00:00 2001 From: Pavel Kvach Date: Mon, 23 Sep 2024 12:59:35 +0300 Subject: [PATCH] feat(youtrack): Add Toggl button to YouTrack Agile board issue modal (#2333) Closes #2316 --- src/content/youtrack.js | 22 ++++++++++++++++++++++ src/styles/style.css | 4 ++++ 2 files changed, 26 insertions(+) diff --git a/src/content/youtrack.js b/src/content/youtrack.js index d6bf7a477..4862f804d 100644 --- a/src/content/youtrack.js +++ b/src/content/youtrack.js @@ -98,3 +98,25 @@ togglbutton.render('.yt-agile-card:not(.toggl)', { observe: true }, function ( container.appendChild(link); }); + +// Agile board - issue modal +togglbutton.render('div[role="dialog"] div[data-test="fields-sidebar"]:not(.toggl)', { observe: true }, function ( + elem +) { + const dialog = elem.closest('div[role="dialog"]'); + + const issueIdElem = dialog.querySelector('a[href*="issue/"]'); + const issueId = issueIdElem ? issueIdElem.textContent.trim() : ""; + + const issueTitleElem = dialog.querySelector('h1'); + const issueTitle = issueTitleElem ? issueTitleElem.textContent.trim() : ""; + + const link = togglbutton.createTimerLink({ + className: 'youtrack-modal', + description: issueId + ' ' + issueTitle, + projectName: issueId.split('-')[0] + }); + + const container = elem.lastChild; + container.insertBefore(link, container.firstChild); +}); diff --git a/src/styles/style.css b/src/styles/style.css index e31fe8e2f..62f26e4ed 100644 --- a/src/styles/style.css +++ b/src/styles/style.css @@ -53,6 +53,10 @@ margin-right: 30px; } +.toggl-button.youtrack-modal { + padding: 6px 12px; +} + /********* ASANA *********/ .toggl-button.asana, .toggl-button.asana-new {