From 0ae9ac155c2d6d91060e0b0a3d528681aeb0dfe2 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 30 Dec 2011 22:56:13 +0200 Subject: [PATCH 1/3] repo tab added. activities page for repo --- app/controllers/repositories_controller.rb | 14 ++++++++++++++ app/helpers/projects_helper.rb | 6 ++++++ app/views/layouts/project.html.haml | 1 + app/views/repositories/_head.html.haml | 19 +++++++++++++++++++ app/views/repositories/show.html.haml | 7 +++++++ config/routes.rb | 2 ++ 6 files changed, 49 insertions(+) create mode 100644 app/controllers/repositories_controller.rb create mode 100644 app/views/repositories/_head.html.haml create mode 100644 app/views/repositories/show.html.haml diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb new file mode 100644 index 00000000..8e1fc74d --- /dev/null +++ b/app/controllers/repositories_controller.rb @@ -0,0 +1,14 @@ +class RepositoriesController < ApplicationController + before_filter :project + + # Authorize + before_filter :add_project_abilities + before_filter :authorize_read_project! + before_filter :require_non_empty_project + + layout "project" + + def show + @activities = @project.fresh_commits(20) + end +end diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index cc1d69d4..902d2780 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -33,4 +33,10 @@ module ProjectsHelper :project_id => @project, :id => @ref || @project.root_ref ) ? "current" : nil end + + def repository_tab_class + if controller.controller_name == "repositories" + "current" + end + end end diff --git a/app/views/layouts/project.html.haml b/app/views/layouts/project.html.haml index 1c9b5884..5545cc2f 100644 --- a/app/views/layouts/project.html.haml +++ b/app/views/layouts/project.html.haml @@ -24,6 +24,7 @@ .fixed %aside = link_to "Project", project_path(@project), :class => project_tab_class + = link_to "Repository", project_repository_path(@project), :class => repository_tab_class = link_to "Tree", tree_project_ref_path(@project, @project.root_ref), :class => tree_tab_class = link_to "Commits", project_commits_path(@project), :class => current_page?(:controller => "commits", :action => "index", :project_id => @project) ? "current" : nil = link_to "Network graph", graph_project_path(@project), :class => current_page?(:controller => "projects", :action => "graph", :id => @project) ? "current" : nil diff --git a/app/views/repositories/_head.html.haml b/app/views/repositories/_head.html.haml new file mode 100644 index 00000000..7c5ae8da --- /dev/null +++ b/app/views/repositories/_head.html.haml @@ -0,0 +1,19 @@ +.merge-tabs.repository + = link_to project_repository_path(@project), :class => "tab #{'active' if current_page?(project_repository_path(@project)) }" do + %span + Activities + = link_to "#", :class => "tab" do + %span + Branches + = link_to "#", :class => "tab" do + %span + Tags + = link_to "#", :class => "tab" do + %span + Hooks + = link_to "#", :class => "tab" do + %span + Deploy Keys + + + diff --git a/app/views/repositories/show.html.haml b/app/views/repositories/show.html.haml new file mode 100644 index 00000000..494f82b9 --- /dev/null +++ b/app/views/repositories/show.html.haml @@ -0,0 +1,7 @@ +- content_for(:body_class, "project-page dashboard") += render "head" + +#news-feed.news-feed + .project-box.project-updates.ui-box.ui-box-small.ui-box-big + - @activities.each do |update| + = render "projects/feed", :update => update, :project => @project diff --git a/config/routes.rb b/config/routes.rb index 58880966..9e5e15a3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -46,6 +46,8 @@ Gitlab::Application.routes.draw do get "files" end + resource :repository + resources :refs, :only => [], :path => "/" do collection do get "switch" From d8247012b5dd7578a5d9f9922352c7f373d89af4 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 31 Dec 2011 12:52:01 +0200 Subject: [PATCH 2/3] repositories tab specs --- app/views/repositories/_head.html.haml | 2 +- db/schema.rb | 12 +++++++++ spec/requests/repositories_spec.rb | 35 ++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 spec/requests/repositories_spec.rb diff --git a/app/views/repositories/_head.html.haml b/app/views/repositories/_head.html.haml index 7c5ae8da..7cf8c20d 100644 --- a/app/views/repositories/_head.html.haml +++ b/app/views/repositories/_head.html.haml @@ -1,5 +1,5 @@ .merge-tabs.repository - = link_to project_repository_path(@project), :class => "tab #{'active' if current_page?(project_repository_path(@project)) }" do + = link_to project_repository_path(@project), :class => "activities-tab tab #{'active' if current_page?(project_repository_path(@project)) }" do %span Activities = link_to "#", :class => "tab" do diff --git a/db/schema.rb b/db/schema.rb index 3014579c..7f3264cc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -13,6 +13,18 @@ ActiveRecord::Schema.define(:version => 20111220190817) do + create_table "features", :force => true do |t| + t.string "name" + t.string "branch_name" + t.integer "assignee_id" + t.integer "author_id" + t.integer "project_id" + t.datetime "created_at" + t.datetime "updated_at" + t.string "version" + t.integer "status", :default => 0, :null => false + end + create_table "issues", :force => true do |t| t.string "title" t.integer "assignee_id" diff --git a/spec/requests/repositories_spec.rb b/spec/requests/repositories_spec.rb new file mode 100644 index 00000000..92933b40 --- /dev/null +++ b/spec/requests/repositories_spec.rb @@ -0,0 +1,35 @@ +require 'spec_helper' + +describe "Repository" do + + before do + @user = Factory :user + @project = Factory :project + @project.add_access(@user, :read, :write) + login_with @user + end + + describe "GET /:project_name/repository" do + before do + visit project_repository_path(@project) + end + + it "should be on projects page" do + current_path.should == project_repository_path(@project) + end + + it "should have link to repo activities" do + page.should have_content("Activities") + end + + it "should have link to last commit for activities tab" do + page.should have_content(@project.commit.safe_message[0..20]) + page.should have_content(@project.commit.author_name) + end + + it "should show commits list" do + page.all(:css, ".project-update").size.should == 20 + end + end +end + From a667c713128b3dd8dece604e4aae3519ab7e57ed Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 31 Dec 2011 13:12:10 +0200 Subject: [PATCH 3/3] repo branches and tags --- app/assets/stylesheets/projects.css.scss | 1 + app/controllers/repositories_controller.rb | 8 ++++++++ app/views/repositories/_head.html.haml | 8 ++++---- app/views/repositories/branches.html.haml | 10 ++++++++++ app/views/repositories/tags.html.haml | 10 ++++++++++ config/routes.rb | 7 ++++++- spec/requests/repositories_spec.rb | 23 ++++++++++++++++++++++ 7 files changed, 62 insertions(+), 5 deletions(-) create mode 100644 app/views/repositories/branches.html.haml create mode 100644 app/views/repositories/tags.html.haml diff --git a/app/assets/stylesheets/projects.css.scss b/app/assets/stylesheets/projects.css.scss index 6916d65c..316ef033 100644 --- a/app/assets/stylesheets/projects.css.scss +++ b/app/assets/stylesheets/projects.css.scss @@ -598,6 +598,7 @@ h4.middle-panel { } } } +.merge-tabs.repository .tab span{ background: url("images.png") no-repeat -38px -77px; } .activities-tab span { background: url("images.png") no-repeat -161px -1px; } .stat-tab span, .team-tab span, diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 8e1fc74d..9a112f46 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -11,4 +11,12 @@ class RepositoriesController < ApplicationController def show @activities = @project.fresh_commits(20) end + + def branches + @branches = @project.repo.heads.sort_by(&:name) + end + + def tags + @tags = @project.repo.tags.sort_by(&:name).reverse + end end diff --git a/app/views/repositories/_head.html.haml b/app/views/repositories/_head.html.haml index 7cf8c20d..c22286ec 100644 --- a/app/views/repositories/_head.html.haml +++ b/app/views/repositories/_head.html.haml @@ -2,16 +2,16 @@ = link_to project_repository_path(@project), :class => "activities-tab tab #{'active' if current_page?(project_repository_path(@project)) }" do %span Activities - = link_to "#", :class => "tab" do + = link_to branches_project_repository_path(@project), :class => "tab #{'active' if current_page?(branches_project_repository_path(@project)) }" do %span Branches - = link_to "#", :class => "tab" do + = link_to tags_project_repository_path(@project), :class => "tab #{'active' if current_page?(tags_project_repository_path(@project)) }" do %span Tags - = link_to "#", :class => "tab" do + -#= link_to "#", :class => "tab" do %span Hooks - = link_to "#", :class => "tab" do + -#= link_to "#", :class => "tab" do %span Deploy Keys diff --git a/app/views/repositories/branches.html.haml b/app/views/repositories/branches.html.haml new file mode 100644 index 00000000..3a63e761 --- /dev/null +++ b/app/views/repositories/branches.html.haml @@ -0,0 +1,10 @@ += render "head" +- unless @branches.empty? + %div.update-data.ui-box.ui-box-small + .data + - @branches.each do |branch| + %a.update-item{:href => project_commits_path(@project, :ref => branch.name)} + %span.update-title{:style => "margin-bottom:0px;"} + = branch.name +- else + %h3 No brances diff --git a/app/views/repositories/tags.html.haml b/app/views/repositories/tags.html.haml new file mode 100644 index 00000000..6c8e377a --- /dev/null +++ b/app/views/repositories/tags.html.haml @@ -0,0 +1,10 @@ += render "head" +- unless @tags.empty? + %div.update-data.ui-box.ui-box-small + .data + - @tags.each do |tag| + %a.update-item{:href => project_commits_path(@project, :ref => tag.name)} + %span.update-title{:style => "margin-bottom:0px;"} + = tag.name +- else + %h3 No tags diff --git a/config/routes.rb b/config/routes.rb index 9e5e15a3..90b391cd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -46,7 +46,12 @@ Gitlab::Application.routes.draw do get "files" end - resource :repository + resource :repository do + member do + get "branches" + get "tags" + end + end resources :refs, :only => [], :path => "/" do collection do diff --git a/spec/requests/repositories_spec.rb b/spec/requests/repositories_spec.rb index 92933b40..8c3ebf18 100644 --- a/spec/requests/repositories_spec.rb +++ b/spec/requests/repositories_spec.rb @@ -31,5 +31,28 @@ describe "Repository" do page.all(:css, ".project-update").size.should == 20 end end + + describe "GET /:project_name/repository/branches" do + before do + visit branches_project_repository_path(@project) + end + + it "should have link to repo activities" do + page.should have_content("Branches") + page.should have_content("master") + end + end + + # TODO: Add new repo to seeds with tags list + describe "GET /:project_name/repository/tags" do + before do + visit tags_project_repository_path(@project) + end + + it "should have link to repo activities" do + page.should have_content("Tags") + page.should have_content("No tags") + end + end end