Skip to content

Commit

Permalink
fix(taiga): Fix taiga.io integration (#2037)
Browse files Browse the repository at this point in the history
* fix(taiga): Fix taiga.io integration

Closes #1929
  • Loading branch information
EternallLight authored Jan 29, 2022
1 parent a78b625 commit 5df3c58
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 19 deletions.
37 changes: 21 additions & 16 deletions src/content/taiga.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
/**
* @name Taiga
* @urlAlias taiga.io
* @urlRegex *://*.taiga.io/*
*/
'use strict';

/* Epic/User story/Task/Issue details button */
togglbutton.render(
'.detail-title-wrapper:not(.toggl)',
{ observe: true },
function (elem) {
const projectElem = $('.us-detail .project-name');
const refElem = $('.detail-number', elem);
const titleElem = $('.detail-subject', elem);
const projectElem = $('tg-project-menu tg-legacy-loader').shadowRoot.querySelector('.menu-option-text.project-name');
const refElem = $('.detail-ref', elem);
const titleElem = $('.detail-title-text > span', elem);

const link = togglbutton.createTimerLink({
className: 'taiga',
Expand Down Expand Up @@ -38,12 +43,12 @@ togglbutton.render('.epic-row .name:not(.toggl)', { observe: true }, function (
});

/* Backlog buttons */
togglbutton.render('.user-story-name:not(.toggl)', { observe: true }, function (
togglbutton.render('.user-story-link:not(.toggl)', { observe: true }, function (
elem
) {
const projectElem = $('.backlog .project-name');
const refElem = $('a > span:nth-child(1)', elem);
const taskElem = $('a > span:nth-child(2)', elem);
const projectElem = $('tg-project-menu tg-legacy-loader').shadowRoot.querySelector('.menu-option-text.project-name');
const refElem = $('.user-story-number', elem);
const taskElem = $('.user-story-name', elem);

const link = togglbutton.createTimerLink({
className: 'taiga',
Expand All @@ -52,17 +57,17 @@ togglbutton.render('.user-story-name:not(.toggl)', { observe: true }, function (
description: refElem.textContent.trim() + ' ' + taskElem.textContent
});

elem.insertBefore(link, $('a', elem));
elem.prepend(link);
});

/* Kanban buttons */
togglbutton.render(
'.kanban .card-title:not(.toggl)',
{ observe: true },
function (elem) {
const refElem = $('a > span:nth-child(1)', elem);
const titleElem = $('a > span:nth-child(2)', elem);
const projectElem = $('.kanban .project-name');
const refElem = $('a > .card-ref', elem);
const titleElem = $('a > .card-subject', elem);
const projectElem = $('tg-project-menu tg-legacy-loader').shadowRoot.querySelector('.menu-option-text.project-name');

const link = togglbutton.createTimerLink({
className: 'taiga',
Expand All @@ -88,7 +93,7 @@ togglbutton.render(
className: 'taiga',
buttonType: 'minimal',
description: refElem.textContent.trim() + ' ' + titleElem.textContent,
projectName: projectElem.textContent
projectName: projectElem ? projectElem.textContent : 'kva'
});

elem.insertBefore(link, $('a', elem));
Expand All @@ -100,14 +105,14 @@ togglbutton.render(
'.issues-table .row:not(.toggl)',
{ observe: true },
function (elem) {
const projectElem = $('.issues-page .project-name');
const refElem = $('a > span:nth-child(1)', elem);
const taskElem = $('a > span:nth-child(2)', elem);
const projectElem = $('tg-project-menu tg-legacy-loader').shadowRoot.querySelector('.menu-option-text.project-name');
const refElem = $('.subject .issue-ref', elem);
const taskElem = $('.subject .issue-subject', elem);

const link = togglbutton.createTimerLink({
className: 'taiga',
buttonType: 'minimal',
projectName: projectElem.textContent,
projectName: projectElem ? projectElem.textContent : 'kva',
description: refElem.textContent.trim() + ' ' + taskElem.textContent
});

Expand Down
3 changes: 2 additions & 1 deletion src/origins.js
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,8 @@ export default {
},
'taiga.io': {
url: '*://*.taiga.io/*',
name: 'Taiga'
name: 'Taiga',
file: 'taiga.js'
},
'targetprocess.com': {
url: '*://*.targetprocess.com/*',
Expand Down
12 changes: 10 additions & 2 deletions src/styles/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -604,11 +604,13 @@ a.toggl-button.toggl-plan {
flex-grow: 0;
}

.backlog-table-body .user-story-name a.toggl-button.taiga {
.backlog-table-body .user-story-link a.toggl-button.taiga {
margin-top: 0;
margin-right: 0.5rem;
text-decoration: none;
flex-grow: 0;
position: relative;
top: 4px;
}

.detail-title-wrapper a.toggl-button.taiga {
Expand All @@ -617,6 +619,13 @@ a.toggl-button.toggl-plan {
flex-grow: 0;
}

.card .card-title a.toggl-button.taiga + a {
display: inline-flex;
align-items: center;
justify-content: center;
height: 13px;

This comment has been minimized.

Copy link
@Arachnos

Arachnos Feb 11, 2022

Don't fix height for following the Toggl button : it is what causes mistakes on multilines titles of tasks or user stories.
height: auto; instead

}

.epic-row a.toggl-button,
.card-title a.toggl-button {
margin: 0 0.25rem 0 0;
Expand All @@ -631,7 +640,6 @@ a.toggl-button.toggl-plan {

.issues-table .row a.toggl-button.taiga {
margin-top: 0;
margin-right: 0.5rem;
text-decoration: none;
flex-grow: 0;
}
Expand Down

1 comment on commit 5df3c58

@Arachnos
Copy link

@Arachnos Arachnos commented on 5df3c58 Feb 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Toggl buttton is displayed correctly on one line tasks or user stories, but, when the title length is bigger, it does mistakes (see screenshot).

image

Please sign in to comment.