Skip to content

Plugin static files - #7763

Merged
SchrodingersGat merged 3 commits into
inventree:masterfrom
wolflu05:plugin-static-files
Jul 30, 2024
Merged

SchrodingersGat merged 3 commits into
inventree:masterfrom
wolflu05:plugin-static-files

Conversation

@wolflu05

@wolflu05 wolflu05 commented Jul 30, 2024 •

Copy link
Copy Markdown
Member

This PR fixes issue 1 and 4 from #7709 (comment)

This PR is marked as breaking to appear at the top of the changelog. Something like the following text should be added to the changelog for users to explain the change:


⚠️ Plugin static files (#7425) (#7763)

Previously if a plugin had the AppMixin and contained a static folder, static files where collected as part of invoke static like a normal django app directly in the static folder (e.g. my-plugin/static/test.js was accessible by /static/test.js). Now plugin static files are collected from every plugin that contains a my-plugin/static folder (No need for the AppMixin anymore) in /static/plugins/<plugin-slug>/ meaning the test.js in the static folder from the previous example is now accessible from /static/plugins/<plugin-slug>/test.js.

The {% plugin_static "test.js" %} template tag from {% load plugin_extras %} can be used to get the correct path for a static file provided by a plugin. It is also backported to 0.15.x (#7764) and acts as a proxy to the normal static tag there.


@netlify

netlify Bot commented Jul 30, 2024 •

Copy link
Copy Markdown

✅ Deploy Preview for inventree-web-pui-preview canceled.

Name Link
🔨 Latest commit b3aaeb8
🔍 Latest deploy log https://app.netlify.com/sites/inventree-web-pui-preview/deploys/66a8b557d7f3600008c63a9e

@wolflu05 wolflu05 added plugin Plugin ecosystem breaking Indicates a major update or change which breaks compatibility labels Jul 30, 2024
@wolflu05 wolflu05 added this to the 0.16.0 milestone Jul 30, 2024
@codecov

codecov Bot commented Jul 30, 2024 •

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 26.66667% with 11 lines in your changes missing coverage. Please review.

Project coverage is 83.51%. Comparing base (637a7fe) to head (b3aaeb8).
Report is 326 commits behind head on master.

Files with missing lines Patch % Lines
...end/InvenTree/plugin/templatetags/plugin_extras.py 30.00% 7 Missing ⚠️
src/backend/InvenTree/plugin/staticfiles.py 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7763      +/-   ##
==========================================
- Coverage   83.52%   83.51%   -0.02%     
==========================================
  Files        1114     1114              
  Lines       49355    49365      +10     
  Branches     1571     1571              
==========================================
+ Hits        41225    41226       +1     
- Misses       7734     7743       +9     
  Partials      396      396              
Flag Coverage Δ
backend 85.34% <26.66%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@SchrodingersGat

Copy link
Copy Markdown
Member

@wolflu05 so with these changes are you happy that existing plugin static files are honoured, and also the new approach?

@wolflu05

wolflu05 commented Jul 30, 2024 •

Copy link
Copy Markdown
Member Author

Sorry, but I don't understand your comment, could you please explain?

With this PR, the old approach using the AppMixin has no effect anymore, as the plugins get not loaded for the traditional Django static file collection. They only get copied with your added collectplugins script. That way there are no duplicated static files at two paths anymore. And yes, I'm happy with that, as this is a clear, single and official path now for handeling static files. (Also automatic if issue 2 from my comment is fixed too)

Additionally I have fixed the issue with the recursive deletion.

@SchrodingersGat

Copy link
Copy Markdown
Member

@wolflu05 sorry, was not very good description.

I mean, that the new approach allows for static file collection whether or not the plugin has "app" support. So, are we happy that this is sufficient and covers all cases?

@wolflu05

Copy link
Copy Markdown
Member Author

Thanks for clarifying, Yes, I'm happy with it.

@SchrodingersGat

Copy link
Copy Markdown
Member

Ok, well thanks for the additional fixes and insights :)

@SchrodingersGat
SchrodingersGat merged commit 648cb12 into inventree:master Jul 30, 2024
@SchrodingersGat SchrodingersGat added the bug Identifies a bug which needs to be addressed label Jul 30, 2024
@wolflu05
wolflu05 deleted the plugin-static-files branch July 30, 2024 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Indicates a major update or change which breaks compatibility bug Identifies a bug which needs to be addressed plugin Plugin ecosystem

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants