diff --git a/R/utils.R b/R/utils.R index f3054cb4cc..df00a84e42 100644 --- a/R/utils.R +++ b/R/utils.R @@ -134,24 +134,13 @@ report_card_template <- function(title, label, description = NULL, with_filter, #' @return `TRUE` if validation passes, otherwise `character(1)` or `shiny.tag.list` #' @keywords internal check_modules_datanames <- function(modules, datanames) { - check_datanames <- check_modules_datanames_recursive(modules, datanames) - if (length(check_datanames)) { - modules_msg <- sapply(check_datanames, function(mod) { - sprintf( - "%s %s %s missing for module %s.", - if (length(mod$missing_datanames) > 1) "Datasets" else "Dataset", - toString(dQuote(mod$missing_datanames, q = FALSE)), - if (length(mod$missing_datanames) > 1) "are" else "is", - toString(dQuote(mod$label, q = FALSE)) - ) - }) - sprintf( - "%s Datasets available in data: %s", - paste(modules_msg, collapse = "\n"), - toString(dQuote(datanames, q = FALSE)) - ) + out <- check_modules_datanames_html(modules, datanames) + if (inherits(out, "shiny.tag.list")) { + out_with_ticks <- gsub("|", "`", toString(out)) + out_text <- trimws(gsub("<[^<>]+>", "", toString(out_with_ticks))) + gsub("[[:space:]]+", " ", out_text) } else { - TRUE + out } } @@ -174,7 +163,7 @@ check_modules_datanames_html <- function(modules, tags$span( paste0( if (length(mod$missing_datanames) > 1) "are missing" else "is missing", - if (show_module_info) sprintf(" for tab '%s'.", mod$label) else "." + if (show_module_info) sprintf(" for module '%s'.", mod$label) else "." ) ) ), diff --git a/tests/testthat/test-init.R b/tests/testthat/test-init.R index abc57f5928..1ebca65fa2 100644 --- a/tests/testthat/test-init.R +++ b/tests/testthat/test-init.R @@ -64,7 +64,7 @@ testthat::test_that( data = teal.data::teal_data(mtcars = mtcars), modules = list(example_module(datanames = "iris")) ), - "Dataset \"iris\" is missing for module \"example teal module\". Datasets available in data: \"mtcars\"" + "Dataset `iris` is missing for module 'example teal module'. Dataset available in data: `mtcars`." ) } ) @@ -77,7 +77,7 @@ testthat::test_that( data = teal.data::teal_data(mtcars = mtcars), modules = list(example_module(datanames = c("a", "b"))) ), - "Datasets \"a\", \"b\" are missing for module \"example teal module\". Datasets available in data: \"mtcars\"" + "Datasets `a` and `b` are missing for module 'example teal module'. Dataset available in data: `mtcars`." ) } ) diff --git a/tests/testthat/test-module_teal.R b/tests/testthat/test-module_teal.R index 8e91f7f2c8..2fa450ed60 100644 --- a/tests/testthat/test-module_teal.R +++ b/tests/testthat/test-module_teal.R @@ -655,7 +655,7 @@ testthat::describe("srv_teal teal_modules", { ) ) ), - "Datasets missing1 and missing2 are missing for tab 'module_1'. Dataset available in data: mtcars." + "Datasets missing1 and missing2 are missing for module 'module_1'. Dataset available in data: mtcars." ) } )