Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion app/controllers/additional_tags_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ class AdditionalTagsController < ApplicationController
before_action :find_tag, only: %i[edit update]
before_action :bulk_find_tags, only: %i[context_menu merge destroy]
before_action :set_tag_list_path
before_action :find_project_by_project_id, if: -> { params[:project_id] }
before_action :authorize, if: -> { @project.present? }

helper :additional_tags_issues
include AdditionalTagsHelper
Expand All @@ -13,6 +15,7 @@ class AdditionalTagsController < ApplicationController

# used by api calls
def index
raise 'tags are not enabled for project' unless allow_tags?
raise 'type is not provided' if params[:type].blank?

type_info = manageable_tag_columns.detect { |m| m.first.to_s == params[:type] }
Expand Down Expand Up @@ -101,4 +104,8 @@ def find_tag
rescue ActiveRecord::RecordNotFound
render_404
end
end

def allow_tags?
@project.nil? || @project.module_enabled?(:additional_tags)
end
end
3 changes: 2 additions & 1 deletion app/helpers/additional_tags_issues_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ def render_api_custom_values(custom_values, api)

if @issue.present? &&
(defined?(controller_name) && controller_name == 'issues' && action_name == 'show' || !defined?(controller_name)) &&
AdditionalTags.setting?(:active_issue_tags) && User.current.allowed_to?(:view_issue_tags, @project)
AdditionalTags.setting?(:active_issue_tags) && User.current.allowed_to?(:view_issue_tags, @project) &&
project.module_enabled?(:additional_tags)

api.array :tags do
# support tags, which are not saved to database
Expand Down
2 changes: 1 addition & 1 deletion app/views/issues/_tags.html.slim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- if AdditionalTags.setting?(:active_issue_tags) && User.current.allowed_to?(:view_issue_tags, issue.project)
- if AdditionalTags.setting?(:active_issue_tags) && User.current.allowed_to?(:view_issue_tags, issue.project) && @project && project.module_enabled?(:additional_tags)
= render 'additional_tags/tag_list',
entry: issue,
show_always: true,
Expand Down
4 changes: 4 additions & 0 deletions app/views/projects/settings/_additional_tags.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<p>
<%= check_box_tag 'settings[additional_tags_enabled]', 1, @project.additional_tags_enabled? %>
<%= label_tag 'settings[additional_tags_enabled]', l(:label_additional_tags_enabled) %>
</p>
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ en:
tags_sidebar_simple_cloud: "Simple cloud"
tags_sort_by_count: "Count"
tags_sort_by_name: "Name"
label_additional_tags_enabled: "Enable Additional Tags"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddAdditionalTagsEnabledToProjects < ActiveRecord::Migration[6.0]
def change
add_column :projects, :additional_tags_enabled, :boolean, default: true, null: false
end
end
5 changes: 5 additions & 0 deletions init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
permission :view_issue_tags, {}, read: true
end

project_module :additional_tags do
permission :view_project_tags, { tags: %i[index, show] }
permission :manage_project_tags, { tags: %i[new, create, edit, destroy] }
end

project_module :wiki do
permission :add_wiki_tags, wiki: %i[update_tags]
end
Expand Down
Loading