feature/project-identifier-in-trello-board-title (#27)

* Read project identifier from Trello board title

* Refactor

* Update changelog and pump version
This commit is contained in:
Manuel Bouza 2019-10-25 11:13:50 +02:00 committed by Tobias Miesel
parent 7e249202e5
commit 1dcda94483
3 changed files with 21 additions and 35 deletions

View File

@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [1.3.2] - 2019-10-24
### Added
- Read project identifier from Trello board title
## [1.3.1] - 2019-10-17 ## [1.3.1] - 2019-10-17
### Fixed ### Fixed

View File

@ -1,7 +1,7 @@
{ {
"name": "moco-browser-extensions", "name": "moco-browser-extensions",
"description": "Browser plugin for MOCO", "description": "Browser plugin for MOCO",
"version": "1.3.1", "version": "1.3.2",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"start": "yarn start:chrome", "start": "yarn start:chrome",

View File

@ -1,5 +1,11 @@
const projectRegex = /\[([\w-]+)\]/ const projectRegex = /\[([\w-]+)\]/
const projectIdentifierBySelector = selector => document =>
document
.querySelector(selector)
?.textContent?.trim()
?.match(projectRegex)?.[1]
export default { export default {
asana: { asana: {
name: "asana", name: "asana",
@ -11,11 +17,7 @@ export default {
document.querySelector(".ItemRow--highlighted textarea")?.textContent?.trim() || document.querySelector(".ItemRow--highlighted textarea")?.textContent?.trim() ||
document.querySelector(".ItemRow--focused textarea")?.textContent?.trim() || document.querySelector(".ItemRow--focused textarea")?.textContent?.trim() ||
document.querySelector(".SingleTaskPane textarea")?.textContent?.trim(), document.querySelector(".SingleTaskPane textarea")?.textContent?.trim(),
projectId: document => projectId: projectIdentifierBySelector(".TaskProjectPill-projectName"),
document
.querySelector(".TaskProjectPill-projectName")
?.textContent?.trim()
?.match(projectRegex)?.[1],
}, },
"github-pr": { "github-pr": {
@ -23,11 +25,7 @@ export default {
urlPatterns: ["https\\://github.com/:org/:repo/pull/:id(/:tab)"], urlPatterns: ["https\\://github.com/:org/:repo/pull/:id(/:tab)"],
id: (document, service, { org, repo, id }) => [service.key, org, repo, id].join("."), id: (document, service, { org, repo, id }) => [service.key, org, repo, id].join("."),
description: document => document.querySelector(".js-issue-title")?.textContent?.trim(), description: document => document.querySelector(".js-issue-title")?.textContent?.trim(),
projectId: document => projectId: projectIdentifierBySelector(".js-issue-title"),
document
.querySelector(".js-issue-title")
?.textContent.trim()
?.match(projectRegex)?.[1],
}, },
"github-issue": { "github-issue": {
@ -36,11 +34,7 @@ export default {
id: (document, service, { org, repo, id }) => [service.key, org, repo, id].join("."), id: (document, service, { org, repo, id }) => [service.key, org, repo, id].join("."),
description: (document, service, { org, repo, id }) => description: (document, service, { org, repo, id }) =>
document.querySelector(".js-issue-title")?.textContent?.trim(), document.querySelector(".js-issue-title")?.textContent?.trim(),
projectId: document => projectId: projectIdentifierBySelector(".js-issue-title"),
document
.querySelector(".js-issue-title")
?.textContent?.trim()
?.match(projectRegex)?.[1],
}, },
jira: { jira: {
@ -88,21 +82,15 @@ export default {
description: (document, service, { title }) => description: (document, service, { title }) =>
document.querySelector(".js-title-helper")?.textContent?.trim() || title, document.querySelector(".js-title-helper")?.textContent?.trim() || title,
projectId: document => projectId: document =>
document projectIdentifierBySelector(".js-title-helper")(document) ||
.querySelector(".js-title-helper") projectIdentifierBySelector(".js-board-editing-target")(document),
?.textContent?.trim()
?.match(projectRegex)?.[1],
}, },
youtrack: { youtrack: {
name: "youtrack", name: "youtrack",
urlPatterns: ["https\\://:org.myjetbrains.com/youtrack/issue/:id"], urlPatterns: ["https\\://:org.myjetbrains.com/youtrack/issue/:id"],
description: document => document.querySelector("yt-issue-body h1")?.textContent?.trim(), description: document => document.querySelector("yt-issue-body h1")?.textContent?.trim(),
projectId: document => projectId: projectIdentifierBySelector("yt-issue-body h1"),
document
.querySelector("yt-issue-body h1")
?.textContent?.trim()
?.match(projectRegex)?.[1],
}, },
wrike: { wrike: {
@ -117,11 +105,7 @@ export default {
id: ["t", "ot"], id: ["t", "ot"],
}, },
description: document => document.querySelector(".title-field-ghost")?.textContent?.trim(), description: document => document.querySelector(".title-field-ghost")?.textContent?.trim(),
projectId: document => projectId: projectIdentifierBySelector(".header-title__main"),
document
.querySelector(".header-title__main")
?.textContent?.trim()
?.match(projectRegex)?.[1],
}, },
wunderlist: { wunderlist: {
@ -131,10 +115,6 @@ export default {
document document
.querySelector(".taskItem.selected .taskItem-titleWrapper-title") .querySelector(".taskItem.selected .taskItem-titleWrapper-title")
?.textContent?.trim(), ?.textContent?.trim(),
projectId: document => projectId: projectIdentifierBySelector(".taskItem.selected .taskItem-titleWrapper-title"),
document
.querySelector(".taskItem.selected .taskItem-titleWrapper-title")
?.textContent?.trim()
?.match(projectRegex)?.[1],
}, },
} }