Skip to content

Commit

Permalink
New EVENT_MENU_ISSUE_RELATIONSHIP event
Browse files Browse the repository at this point in the history
Allows plugins to add new links to the menu under the Relationships
section in the View Issue Details page.

Fixes #11365
  • Loading branch information
dregad committed Feb 2, 2020
1 parent 3cc4ce9 commit 89b126e
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 19 deletions.
59 changes: 40 additions & 19 deletions bug_view_inc.php
Expand Up @@ -941,16 +941,16 @@ function bug_view_relationship_view_box( $p_bug_id, $p_can_update ) {
}

$t_relationship_graph = ON == config_get( 'relationship_graph_enable' );
$t_show_top_div = $p_can_update || $t_relationship_graph;
?>
$t_event_buttons = event_signal( 'EVENT_MENU_ISSUE_RELATIONSHIP', $p_bug_id );
$t_show_top_div = $p_can_update || $t_relationship_graph || !empty( $t_event_buttons );
?>
<div class="col-md-12 col-xs-12">
<div class="space-10"></div>

<?php
<?php
$t_collapse_block = is_collapsed( 'relationships' );
$t_block_css = $t_collapse_block ? 'collapsed' : '';
$t_block_icon = $t_collapse_block ? 'fa-chevron-down' : 'fa-chevron-up';
?>
?>
<div id="relationships" class="widget-box widget-color-blue2 <?php echo $t_block_css ?>">
<div class="widget-header widget-header-small">
<h4 class="widget-title lighter">
Expand All @@ -964,22 +964,41 @@ function bug_view_relationship_view_box( $p_bug_id, $p_can_update ) {
</div>
</div>
<div class="widget-body">
<?php if( $t_show_top_div ) { ?>
<?php
if( $t_show_top_div ) {
?>
<div class="widget-toolbox padding-8 clearfix">
<?php
if( $t_relationship_graph ) {
?>
<?php
# Default relationship buttons
$t_buttons = array();
if( $t_relationship_graph ) {
$t_buttons[lang_get( 'relation_graph' )] =
'bug_relationship_graph.php?bug_id=' . $p_bug_id . '&graph=relation';
$t_buttons[lang_get( 'dependency_graph' )] =
'bug_relationship_graph.php?bug_id=' . $p_bug_id . '&graph=dependency';
}

# Plugin-added buttons
foreach( $t_event_buttons as $t_plugin => $t_plugin_buttons ) {
foreach( $t_plugin_buttons as $t_callback => $t_callback_buttons ) {
if( is_array( $t_callback_buttons ) ) {
$t_buttons = array_merge( $t_buttons, $t_callback_buttons );
}
}
}
?>
<div class="btn-group pull-right noprint">
<?php
print_small_button( 'bug_relationship_graph.php?bug_id=' . $p_bug_id . '&graph=relation', lang_get( 'relation_graph' ) );
print_small_button( 'bug_relationship_graph.php?bug_id=' . $p_bug_id . '&graph=dependency', lang_get( 'dependency_graph' ) );
# Print the buttons, if any
foreach( $t_buttons as $t_label => $t_url ) {
print_small_button( $t_url, $t_label );
}
?>
</div>
<?php
} # $t_relationship_graph

if( $p_can_update ) {
?>
<?php
if( $p_can_update ) {
?>
<form method="post" action="bug_relationship_add.php" class="form-inline noprint">
<?php echo form_security_field( 'bug_relationship_add' ) ?>
<input type="hidden" name="src_bug_id" value="<?php echo $p_bug_id?>" />
Expand All @@ -988,11 +1007,13 @@ function bug_view_relationship_view_box( $p_bug_id, $p_can_update ) {
<input type="text" class="input-sm" name="dest_bug_id" value="" />
<input type="submit" class="btn btn-primary btn-sm btn-white btn-round" name="add_relationship" value="<?php echo lang_get( 'add_new_relationship_button' )?>" />
</form>
<?php
} # can update
?>
<?php
} # can update
?>
</div>
<?php } # show top div ?>
<?php
} # show top div
?>

<div class="widget-main no-padding">
<div class="table-responsive">
Expand Down
1 change: 1 addition & 0 deletions core/events_inc.php
Expand Up @@ -67,6 +67,7 @@
'EVENT_MENU_ACCOUNT' => EVENT_TYPE_DEFAULT,
'EVENT_MENU_FILTER' => EVENT_TYPE_DEFAULT,
'EVENT_MENU_ISSUE' => EVENT_TYPE_DEFAULT,
'EVENT_MENU_ISSUE_RELATIONSHIP' => EVENT_TYPE_DEFAULT,

# Management pages
'EVENT_MANAGE_OVERVIEW_INFO' => EVENT_TYPE_OUTPUT,
Expand Down
28 changes: 28 additions & 0 deletions docbook/Developers_Guide/en-US/Events_Reference_Output.xml
Expand Up @@ -240,6 +240,34 @@ array( '&lt;a href="' . plugin_page( 'mypage' ) . '">' . plugin_lang_get( 'mypag
</blockquote>
</blockquote>

<blockquote id="dev.eventref.output.menu.issue.relationship">
<title>EVENT_MENU_ISSUE_RELATIONSHIP (Default)</title>
<blockquote>
<para>
This event allows plugins to add new links to the menu
under the <emphasis>Relationships</emphasis> section
in the View Issue Details page.
</para>

<itemizedlist>
<title>Parameters</title>
<listitem><para>&lt;Integer&gt;: bug ID</para></listitem>
</itemizedlist>

<itemizedlist>
<title>Return Value</title>
<listitem>
<para>&lt;Array&gt;: List of elements to add to the menu.</para>
<para>This is an associative array, with the link's label as key
and the link target as value, e.g. <programlisting>
array( plugin_lang_get( 'mypage_label' ) => plugin_page( 'mypage' );
</programlisting>
</para>
</listitem>
</itemizedlist>
</blockquote>
</blockquote>

<blockquote id="dev.eventref.output.menu.main">
<title>EVENT_MENU_MAIN (Default)</title>
<blockquote>
Expand Down

0 comments on commit 89b126e

Please sign in to comment.