Skip to content

Commit

Permalink
fix(asana.js): update project header selector and include it in board…
Browse files Browse the repository at this point in the history
… view

closes #2293
  • Loading branch information
niyiAO committed Apr 4, 2024
1 parent a448a2c commit 12a4d27
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions src/content/asana.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@
*/
'use strict';

const projectHeaderSelector = () => {
// Try to look for for page project title instead.
const projectHeader = document.querySelector(
'.ProjectPageHeaderProjectTitle-container',
);

if (!projectHeader) {
return '';
}
return projectHeader.textContent
.replace(/\u00a0/g, ' ') // There can be   in Asana header content
.trim();
};

// Board view. Inserts button next to assignee/due date.
togglbutton.render('.BoardCardLayout:not(.toggl)', { observe: true },
Expand All @@ -15,12 +28,14 @@ togglbutton.render('.BoardCardLayout:not(.toggl)', { observe: true },
}

const descriptionSelector = () => boadCardElem.querySelector('.BoardCard-taskName').textContent.trim();


const link = togglbutton.createTimerLink({
className: 'asana-board-view',
description: descriptionSelector,
buttonType: 'minimal',
// N.B. Tags and ProjectName cannot be supported on board view as the information is not available.
projectName: projectHeaderSelector,
// N.B. Tags cannot be supported on board view as the information is not available.
});

const injectContainer = boadCardElem.querySelector('.BoardCardLayout-actionButtons');
Expand All @@ -41,19 +56,7 @@ togglbutton.render('.SpreadsheetRow .SpreadsheetTaskName:not(.toggl)', { observe
}

const descriptionSelector = () => taskNameCell.querySelector('textarea').textContent.trim();
const projectHeaderSelector = () => {
// Try to look for for page project title instead.
const projectHeader = document.querySelector(
'.TopbarPageHeaderStructure.ProjectPageHeader .ProjectPageHeaderProjectTitle-shadow',
);

if (!projectHeader) {
return '';
}
return projectHeader.textContent
.replace(/\u00a0/g, ' ') // There can be   in Asana header content
.trim();
};

const projectSelector = () => {
const projectCell = container.querySelector('.SpreadsheetTaskRow-projectsCell');
if (!projectCell) {
Expand Down

0 comments on commit 12a4d27

Please sign in to comment.