@@ -768,6 +768,8 @@ struct BuildQueuePage {
768768 in_progress_builds : Vec < InProgressBuild > ,
769769 expand_rebuild_queue : bool ,
770770 show_length_warning : bool ,
771+ queue_length_graph_url : Option < String > ,
772+ queue_wait_time_graph_url : Option < String > ,
771773}
772774
773775impl_axum_webpage ! { BuildQueuePage }
@@ -786,6 +788,7 @@ pub(crate) struct BuildQueueParams {
786788}
787789
788790pub ( crate ) async fn build_queue_handler (
791+ State ( config) : State < Arc < Config > > ,
789792 State ( build_queue) : State < Arc < AsyncBuildQueue > > ,
790793 Extension ( csp) : Extension < Arc < Csp > > ,
791794 mut conn : DbConnection ,
@@ -849,7 +852,11 @@ pub(crate) async fn build_queue_handler(
849852 }
850853 } ) ;
851854
852- csp. allow_datadog_frame ( ) ;
855+ if config. build_queue_length_graph_url . is_some ( )
856+ || config. build_queue_wait_time_graph_url . is_some ( )
857+ {
858+ csp. allow_datadog_frame ( ) ;
859+ }
853860
854861 Ok ( BuildQueuePage {
855862 description : "crate documentation scheduled to build & deploy" ,
@@ -858,6 +865,8 @@ pub(crate) async fn build_queue_handler(
858865 in_progress_builds,
859866 expand_rebuild_queue : params. expand . is_some ( ) ,
860867 show_length_warning,
868+ queue_length_graph_url : config. build_queue_length_graph_url . clone ( ) ,
869+ queue_wait_time_graph_url : config. build_queue_wait_time_graph_url . clone ( ) ,
861870 } )
862871}
863872
@@ -886,6 +895,38 @@ mod tests {
886895 use std:: str:: FromStr ;
887896 use test_case:: test_case;
888897
898+ #[ test_case( false , false ) ]
899+ #[ test_case( true , false ) ]
900+ #[ test_case( false , true ) ]
901+ #[ test_case( true , true ) ]
902+ fn test_build_queue_optional_graphs ( length : bool , wait_time : bool ) {
903+ let url = "https://app.datadoghq.com/graph/embed?token=test&legend=true" ;
904+ let mut page = BuildQueuePage {
905+ description : "test" ,
906+ queue : Vec :: new ( ) ,
907+ rebuild_queue : Vec :: new ( ) ,
908+ in_progress_builds : Vec :: new ( ) ,
909+ expand_rebuild_queue : false ,
910+ show_length_warning : false ,
911+ queue_length_graph_url : length. then ( || url. to_owned ( ) ) ,
912+ queue_wait_time_graph_url : wait_time. then ( || url. to_owned ( ) ) ,
913+ } ;
914+ let html =
915+ kuchikiki:: parse_html ( ) . one ( page. render_with_csp_nonce ( "test-nonce" . into ( ) ) . unwrap ( ) ) ;
916+ let frames: Vec < _ > = html
917+ . select ( ".build-queue-metrics iframe" )
918+ . unwrap ( )
919+ . collect ( ) ;
920+ assert_eq ! ( frames. len( ) , usize :: from( length) + usize :: from( wait_time) ) ;
921+ for frame in frames {
922+ assert_eq ! ( frame. attributes. borrow( ) . get( "src" ) , Some ( url) ) ;
923+ }
924+ assert_eq ! (
925+ html. select( ".build-queue-layout" ) . unwrap( ) . count( ) ,
926+ usize :: from( length || wait_time)
927+ ) ;
928+ }
929+
889930 #[ test]
890931 fn test_release_list_with_incomplete_release_and_successful_build ( ) {
891932 async_wrapper ( |env| async move {
0 commit comments