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

Validate individual components against JsonSchema and produce warnings in DevTools #1512

Closed
Tracked by #339 ...
olemartinorg opened this issue Sep 25, 2023 · 3 comments · Fixed by #1602
Closed
Tracked by #339 ...
Assignees
Labels
area/layout related to layouts/components fe-v4 Issues to be solved before v4 goes gold kind/feature-request New feature or request

Comments

@olemartinorg
Copy link
Contributor

Extracted from #648. We should bring a copy of the component JsonSchema into app-frontend, and validate all components in a layout file against that, spitting out errors in DevTools if any.

@olemartinorg olemartinorg added kind/feature-request New feature or request area/layout related to layouts/components labels Sep 25, 2023
@olemartinorg olemartinorg added the fe-v4 Issues to be solved before v4 goes gold label Sep 25, 2023
@bjosttveit
Copy link
Member

How should app-frontend load the schemas? I can see a few options:

  1. Bundle the schemas with altinn-app-frontend.js
    • This file is already quite large, and this would bring an additional ~230kb
    • It is unnecessary to load in prod, but if done this way it would not be optional
    • It would always be up to date with the actual frontend version used, but risks differing from the schema used in the layout file giving feedback in the editor.
  2. Load the schema using the same url as the layout-files have.
    • It could either be hard-coded in app-frontend or picked out from the layout-file from the app.
    • This method risks using the incorrect version depending on what frontend-version the app is using. (frontend version can be set to a specific version and will not necessarily be on the latest version)
    • If not bundled, it can be loaded only in dev/tt02 or only when dev-tools is opened (or both). Additional loading time would be less of an issue.
  3. We could move the schemas to the dist folder so the schemas would be tied to the frontend-version and would be deployed to cdn alongside altinn-app-frontend.js.
    • This is especially relevant since schemas are auto generated and can be assumed to be up to date with every version.
    • This would have the same benefit as 2. with the added benefit of always corresponding to the actual frontend version used.
    • It would be a breaking change for the schema url used in the layout file, since to be guaranteed to have the same schema used to check in the editor as in dev-tools you would need to update the url in each layout file. We would likely need to change the url for v4 anyways if we want to keep support for v3 for a while, and this change should be handled automatically using an upgrade tool either in studio or cli or both.
    • Downside is more storage use in cdn, but since it looks like we are finally ditching GitHub pages this may not be an issue very soon?

Any thoughts @olemartinorg @tjololo ?

@olemartinorg
Copy link
Contributor Author

Agree whole-heartedly on alternative number 3. We would also need tooling (such as the upgrade tool) to update $schema references in layout files in apps when changing the frontend version.

@bjosttveit bjosttveit self-assigned this Oct 18, 2023
@bjosttveit bjosttveit moved this to 👷 In Progress in Team Apps Oct 18, 2023
@bjosttveit bjosttveit moved this from 👷 In Progress to 🔎 Review in Team Apps Oct 27, 2023
@bjosttveit bjosttveit moved this from 🔎 Review to 🧪 Test in Team Apps Oct 30, 2023
@olemartinorg
Copy link
Contributor Author

Tested OK! 🥳 There's a bit of mixing between norwegian and english right now in the log, but IMO that's fine.

@olemartinorg olemartinorg moved this from 🧪 Test to ✅ Done in Team Apps Nov 3, 2023
@RonnyB71 RonnyB71 mentioned this issue Nov 22, 2023
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/layout related to layouts/components fe-v4 Issues to be solved before v4 goes gold kind/feature-request New feature or request
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants