Compare commits

..

2 Commits

Author SHA1 Message Date
337acb5448 mstodo query 2020-10-11 20:18:09 +02:00
e019d5660b added mstodo as wunderlist, gitbase as gitlab 2020-10-04 03:14:41 +02:00
7 changed files with 37 additions and 21 deletions

View File

@@ -25,7 +25,7 @@
"mobx": "^5.15.4", "mobx": "^5.15.4",
"mobx-react": "^6.2.2", "mobx-react": "^6.2.2",
"prop-types": "^15.6.2", "prop-types": "^15.6.2",
"query-string": "^6.13.4", "query-string": "^6.12.1",
"react": "^16.13.1", "react": "^16.13.1",
"react-dom": "^16.13.1", "react-dom": "^16.13.1",
"react-select": "^3.1.0", "react-select": "^3.1.0",

View File

@@ -1,11 +1,11 @@
import axios from "axios" import axios from "axios"
import { formatDate } from "utils" import { formatDate } from "utils"
const baseURL = subdomain => { const baseURL = (subdomain) => {
if (process.env.NODE_ENV === "production") { if (process.env.NODE_ENV === "production") {
return `https://${encodeURIComponent(subdomain)}.mocoapp.com/api/browser_extensions` return `https://${encodeURIComponent(subdomain)}.mocoapp.com/api/browser_extensions`
} else { } else {
return `http://${encodeURIComponent(subdomain)}.mocoapp.localhost:3000/api/browser_extensions` return `https://${encodeURIComponent(subdomain)}.mocoapp.com/api/browser_extensions`
} }
} }
@@ -27,7 +27,7 @@ export default class Client {
}) })
} }
login = service => login = (service) =>
this.#client.post("session", { this.#client.post("session", {
api_key: this.#apiKey, api_key: this.#apiKey,
remote_service: service?.name, remote_service: service?.name,
@@ -46,7 +46,7 @@ export default class Client {
params: { date: `${formatDate(fromDate)}:${formatDate(toDate)}` }, params: { date: `${formatDate(fromDate)}:${formatDate(toDate)}` },
}) })
activitiesStatus = service => { activitiesStatus = (service) => {
if (!service) { if (!service) {
return Promise.resolve({ data: { hours: 0 } }) return Promise.resolve({ data: { hours: 0 } })
} }
@@ -55,7 +55,7 @@ export default class Client {
}) })
} }
createActivity = activity => this.#client.post("activities", { activity }) createActivity = (activity) => this.#client.post("activities", { activity })
stopTimer = timedActivity => this.#client.get(`activities/${timedActivity.id}/stop_timer`) stopTimer = (timedActivity) => this.#client.get(`activities/${timedActivity.id}/stop_timer`)
} }

View File

@@ -122,18 +122,31 @@ export default {
allowHostOverride: false, allowHostOverride: false,
}, },
wunderlist: { mstodo: {
name: "wunderlist", name: "wunderlist",
host: "https://www.wunderlist.com", host: "https://to-do.office.com",
urlPatterns: [":host:/(webapp)#/tasks/:id(/*)"], urlPatterns: [":host:/tasks/id/:id(*)"],
description: (document) => description: (document) =>
document document
.querySelector(".taskItem.selected .taskItem-titleWrapper-title") .querySelector(".detailHeader")
?.textContent?.trim(), ?.textContent?.replace(/^[^[]+\[/, "[")
projectId: projectIdentifierBySelector(".taskItem.selected .taskItem-titleWrapper-title"), .replace(projectRegex, "")
.trim(),
projectId: projectIdentifierBySelector(".detailHeader"),
allowHostOverride: false, allowHostOverride: false,
}, },
gitbase: {
name: "gitlab",
host: "https://gitbase.de",
urlPatterns: [":host:/:owner/:repo/issues/:id"],
description: (document) =>
document.querySelector("#issue-title")?.textContent?.replace(projectRegex, "").trim(),
projectId: projectIdentifierBySelector(".select-project.list a"),
allowHostOverride: false,
},
/*
"gitlab-mr": { "gitlab-mr": {
name: "gitlab", name: "gitlab",
host: "https://gitlab.com", host: "https://gitlab.com",
@@ -161,6 +174,7 @@ export default {
}, },
allowHostOverride: true, allowHostOverride: true,
}, },
*/
monday: { monday: {
name: "monday", name: "monday",

View File

@@ -28,6 +28,8 @@ export function tabUpdated(tab, { messenger, settings }) {
const service = matcher(tab.url) const service = matcher(tab.url)
const apiClient = new ApiClient(settings) const apiClient = new ApiClient(settings)
// console.log(service)
if (service?.match?.id) { if (service?.match?.id) {
messenger.postMessage(tab, { type: "requestService" }) messenger.postMessage(tab, { type: "requestService" })
@@ -67,7 +69,7 @@ export function settingsChanged(settings, { messenger }) {
queryTabs({ currentWindow: true }) queryTabs({ currentWindow: true })
.then(reject(isBrowserTab)) .then(reject(isBrowserTab))
.then( .then(
forEach(tab => { forEach((tab) => {
messenger.postMessage(tab, { type: "closePopup" }) messenger.postMessage(tab, { type: "closePopup" })
tabUpdated(tab, { settings, messenger }) tabUpdated(tab, { settings, messenger })
}), }),
@@ -75,7 +77,7 @@ export function settingsChanged(settings, { messenger }) {
} }
export function togglePopup(tab, { messenger }) { export function togglePopup(tab, { messenger }) {
return function({ isOpen, service } = {}) { return function ({ isOpen, service } = {}) {
if (isNil(isOpen)) { if (isNil(isOpen)) {
return return
} }

View File

@@ -20,7 +20,7 @@ module.exports = (env) => {
...manifest, ...manifest,
permissions: compact([ permissions: compact([
...manifest.permissions, ...manifest.permissions,
env.NODE_ENV === "development" ? "http://*.mocoapp.localhost/*" : null, env.NODE_ENV === "development" ? "https://*.mocoapp.com/*" : null,
]), ]),
options_ui: { options_ui: {
...manifest.options_ui, ...manifest.options_ui,

View File

@@ -21,7 +21,7 @@ module.exports = (env) => {
...manifest, ...manifest,
permissions: compact([ permissions: compact([
...manifest.permissions, ...manifest.permissions,
env.NODE_ENV === "development" ? "http://*.mocoapp.localhost/*" : null, env.NODE_ENV === "development" ? "https://*.mocoapp.com/*" : null,
]), ]),
options_ui: { options_ui: {
...manifest.options_ui, ...manifest.options_ui,

View File

@@ -6542,10 +6542,10 @@ query-string@^4.1.0:
object-assign "^4.1.0" object-assign "^4.1.0"
strict-uri-encode "^1.0.0" strict-uri-encode "^1.0.0"
query-string@^6.13.4: query-string@^6.12.1:
version "6.13.4" version "6.13.1"
resolved "https://registry.yarnpkg.com/query-string/-/query-string-6.13.4.tgz#b35a9a3bd4955bce55f94feb0e819b3d0be6f66f" resolved "https://registry.yarnpkg.com/query-string/-/query-string-6.13.1.tgz#d913ccfce3b4b3a713989fe6d39466d92e71ccad"
integrity sha512-E2NPIeJoBEJGQNy3ib1k/Z/OkDBUKIo8IV2ZVwbKfoa65IS9unqWWUlLcbfU70Da0qNoxUZZA8CfKUjKLE641Q== integrity sha512-RfoButmcK+yCta1+FuU8REvisx1oEzhMKwhLUNcepQTPGcNMp1sIqjnfCtfnvGSQZQEhaBHvccujtWoUV3TTbA==
dependencies: dependencies:
decode-uri-component "^0.2.0" decode-uri-component "^0.2.0"
split-on-first "^1.0.0" split-on-first "^1.0.0"