We have a module with its Views, ViewModels and Models and a requirement came in to have an exact copy of the module, but part of the functionality has to be read-only. The read-only mode should be turned on by a configuration parameter. The Model part is the same - it will use the same data sources.
I see two possible solutions to this problem:
Change the existing Views and ViewModels, by manipulating controls' interactivity based on the param. Downsides of this approach is additional conditional logic. We're worried that if we do this, another requirement might come in, where we have to add more conditional logic. Upside - no duplication.
Another way is to split the existing view's into multiple components and assemble the regular module version and the read-only version using those components. We could disable interactivity on the View level in read-only versions and inherit from the ViewModel of the View which we're splitting from and override needed behaviour. The upside would be modularity. Downside - duplication, multiple places to maintain when new components are added in the future.
What's the preferred approach to solve problems like this?