Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ $secondary: $california-gold;
@import "custom_bootstrap";
@import "font-awesome";

@import "datatables/dataTables.bootstrap5.css";
@import "datatables/responsive.bootstrap5.css";

@each $name, $value in $colors {
.bg-#{$name} {
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/controllers/assignment_controller.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Controller } from "@hotwired/stimulus"
import DataTable from "datatables.net-bs5";
import { pollUntilDone } from "./sync_poller";
import { pollUntilDone } from "controllers/sync_poller";
import "datatables.net-responsive";
import "datatables.net-responsive-bs5";

Expand Down
2 changes: 1 addition & 1 deletion app/javascript/controllers/enrollments_controller.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Controller } from "@hotwired/stimulus";
import DataTable from "datatables.net-bs5";
import { pollUntilDone } from "./sync_poller";
import { pollUntilDone } from "controllers/sync_poller";
import "datatables.net-responsive";
import "datatables.net-responsive-bs5";

Expand Down
8 changes: 7 additions & 1 deletion app/views/layouts/_navbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle testid-username" href="#" data-bs-toggle="dropdown"
aria-expanded="false" aria-label="User menu for <%= session[:username] %>"><%= session[:username] %></a>
<ul class="dropdown-menu">
<ul class="dropdown-menu" id="user-dropdown-menu">
<% if current_user.admin? %>
<li><h6 class="dropdown-header">Admin Tools</h6></li>
<li><a class="dropdown-item" href="/admin/blazer">Dashboards</a></li>
<li><a class="dropdown-item" href="/admin/good_job">Background Jobs</a></li>
<li><hr class="dropdown-divider"></li>
<% end %>
<li><a class="dropdown-item testid-logout-button" href="/logout/">Logout</a></li>
</ul>
</li>
Expand Down
2 changes: 2 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<%= csp_meta_tag %>

<%= stylesheet_link_tag "application" %>
<link rel="stylesheet" href="/datatables/dataTables.bootstrap5.css">
<link rel="stylesheet" href="/datatables/responsive.bootstrap5.css">

<%= javascript_importmap_tags %>
<%= render "layouts/components/color_mode_critical" %>
Expand Down
16 changes: 16 additions & 0 deletions features/navigation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,19 @@ Feature: Navigation
And I should see "Login with bCourses" in the navbar
And I should not see "Offerings" in the navbar
And I should not see "Logout" in the navbar

Scenario: Admin user sees admin tools in navbar dropdown
Given a course exists
And I am logged in as an admin
And I am on the "Courses page"
Then I should see "Admin Tools" in the navbar dropdown
And I should see "Dashboards" in the navbar dropdown
And I should see "Background Jobs" in the navbar dropdown

Scenario: Non-admin user does not see admin tools in navbar dropdown
Given a course exists
And I am logged in as a teacher
And I am on the "Courses page"
Then I should not see "Admin Tools" in the navbar dropdown
And I should not see "Dashboards" in the navbar dropdown
And I should not see "Background Jobs" in the navbar dropdown
5 changes: 5 additions & 0 deletions features/step_definitions/custom_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
end
end

Given(/^I am logged in as an admin$/) do
user = create(:admin, email: 'admin@berkeley.edu', canvas_uid: 'canvas_uid_admin')
page.set_rack_session(user_id: user.canvas_uid, username: user.name)
end

Given(/^(?:I am|I'm|I) (?:logged|log) in as a (teacher|ta|student)$/i) do |role|
emails = {
'teacher' => 'user1@berkeley.edu',
Expand Down
12 changes: 12 additions & 0 deletions features/step_definitions/navigation_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@
end
end

Then(/^I should see "(.*?)" in the navbar dropdown$/) do |text|
within('#user-dropdown-menu') do
expect(page).to have_content(text)
end
end

Then(/^I should not see "(.*?)" in the navbar dropdown$/) do |text|
within('#user-dropdown-menu') do
expect(page).not_to have_content(text)
end
end

When(/^I navigate to any page other than the "(.*?)"$/) do |excluded_page|
# Currently included home and courses page
case excluded_page
Expand Down
Loading
Loading