diff --git a/CHANGELOG.md b/CHANGELOG.md index 43d6610e..153e73df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 3.2.0 + +- add option to hide issue attachments, if number of file is too high +- rubocop offenses has been fixed + ## 3.1.0 - Fix missing label for view all documents diff --git a/app/helpers/additionals_queries_helper.rb b/app/helpers/additionals_queries_helper.rb index 46463c45..1b1cad42 100644 --- a/app/helpers/additionals_queries_helper.rb +++ b/app/helpers/additionals_queries_helper.rb @@ -18,7 +18,7 @@ module AdditionalsQueriesHelper end def additionals_query_session_key(object_type) - "#{object_type}_query".to_sym + :"#{object_type}_query" end def additionals_retrieve_query(object_type, user_filter: nil, search_string: nil) diff --git a/app/models/additionals_chart.rb b/app/models/additionals_chart.rb index e816ec82..23cf0009 100644 --- a/app/models/additionals_chart.rb +++ b/app/models/additionals_chart.rb @@ -42,7 +42,7 @@ class AdditionalsChart def build_values_without_gaps(data, gap_value = 0) values = [] - labels.each do |label, _label_id| + labels.each_key do |label| values << if data.key? label data[label] else diff --git a/app/models/additionals_query.rb b/app/models/additionals_query.rb index be179857..208c1874 100644 --- a/app/models/additionals_query.rb +++ b/app/models/additionals_query.rb @@ -264,7 +264,7 @@ module AdditionalsQuery end def results_scope(**options) - order_option = [group_by_sort_order, (options[:order] || sort_clause)].flatten!.to_a.compact_blank + order_option = [group_by_sort_order, options[:order] || sort_clause].flatten!.to_a.compact_blank objects_scope(**options.except(:order, :limit, :offset)) .order(order_option) diff --git a/app/models/dashboard.rb b/app/models/dashboard.rb index def833c5..c0eb800c 100644 --- a/app/models/dashboard.rb +++ b/app/models/dashboard.rb @@ -24,10 +24,10 @@ class Dashboard < ActiveRecord::Base VISIBILITY_ROLES = 1 VISIBILITY_PUBLIC = 2 - scope :by_project, (->(project_id) { where project_id: project_id if project_id.present? }) - scope :sorted, (-> { order :name }) - scope :welcome_only, (-> { where dashboard_type: DashboardContentWelcome::TYPE_NAME }) - scope :project_only, (-> { where dashboard_type: DashboardContentProject::TYPE_NAME }) + scope :by_project, ->(project_id) { where project_id: project_id if project_id.present? } + scope :sorted, -> { order :name } + scope :welcome_only, -> { where dashboard_type: DashboardContentWelcome::TYPE_NAME } + scope :project_only, -> { where dashboard_type: DashboardContentProject::TYPE_NAME } safe_attributes 'name', 'description', 'enable_sidebar', 'locked', 'always_expose', 'project_id', 'author_id', @@ -267,7 +267,7 @@ class Dashboard < ActiveRecord::Base def editable?(user = User.current) return false unless user - (user.admin? || (author == user && user.allowed_to?(:save_dashboards, project, global: true))) + user.admin? || (author == user && user.allowed_to?(:save_dashboards, project, global: true)) end def deletable?(user = User.current) diff --git a/app/overrides/issues_show.rb b/app/overrides/issues_show.rb index 3853afe3..e0d9db5c 100644 --- a/app/overrides/issues_show.rb +++ b/app/overrides/issues_show.rb @@ -24,4 +24,11 @@ module IssuesShow insert_before: 'erb[loud]:contains("render_private_notes_indicator")', original: '38ddc174974d0a0ee482dd73070ee80baebe9e4d', partial: 'issues/additionals_note_history' + + Deface::Override.new virtual_path: 'issues/show', + name: 'show-issue-attachments', + replace: 'erb[silent]:contains("if @issue.attachments.any?")', + closing_selector: 'erb[silent]:contains("end")', + original: 'e2a825486b3b1ba51c0e2fa1f72bdd5e98e1b964', + partial: 'issues/hide_attachments' end diff --git a/app/views/additionals/settings/_issues.html.slim b/app/views/additionals/settings/_issues.html.slim index 1a0402f0..aa54f2ec 100644 --- a/app/views/additionals/settings/_issues.html.slim +++ b/app/views/additionals/settings/_issues.html.slim @@ -6,7 +6,12 @@ p = additionals_settings_textarea :new_ticket_message em.info = l :new_ticket_message_info -br +p + = additionals_settings_numberfield :issue_hide_max_attachments, + min: 0, max: 1000, size: 5 + em.info + = l :info_issue_hide_max_attachments + p = additionals_settings_checkbox :new_issue_on_profile p = additionals_settings_checkbox :issue_assign_to_me p = additionals_settings_checkbox :issue_note_with_author diff --git a/app/views/issues/_hide_attachments.html.slim b/app/views/issues/_hide_attachments.html.slim new file mode 100644 index 00000000..2320cb47 --- /dev/null +++ b/app/views/issues/_hide_attachments.html.slim @@ -0,0 +1,15 @@ +- if @issue.attachments.any? + - file_count = @issue.attachments.length + - if file_count > Additionals.setting(:issue_hide_max_attachments).to_i + fieldset.collapsible.collapsed.hide-attachments + legend onclick="toggleFieldset(this);" class="icon icon-collapsed" + strong + = l :label_attachment_plural + = " (#{file_count})" + .hidden + = link_to_attachments @issue, thumbnails: true + - else + hr + p + strong = l :label_attachment_plural + = link_to_attachments @issue, thumbnails: true diff --git a/assets/stylesheets/additionals.css b/assets/stylesheets/additionals.css index 318f3c64..cb983b34 100644 --- a/assets/stylesheets/additionals.css +++ b/assets/stylesheets/additionals.css @@ -25,6 +25,11 @@ span.dashboard-locked { color: #666; } +fieldset.hide-attachments { + padding-left: 0; + margin-top: 8px; +} + #my-page.dashboard .settings input[type='text'], #my-page.dashboard .settings input[type='password'], #my-page.dashboard .settings input[type='url'] { diff --git a/config/locales/cs.yml b/config/locales/cs.yml index fdafd65f..547a60d7 100644 --- a/config/locales/cs.yml +++ b/config/locales/cs.yml @@ -210,3 +210,5 @@ cs: wiki_pdf_remove_attachments_info: "Pokud je aktivní, připojené soubory Wiki se nebudou zobrazovat v zobrazení PDF." wiki_pdf_remove_title_info: "Pokud je aktivní, informace o názvu Wiki se nebudou zobrazovat v zobrazení PDF." label_document_view_all: "Zobrazit všechny dokumenty" + label_issue_hide_max_attachments: Show max. files + info_issue_hide_max_attachments: If the number of files entered here is exceeding all file attachments of an issue are displayed hidden. diff --git a/config/locales/de.yml b/config/locales/de.yml index 3e0ce423..27b317d7 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -210,3 +210,5 @@ de: wiki_pdf_remove_attachments_info: Wenn aktiv, werden die an der Wiki Seite angehängten Dateien nicht in der PDF Ansicht angezeigt. wiki_pdf_remove_title_info: Wenn aktiv, wird der Wiki Titel nicht in der PDF Ansicht angezeigt. label_document_view_all: Alle Dokumente anzeigen + label_issue_hide_max_attachments: Max. angezeigte Dateien + info_issue_hide_max_attachments: Wird die hier angegene Anzahl überschritten, werden alle Dateianhänge im Ticket eingeklappt/versteckt dargestellt. diff --git a/config/locales/en.yml b/config/locales/en.yml index b242b2fc..075c322c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -210,3 +210,5 @@ en: wiki_pdf_remove_attachments_info: "When active the attached Wiki files will not be displayed in PDF view." wiki_pdf_remove_title_info: "When active the Wiki title info will not be displayed in PDF view." label_document_view_all: View all documents + label_issue_hide_max_attachments: Show max. files + info_issue_hide_max_attachments: If the number of files entered here is exceeding all file attachments of an issue are displayed hidden. diff --git a/config/locales/es.yml b/config/locales/es.yml index f7ceeb11..8961b21c 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -210,3 +210,5 @@ es: wiki_pdf_remove_attachments_info: "Cuando está activa, los adjuntos no serán mostrados en los PDF." wiki_pdf_remove_title_info: "Cuando está activa, el título de la Wiki no será mostrado en los PDF." label_document_view_all: "Todos los documentos" + label_issue_hide_max_attachments: Show max. files + info_issue_hide_max_attachments: If the number of files entered here is exceeding all file attachments of an issue are displayed hidden. diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 5eca8254..4208eb61 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -210,3 +210,5 @@ fr: wiki_pdf_remove_attachments_info: "Lorsqu'ils sont actifs, les fichiers Wiki joints ne seront pas affichés en vue PDF." wiki_pdf_remove_title_info: "Lorsqu'elle est active, l'information sur le titre du wiki ne sera pas affichée dans la vue PDF." label_document_view_all: "Voir tous les documents" + label_issue_hide_max_attachments: Show max. files + info_issue_hide_max_attachments: If the number of files entered here is exceeding all file attachments of an issue are displayed hidden. diff --git a/config/locales/it.yml b/config/locales/it.yml index e8317018..931ae202 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -210,3 +210,5 @@ it: wiki_pdf_remove_attachments_info: "Quando è attivo, il Wiki file allegati non verranno visualizzati nella vista PDF." wiki_pdf_remove_title_info: "Quando è attivo, le informazioni sul titolo del Wiki non verranno visualizzate nella vista PDF." label_document_view_all: "Vedi tutti i documenti" + label_issue_hide_max_attachments: Show max. files + info_issue_hide_max_attachments: If the number of files entered here is exceeding all file attachments of an issue are displayed hidden. diff --git a/config/locales/ja.yml b/config/locales/ja.yml index f9844840..08bde4d1 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -210,3 +210,5 @@ ja: wiki_pdf_remove_attachments_info: "アクティブな場合、添付されたWikiファイルはPDFビューに表示されません。" wiki_pdf_remove_title_info: "アクティブな場合、Wikiのタイトル情報はPDFビューに表示されません。" label_document_view_all: "すべての資料を見る" + label_issue_hide_max_attachments: Show max. files + info_issue_hide_max_attachments: If the number of files entered here is exceeding all file attachments of an issue are displayed hidden. diff --git a/config/locales/ko.yml b/config/locales/ko.yml index 6a17ffba..5515858f 100644 --- a/config/locales/ko.yml +++ b/config/locales/ko.yml @@ -210,3 +210,5 @@ ko: wiki_pdf_remove_attachments_info: 활성화 된 경우 첨부 된 Wiki 파일은 PDF보기에 표시되지 않습니다. wiki_pdf_remove_title_info: 활성화되면 위키 제목 정보가 PDF보기에 표시되지 않습니다. label_document_view_all: "모든 문서 보기" + label_issue_hide_max_attachments: Show max. files + info_issue_hide_max_attachments: If the number of files entered here is exceeding all file attachments of an issue are displayed hidden. diff --git a/config/locales/pl.yml b/config/locales/pl.yml index f9c2242d..86629bf8 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -210,3 +210,5 @@ pl: wiki_pdf_remove_attachments_info: "Gdy jest aktywny, załączone pliki Wiki nie będą wyświetlane w widoku PDF." wiki_pdf_remove_title_info: "Gdy jest aktywny, informacja o tytule Wiki nie będzie wyświetlana w widoku PDF." label_document_view_all: "Zobacz wszystkie dokumenty" + label_issue_hide_max_attachments: Show max. files + info_issue_hide_max_attachments: If the number of files entered here is exceeding all file attachments of an issue are displayed hidden. diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index 5c676e50..062175c8 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -210,3 +210,5 @@ pt-BR: wiki_pdf_remove_attachments_info: "Quando ativo, os arquivos Wiki anexos não serão exibidos na visualização em PDF." wiki_pdf_remove_title_info: "Quando ativo, o título do Wiki não será exibido na visualização em PDF." label_document_view_all: "Veja todos os documentos" + label_issue_hide_max_attachments: Show max. files + info_issue_hide_max_attachments: If the number of files entered here is exceeding all file attachments of an issue are displayed hidden. diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 83a93462..ba8ff77a 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -210,3 +210,5 @@ ru: wiki_pdf_remove_attachments_info: "Если флажок установлен, вложенные Вики-файлы не будут отображаться в PDF-формате." wiki_pdf_remove_title_info: "При активации этого параметра информация о названии Вики не будет отображаться в PDF-формате." label_document_view_all: "Посмотреть все документы" + label_issue_hide_max_attachments: Show max. files + info_issue_hide_max_attachments: If the number of files entered here is exceeding all file attachments of an issue are displayed hidden. diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml index 1e3b6e94..a43f47f5 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -210,3 +210,5 @@ wiki_pdf_remove_attachments_info: "當啟用時,Wiki附件將不會顯示在PDF中。" wiki_pdf_remove_title_info: "當啟用時,Wiki標題訊息不會顯示在PDF中" label_document_view_all: "查看所有文件" + label_issue_hide_max_attachments: Show max. files + info_issue_hide_max_attachments: If the number of files entered here is exceeding all file attachments of an issue are displayed hidden. diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 0631153e..5077f7ff 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -210,3 +210,5 @@ zh: wiki_pdf_remove_attachments_info: 当启用时,Wiki 附件将不会显示在 PDF 视图中。 wiki_pdf_remove_title_info: 当启用时,Wiki 标题信息将不会显示在 PDF 视图中。 label_document_view_all: "查看所有文件" + label_issue_hide_max_attachments: Show max. files + info_issue_hide_max_attachments: If the number of files entered here is exceeding all file attachments of an issue are displayed hidden. diff --git a/config/settings.yml b/config/settings.yml index ed4443c0..51046e9d 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -17,6 +17,7 @@ issue_auto_assign_status: '' issue_change_status_in_sidebar: 0 issue_current_user_status: 0 issue_freezed_with_close: 0 +issue_hide_max_attachments: 10 issue_note_with_author: 0 issue_fast_description_edit: 0 issue_status_change: 0 diff --git a/lib/additionals/helpers.rb b/lib/additionals/helpers.rb index 12fc5805..5842dddf 100644 --- a/lib/additionals/helpers.rb +++ b/lib/additionals/helpers.rb @@ -59,7 +59,7 @@ module Additionals end def additionals_i18n_title(options, title) - i18n_title = "#{title}_#{::I18n.locale}".to_sym + i18n_title = :"#{title}_#{::I18n.locale}" if options.key? i18n_title options[i18n_title] elsif options.key? title diff --git a/lib/additionals/plugin_version.rb b/lib/additionals/plugin_version.rb index 8b0a2e65..b103f024 100644 --- a/lib/additionals/plugin_version.rb +++ b/lib/additionals/plugin_version.rb @@ -2,6 +2,6 @@ module Additionals module PluginVersion - VERSION = '3.1.0' unless defined? Additionals::PluginVersion::VERSION + VERSION = '3.2.0-main' unless defined? Additionals::PluginVersion::VERSION end end diff --git a/test/crud_controller_base.rb b/test/crud_controller_base.rb index d24c71da..a237fd19 100644 --- a/test/crud_controller_base.rb +++ b/test/crud_controller_base.rb @@ -268,7 +268,7 @@ module CrudControllerBase end def form_params(action) - crud_params = @crud["#{action}_params".to_sym] + crud_params = @crud[:"#{action}_params"] if @crud[:form] { id: id_value, @crud[:form] => crud_params } else diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index b62aed67..006a49df 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -13,7 +13,7 @@ class IssuesControllerTest < Additionals::ControllerTest :workflows, :custom_fields, :custom_values, :custom_fields_projects, :custom_fields_trackers, :time_entries, - :watchers, + :watchers, :attachments, :journals, :journal_details, :repositories, :changesets, :queries @@ -219,4 +219,22 @@ class IssuesControllerTest < Additionals::ControllerTest assert_select 'h4.note-header .badge-author', count: 0 end end + + def test_show_attachments + with_plugin_settings 'additionals', issue_hide_max_attachments: 10 do + get :show, params: { id: 3 } + + assert_response :success + assert_select 'fieldset.hide-attachments', count: 0 + end + end + + def test_show_attachments_as_hidden + with_plugin_settings 'additionals', issue_hide_max_attachments: 0 do + get :show, params: { id: 3 } + + assert_response :success + assert_select 'fieldset.hide-attachments', count: 1 + end + end end