Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions blade/components/dashboard/duration_chart.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
use leptos::prelude::*;
use leptos_dom::helpers::window;
use state::TestHistory;

use crate::{charts::linechart::LineChart, summaryheader::format_time};
use crate::{
charts::linechart::LineChart,
navigation::open_in_new_tab,
summaryheader::format_time,
};

pub fn format_unix(t: f64) -> String {
let d = std::time::Duration::from_secs_f64(t);
Expand All @@ -17,7 +20,7 @@ pub fn format_unix(t: f64) -> String {
pub fn DurationChart(history: TestHistory) -> impl IntoView {
let on_point_click = |point: state::TestHistoryPoint| {
let link = format!("/invocation/{}", point.invocation_id);
window().open_with_url_and_target(&link, "_blank").unwrap();
open_in_new_tab(&link);
};

// Sort data so that successful tests are rendered first and failed tests last
Expand Down
9 changes: 6 additions & 3 deletions blade/components/dashboard/pass_fail_scatterplot.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
use leptos::prelude::*;
use leptos_dom::helpers::window;
use state::{Status, TestHistory};

use crate::{charts::scatterplot::ScatterPlot, summaryheader::format_time};
use crate::{
charts::scatterplot::ScatterPlot,
navigation::open_in_new_tab,
summaryheader::format_time,
};

#[allow(non_snake_case)]
#[component]
pub fn PassFailScatterPlot(history: TestHistory) -> impl IntoView {
let on_point_click = |point: state::TestHistoryPoint| {
let link = format!("/invocation/{}", point.invocation_id);
window().location().set_href(&link).unwrap();
open_in_new_tab(&link);
};

view! {
Expand Down
6 changes: 2 additions & 4 deletions blade/components/dashboard/test_history_table.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use leptos::prelude::*;
use leptos_router::hooks::use_navigate;
use state::{Status, TestHistory};

use crate::summaryheader::format_time;
use crate::{navigation::open_in_new_tab, summaryheader::format_time};

#[derive(Debug, Clone)]
struct RuntimeStats {
Expand Down Expand Up @@ -140,9 +139,8 @@ pub fn TestHistoryTable(history: TestHistory) -> impl IntoView {
<tr
class="border-b border-gray-200 dark:border-gray-600 hover:bg-gray-100 dark:hover:bg-gray-600 cursor-pointer"
on:click=move |_| {
let navigate = use_navigate();
let url = format!("/invocation/{}", &point.invocation_id);
navigate(&url, Default::default());
open_in_new_tab(&url);
}
>
<td class="py-3 px-6 text-left whitespace-nowrap">
Expand Down
1 change: 1 addition & 0 deletions blade/components/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub mod dashboard;
pub mod list;
pub mod measuretime;
pub mod nav;
pub mod navigation;
pub mod searchbar;
pub mod shellout;
pub mod statusicon;
Expand Down
4 changes: 4 additions & 0 deletions blade/components/navigation.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
use leptos_dom::helpers::window;

/// Opens a URL in a new browser tab
pub fn open_in_new_tab(url: &str) { let _ = window().open_with_url_and_target(url, "_blank"); }