From eb3e07a509d360922ff52c3634be7770104b0994 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 30 Nov 2012 18:26:17 +0200 Subject: [PATCH] Use project owner if no namespace. Restyled team page --- app/assets/stylesheets/sections/projects.scss | 1 + app/models/ability.rb | 21 +++++---- app/models/project.rb | 4 ++ app/views/admin/projects/_form.html.haml | 4 -- app/views/admin/projects/show.html.haml | 11 ++++- app/views/groups/people.html.haml | 8 +--- app/views/layouts/project_resource.html.haml | 3 +- app/views/projects/empty.html.haml | 47 ++++++++++--------- app/views/shared/_clone_panel.html.haml | 2 +- app/views/team_members/_show.html.haml | 46 +++++++++--------- app/views/team_members/_team.html.haml | 12 ++--- app/views/team_members/index.html.haml | 14 +++--- app/views/tree/_head.html.haml | 2 +- 13 files changed, 96 insertions(+), 79 deletions(-) diff --git a/app/assets/stylesheets/sections/projects.scss b/app/assets/stylesheets/sections/projects.scss index c592f87c..452fbc2b 100644 --- a/app/assets/stylesheets/sections/projects.scss +++ b/app/assets/stylesheets/sections/projects.scss @@ -94,6 +94,7 @@ } input[type="text"] { + @extend .monospace; border: 1px solid #BBB; box-shadow: none; margin-left: -1px; diff --git a/app/models/ability.rb b/app/models/ability.rb index 96d3ac6d..b09899f1 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -18,7 +18,7 @@ class Ability # Rules based on role in project if project.master_access_for?(user) # TODO: replace with master rules. - # Only allow project administration for owners + # Only allow project administration for namespace owners rules << project_admin_rules elsif project.dev_access_for?(user) @@ -31,15 +31,20 @@ class Ability rules << project_guest_rules end - # If user own project namespace (Ex. group owner or account owner) - if project.namespace && project.namespace.owner == user - rules << project_admin_rules + if project.namespace + # If user own project namespace + # (Ex. group owner or account owner) + if project.namespace.owner == user + rules << project_admin_rules + end + else + # For compatibility with global projects + # use projects.owner_id + if project.owner == user + rules << project_admin_rules + end end - # If user was set as direct project owner - if project.owner == user - rules << project_admin_rules - end rules.flatten end diff --git a/app/models/project.rb b/app/models/project.rb index 898f0267..74d981f2 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -292,4 +292,8 @@ class Project < ActiveRecord::Base merge_requests end end + + def namespace_owner + namespace.try(:owner) + end end diff --git a/app/views/admin/projects/_form.html.haml b/app/views/admin/projects/_form.html.haml index 110ff04a..e515c68c 100644 --- a/app/views/admin/projects/_form.html.haml +++ b/app/views/admin/projects/_form.html.haml @@ -24,10 +24,6 @@ = f.label :namespace_id .input= f.select :namespace_id, namespaces_options(@project.namespace_id), {}, {class: 'chosen'} - .clearfix - = f.label :owner_id - .input= f.select :owner_id, User.all.map { |user| [user.name, user.id] }, {}, {class: 'chosen'} - - if project.repo_exists? .clearfix = f.label :default_branch, "Default Branch" diff --git a/app/views/admin/projects/show.html.haml b/app/views/admin/projects/show.html.haml index 3691f7bd..47185308 100644 --- a/app/views/admin/projects/show.html.haml +++ b/app/views/admin/projects/show.html.haml @@ -25,6 +25,15 @@ Name: %td = @project.name + %tr + %td + %b + Namespace: + %td + - if @project.namespace + = @project.namespace.human_name + - else + Global %tr %td %b @@ -34,7 +43,7 @@ %tr %td %b - Owner: + Created by: %td = @project.owner_name || '(deleted)' %tr diff --git a/app/views/groups/people.html.haml b/app/views/groups/people.html.haml index c43b0d41..68102b6a 100644 --- a/app/views/groups/people.html.haml +++ b/app/views/groups/people.html.haml @@ -15,10 +15,6 @@ = image_tag gravatar_icon(user.email, 16), class: "avatar s16" %strong= user.name %span.cgray= user.email - - if @project - - if @project.owner == user - %span.btn.btn-small.disabled.right Project Owner - - else - - if @group.owner == user - %span.btn.btn-small.disabled.right Group Owner + - if @group.owner == user + %span.btn.btn-small.disabled.right Group Owner diff --git a/app/views/layouts/project_resource.html.haml b/app/views/layouts/project_resource.html.haml index b52ef574..ab8e88c0 100644 --- a/app/views/layouts/project_resource.html.haml +++ b/app/views/layouts/project_resource.html.haml @@ -4,7 +4,8 @@ %body{class: "#{app_theme} project"} = render "layouts/flash" = render "layouts/head_panel", title: @project.name - = render 'shared/no_ssh' + - if can?(current_user, :download_code, @project) + = render 'shared/no_ssh' .container %ul.main_menu = nav_link(html_options: {class: "home #{project_tab_class}"}) do diff --git a/app/views/projects/empty.html.haml b/app/views/projects/empty.html.haml index c0b2a8e6..f331ae7f 100644 --- a/app/views/projects/empty.html.haml +++ b/app/views/projects/empty.html.haml @@ -1,30 +1,33 @@ = render 'clone_panel' %div.git-empty - %h4 Git global setup: - %pre.dark - = preserve do - git config --global user.name "#{current_user.name}" - git config --global user.email "#{current_user.email}" + %fieldset + %legend Git global setup: + %pre.dark + = preserve do + git config --global user.name "#{current_user.name}" + git config --global user.email "#{current_user.email}" - %h4.prepend-top-20 Create Repository - %pre.dark - = preserve do - mkdir #{@project.path} - cd #{@project.path} - git init - touch README - git add README - git commit -m 'first commit' - git remote add origin #{@project.url_to_repo} - git push -u origin master + %fieldset + %legend Create Repository + %pre.dark + = preserve do + mkdir #{@project.path} + cd #{@project.path} + git init + touch README + git add README + git commit -m 'first commit' + git remote add origin #{@project.url_to_repo} + git push -u origin master - %h4.prepend-top-20 Existing Git Repo? - %pre.dark - = preserve do - cd existing_git_repo - git remote add origin #{@project.url_to_repo} - git push -u origin master + %fieldset + %legend Existing Git Repo? + %pre.dark + = preserve do + cd existing_git_repo + git remote add origin #{@project.url_to_repo} + git push -u origin master - if can? current_user, :admin_project, @project .prepend-top-20 diff --git a/app/views/shared/_clone_panel.html.haml b/app/views/shared/_clone_panel.html.haml index 924eb3fc..f632e122 100644 --- a/app/views/shared/_clone_panel.html.haml +++ b/app/views/shared/_clone_panel.html.haml @@ -1,4 +1,4 @@ .input-prepend.project_clone_holder %button{class: "btn active", :"data-clone" => @project.ssh_url_to_repo} SSH %button{class: "btn", :"data-clone" => @project.http_url_to_repo}= Gitlab.config.web_protocol.upcase - = text_field_tag :project_clone, @project.url_to_repo, class: "one_click_select span5" + = text_field_tag :project_clone, @project.url_to_repo, class: "one_click_select input-xxlarge" diff --git a/app/views/team_members/_show.html.haml b/app/views/team_members/_show.html.haml index f68f8eb4..8938c7d8 100644 --- a/app/views/team_members/_show.html.haml +++ b/app/views/team_members/_show.html.haml @@ -1,26 +1,28 @@ - user = member.user - allow_admin = can? current_user, :admin_project, @project -%tr{id: dom_id(member), class: "team_member_row user_#{user.id}"} - %td.span6 - = link_to project_team_member_path(@project, member), title: user.name, class: "dark" do - = image_tag gravatar_icon(user.email, 40), class: "avatar s32" - = link_to project_team_member_path(@project, member), title: user.name, class: "dark" do - %strong= truncate(user.name, lenght: 40) - %br - %small.cgray= user.email +%li.wll{id: dom_id(member), class: "team_member_row user_#{user.id}"} + .row + .span6 + = link_to project_team_member_path(@project, member), title: user.name, class: "dark" do + = image_tag gravatar_icon(user.email, 40), class: "avatar s32" + = link_to project_team_member_path(@project, member), title: user.name, class: "dark" do + %strong= truncate(user.name, lenght: 40) + %br + %small.cgray= user.email - %td.span5 - .right - - if current_user == user - %span.btn.disabled This is you! - - if @project.owner == user - %span.btn.disabled.success Owner - - elsif user.blocked - %span.btn.disabled.blocked Blocked - - elsif allow_admin - = link_to project_team_member_path(project_id: @project, id: member.id), confirm: remove_from_team_message(@project, member), method: :delete, class: "very_small btn danger" do - %i.icon-minus.icon-white + .span5.right + - if allow_admin + .left + = form_for(member, as: :team_member, url: project_team_member_path(@project, member)) do |f| + = f.select :project_access, options_for_select(UsersProject.access_roles, member.project_access), {}, class: "medium project-access-select span2" + .right + - if current_user == user + %span.btn.disabled This is you! + - if @project.namespace_owner == user + %span.btn.disabled.success Owner + - elsif user.blocked + %span.btn.disabled.blocked Blocked + - elsif allow_admin + = link_to project_team_member_path(project_id: @project, id: member.id), confirm: remove_from_team_message(@project, member), method: :delete, class: "very_small btn danger" do + %i.icon-minus.icon-white - - if allow_admin - = form_for(member, as: :team_member, url: project_team_member_path(@project, member)) do |f| - = f.select :project_access, options_for_select(UsersProject.access_roles, member.project_access), {}, class: "medium project-access-select span2" diff --git a/app/views/team_members/_team.html.haml b/app/views/team_members/_team.html.haml index 26d13533..65f17864 100644 --- a/app/views/team_members/_team.html.haml +++ b/app/views/team_members/_team.html.haml @@ -1,11 +1,9 @@ - grouper_project_members(@project).each do |access, members| - %table.low - %thead - %tr - %th.span7 - = Project.access_options.key(access).pluralize - %th - %tbody + %fieldset + %legend + = Project.access_options.key(access).pluralize + %small= members.size + %ul.unstyled - members.each do |up| = render(partial: 'team_members/show', locals: {member: up}) diff --git a/app/views/team_members/index.html.haml b/app/views/team_members/index.html.haml index ca3edcf7..e413c81b 100644 --- a/app/views/team_members/index.html.haml +++ b/app/views/team_members/index.html.haml @@ -1,18 +1,20 @@ = render "projects/project_head" %h3.page_title Team Members - %small (#{@project.users_projects.count}) - -- if can? current_user, :admin_team_member, @project - %p.slead + (#{@project.users_projects.count}) + %small Read more about project permissions %strong= link_to "here", help_permissions_path, class: "vlink" + - if can? current_user, :admin_team_member, @project %span.right = link_to import_project_team_members_path(@project), class: "btn small grouped", title: "Import team from another project" do Import team from another project = link_to new_project_team_member_path(@project), class: "btn success small grouped", title: "New Team Member" do New Team Member +%hr - .clearfix -= render partial: "team_members/team", locals: {project: @project} + +.clearfix +%div.team-table + = render partial: "team_members/team", locals: {project: @project} diff --git a/app/views/tree/_head.html.haml b/app/views/tree/_head.html.haml index f8e5c99f..f14526cf 100644 --- a/app/views/tree/_head.html.haml +++ b/app/views/tree/_head.html.haml @@ -4,4 +4,4 @@ = nav_link(controller: :tree) do = link_to 'Source', project_tree_path(@project, @ref) %li.right - = render "shared/clone_panel" \ No newline at end of file + = render "shared/clone_panel"