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

Split identifiers into asset and code identifiers #896

Closed
sra405 opened this issue Jan 19, 2024 · 1 comment · Fixed by #901
Closed

Split identifiers into asset and code identifiers #896

sra405 opened this issue Jan 19, 2024 · 1 comment · Fixed by #901
Assignees

Comments

@sra405
Copy link
Contributor

sra405 commented Jan 19, 2024

2. Split identifiers into asset and code identifiers

Assets are loaded by:

  • asset identifier

Code is loaded by:

  • code identifier, OR
  • code prop, ELSE
  • blank

This has been done by:

  1. Update editor-ui to allow two identifiers: asset-identifier and code-identifier
  2. Update editor-api to add endpoint for assets only (easy, as above)
  3. Update editor-api to add endpoint for code only (easy)

Draft spike

This has been drafted out in the associated branch which splits out the asset loading from the project loading.

Using Redux devtools we can see the assets from the specified project are available to the user.

For HTML projects, as we can't provide the project type via props, this can be achieved loading a blank HTML project which will in turn set the project type.

You can preview this using these project identifiers:

  <editor-wc
    code_identifier="top-5-emoji-list-step-5" 
    class="c-editor__wc" 
    asset_identifier="anime-expressions"
    output_only
    data-editor-target="editor"
  >

Pros

  • A comprehensive, robust, reliable option as it allows specific loading of different assets and code, without having to overwrite code. This should prevent mistakes or unstable situations.
  • API work required is simple, just splitting the response into two endpoints, one for the assets and the other for the code
  • Backwards compatible, the new assets and code props will supplement the existing identifier prop

Considerations

  • There will be an increase in API calls, as a project with separate identifiers will now be making two calls.
  • This is mitigated by preserving existing identifier prop and routes which will load both assets and code when they're the same, with the new props only being used when the code and assets are different.

Originally posted by @conorriches in #868 (comment)

Notes

  • this is work for the block-to-text alpha so only needs to be merged into the https://github.com/RaspberryPiFoundation/editor-ui/tree/output-only-wc feature branch
  • any additional api endpoints should be fine going into production but sanity check first
  • enables assets and code to be split and managed in the backend 🥳
  • current assumption is we'll hardcode the code template in app and pass populated code back as code
@loiswells97 loiswells97 self-assigned this Jan 23, 2024
Copy link
Contributor

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

Successfully merging a pull request may close this issue.

2 participants