Altinn / Altinn/app-lib-dotnet
Build Index.cshtml automatically
- Dominant language
- C#
- Stars
- 8
- Forks
- 27
- Avg merge
- 1h 21m
- Merged PRs (30d)
- 7
Description
### 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:
```html
```
And the corresponding stylesheet in the header:
```html
```
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](https://github.com/Altinn/altinn-studio/blob/d9edb1e99a47e04f71c1b9b453446ee1014d6f04/src/development/LocalTest/Controllers/HomeController.cs#L201) 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
- https://learn.microsoft.com/en-us/aspnet/core/mvc/views/view-components
- #109
Contributor guide
Research direction
Start by reviewing the current Index.cshtml template and the ViewComponents guidance, then inspect App.csproj and the related discussion in issue #109. Define the configuration, override, and environment behavior before implementation. Done means apps can use a generated default without maintaining the file while still supporting custom scripts, styles, and frontend replacement.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- frontend, web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100