Conversation
|
I tested the changes locally and it looks great to me! One small thing: When I fill out the rollout experience description and then go back to the old UI's branch page, the description field there is left empty, which triggers a validation error. It looks like the new rollout experience description is stored separately from the field the old UI uses. Just wanted to confirm that separation was intentional since we might have to make additional changes later on to avoid that validation error. |
if im not mistaken the rollout experience field is a new field entirely and i wasnt sure whether the better approach was to introduce it as a new field with a migration, or to reuse a similarly shaped existing field like the main issue i saw with introducing a new field is that all non-rollout experiments would leave it blank since it doesnt apply to them. that said, i can see that the current approach may make it unclear where the rollout experience description is actually stored, especially when switching between the new and old UIs |
|
Ah that makes sense! I agree with your approach of adding a new field then since it is different. One other thing: for preventing intermediate updates from saving I did something similar for the rollout phases, but @yashikakhurana suggested following the pattern from Documentation Links in the old UI, where changes persist right away for simplicity so maybe that might apply here as well but I'm not too sure. |
| def get_branch_feature_values_data(self): | ||
| # Add temporary formset rows so newly selected, unsaved features get JSON | ||
| # editors during the HTMX preview before Save persists them. | ||
| if not self.is_bound: | ||
| return None | ||
|
|
||
| data = self.data.copy() | ||
| prefix = "branch-feature-value" | ||
| total_forms_key = "branch-feature-value-TOTAL_FORMS" | ||
| total_forms = int(data[total_forms_key]) | ||
|
|
||
| selected_feature_config_values = ( | ||
| data.getlist("feature_configs") | ||
| if hasattr(data, "getlist") | ||
| else data.get("feature_configs", []) | ||
| ) | ||
| selected_feature_config_ids = [ | ||
| int(feature_config_id) | ||
| for feature_config_id in selected_feature_config_values | ||
| if feature_config_id | ||
| ] | ||
| submitted_feature_config_ids = { | ||
| int(feature_config_id) | ||
| for index in range(total_forms) | ||
| if (feature_config_id := data.get(f"{prefix}-{index}-feature_config")) | ||
| } |
There was a problem hiding this comment.
is this how we are doing with the current forms?
|
you have 2 options to do that- 1- add temporary forms after formset init instead of patching POST data Instead of manipulating raw POST data before passing to the formset, build extra forms directly after: self.branch_feature_values = RolloutBranchFeatureValueFormSet( Add temporary forms for newly selected, unsaved featuresif self.is_bound: 2nd- keep current approach but simplify) Keep get_branch_feature_values_data() but extract the "find new feature IDs" logic: def _get_new_feature_config_ids(self, data, prefix, total_forms): |
Because
This commit
Fixes #16119