Skip to content

Commit

Permalink
chore: rename ui/srv_teal_transform_data to ui/srv_transform_teal_data
Browse files Browse the repository at this point in the history
  • Loading branch information
averissimo committed Nov 22, 2024
1 parent 0f9565c commit f67584f
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ export(reporter_previewer_module)
export(set_datanames)
export(show_rcode_modal)
export(srv_teal)
export(srv_teal_transform_data)
export(srv_teal_with_splash)
export(srv_transform_teal_data)
export(tdata2env)
export(teal_data_module)
export(teal_slices)
export(teal_transform_module)
export(ui_teal)
export(ui_teal_transform_data)
export(ui_teal_with_splash)
export(ui_transform_teal_data)
export(validate_has_data)
export(validate_has_elements)
export(validate_has_variable)
Expand Down
4 changes: 2 additions & 2 deletions R/dummy_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ example_module <- function(label = "example teal module",
)
})

table_data_decorated_no_print <- srv_teal_transform_data(
table_data_decorated_no_print <- srv_transform_teal_data(
"decorate",
data = table_data,
transformators = decorators
Expand All @@ -87,7 +87,7 @@ example_module <- function(label = "example teal module",
output = verbatimTextOutput(ns("text")),
encoding = tags$div(
selectInput(ns("dataname"), "Choose a dataset", choices = NULL),
ui_teal_transform_data(ns("decorate"), transformators = decorators),
ui_transform_teal_data(ns("decorate"), transformators = decorators),
teal.widgets::verbatim_popup_ui(ns("rcode"), "Show R code")
)
)
Expand Down
4 changes: 2 additions & 2 deletions R/module_nested_tabs.R
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ ui_teal_module.teal_module <- function(id, modules, depth = 0L) {
width = 3,
ui_data_summary(ns("data_summary")),
ui_filter_data(ns("filter_panel")),
ui_teal_transform_data(ns("data_transform"), transformators = modules$transformators, class = "well"),
ui_transform_teal_data(ns("data_transform"), transformators = modules$transformators, class = "well"),
class = "teal_secondary_col"
)
)
Expand Down Expand Up @@ -261,7 +261,7 @@ srv_teal_module.teal_module <- function(id,
is_active = is_active
)
is_transform_failed <- reactiveValues()
transformed_teal_data <- srv_teal_transform_data(
transformed_teal_data <- srv_transform_teal_data(
"data_transform",
data = filtered_teal_data,
transformators = modules$transformators,
Expand Down
8 changes: 4 additions & 4 deletions R/module_transform_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ NULL

#' @export
#' @rdname module_transform_data
ui_teal_transform_data <- function(id, transformators, class = "well") {
ui_transform_teal_data <- function(id, transformators, class = "well") {
checkmate::assert_string(id)
if (length(transformators) == 0L) {
return(NULL)
Expand Down Expand Up @@ -56,7 +56,7 @@ ui_teal_transform_data <- function(id, transformators, class = "well") {
tags$div(
id = transform_wrapper_id,
if (is.null(data_mod$ui)) {
NULL
return(NULL)
} else {
data_mod$ui(id = ns("transform"))
},
Expand All @@ -74,7 +74,7 @@ ui_teal_transform_data <- function(id, transformators, class = "well") {

#' @export
#' @rdname module_transform_data
srv_teal_transform_data <- function(id, data, transformators, modules = NULL, is_transform_failed = reactiveValues()) {
srv_transform_teal_data <- function(id, data, transformators, modules = NULL, is_transform_failed = reactiveValues()) {
checkmate::assert_string(id)
assert_reactive(data)
checkmate::assert_class(modules, "teal_module", null.ok = TRUE)
Expand All @@ -91,7 +91,7 @@ srv_teal_transform_data <- function(id, data, transformators, modules = NULL, is
module_output <- Reduce(
function(data_previous, name) {
moduleServer(name, function(input, output, session) {
logger::log_debug("srv_teal_transform_data initializing for { name }.")
logger::log_debug("srv_transform_teal_data initializing for { name }.")
is_transform_failed[[name]] <- FALSE
data_out <- transformators[[name]]$server("transform", data = data_previous)
data_handled <- reactive(tryCatch(data_out(), error = function(e) e))
Expand Down
2 changes: 1 addition & 1 deletion R/teal_transform_module.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#' `teal_transform_module` also allows developers to modify any object created within [`teal.data::teal_data`].
#' This means you can use it to customize not only datasets but also tables, listings, and graphs.
#' Some [`teal_modules`] permit developers to inject custom `shiny` modules to enhance displayed outputs.
#' To manage these `decorators` within your module, use [`ui_teal_transform_data()`] and [`srv_teal_transform_data()`].
#' To manage these `decorators` within your module, use [`ui_transform_teal_data()`] and [`srv_teal_transform_data()`].
#' (For further guidance on managing decorators, refer to `ui_args` and `srv_args` in the vignette documentation.)
#'
#' See the vignette `vignette("decorate-modules-output", package = "teal")` for additional examples.
Expand Down
8 changes: 4 additions & 4 deletions man/module_transform_data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/teal_transform_module.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/test-module_teal.R
Original file line number Diff line number Diff line change
Expand Up @@ -2051,7 +2051,7 @@ testthat::describe("srv_teal teal_module(s) transformator", {
expr = {
session$setInputs(`teal_modules-active_tab` = "mod1")
session$setInputs(`teal_modules-mod1-module-dataname` = "x1")
session$setInputs(`teal_modules-mod1-module-decorate-decorator_name-transform-text` = "lorem ipsum dolor")
session$setInputs(`teal_modules-mod1-module-decorate-transform_1-transform-text` = "lorem ipsum dolor")
session$flushReact()

testthat::expect_identical(modules_output$mod1()()[["object"]], "ABC lorem ipsum dolor")
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-shinytest2-decorators.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ testthat::test_that("e2e: module with decorator UI and output is modified intera

input_id <- Reduce(
shiny::NS,
c("decorate", "transform_module", "transform", "append_text")
c("decorate", "transform_1", "transform", "append_text")
)

testthat::expect_true(
Expand Down
10 changes: 5 additions & 5 deletions tests/testthat/test-teal_transform_module.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ testthat::describe("make_teal_transform_server produces a valid teal_transform_m
)

shiny::testServer(
app = srv_teal_transform_data,
app = srv_transform_teal_data,
args = list(
id = "test",
data = reactive(teal.data::teal_data(data1 = iris, data2 = mtcars)),
Expand All @@ -32,7 +32,7 @@ testthat::describe("make_teal_transform_server produces a valid teal_transform_m
)

shiny::testServer(
app = srv_teal_transform_data,
app = srv_transform_teal_data,
args = list(
id = "test",
data = reactive(teal.data::teal_data(data1 = iris, data2 = mtcars)),
Expand All @@ -47,7 +47,7 @@ testthat::describe("make_teal_transform_server produces a valid teal_transform_m
})

testthat::test_that(
"ui_teal_transform_dataname and srv_teal_transform_dataname have the same namespace for transform module",
"ui_transform_teal_data and srv_transform_teal_data have the same namespace for transform module",
{
ttm <- teal_transform_module(
ui = function(id) tags$div(id = NS(id, "a_div"), "a div"),
Expand All @@ -60,12 +60,12 @@ testthat::test_that(
)

initial_id <- "a-path-to-an-inner-namespace"
ui <- ui_teal_transform_data(initial_id, ttm)
ui <- ui_transform_teal_data(initial_id, ttm)
# Find element that ends in "-a_div"
expected_id <- unname(unlist(ui)[grepl(".*-a_div$", unlist(ui))][1])

testServer(
app = srv_teal_transform_data,
app = srv_transform_teal_data,
args = list(
id = initial_id,
data = reactive(within(teal_data(), iris <- iris)),
Expand Down
8 changes: 4 additions & 4 deletions vignettes/decorate-module-output.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ tm_decorated_plot <- function(label = "module", transformators = list(), decorat
selectInput(ns("dataname"), label = "select dataname", choices = NULL),
selectInput(ns("x"), label = "select x", choices = NULL),
selectInput(ns("y"), label = "select y", choices = NULL),
ui_teal_transform_data(ns("decorate"), transformators = decorators),
ui_transform_teal_data(ns("decorate"), transformators = decorators),
plotOutput(ns("plot")),
verbatimTextOutput(ns("text"))
)
Expand Down Expand Up @@ -260,7 +260,7 @@ tm_decorated_plot <- function(label = "module", transformators = list(), decorat
)
})
plot_data_decorated_no_print <- srv_teal_transform_data(
plot_data_decorated_no_print <- srv_transform_teal_data(
"decorate",
data = plot_data,
transformators = decorators
Expand Down Expand Up @@ -336,7 +336,7 @@ tm_decorated_plot <- function(label = "module", decorators = NULL) {
lapply(names(decorators), function(decorator_name) {
div(
id = ns(paste0("decorate_", decorator_name)),
ui_teal_transform_data(
ui_transform_teal_data(
ns(paste0("decorate_", decorator_name)),
transformators = decorators[[decorator_name]]
)
Expand Down Expand Up @@ -398,7 +398,7 @@ tm_decorated_plot <- function(label = "module", decorators = NULL) {
input$decorator_choice
})
decorated_data_no_print <- srv_teal_transform_data(
decorated_data_no_print <- srv_transform_teal_data(
paste0("decorate_", selected_decorator()),
data = plot_data,
transformators = decorators[[selected_decorator()]]
Expand Down

0 comments on commit f67584f

Please sign in to comment.