Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix toolbar undefined #295

Closed

Conversation

sashadev-sky
Copy link
Member

@sashadev-sky sashadev-sky commented Jun 5, 2019

Fixes #273, #123 (<=== Add issue number here)

Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!

  • PR is descriptively titled 📑 and links the original issue above 🔗
  • tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR -- or run tests locally with grunt
  • code is in uniquely-named feature branch and has no merge conflicts 📁
  • screenshots/GIFs are attached 📎 in case of UI updates
  • @mention the original creator of the issue in a comment below for help or for a review

We're happy to help you get this ready -- don't be afraid to ask for help, and don't be discouraged if your tests fail at first!

If tests do fail, click on the red X to learn why by reading the logs.

Please be sure you've reviewed our contribution guidelines at https://publiclab.org/contributing-to-public-lab-software

Thanks!

===============================================

Steps to reproduce bug in our dev environment:

make the changes from the 1st commit:

  1. Update leaflet-toolbar 0.3.0 -> "leaflet-toolbar": "git+https://github.com/Leaflet/Leaflet.toolbar.git" in package.json
  2. $ npm install
  3. $ grunt
  4. Will receive error:
ReferenceError: Can't find variable: LeafletToolbar
  at src/edit/DistortableImage.EditToolbar.js:3:39

Steps to fix the bug in our dev environment:

make the changes from the 2nd commit

  1. LeafletToolbar.ToolbarAction -> L.Toolbar2.Action
  2. LeafletToolbar.Popup -> L.Toolbar2.Popup

@sashadev-sky sashadev-sky requested review from rexagod and jywarren June 5, 2019 07:34
@sashadev-sky sashadev-sky added bug dependencies Pull requests that update a dependency file high-priority needs-review and removed bug labels Jun 5, 2019
@rexagod
Copy link
Member

rexagod commented Jun 5, 2019

Possible breaking change

All functions in the Leaflet.Toolbar namespace should have been ported over
to either the new Leaflet.Toolbar2 namespace in the Leaflet.toolbar
library, or moved to github.com/justinmanley/leaflet-draw-toolbar. If there
are functions missing, that is a bug (either with the library or the docs),
so I would be very grateful if you would create issues when you encounter
such missing functionality.

Okay, so I remember having a conversation about this with Justin a while back where he suggested at some breaking changes between the two namespace and the resulting difference in API support. I guess this was due and should stop conflict with the draw lib! Looks good to me!

Also, none of the users were using the draw library, right? Then why exactly this change? I suppose if they stick to the 0.3.0 install rather than the git one then this shouldn't occur? I can be surely wrong about this, sorry but just want to know why exactly is this happening? Thanks!

@rexagod
Copy link
Member

rexagod commented Jun 5, 2019

Okay just saw your comment at the corresponding issue, I guess the reason for this was the leaflet-toolbar lib shifting the namespace to L.Toolbar2 form LeafletToolbar. Is that right, @sashadev-sky?

@sashadev-sky
Copy link
Member Author

@rexagod not positive. I looked through some issues on the page and I think I remember seeing that the old namespace was also not ES6 compatible (didn't let you import). Which had nothing to do with leaflet-draw-toolbar

anyway the question now is what should we do? Do we ask the users to test out making this change. Or can they not really do that and we just need to announce a breaking change bump a major version and hope it fixes it?

we could add leaflet toolbar locked in as 0.3.0 alternatively to a dependency (not dev), but as I said its not ES6 compatible which seems to be what most users are using. So I would vote for the former

@jywarren

@whoisstan
Copy link

whoisstan commented Jun 5, 2019 via email

@sashadev-sky
Copy link
Member Author

The people have spoken

@sashadev-sky
Copy link
Member Author

I agree. @jywarren how should we proceed with this PR?

@jywarren
Copy link
Member

jywarren commented Jun 5, 2019

How about we try to poll some potential users of this lib by looking at recent commenters (@whoisstan are you a downstream user of this library?)

We could pin an issue with this question for visibility... i dunno. i just imagine it's going to be hard to get feedback from people and we don't want to be too disruptive. That said, there's only one downstream user besides MapKnitter that I'm aware of -- https://github.com/publiclab/Leaflet.DistortableImage/network/dependents

@jywarren
Copy link
Member

jywarren commented Jun 5, 2019

Er, actually that's a second one! I was thinking of:

#105 by @ChrisLowe-Takor

@sashadev-sky
Copy link
Member Author

@jywarren I think based on what I see in the original where it was decided to swap namespaces: Leaflet/Leaflet.toolbar#48 this update will be necessary for moving the library forward as we have 4+ people having reported the issue here and a complaint there resulting in it making this change. It makes sense to move a repo forward with the rest of the packages on Github (leaflet and leaflet-toolbar both adapting to ES6). Additionally could open the door for more contributors!

And also shouldn't really be breaking right? Unless libraries are extending our extended classes like we
we're doing with leaflet-toolbar. The key here will just be documentation.

@jywarren
Copy link
Member

jywarren commented Jun 5, 2019 via email

@sashadev-sky
Copy link
Member Author

@jywarren Ok cool! So do you think it'd be good to release this with a version bump since this issue has been around for a few months? Then we can document the update in the releases like we started doing.

I was thinking to try all this first on my own fork, and confirm it doesn't cause any problems with mapknitter

@jywarren
Copy link
Member

jywarren commented Jun 6, 2019 via email

@whoisstan
Copy link

whoisstan commented Jun 6, 2019 via email

@ChrisLowe-Takor
Copy link

ChrisLowe-Takor commented Jun 7, 2019

#105 by @ChrisLowe-Takor

+1 from downstream. My react wrapper uses a hacked up dist version of Leaflet.DistortableImage as I had problems with the toolbar and needed to chop it. First impression of the diff is it would will make it possible to refactor as a proper dependency.

@sashadev-sky
Copy link
Member Author

@jywarren Ok it works - but it requires a few other updates. Bower can't find the updated package because it is only released on npm. So we will need to:

  • In LDI, we will remove leaflet-toolbar from bower.json (which we're deleting very soon anyway) and add the new version in the dependencies section for package.lock (I'll fix that in this PR)
  • in Mapknitter, we will remove leaflet-toolbar from bower.json and leaflet (leaflet is defined as a peer dependency in leaflet-toolbar so this will prevent receiving a warning message if npm/yarn doesn't see it in our package.json). Create a package.json and move these there, then bump leaflet-toolbar version.
  • We will then need to add a .yarnrc that makes sure these packages are installed under /public/lib. Update installation instructions to include $ yarn install

This will be a breaking a change for repositories using Bower only, so we would release a new major version. We're planning on deprecating bower support this week as part of #240 so these changes will put that in motion now!

Developers (and jywarren & @rexagod ) - please chime in if you don't like anything written above because dependency management is newish to me.

@jywarren
Copy link
Member

MapKnitter switched to yarn last week! 👍

@sashadev-sky sashadev-sky mentioned this pull request Jun 29, 2019
19 tasks
@sashadev-sky
Copy link
Member Author

closing this as it has been fixed in #314

I'll mention everyone on the original issue! Would like to make sure the fix actually fixed it. Note ES6 compatibility has not been addressed yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file high-priority needs-review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue with "LeafletToolbar" when using "leaflet.distordableimage"
5 participants