Commit dac7c44ab357d703381c2beafd2e04996794fa45
1 parent
37224dc9
Exists in
master
and in
4 other branches
Updated readme, Roles in progress
Showing
15 changed files
with
164 additions
and
66 deletions
Show diff stats
app/assets/images/help_commit.png
95.7 KB
app/assets/images/help_merge_request.png
54.5 KB
app/assets/stylesheets/common.scss
... | ... | @@ -6,6 +6,10 @@ a { |
6 | 6 | } |
7 | 7 | } |
8 | 8 | |
9 | +.vlink { | |
10 | + color: $link_color !important; | |
11 | +} | |
12 | + | |
9 | 13 | .pills .active a { |
10 | 14 | background-color: #474D57; |
11 | 15 | } |
... | ... | @@ -27,6 +31,7 @@ a { |
27 | 31 | .cgray { color:gray; } |
28 | 32 | .cred { color:#D12F19; } |
29 | 33 | .cgreen { color:#44aa22; } |
34 | +.cblack { color:#111; } | |
30 | 35 | |
31 | 36 | /** COMMON STYLES **/ |
32 | 37 | .left { |
... | ... | @@ -259,3 +264,5 @@ img.lil_av { |
259 | 264 | } |
260 | 265 | |
261 | 266 | } |
267 | + | |
268 | +.help li { color:#111 } | ... | ... |
app/controllers/protected_branches_controller.rb
... | ... | @@ -6,6 +6,8 @@ class ProtectedBranchesController < ApplicationController |
6 | 6 | before_filter :authorize_read_project! |
7 | 7 | before_filter :require_non_empty_project |
8 | 8 | |
9 | + before_filter :authorize_admin_project!, :only => [:destroy, :create] | |
10 | + | |
9 | 11 | layout "project" |
10 | 12 | |
11 | 13 | def index |
... | ... | @@ -19,5 +21,11 @@ class ProtectedBranchesController < ApplicationController |
19 | 21 | end |
20 | 22 | |
21 | 23 | def destroy |
24 | + @project.protected_branches.find(params[:id]).destroy | |
25 | + | |
26 | + respond_to do |format| | |
27 | + format.html { redirect_to project_protected_branches_path } | |
28 | + format.js { render :nothing => true } | |
29 | + end | |
22 | 30 | end |
23 | 31 | end | ... | ... |
app/helpers/projects_helper.rb
... | ... | @@ -34,7 +34,9 @@ module ProjectsHelper |
34 | 34 | |
35 | 35 | def repository_tab_class |
36 | 36 | if controller.controller_name == "repositories" || |
37 | - controller.controller_name == "hooks" | |
37 | + controller.controller_name == "hooks" || | |
38 | + controller.controller_name == "protected_branches" || | |
39 | + controller.controller_name == "deploy_keys" | |
38 | 40 | "current" |
39 | 41 | end |
40 | 42 | end | ... | ... |
app/models/users_project.rb
1 | 1 | class UsersProject < ActiveRecord::Base |
2 | + REPORTER = 21 | |
3 | + DEVELOPER = 22 | |
4 | + MASTER = 33 | |
5 | + | |
2 | 6 | belongs_to :user |
3 | 7 | belongs_to :project |
4 | 8 | |
... | ... | @@ -41,6 +45,18 @@ class UsersProject < ActiveRecord::Base |
41 | 45 | end |
42 | 46 | end |
43 | 47 | |
48 | + def self.access_roles | |
49 | + { | |
50 | + "Reporter" => REPORTER, | |
51 | + "Developer" => DEVELOPER, | |
52 | + "Master" => MASTER | |
53 | + } | |
54 | + end | |
55 | + | |
56 | + def role_access | |
57 | + "#{project_access}#{repo_access}" | |
58 | + end | |
59 | + | |
44 | 60 | def update_repository |
45 | 61 | Gitlabhq::GitHost.system.new.configure do |c| |
46 | 62 | c.update_project(project.path, project) | ... | ... |
app/views/help/index.html.haml
1 | -- bash_lexer = Pygments::Lexer[:bash] | |
2 | -%div.help_content | |
3 | - %h2 | |
4 | - Gitlabhq | |
5 | - %span.right v2.1 | |
6 | - %hr | |
7 | - %h3 Self Hosted Git Management | |
8 | - %h3 Fast, secure and stable solution based on Ruby on Rails & Gitolite. | |
1 | +%h3 | |
2 | + Gitlabhq | |
3 | + %span.right v2.2 | |
4 | +%hr | |
5 | +%h4 Self Hosted Git Management | |
6 | +%h4 Fast, secure and stable solution based on Ruby on Rails & Gitolite. | |
9 | 7 | |
10 | - %hr | |
8 | +%hr | |
11 | 9 | |
12 | - .menu | |
13 | - %h3= link_to "Workflow", "#", :class => "active" | |
10 | +%h3 Help | |
14 | 11 | |
15 | - .content | |
16 | - %h3 Clone project | |
17 | - .bash | |
18 | - %pre | |
19 | - git clone git@example.com:project-name.git | |
12 | +%ol | |
13 | + %li | |
14 | + = link_to "Workflow", help_workflow_path | |
20 | 15 | |
21 | - %h3 Create branch with your feature | |
22 | - .bash | |
23 | - %pre | |
24 | - git checkout -b $feature_name | |
25 | - | |
26 | - %h3 Write code. Commit changes | |
27 | - .bash | |
28 | - %pre | |
29 | - git commit -am "My feature is ready" | |
30 | - | |
31 | - %h3 Push your branch to gitlabhq | |
32 | - .bash | |
33 | - %pre | |
34 | - git push origin $feature_name | |
35 | - | |
36 | - %h3 Review your code | |
37 | - .bash= image_tag "help_commit.png", :width => 600 | |
38 | - | |
39 | - | |
40 | - %h3 Open a merge request | |
41 | - .bash= image_tag "help_merge_request.png", :width => 600 | |
42 | - | |
43 | - %h3 Your team lead will review code & merge it to main branch | |
16 | + %li | |
17 | + = link_to "Permissions", help_permissions_path | ... | ... |
... | ... | @@ -0,0 +1,27 @@ |
1 | +%h3 Permissions | |
2 | +%hr | |
3 | + | |
4 | +%h4 Reporter | |
5 | +%ul | |
6 | + %li Pull project code | |
7 | + %li Create new issue | |
8 | + %li Create new merge request | |
9 | + %li Write on project wall | |
10 | + | |
11 | + | |
12 | +%h4 Developer | |
13 | +%ul | |
14 | + %li Pull project code | |
15 | + %li Create new branches | |
16 | + %li Push to non-protected branches | |
17 | + %li Remove non-protected branches | |
18 | + %li Add tags | |
19 | + %li Create new issue | |
20 | + %li Create new merge request | |
21 | + %li Write on project wall | |
22 | + | |
23 | +%h4 Master | |
24 | +%ul | |
25 | + %li Full repository access | |
26 | + %li Full project access | |
27 | + %li Add new team members | ... | ... |
... | ... | @@ -0,0 +1,38 @@ |
1 | +- bash_lexer = Pygments::Lexer[:bash] | |
2 | +%h3 Workflow | |
3 | +%hr | |
4 | + | |
5 | +%ol.help | |
6 | + %li | |
7 | + %p Clone project | |
8 | + .bash | |
9 | + %pre | |
10 | + git clone git@example.com:project-name.git | |
11 | + | |
12 | + %li | |
13 | + %p Create branch with your feature | |
14 | + .bash | |
15 | + %pre | |
16 | + git checkout -b $feature_name | |
17 | + | |
18 | + %li | |
19 | + %p Write code. Commit changes | |
20 | + .bash | |
21 | + %pre | |
22 | + git commit -am "My feature is ready" | |
23 | + | |
24 | + %li | |
25 | + %p Push your branch to gitlabhq | |
26 | + .bash | |
27 | + %pre | |
28 | + git push origin $feature_name | |
29 | + | |
30 | + %li | |
31 | + %p Review your code on Commits page | |
32 | + | |
33 | + %li | |
34 | + %p Create a merge request | |
35 | + | |
36 | + %li | |
37 | + %p Your team lead will review code & merge it to main branch | |
38 | + | ... | ... |
app/views/projects/team.html.haml
... | ... | @@ -4,9 +4,9 @@ |
4 | 4 | .alert-message.block-message |
5 | 5 | = link_to new_project_team_member_path(@project), :class => "btn small right", :title => "New Team Member" do |
6 | 6 | New Team Member |
7 | - Manage project team from this page. | |
8 | - %br | |
9 | - To open team member profile - click on avatar. | |
7 | + %p Ream more about project permissions #{link_to "here", help_permissions_path, :class => "vlink"} | |
8 | + %p To open team member profile - click on avatar. | |
9 | + | |
10 | 10 | |
11 | 11 | = render :partial => "team", :locals => {:project => @project} |
12 | 12 | ... | ... |
app/views/protected_branches/index.html.haml
1 | 1 | = render "repositories/branches_head" |
2 | 2 | |
3 | -= form_for [@project, @protected_branch] do |f| | |
4 | - -if @protected_branch.errors.any? | |
5 | - .alert-message.block-message.error | |
6 | - %ul | |
7 | - - @protected_branch.errors.full_messages.each do |msg| | |
8 | - %li= msg | |
3 | +.alert-message.block-message | |
4 | + %p Protected branches designed to prevent push for all except #{link_to "masters", help_permissions_path, :class => "vlink"}. | |
5 | + %p This ability allows: | |
6 | + %ul | |
7 | + %li keep stable branches secured | |
8 | + %li forced code review before merge to protected branches | |
9 | + %p Ream more about project permissions #{link_to "here", help_permissions_path, :class => "vlink"} | |
9 | 10 | |
10 | - .clearfix | |
11 | - = f.label :name | |
12 | - .input= f.select(:name, @project.open_branches.map { |br| [br.name, br.name] } , { :include_blank => "Select branch" }, { :style => "width:300px" }) | |
13 | - .actions | |
14 | - = f.submit 'Add', :class => "primary btn" | |
15 | 11 | |
16 | 12 | |
17 | 13 | - unless @branches.empty? |
18 | - %table | |
14 | + %table.zebra-striped | |
19 | 15 | %thead |
20 | 16 | %tr |
21 | 17 | %th Name |
22 | 18 | %th Last commit |
19 | + %th | |
23 | 20 | %tbody |
24 | 21 | - @branches.each do |branch| |
25 | 22 | %tr |
... | ... | @@ -33,6 +30,25 @@ |
33 | 30 | = truncate branch.commit.id.to_s, :length => 10 |
34 | 31 | = time_ago_in_words(branch.commit.committed_date) |
35 | 32 | ago |
33 | + %td | |
34 | + - if can? current_user, :admin_project, @project | |
35 | + = link_to 'Unprotect', [@project, branch], :confirm => 'Are you sure?', :method => :delete, :class => "danger btn small" | |
36 | + | |
37 | + | |
38 | + | |
39 | +- if can? current_user, :admin_project, @project | |
40 | + = form_for [@project, @protected_branch] do |f| | |
41 | + -if @protected_branch.errors.any? | |
42 | + .alert-message.block-message.error | |
43 | + %ul | |
44 | + - @protected_branch.errors.full_messages.each do |msg| | |
45 | + %li= msg | |
46 | + | |
47 | + .clearfix | |
48 | + = f.label :name | |
49 | + .input= f.select(:name, @project.open_branches.map { |br| [br.name, br.name] } , { :include_blank => "Select branch" }, { :style => "width:300px" }) | |
50 | + .actions | |
51 | + = f.submit 'Add', :class => "primary btn" | |
36 | 52 | |
37 | 53 | |
38 | 54 | :javascript | ... | ... |
app/views/repositories/_branches_head.html.haml
app/views/team_members/_form.html.haml
... | ... | @@ -11,13 +11,20 @@ |
11 | 11 | = f.label :user_id, "Name" |
12 | 12 | .input= f.select(:user_id, User.not_in_project(@project).all.collect {|p| [ p.name, p.id ] }, { :include_blank => "Select user" }, { :style => "width:300px" }) |
13 | 13 | |
14 | + | |
14 | 15 | .clearfix |
15 | 16 | = f.label :project_access, "Project Access" |
16 | - .input= f.select :project_access, options_for_select(Project.access_options, @team_member.project_access), {}, :class => "project-access-select" | |
17 | + .input= f.select :_project_access, options_for_select(UsersProject.access_roles, @team_member.role_access), {}, :class => "project-access-select" | |
18 | + | |
17 | 19 | |
18 | - .clearfix | |
19 | - = f.label :repo_access, "Repository Access" | |
20 | - .input= f.select :repo_access, options_for_select(Repository.access_options, @team_member.repo_access), {}, :class => "repo-access-select" | |
20 | + | |
21 | + -#.clearfix | |
22 | + -#= f.label :project_access, "Project Access" | |
23 | + -#.input= f.select :project_access, options_for_select(Project.access_options, @team_member.project_access), {}, :class => "project-access-select" | |
24 | + | |
25 | + -#.clearfix | |
26 | + -#= f.label :repo_access, "Repository Access" | |
27 | + -#.input= f.select :repo_access, options_for_select(Repository.access_options, @team_member.repo_access), {}, :class => "repo-access-select" | |
21 | 28 | |
22 | 29 | .actions |
23 | 30 | = f.submit 'Save', :class => "btn primary" |
... | ... | @@ -30,5 +37,6 @@ |
30 | 37 | |
31 | 38 | :javascript |
32 | 39 | $('select#team_member_user_id').chosen(); |
33 | - $('select#team_member_repo_access').chosen(); | |
34 | - $('select#team_member_project_access').chosen(); | |
40 | + $('select#team_member__project_access').chosen(); | |
41 | + //$('select#team_member_repo_access').chosen(); | |
42 | + //$('select#team_member_project_access').chosen(); | ... | ... |
app/views/team_members/_show.html.haml
... | ... | @@ -11,9 +11,9 @@ |
11 | 11 | |
12 | 12 | .span3 |
13 | 13 | = form_for(member, :as => :team_member, :url => project_team_member_path(@project, member)) do |f| |
14 | - = f.select :project_access, options_for_select(Project.access_options, member.project_access), {}, :class => "medium project-access-select", :disabled => !allow_admin | |
15 | - .span3 | |
16 | - = form_for(member, :as => :team_member, :url => project_team_member_path(@project, member)) do |f| | |
17 | - = f.select :repo_access, options_for_select(Repository.access_options, member.repo_access), {}, :class => "medium repo-access-select", :disabled => !allow_admin | |
14 | + = f.select :_project_access, options_for_select(UsersProject.access_roles, member.role_access), {}, :class => "medium project-access-select", :disabled => !allow_admin | |
15 | + -#.span3 | |
16 | + -#= form_for(member, :as => :team_member, :url => project_team_member_path(@project, member)) do |f| | |
17 | + -#= f.select :repo_access, options_for_select(Repository.access_options, member.repo_access), {}, :class => "medium repo-access-select", :disabled => !allow_admin | |
18 | 18 | - if @project.owner == user |
19 | 19 | %span.label Project Owner | ... | ... |
config/routes.rb