Skip to content

Commit

Permalink
#336 - Fix for timer controls not visible in Agile board
Browse files Browse the repository at this point in the history
  • Loading branch information
shridhar-tl committed Oct 20, 2023
1 parent 9377586 commit 4d098b9
Showing 1 changed file with 44 additions and 12 deletions.
56 changes: 44 additions & 12 deletions src/content-scripts/jira-board.js
Expand Up @@ -5,19 +5,51 @@ import { waitAndGet } from "./utils";

export async function applyBoardLogic(currentPage, settings, firstTime, applyModifications) {
if (currentPage === Pages.Board) {
$('.ghx-columns div.js-issue .ja-issue-el').remove();

const triggerFunc = triggerWLTracking.bind({ settings, applyModifications });

const selector = '.ghx-columns div.js-issue';
const issues = firstTime ? (await waitAndGet(selector)) : $(selector);
issues.each((i, el) => {
el = $(el);
const issueKey = el.attr('data-issue-key');
const issueId = el.attr('data-issue-id');

const controls = el.find(isCloud ? '.ghx-stat-fields .ghx-row:first-child' : '.ghx-card-footer');
addTimerControls(currentPage, controls, issueKey, settings, issueId, triggerFunc);
});
if (isCloud) {
await handleForCloudJira(triggerFunc, firstTime, currentPage, settings);
} else {
await handleForPrivateJiraInstance(triggerFunc, firstTime, currentPage, settings);
}
}
}

async function handleForCloudJira(triggerFunc, firstTime, currentPage, settings) {
$('#ak-main-content div[data-test-id="platform-board-kit.ui.card.card"] span.ghx-field.ja-issue-el').remove();
const selector = '#ak-main-content div[data-test-id="platform-board-kit.ui.card.card"]';

const issues = firstTime ? (await waitAndGet(selector)) : $(selector);
issues.each((i, el) => {
el = $(el);
let issueKey = el.attr('id');
if (!issueKey?.startsWith('card-')) {
return;
}
issueKey = issueKey.substring(5);

let issueId = el.attr('data-rbd-draggable-id');
if (!issueId?.startsWith('ISSUE::')) {
return;
}
issueId = issueId.substring(7);

const controls = el.find('> div > div > div > div:last-child:not(:first-child) > div:first-child:last-child > div:first-child');
addTimerControls(currentPage, controls, issueKey, settings, issueId, triggerFunc);
});
}

async function handleForPrivateJiraInstance(triggerFunc, firstTime, currentPage, settings) {
$('.ghx-columns div.js-issue .ja-issue-el').remove();

const selector = '.ghx-columns div.js-issue';
const issues = firstTime ? (await waitAndGet(selector)) : $(selector);
issues.each((i, el) => {
el = $(el);
const issueKey = el.attr('data-issue-key');
const issueId = el.attr('data-issue-id');

const controls = el.find('.ghx-card-footer');
addTimerControls(currentPage, controls, issueKey, settings, issueId, triggerFunc);
});
}

0 comments on commit 4d098b9

Please sign in to comment.