-
Notifications
You must be signed in to change notification settings - Fork 47
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
Add admin UI #227
Merged
Merged
Add admin UI #227
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
53981a0
Add admin UI
a049c85
Add admin acceptance test
b725f45
Add form for running suite manually
389362d
Run on form submit
11e1804
Add manual run integration test
f5cb6a4
Fix Capybara::Poltergeist::StatusFailError on travis
fc9b706
Reload assets when switch between admin and application layout
acdffdc
Add alert when submit manual run
7562941
Fix
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
//= require jquery | ||
//= require jquery_ujs | ||
//= require turbolinks | ||
//= require bootstrap_sb_admin_base_v2 | ||
//= require_tree ./admin |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
$(document).on('turbolinks:load', function() { | ||
$('#manual_run_form').submit(function(event) { | ||
$('#notice').remove(); | ||
$('#wait_alert').removeClass('hidden'); | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@import "bootstrap-sprockets"; | ||
@import "bootstrap"; | ||
@import "font-awesome"; | ||
@import "bootstrap_sb_admin_base_v2"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,36 @@ class AdminController < ApplicationController | |
http_basic_authenticate_with( | ||
name: 'admin', | ||
password: Rails.application.secrets.admin_password | ||
) | ||
) unless Rails.env.test? | ||
|
||
layout 'admin' | ||
|
||
before_action :set_repos | ||
before_action :set_repo, only: [:repo, :run] | ||
|
||
def toggle_admin | ||
session['admin'] = !session['admin'] | ||
redirect_to root_path | ||
end | ||
|
||
def home | ||
end | ||
|
||
def repo | ||
end | ||
|
||
def run | ||
ManualRunner.new(@repo).run_last(params[:count].to_i) | ||
redirect_to admin_repo_path(@repo.name), notice: "#{@repo.name.capitalize} suite is running for last #{params[:count].to_i} commits." | ||
end | ||
|
||
private | ||
|
||
def set_repos | ||
@repos = Repo.all | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing blank line after this line :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👌 |
||
|
||
def set_repo | ||
@repo = Repo.find_by(name: params[:repo_name]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- content_for(:page_header) do | ||
= t('admin.dashboard') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
- content_for(:page_header) do | ||
= @repo.name.capitalize | ||
|
||
.row | ||
.col-lg-6 | ||
- if notice.present? | ||
#notice.alert.alert-success | ||
= notice | ||
|
||
#wait_alert.alert.alert-warning.hidden | ||
= t('admin.wait_manual_run') | ||
|
||
.panel.panel-warning | ||
.panel-body | ||
= form_tag(admin_repo_run_path(@repo.name), id: 'manual_run_form') do | ||
.form-group | ||
= label_tag(t('admin.manual_run_label')) | ||
= select_tag(:count, options_for_select(ManualRunner::OPTIONS, ManualRunner::OPTIONS.last), class: 'form-control') | ||
= button_tag(t('admin.manual_run_button'), class: 'btn btn-default') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
%HTML{ lang: 'en' } | ||
%head | ||
%title RubyBench Admin | ||
|
||
= stylesheet_link_tag 'admin', 'data-turbolinks-track' => 'reload' | ||
= javascript_include_tag 'admin', 'data-turbolinks-track' => 'reload' | ||
= csrf_meta_tags | ||
|
||
%body | ||
#wrapper | ||
= render 'layouts/admin/navbar' | ||
|
||
#page-wrapper | ||
.row | ||
.col-lg-12 | ||
%h1.page-header | ||
= yield(:page_header) | ||
= yield |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
%nav.navbar.navbar-default.navbar-static-top{:role => "navigation", :style => "margin-bottom: 0"} | ||
.navbar-header | ||
%button.navbar-toggle{"data-target" => ".navbar-collapse", "data-toggle" => "collapse", :type => "button"} | ||
%span.sr-only Toggle navigation | ||
%span.icon-bar | ||
%span.icon-bar | ||
%span.icon-bar | ||
%a.navbar-brand RubyBench Admin | ||
|
||
%ul.nav.navbar-top-links.navbar-right.pull-right | ||
%li.dropdown | ||
= link_to root_path do | ||
%i.fa.fa-sign-out | ||
|
||
.navbar-default.sidebar{:role => "navigation"} | ||
.sidebar-nav.navbar-collapse | ||
%ul#side-menu.nav.in | ||
%li | ||
= link_to admin_path do | ||
%i.fa.fa-dashboard.fa-fw | ||
= t('admin.dashboard') | ||
- @repos.each do |repo| | ||
%li | ||
= link_to admin_repo_path(repo.name) do | ||
%i.fa.fa-suitcase.fa-fw | ||
= repo.name.capitalize | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require 'acceptance/test_helper' | ||
|
||
class AdminTest < AcceptanceTest | ||
test 'Admin should be able to manually run suite for existing repo' do | ||
repo = create(:repo) | ||
|
||
visit admin_repo_path(repo.name) | ||
page.has_css?('label', text: I18n.t('admin.manual_run_label')) | ||
page.has_css?('button', text: I18n.t('admin.manual_run_button')) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require 'test_helper' | ||
|
||
class ManualRunTest < ActionDispatch::IntegrationTest | ||
def test_running_commits_manually | ||
@repo = create(:repo) | ||
|
||
ManualRunner.any_instance.expects(:run_last).with(100) | ||
|
||
post(admin_repo_run_path(@repo.name), params: { count: 100 }) | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm this is alittle odd. Why do we need to precompile assets in our test env?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I encountered this problem on Travis and solved it with assets precompilation.
Error occurred most probably because of introducing admin layout with its own asset group.