additional_tags 1.0.2 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/codeql-analysis.yml +70 -0
  3. data/.github/workflows/linters.yml +6 -2
  4. data/.github/workflows/tests.yml +8 -6
  5. data/.gitignore +2 -1
  6. data/.rubocop.yml +31 -6
  7. data/README.md +17 -18
  8. data/additional_tags.gemspec +6 -4
  9. data/app/controllers/additional_tags_controller.rb +23 -0
  10. data/app/helpers/additional_tags_helper.rb +60 -19
  11. data/app/helpers/additional_tags_issues_helper.rb +12 -2
  12. data/app/helpers/additional_tags_wiki_helper.rb +1 -25
  13. data/app/jobs/additional_tags_remove_unused_tag_job.rb +5 -0
  14. data/app/views/additional_tags/_body_bottom.html.slim +19 -0
  15. data/app/views/additional_tags/_html_head.html.slim +1 -4
  16. data/app/views/additional_tags/_tag_list.html.slim +1 -1
  17. data/app/views/additional_tags/context_menu.html.slim +1 -4
  18. data/app/views/additional_tags/index.api.rsb +5 -0
  19. data/app/views/additional_tags/settings/_manage_tags.html.slim +23 -23
  20. data/app/views/common/_tag_summary_block.html.slim +11 -0
  21. data/app/views/context_menus/_issues_tags.html.slim +1 -1
  22. data/app/views/dashboards/blocks/_issue_tags.html.slim +58 -0
  23. data/app/views/dashboards/blocks/_issue_tags_settings.html.slim +20 -0
  24. data/app/views/issue_tags/_edit_modal.html.slim +4 -2
  25. data/app/views/issues/_tags_sidebar.html.slim +4 -1
  26. data/assets/javascripts/tags.js +4 -3
  27. data/assets/stylesheets/tags.css +27 -13
  28. data/config/initializers/zeitwerk.rb +4 -0
  29. data/config/locales/bg.yml +5 -0
  30. data/config/locales/cs.yml +5 -0
  31. data/config/locales/de.yml +5 -0
  32. data/config/locales/en.yml +5 -0
  33. data/config/locales/es.yml +5 -0
  34. data/config/locales/fr.yml +5 -0
  35. data/config/locales/it.yml +5 -0
  36. data/config/locales/ja.yml +5 -0
  37. data/config/locales/ko.yml +5 -0
  38. data/config/locales/pl.yml +5 -0
  39. data/config/locales/pt-BR.yml +5 -0
  40. data/config/locales/ru.yml +28 -23
  41. data/config/routes.rb +1 -1
  42. data/db/migrate/20201123093214_migrate_existing_tags.rb +1 -1
  43. data/init.rb +9 -7
  44. data/lib/additional_tags/hooks/model_hook.rb +11 -0
  45. data/lib/additional_tags/hooks/view_hook.rb +79 -0
  46. data/lib/additional_tags/patches/auto_completes_controller_patch.rb +5 -6
  47. data/lib/additional_tags/patches/dashboard_content_patch.rb +28 -0
  48. data/lib/additional_tags/patches/issue_patch.rb +25 -28
  49. data/lib/additional_tags/patches/query_patch.rb +10 -3
  50. data/lib/additional_tags/patches/wiki_controller_patch.rb +1 -1
  51. data/lib/additional_tags/patches/wiki_page_patch.rb +50 -1
  52. data/lib/additional_tags/plugin_version.rb +7 -0
  53. data/lib/additional_tags/tags.rb +54 -4
  54. data/lib/additional_tags.rb +51 -65
  55. data/lib/tasks/additional_tags.rake +18 -0
  56. metadata +34 -12
  57. data/.github/workflows/brakeman.yml +0 -34
  58. data/app/views/reports/_tags_simple.html.slim +0 -11
  59. data/lib/additional_tags/hooks.rb +0 -75
  60. data/lib/additional_tags/patches/reports_controller_patch.rb +0 -34
  61. data/lib/additional_tags/version.rb +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '094d1e57c687d9c643b002e5e6134a457d47791a2b086c3c159d690242228488'
