Skip to content

Commit bb6038d

Browse files
committed
tasks dropdown
1 parent 170b3e9 commit bb6038d

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

app/views/application/_navbar.html.erb

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,35 @@
1616
<% if logged_in? %>
1717
<%= render partial: 'navbar_link', locals: { path: projects_path, text: 'Projects', active: -> { params[:controller] == 'projects' } } %>
1818
<%= render partial: 'navbar_link', locals: { path: repositories_path, text: 'Repositories', active: -> { params[:controller] == 'repositories' } } %>
19-
<%= render partial: 'navbar_link', locals: { path: tasks_path, text: 'Tasks', active: -> { params[:controller] == 'tasks' } } %>
19+
20+
<% if logged_in? %>
21+
<li class="nav-item dropdown ms-3 me-3">
22+
<%- tasks = current_user.tasks.where(state: %w[pending_fetch pending_build running failed]).load_async %>
23+
<a class="nav-link dropdown-toggle <%= params[:controller] == 'tasks' ? 'active' : '' %>" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
24+
<% if tasks.any?(&:running?) %>
25+
<span class="spinner-border spinner-border-sm"></span>
26+
<% end %>
27+
Build tasks
28+
</a>
29+
<ul class="dropdown-menu dropdown-menu-end shadow">
30+
<% tasks.first(15).each do |task| %>
31+
<li>
32+
<%= link_to task_path(task), class: 'dropdown-item' do %>
33+
<%= render partial: 'tasks/state_icon', locals: { task: task } %>
34+
<%= task.state.humanize %>
35+
<% if task.running? %>
36+
<%= task.progress.to_s %>
37+
<% end %>
38+
<% end %>
39+
</li>
40+
<% end %>
41+
<li><hr class="dropdown-divider"></li>
42+
<li>
43+
<%= link_to 'Show all', tasks_path, class: 'dropdown-item' %>
44+
</li>
45+
</ul>
46+
</li>
47+
<% end %>
2048
<% end %>
2149
</ul>
2250

0 commit comments

Comments
 (0)