Skip to content

[Org Home] Disable transactions if organizers aren't signed in #10647

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

manuthecoder
Copy link
Contributor

This pull request refines the logic for rendering transaction links in the app/views/events/home directory. The changes ensure that links are only clickable when the user is signed in as an organizer, improving the user experience and preventing unintended behavior for non-organizers.

Updates to transaction link rendering:

@manuthecoder manuthecoder requested review from a team as code owners June 17, 2025 03:53
Comment on lines +13 to +19
<a
class="homepage-transaction <%= organizer_signed_in? && Flipper.enabled?(:hcb_code_popovers_2023_06_16, current_user) && (@event || transaction.local_hcb_code.event).present? ? "cursor-pointer hover:bg-gray-50 active:bg-gray-100 transition-colors dark:hover:bg-neutral-700 dark:active:bg-neutral-600" : "" %>"
<% if organizer_signed_in? %>
href="<%= url_for(transaction.local_hcb_code) %>"
data-behavior="modal_trigger"
data-modal="money_movement_tx_details_<%= transaction.local_hcb_code.__id__ %>"
<% end %>>
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: If I'm reading this correctly, we're basically removing all useful classes and properties from this <a> tag when organizer_signed_in?, which leaves me with two questions:

  1. Do we need this to be a <a> when there is no href?

    → The capture helper might come in handy here so we can wrap the inner content with different outer elements.

  2. Can we simplify the class attribute logic?

    → Would a local variable be more readable?

^ putting the above together we end up with something like

<% @money_in.each do |transaction| %>
  <% rendered_transaction = capture do %>
    <!-- What was previously in the `<a>` tag -->
  <% end %>  

  <% if organizer.signed_in? %>
    <!-- 👇 We should probably name this -->
    <% name_this_concept = Flipper.enabled?(:hcb_code_popovers_2023_06_16, current_user) && (@event || transaction.local_hcb_code.event).present? %>
    <% css_classes = "cursor-pointer hover:bg-gray-50 active:bg-gray-100 transition-colors dark:hover:bg-neutral-700 dark:active:bg-neutral-600" if name_this_concept  %>
    <a
      class="homepage-transaction <%= css_classes %>" 
      href="<%= url_for(transaction.local_hcb_code) %>"
      data-behavior="modal_trigger"
      data-modal="money_movement_tx_details_<%= transaction.local_hcb_code.__id__ %>"
    >
      <%= rendered_transaction %>
    </a>
  <% else %>
    <div class="homepage-transaction">
      <%= rendered_transaction %>
    </div>
  <% end %>
<% end %>

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.

2 participants