Altinn / app-lib-dotnet

Libraries used in Altinn Apps
BSD 3-Clause "New" or "Revised" License
8 stars 10 forks source link

Build Index.cshtml automatically #108

Open olemartinorg opened 1 year ago

olemartinorg commented 1 year ago

Description

I spent a little time investigating how, and I think I found a fitting solution for how to use ASP.NET MVC to build the Index.cshtml file instead of having each app maintaining it by themselves. Right now we have lines in that file like:

<script src="https://altinncdn.no/toolkits/altinn-app-frontend/3/altinn-app-frontend.js" crossorigin></script>

And the corresponding stylesheet in the header:

<link rel="stylesheet" type="text/css" href="https://altinncdn.no/toolkits/altinn-app-frontend/3/altinn-app-frontend.css">

We also have a script that sets window.org and window.app from the URL. All of these are implementation specifics for app-frontend, and they're irrelevant for most app developers. Most apps use the default version of this file, never changing it. Some add their own scripts and styles (which is needed for custom web components), but most don't.

We should have better control here:

  1. Implement ViewComponents for the common parts (our script/style tags, the expected HTML structure needed for app-frontend, head/body)
  2. Break it up into parts so that app developers can override parts of the file, or everything in it. Some (OED?) needs to replace the frontend app.
  3. Make it possible to not have the file in your app repo at all (and make that the default in the template), instead controlling the app-frontend version through a configuration option (or in App.csproj like the backend versions).
  4. Possibly also add configuration options for custom script/style tags?
  5. When we generate our own script/styles tags for app-frontend on the fly, we can catch the LocalTest cookie and prefer that (regardless of the version we would have defaulted to).
  6. Test environments (local, tt02, etc) should perhaps default to use the latest pre-release of app-frontend should there be a newer one than the latest stable. We could possibly add a global info box in app-frontend to notify the user about the pre-release version being used, with a simple option to swap to the latest stable.

Additional Information

bjosttveit commented 1 year ago

Related to: https://github.com/Altinn/app-frontend-react/issues/760#issuecomment-1383703287

bjosttveit commented 1 year ago

We could also bundle static data like applicationMetadata, layoutSets++ into a script-tag so that the static data that never changes is available immediately, not requiring a bunch of get-requests after initially loading.

ivarne commented 1 year ago

@bjosttveit footer.json?

bjosttveit commented 1 year ago

Sure 😅