wagtail / wagtail-localize

Translation plugin for Wagtail CMS
https://wagtail-localize.org/
Other
226 stars 86 forks source link

Editing translation fails with 1.3a2: snippet-chooser-modal.js no longer exists in wagtail #618

Closed iscilyas closed 2 years ago

iscilyas commented 2 years ago

Hi again @zerolab ;)

Trying to do my first translation edit with the new alpha version, I came across the following error:

[many lines omitted]

/contrib/staticfiles/storage.py", line 173, in url
    return self._url(self.stored_name, name, force)
  File "/var/www/html/imrozrum.k12.tr/wagtail/venv/lib/python3.10/site-packages/django/contrib/staticfiles/storage.py", line 152, in _url
    hashed_name = hashed_name_func(*args)
  File "/var/www/html/imrozrum.k12.tr/wagtail/venv/lib/python3.10/site-packages/django/contrib/staticfiles/storage.py", line 472, in stored_name
    raise ValueError(
ValueError: Missing staticfiles manifest entry for 'wagtailsnippets/js/snippet-chooser-modal.js'

After chasing down the usual suspects collectstatic and all, it appears that the offending file wagtailsnippets/js/snippet-chooser-modal.js is referenced here:

wagtail_localize/templates/wagtail_localize/admin/edit_translation.html:    <script type="text/javascript" src="{% versioned_static 'wagtailsnippets/js/snippet-chooser-modal.js' %}"></script>

but snippet-chooser-modal.js longer exists in wagtail (as of commit 172b1335689307960c8ebf363611983581ea6545):

diff --git a/wagtail/snippets/widgets.py b/wagtail/snippets/widgets.py
index 72352ec780..7787ffc9d6 100644
--- a/wagtail/snippets/widgets.py
+++ b/wagtail/snippets/widgets.py
@@ -53,7 +53,7 @@ class AdminSnippetChooser(BaseChooser):
     def media(self):
         return forms.Media(
             js=[
-                versioned_static("wagtailsnippets/js/snippet-chooser-modal.js"),
+                versioned_static("wagtailadmin/js/chooser-modal.js"),
                 versioned_static("wagtailsnippets/js/snippet-chooser.js"),
             ]
         )

(sounds like a pain for wagtail-localize to do wagtail-version-dependent stuff in its template file, but this appears to be the bug and its cause.)

zerolab commented 2 years ago

617 should fix that, if you have time to test

pip install git+https://github.com/wagtail/wagtail-localize.git@chore/drop-pre-wagtail2.15

iscilyas commented 2 years ago

i don't know what i'm doing wrong... i see the diffs on that branch (on github) but after pip install (and pip install --upgrade) i'm not seeing the changes on my filesystem (in particular.. i still have the old version of admin/edit_translation). i'm going to assume the problem is between my chair and keyboard :(

OK so i needed to --force-reinstall it. looks good now! awesome turnaround time!

iscilyas commented 2 years ago

617 should fix that, if you have time to test

pip install git+https://github.com/wagtail/wagtail-localize.git@chore/drop-pre-wagtail2.15

btw, @zerolab ...

the version of wagtail-localize i installed from git/pip using the above link doesn't build/include wagtail-localize.js (as in... doesn't run npm run build) ... it seems like this should be done automatically as part of pip install, but i couldn't see anything in pyproject.toml (or anywhere) that actually runs that... is it just me or is there something missing/wrong? do you guys run npm run build manually before shipping the stuff off with flit? couldn't/shouldn't that be automated (sorry for hijacking this thread, but it seemed rather presumptuous to open yet another bug... especially since i'm not sure about this one)

zerolab commented 2 years ago

This is a manual step at the moment, before flit buld. Can't make it work on pip install as it needs node and that is an entirely different ecosystem. The release process should be documented in the wiki.

My longer term goal is to drop the react dependency and go good old plain JavaScript, but that is something for a later date

iscilyas commented 2 years ago

This is a manual step at the moment, before flit buld. Can't make it work on pip install as it needs node and that is an entirely different ecosystem. The release process should be documented in the wiki.

hey @zerolab if by 'wiki' you mean https://www.wagtail-localize.org/how-to/installation/ there's no reference to webpack... in fact i couldn't find a meaningful result with wagtail-localize "webpack" on google... maybe documentation could use an update?

and yeah, i also looked around for a way to do this with pip... i'm assuming you're aware of setuptools-npm and those aren't the droids you're looking for?

zerolab commented 2 years ago

I'm away from computers till tomorrow. I could swear we had a wiki page on the repo, not the package docs.

Anyhow, i think the README contributing section needs updating with a note on this.

I do know about setuptools-npm (and one other package which I don't have the name/link to), but I see it as an unnecessary evil 🙈 that I don't want imposed on others

chris48s commented 2 years ago

The crucial difference between pip install-ing from PyPI and pip install-ing straight from GitHub is:

so this issue that you have to manually run npm run build applies to the dev build @zerolab is asking you test by running pip install git+https://github.com/wagtail/wagtail-localize.git@chore/drop-pre-wagtail2.15 to help us confirm the fix, but it won't apply to the final release asset we ship to PyPI when we've verified the fix, cut a proper release and you install by running pip install wagtail-localize.

iscilyas commented 2 years ago

thanks @chris48s ... actually i got that part about how they're different ;)

i just thought (especially with the type of hotfixes @zerolab has been amazingly throwing out) it would be great if pip install just generated all the necessary files so the bleeding-edge hotfix tester had a working installation to test ;) but that's before i realized that it's not really so straightforward (and i can't believe every other project isn't also running into this problem... nor the lack of questions/comments about this (as far as i have been able to find))... i thought it would be as simple as adding an npm run build somewhere in some config file and boom ;)

that's all ;)