Skip to content

Commit

Permalink
Relationship Graphs allow display of Issue Summary
Browse files Browse the repository at this point in the history
A new Show/Hide Summary button lets the user choose whether they want to
see just the Issue ID, or also the Summary. In that case, the text is
truncated to an arbitrary 30 characters, to avoid the node boxes being
too wide.

Fixes #17594
  • Loading branch information
dregad committed Feb 2, 2020
1 parent 89b126e commit ec616fd
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 17 deletions.
21 changes: 16 additions & 5 deletions bug_relationship_graph.php
Expand Up @@ -62,6 +62,7 @@
$f_bug_id = gpc_get_int( 'bug_id' );
$f_type = gpc_get_string( 'graph', 'relation' );
$f_orientation = gpc_get_string( 'orientation', config_get( 'relationship_graph_orientation' ) );
$f_show_summary = gpc_get_bool( 'summary', false );

if( 'relation' == $f_type ) {
$t_graph_type = 'relation';
Expand Down Expand Up @@ -122,7 +123,8 @@
# Relation/Dependency Graph Switch
print_link_button(
'bug_relationship_graph.php?bug_id=' . $f_bug_id
. '&graph=' . $t_graph_type_switch,
. '&graph=' . $t_graph_type_switch
. '&summary=' . $f_show_summary,
lang_get( $t_graph_relation ? 'dependency_graph' : 'relation_graph' )
);

Expand All @@ -131,10 +133,19 @@
print_link_button(
'bug_relationship_graph.php?bug_id=' . $f_bug_id
. '&graph=' . $t_graph_type
. '&orientation=' . $t_graph_orientation_switch,
. '&orientation=' . $t_graph_orientation_switch
. '&summary=' . $f_show_summary,
lang_get( $t_graph_orientation_switch )
);
}

print_link_button(
'bug_relationship_graph.php?bug_id=' . $f_bug_id
. '&graph=' . $t_graph_type
. '&orientation=' . $t_graph_orientation
. '&summary=' . !$f_show_summary,
lang_get( $f_show_summary ? 'hide_summary' : 'show_summary' )
);
?>
</div>
</div>
Expand All @@ -143,15 +154,15 @@
<div class="center padding-8">
<?php
if( $t_graph_relation ) {
$t_graph = relgraph_generate_rel_graph( $f_bug_id );
$t_graph = relgraph_generate_rel_graph( $f_bug_id, $f_show_summary );
} else {
$t_graph = relgraph_generate_dep_graph( $f_bug_id, $t_graph_horizontal );
$t_graph = relgraph_generate_dep_graph( $f_bug_id, $t_graph_horizontal, $f_show_summary );
}

$t_map_name = 'relationship_graph_map';
relgraph_output_map( $t_graph, $t_map_name );

$t_graph_src = "bug_relationship_graph_img.php?bug_id=$f_bug_id&graph=$t_graph_type&orientation=$t_graph_orientation";
$t_graph_src = "bug_relationship_graph_img.php?bug_id=$f_bug_id&graph=$t_graph_type&orientation=$t_graph_orientation&summary=$f_show_summary";
?>
<img src="<?php echo $t_graph_src ?>"
usemap="#<?php echo $t_map_name ?>"
Expand Down
5 changes: 3 additions & 2 deletions bug_relationship_graph_img.php
Expand Up @@ -55,6 +55,7 @@
$f_bug_id = gpc_get_int( 'bug_id' );
$f_type = gpc_get_string( 'graph', 'relation' );
$f_orientation = gpc_get_string( 'orientation', config_get( 'relationship_graph_orientation' ) );
$f_show_summary = gpc_get_bool( 'summary', false );

$t_bug = bug_get( $f_bug_id, true );

Expand All @@ -66,9 +67,9 @@
$t_graph_horizontal = ( 'horizontal' == $f_orientation );

if( $t_graph_relation ) {
$t_graph = relgraph_generate_rel_graph( $f_bug_id );
$t_graph = relgraph_generate_rel_graph( $f_bug_id, $f_show_summary );
} else {
$t_graph = relgraph_generate_dep_graph( $f_bug_id, $t_graph_horizontal );
$t_graph = relgraph_generate_dep_graph( $f_bug_id, $t_graph_horizontal, $f_show_summary );
}

