-
-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New methods for TealAppDriver
: get_active_module_*ws_output
#1208
Conversation
Code Coverage Summary
Diff against main
Results for commit: da8c778 Minimum allowed coverage is ♻️ This comment has been updated with latest results |
Unit Tests Summary 1 files 30 suites 2m 52s ⏱️ Results for commit da8c778. ♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should use hardcoded prefixes on the id.
Otherwise, these 2 functions seem very helpful! 👍
Hey @averissimo I allowed table/plot namespace name to be passed by a parameter in both methods. Would you take a look in your free time? |
I moved the cleanup discussion to insightsengineering/teal.modules.general#743 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works great
Tested with:
library(shiny)
library(rtables)
library(magrittr)
library(rlang)
widgets_module <- function(label = "example teal module", datanames = "all") {
checkmate::assert_string(label)
ans <- module(
label,
server = function(id, data) {
checkmate::assert_class(data(), "teal_data")
moduleServer(id, function(input, output, session) {
# table_with_settings -------------------------------------------------
table_r <- shiny::reactive({
l <- rtables::basic_table() %>%
rtables::split_cols_by("ARM") %>%
rtables::analyze(c("SEX", "AGE"))
rtables::build_table(l, data()[["DM"]])
})
teal.widgets::table_with_settings_srv(id = "a_table", table_r = table_r)
# plot_with_settings --------------------------------------------------
plot_r <- reactive({
ggplot2::ggplot(
data()[["faithful"]],
ggplot2::aes(x = .data$waiting, y = .data$eruptions)) +
ggplot2::geom_point()
})
teal.widgets::plot_with_settings_srv(
id = "a_plot",
plot_r = plot_r,
height = c(400, 100, 1200),
width = c(500, 250, 750)
)
})
},
ui = function(id) {
ns <- shiny::NS(id)
shiny::tagList(
teal.widgets::plot_with_settings_ui(
id = ns("a_plot")
),
teal.widgets::table_with_settings_ui(
id = ns("a_table")
)
)
},
datanames = datanames
)
attr(ans, "teal_bookmarkable") <- TRUE
ans
}
app_driver <- TealAppDriver$new(
data = teal_data(DM = DM, faithful = faithful),
modules = widgets_module()
)
withr::defer(app_driver$stop())
app_driver$view()
app_driver$get_active_module_tws_output("a_table")
app_driver$get_active_module_pws_output("a_plot")
withr::deferred_run()
Co-authored-by: kartikeya kirar <[email protected]> Signed-off-by: Marcin <[email protected]>
Motivated by the need to check current plot and table contents
tm_g_ci
shinytests teal.modules.clinical#1125tm_a_gee
shinytests teal.modules.clinical#1127