Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add coda.io support to rows labelled as 'Task' #1743

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions src/scripts/content/coda.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
'use strict';

// over all rows rendered in coda
togglbutton.render('.kr-row:not(.toggl)', { observe: true }, function (elem) {
// prevent rendering on temporary rows
if (elem.getElementsByClassName('toggl-wrapper').length > 0) return;

// fetch the row data
const row = {
object_id: elem.getAttribute('data-object-id'),
id: elem.getAttribute('data-row-id'),
cells: Array.from(elem.childNodes).map(cell => {
const id = cell.getAttribute('data-column-id');
const columnSelector = 'div[data-column-id=' + id + ']';
const column = document.querySelector(columnSelector);

return {
id,
cell,
column,
title: column && column.textContent,
text: cell.textContent
};
})
};

// look for features of a task
const task = row.cells.findIndex(cell => cell.title === 'Task');
const project = row.cells.findIndex(cell => cell.title === 'Project');
const isTask = task > 0;

// ignore anything thats not a task
if (!isTask) return;

// build the button
const link = togglbutton.createTimerLink(
Object.assign(
{
className: 'coda',
buttonType: 'minimal',
description: row.cells[task].text + ' -- ' + row.cells[task].id
},
project > 0 && {
projectName: row.cells[project].text
}
)
);

// style it for coda
const wrapper = document.createElement('div');
wrapper.className = 'toggl-wrapper';
wrapper.style.display = 'flex';
wrapper.style.alignItems = 'center';
wrapper.style.justifyContent = 'center';
wrapper.appendChild(link);

// add it to the end of the task
elem.appendChild(wrapper);
});
4 changes: 4 additions & 0 deletions src/scripts/origins.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ export default {
url: '*://app.clubhouse.io/*',
name: 'Clubhouse'
},
'coda.io': {
url: '*://coda.io/d/*',
name: 'Coda'
},
'codeable.io': {
url: '*://app.codeable.io/*',
name: 'Codeable'
Expand Down