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

Support new React Interface #44

Open
wants to merge 33 commits into
base: main
Choose a base branch
from
Open

Support new React Interface #44

wants to merge 33 commits into from

Conversation

SchrodingersGat
Copy link
Member

@SchrodingersGat SchrodingersGat commented Sep 30, 2024

This PR is a major update to the plugin, to support the modern react interface.

TODO

  • Update backend code to support new "UI panels" ecosystem
  • Setup react / vite project
  • Run CI for frontend code
  • Fix path of static javascript file (currently hard-coded)
  • Update to pyproject.toml setup script
  • Automatically build frontend code on plugin install
  • Ensure static files are copied across correctly
  • Choose better icon for plugin panel
  • Add custom "admin" UI elements - [PUI] Plugin settings UI InvenTree#8228
  • Provide method for deleting existing diagram
  • Provide method for uploading a new diagram
  • Provide method for uploading an initial diagram file

Copy link
Member

@matmair matmair left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very intresting @SchrodingersGat !

src/frontend/src/App.css Outdated Show resolved Hide resolved
src/frontend/src/App.tsx Outdated Show resolved Hide resolved
@SchrodingersGat
Copy link
Member Author

SchrodingersGat commented Sep 30, 2024

@matmair @wolflu05 question for you guys. I have had to "hack" something into setup.py to allow me to copy across the compiled "static" files:

# Copy the compiled frontend files into the 'static' directory
# Required for MANIFEST.in to work correctly
here = pathlib.Path(__file__).parent.absolute()

# Copy the compiled frontend files into the 'static' directory
src_dir = here.joinpath('frontend/dist/static').resolve()
dst_dir = here.joinpath('inventree_wireviz/static').resolve()

if src_dir.exists():
    print("Copying frontend files from", src_dir, "to", dst_dir)
    shutil.copytree(src_dir, dst_dir, dirs_exist_ok=True)

The reason for this is that the MANIFEST.in file does not allow you to specify a separae "target" directory. That is, the directory of the copied files within the package matches the directory where they are located in the project.

Here is the contents of MANIFIEST.in:

recursive-include inventree_wireviz/templates *.js *.html
recursive-include inventree_wireviz/static *.js *.css

So, to appear at ./static/ I have to copy them across in setup.py (after building with npm run build as a separate step).

This works, but is a bit of a kludge and I'd like to avoid this step if possible. It also makes documenting the process (for other plugin developers) a bit tricker. Any ideas on how this might be improved?

@wolflu05
Copy link

wolflu05 commented Sep 30, 2024

You can specify the bundle out dir in vite with the rollup options, so that the bundle is directly saved in the static folder.

An other option would be to define a manually cp step in the package.json in the build script. (Something like:

  "scripts": {
    "build": "vite build && cp dist/ static/"

Of course you need the correct paths here)

@SchrodingersGat
Copy link
Member Author

@wolflu05 thanks, that helped. The workflow is much cleaner now :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants