Programmatic GenericFilter prompts for a configuration name when opened for editing #5451#5503
Open
fractal3000 wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #5451
Problem
Opening the configuration editor for a named run-time configuration that exists only in memory (created programmatically, or added via
addConfiguration, and never persisted) shows an empty "Configuration name" field and the "Configuration name required" error, even though the name is visible in the filter header. The conditions are transferred correctly; only the name is lost.Root cause
GenericFilterSupport.loadFilterConfigurationModel(boolean isNewConfiguration, Configuration currentConfiguration)loads the model from the database by id wheneverisNewConfigurationisfalse(i.e. the id is not the empty-configuration id). For an in-memory configuration there is no database row, so the load returnsnulland the fallback creates an emptyFilterConfigurationModelcarrying only the username — the name (and id) are not copied. The editor binds to that empty model.Fix
In the fallback, when the configuration is not new, copy its
idandnameinto the model. The id is required as well: on save,saveCurrentFilterConfigurationbuilds the result configuration fromconfigurationModel.getConfigurationId(), andinitFilterConfigurationreplaces the existing configuration when the ids differ — so without the id the save would drop the original and create a broken/duplicate configuration. TheisNewConfigurationguard leaves both empty for a genuinely new configuration.Notes
flowui-data, so the regression test lives there too.Tests
Added
GenericFilterConfigurationNamePrefillTest(flowui-data) covering all three branches ofloadFilterConfigurationModel(boolean, Configuration):isNewConfiguration == false, load returnsnull): the fallback model is pre-filled with the configuration's id and name. This is the fixed case — it fails on the unpatched code (expected: <Open Projects> but was: <null>) and passes with the fix.isNewConfiguration == false,configurationModel != null): the stored model is returned unchanged, the fallback is not entered.isNewConfiguration == true): the fallback model stays empty (no id/name), so creating a new configuration still asks the user for a name — this guards the!isNewConfigurationguard.The branch actually taken is asserted via
EntityStates.isNew(a model loaded from the database is not new; ametadata.createfallback model is). The existingFilterConfigurationPersistenceTeststays green.