Skip to content

Commit 397c227

Browse files
fix(linear): place timer button next to project icon and update issue view sidebar anchor
1 parent e74da74 commit 397c227

1 file changed

Lines changed: 36 additions & 4 deletions

File tree

src/content/linear.js

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,40 @@ togglbutton.render(
3838
},
3939
)
4040

41-
// Add linear integration for issue view
41+
// Add linear integration for issue view and project view (single render)
4242
togglbutton.render(
43-
'div[data-view-id="issue-view"]:not(.toggl)',
43+
'div[data-view-id="issue-view"]:not(.toggl), [data-restore-scroll-view="project-overview"]:not(.toggl)',
4444
{ observe: true },
4545
function (elem) {
46-
if (elem.querySelector('.toggl-button')) {
46+
if (elem.querySelector('.toggl-button')) return
47+
48+
// Project overview page — anchor next to the project icon at the top.
49+
const iconBtn = elem.querySelector('button[aria-label="Choose icon"]')
50+
if (iconBtn) {
51+
const projectName = elem
52+
.querySelector('[aria-label="Project name"]')
53+
?.textContent?.trim()
54+
55+
const link = togglbutton.createTimerLink({
56+
description: projectName,
57+
className: 'linear-project-view',
58+
projectName: projectName,
59+
})
60+
link.style.cssText +=
61+
';display:inline-flex;align-items:center;line-height:0;margin-left:8px;'
62+
63+
// Linear's project header lays the icon out as a block, so a sibling
64+
// ends up on the next row. Wrap both in a flex row so the timer
65+
// button sits inline with the icon.
66+
const row = document.createElement('div')
67+
row.style.cssText = 'display:flex;align-items:center;gap:16px;'
68+
iconBtn.parentElement.insertBefore(row, iconBtn)
69+
row.appendChild(iconBtn)
70+
row.appendChild(link)
4771
return
4872
}
4973

74+
// Issue view — anchor inside the right sidebar above the section list.
5075
const title = elem.querySelector('[aria-label="Issue title"]')?.textContent
5176
const projectElem = elem.parentElement.parentElement.querySelector(
5277
'svg[aria-label="Project"]',
@@ -61,7 +86,14 @@ togglbutton.render(
6186

6287
const sidebar =
6388
elem.parentElement.parentElement.lastElementChild.firstElementChild
64-
sidebar.lastElementChild.prepend(link)
89+
const firstSectionBtn = sidebar.querySelector('button[aria-expanded]')
90+
const sectionWrapper =
91+
firstSectionBtn?.parentElement?.parentElement?.parentElement
92+
if (sectionWrapper) {
93+
sectionWrapper.prepend(link)
94+
} else {
95+
sidebar.appendChild(link)
96+
}
6597
},
6698
)
6799

0 commit comments

Comments
 (0)