Skip to content

[plugins] allow static files for plugins - #7425

Merged
SchrodingersGat merged 6 commits into
inventree:masterfrom
SchrodingersGat:plugin-static-dirs
Jun 10, 2024
Merged

SchrodingersGat merged 6 commits into
inventree:masterfrom
SchrodingersGat:plugin-static-dirs

Conversation

@SchrodingersGat

@SchrodingersGat SchrodingersGat commented Jun 10, 2024 •

Copy link
Copy Markdown
Member
  • Adds support for static files for plugins
  • Anything in the "static" subdir of each plugin is copied across
  • Runs automatically when a plugin is activated
  • Runs as part of the invoke static task
  • Runs as part of the invoke plugins task

This PR is part of preparation for bring UI plugins into the new react interface. Ideally, the bulk of any "frontend" plugin code can be served by the static file server, which is much more efficient than rendering everything on the backend on each request. It is left up to the plugin developer to determine which files should be served statically.

Plugin static files are copied into the global static directory, to ./plugin/<slug>/ - where slug is the key of the plugin instance.

Files are copied only for "active" plugins

@SchrodingersGat SchrodingersGat added enhancement This is an suggested enhancement or new feature plugin Plugin ecosystem labels Jun 10, 2024
@SchrodingersGat SchrodingersGat added this to the 0.16.0 milestone Jun 10, 2024
@SchrodingersGat
SchrodingersGat requested a review from matmair as a code owner June 10, 2024 07:04
@netlify

netlify Bot commented Jun 10, 2024 •

Copy link
Copy Markdown

✅ Deploy Preview for inventree-web-pui-preview ready!

Name Link
🔨 Latest commit 9bb34f2
🔍 Latest deploy log https://app.netlify.com/sites/inventree-web-pui-preview/deploys/6666a7cf56fcf20008865f3a
😎 Deploy Preview https://deploy-preview-7425--inventree-web-pui-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 100 (no change from production)
Accessibility: 89 (no change from production)
Best Practices: 92 (no change from production)
SEO: 70 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@codecov

codecov Bot commented Jun 10, 2024 •

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 45.16129% with 34 lines in your changes missing coverage. Please review.

Project coverage is 83.80%. Comparing base (66b2976) to head (9bb34f2).
Report is 336 commits behind head on master.

Files with missing lines Patch % Lines
src/backend/InvenTree/plugin/staticfiles.py 31.25% 33 Missing ⚠️
src/backend/InvenTree/plugin/models.py 90.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7425      +/-   ##
==========================================
- Coverage   83.86%   83.80%   -0.07%     
==========================================
  Files        1057     1058       +1     
  Lines       46408    46468      +60     
  Branches     1386     1386              
==========================================
+ Hits        38921    38943      +22     
- Misses       7126     7164      +38     
  Partials      361      361              
Flag Coverage Δ
backend 85.08% <45.16%> (-0.07%) ⬇️

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
SchrodingersGat merged commit 9962d85 into inventree:master Jun 10, 2024
@SchrodingersGat
SchrodingersGat deleted the plugin-static-dirs branch June 10, 2024 11:05
martonmiklos pushed a commit to martonmiklos/InvenTree that referenced this pull request Jun 24, 2024
* Add 'clear' option to 'invoke static'

* Add functions for copying static files from installed plugins

* Collect plugin static files as part of 'invoke static'

* Add 'activate' method for PluginConfig

* Run as part of `invoke plugins`
@wolflu05

wolflu05 commented Jul 21, 2024 •

Copy link
Copy Markdown
Member

Moved to a new issue => #7709

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement This is an suggested enhancement or new feature plugin Plugin ecosystem

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants