From 71081a30bd1955cda35780a40d908b888737aa7d Mon Sep 17 00:00:00 2001 From: Manuel Bouza Date: Wed, 24 Apr 2019 17:34:26 +0200 Subject: [PATCH] Add support for WRIKE --- CHANGELOG.md | 6 ++++++ package.json | 2 +- src/css/content.scss | 1 + src/js/remoteServices.js | 19 +++++++++++++++++++ src/js/utils/index.js | 1 + src/js/utils/urlMatcher.js | 26 ++++++++++++++++++++++---- 6 files changed, 50 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e83200c..e01d8fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add support for starting/stopping a timer - Show hours as HH:MM or decimal in the Bubble, depending on setting in MOCO +## [1.2.0] - 2019-04-26 + +### Added + +- Add support for wrike.com + ## [1.1.5] - 2019-04-24 ### Fixed diff --git a/package.json b/package.json index 892d444..95e5b29 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "moco-browser-extensions", "description": "Browser plugin for MOCO", - "version": "1.1.5", + "version": "1.2.0", "license": "MIT", "scripts": { "start": "yarn start:chrome", diff --git a/src/css/content.scss b/src/css/content.scss index 06945c1..aad519e 100644 --- a/src/css/content.scss +++ b/src/css/content.scss @@ -68,6 +68,7 @@ height: 100%; overflow: auto; background-color: rgba(0, 0, 0, 0.4); + z-index: 9999; .moco-bx-popup-content { background-color: white; diff --git a/src/js/remoteServices.js b/src/js/remoteServices.js index e230e0a..309f6b3 100644 --- a/src/js/remoteServices.js +++ b/src/js/remoteServices.js @@ -95,6 +95,25 @@ export default { description: document => document.querySelector("yt-issue-body h1")?.textContent?.trim(), }, + wrike: { + name: "wrike", + urlPatterns: [ + "https\\://www.wrike.com/workspace.htm#path=mywork", + "https\\://www.wrike.com/workspace.htm#path=folder", + ], + queryParams: { + id: ["t", "ot"], + }, + description: document => document.querySelector(".title-field-ghost")?.textContent?.trim(), + projectId: document => { + const match = document + .querySelector(".header-title__main") + ?.textContent?.trim() + ?.match(projectRegex) + return match && match[1] + }, + }, + wunderlist: { name: "wunderlist", urlPatterns: ["https\\://www.wunderlist.com/(webapp)#/tasks/:id(/*)"], diff --git a/src/js/utils/index.js b/src/js/utils/index.js index 256408d..ffc5f63 100644 --- a/src/js/utils/index.js +++ b/src/js/utils/index.js @@ -20,6 +20,7 @@ export const ERROR_UPGRADE_REQUIRED = "upgrade-required" export const ERROR_UNKNOWN = "unknown" export const noop = () => null +export const asArray = input => (Array.isArray(input) ? input : [input]) export const findProjectBy = prop => val => projects => { if (!val) { diff --git a/src/js/utils/urlMatcher.js b/src/js/utils/urlMatcher.js index 2695bd6..4767fa2 100644 --- a/src/js/utils/urlMatcher.js +++ b/src/js/utils/urlMatcher.js @@ -1,10 +1,28 @@ import UrlPattern from "url-pattern" -import { isFunction, isUndefined, compose, toPairs, map, pipe } from "lodash/fp" +import { isFunction, isUndefined, compose, toPairs, map, pipe, isNil } from "lodash/fp" +import { asArray } from "./index" import queryString from "query-string" -const extractQueryParams = (queryParams, query) => { - return toPairs(queryParams).reduce((acc, [key, param]) => { - acc[key] = query[param] +function parseUrl(url) { + const urlObject = new URL(url) + const { origin, pathname, search } = urlObject + let { hash } = urlObject + const query = { + ...queryString.parse(search), + ...queryString.parse(hash), + } + if (hash) { + hash = hash.match(/#[^&]+/)[0] + } + return { origin, pathname, hash, query } +} + +function extractQueryParams(queryParams, query) { + return toPairs(queryParams).reduce((acc, [key, params]) => { + const param = asArray(params).find(param => !isNil(query[param])) + if (param) { + acc[key] = query[param] + } return acc }, {}) }