fix/annoying-closing-of-trello-card (#16)

* Fix unexpected closing of trello card when clicking on bubble

* Have latest change at the top in changelog
This commit is contained in:
Manuel Bouza 2019-04-24 15:21:36 +02:00 committed by GitHub
parent cd9f94423c
commit 25773cc661
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 77 additions and 46 deletions

View File

@ -1,62 +1,92 @@
# Changelog # Changelog
All notable changes to this project will be documented in this file. 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).
## [Unreleased] ## [Unreleased]
- Add support for starting/stopping a timer - Add support for starting/stopping a timer
- Show hours as HH:MM or decimal in the Bubble, depending on setting in MOCO - Show hours as HH:MM or decimal in the Bubble, depending on setting in MOCO
## [1.1.5] - 2019-04-24
## [1.0.18] - 2019-03-23
### Added
- First release of version 1
## [1.0.19] - 2019-03-26
### Changed
- Position Bubble in the bottom right by default
### Fixed ### Fixed
- Set default value of subdomain to `__unset__` to prevent network error if it is empty
## [1.0.20] - 2019-03-26 - Unexpected closing of Trello card when clicking on Bubble
## [1.1.4] - 2019-04-11
### Added ### Added
- Add support for tags in description
## [1.0.21] - 2019-03-26 - Show customer name in the project select box
### Changed
- Update README with example configuration and instructions for local installation
## [1.0.22] - 2019-03-28 ## [1.1.3] - 2019-04-10
### Changed
- Change the default value of subdomain to `unset` to have a well-formed URL.
## [1.1.0] - 2019-03-30
### Added
- Read project identifier from Asana project title
- Add support for meistertask.com
### Fixed ### Fixed
- Link logo in modal to MOCO activities page
- Set full url on service, including query params
## [1.1.1] - 2019-04-01 - Read projected identifier in Asana's "My tasks"-view
### Fixed
- Discard projects with undefined identifier for preselecting
## [1.1.2] - 2019-04-06 ## [1.1.2] - 2019-04-06
### Fixed ### Fixed
- Allow production build without BUGSNAG_API_KEY - Allow production build without BUGSNAG_API_KEY
- Hours entered in brackets must be non-billable - Hours entered in brackets must be non-billable
### Changed ### Changed
- Read project identifier also from card title in the meistertask service - Read project identifier also from card title in the meistertask service
## [1.1.3] - 2019-04-10 ## [1.1.1] - 2019-04-01
### Fixed
- Read projected identifier in Asana's "My tasks"-view ### Fixed
- Discard projects with undefined identifier for preselecting
## [1.1.0] - 2019-03-30
## [1.1.4] - 2019-04-11
### Added ### Added
- Show customer name in the project select box
- Read project identifier from Asana project title
- Add support for meistertask.com
### Fixed
- Link logo in modal to MOCO activities page
- Set full url on service, including query params
## [1.0.22] - 2019-03-28
### Changed
- Change the default value of subdomain to `unset` to have a well-formed URL.
## [1.0.21] - 2019-03-26
### Changed
- Update README with example configuration and instructions for local installation
## [1.0.20] - 2019-03-26
### Added
- Add support for tags in description
## [1.0.19] - 2019-03-26
### Changed
- Position Bubble in the bottom right by default
### Fixed
- Set default value of subdomain to `__unset__` to prevent network error if it is empty
## [1.0.18] - 2019-03-23
### Added
- First release of version 1

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.1.4", "version": "1.1.5",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"start": "yarn start:chrome", "start": "yarn start:chrome",

View File

@ -12,11 +12,11 @@ const Bubble = ({ bookedHours }) => (
) )
Bubble.propTypes = { Bubble.propTypes = {
bookedHours: PropTypes.number bookedHours: PropTypes.number,
} }
Bubble.defaultProps = { Bubble.defaultProps = {
bookedHours: 0 bookedHours: 0,
} }
export default Bubble export default Bubble

View File

@ -15,8 +15,15 @@ const findService = createServiceFinder(remoteServices)(document)
chrome.runtime.onConnect.addListener(function(port) { chrome.runtime.onConnect.addListener(function(port) {
const messenger = new ContentMessenger(port) const messenger = new ContentMessenger(port)
function clickHandler(event) {
if (event.target.closest(".moco-bx-bubble")) {
event.stopPropagation()
messenger.postMessage({ type: "togglePopup" })
}
}
port.onDisconnect.addListener(() => { port.onDisconnect.addListener(() => {
messenger.stop() messenger.stop()
document.removeEventListener("click", clickHandler, true)
}) })
function updateBubble({ service, bookedHours } = {}) { function updateBubble({ service, bookedHours } = {}) {
@ -24,6 +31,7 @@ chrome.runtime.onConnect.addListener(function(port) {
const domRoot = document.createElement("div") const domRoot = document.createElement("div")
domRoot.setAttribute("id", "moco-bx-root") domRoot.setAttribute("id", "moco-bx-root")
document.body.appendChild(domRoot) document.body.appendChild(domRoot)
document.addEventListener("click", clickHandler, true)
} }
ReactDOM.render( ReactDOM.render(
@ -40,21 +48,14 @@ chrome.runtime.onConnect.addListener(function(port) {
service && service &&
// eslint-disable-next-line react/display-name // eslint-disable-next-line react/display-name
(props => ( (props => (
<animated.div <animated.div className="moco-bx-bubble" style={{ ...props, ...service.position }}>
className="moco-bx-bubble"
style={{ ...props, ...service.position }}
onClick={event => {
event.stopPropagation()
messenger.postMessage({ type: "togglePopup" })
}}
>
<Bubble key={service.url} bookedHours={bookedHours} /> <Bubble key={service.url} bookedHours={bookedHours} />
</animated.div> </animated.div>
)) ))
} }
</Transition> </Transition>
</ErrorBoundary>, </ErrorBoundary>,
document.getElementById("moco-bx-root") document.getElementById("moco-bx-root"),
) )
} }
@ -69,7 +70,7 @@ chrome.runtime.onConnect.addListener(function(port) {
<ErrorBoundary> <ErrorBoundary>
<Popup ref={popupRef} {...payload} onRequestClose={closePopup} /> <Popup ref={popupRef} {...payload} onRequestClose={closePopup} />
</ErrorBoundary>, </ErrorBoundary>,
document.getElementById("moco-bx-popup-root") document.getElementById("moco-bx-popup-root"),
) )
} }
@ -86,7 +87,7 @@ chrome.runtime.onConnect.addListener(function(port) {
const service = findService(window.location.href) const service = findService(window.location.href)
messenger.postMessage({ messenger.postMessage({
type: "newService", type: "newService",
payload: { isOpen: !!popupRef.current, service } payload: { isOpen: !!popupRef.current, service },
}) })
}) })