Combine recommendation and suggestion screens #2744
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
(a.k.a., "Rewrite recommendations... again")
Problem
If you import a .ckan file that recommends CustomBarnKit, it'll try to install two mods by default:
These conflict with one another, so if the user simply accepts the recommendation, the install will fail with an error.
Cause
CustomBarnKit-RO
provides
CustomBarnKit, so recommending one pulls in both.This is important for something like FerramAerospaceResearchContinued, which we want to match a recommendation for FAR.
Changes
We need the ability to present a recommendation as unchecked. This is impossible within the current code structure, since all recommendations are handled the same way in one big group, and there's no conduit through which we could pass an indication of whether to check the checkbox.
Now the recommendations and suggestions prompts are merged into one big prompt, containing some items that are checked by default (the recommendations) and others that are unchecked by default (the suggestions). This reduces the number of clicks needed to get through an install.
To make this work, the recommendations code is refactored to generate a single sequence of
ListViewItem
s, each of which represents a recommendation or suggestion, and the checked state of which is controlled by more subtle logic. If only one module matches the recommendation, or if there's an exact identifier match, then it'll be checked, otherwise it'll be unchecked. In the original CustomBarnKit scenario, CustomBarnKit will be checked while CustomBarnKit-RO is unchecked. This allows the user to change it if they really want to, while still providing something that will work by default.Using the new code is somewhat simpler for calling code, since it no longer needs to loop over modules or generate lists of recommendations and suggestions. Instead we can now simply pass the list of source modules and receive back the rows that would go to the dialog as input.
Fixes #2724.