Skip to content

Commit

Permalink
fix(zendesk): Render button in the new UI
Browse files Browse the repository at this point in the history
Closes #2183
  • Loading branch information
Alissonsz committed Apr 27, 2023
1 parent 579fe89 commit 2a77394
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/content/zendesk.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,49 @@ setTimeout(() => {
);
}, 1000);


// Zendesk new UI Apr 2023
setTimeout(() => {
togglbutton.render(
'[data-garden-id="pane"]:not(.toggl)',
{ observe: true },
function (elem) {
if (elem.id === ':r1:--primary-pane') return
let description;
const projectName = $('title').textContent;

const titleFunc = function () {
const titleElem = $('[data-test-id="omni-header-subject"]', elem);
const ticketNum = location.href.match(/tickets\/(\d+)/);

if (titleElem !== null) {
description = titleElem.value.trim();
}

if (ticketNum) {
description = '#' + ticketNum[1].trim() + ' ' + description;
}
return description;
};

const link = togglbutton.createTimerLink({
className: 'zendesk',
description: titleFunc,
projectName: projectName && projectName.split(' - ').shift()
});

// Check for strange duplicate buttons. Don't know why this happens in Zendesk.
if (document.querySelector('.toggl-button')) {
document.removeChild(elem.querySelector('.toggl-button'));
}
elem.querySelector('[data-side-conversations-anchor-id="1"]').firstChild
.firstChild
.firstChild
.appendChild(link);
}
);
}, 1000);

// Zendesk pre-2021
setTimeout(() => {
togglbutton.render(
Expand Down

0 comments on commit 2a77394

Please sign in to comment.