Skip to content

Introduce helper for delete/destroy buttons#640

Open
Jonnah151 wants to merge 2 commits intobamnet:mainfrom
Jonnah151:refactor/destroy-button-helper
Open

Introduce helper for delete/destroy buttons#640
Jonnah151 wants to merge 2 commits intobamnet:mainfrom
Jonnah151:refactor/destroy-button-helper

Conversation

@Jonnah151
Copy link

This PR introduces a reusable destroy_button helper to standardize delete/destroy buttons and confirmation dialogs across the application.

Fixes #549

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Jonnah151, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new Rails helper to standardize the creation of delete and destroy buttons throughout the application. By centralizing this common UI pattern, it aims to improve code consistency, reduce duplication, and simplify future maintenance. The screens/show.html.erb view has been refactored to adopt this new helper, and existing links for managing subscriptions are now correctly gated by user permissions, enhancing security and user experience.

Highlights

  • New Helper Introduced: A new helper file, destroy_button_helper.rb, has been added to centralize the logic for creating delete/destroy buttons with standardized confirmation dialogs.
  • Standardized Delete Button: The destroy_button helper encapsulates the button_to call, automatically setting the method: :delete and turbo_confirm data attribute, promoting consistency across the application.
  • View Refactoring: The app/views/screens/show.html.erb file has been updated to utilize the new destroy_button helper for the 'Delete Screen' action, replacing the verbose inline button_to call.
  • Permission-Based Rendering: Several link_to elements in app/views/screens/show.html.erb related to managing subscriptions are now conditionally rendered based on policy(@screen).edit?, ensuring proper authorization checks for visibility.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a reusable destroy_button helper, which is a great step towards standardizing UI components for destructive actions. The implementation is solid, and it's correctly applied in the screens/show view. The suggestion in the helper to improve consistency and accessibility for buttons with custom content has been kept as it aligns with general best practices. The related changes in the view, which add authorization checks and improve formatting, are also valuable improvements.

method: :delete,
class: button_class,
form: form_options,
title: title) do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

When a block is provided, the title attribute is set to the title parameter, which can be nil. If a block is used to render an icon-only button and no explicit title is passed, the button will lack a tooltip, which is detrimental to accessibility. The non-block version of this helper correctly falls back to using label for the title. The same logic should be applied here for consistency and improved accessibility.

                       title: (title || label)) do

@bamnet
Copy link
Owner

bamnet commented Jan 26, 2026

P.S. AFAICT these test failures are unrelated to your work. I'll try to address them in #641. If you rebase after that merges I'm hoping the tests pass here.

@Jonnah151
Copy link
Author

P.S. AFAICT these test failures are unrelated to your work. I'll try to address them in #641. If you rebase after that merges I'm hoping the tests pass here.

thanks

@bamnet
Copy link
Owner

bamnet commented Jan 27, 2026

It looks like this has test failures related to the new button. You should be able to use bin/ci to locally run the full suite of tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Introduce helper for delete / destroy button

2 participants