relgraph_output_image( $t_graph );
28 changes: 18 additions & 10 deletions core/relationship_graph_api.php
Expand Up @@ -78,9 +78,10 @@ function relgraph_bug_format_id( $p_bug_id ) {
* Generate a relationship graph for the given issue.
*
* @param integer $p_bug_id A bug identifier.
* @param boolean $p_show_summary Whether to include the Summary in the nodes
* @return Graph
*/
function relgraph_generate_rel_graph( $p_bug_id ) {
function relgraph_generate_rel_graph( $p_bug_id, $p_show_summary = false ) {
# List of visited issues and their data.
$v_bug_list = array();
$v_rel_list = array();
Expand Down Expand Up @@ -191,7 +192,7 @@ function relgraph_generate_rel_graph( $p_bug_id ) {
$t_url = 'bug_relationship_graph.php?bug_id=' . $t_id . '&graph=relation';
}

relgraph_add_bug_to_graph( $t_graph, $t_id_string, $t_bug, $t_url, $t_id == $p_bug_id );
relgraph_add_bug_to_graph( $t_graph, $t_id_string, $t_bug, $t_url, $t_id == $p_bug_id, $p_show_summary );

# Now add all relationship edges to the graph.
if( isset( $v_rel_list[$t_id] ) ) {
Expand Down Expand Up @@ -228,10 +229,11 @@ function relgraph_generate_rel_graph( $p_bug_id ) {
* Generate a dependency relationship graph for the given issue.
* @param integer $p_bug_id Bug identifier.
* @param boolean $p_horizontal Graph orientation - horizontal if true.
* @param boolean $p_show_summary Whether to include the Summary in the nodes
* @todo duplicate bug/bugid
* @return Digraph
*/
function relgraph_generate_dep_graph( $p_bug_id, $p_horizontal = false ) {
function relgraph_generate_dep_graph( $p_bug_id, $p_horizontal = false, $p_show_summary = false ) {
# List of visited issues and their data.
$v_bug_list = array();

Expand Down Expand Up @@ -321,7 +323,7 @@ function relgraph_generate_dep_graph( $p_bug_id, $p_horizontal = false ) {
$t_url = 'bug_relationship_graph.php?bug_id=' . $t_related_bug_id . '&graph=dependency&orientation=' . $t_graph_orientation;
}

relgraph_add_bug_to_graph( $t_graph, $t_id_string, $t_related_bug, $t_url, $t_related_bug_id == $p_bug_id );
relgraph_add_bug_to_graph( $t_graph, $t_id_string, $t_related_bug, $t_url, $t_related_bug_id == $p_bug_id, $p_show_summary );

# Now add all relationship edges to the graph.
foreach( $v_bug_list[$t_related_bug_id]->parents as $t_parent_id ) {
Expand Down Expand Up @@ -501,11 +503,21 @@ function relgraph_output_map( Graph $p_graph, $p_name ) {
* @param BugData $p_bug A BugData object.
* @param string $p_url URL.
* @param boolean $p_highlight Highlight.
* @param boolean $p_show_summary Whether to include the Summary in the nodes
* @return void
*/
function relgraph_add_bug_to_graph( Graph &$p_graph, $p_bug_id, BugData $p_bug, $p_url = null, $p_highlight = false ) {
function relgraph_add_bug_to_graph( Graph &$p_graph, $p_bug_id, BugData $p_bug, $p_url = null, $p_highlight = false, $p_show_summary = false ) {
$t_summary = string_display_line_links( $p_bug->summary );
$t_status = get_enum_element( 'status', $p_bug->status );
$t_label = $p_bug_id;
if( $p_show_summary ) {
# Truncate summary to 30 chars, to avoid nodes being too wide
$t_label .= "\n" . mb_strimwidth( $t_summary, 0, 30, "..." );
}

$t_node_attributes = array();
$t_node_attributes['label'] = $p_bug_id;
$t_node_attributes['label'] = $t_label;
$t_node_attributes['tooltip'] = '[' . $t_status . '] ' . $t_summary;

if( $p_highlight ) {
$t_node_attributes['color'] = '#0000FF';
Expand All @@ -521,9 +533,5 @@ function relgraph_add_bug_to_graph( Graph &$p_graph, $p_bug_id, BugData $p_bug,
$t_node_attributes['URL'] = $p_url;
}

$t_summary = string_display_line_links( $p_bug->summary );
$t_status = get_enum_element( 'status', $p_bug->status );
$t_node_attributes['tooltip'] = '[' . $t_status . '] ' . $t_summary;

$p_graph->add_node( $p_bug_id, $t_node_attributes );
}
2 changes: 2 additions & 0 deletions lang/strings_english.txt
Expand Up @@ -1417,6 +1417,8 @@ $s_dependency_graph = 'Dependency Graph';
$s_vertical = 'Vertical';
$s_horizontal = 'Horizontal';
$s_view_issue = 'View Issue';
$s_show_summary = 'Show Summary';
$s_hide_summary = 'Hide Summary';

# Permissions report
$s_perm_rpt_capability = 'Capability';
Expand Down

0 comments on commit ec616fd

Please sign in to comment.