New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stages/prompt: Add initial_data prompt field and ability to select a default choice for choice fields #5095
stages/prompt: Add initial_data prompt field and ability to select a default choice for choice fields #5095
Conversation
✅ Deploy Preview for authentik ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #5095 +/- ##
==========================================
- Coverage 92.77% 92.76% -0.01%
==========================================
Files 506 506
Lines 25779 25837 +58
==========================================
+ Hits 23913 23964 +51
- Misses 1866 1873 +7
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 8 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
@BeryJu, would it be possible to merge this before 2023.4 is out? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
looking back at this retroactively I think it would've made more sense to have an option to select some sort of "Prompt mapping" in prompts instead of specifying expressions directly, but I'm also not all too sure if that would actually be better.
Also one other thing that might be worth adding is a bit better migration, basically changing the fields in the same way as the blueprints were
Hi, thanks for taking a look at this!
Not sure I understand this correctly. Do you mean to add some extra fields in the model which do not apply to all prompt types? Until now I have been extremely careful not to add "prompt type specific" fields to the model, which is why this weird mapping to the placeholder was necessary for fixed choice prompts. Otherwise the way I imagine this to work is for every prompt type to be a different model (if needed) in the DB with different properties. For example, fixed choice prompts will not have an a However, I am not sure of the extent of (potentially breaking) changes this will introduce and did not want to submit such a PR without your approval and go-ahead first.
Do you mean to create a new migration that migrates placeholder fields to an initial value fields or? I haven't created a manual migration before so if this is required I might need to look up the Django docs on how to do that. |
I meant instead of having the expression specified directly in the prompt, adding a ForeginKey to the mapping object, to make expressions re-usable (but again that's just random thoughts so don't worry about that too much) For the migration I meant something like authentik/authentik/stages/prompt/migrations/0009_prompt_name.py Lines 9 to 21 in 9666d40
|
Ah, so basically for every prompt in the DB that has "evaluate as expression" set (except fixed choice fields):
Is that correct? |
I think that should do it? |
Hi @BeryJu , does this need anything else? |
Hi @sdimovv quick question... you mention the "breaking change" of needing to manually update the any custom prompt fields or blueprints. Do you mention this in your docs in index.md? I didn't see it, but might have missed it. If it is not there, can you add a Note or some such to call it out? Thanks! |
Hi @tanberry , Yes I don't think it is in the docs. However, since I wrote this, @BeryJu requested to add a manual migration step. You can see this here: Lines 8 to 22 in facdc71
This should automatically migrate all prompts (except the new choice prompts) that interpret the placeholder as expression to the new |
Details
Resolves Choice fields: Ability to select arbitrary default value(s) #5063
Changes
New Features
radio-button-group
,dropdown
)Breaking Changes
placeholder
field. Namely - the responsibility of giving initial value to prompts in the user settings flow.Additional
The breaking change should not affect the default authentik config as that will be updated from the updated default blueprints automatically. However, any custom prompt fields or blueprints will need to be manually updated so that their initial value is specified in the "initial_value" field instead of in the "placeholder" field.