Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Show forum module although there are no forums

Henriette Dinger35cb01b9feb6
diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb
index 5ee64e20445..e4b320b4ea9 100644
--- a/app/controllers/forums_controller.rb
+++ b/app/controllers/forums_controller.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
diff --git a/app/views/forums/index.html.erb b/app/views/forums/index.html.erb
index 017d3219743..345370933b9 100644
--- a/app/views/forums/index.html.erb
+++ b/app/views/forums/index.html.erb
@@ -40,116 +40,123 @@ See docs/COPYRIGHT.rdoc for more details.
</li>
<% end %>
<% end %>
-<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) %>
+
+<% if @forums.empty? %>
+ <%= no_results_box(action_url: new_project_forum_path(@project),
+ display_action: true,
+ custom_action_text: t('forums.no_results_content_text')) %>
+<% else %>
+ <div class="generic-table--container">
+ <div class="generic-table--results-container">
+ <table class="generic-table boards">
+ <colgroup>
<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>
- </th>
- <th>
- <div class="generic-table--sort-header-outer">
- <div class="generic-table--sort-header">
- <span>
- <%= t(:label_topic_plural) %>
- </span>
+ <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_message_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_last) %>
- </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>
- <% if User.current.allowed_to?(:manage_forums, @project) %>
+ </th>
<th>
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
- <span>
- <%=l(:button_sort)%>
- </span>
+ <span>
+ <%= t(:label_message_last) %>
+ </span>
</div>
</div>
</th>
- <th><div class="generic-table--empty-header"></div></th>
- <% end %>
- </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>
<% 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 %>
+ <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>
+ </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 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><%= 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>
- <% end %>
- </tr>
- <% end %>
- </tbody>
- </table>
+ <% 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 %>
diff --git a/config/initializers/menus.rb b/config/initializers/menus.rb
index 7681b9cbc16..a6c8fdd5405 100644
--- a/config/initializers/menus.rb
+++ b/config/initializers/menus.rb
@@ -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'
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 615901b2b1b..ed1efbaece8 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -125,6 +125,7 @@ en:
For more information, visit <a href="%{link}">the Net::LDAP documentation</a>.
forums:
+ no_results_content_text: Create a new forum
show:
no_results_title_text: There are currently no posts for the forum.