Commit 67043ec5 authored by Zeger-Jan van de Weg's avatar Zeger-Jan van de Weg

Hide delete botton on edit page

parent 212e83ba
...@@ -7,8 +7,7 @@ module InternalId ...@@ -7,8 +7,7 @@ module InternalId
end end
def set_iid def set_iid
max_iid = case self.class max_iid = if self.paranoid?
when Issue, MergeRequest
project.send(self.class.name.tableize).with_deleted.maximum(:iid) project.send(self.class.name.tableize).with_deleted.maximum(:iid)
else else
project.send(self.class.name.tableize).maximum(:iid) project.send(self.class.name.tableize).maximum(:iid)
......
...@@ -440,6 +440,10 @@ class User < ActiveRecord::Base ...@@ -440,6 +440,10 @@ class User < ActiveRecord::Base
Project.where("projects.id IN (#{projects_union.to_sql})") Project.where("projects.id IN (#{projects_union.to_sql})")
end end
def owner?(project)
owned_projects.include?(project)
end
def owned_projects def owned_projects
@owned_projects ||= @owned_projects ||=
Project.where('namespace_id IN (?) OR namespace_id = ?', Project.where('namespace_id IN (?) OR namespace_id = ?',
......
...@@ -45,10 +45,6 @@ ...@@ -45,10 +45,6 @@
- if can?(current_user, :update_issue, @issue) - if can?(current_user, :update_issue, @issue)
= link_to 'Reopen issue', issue_path(@issue, issue: {state_event: :reopen}, status_only: true, format: 'json'), data: {no_turbolink: true}, class: "btn btn-nr btn-grouped btn-reopen #{issue_button_visibility(@issue, false)}", title: 'Reopen issue' = link_to 'Reopen issue', issue_path(@issue, issue: {state_event: :reopen}, status_only: true, format: 'json'), data: {no_turbolink: true}, class: "btn btn-nr btn-grouped btn-reopen #{issue_button_visibility(@issue, false)}", title: 'Reopen issue'
= link_to 'Close issue', issue_path(@issue, issue: {state_event: :close}, status_only: true, format: 'json'), data: {no_turbolink: true}, class: "btn btn-nr btn-grouped btn-close #{issue_button_visibility(@issue, true)}", title: 'Close issue' = link_to 'Close issue', issue_path(@issue, issue: {state_event: :close}, status_only: true, format: 'json'), data: {no_turbolink: true}, class: "btn btn-nr btn-grouped btn-close #{issue_button_visibility(@issue, true)}", title: 'Close issue'
- if current_user.admin?
= link_to namespace_project_issue_path(@project.namespace, @project, @issue), method: :delete, class: 'btn btn-grouped' do
= icon('trash-o')
Delete
= link_to edit_namespace_project_issue_path(@project.namespace, @project, @issue), class: 'btn btn-nr btn-grouped issuable-edit' do = link_to edit_namespace_project_issue_path(@project.namespace, @project, @issue), class: 'btn btn-nr btn-grouped issuable-edit' do
= icon('pencil-square-o') = icon('pencil-square-o')
Edit Edit
......
...@@ -33,7 +33,3 @@ ...@@ -33,7 +33,3 @@
Edit Edit
- if @merge_request.closed? - if @merge_request.closed?
= link_to 'Reopen', merge_request_path(@merge_request, merge_request: {state_event: :reopen }), method: :put, class: 'btn btn-nr btn-grouped btn-reopen reopen-mr-link', title: 'Reopen merge request' = link_to 'Reopen', merge_request_path(@merge_request, merge_request: {state_event: :reopen }), method: :put, class: 'btn btn-nr btn-grouped btn-reopen reopen-mr-link', title: 'Reopen merge request'
- if current_user.admin?
= link_to namespace_project_merge_request_path(@project.namespace, @project, @merge_request), method: :delete, class: 'btn btn-grouped' do
= icon('trash-o')
Delete
...@@ -106,6 +106,10 @@ ...@@ -106,6 +106,10 @@
= f.submit "Submit #{issuable.class.model_name.human.downcase}", class: 'btn btn-create' = f.submit "Submit #{issuable.class.model_name.human.downcase}", class: 'btn btn-create'
- else - else
= f.submit 'Save changes', class: 'btn btn-save' = f.submit 'Save changes', class: 'btn btn-save'
- if current_user.admin? || current_user.owner?(@project)
= link_to namespace_project_issue_path(@project.namespace, @project, issuable), method: :delete, class: 'btn' do
= icon('trash-o')
Delete
- if !issuable.persisted? && !issuable.project.empty_repo? && (guide_url = contribution_guide_path(issuable.project)) - if !issuable.persisted? && !issuable.project.empty_repo? && (guide_url = contribution_guide_path(issuable.project))
.inline.prepend-left-10 .inline.prepend-left-10
......
...@@ -948,7 +948,6 @@ ActiveRecord::Schema.define(version: 20160316204731) do ...@@ -948,7 +948,6 @@ ActiveRecord::Schema.define(version: 20160316204731) do
t.string "unlock_token" t.string "unlock_token"
t.datetime "otp_grace_period_started_at" t.datetime "otp_grace_period_started_at"
t.boolean "ldap_email", default: false, null: false t.boolean "ldap_email", default: false, null: false
t.boolean "external", default: false
end end
add_index "users", ["admin"], name: "index_users_on_admin", using: :btree add_index "users", ["admin"], name: "index_users_on_admin", using: :btree
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment