Skip to content

Commit

Permalink
445 unify html tags (#1122)
Browse files Browse the repository at this point in the history
part of insightsengineering/teal.slice#445
for teal package

---------

Co-authored-by: 27856297+dependabot-preview[bot]@users.noreply.github.com <27856297+dependabot-preview[bot]@users.noreply.github.com>
  • Loading branch information
kartikeyakirar and dependabot-preview[bot] authored Mar 8, 2024
1 parent b8c3f3b commit 0d74e49
Show file tree
Hide file tree
Showing 18 changed files with 47 additions and 47 deletions.
2 changes: 1 addition & 1 deletion R/dummy_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ example_module <- function(label = "example teal module", datanames = "all") {
ns <- NS(id)
teal.widgets::standard_layout(
output = verbatimTextOutput(ns("text")),
encoding = div(
encoding = tags$div(
selectInput(ns("dataname"), "Choose a dataset", choices = NULL),
teal.widgets::verbatim_popup_ui(ns("rcode"), "Show R code")
)
Expand Down
2 changes: 1 addition & 1 deletion R/init.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
#' module(
#' label = "data source",
#' server = function(input, output, session, data) {},
#' ui = function(id, ...) div(p("information about data source")),
#' ui = function(id, ...) tags$div(p("information about data source")),
#' datanames = "all"
#' ),
#' example_module(label = "example teal module"),
Expand Down
2 changes: 1 addition & 1 deletion R/module_filter_manager.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ filter_manager_modal_srv <- function(id, filtered_data_list, filter) {
#' @rdname module_filter_manager
filter_manager_ui <- function(id) {
ns <- NS(id)
div(
tags$div(
class = "filter_manager_content",
tableOutput(ns("slices_table")),
snapshot_manager_ui(ns("snapshot_manager"))
Expand Down
2 changes: 1 addition & 1 deletion R/module_nested_tabs.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ ui_nested_tabs.teal_module <- function(id, modules, datasets, depth = 0L, is_mod
class = "teal_module",
uiOutput(ns("data_reactive"), inline = TRUE),
tagList(
if (depth >= 2L) div(style = "mt-6"),
if (depth >= 2L) tags$div(style = "mt-6"),
do.call(modules$ui, args)
)
)
Expand Down
12 changes: 6 additions & 6 deletions R/module_snapshot_manager.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@
#'
snapshot_manager_ui <- function(id) {
ns <- NS(id)
div(
tags$div(
class = "snapshot_manager_content",
div(
tags$div(
class = "snapshot_table_row",
span(tags$b("Snapshot manager")),
tags$span(tags$b("Snapshot manager")),
actionLink(ns("snapshot_add"), label = NULL, icon = icon("camera"), title = "add snapshot"),
actionLink(ns("snapshot_load"), label = NULL, icon = icon("upload"), title = "upload snapshot"),
actionLink(ns("snapshot_reset"), label = NULL, icon = icon("undo"), title = "reset initial state"),
Expand Down Expand Up @@ -303,9 +303,9 @@ snapshot_manager_srv <- function(id, slices_global, mapping_matrix, filtered_dat
}
# Create a row for the snapshot table.
if (!is.element(id_rowme, names(divs))) {
divs[[id_rowme]] <- div(
divs[[id_rowme]] <- tags$div(
class = "snapshot_table_row",
span(h5(s)),
tags$span(tags$h5(s)),
actionLink(inputId = ns(id_pickme), label = icon("circle-check"), title = "select"),
downloadLink(outputId = ns(id_saveme), label = icon("save"), title = "save to file")
)
Expand All @@ -317,7 +317,7 @@ snapshot_manager_srv <- function(id, slices_global, mapping_matrix, filtered_dat
output$snapshot_list <- renderUI({
rows <- lapply(rev(reactiveValuesToList(divs)), function(d) d)
if (length(rows) == 0L) {
div(
tags$div(
class = "snapshot_manager_placeholder",
"Snapshots will appear here."
)
Expand Down
10 changes: 5 additions & 5 deletions R/module_teal.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,19 @@ ui_teal <- function(id,
ns <- NS(id)

# Once the data is loaded, we will remove this element and add the real teal UI instead
splash_ui <- div(
splash_ui <- tags$div(
# id so we can remove the splash screen once ready, which is the first child of this container
id = ns("main_ui_container"),
# we put it into a div, so it can easily be removed as a whole, also when it is a tagList (and not
# just the first item of the tagList)
div(splash_ui)
tags$div(splash_ui)
)

# show busy icon when `shiny` session is busy computing stuff
# based on https://stackoverflow.com/questions/17325521/r-shiny-display-loading-message-while-function-is-running/22475216#22475216 # nolint: line_length.
shiny_busy_message_panel <- conditionalPanel(
condition = "(($('html').hasClass('shiny-busy')) && (document.getElementById('shiny-notification-panel') == null))", # nolint: line_length.
div(
tags$div(
icon("arrows-rotate", "spin fa-spin"),
"Computing ...",
# CSS defined in `custom.css`
Expand All @@ -110,7 +110,7 @@ ui_teal <- function(id,
splash_ui,
tags$hr(),
tags$footer(
div(
tags$div(
footer,
teal.widgets::verbatim_popup_ui(ns("sessionInfo"), "Session Info", type = "link"),
textOutput(ns("identifier"))
Expand Down Expand Up @@ -185,7 +185,7 @@ srv_teal <- function(id, modules, teal_data_rv, filter = teal_slices()) {
where = "beforeEnd",
# we put it into a div, so it can easily be removed as a whole, also when it is a tagList (and not
# just the first item of the tagList)
ui = div(ui_tabs_with_filters(
ui = tags$div(ui_tabs_with_filters(
session$ns("main_ui"),
modules = modules,
datasets = datasets,
Expand Down
4 changes: 2 additions & 2 deletions R/module_teal_with_splash.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ ui_teal_with_splash <- function(id,
splash_ui <- if (inherits(data, "teal_data_module")) {
data$ui(ns("teal_data_module"))
} else if (inherits(data, "teal_data")) {
div()
tags$div()
}
ui_teal(
id = ns("teal"),
splash_ui = div(splash_ui, uiOutput(ns("error"))),
splash_ui = tags$div(splash_ui, uiOutput(ns("error"))),
title = title,
header = header,
footer = footer
Expand Down
2 changes: 1 addition & 1 deletion R/validate_inputs.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#' sidebarPanel(
#' selectInput("letter", "select a letter:", c(letters[1:3], LETTERS[4:6])),
#' selectInput("number", "select a number:", 1:6),
#' br(),
#' tags$br(),
#' selectInput("color", "select a color:",
#' c("black", "indianred2", "springgreen2", "cornflowerblue"),
#' multiple = TRUE
Expand Down
2 changes: 1 addition & 1 deletion man/init.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/validate_inputs.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-init.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ testthat::test_that("init data accepts teal_data object", {
testthat::test_that("init data accepts teal_data_module", {
testthat::expect_no_error(
init(
data = teal_data_module(ui = function(id) div(), server = function(id) NULL),
data = teal_data_module(ui = function(id) tags$div(), server = function(id) NULL),
modules = modules(example_module())
)
)
Expand Down
20 changes: 10 additions & 10 deletions tests/testthat/test-module_teal_with_splash.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ testthat::test_that("srv_teal_with_splash data accepts a teal_data_module", {
app = srv_teal_with_splash,
args = list(
id = "id",
data = teal_data_module(ui = function(id) div(), server = function(id) reactive(NULL)),
data = teal_data_module(ui = function(id) tags$div(), server = function(id) reactive(NULL)),
modules = modules(example_module())
),
expr = {}
Expand All @@ -18,7 +18,7 @@ testthat::test_that("srv_teal_with_splash throws when teal_data_module doesn't r
app = srv_teal_with_splash,
args = list(
id = "id",
data = teal_data_module(ui = function(id) div(), server = function(id) NULL),
data = teal_data_module(ui = function(id) tags$div(), server = function(id) NULL),
modules = modules(example_module())
),
expr = {}
Expand All @@ -32,7 +32,7 @@ testthat::test_that("srv_teal_with_splash teal_data_rv evaluates the server of t
app = srv_teal_with_splash,
args = list(
id = "test",
data = teal_data_module(ui = function(id) div(), server = function(id) reactive("whatever")),
data = teal_data_module(ui = function(id) tags$div(), server = function(id) reactive("whatever")),
modules = modules(example_module())
),
expr = {
Expand Down Expand Up @@ -81,7 +81,7 @@ testthat::test_that("srv_teal_with_splash teal_data_rv_validate throws when teal
args = list(
id = "test",
data = teal_data_module(
ui = function(id) div(),
ui = function(id) tags$div(),
server = function(id) reactive(stop("this error"))
),
modules = modules(example_module())
Expand All @@ -99,7 +99,7 @@ testthat::test_that("srv_teal_with_splash teal_data_rv_validate throws then qenv
args = list(
id = "test",
data = teal_data_module(
ui = function(id) div(),
ui = function(id) tags$div(),
server = function(id) reactive(within(teal.data::teal_data(), stop("not good")))
),
modules = modules(example_module())
Expand All @@ -119,7 +119,7 @@ testthat::test_that(
args = list(
id = "test",
data = teal_data_module(
ui = function(id) div(),
ui = function(id) tags$div(),
server = function(id) reactive(data.frame())
),
modules = modules(example_module())
Expand Down Expand Up @@ -185,7 +185,7 @@ testthat::test_that("srv_teal_with_splash gets observe event from srv_teal", {
})

testthat::test_that("srv_teal_with_splash accepts data after within.teal_data_module", {
tdm <- teal_data_module(ui = function(id) div(), server = function(id) reactive(teal_data(IRIS = iris)))
tdm <- teal_data_module(ui = function(id) tags$div(), server = function(id) reactive(teal_data(IRIS = iris)))
tdm2 <- within(tdm, IRIS$id <- seq_len(NROW(IRIS$Species))) # nolint: object_name.

testthat::expect_no_error(
Expand All @@ -210,7 +210,7 @@ testthat::test_that("srv_teal_with_splash accepts data after within.teal_data_mo
})

testthat::test_that("srv_teal_with_splash throws error when within.teal_data_module returns qenv.error", {
tdm <- teal_data_module(ui = function(id) div(), server = function(id) reactive(teal_data(IRIS = iris)))
tdm <- teal_data_module(ui = function(id) tags$div(), server = function(id) reactive(teal_data(IRIS = iris)))
tdm2 <- within(tdm, non_existing_var + 1)

testthat::expect_no_error(
Expand All @@ -232,7 +232,7 @@ testthat::test_that("srv_teal_with_splash throws error when within.teal_data_mod
})

testthat::test_that("srv_teal_with_splash throws error when within.teal_data_module returns NULL", {
tdm <- teal_data_module(ui = function(id) div(), server = function(id) reactive(NULL))
tdm <- teal_data_module(ui = function(id) tags$div(), server = function(id) reactive(NULL))
tdm2 <- within(tdm, within(1 + 1))
testthat::expect_no_error(
shiny::testServer(
Expand Down Expand Up @@ -261,7 +261,7 @@ testthat::test_that(
"(other than `teal_data` or `qenv.error`)"
),
{
tdm <- teal_data_module(ui = function(id) div(), server = function(id) reactive(NULL))
tdm <- teal_data_module(ui = function(id) tags$div(), server = function(id) reactive(NULL))
tdm2 <- within(tdm, 1 + 1)
testthat::expect_no_error(
shiny::testServer(
Expand Down
16 changes: 8 additions & 8 deletions tests/testthat/test-teal_data_module-eval_code.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
testthat::test_that("within.teal_data_module returns an object with teal_data_module class", {
tdm <- teal_data_module(
ui = function(id) div(),
ui = function(id) tags$div(),
server = function(id) {
shiny::moduleServer(id, function(input, output, session) {
shiny::reactive(teal.data::teal_data(IRIS = iris))
Expand All @@ -17,7 +17,7 @@ testthat::test_that("eval_code.teal_data_module ui has modified namespace for id
tdm <- teal_data_module(
ui = function(id) {
ns <- NS(id)
div(id = ns("element"))
tags$div(id = ns("element"))
},
server = function(id) NULL
)
Expand All @@ -33,7 +33,7 @@ testthat::test_that("eval_code.teal_data_module ui has modified namespace for id

testthat::test_that("within.teal_data_module modifies the reactive tea_data object", {
tdm <- teal_data_module(
ui = function(id) div(),
ui = function(id) tags$div(),
server = function(id) {
shiny::moduleServer(id, function(input, output, session) {
shiny::reactive(teal.data::teal_data(IRIS = iris))
Expand All @@ -58,7 +58,7 @@ testthat::test_that("within.teal_data_module modifies the reactive tea_data obje

testthat::test_that("eval_code.teal_data_module will execute several times until error", {
tdm <- teal_data_module(
ui = function(id) div(),
ui = function(id) tags$div(),
server = function(id) {
shiny::moduleServer(id, function(input, output, session) {
shiny::reactive(teal.data::teal_data(IRIS = iris))
Expand All @@ -82,7 +82,7 @@ testthat::test_that("eval_code.teal_data_module will execute several times until

testthat::test_that("eval_code.teal_data_module throws error when original teal_data_module result is not reactive", {
tdm <- teal_data_module(
ui = function(id) div(),
ui = function(id) tags$div(),
server = function(id) {
shiny::moduleServer(id, function(input, output, session) {
"I am not reactive, I am a string"
Expand All @@ -103,7 +103,7 @@ testthat::test_that("eval_code.teal_data_module throws error when original teal_

testthat::test_that("eval_code.teal_data_module propagates qenv error from the original/first call", {
tdm <- teal_data_module(
ui = function(id) div(),
ui = function(id) tags$div(),
server = function(id) {
shiny::moduleServer(id, function(input, output, session) {
reactive(
Expand All @@ -130,7 +130,7 @@ testthat::test_that("eval_code.teal_data_module propagates qenv error from the o

testthat::test_that("eval_code.teal_data_module handles an arbitrary object (other than `teal_data` or `qenv.error`)", {
tdm <- teal_data_module(
ui = function(id) div(),
ui = function(id) tags$div(),
server = function(id) {
shiny::moduleServer(id, function(input, output, session) {
reactive(list())
Expand All @@ -155,7 +155,7 @@ testthat::test_that("eval_code.teal_data_module handles an arbitrary object (oth

testthat::test_that("eval_code.teal_data_module handles a `NULL` result", {
tdm <- teal_data_module(
ui = function(id) div(),
ui = function(id) tags$div(),
server = function(id) {
shiny::moduleServer(id, function(input, output, session) {
reactive(NULL)
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-teal_data_module.R
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
testthat::test_that("teal_data_module returns teal_data_module", {
testthat::expect_s3_class(
teal_data_module(ui = function(id) div(), server = function(id) NULL),
teal_data_module(ui = function(id) tags$div(), server = function(id) NULL),
"teal_data_module"
)
})

testthat::test_that("teal_data_module throws when ui has other formals than id only", {
testthat::expect_error(
teal_data_module(ui = function(id, x) div(), server = function(id) NULL),
teal_data_module(ui = function(id, x) tags$div(), server = function(id) NULL),
"Must have exactly 1 formal arguments"
)
})

testthat::test_that("teal_data_module throws when server has other formals than id only", {
testthat::expect_error(
teal_data_module(ui = function(id) div(), server = function(id, x) NULL),
teal_data_module(ui = function(id) tags$div(), server = function(id, x) NULL),
"Must have exactly 1 formal arguments"
)
})
2 changes: 1 addition & 1 deletion tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ testthat::test_that("create_app_id: 'data' accepts teal_data or teal_data_module
testthat::expect_no_error(create_app_id(teal.data::teal_data(), modules(example_module())))

tdm <- teal_data_module(
ui = function(id) div(),
ui = function(id) tags$div(),
server = function(id) NULL
)
testthat::expect_no_error(create_app_id(tdm, modules(example_module())))
Expand Down
2 changes: 1 addition & 1 deletion vignettes/adding-support-for-reporting.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ example_reporter_module <- function(label = "Example") {
sidebarLayout(
sidebarPanel(
div(
tags$div(
teal.reporter::add_card_button_ui(ns("addReportCard")),
teal.reporter::download_report_button_ui(ns("downloadButton")),
teal.reporter::reset_report_button_ui(ns("resetButton"))
Expand Down
4 changes: 2 additions & 2 deletions vignettes/data-as-shiny-module.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ library(teal)

```{r}
data_module <- teal_data_module(
ui = function(id) div(),
ui = function(id) tags$div(),
server = function(id) {
moduleServer(id, function(input, output, session) {
reactive({
Expand Down Expand Up @@ -86,7 +86,7 @@ datanames(data) <- c("dataset1", "dataset2")
data_module <- teal_data_module(
ui = function(id) {
ns <- NS(id)
div(
tags$div(
selectInput(ns("species"), "Select species to keep",
choices = unique(iris$Species), multiple = TRUE
),
Expand Down
2 changes: 1 addition & 1 deletion vignettes/getting-started-with-teal.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ app <- init(
),
title = build_app_title(title = "My first teal app"),
header = h3("My first teal application"),
footer = div(a("Powered by teal", href = "https://insightsengineering.github.io/teal/latest-tag/"))
footer = tags$div(a("Powered by teal", href = "https://insightsengineering.github.io/teal/latest-tag/"))
)
if (interactive()) {
Expand Down

0 comments on commit 0d74e49

Please sign in to comment.