4
- data.tar.gz: dbfd7b4cb744aef1df5d132615bc1d8816ac85ccb7b837b04376d2b1eb9a76d6
3
+ metadata.gz: 74f23c86bdd928603d2740edb89fbecf6061fa559bbd1a030b3221929c81ec70
4
+ data.tar.gz: fb2c25b2a00e1ee5530cf677fcd3474280075c0c60d028209240ec933631f71b
5
5
  SHA512:
6
- metadata.gz: f95b50b1d98bb7f22c8a2d3bfc5d767ba85a6df06b5e259d9fe2a03ce2980f6577e948f6120f0fb831d3dee5155f88ebdab215534a3264fc24adb31749610122
7
- data.tar.gz: 417da0e654d1d966592242c95dd12899638758023b0822499c92e2079d03c28f0b9788046ee161f6ce721df325a0cdd91f1bd6dfe621cb88f910d7b9c12dcd3e
6
+ metadata.gz: 8a86b18dbebc7599d1afcb2b63edbea742e32825de1693254c5f066c7a12067aee4dec0649d5c5768480b13e830102e380784e0025f91b4a1da690f085b1b3fe
7
+ data.tar.gz: 2ccee9443f19a4a5b193cb63dc1a2d0ae6f965a2f2c11c937e3c2066149baa56272329b8ffa087f5f55d1446440da85a3c9e3d5b69b03ea6b5c99c78d72a3885
@@ -0,0 +1,70 @@
1
+ # For most projects, this workflow file will not need changing; you simply need
2
+ # to commit it to your repository.
3
+ #
4
+ # You may wish to alter this file to override the set of languages analyzed,
5
+ # or to provide custom queries or build logic.
6
+ #
7
+ # ******** NOTE ********
8
+ # We have attempted to detect the languages in your repository. Please check
9
+ # the `language` matrix defined below to confirm you have the correct set of
10
+ # supported CodeQL languages.
11
+ #
12
+ name: "CodeQL"
13
+
14
+ on:
15
+ push:
16
+ branches: [ master ]
17
+ pull_request:
18
+ # The branches below must be a subset of the branches above
19
+ branches: [ master ]
20
+ schedule:
21
+ - cron: '35 20 * * 2'
22
+
23
+ jobs:
24
+ analyze:
25
+ name: Analyze
26
+ runs-on: ubuntu-latest
27
+ permissions:
28
+ actions: read
29
+ contents: read
30
+ security-events: write
31
+
32
+ strategy:
33
+ fail-fast: false
34
+ matrix:
35
+ language: [ 'javascript', 'ruby' ]
36
+ # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37
+ # Learn more about CodeQL language support at https://git.io/codeql-language-support
38
+
39
+ steps:
40
+ - name: Checkout repository
41
+ uses: actions/checkout@v2
42
+
43
+ # Initializes the CodeQL tools for scanning.
44
+ - name: Initialize CodeQL
45
+ uses: github/codeql-action/init@v1
46
+ with:
47
+ languages: ${{ matrix.language }}
48
+ # If you wish to specify custom queries, you can do so here or in a config file.
49
+ # By default, queries listed here will override any specified in a config file.
50
+ # Prefix the list here with "+" to use these queries and those in the config file.
51
+ # queries: ./path/to/local/query, your-org/your-repo/queries@main
52
+
53
+ # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
54
+ # If this step fails, then you should remove it and run the build manually (see below)
55
+ - name: Autobuild
56
+ uses: github/codeql-action/autobuild@v1
57
+
58
+ # ℹ️ Command-line programs to run using the OS shell.
59
+ # 📚 https://git.io/JvXDl
60
+
61
+ # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
62
+ # and modify them (or add more) to build your code if your project
63
+ # uses a compiled language
64
+
65
+ #- run: |
66
+ # make bootstrap
67
+ # make release
68
+
69
+ - name: Perform CodeQL Analysis
70
+ uses: github/codeql-action/analyze@v1
@@ -16,13 +16,13 @@ jobs:
16
16
 
17
17
  - name: Setup Gemfile
18
18
  run: |
19
- touch .enable_dev
19
+ touch .enable_linters
20
20
  sed -i "3isource 'https://rubygems.org'" Gemfile
21
21
 
