From a67193ea1259716af0c7bbf15719a3503668621b Mon Sep 17 00:00:00 2001 From: yzzy Date: Wed, 12 May 2021 16:35:23 +0500 Subject: [PATCH] Other Redmine plugins compatibility --- app/views/webhook_settings/_show.html.erb | 7 +------ init.rb | 4 +++- lib/redmine_webhook/projects_helper_patch.rb | 8 +++++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/app/views/webhook_settings/_show.html.erb b/app/views/webhook_settings/_show.html.erb index de7b379..d9bf953 100644 --- a/app/views/webhook_settings/_show.html.erb +++ b/app/views/webhook_settings/_show.html.erb @@ -1,5 +1,3 @@ - -<% if User.current.allowed_to?( :manage_hook, @project) %> <% if Webhook.where(:project_id => @project.id).first%>
<% Webhook.where(:project_id => @project.id).each do |webhook|%> @@ -15,6 +13,7 @@ <% end %>
<% end %> + <%= form_tag(create_webhook_path(@project), :method => :post, :class => "tabular") do %>
@@ -23,8 +22,4 @@ <%= submit_tag l(:button_add) %>
- - -<% end %> - <% end %> diff --git a/init.rb b/init.rb index 9246693..22550ab 100644 --- a/init.rb +++ b/init.rb @@ -7,5 +7,7 @@ version '0.0.5' url 'https://github.com/suer/redmine_webhook' author_url 'http://d.hatena.ne.jp/suer' - permission :manage_hook, {:webhook_settings => [:index, :show, :update, :create, :destroy]}, :require => :member + project_module :webhooks do + permission :manage_hook, {:webhook_settings => [:index, :show, :update, :create, :destroy]}, :require => :member + end end diff --git a/lib/redmine_webhook/projects_helper_patch.rb b/lib/redmine_webhook/projects_helper_patch.rb index a909813..7bbfe37 100644 --- a/lib/redmine_webhook/projects_helper_patch.rb +++ b/lib/redmine_webhook/projects_helper_patch.rb @@ -2,15 +2,17 @@ module RedmineWebhook module ProjectsHelperPatch def project_settings_tabs tabs = super - tabs << { + webhook_tab = { :name => 'webhook', :controller => 'webhook_settings', :action => :show, :partial => 'webhook_settings/show', :label => :webhook } + tabs << webhook_tab if User.current.allowed_to?(:manage_hook, @project) + tabs end end - - ProjectsHelper.prepend ProjectsHelperPatch end + +ProjectsController.send(:helper, RedmineWebhook::ProjectsHelperPatch)