From f67584f1beac0708053ecbd0f47b75740b1c63c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Fri, 22 Nov 2024 12:06:56 +0000 Subject: [PATCH] chore: rename ui/srv_teal_transform_data to ui/srv_transform_teal_data --- NAMESPACE | 4 ++-- R/dummy_functions.R | 4 ++-- R/module_nested_tabs.R | 4 ++-- R/module_transform_data.R | 8 ++++---- R/teal_transform_module.R | 2 +- man/module_transform_data.Rd | 8 ++++---- man/teal_transform_module.Rd | 2 +- tests/testthat/test-module_teal.R | 2 +- tests/testthat/test-shinytest2-decorators.R | 2 +- tests/testthat/test-teal_transform_module.R | 10 +++++----- vignettes/decorate-module-output.Rmd | 8 ++++---- 11 files changed, 27 insertions(+), 27 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index cd5a987d12..3e156a1e6f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -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) diff --git a/R/dummy_functions.R b/R/dummy_functions.R index 0d48e668d8..b04c4a488b 100644 --- a/R/dummy_functions.R +++ b/R/dummy_functions.R @@ -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 @@ -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") ) ) diff --git a/R/module_nested_tabs.R b/R/module_nested_tabs.R index 6b0103d8ce..4994d4eb85 100644 --- a/R/module_nested_tabs.R +++ b/R/module_nested_tabs.R @@ -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" ) ) @@ -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, diff --git a/R/module_transform_data.R b/R/module_transform_data.R index 221f3d36e6..128214f9b5 100644 --- a/R/module_transform_data.R +++ b/R/module_transform_data.R @@ -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) @@ -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")) }, @@ -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) @@ -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)) diff --git a/R/teal_transform_module.R b/R/teal_transform_module.R index 0ede26dc85..258017e613 100644 --- a/R/teal_transform_module.R +++ b/R/teal_transform_module.R @@ -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. diff --git a/man/module_transform_data.Rd b/man/module_transform_data.Rd index 9ebe37f105..4dcd515ae3 100644 --- a/man/module_transform_data.Rd +++ b/man/module_transform_data.Rd @@ -2,13 +2,13 @@ % Please edit documentation in R/module_transform_data.R \name{module_transform_data} \alias{module_transform_data} -\alias{ui_teal_transform_data} -\alias{srv_teal_transform_data} +\alias{ui_transform_teal_data} +\alias{srv_transform_teal_data} \title{Module to transform \code{reactive} \code{teal_data}} \usage{ -ui_teal_transform_data(id, transformators, class = "well") +ui_transform_teal_data(id, transformators, class = "well") -srv_teal_transform_data( +srv_transform_teal_data( id, data, transformators, diff --git a/man/teal_transform_module.Rd b/man/teal_transform_module.Rd index c89b8ae01c..78803743eb 100644 --- a/man/teal_transform_module.Rd +++ b/man/teal_transform_module.Rd @@ -46,7 +46,7 @@ For more details, see the vignette: \code{vignette("data-transform-as-shiny-modu \code{teal_transform_module} also allows developers to modify any object created within \code{\link[teal.data:teal_data]{teal.data::teal_data}}. This means you can use it to customize not only datasets but also tables, listings, and graphs. Some \code{\link{teal_modules}} permit developers to inject custom \code{shiny} modules to enhance displayed outputs. -To manage these \code{decorators} within your module, use \code{\link[=ui_teal_transform_data]{ui_teal_transform_data()}} and \code{\link[=srv_teal_transform_data]{srv_teal_transform_data()}}. +To manage these \code{decorators} within your module, use \code{\link[=ui_transform_teal_data]{ui_transform_teal_data()}} and \code{\link[=srv_teal_transform_data]{srv_teal_transform_data()}}. (For further guidance on managing decorators, refer to \code{ui_args} and \code{srv_args} in the vignette documentation.) See the vignette \code{vignette("decorate-modules-output", package = "teal")} for additional examples. diff --git a/tests/testthat/test-module_teal.R b/tests/testthat/test-module_teal.R index 6f46e07894..b4eced1301 100644 --- a/tests/testthat/test-module_teal.R +++ b/tests/testthat/test-module_teal.R @@ -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") diff --git a/tests/testthat/test-shinytest2-decorators.R b/tests/testthat/test-shinytest2-decorators.R index 382778292e..3cd299f646 100644 --- a/tests/testthat/test-shinytest2-decorators.R +++ b/tests/testthat/test-shinytest2-decorators.R @@ -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( diff --git a/tests/testthat/test-teal_transform_module.R b/tests/testthat/test-teal_transform_module.R index 01ba455c70..74c8837acb 100644 --- a/tests/testthat/test-teal_transform_module.R +++ b/tests/testthat/test-teal_transform_module.R @@ -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)), @@ -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)), @@ -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"), @@ -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)), diff --git a/vignettes/decorate-module-output.Rmd b/vignettes/decorate-module-output.Rmd index 15ed14e7ce..d1bea0e371 100644 --- a/vignettes/decorate-module-output.Rmd +++ b/vignettes/decorate-module-output.Rmd @@ -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")) ) @@ -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 @@ -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]] ) @@ -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()]]