Merge pull request #7948 from opf/feature/move-forum-from-settings-to-forums-module

[31905] Remove tab "Forum" from project settings
pull/7951/head
Henriette Dinger 5 years ago committed by GitHub
commit 48f1650766
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      app/controllers/forums_controller.rb
  2. 6
      app/helpers/projects_helper.rb
  3. 2
      app/views/forums/edit.html.erb
  4. 187
      app/views/forums/index.html.erb
  5. 136
      app/views/project_settings/_forums.html.erb
  6. 1
      config/initializers/menus.rb
  7. 28
      spec/controllers/forums_controller_spec.rb
  8. 1
      spec/features/forums/attachment_upload_spec.rb
  9. 4
      spec/features/forums/message_spec.rb
  10. 4
      spec/features/forums/sticky_spec.rb

@ -41,12 +41,6 @@ class ForumsController < ApplicationController
def index
@forums = @project.forums
render_404 if @forums.empty?
# show the forum if there is only one
if @forums.size == 1
@forum = @forums.first
show
end
end
current_menu_item [:index, :show] do
@ -96,7 +90,7 @@ class ForumsController < ApplicationController
def create
if @forum.save
flash[:notice] = l(:notice_successful_create)
redirect_to_settings_in_projects
redirect_to action: 'index'
else
render :new
end
@ -107,7 +101,7 @@ class ForumsController < ApplicationController
def update
if @forum.update(permitted_params.forum)
flash[:notice] = l(:notice_successful_update)
redirect_to_settings_in_projects
redirect_to action: 'index'
else
render :edit
end
@ -120,21 +114,17 @@ class ForumsController < ApplicationController
flash.now[:error] = t('forum_could_not_be_saved')
render action: 'edit'
end
redirect_to_settings_in_projects(@forum.project_id)
redirect_to action: 'index'
end
def destroy
@forum.destroy
flash[:notice] = l(:notice_successful_delete)
redirect_to_settings_in_projects
redirect_to action: 'index'
end
private
def redirect_to_settings_in_projects(id = @project)
redirect_to controller: '/project_settings', action: 'show', id: id, tab: 'forums'
end
def find_forum
@forum = @project.forums.find(params[:id])
rescue ActiveRecord::RecordNotFound

