Project

General

Profile

Actions

Defect #5932

open

hook for :view_repositories_show_contextual is incomplete

Added by Arnaud Martel over 13 years ago. Updated over 13 years ago.

Status:
Reopened
Priority:
Normal
Assignee:
-
Category:
Plugin API
Target version:
-
Start date:
2010-07-21
Due date:
% Done:

0%

Estimated time:
Resolution:
Affected version:

Description

I wrote a plugin to add new commands in repository views (upload files, create directory and delete file/directory) and I noticed that :view_repositories_show_contextual hook lacks of 2 context parameters:
  • path
  • revision

As a "workaround", I patched the views (show.rhtml, entry.rhtml, changes.rhtml and annotate.rhtml) to replace:

<%= call_hook(:view_repositories_show_contextual, { :repository => @repository, :project => @project }) %>

with
<%= call_hook(:view_repositories_show_contextual, { :repository => @repository, :project => @project, :path => @path, :revision => @rev }) %>

but it would be better if included in the next release of Redmine...

Actions #1

Updated by Holger Just over 13 years ago

As you can see in one of my plugins (line 15), you can get these variables today without having to patch the hook calls.

Actions #2

Updated by Arnaud Martel over 13 years ago

  • Status changed from New to Resolved

Many thanks!!! I didn't know how to do that and I really like your solution: I will undo my patches ASAP!!!

Actions #3

Updated by Holger Just over 13 years ago

  • Status changed from Resolved to Closed
  • Resolution set to Wont fix
Actions #4

Updated by Jean-Baptiste Barth over 13 years ago

  • Category set to Plugin API
  • Status changed from Closed to Reopened
  • Affected version (unused) set to devel
  • Resolution deleted (Wont fix)

I disagree... Many things are accessible through context[:controller] but it's not the right way to go for me. Hooks should provide instance variables directly so plugin developers don't have to do hacky things like instance_variable_get. Else, with this argument, we could remove nearly any context variables passed to the hooks ;)

It makes me think of using .send() to bypass object privacy: possible, but not so good in most cases.

Is there a particular reason why we should refuse adding those variables ? Maybe something I missed..

Actions

Also available in: Atom PDF