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

Allow Admin UI extensions to be authored in any JS framework #225

Closed
michaelbromley opened this issue Dec 6, 2019 · 1 comment
Closed
Labels
design 📐 This issue deals with high-level design of a feature type: feature ✨ @vendure/admin-ui

Comments

@michaelbromley
Copy link
Member

Is your feature request related to a problem? Please describe.
Currently, Admin UI extensions must be Angular modules. This allows the modules to be compiled into the main Admin UI app, and allows re-use of components and sharing of core services e.g. the DataService or ModalService.

The problem is that a significant segment of JS devs do not know Angular. There will be plenty of React/Vue/Other devs who will want to create some UI extension but would be able to do it much more efficiently in their tech of choice.

Describe the solution you'd like
I would like to create a kind of host component which allows any arbitrary JS app to be used as an extension.

The basic idea would be that the user code is put in an iframe which is part of the host component. Communication is possible via an well-defined API which uses Window.postMessage API to pass data between the UI app and the user code.

Data layer

This API could even expose a GraphQL client which takes DocumentNodes and passes the stringified representation across the iframe boundary, at which point the UI app DataService makes the request, and then passes the response back to the user code. In this way the global Apollo cache can be leveraged and kept in sync.

Styling

A major downside to using a different tech is that it will not look consistent with the rest of the UI by default. This can be mitigated by providing a basic stylesheet which can be included in the user code.

Proof-of-concept

  1. The first goal would be to allow the display of an arbitrary HTML document at a specified route in the UI app. Just use plain JS/HTML at this point
  2. Next, provide a way to fetch data from the user app
  3. Then provide some means of styling
  4. Implement a simple CRUD view in React and Vue
  5. Look into how we can expose some other services such as NotificationService (toast messages), ModalService etc. which would be commonly required, so the user apps can do these common UI tasks without needing to re-invent this common functionality.

Custom Field Controls

The other thing UI extension can do is to define custom controls for CustomFields. A similar approach as above could make it possible to author these custom controls in any technology.

@michaelbromley michaelbromley added design 📐 This issue deals with high-level design of a feature @vendure/admin-ui type: feature ✨ labels Dec 6, 2019
michaelbromley added a commit that referenced this issue Dec 11, 2019
This package exposes an API which allows embedded UI extension applications to access core functionality. So far implements GraphQL queries & mutations. Relates to #225
michaelbromley added a commit that referenced this issue Dec 11, 2019
@michaelbromley
Copy link
Member Author

This is now implemented with Vendure 0.10.0: https://www.vendure.io/blog/2020/03/announcing-vendure-v0.10.0/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design 📐 This issue deals with high-level design of a feature type: feature ✨ @vendure/admin-ui
Projects
None yet
Development

No branches or pull requests

1 participant