@ -79,12 +79,6 @@ module ProjectsHelper
partial: 'repositories/settings',
label: :label_repository
},
{
name: 'forums',
action: :manage_forums,
partial: 'project_settings/forums',
label: :label_forum_plural
},
{
name: 'activities',
action: :manage_project_activities,

@ -31,5 +31,5 @@ See docs/COPYRIGHT.rdoc for more details.
<%= labelled_tabular_form_for [@project, @forum] do |f| %>
<%= render partial: 'form', locals: { f: f } %>
<%= f.button t(:button_save), class: 'button -highlight -with-icon icon-checkmark' %>
<%= link_to t(:button_cancel), project_forum_path(@project, @forum), class: 'button -with-icon icon-cancel' %>
<%= link_to t(:button_cancel), project_forums_path(@project), class: 'button -with-icon icon-cancel' %>
<% end %>

@ -27,79 +27,134 @@ See docs/COPYRIGHT.rdoc for more details.
++#%>
<% html_title t(:label_forum_plural) %>
<%= toolbar title: t(:label_forum_plural) %>
<div class="generic-table--container">
<div class="generic-table--results-container">
<table class="generic-table boards">
<colgroup>
<col highlight-col>
<col highlight-col>
<col highlight-col>
<col highlight-col>
</colgroup>
<thead>
<tr>
<th>
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
<span>
<%= Forum.name.humanize %>
</span>
<%= toolbar title: t(:label_forum_plural) do %>
<% if User.current.allowed_to?(:manage_forums, @project) %>
<li class="toolbar-item">
<%= link_to({ controller: '/forums', action: 'new', project_id: @project },
{ aria: { label: t(:label_forum_new) },
title: t(:label_forum_new),
class: 'button -highlight' }) do %>
<%= op_icon('button--icon icon-add') %>
<span class="button--text"><%= t('activerecord.models.forum') %></span>
<% end %>
</li>
<% end %>
<% end %>
<% if @forums.empty? %>
<%= no_results_box(action_url: new_project_forum_path(@project)) %>
<% else %>
<div class="generic-table--container">
<div class="generic-table--results-container">
<table class="generic-table boards">
<colgroup>
<col highlight-col>
<col highlight-col>
<col highlight-col>
<col highlight-col>
<% if User.current.allowed_to?(:manage_forums, @project) %>
<col highlight-col>
<col>
<% end %>
</colgroup>
<thead>
<tr>
<th>
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
<span>
<%= Forum.name.humanize %>
</span>
</div>
</div>
</div>
</th>
<th>
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
<span>
<%= t(:label_topic_plural) %>
</span>
</th>
<th>
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
<span>
<%= t(:label_topic_plural) %>
</span>
</div>
</div>
</div>
</th>
<th>
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
<span>
<%= t(:label_message_plural) %>
</span>
</th>
<th>
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
<span>
<%= t(:label_message_plural) %>
</span>
</div>
</div>
</div>
</th>
<th>
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
<span>
<%= t(:label_message_last) %>
</span>
</th>
<th>
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
<span>
<%= t(:label_message_last) %>
</span>
</div>
</div>
</div>
</th>
</tr>
</thead>
<tbody>
<% for forum in @forums %>
<tr>
<td class="-no-ellipsis">
<%= link_to h(forum.name), { action: 'show', id: forum }, class: "forum" %><br />
<%= format_text(forum.description) %>
</td>
<td><%= forum.topics_count %></td>
<td><%= forum.messages_count %></td>
<td>
<% if forum.last_message %>
<% forum.last_message %>
<%= authoring forum.last_message.created_on, forum.last_message.author %><br />
<%= link_to_message forum.last_message, no_root: true %>
<% end %>
</td>
</th>
<% if User.current.allowed_to?(:manage_forums, @project) %>
<th>
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
<span>
<%=l(:button_sort)%>
</span>
</div>
</div>
</th>
<th><div class="generic-table--empty-header"></div></th>
<% end %>
</tr>
<% end %>
</tbody>
</table>
</thead>
<tbody>
<% for forum in @forums %>
<tr>
<td class="-no-ellipsis">
<%= link_to h(forum.name), { action: 'show', id: forum }, class: "forum" %><br />
<%= format_text(forum.description) %>
</td>
<td><%= forum.topics_count %></td>
<td><%= forum.messages_count %></td>
<td>
<% if forum.last_message %>
<% forum.last_message %>
<%= authoring forum.last_message.created_on, forum.last_message.author %><br />
<%= link_to_message forum.last_message, no_root: true %>
<% end %>
</td>
<% if User.current.allowed_to?(:manage_forums, @project) %>
<td class="small-icons">
<% if authorize_for 'forums', 'edit' %>
<%= reorder_links 'forum', controller: '/forums',
action: 'move',
project_id: @project,
id: forum %>
<% end %>
</td>
<td class="buttons">
<%= link_to_if_authorized '',
{ controller: '/forums', action: 'edit', project_id: @project, id: forum },
class: 'icon icon-edit',
title: t(:button_edit) %>
<%= link_to_if_authorized '',
{ controller: '/forums', action: 'destroy', project_id: @project, id: forum },
data: { confirm: l(:text_are_you_sure) },
method: :delete,
class: 'icon icon-delete',
title: t(:button_delete) %>
</td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
<% end %>
<%= other_formats_links do |f| %>
<%= f.link_to 'Atom', url: { controller: '/activities', action: 'index', id: @project, show_messages: 1, key: User.current.rss_key } %>
<% end %>

@ -1,136 +0,0 @@
<%#-- copyright
OpenProject is a project management system.
Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 3.
OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
Copyright (C) 2006-2017 Jean-Philippe Lang
Copyright (C) 2010-2013 the ChiliProject Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
See docs/COPYRIGHT.rdoc for more details.
++#%>
<% if @project.forums.any? %>
<fieldset class="form--fieldset">
<legend class="form--fieldset-legend">
<%= l(:label_available_project_forums) %>
</legend>
<div class="form--fieldset-control">
<span class="form--fieldset-control-container">
<%= link_to_if_authorized({ controller: '/forums', action: 'new', project_id: @project },
{ aria: { label: t(:label_forum_new) },
title: t(:label_forum_new) }) do %>
<%= op_icon('icon-add icon-small') %>
<span><%= t('activerecord.models.forum') %></span>
<% end %>
</span>
</div>
<div class="generic-table--container">
<div class="generic-table--results-container">
<table class="generic-table">
<colgroup>
<col highlight-col>
<col highlight-col>
<col highlight-col>
<col>
</colgroup>
<thead>
<tr>
<th>
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
<span>
<%= Forum.model_name.human %>
</span>
</div>
</div>
</th>
<th>
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
<span>
<%= Forum.human_attribute_name(:description) %>
</span>
</div>
</div>
</th>
<th>
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
<span>
<%=l(:button_sort)%>
</span>
</div>
</div>
</th>
<th><div class="generic-table--empty-header"></div></th>
</tr>
</thead>
<tbody>
<% @project.forums.each do |forum|
next if forum.new_record? %>
<tr>
<td><%=h forum.name %></td>
<td><%= format_text(forum.description) %></td>
<td class="small-icons">
<% if authorize_for 'forums', 'edit' %>
<%= reorder_links 'forum', controller: '/forums',
action: 'move',
project_id: @project,
id: forum %>
<% end %>
</td>
<td class="buttons">
<%= link_to_if_authorized '',
{ controller: '/forums', action: 'edit', project_id: @project, id: forum },
class: 'icon icon-edit',
title: t(:button_edit) %>
<%= link_to_if_authorized '',
{ controller: '/forums', action: 'destroy', project_id: @project, id: forum },
data: { confirm: l(:text_are_you_sure) },
method: :delete,
class: 'icon icon-delete',
title: t(:button_delete) %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
<% if @project.forums.any? %>
<div class="generic-table--action-buttons">
<%= link_to_if_authorized({ controller: '/forums', action: 'new', project_id: @project },
{ class: 'button -alt-highlight',
aria: {label: t(:label_forum_new)},
title: t(:label_forum_new)}) do %>
<%= op_icon('button--icon icon-add') %>
<span class="button--text"><%= t('activerecord.models.forum') %></span>
<% end %>
</div>
<% end %>
<% else %>
<%= no_results_box action_url: new_project_forum_path(@project),
display_action: authorize_for('forums', 'new'),
custom_title: t('projects.settings.forums.no_results_title_text'),
custom_action_text: t('projects.settings.forums.no_results_content_text') %>
<% end %>
</fieldset>

@ -336,7 +336,6 @@ Redmine::MenuManager.map :project_menu do |menu|
menu.push :forums,
{ controller: '/forums', action: 'index', id: nil },
param: :project_id,
if: Proc.new { |p| p.forums.any? },
caption: :label_forum_plural,
icon: 'icon2 icon-ticket-note'

@ -49,7 +49,7 @@ describe ForumsController, type: :controller do
end
expect(response).to be_successful
expect(response).to render_template 'forums/show'
expect(response).to render_template 'forums/index'
expect(assigns(:forums)).to be_present
expect(assigns(:project)).to be_present
end
@ -113,12 +113,11 @@ describe ForumsController, type: :controller do
end
end
it 'should redirect to the settings page if successful' do
it 'should redirect to the index page if successful' do
expect(response)
.to redirect_to controller: '/project_settings',
action: 'show',
id: project,
tab: 'forums'
.to redirect_to controller: '/forums',
action: 'index',
project_id: project.id
end
it 'have a successful creation flash' do
@ -178,7 +177,6 @@ describe ForumsController, type: :controller do
describe '#higher' do
let(:move_to) { 'higher' }
let(:redirect_url) { "http://test.host/projects/#{project.id}/settings/forums" }
before do
post 'move', params: { id: forum_2.id,
@ -190,7 +188,12 @@ describe ForumsController, type: :controller do
it do expect(response).to be_redirect end
it do expect(response).to redirect_to(redirect_url) end
it do
expect(response)
.to redirect_to controller: '/forums',
action: 'index',
project_id: project.id
end
end
end
@ -213,11 +216,10 @@ describe ForumsController, type: :controller do
end
end
it 'should redirect to the settings page if successful' do
expect(response).to redirect_to controller: '/project_settings',
action: 'show',
id: forum.project,
tab: 'forums'
it 'should redirect to the index page if successful' do
expect(response).to redirect_to controller: '/forums',
action: 'index',
project_id: forum.project_id
end
it 'have a successful update flash' do

@ -52,6 +52,7 @@ describe 'Upload attachment to forum message', js: true do
it 'can upload an image to new and existing messages via drag & drop' do
index_page.visit!
click_link forum.name
create_page = index_page.click_create_message
create_page.set_subject 'A new message'

@ -51,6 +51,7 @@ describe 'messages', type: :feature, js: true do
scenario 'adding, checking replies, replying' do
index_page.visit!
click_link forum.name
create_page = index_page.click_create_message
@ -68,6 +69,7 @@ describe 'messages', type: :feature, js: true do
show_page.expect_content('There is no message here')
index_page.visit!
click_link forum.name
index_page.expect_listed(subject: 'The message is',
replies: 0)
@ -86,6 +88,7 @@ describe 'messages', type: :feature, js: true do
content: 'But, but there should be one')
index_page.visit!
click_link forum.name
index_page.expect_listed(subject: 'The message is',
replies: 1,
@ -109,6 +112,7 @@ describe 'messages', type: :feature, js: true do
expect(page).to have_selector('blockquote', text: 'But, but there should be one')
index_page.visit!
click_link forum.name
index_page.expect_listed(subject: 'The message is',
replies: 2,
last_message: 'And now to something completely different')

@ -56,7 +56,7 @@ describe 'sticky messages', type: :feature do
before do
login_as user
visit project_forums_path(forum.project)
visit project_forum_path(forum.project, forum)
end
def expect_order_of_messages(*order)
@ -75,7 +75,7 @@ describe 'sticky messages', type: :feature do
check('message[sticky]')
click_button('Save')
visit project_forums_path(forum.project)
visit project_forum_path(forum.project, forum)
expect_order_of_messages(message2, message1, message3)
end

Loading…
Cancel
Save