Add admin_tool helper

This commit is contained in:
Max Wofford 2025-02-21 15:34:59 -05:00
parent c41ae264e5
commit bd508e5904
3 changed files with 16 additions and 1 deletions

View file

@ -15,4 +15,9 @@
:root {
--primary-color: var(--uchu-red);
--muted-color: var(--uchu-gray);
}
}
.admin-tool {
border-radius: 5px;
border: 1px solid var(--uchu-gray);
}

View file

@ -4,4 +4,9 @@ module ApplicationHelper
misses = Thread.current[:cache_misses] || 0
{ hits: hits, misses: misses }
end
def admin_tool(class_name = "", element = "div", **options, &block)
return unless current_user&.is_admin?
concat content_tag(element, class: "#{class_name}", **options, &block)
end
end

View file

@ -28,5 +28,10 @@
Leaderboards
<% end %>
</li>
<% admin_tool(nil, "li") do %>
<%= link_to avo_path, class: "nav-item #{current_page?(avo_path) ? 'active' : ''}" do %>
Avo
<% end %>
<% end %>
</ul>
</aside>