From 5601bfbb5bff25fcbf2059a15f9c25c615857ae0 Mon Sep 17 00:00:00 2001 From: Yalaeddin Date: Mon, 15 Apr 2024 12:06:54 +0200 Subject: [PATCH 1/2] Masquer les membres sur la page d'apercu d'un projet --- .github/workflows/4_2_11.yml | 2 ++ .github/workflows/5_1_2.yml | 2 ++ app/overrides/projects/show.rb | 8 +++++ ...ine_plugin_tiny_features_settings.html.erb | 6 ++++ config/locales/en.yml | 1 + config/locales/fr.yml | 1 + spec/system/projects_spec.rb | 36 +++++++++++++++++++ .../settings_redmine_tiny_features_spec.rb | 17 +++++++++ 8 files changed, 73 insertions(+) create mode 100644 app/overrides/projects/show.rb create mode 100644 spec/system/projects_spec.rb diff --git a/.github/workflows/4_2_11.yml b/.github/workflows/4_2_11.yml index ab352be..7457195 100644 --- a/.github/workflows/4_2_11.yml +++ b/.github/workflows/4_2_11.yml @@ -89,6 +89,8 @@ jobs: - name: Prepare Redmine source working-directory: redmine run: | + # TODO Remove the following line when https://www.redmine.org/issues/40551 is fixed + sed -i -e 's/.*mocha.*/ gem "mocha", "2.1.0"/' Gemfile # Fix core tests not compatible with Mocha 2.2.0 sed -i '/rubocop/d' Gemfile rm -f .rubocop* cp plugins/redmine_base_rspec/spec/support/database-${{ matrix.db }}.yml config/database.yml diff --git a/.github/workflows/5_1_2.yml b/.github/workflows/5_1_2.yml index 62e5c2e..087ba7e 100644 --- a/.github/workflows/5_1_2.yml +++ b/.github/workflows/5_1_2.yml @@ -90,6 +90,8 @@ jobs: working-directory: redmine run: | rm -f test/integration/routing/plugins_test.rb # Fix routing tests # TODO Remove this line when https://www.redmine.org/issues/38707 is fixed + # TODO Remove the following line when https://www.redmine.org/issues/40551 is fixed + sed -i -e 's/.*mocha.*/ gem "mocha", "2.1.0"/' Gemfile # Fix core tests not compatible with Mocha 2.2.0 sed -i '/rubocop/d' Gemfile rm -f .rubocop* cp plugins/redmine_base_rspec/spec/support/database-${{ matrix.db }}.yml config/database.yml diff --git a/app/overrides/projects/show.rb b/app/overrides/projects/show.rb new file mode 100644 index 0000000..8960edc --- /dev/null +++ b/app/overrides/projects/show.rb @@ -0,0 +1,8 @@ +Deface::Override.new :virtual_path => 'projects/show', + :name => 'hide-members-on-project-overview', + :surround => "erb[loud]:contains('members_box')", + :text => <<-EOS +<% if !Setting["plugin_redmine_tiny_features"]["hide_members_section_in_overview_project"].present? %> + <%= render_original %> +<% end %> +EOS \ No newline at end of file diff --git a/app/views/settings/_redmine_plugin_tiny_features_settings.html.erb b/app/views/settings/_redmine_plugin_tiny_features_settings.html.erb index f839e98..c50febc 100644 --- a/app/views/settings/_redmine_plugin_tiny_features_settings.html.erb +++ b/app/views/settings/_redmine_plugin_tiny_features_settings.html.erb @@ -73,6 +73,12 @@ <%= l("setting_load_issue_edit_form_asynchronously") %> <% end %>

+

+ <%= label_tag '', { style: 'width: auto;' } do %> + <%= check_box_tag "settings[hide_members_section_in_overview_project]", '1', Setting["plugin_redmine_tiny_features"]["hide_members_section_in_overview_project"] %> + <%= l("enable_members_in_overview_project") %> + <% end %> +

<%= javascript_tag do %> $(function() { diff --git a/config/locales/en.yml b/config/locales/en.yml index 76c348d..3220ca2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -40,3 +40,4 @@ en: label_issue_display_by_priority: "Colorization According to priority" label_issue_display_by_status: "Colorization According to status" field_show_pagination_at_top_results: "Show pagination links at the top of issues results" + enable_members_in_overview_project: "Hides members section on project overview page" diff --git a/config/locales/fr.yml b/config/locales/fr.yml index f0d80c2..41e41c4 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -40,3 +40,4 @@ fr: label_issue_display_by_priority: "Colorisation par priorité" label_issue_display_by_status: "Colorisation par statut" field_show_pagination_at_top_results: "Afficher les liens de pagination en haut des résultats des demandes" + enable_members_in_overview_project: "Masquer la section des membres sur la page d'apercu d'un projet" diff --git a/spec/system/projects_spec.rb b/spec/system/projects_spec.rb new file mode 100644 index 0000000..bbff36a --- /dev/null +++ b/spec/system/projects_spec.rb @@ -0,0 +1,36 @@ +require "spec_helper" + +RSpec.describe "ProjectController", type: :system do + + fixtures :users, :user_preferences, :projects, :members, :roles, :member_roles + + before do + log_user('admin', 'admin') + end + + describe "Option to hide/show the members section on the overview page of each project" do + let(:project_test) { Project.find(1) } + + it "Should hide members section when the option is activated" do + + Setting.send "plugin_redmine_tiny_features=", { + "hide_members_section_in_overview_project" => "1", + } + + visit "/projects/#{project_test.identifier}" + expect(page).to_not have_selector('div.members') + + end + + it "Should display members section when the option is deactivated" do + + Setting.send "plugin_redmine_tiny_features=", { + "hide_members_section_in_overview_project" => "", + } + + visit "/projects/#{project_test.identifier}" + expect(page).to have_selector('div.members') + end + + end +end diff --git a/spec/system/settings_redmine_tiny_features_spec.rb b/spec/system/settings_redmine_tiny_features_spec.rb index 1aafa1e..066733b 100644 --- a/spec/system/settings_redmine_tiny_features_spec.rb +++ b/spec/system/settings_redmine_tiny_features_spec.rb @@ -37,4 +37,21 @@ "load_issue_edit_form_asynchronously" => "0", } end + + it "activates the option hide_members_section_in_overview_project" do + log_user('admin', 'admin') + + visit 'settings/plugin/redmine_tiny_features' + + find("input[name='settings[hide_members_section_in_overview_project]']").click + find("input[name='commit']").click + + expect(Setting["plugin_redmine_tiny_features"]["hide_members_section_in_overview_project"]).to eq '1' + Setting.send "plugin_redmine_tiny_features=", { + "warning_message_on_closed_issues" => "1", + "default_open_status" => "2", + "default_project" => "1", + "hide_members_section_in_overview_project" => "0", + } + end end From d9a918eb25c45dac9cd7d295765ed59b36429f34 Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Thu, 18 Apr 2024 16:36:56 +0200 Subject: [PATCH 2/2] Complete Readme with latest feature and cleanup code and translations --- .github/workflows/master.yml | 2 ++ README.md | 1 + app/overrides/projects/show.rb | 16 ++++++++-------- ...edmine_plugin_tiny_features_settings.html.erb | 5 +++-- config/locales/en.yml | 2 +- config/locales/fr.yml | 2 +- spec/system/projects_spec.rb | 8 ++++---- .../settings_redmine_tiny_features_spec.rb | 8 ++++---- 8 files changed, 24 insertions(+), 20 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 13263ae..d7eff47 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -89,6 +89,8 @@ jobs: - name: Prepare Redmine source working-directory: redmine run: | + # TODO Remove the following line when https://www.redmine.org/issues/40551 is fixed + sed -i -e 's/.*mocha.*/ gem "mocha", "2.1.0"/' Gemfile # Fix core tests not compatible with Mocha 2.2.0 sed -i '/rubocop/d' Gemfile rm -f .rubocop* cp plugins/redmine_base_rspec/spec/support/database-${{ matrix.db }}.yml config/database.yml diff --git a/README.md b/README.md index 4752e73..f6fac68 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ Here is a complete list of the features: * Include the 'notes' field in workflows, providing the capability to **require notes** when updating an issue * Issues filter: **sort group-by options alphabetically** * PDF exports: add **links to attached files in generated PDF**" +* Projects overview: add an option to **hide members section** ## Test status diff --git a/app/overrides/projects/show.rb b/app/overrides/projects/show.rb index 8960edc..feec6a9 100644 --- a/app/overrides/projects/show.rb +++ b/app/overrides/projects/show.rb @@ -1,8 +1,8 @@ -Deface::Override.new :virtual_path => 'projects/show', - :name => 'hide-members-on-project-overview', - :surround => "erb[loud]:contains('members_box')", - :text => <<-EOS -<% if !Setting["plugin_redmine_tiny_features"]["hide_members_section_in_overview_project"].present? %> - <%= render_original %> -<% end %> -EOS \ No newline at end of file +Deface::Override.new :virtual_path => 'projects/show', + :name => 'hide-members-on-project-overview', + :surround => "erb[loud]:contains('members_box')", + :text => <<-EOS + <% if !Setting["plugin_redmine_tiny_features"]["hide_members_section_on_project_overview"].present? %> + <%= render_original %> + <% end %> + EOS diff --git a/app/views/settings/_redmine_plugin_tiny_features_settings.html.erb b/app/views/settings/_redmine_plugin_tiny_features_settings.html.erb index c50febc..054e0fe 100644 --- a/app/views/settings/_redmine_plugin_tiny_features_settings.html.erb +++ b/app/views/settings/_redmine_plugin_tiny_features_settings.html.erb @@ -73,10 +73,11 @@ <%= l("setting_load_issue_edit_form_asynchronously") %> <% end %>

+

<%= label_tag '', { style: 'width: auto;' } do %> - <%= check_box_tag "settings[hide_members_section_in_overview_project]", '1', Setting["plugin_redmine_tiny_features"]["hide_members_section_in_overview_project"] %> - <%= l("enable_members_in_overview_project") %> + <%= check_box_tag "settings[hide_members_section_on_project_overview]", '1', Setting["plugin_redmine_tiny_features"]["hide_members_section_on_project_overview"] %> + <%= l("hide_members_on_project_overview") %> <% end %>

diff --git a/config/locales/en.yml b/config/locales/en.yml index 3220ca2..bd407f3 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -40,4 +40,4 @@ en: label_issue_display_by_priority: "Colorization According to priority" label_issue_display_by_status: "Colorization According to status" field_show_pagination_at_top_results: "Show pagination links at the top of issues results" - enable_members_in_overview_project: "Hides members section on project overview page" + hide_members_on_project_overview: "Hide members section on project overview page" diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 41e41c4..ad3df4b 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -40,4 +40,4 @@ fr: label_issue_display_by_priority: "Colorisation par priorité" label_issue_display_by_status: "Colorisation par statut" field_show_pagination_at_top_results: "Afficher les liens de pagination en haut des résultats des demandes" - enable_members_in_overview_project: "Masquer la section des membres sur la page d'apercu d'un projet" + hide_members_on_project_overview: "Masquer la section des membres sur la page d'aperçu des projets" diff --git a/spec/system/projects_spec.rb b/spec/system/projects_spec.rb index bbff36a..548fdc0 100644 --- a/spec/system/projects_spec.rb +++ b/spec/system/projects_spec.rb @@ -11,10 +11,10 @@ describe "Option to hide/show the members section on the overview page of each project" do let(:project_test) { Project.find(1) } - it "Should hide members section when the option is activated" do + it "hides members section when the option is activated" do Setting.send "plugin_redmine_tiny_features=", { - "hide_members_section_in_overview_project" => "1", + "hide_members_section_on_project_overview" => "1", } visit "/projects/#{project_test.identifier}" @@ -22,10 +22,10 @@ end - it "Should display members section when the option is deactivated" do + it "displays members section when the option is deactivated" do Setting.send "plugin_redmine_tiny_features=", { - "hide_members_section_in_overview_project" => "", + "hide_members_section_on_project_overview" => "", } visit "/projects/#{project_test.identifier}" diff --git a/spec/system/settings_redmine_tiny_features_spec.rb b/spec/system/settings_redmine_tiny_features_spec.rb index 066733b..8387075 100644 --- a/spec/system/settings_redmine_tiny_features_spec.rb +++ b/spec/system/settings_redmine_tiny_features_spec.rb @@ -38,20 +38,20 @@ } end - it "activates the option hide_members_section_in_overview_project" do + it "activates the option hide_members_section_on_project_overview" do log_user('admin', 'admin') visit 'settings/plugin/redmine_tiny_features' - find("input[name='settings[hide_members_section_in_overview_project]']").click + find("input[name='settings[hide_members_section_on_project_overview]']").click find("input[name='commit']").click - expect(Setting["plugin_redmine_tiny_features"]["hide_members_section_in_overview_project"]).to eq '1' + expect(Setting["plugin_redmine_tiny_features"]["hide_members_section_on_project_overview"]).to eq '1' Setting.send "plugin_redmine_tiny_features=", { "warning_message_on_closed_issues" => "1", "default_open_status" => "2", "default_project" => "1", - "hide_members_section_in_overview_project" => "0", + "hide_members_section_on_project_overview" => "0", } end end