Skip to content

Commit

Permalink
Styled admin panels to look like projects panel (#1070)
Browse files Browse the repository at this point in the history
* Styled admin panels to look like projects panel

* Fixed tests
  • Loading branch information
kelynch authored Nov 22, 2024
1 parent c6e4e66 commit bcc2f53
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 40 deletions.
6 changes: 6 additions & 0 deletions app/assets/stylesheets/_dashboard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,10 @@
vertical-align: top;
}

}

#admin-listing {
.section {
margin-top: 2em;
}
}
4 changes: 2 additions & 2 deletions app/controllers/welcome_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ class WelcomeController < ApplicationController

def index
return if current_user.nil?
@pending_projects = Project.pending_projects
@approved_projects = Project.approved_projects
@pending_projects = Project.pending_projects.map { |project| ProjectDashboardPresenter.new(project) }
@approved_projects = Project.approved_projects.map { |project| ProjectDashboardPresenter.new(project) }
@eligible_data_user = true if !current_user.eligible_sponsor? && !current_user.eligible_manager?

@dashboard_projects = Project.users_projects(@current_user).map { |project| ProjectDashboardPresenter.new(project) }
Expand Down
61 changes: 61 additions & 0 deletions app/views/welcome/_admin_listing.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<div id="admin-listing">
<% if current_user.eligible_sysadmin?%>
<div class="section">
<h2>Pending Projects</h2>
<% if !@pending_projects.empty? %>
<div id="projects-listing">
<% @pending_projects.each do |project| %>
<a href="<%= project_path(project.id) %>">
<section>
<div class="project <%= "last" if project.equal? @pending_projects.last %>">
<h2><%= project.title %></h2>
<div class="details">
<ul>
<li class="status <%= project.status.downcase %>"><%= project.status %></li>
<li class="project-type"><%= project.type %></li>
<li class="user-role"><%= project.role(current_user) %></li>
<li class="last-download"><%= project.latest_file_list_time %></li>
<li class="last-activity"><%= project.last_activity %></li>
</ul>
</div>
</div>
</section>
</a>
<% end %>
</div>
<% else %>
<p> (none) </p>
<% end %>
</div>
<div class="section">
<h2>Recently Approved Projects</h2>
<% if !@approved_projects.empty? %>
<div id="projects-listing">
<% @approved_projects.each do |project| %>
<a href="<%= project_path(project.id) %>">
<section>
<div class="project <%= "last" if project.equal? @approved_projects.last %>">
<h2><%= project.title %></h2>
<div class="details">
<ul>
<li class="status <%= project.status.downcase %>"><%= project.status %></li>
<li class="project-type"><%= project.type %></li>
<li class="user-role"><%= project.role(current_user) %></li>
<li class="last-download"><%= project.latest_file_list_time %></li>
<li class="last-activity"><%= project.last_activity %></li>
</ul>
</div>
</div>
</section>
</a>
<% end %>
</div>
<% else %>
<p> (none) </p>
<% end %>
</div>
<% unless current_user.superuser? %>
<%= render partial: "recent_activity" %>
<% end %>
<%end%>
</div>
2 changes: 1 addition & 1 deletion app/views/welcome/_projects_listing.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<% @dashboard_projects.each do |project| %>
<a href="<%= project_path(project.id) %>">
<section>
<div class="project">
<div class="project <%= "last" if project.equal? @dashboard_projects.last %>">
<h2><%= project.title %></h2>
<div class="details">
<ul>
Expand Down
37 changes: 1 addition & 36 deletions app/views/welcome/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,42 +22,7 @@
<% elsif @dashtab == "activity" %>
<%= render partial: "recent_activity" %>
<% elsif @dashtab == "admin" %>
<div style="display: inline-flex">
<% if current_user.eligible_sysadmin?%>
<div id="dashboard-pending">
<h1>Project Administration</h1>
<h4>Pending Projects</h4>
<% if !@pending_projects.empty? %>
<ul class="project-list">
<% @pending_projects.each do |project| %>
<li>
<%= link_to(project.title, project) %>
</li>
<% end %>
</ul>
<% else %>
<p> (none) </p>
<% end %>
<h4>Recently Approved Projects</h4>
<% if !@approved_projects.empty? %>
<table class="sysadmin-list">
<% @approved_projects.each_with_index do |project, index| %>
<% @row_css = index < 5 ? "visible-row top-section" : "invisible-row bottom-section" %>
<tr class="<%=@row_css%>">
<td><%= link_to(project.title, project) %> </td>
</tr>
<% end %>
</table>
<button id="show-more-sysadmin" type="button" class="btn btn-dark">Show More</button>
<% else %>
<p> (none) </p>
<% end %>
</div>
<% unless current_user.superuser? %>
<%= render partial: "recent_activity" %>
<% end %>
<%end%>
</div>
<%= render partial: "admin_listing" %>
<% end %>
<% end %>
</div>
Expand Down
2 changes: 1 addition & 1 deletion spec/system/project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@

click_on "Return to Dashboard"
click_on "Administration"
expect(page).to have_content "Project Administration"
expect(page).to have_content "Pending Projects"
end
end

Expand Down
2 changes: 2 additions & 0 deletions spec/system/welcome_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,11 @@
it "shows the system administrator dashboard" do
sign_in current_user
visit "/"
visit "/"
click_on "Administration"
expect(page).to have_content("Pending Projects")
expect(page).to have_content("Approved Projects")
expect(page).to have_content("Activity")
end
end

Expand Down

0 comments on commit bcc2f53

Please sign in to comment.