From 54ae654d7c05b4de009185ac75a89813afc35a6c Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Wed, 8 Apr 2015 15:20:25 +0300 Subject: [PATCH 1/3] adding admin section --- .../admin/application_controller.rb | 2 ++ app/views/admin/builds/index.html.haml | 2 +- app/views/admin/events/index.html.haml | 7 ++++++- app/views/admin/projects/index.html.haml | 1 - app/views/admin/projects/show.html.haml | 15 +++++++------- app/views/admin/runners/show.html.haml | 20 +++++++++++-------- app/views/layouts/_nav.html.haml | 11 +--------- app/views/layouts/_nav_admin.html.haml | 18 +++++++++++++++++ app/views/layouts/admin.html.haml | 18 +++++++++++++++++ 9 files changed, 66 insertions(+), 28 deletions(-) create mode 100644 app/views/layouts/_nav_admin.html.haml create mode 100644 app/views/layouts/admin.html.haml diff --git a/app/controllers/admin/application_controller.rb b/app/controllers/admin/application_controller.rb index 83ae7eb0b..506c6e781 100644 --- a/app/controllers/admin/application_controller.rb +++ b/app/controllers/admin/application_controller.rb @@ -1,4 +1,6 @@ class Admin::ApplicationController < ApplicationController before_filter :authenticate_user! before_filter :authenticate_admin! + + layout "admin" end diff --git a/app/views/admin/builds/index.html.haml b/app/views/admin/builds/index.html.haml index 96302cbeb..5f1f48920 100644 --- a/app/views/admin/builds/index.html.haml +++ b/app/views/admin/builds/index.html.haml @@ -1,7 +1,7 @@ = content_for :title do %h3.project-title All builds - + .pull-right %small = pluralize(@builds.total_count, 'build') diff --git a/app/views/admin/events/index.html.haml b/app/views/admin/events/index.html.haml index 779f49b3d..b86eb5dd6 100644 --- a/app/views/admin/events/index.html.haml +++ b/app/views/admin/events/index.html.haml @@ -1,4 +1,9 @@ -%h3.page-title Events += content_for :title do + %h3.project-title + Events + .pull-right + %small + = pluralize(@events.total_count, 'event') %table.table %thead diff --git a/app/views/admin/projects/index.html.haml b/app/views/admin/projects/index.html.haml index 498c66ea4..3816d3ddf 100644 --- a/app/views/admin/projects/index.html.haml +++ b/app/views/admin/projects/index.html.haml @@ -1,7 +1,6 @@ = content_for :title do %h3.project-title Manage Projects - .pull-right %small = pluralize(@projects.total_count, 'project') diff --git a/app/views/admin/projects/show.html.haml b/app/views/admin/projects/show.html.haml index 54a01878c..2551afaa8 100644 --- a/app/views/admin/projects/show.html.haml +++ b/app/views/admin/projects/show.html.haml @@ -1,10 +1,11 @@ -%h4.page-title - Project: #{@project.name} - - if current_user.can_manage_project?(@project.gitlab_id) - .pull-right - = link_to project_jobs_path(@project), class: "btn btn-default btn-small" do - %i.icon-edit.icon-white - Edit Job += content_for :title do + %h3.project-title + Project: #{@project.name} + - if current_user.can_manage_project?(@project.gitlab_id) + .pull-right + = link_to project_jobs_path(@project), class: "btn btn-default btn-small" do + %i.icon-edit.icon-white + Edit Job %p = link_to admin_projects_path do diff --git a/app/views/admin/runners/show.html.haml b/app/views/admin/runners/show.html.haml index d6bd2197b..a99bd2e8c 100644 --- a/app/views/admin/runners/show.html.haml +++ b/app/views/admin/runners/show.html.haml @@ -1,11 +1,15 @@ -%h4 - - if @runner.shared? - %span.runner-state.runner-state-shared - Shared - - else - %span.runner-state.runner-state-specific - Specific - Runner ##{@runner.id} += content_for :title do + %h3.project-title + Runner ##{@runner.id} + .pull-right + - if @runner.shared? + %span.runner-state.runner-state-shared + Shared + - else + %span.runner-state.runner-state-specific + Specific + + - if @runner.shared? .bs-callout.bs-callout-success diff --git a/app/views/layouts/_nav.html.haml b/app/views/layouts/_nav.html.haml index 45dd7e1c0..7ea53b412 100644 --- a/app/views/layouts/_nav.html.haml +++ b/app/views/layouts/_nav.html.haml @@ -10,18 +10,9 @@ .collapse.navbar-collapse %ul.nav.navbar-nav - if current_user && current_user.is_admin - %li - = link_to admin_runners_path do - Runners %li = link_to admin_projects_path do - Projects - %li - = link_to admin_builds_path do - Builds - %li - = link_to admin_events_path do - Events + Admin %li = link_to 'Help', help_path diff --git a/app/views/layouts/_nav_admin.html.haml b/app/views/layouts/_nav_admin.html.haml new file mode 100644 index 000000000..c5155db23 --- /dev/null +++ b/app/views/layouts/_nav_admin.html.haml @@ -0,0 +1,18 @@ +%ul.nav.nav-pills.nav-stacked.admin-menu + = nav_link path: 'projects' do + = link_to admin_projects_path do + %i.icon-list-alt + Projects + = nav_link path: 'events' do + = link_to admin_events_path do + %i.icon-bar-chart + Events + = nav_link path: 'runners#index' do + = link_to admin_runners_path do + %i.icon-cog + Runners + = nav_link path: 'builds' do + = link_to admin_builds_path do + %i.icon-link + Builds + diff --git a/app/views/layouts/admin.html.haml b/app/views/layouts/admin.html.haml new file mode 100644 index 000000000..ec4a9e59f --- /dev/null +++ b/app/views/layouts/admin.html.haml @@ -0,0 +1,18 @@ +!!! 5 +%html{ lang: "en"} + = render 'layouts/head' + %body{ :'data-page' => body_data_page } + = render 'layouts/nav' + = render 'layouts/info' + .container + %h3 + - if content_for?(:title) + = yield(:title) + + %hr + .container + .row + .col-md-2.append-bottom-20 + = render 'layouts/nav_admin' + .col-md-10 + = yield \ No newline at end of file From cfe4d30740535fbbfc1e88c5868853302e396ee2 Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Wed, 8 Apr 2015 15:51:52 +0300 Subject: [PATCH 2/3] remove admin show page --- app/controllers/admin/projects_controller.rb | 4 - app/views/admin/projects/_project.html.haml | 2 +- app/views/admin/projects/show.html.haml | 87 -------------------- spec/features/admin/projects_spec.rb | 9 -- 4 files changed, 1 insertion(+), 101 deletions(-) delete mode 100644 app/views/admin/projects/show.html.haml diff --git a/app/controllers/admin/projects_controller.rb b/app/controllers/admin/projects_controller.rb index 3b4e9ba9e..6892776b8 100644 --- a/app/controllers/admin/projects_controller.rb +++ b/app/controllers/admin/projects_controller.rb @@ -3,10 +3,6 @@ def index @projects = Project.ordered_by_last_commit_date.page(params[:page]).per(30) end - def show - project - end - def destroy project.destroy diff --git a/app/views/admin/projects/_project.html.haml b/app/views/admin/projects/_project.html.haml index 4952b6073..8da5e0a5b 100644 --- a/app/views/admin/projects/_project.html.haml +++ b/app/views/admin/projects/_project.html.haml @@ -3,7 +3,7 @@ %td = project.id %td - = link_to [:admin, project] do + = link_to project do %strong= project.name %td - if last_commit diff --git a/app/views/admin/projects/show.html.haml b/app/views/admin/projects/show.html.haml deleted file mode 100644 index 2551afaa8..000000000 --- a/app/views/admin/projects/show.html.haml +++ /dev/null @@ -1,87 +0,0 @@ -= content_for :title do - %h3.project-title - Project: #{@project.name} - - if current_user.can_manage_project?(@project.gitlab_id) - .pull-right - = link_to project_jobs_path(@project), class: "btn btn-default btn-small" do - %i.icon-edit.icon-white - Edit Job - -%p - = link_to admin_projects_path do - ← Back to projects list -%hr -.row - .col-md-6 - %fieldset - %legend Project info - %p - ID: - %strong= @project.id - %p - Name: - %strong= @project.name - %p - Build timeout: - %strong= @project.timeout - %p - GitLab ID: - %strong= @project.gitlab_id - %p - Created at: - %strong= @project.created_at - %p - Token: - %strong= @project.token - %p - Public: - %strong= @project.public - %p - Last build: - - if @project.last_commit_date - = time_ago_in_words @project.last_commit_date - %br - %fieldset - %legend Email notification - %p - Repicients: - %strong= @project.email_recipients - %p - Send mail to commiter: - %strong= @project.email_add_pusher - %p - Send on all broken builds: - %strong= @project.email_only_broken_builds - - .col-md-6 - - @project.jobs.active.each do |job| - %fieldset - %legend - Build script for #{job.name} - = preserve do - %pre - = job.commands - - %br - %fieldset - %legend Builds stats - %p - Total: - %strong= pluralize @project.builds.count(:all), 'build' - %p - Successful: - %strong= pluralize @project.builds.success.count(:all), 'build' - %p - Failed: - %strong= pluralize @project.builds.failed.count(:all), 'build' - - %p - Success ratio: - %strong - #{success_ratio(@project.builds.success, @project.builds.failed)}% - - %p - Commits covered: - %strong - = @project.commits.count - diff --git a/spec/features/admin/projects_spec.rb b/spec/features/admin/projects_spec.rb index 0c8168aef..a6adae2a5 100644 --- a/spec/features/admin/projects_spec.rb +++ b/spec/features/admin/projects_spec.rb @@ -16,13 +16,4 @@ it { page.should have_content "Manage Projects" } end - - describe "GET /admin/projects/:id" do - before do - visit admin_project_path(project) - end - - it { page.should have_content "Project info" } - it { page.should have_content project.name } - end end From e1748f0229c3fa56b7b186b547733a959ee7d1f9 Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Wed, 8 Apr 2015 16:01:09 +0300 Subject: [PATCH 3/3] update changelog --- CHANGELOG | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index a1da52682..aacb65941 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,7 @@ v7.10.0 - Events for admin - Events per projects - Search for runners in admin area + - UI improvements: created separated admin section, removed useless project show page v7.9.3 - Contains no changes @@ -186,4 +187,4 @@ v1.2.0 v1.1.0 - Added JSON response for builds status - - Compatible with GitLab v4.0.0 \ No newline at end of file + - Compatible with GitLab v4.0.0