22
22
  - name: Setup Ruby
23
23
  uses: ruby/setup-ruby@v1
24
24
  with:
25
- ruby-version: 2.6
25
+ ruby-version: 3.0
26
26
  bundler-cache: true
27
27
 
28
28
  - name: Setup gems
@@ -37,3 +37,7 @@ jobs:
37
37
  run: |
38
38
  bundle exec slim-lint app/views
39
39
  if: always()
40
+
41
+ - name: Run Brakeman
42
+ run: |
43
+ bundle exec brakeman -5
@@ -10,17 +10,14 @@ jobs:
10
10
 
11
11
  strategy:
12
12
  matrix:
13
- ruby: ['2.7', '2.6', '2.5']
14
- redmine: ['4.1-stable', '4.2-stable', 'master']
13
+ ruby: ['2.7', '3.0', '3.1']
14
+ redmine: ['5.0-stable', 'master']
15
15
  db: ['postgres', 'mysql']
16
- exclude:
17
- - ruby: '2.7'
18
- redmine: 4.1-stable
19
16
  fail-fast: false
20
17
 
21
18
  services:
22
19
  postgres:
23
- image: postgres:13
20
+ image: postgres:14
24
21
  env:
25
22
  POSTGRES_DB: redmine
26
23
  POSTGRES_USER: postgres
@@ -83,6 +80,10 @@ jobs:
83
80
  libpq-dev
84
81
  libmysqlclient-dev
85
82
 
83
+ - name: Setup Gemfile
84
+ run: |
85
+ touch .enable_test
86
+
86
87
  - name: Setup Ruby
87
88
  uses: ruby/setup-ruby@v1
88
89
  with:
@@ -94,6 +95,7 @@ jobs:
94
95
  run: |
95
96
  cp plugins/additional_tags/test/support/database-${{ matrix.db }}.yml config/database.yml
96
97
  cp plugins/additional_tags/test/support/configuration.yml config/configuration.yml
98
+ cp plugins/additionals/test/support/additional_environment.rb config/additional_environment.rb
97
99
 
98
100
  - name: Install Ruby dependencies
99
101
  working-directory: redmine
data/.gitignore CHANGED
@@ -5,5 +5,6 @@ tmp/
5
5
  Gemfile.lock
6
6
  .project
7
7
  .settings/
8
+ .enable_*
8
9
  ._*
9
- .enable_dev
10
+ *.gem
data/.rubocop.yml CHANGED
@@ -1,14 +1,22 @@
1
1
  require:
2
2
  - rubocop-performance
3
3
  - rubocop-rails
4
+ - rubocop-minitest
5
+
6
+ AllCops:
7
+ TargetRubyVersion: 2.7
8
+ TargetRailsVersion: 6.1
9
+ NewCops: enable
4
10
 
5
11
  Rails:
6
12
  Enabled: true
7
13
 
8
- AllCops:
9
- TargetRubyVersion: 2.5
10
- TargetRailsVersion: 5.2
11
- NewCops: enable
14
+ Minitest/MultipleAssertions:
15
+ Max: 15
16
+ Enabled: true
17
+
18
+ Minitest/AssertPredicate:
19
+ Enabled: false
12
20
 
13
21
  Metrics/AbcSize:
14
22
  Enabled: false
@@ -47,6 +55,14 @@ Style/ExpandPathArguments:
47
55
  Rails/ApplicationJob:
48
56
  Enabled: false
49
57
 
58
+ Lint/AmbiguousOperatorPrecedence:
59
+ Enabled: false
60
+
61
+ Rails/ContentTag:
62
+ Enabled: true
63
+ Exclude:
64
+ - app/helpers/additional_tags_issues_helper.rb
65
+
50
66
  Rails/ApplicationRecord:
51
67
  Enabled: false
52
68
 
@@ -83,8 +99,12 @@ Style/OptionHash:
83
99
  - params
84
100
  - parameters
85
101
  - settings
