-
Notifications
You must be signed in to change notification settings - Fork 1
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
[59468] Danger Confirmation Dialog implementation #214
Conversation
🦋 Changeset detectedLatest commit: 43e1243 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
843ae27
to
0fb1cb5
Compare
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.
Hi @myabc
nice job, it looks really good 👍 I only have some minor remarks.
app/components/primer/open_project/danger_confirmation_dialog.html.erb
Outdated
Show resolved
Hide resolved
app/components/primer/open_project/danger_confirmation_dialog.html.erb
Outdated
Show resolved
Hide resolved
app/components/primer/open_project/danger_confirmation_dialog.rb
Outdated
Show resolved
Hide resolved
previews/primer/open_project/danger_confirmation_dialog_preview.rb
Outdated
Show resolved
Hide resolved
previews/primer/open_project/danger_confirmation_dialog_preview/playground.html.erb
Show resolved
Hide resolved
e38d4bb
to
0ab3d92
Compare
@HDinger I've addressed most of the issues you raised. In addition to the couple of questions inline, a couple general questions:
|
|
||
def call | ||
render(Primer::BaseComponent.new(**@system_arguments)) do | ||
render(Primer::Alpha::CheckBox.new(**@checkbox_arguments.merge(label: trimmed_content))) |
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.
@HDinger As I've implemented it, we build the checkbox label based on (trimmed_
)content
- this allows for a similar API to the other slots, i.e.:
dialog.with_show_button { "Click me" }
dialog.with_confirmation_checkbox { "I confirm this deletion" }
An alternative would be to add a label_text
string parameter - either on DangerConfirmationDialog
itself - or on the slot. I am not sure "what feels" more idiomatic?
DangerConfirmationDialog.new(label_text: "I confirm this deletion")
dialog.with_confirmation_checkbox(label_text: "I confirm this deletion")
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.
Also, do we want to define a I18n.t
default for the label? Or is it fine to always leave it to the caller?
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.
Currently you can write something like dialog.with_confirmation_checkbox
which will render a checkbox without any label. So we either have to provide a default or enforce that the user provides a string. Since the default is rather special, we probably have to enforce the the user to pass an argument for now.
With regards to the syntax, I like the dialog.with_confirmation_checkbox { "I confirm this deletion" }
notation, but if it is easier to enfoce a text with a named parameter, I am also fine with that.
161029a
to
f3848d1
Compare
Based on `FeedbackDialog`. Wraps `Primer::Alpha::Dialog`, providing additional standardised behaviour for scenarios where a user performs a "dangerous" action. Includes initial Lookbook previews and component tests. Implements `DangerConfirmationDialogFormHelperElement` Catalyst controller providing checkbox confirmation behaviour. https://community.openproject.org/projects/openproject/work_packages/58680
Adds `confirmation_checkbox` slot to allow the caller to provide custom labels, including I18n strings.
f3848d1
to
d60a8e6
Compare
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.
I left some remarks and will check what is happening with the snapshots.
|
||
def call | ||
render(Primer::BaseComponent.new(**@system_arguments)) do | ||
render(Primer::Alpha::CheckBox.new(**@checkbox_arguments.merge(label: trimmed_content))) |
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.
Currently you can write something like dialog.with_confirmation_checkbox
which will render a checkbox without any label. So we either have to provide a default or enforce that the user provides a string. Since the default is rather special, we probably have to enforce the the user to pass an argument for now.
With regards to the syntax, I like the dialog.with_confirmation_checkbox { "I confirm this deletion" }
notation, but if it is easier to enfoce a text with a named parameter, I am also fine with that.
app/components/primer/open_project/danger_confirmation_dialog.html.erb
Outdated
Show resolved
Hide resolved
4e56bad
to
0d265ad
Compare
Ensure the the form is actually submittable.
Makes the capitalisation of CheckBox/check_box consistent with other Primer components. Renames the internal `ConfirmationCheckBox` component and slots (`with_confirmation_check_box`) accordinly.
* Teaches `form_arguments` `:builder` and `:name` options. `:builder` should be an instance of `ActionView::Helpers::FormBuilder`, which is created by the standard Rails `#form_with` and `#form_for` helpers. * Uses Rails Form Helpers under-the-hood to render form tags, ensuring automatic generation of CSRF token, `_method` hidden inputs.
f12553a
to
43e1243
Compare
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.
Nice job 🌟 I really like the way it can be used 👍
Based on
FeedbackDialog
. WrapsPrimer::Alpha::Dialog
, providing additional standardised behaviour for scenarios where a user performs a "dangerous" action.Includes initial Lookbook previews and component tests.
Implements
DangerConfirmationDialogFormHelperElement
Catalyst controller providing checkbox confirmation behaviour.What are you trying to accomplish?
Screenshots
https://raw.githubusercontent.com/opf/primer_view_components/d232bfc77ee23bcde7e00ac3bd50c70bc2f4d034/.playwright/screenshots/snapshots.test.ts-snapshots/primer/open_project/danger_confirmation_dialog/default/light.png
Integration
List the issues that this change affects.
https://community.openproject.org/projects/openproject/work_packages/58680
Risk Assessment
What approach did you choose and why?
Anything you want to highlight for special attention from reviewers?
Accessibility
Merge checklist
Additional TODOs/Questions for Discussion
Test with Rails form builders (?)Resolution: test once upstream