Patch #44660 » 04_action_menus.patch
| app/views/boards/show.html.erb | ||
|---|---|---|
|
{:controller => 'projects', :action => 'settings', :id => @project, :tab => 'boards'},
|
||
|
:class => 'icon icon-settings' if User.current.allowed_to?(:manage_boards, @project) %>
|
||
|
<%= call_hook(:view_boards_show_contextual, {:board => @board, :project => @project}) %>
|
||
|
</div>
|
||
|
<div id="add-message" style="display:none;">
|
||
| app/views/context_menus/issues.html.erb | ||
|---|---|---|
|
:method => :delete, :data => {:confirm => issues_destroy_confirmation_message(@issues)}, :class => 'icon icon-del', :disabled => !@can[:delete] %></li>
|
||
|
<% end %>
|
||
|
<%= render_object_menu_items(:issue_context_menu, @issues, @project, list: true) %>
|
||
|
<%= call_hook(:view_issues_context_menu_end, {:issues => @issues, :can => @can, :back => @back }) %>
|
||
|
</ul>
|
||
| app/views/documents/index.html.erb | ||
|---|---|---|
|
<div class="contextual">
|
||
|
<%= link_to sprite_icon('add', l(:label_document_new)), new_project_document_path(@project), :class => 'icon icon-add',
|
||
|
:onclick => 'showAndScrollTo("add-document", "document_title"); return false;' if User.current.allowed_to?(:add_documents, @project) %>
|
||
|
<%= call_hook(:view_documents_index_contextual, {:project => @project}) %>
|
||
|
</div>
|
||
|
<div id="add-document" style="display:none;">
|
||
| app/views/documents/show.html.erb | ||
|---|---|---|
|
<% if User.current.allowed_to?(:delete_documents, @project) %>
|
||
|
<%= delete_link document_path(@document) %>
|
||
|
<% end %>
|
||
|
<%= call_hook(:view_documents_show_contextual, {:document => @document, :project => @project}) %>
|
||
|
</div>
|
||
|
<h2><%= @document.title %></h2>
|
||
| app/views/groups/show.html.erb | ||
|---|---|---|
|
<div class="contextual">
|
||
|
<%= link_to(sprite_icon('edit', l(:button_edit)), edit_group_path(@group), :class => 'icon icon-edit') if User.current.admin? %>
|
||
|
<%= call_hook(:view_groups_show_contextual, {:group => @group}) %>
|
||
|
</div>
|
||
|
<h2><%= @group.name %></h2>
|
||
| app/views/issues/_action_menu.html.erb | ||
|---|---|---|
|
<%= watcher_link(@issue, User.current) %>
|
||
|
<%= link_to sprite_icon('copy', l(:button_copy)), project_copy_issue_path(@project, @issue),
|
||
|
:class => 'icon icon-copy ' if User.current.allowed_to?(:copy_issues, @project) && Issue.allowed_target_projects.any? %>
|
||
|
<%= call_hook(:view_issues_show_contextual, {:issue => @issue, :project => @project}) %>
|
||
|
<%= actions_dropdown do %>
|
||
|
<%= copy_object_url_link(issue_url(@issue, only_path: false)) %>
|
||
|
<%= render_object_menu_items(:issue_actions, @issue, @project) %>
|
||
|
<%= link_to sprite_icon('del', l(:button_delete_object, object_name: l(:label_issue)).capitalize), issue_path(@issue),
|
||
|
:data => {:confirm => issues_destroy_confirmation_message(@issue)},
|
||
|
:method => :delete, :class => 'icon icon-del ' if @issue.deletable? %>
|
||
|
<%= call_hook(:view_issues_show_actions_menu, {:issue => @issue, :project => @project}) %>
|
||
|
<% end %>
|
||
|
</div>
|
||
| app/views/issues/index.html.erb | ||
|---|---|---|
|
<% if User.current.allowed_to?(:add_issues, @project, :global => true) && (@project.nil? || Issue.allowed_target_trackers(@project).any?) %>
|
||
|
<%= link_to sprite_icon('add', l(:label_issue_new)), _new_project_issue_path(@project), :class => 'icon icon-add new-issue' %>
|
||
|
<% end %>
|
||
|
<%= call_hook(:view_issues_index_contextual, {:project => @project, :query => @query}) %>
|
||
|
<%= actions_dropdown do %>
|
||
|
<% if @project %>
|
||
|
<%= link_to sprite_icon('summary', l(:field_summary)), project_issues_report_path(@project), :class => 'icon icon-stats' %>
|
||
| ... | ... | |
|
<%= link_to_if_authorized sprite_icon('settings', l(:label_settings)),
|
||
|
{:controller => 'projects', :action => 'settings', :id => @project, :tab => 'issues'},
|
||
|
:class => 'icon icon-settings' if User.current.allowed_to?(:edit_project, @project) %>
|
||
|
<%= call_hook(:view_issues_index_actions_menu, {:project => @project, :query => @query}) %>
|
||
|
<% end %>
|
||
|
</div>
|
||
| app/views/messages/show.html.erb | ||
|---|---|---|
|
:data => { :confirm => l(:text_are_you_sure) },
|
||
|
:class => 'icon icon-del'
|
||
|
) if @message.destroyable_by?(User.current) %>
|
||
|
<%= call_hook(:view_messages_show_contextual, {:topic => @topic, :message => @message, :project => @project}) %>
|
||
|
</div>
|
||
|
<h2><%= avatar(@topic.author) %><%= @topic.subject %></h2>
|
||
| app/views/news/index.html.erb | ||
|---|---|---|
|
:class => 'icon icon-add add-news-link',
|
||
|
:onclick => 'showAndScrollTo("add-news", "news_title"); return false;') if User.current.allowed_to?(:manage_news, @project, global: true) %>
|
||
|
<%= watcher_link(@project.enabled_module('news'), User.current) if @project && User.current.logged? %>
|
||
|
<%= call_hook(:view_news_index_contextual, {:project => @project}) %>
|
||
|
</div>
|
||
|
<div id="add-news" style="display:none;">
|
||
| app/views/news/show.html.erb | ||
|---|---|---|
|
:accesskey => accesskey(:edit),
|
||
|
:onclick => '$("#edit-news").show(); return false;') if User.current.allowed_to?(:manage_news, @project) %>
|
||
|
<%= delete_link news_path(@news) if User.current.allowed_to?(:manage_news, @project) %>
|
||
|
<%= call_hook(:view_news_show_contextual, {:news => @news, :project => @project}) %>
|
||
|
</div>
|
||
|
<h2><%= avatar(@news.author) %> <%=h @news.title %></h2>
|
||
| app/views/projects/index.html.erb | ||
|---|---|---|
|
<%= form_tag({}, :method => :get) do %>
|
||
|
<% end %>
|
||
|
<%= render_project_action_links %>
|
||
|
<%= call_hook(:view_projects_index_contextual, {:query => @query}) %>
|
||
|
</div>
|
||
|
<h2><%= @query.new_record? ? l(:label_project_plural) : @query.name %></h2>
|
||
| app/views/projects/show.html.erb | ||
|---|---|---|
|
<div class="contextual">
|
||
|
<%= bookmark_link @project %>
|
||
|
<%= call_hook(:view_projects_show_contextual, {:project => @project}) %>
|
||
|
<%= actions_dropdown do %>
|
||
|
<% if User.current.allowed_to?(:add_subprojects, @project) %>
|
||
|
<%= link_to sprite_icon('add', l(:label_subproject_new)), new_project_path(:parent_id => @project), :class => 'icon icon-add' %>
|
||
| ... | ... | |
|
<%= link_to_if_authorized sprite_icon('settings', l(:label_settings)),
|
||
|
{:controller => 'projects', :action => 'settings', :id => @project},
|
||
|
:class => 'icon icon-settings' if User.current.allowed_to?(:edit_project, @project) %>
|
||
|
<%= render_object_menu_items(:project_actions, @project, @project) %>
|
||
|
<%= call_hook(:view_projects_show_actions_menu, {:project => @project}) %>
|
||
|
<% end %>
|
||
|
</div>
|
||
| app/views/repositories/_navigation.html.erb | ||
|---|---|---|
|
<%= link_to sprite_icon('reload', l(:button_fetch_changesets)),
|
||
|
{:action => :fetch_changesets, :id => @project, :repository_id => @repository.identifier_param},
|
||
|
:class => 'icon icon-reload', :method => :post if User.current.allowed_to?(:manage_repository, @project) && !Setting.autofetch_changesets? %>
|
||
|
<%= call_hook(:view_repositories_navigation_actions_menu, {:repository => @repository, :project => @project}) %>
|
||
|
<% end %>
|
||
|
<%= form_tag({:action => controller.action_name,
|
||
| app/views/timelog/index.html.erb | ||
|---|---|---|
|
<%= link_to sprite_icon('time-add', l(:button_log_time)),
|
||
|
_new_time_entry_path(@project, @query.filtered_issue_id),
|
||
|
:class => 'icon icon-time-add' if User.current.allowed_to?(:log_time, @project, :global => true) %>
|
||
|
<%= call_hook(:view_timelog_index_contextual, {:project => @project, :query => @query}) %>
|
||
|
<%= actions_dropdown do %>
|
||
|
<% if User.current.allowed_to?(:import_time_entries, @project, :global => true) && User.current.allowed_to?(:log_time, @project, :global => true) %>
|
||
|
<%= link_to sprite_icon('import', l(:button_import)), new_time_entries_import_path(:project_id => @project), :class => 'icon icon-import' %>
|
||
| ... | ... | |
|
<%= link_to_if_authorized sprite_icon('settings', l(:label_settings)),
|
||
|
{:controller => 'projects', :action => 'settings', :id => @project, :tab => 'activities'},
|
||
|
:class => 'icon icon-settings' if User.current.allowed_to?(:manage_project_activities, @project) %>
|
||
|
<%= call_hook(:view_timelog_index_actions_menu, {:project => @project, :query => @query}) %>
|
||
|
<% end %>
|
||
|
</div>
|
||
| app/views/users/index.html.erb | ||
|---|---|---|
|
<div class="contextual">
|
||
|
<%= link_to sprite_icon('add', l(:label_user_new)), new_user_path, :class => 'icon icon-add' %>
|
||
|
<%= call_hook(:view_users_index_contextual, {:query => @query}) %>
|
||
|
<%= actions_dropdown do %>
|
||
|
<% if User.current.allowed_to?(:import_users, nil, :global => true) %>
|
||
|
<%= link_to sprite_icon('import', l(:button_import)), new_users_import_path, :class => 'icon icon-import' %>
|
||
|
<% end %>
|
||
|
<%= call_hook(:view_users_index_actions_menu, {:query => @query}) %>
|
||
|
<% end %>
|
||
|
</div>
|
||
| app/views/users/show.html.erb | ||
|---|---|---|
|
<div class="contextual">
|
||
|
<%= link_to(sprite_icon('edit', l(:button_edit)), edit_user_path(@user), :class => 'icon icon-edit') if User.current.admin? && @user.logged? %>
|
||
|
<%= render_object_menu_items(:user_actions, @user) %>
|
||
|
<%= call_hook(:view_users_show_contextual, {:user => @user}) %>
|
||
|
</div>
|
||
|
<h2><%= avatar_edit_link(@user, :size => "50") %> <%= @user.name %></h2>
|
||
| app/views/versions/index.html.erb | ||
|---|---|---|
|
<div class="contextual">
|
||
|
<%= link_to(sprite_icon('add', l(:label_version_new)), new_project_version_path(@project),
|
||
|
:class => 'icon icon-add') if User.current.allowed_to?(:manage_versions, @project) %>
|
||
|
<%= call_hook(:view_versions_index_contextual, {:project => @project}) %>
|
||
|
<%= actions_dropdown do %>
|
||
|
<%= link_to_if_authorized sprite_icon('settings', l(:label_settings)),
|
||
|
{:controller => 'projects', :action => 'settings', :id => @project, :tab => 'versions'},
|
||
|
:class => 'icon icon-settings' if User.current.allowed_to?(:manage_versions, @project) %>
|
||
|
<%= call_hook(:view_versions_index_actions_menu, {:project => @project}) %>
|
||
|
<% end %>
|
||
|
</div>
|
||
| app/views/versions/show.html.erb | ||
|---|---|---|
|
<%= link_to_if_authorized(sprite_icon('edit', l(:button_edit_associated_wikipage, :page_title => @version.wiki_page_title)), { :controller => 'wiki', :action => 'edit', :project_id => @version.project, :id => Wiki.titleize(@version.wiki_page_title)}, :class => 'icon icon-edit') unless @version.wiki_page_title.blank? || @version.project.wiki.nil? %>
|
||
|
<%= delete_link version_path(@version, :back_url => url_for(:controller => 'versions', :action => 'index', :project_id => @version.project)) if User.current.allowed_to?(:manage_versions, @version.project) %>
|
||
|
<%= link_to_new_issue(@version, @project) %>
|
||
|
<%= render_object_menu_items(:version_actions, @version, @version.project) %>
|
||
|
<%= call_hook(:view_versions_show_contextual, { :version => @version, :project => @project }) %>
|
||
|
</div>
|
||
| app/views/wiki/show.html.erb | ||
|---|---|---|
|
<% end %>
|
||
|
<% end %>
|
||
|
<%= call_hook(:view_wiki_show_contextual, {:page => @page, :project => @project}) %>
|
||
|
<%= actions_dropdown do %>
|
||
|
<%= link_to_if_authorized(sprite_icon('history', l(:label_history)), { :action => 'history', :id => @page.title}, :class => 'icon icon-history') %>
|
||
| ... | ... | |
|
<% if User.current.allowed_to?(:edit_wiki_pages, @project) %>
|
||
|
<%= link_to sprite_icon('add', l(:label_wiki_page_new)), new_project_wiki_page_path(@project, :parent => @page.title), :remote => true, :class => 'icon icon-add' %>
|
||
|
<% end %>
|
||
|
<%= call_hook(:view_wiki_show_actions_menu, {:page => @page, :project => @project}) %>
|
||
|
<% end %>
|
||
|
</div>
|
||
| doc/HOOKS | ||
|---|---|---|
|
Context: -
|
||
|
Called in: app/views/admin/projects.html.erb
|
||
|
view_boards_show_contextual
|
||
|
Since: 7.1.0
|
||
|
Context: :board, :project
|
||
|
Called in: app/views/boards/show.html.erb
|
||
|
view_calendars_show_bottom
|
||
|
Since: -
|
||
|
Context: :year, :month, :project, :query
|
||
| ... | ... | |
|
Context: :custom_field, :form
|
||
|
Called in: app/views/custom_fields/_form.html.erb
|
||
|
view_documents_index_contextual
|
||
|
Since: 7.1.0
|
||
|
Context: :project
|
||
|
Called in: app/views/documents/index.html.erb
|
||
|
view_documents_show_contextual
|
||
|
Since: 7.1.0
|
||
|
Context: :document, :project
|
||
|
Called in: app/views/documents/show.html.erb
|
||
|
view_groups_memberships_table_header
|
||
|
Since: -
|
||
|
Context: :group
|
||
| ... | ... | |
|
Context: :group, :membership
|
||
|
Called in: app/helpers/principal_memberships_helper.rb
|
||
|
view_groups_show_contextual
|
||
|
Since: 7.1.0
|
||
|
Context: :group
|
||
|
Called in: app/views/groups/show.html.erb
|
||
|
view_issue_statuses_form
|
||
|
Since: -
|
||
|
Context: :issue_status
|
||
| ... | ... | |
|
Context: :time_entry
|
||
|
Called in: app/views/issues/tabs/_time_entries.html.erb
|
||
|
view_issues_index_actions_menu
|
||
|
Since: 7.1.0
|
||
|
Context: :project, :query
|
||
|
Called in: app/views/issues/index.html.erb
|
||
|
view_issues_index_bottom
|
||
|
Since: -
|
||
|
Context: :issues, :project, :query
|
||
|
Called in: app/views/issues/index.html.erb
|
||
|
view_issues_index_contextual
|
||
|
Since: 7.1.0
|
||
|
Context: :project, :query
|
||
|
Called in: app/views/issues/index.html.erb
|
||
|
view_issues_new_top
|
||
|
Since: -
|
||
|
Context: :issue
|
||
|
Called in: app/views/issues/new.html.erb
|
||
|
view_issues_show_actions_menu
|
||
|
Since: 7.1.0
|
||
|
Context: :issue, :project
|
||
|
Called in: app/views/issues/_action_menu.html.erb
|
||
|
view_issues_show_bottom
|
||
|
Since: 7.1.0
|
||
|
Context: :issue
|
||
|
Called in: app/views/issues/show.html.erb
|
||
|
view_issues_show_contextual
|
||
|
Since: 7.1.0
|
||
|
Context: :issue, :project
|
||
|
Called in: app/views/issues/_action_menu.html.erb
|
||
|
view_issues_show_description_bottom
|
||
|
Since: -
|
||
|
Context: :issue
|
||
| ... | ... | |
|
Context: :title
|
||
|
Called in: app/helpers/application_helper.rb
|
||
|
view_messages_show_contextual
|
||
|
Since: 7.1.0
|
||
|
Context: :topic, :message, :project
|
||
|
Called in: app/views/messages/show.html.erb
|
||
|
view_my_account
|
||
|
Since: -
|
||
|
Context: :user, :form
|
||
| ... | ... | |
|
Context: :user
|
||
|
Called in: app/views/my/page.html.erb
|
||
|
view_news_index_contextual
|
||
|
Since: 7.1.0
|
||
|
Context: :project
|
||
|
Called in: app/views/news/index.html.erb
|
||
|
view_news_show_contextual
|
||
|
Since: 7.1.0
|
||
|
Context: :news, :project
|
||
|
Called in: app/views/news/show.html.erb
|
||
|
view_projects_copy_only_items
|
||
|
Since: -
|
||
|
Context: :project, :f
|
||
| ... | ... | |
|
Context: :project, :form
|
||
|
Called in: app/views/projects/_form.html.erb
|
||
|
view_projects_index_contextual
|
||
|
Since: 7.1.0
|
||
|
Context: :query
|
||
|
Called in: app/views/projects/index.html.erb
|
||
|
view_projects_roadmap_version_bottom
|
||
|
Since: -
|
||
|
Context: :version
|
||
| ... | ... | |
|
Context: :project, :member
|
||
|
Called in: app/views/members/_members.html.erb
|
||
|
view_projects_show_actions_menu
|
||
|
Since: 7.1.0
|
||
|
Context: :project
|
||
|
Called in: app/views/projects/show.html.erb
|
||
|
view_projects_show_contextual
|
||
|
Since: 7.1.0
|
||
|
Context: :project
|
||
|
Called in: app/views/projects/show.html.erb
|
||
|
view_projects_show_left
|
||
|
Since: -
|
||
|
Context: :project
|
||
| ... | ... | |
|
Context: :project
|
||
|
Called in: app/views/reports/issue_report.html.erb
|
||
|
view_repositories_navigation_actions_menu
|
||
|
Since: 7.1.0
|
||
|
Context: :repository, :project
|
||
|
Called in: app/views/repositories/_navigation.html.erb
|
||
|
view_repositories_show_contextual
|
||
|
Since: -
|
||
|
Context: :repository, :project
|
||
| ... | ... | |
|
Context: :time_entry, :form
|
||
|
Called in: app/views/timelog/_form.html.erb
|
||
|
view_timelog_index_actions_menu
|
||
|
Since: 7.1.0
|
||
|
Context: :project, :query
|
||
|
Called in: app/views/timelog/index.html.erb
|
||
|
view_timelog_index_contextual
|
||
|
Since: 7.1.0
|
||
|
Context: :project, :query
|
||
|
Called in: app/views/timelog/index.html.erb
|
||
|
view_users_form
|
||
|
Since: -
|
||
|
Context: :user, :form
|
||
| ... | ... | |
|
Context: :user, :form
|
||
|
Called in: app/views/users/_form.html.erb
|
||
|
view_users_index_actions_menu
|
||
|
Since: 7.1.0
|
||
|
Context: :query
|
||
|
Called in: app/views/users/index.html.erb
|
||
|
view_users_index_contextual
|
||
|
Since: 7.1.0
|
||
|
Context: :query
|
||
|
Called in: app/views/users/index.html.erb
|
||
|
view_users_memberships_table_header
|
||
|
Since: -
|
||
|
Context: :user
|
||
| ... | ... | |
|
Context: :user, :membership
|
||
|
Called in: app/helpers/principal_memberships_helper.rb
|
||
|
view_users_show_contextual
|
||
|
Since: 7.1.0
|
||
|
Context: :user
|
||
|
Called in: app/views/users/show.html.erb
|
||
|
view_users_sidebar_queries_bottom
|
||
|
Since: -
|
||
|
Context: -
|
||
|
Called in: app/views/users/index.html.erb
|
||
|
view_versions_index_actions_menu
|
||
|
Since: 7.1.0
|
||
|
Context: :project
|
||
|
Called in: app/views/versions/index.html.erb
|
||
|
view_versions_index_contextual
|
||
|
Since: 7.1.0
|
||
|
Context: :project
|
||
|
Called in: app/views/versions/index.html.erb
|
||
|
view_versions_show_bottom
|
||
|
Since: -
|
||
|
Context: :version
|
||
| ... | ... | |
|
Context: -
|
||
|
Called in: app/views/welcome/index.html.erb
|
||
|
view_wiki_show_actions_menu
|
||
|
Since: 7.1.0
|
||
|
Context: :page, :project
|
||
|
Called in: app/views/wiki/show.html.erb
|
||
|
view_wiki_show_contextual
|
||
|
Since: 7.1.0
|
||
|
Context: :page, :project
|
||
|
Called in: app/views/wiki/show.html.erb
|
||
|
view_wiki_show_sidebar_bottom
|
||
|
Since: -
|
||
|
Context: :wiki, :page
|
||
| lib/redmine/menu_manager.rb | ||
|---|---|---|
|
links.empty? ? nil : content_tag('ul', links.join.html_safe)
|
||
|
end
|
||
|
# Renders the items that plugins added to the menu of an object:
|
||
|
# * :issue_actions - the actions menu of an issue (object: the issue)
|
||
|
# * :issue_context_menu - the context menu of the issue list (object: the selected issues)
|
||
|
# * :project_actions - the actions menu of a project overview (object: the project)
|
||
|
# * :user_actions - the actions of a user page (object: the user)
|
||
|
# * :version_actions - the actions of a version page (object: the version)
|
||
|
#
|
||
|
# For these menus, the :if and :caption Procs and a Proc url receive the object; a
|
||
|
# Hash url gets the object as its :param (or :ids for a list of objects), and the
|
||
|
# :permission is checked in +project+.
|
||
|
# menu :issue_actions, :a_action, {:controller => 'a_plugin', :action => 'do'},
|
||
|
# :caption => :label_a_action, :icon => 'add', :if => Proc.new {|issue| issue.closed?}
|
||
|
#
|
||
|
# +list+ renders each link in a +li+ (context menu).
|
||
|
def render_object_menu_items(menu, object, project=nil, list: false)
|
||
|
links = []
|
||
|
Redmine::MenuManager.items(menu).root.children.each do |item|
|
||
|
next unless object_menu_item_allowed?(item, object, project)
|
||
|
url =
|
||
|
case item.url
|
||
|
when Proc then item.url.call(object)
|
||
|
when Hash
|
||
|
# a list of objects is an Array or a relation (the selected issues)
|
||
|
many = object.respond_to?(:to_ary)
|
||
|
key = many ? :ids : item.param
|
||
|
value = many ? object.to_ary.map(&:id).sort : object
|
||
|
{key => value}.merge(item.url)
|
||
|
when Symbol then send(item.url, object)
|
||
|
else item.url
|
||
|
end
|
||
|
caption = item.caption(object)
|
||
|
label = item.icon.present? ? sprite_icon(item.icon, h(caption), plugin: item.plugin) : h(caption)
|
||
|
link = link_to(label, use_absolute_controller(url), item.html_options)
|
||
|
links << (list ? content_tag('li', link) : link)
|
||
|
end
|
||
|
safe_join(links)
|
||
|
end
|
||
|
def object_menu_item_allowed?(item, object, project)
|
||
|
return false if project && item.permission && !User.current.allowed_to?(item.permission, project)
|
||
|
return false if item.condition && !item.condition.call(object)
|
||
|
true
|
||
|
end
|
||
|
def render_menu_node(node, project=nil)
|
||
|
if node.children.present? || !node.child_menus.nil?
|
||
|
return render_menu_node_with_children(node, project)
|
||
| test/integration/lib/redmine/view_hooks_test.rb | ||
|---|---|---|
|
require_relative '../../../test_helper'
|
||
|
# The hooks and registries that let plugins add to pages without overriding
|
||
|
# core views or helpers: each one is called on its page, and what a plugin adds
|
||
|
# through them leaves the page's HTML as valid as it was.
|
||
|
# The hooks, registries and menus that let plugins add to pages without
|
||
|
# overriding core views or helpers: each one is called on its page, and what a
|
||
|
# plugin adds through them leaves the page's HTML as valid as it was.
|
||
|
class ViewHooksTest < Redmine::IntegrationTest
|
||
|
# The pages and the hooks each one must call
|
||
|
PAGES = {
|
||
|
'/projects/ecookbook' => %w(
|
||
|
view_layouts_base_header_top view_layouts_base_header_bottom view_layouts_base_sidebar_top
|
||
|
view_layouts_base_content_top view_layouts_base_footer_top view_layouts_base_footer_bottom),
|
||
|
'/issues/1' => %w(view_issues_show_top view_issues_show_details_end view_issues_show_bottom),
|
||
|
view_layouts_base_content_top view_layouts_base_footer_top view_layouts_base_footer_bottom
|
||
|
view_projects_show_contextual view_projects_show_actions_menu),
|
||
|
'/projects/ecookbook/issues' => %w(view_issues_index_contextual view_issues_index_actions_menu),
|
||
|
'/issues/1' => %w(
|
||
|
view_issues_show_contextual view_issues_show_actions_menu view_issues_show_top view_issues_show_details_end
|
||
|
view_issues_show_bottom),
|
||
|
'/projects?display_type=list' => %w(view_projects_index_contextual),
|
||
|
'/users' => %w(view_users_index_contextual view_users_index_actions_menu),
|
||
|
'/users/2' => %w(view_users_show_contextual),
|
||
|
'/users/2/edit' => %w(view_layouts_base_title_after),
|
||
|
'/groups/10' => %w(view_groups_show_contextual),
|
||
|
'/projects/ecookbook/roadmap' => %w(view_versions_index_contextual view_versions_index_actions_menu),
|
||
|
'/projects/ecookbook/wiki' => %w(view_wiki_show_contextual view_wiki_show_actions_menu),
|
||
|
'/projects/ecookbook/news' => %w(view_news_index_contextual),
|
||
|
'/news/1' => %w(view_news_show_contextual),
|
||
|
'/projects/ecookbook/documents' => %w(view_documents_index_contextual),
|
||
|
'/documents/1' => %w(view_documents_show_contextual),
|
||
|
'/projects/ecookbook/boards/1' => %w(view_boards_show_contextual),
|
||
|
'/boards/1/topics/1' => %w(view_messages_show_contextual),
|
||
|
'/projects/ecookbook/time_entries' => %w(view_timelog_index_contextual view_timelog_index_actions_menu),
|
||
|
'/admin/plugins' => %w(view_layouts_base_title_after)
|
||
|
}
|
||
| ... | ... | |
|
Redmine::Hook.clear_listeners
|
||
|
Redmine::Tabs.clear
|
||
|
Redmine::JournalDetails.clear
|
||
|
%w(issue_actions issue_context_menu project_actions user_actions version_actions).each do |menu|
|
||
|
Redmine::MenuManager.map(menu).delete(:sample)
|
||
|
end
|
||
|
end
|
||
|
def html_errors
|
||
| ... | ... | |
|
end
|
||
|
end
|
||
|
def test_contextual_hook_should_be_before_the_actions_menu_and_the_menu_hook_inside_it
|
||
|
Redmine::Hook.add_listener(MarkerListener)
|
||
|
PAGES.each do |path, hooks|
|
||
|
menu = hooks.detect {|hook| hook.end_with?('_actions_menu')}
|
||
|
next unless menu
|
||
|
contextual = hooks.detect {|hook| hook.end_with?('_contextual')}
|
||
|
get path
|
||
|
assert_select "div.contextual .hook-#{contextual} ~ span.dropdown", {:minimum => 1}, "#{contextual} not before the menu on #{path}"
|
||
|
assert_select "span.dropdown .dropdown-items .hook-#{menu}", {:minimum => 1}, "#{menu} not in the menu on #{path}"
|
||
|
end
|
||
|
end
|
||
|
def test_hook_output_should_not_make_the_html_invalid
|
||
|
PAGES.each_key do |path|
|
||
|
Redmine::Hook.clear_listeners
|
||
| ... | ... | |
|
get '/issues/1'
|
||
|
assert_select 'span.sample-detail', :text => 'Sample changed to high'
|
||
|
end
|
||
|
def test_object_menus_should_show_the_items_of_plugins
|
||
|
options = {:caption => 'Sample action', :html => {:class => 'icon sample-action'}}
|
||
|
Redmine::MenuManager.map(:issue_actions).push :sample, {:controller => 'issues', :action => 'show'}, options
|
||
|
Redmine::MenuManager.map(:project_actions).push :sample, Proc.new {|project| "/projects/#{project.identifier}"}, options
|
||
|
Redmine::MenuManager.map(:user_actions).push :sample, Proc.new {|user| "/users/#{user.id}"}, options
|
||
|
Redmine::MenuManager.map(:version_actions).push :sample, '/versions', options.merge(:if => Proc.new {|version| version.id == 2})
|
||
|
Redmine::MenuManager.map(:issue_context_menu).push :sample, {:controller => 'issues', :action => 'index'}, options
|
||
|
get '/issues/1'
|
||
|
assert_select 'a.sample-action[href="/issues/1"]', :text => 'Sample action'
|
||
|
get '/projects/ecookbook'
|
||
|
assert_select 'a.sample-action[href="/projects/ecookbook"]'
|
||
|
get '/users/2'
|
||
|
assert_select 'a.sample-action[href="/users/2"]'
|
||
|
get '/versions/2'
|
||
|
assert_select 'a.sample-action'
|
||
|
get '/versions/3'
|
||
|
assert_select 'a.sample-action', 0
|
||
|
get '/issues/context_menu', :params => {:ids => [1, 2]}, :xhr => true
|
||
|
# the context menu links are full URLs
|
||
|
assert_select 'li a.sample-action[href$=?]', '/issues?ids%5B%5D=1&ids%5B%5D=2', {},
|
||
|
"Links found: #{css_select('a.sample-action').pluck('href').inspect}"
|
||
|
end
|
||
|
end
|
||