86
- Exclude:
87
- - lib/additional_tags/patches/*.rb
102
+
103
+ # postgresql and mysql are supported
104
+ # autodetect does not work without database configuration
105
+ Rails/BulkChangeTable:
106
+ Enabled: true
107
+ Database: postgresql
88
108
 
89
109
  Style/ReturnNil:
90
110
  Enabled: true
@@ -108,3 +128,8 @@ Naming/VariableNumber:
108
128
  Enabled: true
109
129
  Exclude:
110
130
  - 'test/**/*'
131
+
132
+ # see https://github.com/rubocop/rubocop-rails/issues/578
133
+ # redmine does not use load_defaults: https://rails.rubystyle.guide/#config-defaults
134
+ Rails/RedundantPresenceValidationOnBelongsTo:
135
+ Enabled: false
data/README.md CHANGED
@@ -1,30 +1,29 @@
1
1
  # Additional Tags - Tags for Redmine
2
2
 
3
- [![Rate at redmine.org](https://img.shields.io/badge/rate%20at-redmine.org-blue.svg?style=flat)](https://www.redmine.org/plugins/additional_tags) [![Run Linters](https://github.com/AlphaNodes/additional_tags/workflows/Run%20Linters/badge.svg)](https://github.com/AlphaNodes/additional_tags/actions?query=workflow%3A%22Run+Linters%22) [![Run Brakeman](https://github.com/AlphaNodes/additional_tags/workflows/Run%20Brakeman/badge.svg)](https://github.com/AlphaNodes/additional_tags/actions?query=workflow%3A%22Run+Brakeman%22) [![Run Tests](https://github.com/AlphaNodes/additional_tags/workflows/Tests/badge.svg)](https://github.com/AlphaNodes/additional_tags/actions?query=workflow%3ATests)
4
-
3
+ [![Rate at redmine.org](https://img.shields.io/badge/rate%20at-redmine.org-blue.svg?style=flat)](https://www.redmine.org/plugins/additional_tags) [![Run Linters](https://github.com/AlphaNodes/additional_tags/workflows/Run%20Linters/badge.svg)](https://github.com/AlphaNodes/additional_tags/actions?query=workflow%3A%22Run+Linters%22) [![Run Tests](https://github.com/AlphaNodes/additional_tags/workflows/Tests/badge.svg)](https://github.com/AlphaNodes/additional_tags/actions?query=workflow%3ATests)
5
4
 
6
5
  ## Features
7
6
 
8
- - Tags for issues
9
- - Tags for wiki pages
10
- - Accented and non-latin characters supported for tag order
11
- - View, edit and create tag permissions for issues
12
- - Create permission for wiki tags
13
- - Managing tags
14
- - Custom tags and tagging tables (additional_tags and additional_taggings). If a other plugin
7
+ - Tags for issues
8
+ - Tags for wiki pages
9
+ - Accented and non-latin characters supported for tag order
10
+ - View, edit and create tag permissions for issues
11
+ - Create permission for wiki tags
12
+ - Managing tags
13
+ - Custom tags and tagging tables (additional_tags and additional_taggings). If a other plugin
15
14
  used tags or tagging tables for issue or wiki tagging, there tags will be migrated automatically
16
- - Based on the very popular [acts-as-taggable-on](https://github.com/mbleigh/acts-as-taggable-on)
15
+ - Based on the very popular [acts-as-taggable-on](https://github.com/mbleigh/acts-as-taggable-on)
17
16
 
18
17
  ![screenshot](https://raw.githubusercontent.com/AlphaNodes/additional_tags/master/doc/images/additional-tags.gif)
19
18
 
20
19
  Other plugins use additional_tags as framework in order to support tags for their entities.
21
20
  At the moment this are:
22
21
 
23
- - redmine_db (db entry tagging)
24
- - redmine_passwords (password tagging)
25
- - redmine_reporting (project tagging)
26
- - redmine_hrm (holiday tagging)
27
- - redmine_servicedesk (contact tagging)
22
+ - redmine_db (db entry tagging)
23
+ - redmine_passwords (password tagging)
24
+ - redmine_reporting (project tagging)
25
+ - redmine_hrm (holiday tagging)
26
+ - redmine_servicedesk (contact tagging)
28
27
 
29
28
  Start using it, too. The example image shows the centralized tag management in the plugin configuration.
30
29
 
@@ -39,8 +38,8 @@ Start using it, too. The example image shows the centralized tag management in t
39
38
 
40
39
  ## Requirements
41
40
 
42
- - Redmine `>= 4.1.0`
43
- - Ruby `>= 2.5`
41
+ - Redmine `>= 5.0`
42
+ - Ruby `>= 2.7`
44
43
  - Redmine plugins: [additionals](https://www.redmine.org/plugins/additionals)
45
44
 
46
45
  ## Installing
@@ -52,7 +51,7 @@ To install stable version of additional_tags, use
52
51
  ```shell
53
52
  cd $REDMINE_ROOT
54
53
  git clone -b stable https://www.github.com/alphanodes/additionals.git plugins/additionals
55
- git clone -b 1.0.0 https://www.github.com/alphanodes/additional_tags.git plugins/additional_tags
54
+ git clone -b stable https://www.github.com/alphanodes/additional_tags.git plugins/additional_tags
56
55
  ```
57
56
 
58
57
  It is also possible to use stable version as a gem package as an alternative. If you want it, add this to your $REDMINE_ROOT/Gemfile.local:
@@ -2,13 +2,14 @@
2
2
 
3
3
  lib = File.expand_path '../lib', __FILE__
4
4
  $LOAD_PATH.unshift lib unless $LOAD_PATH.include? lib
5
- require 'additional_tags/version'
5
+ require 'additional_tags/plugin_version'
6
6
 
7
7
  Gem::Specification.new do |spec|
8
8
  spec.name = 'additional_tags'
9
- spec.version = AdditionalTags::VERSION
9
+ spec.version = AdditionalTags::PluginVersion::VERSION
10
10
  spec.authors = ['AlphaNodes']
11
11
  spec.email = ['alex@alphanodes.com']
12
+ spec.metadata = { 'rubygems_mfa_required' => 'true' }
12
13
 
13
14
  spec.summary = 'Redmine plugin for adding tag functionality'
14
15
  spec.description = 'Redmine plugin for adding tag functionality'
@@ -21,9 +22,10 @@ Gem::Specification.new do |spec|
21
22
  spec.bindir = 'exe'
22
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename f }
23
24
  spec.require_paths = ['lib']
24
- spec.required_ruby_version = '>= 2.5'
25
+ spec.required_ruby_version = '>= 2.7'
25
26
 
26
- spec.add_runtime_dependency 'acts-as-taggable-on', '~> 7.0'
27
+ spec.add_runtime_dependency 'acts-as-taggable-on', '~> 9.0'
28
+ spec.add_runtime_dependency 'redmine_plugin_kit'
27
29
 
28
30
  spec.add_development_dependency 'bundler'
29
31
  spec.add_development_dependency 'rake'
@@ -7,6 +7,29 @@ class AdditionalTagsController < ApplicationController
7
7
  before_action :set_tag_list_path
8
8
 
9
9
  helper :additional_tags_issues
10
+ include AdditionalTagsHelper
11
+
12
+ accept_api_auth :index
13
+
14
+ # used by api calls
15
+ def index
16
+ raise 'type is not provided' if params[:type].blank?
17
+
18
+ type_info = manageable_tag_columns.detect { |m| m.first.to_s == params[:type] }
19
+ raise 'type is not supported' unless type_info
20
+
21
+ klass = type_info.first.to_s.camelize.constantize
22
+ raise "#{klass.name} does not support tags" unless klass.respond_to? :available_tags
23
+
24
+ @tags = klass.available_tags.to_a
25
+ @count = @tags.count
26
+ @tag_type = klass.name
27
+
28
+ respond_to do |format|
29
+ format.html { head :not_acceptable }
30
+ format.api
31
+ end
32
+ end
10
33
 
11
34
  def edit; end
12
35
 
@@ -15,12 +15,12 @@ module AdditionalTagsHelper
15
15
  if AdditionalTags.setting? :active_issue_tags
16
16
  columns[:issue] = { label: l(:label_issue_plural),
17
17
  tag_controller: :issues,
18
- counts: Issue.available_tags.map { |tag| [tag.id, tag.count] }.to_h }
18
+ counts: Issue.available_tags.to_h { |tag| [tag.id, tag.count] } }
19
19
  end
20
20
 
21
21
  if AdditionalTags.setting? :active_wiki_tags
22
22
  columns[:wiki] = { label: l(:label_wiki),
23
- counts: WikiPage.available_tags.map { |tag| [tag.id, tag.count] }.to_h }
23
+ counts: WikiPage.available_tags.to_h { |tag| [tag.id, tag.count] } }
24
24
  end
25
25
 
26
26
  call_hook :helper_additional_manageable_tag_columns, columns: columns
@@ -43,13 +43,13 @@ module AdditionalTagsHelper
43
43
  columns
44
44
  end
45
45
 
46
- def render_tags_list(tags, **options)
47
- return if tags.blank?
46
+ def sort_tags_for_list(tags, sort_by: nil, sort_order: nil)
47
+ return tags if tags.size < 2
48
48
 
49
- style = options.delete :style
50
- tags = tags.all.to_a if tags.respond_to? :all
49
+ sort_by = AdditionalTags.setting :tags_sort_by if sort_by.blank?
50
+ sort_order = AdditionalTags.setting :tags_sort_order if sort_order.blank?
51
51
 
52
- case "#{AdditionalTags.setting :tags_sort_by}:#{AdditionalTags.setting :tags_sort_order}"
52
+ case "#{sort_by}:#{sort_order}"
53
53
  when 'name:desc'
54
54
  tags = AdditionalTags::Tags.sort_tag_list(tags).reverse
55
55
  when 'count:asc'
@@ -60,6 +60,16 @@ module AdditionalTagsHelper
60
60
  tags = AdditionalTags::Tags.sort_tag_list tags
61
61
  end
62
62
 
63
+ tags
64
+ end
65
+
66
+ def render_tags_list(tags, **options)
67
+ return if tags.blank?
68
+
69
+ style = options.delete :style
70
+ tags = tags.all.to_a if tags.respond_to? :all
71
+ tags = sort_tags_for_list tags
72
+
63
73
  case style
64
74
  when :list
65
75
  list_el = 'ul'
@@ -84,20 +94,24 @@ module AdditionalTagsHelper
84
94
  content_tag(list_el, content, class: 'tags-cloud', style: (style == :simple_cloud ? 'text-align: left;' : ''))
85
95
  end
86
96
 
87
- def additional_tag_link(tag_object, link: nil, link_wiki_tag: false, show_count: false, use_colors: nil, **options)
97
+ def additional_tag_link(tag_object, link: nil, link_wiki_tag: false, show_count: false, use_colors: nil, name: nil, **options)
88
98
  tag_name = []
89
- tag_name << tag_object.name
99
+ tag_name << if name.nil?
100
+ tag_object.name
101
+ else
102
+ name
103
+ end
90
104
 
91
105
  options[:project] = @project if options[:project].blank? && @project.present?
106
+ use_colors = AdditionalTags.setting? :use_colors if use_colors.nil?
92
107
 
93
- use_colors ||= AdditionalTags.setting? :use_colors
94
- if use_colors
95
- tag_bg_color = additional_tag_color tag_object.name
96
- tag_fg_color = additional_tag_fg_color tag_bg_color
97
- tag_style = "background-color: #{tag_bg_color}; color: #{tag_fg_color}"
98
- end
108
+ tag_style = if use_colors
109
+ tag_bg_color = additional_tag_color tag_object.name
110
+ tag_fg_color = additional_tag_fg_color tag_bg_color
111
+ "background-color: #{tag_bg_color}; color: #{tag_fg_color}"
112
+ end
99
113
 
100
- tag_name << tag.span("(#{tag_object.count})", class: 'tag-count') if show_count
114
+ tag_name << tag.span(tag_object.count, class: 'tag-count') if show_count
101
115
 
102
116
  content = if link
103
117
  link_to safe_join(tag_name),
@@ -151,8 +165,10 @@ module AdditionalTagsHelper
151
165
  use_colors ? ' ' : ', '
152
166
  end
153
167
 
154
- def additional_tags_from_string(str)
155
- str.to_s.split(',').map(&:strip)
168
+ def additional_tags_from_params(str)
169
+ tags = str.is_a?(Array) ? str : str.to_s.split(',')
170
+ tags.map!(&:strip)
171
+ tags.compact_blank
156
172
  end
157
173
 
158
174
  def additional_tag_links(tag_list, **options)
@@ -165,6 +181,31 @@ module AdditionalTagsHelper
165
181
  additional_tag_sep(use_colors: options[:use_colors])
166
182
  end
167
183
 
184
+ def link_to_issue_tags_totals(entries:, project:, open_issues_only:)
185
+ sum = if entries.blank? || entries.size.zero?
186
+ 0
187
+ else
188
+ query = IssueQuery.new project: project, name: '_'
189
+ query.add_filter 'tags', '*'
190
+ query.filters['status_id'][:operator] = '*' if !open_issues_only && query.filters.key?('status_id')
191
+
192
+ query.issue_count
193
+ end
194
+
195
+ link_to sum, _project_issues_path(project,
196
+ set_filter: 1,
197
+ tags: '*',
198
+ status_id: open_issues_only ? 'o' : '*')
199
+ end
200
+
201
+ def issue_tag_status_filter(operator: nil, open_issues_only: false)
202
+ if operator
203
+ { field: :status_id, operator: operator }
204
+ elsif open_issues_only
205
+ { field: :status_id, operator: 'o' }
206
+ end
207
+ end
208
+
168
209
  private
169
210
 
170
211
  def tag_url(tag_name, filter: nil, tag_action: nil, tag_controller: nil, project: nil)
@@ -193,7 +234,7 @@ module AdditionalTagsHelper
193
234
  def add_tags(style, tags, content, item_el, options)
194
235
  tag_cloud tags, (1..8).to_a do |tag, weight|
195
236
  content << ' '.html_safe + content_tag(item_el,
196
- additional_tag_link(tag, options),
237
+ additional_tag_link(tag, **options),
197
238
  class: "tag-nube-#{weight}",
198
239
  style: (style == :simple_cloud ? 'font-size: 1em;' : '')) + ' '.html_safe
199
240
  end
@@ -7,7 +7,7 @@ module AdditionalTagsIssuesHelper
7
7
 
8
8
  if @issue.present? &&
9
9
  (defined?(controller_name) && controller_name == 'issues' && action_name == 'show' || !defined?(controller_name)) &&
10
- User.current.allowed_to?(:view_issues, @project)
10
+ AdditionalTags.setting?(:active_issue_tags) && User.current.allowed_to?(:view_issue_tags, @project)
11
11
 
12
12
  api.array :tags do
13
13
  @issue.tags.each do |tag|
@@ -16,6 +16,16 @@ module AdditionalTagsIssuesHelper
16
16
  end
17
17
  end
18
18
 
19
+ if @time_entry.present? &&
20
+ (defined?(controller_name) && controller_name == 'timelog' && action_name == 'show' || !defined?(controller_name)) &&
21
+ AdditionalTags.setting?(:active_issue_tags) && User.current.allowed_to?(:view_issue_tags, @project)
22
+ api.array :issue_tags do
23
+ @time_entry.issue_tags.each do |tag|
24
+ api.tag id: tag.id, name: tag.name
25
+ end
26
+ end
27
+ end
28
+
19
29
  rc
20
30
  end
21
31
 
@@ -40,6 +50,6 @@ module AdditionalTagsIssuesHelper
40
50
  project: @project }
41
51
 
42
52
  options[:tag_action] = 'show' if %w[gantts calendars].include? controller_name
43
- render_tags_list sidebar_tags, options
53
+ render_tags_list sidebar_tags, **options
44
54
  end
45
55
  end
@@ -15,7 +15,7 @@ module AdditionalTagsWikiHelper
15
15
  link_wiki_tag: true,
16
16
  project: @project }
17
17
 
18
- render_tags_list sidebar_tags, options
18
+ render_tags_list sidebar_tags, **options
19
19
  end
20
20
 
21
21
  def render_wiki_index_title(project, tag = nil)
@@ -32,28 +32,4 @@ module AdditionalTagsWikiHelper
32
32
  l :label_wiki
33
33
  end
34
34
  end
35
-
36
- def wiki_pages_with_tag(tag, project = nil)
37
- wiki = project&.wiki
38
-
39
- scope = if wiki
40
- wiki.pages
41
- else
42
- WikiPage.joins wiki: :project
43
- end
44
-
45
- scope = scope.visible User.current, project: project if scope.respond_to? :visible
46
-
47
- scope = scope.joins(AdditionalTags::Tags.tag_to_joins(WikiPage))
48
- .where("LOWER(#{ActiveRecord::Base.connection.quote_table_name ActsAsTaggableOn.tags_table}.name) = LOWER(:p)",
49
- p: tag.to_s.strip)
50
- .with_updated_on
51
- .joins(wiki: :project)
52
-
53
- if wiki.nil?
54
- scope.order "#{Project.table_name}.name, #{WikiPage.table_name}.title"
55
- else
56
- scope.includes(:parent).order "#{WikiPage.table_name}.title"
57
- end
58
- end
59
35
  end
@@ -2,6 +2,11 @@
2
2
 
3
3
  class AdditionalTagsRemoveUnusedTagJob < AdditionalTagsJob
4
4
  def perform
5
+ # only once a minute to reduce load
6
+ cache_key = self.class.to_s
7
+ return if Rails.cache.read(cache_key) && !Rails.env.test?
8
+
9
+ Rails.cache.write cache_key, true, expires_in: 60
5
10
  AdditionalTags::Tags.remove_unused_tags
6
11
  end
7
12
  end
@@ -0,0 +1,19 @@
1
+ = additionals_transform_to_select2 'assignee',
2
+ format_state: 'formatNameWithIcon',
3
+ multiple: true,
4
+ url: assignee_auto_completes_path(project_id: @project)
5
+
6
+ = additionals_transform_to_select2 'author',
7
+ format_state: 'formatNameWithIcon',
8
+ multiple: true,
9
+ url: grouped_users_auto_completes_path(project_id: @project, with_ano: true, with_me: true)
10
+
11
+ = additionals_transform_to_select2 'user_with_me',
12
+ format_state: 'formatNameWithIcon',
13
+ multiple: true,
14
+ url: grouped_users_auto_completes_path(project_id: @project, with_me: true)
15
+
16
+ = additionals_transform_to_select2 'user',
17
+ format_state: 'formatNameWithIcon',
18
+ multiple: true,
19
+ url: grouped_users_auto_completes_path(project_id: @project)
@@ -1,6 +1,3 @@
1
1
  = stylesheet_link_tag 'tags', plugin: 'additional_tags'
2
2
  = javascript_include_tag 'tags', plugin: 'additional_tags'
3
- - if User.current.allowed_to?(:edit_issue_tags, @project, global: true) || \
4
- User.current.allowed_to?(:create_issue_tags, @project, global: true) || \
5
- User.current.allowed_to?(:add_wiki_tags, @project, global: true)
6
- = additionals_library_load :select2
3
+ = additionals_library_load :select2
@@ -18,7 +18,7 @@
18
18
  onclick: "$('#edit_tags_form').show(); $('#tags-data').hide(); return false;",
19
19
  id: 'edit_tags_link'
20
20
 
21
- #edit_tags_form style="display: none;"
21
+ #edit_tags_form.hidden
22
22
  = form_tag update_url, method: :put do
23
23
  = render partial: defined?(tags_form) ? tags_form : 'tags_form',
24
24
  locals: { css_id: defined?(css_id) ? css_id : nil }
@@ -10,7 +10,4 @@ ul
10
10
  merge_additional_tags_path(ids: @tags.collect(&:id)),
11
11
  class: 'icon icon-tags-merge'
12
12
  li
13
- = link_to l(:button_delete),
14
- additional_tags_path(ids: @tags.collect(&:id), back_url: @back),
15
- method: :delete, data: { confirm: l(:text_are_you_sure) },
16
- class: 'icon icon-del'
13
+ = delete_link additional_tags_path(ids: @tags.collect(&:id), back_url: @back)
@@ -0,0 +1,5 @@
1
+ api.array :tags, api_meta(total_count: @count, tag_type: @tag_type) do
2
+ @tags.each do |tag|
3
+ api.tag id: tag.id, name: tag.name, count: tag.count
4
+ end
5
+ end