diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index d515ee8..731eb8a 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -67,3 +67,5 @@ shinytest2::test_app("tests/test_dashboard") # important as not currently ran in styler::style_pkg() lintr::lint_package() ``` + +If you get a lot of lintr errors, particularly around things not being defined, make sure to load the package first using Ctrl-Shft-L or `devtools::load_all(".")`, then run again. There's a known issue with lintr not picking up on bindings until packages are loaded diff --git a/R/cookies.R b/R/cookies.R index f41c915..115b68c 100644 --- a/R/cookies.R +++ b/R/cookies.R @@ -11,26 +11,38 @@ #' @examples #' if (interactive()) { #' # This example shows how to use the full family of cookies functions together -#' # This will be in your global.R script ===================================== +#' # This will be in your global.R script =================================== #' #' library(shiny) #' library(shinyjs) #' library(dfeshiny) #' google_analytics_key <- "ABCDE12345" #' -#' # This will be what is in your ui.R script ================================= +#' # This will be what is in your ui.R script =============================== #' #' ui <- fluidPage( -#' # Place these lines above your header ------------------------------------ +#' # Place these lines above your header ---------------------------------- #' useShinyjs(), #' dfe_cookies_script(), #' cookies_banner_ui(name = "My DfE R-Shiny data dashboard"), #' -#' # Place the cookies panel under the header but in the main content ------- -#' cookies_panel_ui(google_analytics_key = google_analytics_key) +#' # Place the cookies panel under the header but in the main content ----- +#' # Example of placing as a panel within navlistPanel +#' shiny::navlistPanel( +#' "", +#' id = "navlistPanel", +#' widths = c(2, 8), +#' well = FALSE, +#' ## Cookies panel ----------------------------------------------------- +#' shiny::tabPanel( +#' value = "cookies_panel_ui", +#' "Cookies", +#' cookies_panel_ui(google_analytics_key = google_analytics_key) +#' ) +#' ) #' ) #' -#' # This will be in your server.R file ======================================= +#' # This will be in your server.R file ===================================== #' #' server <- function(input, output, session) { #' # Server logic for the pop up banner, can be placed anywhere in server.R - @@ -40,14 +52,14 @@ #' parent_session = session #' ) #' -#' # Server logic for the panel, can be placed anywhere in server.R --------- +#' # Server logic for the panel, can be placed anywhere in server.R ------- #' cookies_panel_server( #' input_cookies = reactive(input$cookies), #' google_analytics_key = google_analytics_key #' ) #' } #' -#' # How to run the minimal app given in this example ========================= +#' # How to run the minimal app given in this example ======================= #' shinyApp(ui, server) #' } dfe_cookies_script <- function() { @@ -298,105 +310,85 @@ init_cookies <- function() { #' "ABCDE12345" #' #' @family cookies -#' @return a standardised panel for a public R Shiny dashboard in DfE +#' @return a html div, containing standard cookises content for a public R +#' Shiny dashboard in DfE #' @export #' @inherit cookies examples cookies_panel_ui <- function(id = "cookies_panel", google_analytics_key = NULL) { - # Build the support page ---------------------------------------------------- - shiny::tabPanel( - id = shiny::NS(id, "cookies_panel"), - value = "cookies_panel_ui", - "Cookies", - shinyGovstyle::gov_main_layout( - shinyGovstyle::gov_row( - shiny::column( - width = 12, - shiny::tags$h1("Cookies"), - shiny::tags$p("Cookies are small files saved on your phone, tablet or + shiny::tags$div( + shiny::tags$h1("Cookies"), + shiny::tags$p("Cookies are small files saved on your phone, tablet or computer when you visit a website."), - shiny::tags$p("We use cookies to collect information about how you + shiny::tags$p("We use cookies to collect information about how you use our service."), - shiny::tags$h2("Essential cookies"), - shinyGovstyle::govTable( - inputId = "essential_cookies_table", - df = data.frame( - Name = "dfe_analytics", - Purpose = "Saves your cookie consent settings", - Expires = "365 days" - ), - caption = "", - caption_size = "s", - num_col = NULL, - width_overwrite = c("one-quarter", "one-quarter", "one-quarter") - ), - shiny::tags$h2("Analytics cookies"), - shiny::tags$p("With your permission, we use Google Analytics to + shiny::tags$h2("Essential cookies"), + shinyGovstyle::govTable( + inputId = "essential_cookies_table", + df = data.frame( + Name = "dfe_analytics", + Purpose = "Saves your cookie consent settings", + Expires = "365 days" + ), + caption = "", + caption_size = "s", + num_col = NULL, + width_overwrite = c("one-quarter", "one-quarter", "one-quarter") + ), + shiny::tags$h2("Analytics cookies"), + shiny::tags$p("With your permission, we use Google Analytics to collect data about how you use this service. This - information helps us improve our service"), - shiny::tags$p("Google is not allowed to share our analytics data with + information helps us improve our service."), + shiny::tags$p("Google is not allowed to share our analytics data with anyone."), - shiny::tags$p("Google Analytics stores anonymised information + shiny::tags$p("Google Analytics stores anonymised information about:"), - shiny::tags$li("How you got to this service"), - shiny::tags$li("The pages you visit on this service and how long you + shiny::tags$ul( + shiny::tags$li("How you got to this service"), + shiny::tags$li("The pages you visit on this service and how long you spend on them"), - shiny::tags$li("How you interact with these pages"), - shinyGovstyle::govTable( - inputId = "ga_cookies_table", - df = data.frame( - Name = c("_ga", paste0("_ga_", google_analytics_key)), - Purpose = c("Used to distinguish users", "Used to persist + shiny::tags$li("How you interact with these pages") + ), + shinyGovstyle::govTable( + inputId = "ga_cookies_table", + df = data.frame( + Name = c("_ga", paste0("_ga_", google_analytics_key)), + Purpose = c("Used to distinguish users", "Used to persist session state"), - Expires = c("13 months", "13 months") - ), - caption = "", - caption_size = "s", - num_col = NULL, - width_overwrite = c("one-quarter", "one-quarter", "one-quarter") - ), - shiny::br(), + Expires = c("13 months", "13 months") + ), + caption = "", + caption_size = "s", + num_col = NULL, + width_overwrite = c("one-quarter", "one-quarter", "one-quarter") + ), + shiny::br(), + shiny::tags$h2("Change your cookie settings"), + shiny::tags$div( + class = "govuk-form-group", + tags$fieldset( + class = "govuk-fieldset", + tags$legend( + class = "govuk-fieldset__legend govuk-fieldset__legend--s", + "Do you want to accept analytics cookies?" + ), + shiny::tags$div( + class = "govuk-radios", + `data-module` = "govuk-radios", shiny::tags$div( - class = "govuk-grid-row", - shiny::tags$div( - class = "govuk-grid-column-two-thirds", - shiny::tags$h2( - class = "govuk-heading-l", - "Change your cookie settings" - ), - shiny::tags$div( - class = "govuk-form-group", - ), - shiny::tags$div( - class = "govuk-form-group", - tags$fieldset( - class = "govuk-fieldset", - tags$legend( - class = "govuk-fieldset__legend govuk-fieldset__legend--s", - "Do you want to accept analytics cookies?" - ), - shiny::tags$div( - class = "govuk-radios", - `data-module` = "govuk-radios", - shiny::tags$div( - class = "govuk-radios__item", - shiny::radioButtons(shiny::NS(id, "cookies_analytics"), - label = NULL, - choices = list("Yes" = "yes", "No" = "no"), - selected = "no", - inline = TRUE - ) - ) - ) - ) - ), - shiny::actionButton(shiny::NS(id, "submit_btn"), - "Save cookie settings", - class = "govuk-button" - ) + class = "govuk-radios__item", + shiny::radioButtons(shiny::NS(id, "cookies_analytics"), + label = NULL, + choices = list("Yes" = "yes", "No" = "no"), + selected = "no", + inline = TRUE ) ) ) ) + ), + shiny::actionButton(shiny::NS(id, "submit_btn"), + "Save cookie settings", + class = "govuk-button" ) ) } diff --git a/R/support_panel.R b/R/support_panel.R index 752d124..c132386 100644 --- a/R/support_panel.R +++ b/R/support_panel.R @@ -15,7 +15,8 @@ #' Explore Education Statistics) #' @param form_url URL for a feedback form for the dashboard #' -#' @return a standardised panel for a public R Shiny dashboard in DfE +#' @return a html div, containing standard support content for a public R Shiny +#' dashboard in DfE #' @export #' #' @examples @@ -26,6 +27,24 @@ #' publication_slug = "my-publication-title", #' form_url = "www.myform.com" #' ) +#' +#' # Often you will use this inside a set of navigation tabs, e.g. +#' shiny::navlistPanel( +#' "", +#' id = "navlistPanel", +#' widths = c(2, 8), +#' well = FALSE, +#' ## Support panel -------------------------------------------------------- +#' shiny::tabPanel( +#' value = "support_panel", +#' "Support and feedback", +#' support_panel( +#' team_email = "explore.statistics@@education.gov.uk", +#' repo_name = "https://github.com/dfe-analytical-services/dfeshiny/", +#' form_url = "https://forms.office.com" +#' ) +#' ) +#' ) support_panel <- function( team_email = "", repo_name = "", @@ -76,119 +95,110 @@ support_panel <- function( } # Build the support page ---------------------------------------------------- - shiny::tabPanel( - value = "support_panel", - "Support and feedback", - shinyGovstyle::gov_main_layout( - shinyGovstyle::gov_row( - shiny::column( - width = 12, - shiny::tags$h1("Support and feedback"), - shiny::tags$h2("Give us feedback"), - if (!is.null(form_url)) { - shiny::tags$p( - "This dashboard is a new service that we are developing. If you + shiny::tags$div( + shiny::tags$h1("Support and feedback"), + shiny::tags$h2("Give us feedback"), + if (!is.null(form_url)) { + shiny::tags$p( + "This dashboard is a new service that we are developing. If you have any feedback or suggestions for improvements, please submit them using our ", - shiny::tags$a( - href = form_url, - "feedback form", - .noWS = c("after") - ) - ) - } else { - shiny::tags$p( - "This dashboard is a new service that we are developing." - ) - }, - shiny::tags$p( - paste0( - ifelse( - !is.null(form_url), - "Alternatively, i", - "I" - ), - "f you spot any errors or bugs while using this dashboard, please + shiny::tags$a( + href = form_url, + "feedback form", + .noWS = c("after") + ) + ) + } else { + shiny::tags$p( + "This dashboard is a new service that we are developing." + ) + }, + shiny::tags$p( + paste0( + ifelse( + !is.null(form_url), + "Alternatively, i", + "I" + ), + "f you spot any errors or bugs while using this dashboard, please screenshot and email them to " - ), - shiny::tags$a( - href = paste0("mailto:", team_email), - team_email, - .noWS = c("after") - ), "." - ), - shiny::tags$h2("Find more information on the data"), - if (ees_publication) { - shiny::tags$p( - "The parent statistical release of this dashboard, along with + ), + shiny::tags$a( + href = paste0("mailto:", team_email), + team_email, + .noWS = c("after") + ), "." + ), + shiny::tags$h2("Find more information on the data"), + if (ees_publication) { + shiny::tags$p( + "The parent statistical release of this dashboard, along with methodological information, is available at the following link: ", - shiny::tags$a( - href = paste0( - "https://explore-education-statistics.service.gov.uk/find-statistics/", # nolint: [line_length_linter] - publication_slug - ), - ifelse( - !is.null(publication_name), - publication_name, - "Explore Education Statistics" - ), - .noWS = c("after") - ), - ". The statistical release provides additional ", - shiny::tags$a( - href = paste0( - "https://explore-education-statistics.service.gov.uk/find-statistics/", # nolint: [line_length_linter] - publication_slug, "/data-guidance" - ), - "data guidance", - .noWS = c("after") - ), - " and ", - shiny::tags$a( - href = paste0( - "https://explore-education-statistics.service.gov.uk/find-statistics/", # nolint: [line_length_linter] - publication_slug, "#explore-data-and-files" - ), - "tools to access and interogate the underling data", - .noWS = c("after") - ), - " contained in this dashboard." - ) - } else { - shiny::tags$p( - "The parent statistical release of this dashboard, along with + shiny::tags$a( + href = paste0( + "https://explore-education-statistics.service.gov.uk/find-statistics/", # nolint: [line_length_linter] + publication_slug + ), + ifelse( + !is.null(publication_name), + publication_name, + "Explore Education Statistics" + ), + .noWS = c("after") + ), + ". The statistical release provides additional ", + shiny::tags$a( + href = paste0( + "https://explore-education-statistics.service.gov.uk/find-statistics/", # nolint: [line_length_linter] + publication_slug, "/data-guidance" + ), + "data guidance", + .noWS = c("after") + ), + " and ", + shiny::tags$a( + href = paste0( + "https://explore-education-statistics.service.gov.uk/find-statistics/", # nolint: [line_length_linter] + publication_slug, "#explore-data-and-files" + ), + "tools to access and interogate the underling data", + .noWS = c("after") + ), + " contained in this dashboard." + ) + } else { + shiny::tags$p( + "The parent statistical release of this dashboard, along with methodological information, is available at the following link: ", - shiny::tags$a( - href = alt_href, - publication_name, - .noWS = c("after") - ) - ) - }, - shiny::tags$h2("Contact us"), - shiny::tags$p( - "If you have questions about the dashboard or data within it, - please contact us at ", - shiny::tags$a( - href = paste0("mailto:", team_email), - team_email, .noWS = c("after") - ) - ), - shiny::tags$h2("See the source code"), - shiny::tags$p( - "The source code for this dashboard is available in our ", - shiny::tags$a( - href = paste0( - repo_name - ), - "GitHub repository", .noWS = c("after") - ), - "." - ) + shiny::tags$a( + href = alt_href, + publication_name, + .noWS = c("after") ) ) + }, + shiny::tags$h2("Contact us"), + shiny::tags$p( + "If you have questions about the dashboard or data within it, + please contact us at ", + shiny::tags$a( + href = paste0("mailto:", team_email), + team_email, .noWS = c("after") + ) + ), + shiny::tags$h2("See the source code"), + shiny::tags$p( + "The source code for this dashboard is available in our ", + shiny::tags$a( + href = paste0( + repo_name + ), + "GitHub repository", .noWS = c("after") + ), + "." ) ) } diff --git a/man/cookies.Rd b/man/cookies.Rd index 378a740..a069577 100644 --- a/man/cookies.Rd +++ b/man/cookies.Rd @@ -17,26 +17,38 @@ cookies. Function should be placed in the ui.R script. \examples{ if (interactive()) { # This example shows how to use the full family of cookies functions together - # This will be in your global.R script ===================================== + # This will be in your global.R script =================================== library(shiny) library(shinyjs) library(dfeshiny) google_analytics_key <- "ABCDE12345" - # This will be what is in your ui.R script ================================= + # This will be what is in your ui.R script =============================== ui <- fluidPage( - # Place these lines above your header ------------------------------------ + # Place these lines above your header ---------------------------------- useShinyjs(), dfe_cookies_script(), cookies_banner_ui(name = "My DfE R-Shiny data dashboard"), - # Place the cookies panel under the header but in the main content ------- - cookies_panel_ui(google_analytics_key = google_analytics_key) + # Place the cookies panel under the header but in the main content ----- + # Example of placing as a panel within navlistPanel + shiny::navlistPanel( + "", + id = "navlistPanel", + widths = c(2, 8), + well = FALSE, + ## Cookies panel ----------------------------------------------------- + shiny::tabPanel( + value = "cookies_panel_ui", + "Cookies", + cookies_panel_ui(google_analytics_key = google_analytics_key) + ) + ) ) - # This will be in your server.R file ======================================= + # This will be in your server.R file ===================================== server <- function(input, output, session) { # Server logic for the pop up banner, can be placed anywhere in server.R - @@ -46,14 +58,14 @@ if (interactive()) { parent_session = session ) - # Server logic for the panel, can be placed anywhere in server.R --------- + # Server logic for the panel, can be placed anywhere in server.R ------- cookies_panel_server( input_cookies = reactive(input$cookies), google_analytics_key = google_analytics_key ) } - # How to run the minimal app given in this example ========================= + # How to run the minimal app given in this example ======================= shinyApp(ui, server) } } diff --git a/man/cookies_banner_server.Rd b/man/cookies_banner_server.Rd index e8d5569..dd94f30 100644 --- a/man/cookies_banner_server.Rd +++ b/man/cookies_banner_server.Rd @@ -38,26 +38,38 @@ R-Shiny dashboards. \examples{ if (interactive()) { # This example shows how to use the full family of cookies functions together - # This will be in your global.R script ===================================== + # This will be in your global.R script =================================== library(shiny) library(shinyjs) library(dfeshiny) google_analytics_key <- "ABCDE12345" - # This will be what is in your ui.R script ================================= + # This will be what is in your ui.R script =============================== ui <- fluidPage( - # Place these lines above your header ------------------------------------ + # Place these lines above your header ---------------------------------- useShinyjs(), dfe_cookies_script(), cookies_banner_ui(name = "My DfE R-Shiny data dashboard"), - # Place the cookies panel under the header but in the main content ------- - cookies_panel_ui(google_analytics_key = google_analytics_key) + # Place the cookies panel under the header but in the main content ----- + # Example of placing as a panel within navlistPanel + shiny::navlistPanel( + "", + id = "navlistPanel", + widths = c(2, 8), + well = FALSE, + ## Cookies panel ----------------------------------------------------- + shiny::tabPanel( + value = "cookies_panel_ui", + "Cookies", + cookies_panel_ui(google_analytics_key = google_analytics_key) + ) + ) ) - # This will be in your server.R file ======================================= + # This will be in your server.R file ===================================== server <- function(input, output, session) { # Server logic for the pop up banner, can be placed anywhere in server.R - @@ -67,14 +79,14 @@ if (interactive()) { parent_session = session ) - # Server logic for the panel, can be placed anywhere in server.R --------- + # Server logic for the panel, can be placed anywhere in server.R ------- cookies_panel_server( input_cookies = reactive(input$cookies), google_analytics_key = google_analytics_key ) } - # How to run the minimal app given in this example ========================= + # How to run the minimal app given in this example ======================= shinyApp(ui, server) } } diff --git a/man/cookies_banner_ui.Rd b/man/cookies_banner_ui.Rd index 15af3f3..cbae8af 100644 --- a/man/cookies_banner_ui.Rd +++ b/man/cookies_banner_ui.Rd @@ -28,26 +28,38 @@ need to include the dfe_cookies_script() function in their ui.R file. \examples{ if (interactive()) { # This example shows how to use the full family of cookies functions together - # This will be in your global.R script ===================================== + # This will be in your global.R script =================================== library(shiny) library(shinyjs) library(dfeshiny) google_analytics_key <- "ABCDE12345" - # This will be what is in your ui.R script ================================= + # This will be what is in your ui.R script =============================== ui <- fluidPage( - # Place these lines above your header ------------------------------------ + # Place these lines above your header ---------------------------------- useShinyjs(), dfe_cookies_script(), cookies_banner_ui(name = "My DfE R-Shiny data dashboard"), - # Place the cookies panel under the header but in the main content ------- - cookies_panel_ui(google_analytics_key = google_analytics_key) + # Place the cookies panel under the header but in the main content ----- + # Example of placing as a panel within navlistPanel + shiny::navlistPanel( + "", + id = "navlistPanel", + widths = c(2, 8), + well = FALSE, + ## Cookies panel ----------------------------------------------------- + shiny::tabPanel( + value = "cookies_panel_ui", + "Cookies", + cookies_panel_ui(google_analytics_key = google_analytics_key) + ) + ) ) - # This will be in your server.R file ======================================= + # This will be in your server.R file ===================================== server <- function(input, output, session) { # Server logic for the pop up banner, can be placed anywhere in server.R - @@ -57,14 +69,14 @@ if (interactive()) { parent_session = session ) - # Server logic for the panel, can be placed anywhere in server.R --------- + # Server logic for the panel, can be placed anywhere in server.R ------- cookies_panel_server( input_cookies = reactive(input$cookies), google_analytics_key = google_analytics_key ) } - # How to run the minimal app given in this example ========================= + # How to run the minimal app given in this example ======================= shinyApp(ui, server) } } diff --git a/man/cookies_panel_server.Rd b/man/cookies_panel_server.Rd index 5903fd0..223b720 100644 --- a/man/cookies_panel_server.Rd +++ b/man/cookies_panel_server.Rd @@ -27,26 +27,38 @@ alongside cookies_panel_ui(). \examples{ if (interactive()) { # This example shows how to use the full family of cookies functions together - # This will be in your global.R script ===================================== + # This will be in your global.R script =================================== library(shiny) library(shinyjs) library(dfeshiny) google_analytics_key <- "ABCDE12345" - # This will be what is in your ui.R script ================================= + # This will be what is in your ui.R script =============================== ui <- fluidPage( - # Place these lines above your header ------------------------------------ + # Place these lines above your header ---------------------------------- useShinyjs(), dfe_cookies_script(), cookies_banner_ui(name = "My DfE R-Shiny data dashboard"), - # Place the cookies panel under the header but in the main content ------- - cookies_panel_ui(google_analytics_key = google_analytics_key) + # Place the cookies panel under the header but in the main content ----- + # Example of placing as a panel within navlistPanel + shiny::navlistPanel( + "", + id = "navlistPanel", + widths = c(2, 8), + well = FALSE, + ## Cookies panel ----------------------------------------------------- + shiny::tabPanel( + value = "cookies_panel_ui", + "Cookies", + cookies_panel_ui(google_analytics_key = google_analytics_key) + ) + ) ) - # This will be in your server.R file ======================================= + # This will be in your server.R file ===================================== server <- function(input, output, session) { # Server logic for the pop up banner, can be placed anywhere in server.R - @@ -56,14 +68,14 @@ if (interactive()) { parent_session = session ) - # Server logic for the panel, can be placed anywhere in server.R --------- + # Server logic for the panel, can be placed anywhere in server.R ------- cookies_panel_server( input_cookies = reactive(input$cookies), google_analytics_key = google_analytics_key ) } - # How to run the minimal app given in this example ========================= + # How to run the minimal app given in this example ======================= shinyApp(ui, server) } } diff --git a/man/cookies_panel_ui.Rd b/man/cookies_panel_ui.Rd index 82010a2..040c2f4 100644 --- a/man/cookies_panel_ui.Rd +++ b/man/cookies_panel_ui.Rd @@ -14,7 +14,8 @@ the user as long as it matches the id in the cookies_panel_server()} "ABCDE12345"} } \value{ -a standardised panel for a public R Shiny dashboard in DfE +a html div, containing standard cookises content for a public R +Shiny dashboard in DfE } \description{ Create the standard DfE R-Shiny cookies dashboard panel in the ui. The server @@ -23,26 +24,38 @@ side functionality is provided by cookies_panel_server() \examples{ if (interactive()) { # This example shows how to use the full family of cookies functions together - # This will be in your global.R script ===================================== + # This will be in your global.R script =================================== library(shiny) library(shinyjs) library(dfeshiny) google_analytics_key <- "ABCDE12345" - # This will be what is in your ui.R script ================================= + # This will be what is in your ui.R script =============================== ui <- fluidPage( - # Place these lines above your header ------------------------------------ + # Place these lines above your header ---------------------------------- useShinyjs(), dfe_cookies_script(), cookies_banner_ui(name = "My DfE R-Shiny data dashboard"), - # Place the cookies panel under the header but in the main content ------- - cookies_panel_ui(google_analytics_key = google_analytics_key) + # Place the cookies panel under the header but in the main content ----- + # Example of placing as a panel within navlistPanel + shiny::navlistPanel( + "", + id = "navlistPanel", + widths = c(2, 8), + well = FALSE, + ## Cookies panel ----------------------------------------------------- + shiny::tabPanel( + value = "cookies_panel_ui", + "Cookies", + cookies_panel_ui(google_analytics_key = google_analytics_key) + ) + ) ) - # This will be in your server.R file ======================================= + # This will be in your server.R file ===================================== server <- function(input, output, session) { # Server logic for the pop up banner, can be placed anywhere in server.R - @@ -52,14 +65,14 @@ if (interactive()) { parent_session = session ) - # Server logic for the panel, can be placed anywhere in server.R --------- + # Server logic for the panel, can be placed anywhere in server.R ------- cookies_panel_server( input_cookies = reactive(input$cookies), google_analytics_key = google_analytics_key ) } - # How to run the minimal app given in this example ========================= + # How to run the minimal app given in this example ======================= shinyApp(ui, server) } } diff --git a/man/support_panel.Rd b/man/support_panel.Rd index 844e69f..8d9395c 100644 --- a/man/support_panel.Rd +++ b/man/support_panel.Rd @@ -34,7 +34,8 @@ Explore Education Statistics)} \item{form_url}{URL for a feedback form for the dashboard} } \value{ -a standardised panel for a public R Shiny dashboard in DfE +a html div, containing standard support content for a public R Shiny +dashboard in DfE } \description{ Create the standard DfE R-Shiny support and feedback dashboard panel. @@ -47,4 +48,22 @@ support_panel( publication_slug = "my-publication-title", form_url = "www.myform.com" ) + +# Often you will use this inside a set of navigation tabs, e.g. +shiny::navlistPanel( + "", + id = "navlistPanel", + widths = c(2, 8), + well = FALSE, + ## Support panel -------------------------------------------------------- + shiny::tabPanel( + value = "support_panel", + "Support and feedback", + support_panel( + team_email = "explore.statistics@education.gov.uk", + repo_name = "https://github.com/dfe-analytical-services/dfeshiny/", + form_url = "https://forms.office.com" + ) + ) +) } diff --git a/tests/test_dashboard/tests/testthat/_snaps/UI-01-basic_load/basic_load-001_.new.png b/tests/test_dashboard/tests/testthat/_snaps/UI-01-basic_load/basic_load-001_.new.png deleted file mode 100644 index 7db0ebf..0000000 Binary files a/tests/test_dashboard/tests/testthat/_snaps/UI-01-basic_load/basic_load-001_.new.png and /dev/null differ diff --git a/tests/test_dashboard/tests/testthat/_snaps/UI-01-basic_load/basic_load-001_.png b/tests/test_dashboard/tests/testthat/_snaps/UI-01-basic_load/basic_load-001_.png deleted file mode 100644 index 88b5e7a..0000000 Binary files a/tests/test_dashboard/tests/testthat/_snaps/UI-01-basic_load/basic_load-001_.png and /dev/null differ diff --git a/tests/test_dashboard/tests/testthat/_snaps/UI-02-cookies/cookies_consent-001_.png b/tests/test_dashboard/tests/testthat/_snaps/UI-02-cookies/cookies_consent-001_.png deleted file mode 100644 index 8158acf..0000000 Binary files a/tests/test_dashboard/tests/testthat/_snaps/UI-02-cookies/cookies_consent-001_.png and /dev/null differ diff --git a/tests/test_dashboard/tests/testthat/_snaps/UI-02-cookies/cookies_consent-002_.png b/tests/test_dashboard/tests/testthat/_snaps/UI-02-cookies/cookies_consent-002_.png deleted file mode 100644 index 8158acf..0000000 Binary files a/tests/test_dashboard/tests/testthat/_snaps/UI-02-cookies/cookies_consent-002_.png and /dev/null differ diff --git a/tests/test_dashboard/tests/testthat/_snaps/UI-02-cookies/cookies_consent-003_.png b/tests/test_dashboard/tests/testthat/_snaps/UI-02-cookies/cookies_consent-003_.png deleted file mode 100644 index 8158acf..0000000 Binary files a/tests/test_dashboard/tests/testthat/_snaps/UI-02-cookies/cookies_consent-003_.png and /dev/null differ diff --git a/tests/test_dashboard/tests/testthat/_snaps/UI-02-cookies/cookies_consent-004_.png b/tests/test_dashboard/tests/testthat/_snaps/UI-02-cookies/cookies_consent-004_.png deleted file mode 100644 index 8158acf..0000000 Binary files a/tests/test_dashboard/tests/testthat/_snaps/UI-02-cookies/cookies_consent-004_.png and /dev/null differ diff --git a/tests/test_dashboard/tests/testthat/_snaps/UI-03-support_panel/support_panel-001.json b/tests/test_dashboard/tests/testthat/_snaps/UI-03-support_panel/support_panel-001.json deleted file mode 100644 index d806c7d..0000000 --- a/tests/test_dashboard/tests/testthat/_snaps/UI-03-support_panel/support_panel-001.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "input": { - "cookies": { - - }, - "cookies_banner-cookies_accept": 0, - "cookies_banner-cookies_link": 0, - "cookies_banner-cookies_reject": 0, - "cookies_panel-cookies_analytics": "no", - "cookies_panel-submit_btn": 0, - "navlistPanel": "support_panel" - }, - "output": { - - }, - "export": { - - } -} diff --git a/tests/test_dashboard/tests/testthat/_snaps/UI-03-support_panel/support_panel-001_.new.png b/tests/test_dashboard/tests/testthat/_snaps/UI-03-support_panel/support_panel-001_.new.png deleted file mode 100644 index 7db0ebf..0000000 Binary files a/tests/test_dashboard/tests/testthat/_snaps/UI-03-support_panel/support_panel-001_.new.png and /dev/null differ diff --git a/tests/test_dashboard/tests/testthat/_snaps/UI-03-support_panel/support_panel-001_.png b/tests/test_dashboard/tests/testthat/_snaps/UI-03-support_panel/support_panel-001_.png deleted file mode 100644 index 49fbf2c..0000000 Binary files a/tests/test_dashboard/tests/testthat/_snaps/UI-03-support_panel/support_panel-001_.png and /dev/null differ diff --git a/tests/test_dashboard/tests/testthat/test-UI-01-basic_load.R b/tests/test_dashboard/tests/testthat/test-UI-01-basic_load.R index fbcbf77..11db292 100644 --- a/tests/test_dashboard/tests/testthat/test-UI-01-basic_load.R +++ b/tests/test_dashboard/tests/testthat/test-UI-01-basic_load.R @@ -7,7 +7,7 @@ app <- AppDriver$new( load_timeout = 45 * 1000, timeout = 20 * 1000, wait = TRUE, - expect_values_screenshot_args = TRUE + expect_values_screenshot_args = FALSE ) app$wait_for_idle(5) diff --git a/tests/test_dashboard/tests/testthat/test-UI-02-cookies.R b/tests/test_dashboard/tests/testthat/test-UI-02-cookies.R index c9ea125..3d83c43 100644 --- a/tests/test_dashboard/tests/testthat/test-UI-02-cookies.R +++ b/tests/test_dashboard/tests/testthat/test-UI-02-cookies.R @@ -7,33 +7,41 @@ app <- AppDriver$new( load_timeout = 45 * 1000, timeout = 20 * 1000, wait = TRUE, - expect_values_screenshot_args = TRUE + expect_values_screenshot_args = FALSE ) -app$wait_for_idle(5) +app$wait_for_idle(50) app$click("cookies_banner-cookies_accept") +app$wait_for_idle(50) + test_that("Cookies accepted banner", { - # Capture initial values app$expect_values() }) app$click("cookies_banner-cookies_reject") +app$wait_for_idle(50) + test_that("Cookies rejected banner", { - # Capture initial values app$expect_values() }) app$set_inputs(`cookies_panel-cookies_analytics` = "yes") +app$wait_for_idle(50) + app$click("cookies_panel-submit_btn") +app$wait_for_idle(50) + test_that("Cookies accepted page", { - # Capture initial values app$expect_values() }) app$set_inputs(`cookies_panel-cookies_analytics` = "no") +app$wait_for_idle(50) + app$click("cookies_panel-submit_btn") +app$wait_for_idle(50) + test_that("Cookies rejected page", { - # Capture initial values app$expect_values() }) diff --git a/tests/test_dashboard/tests/testthat/test-UI-03-support_panel.R b/tests/test_dashboard/tests/testthat/test-UI-03-support_panel.R deleted file mode 100644 index 6b32723..0000000 --- a/tests/test_dashboard/tests/testthat/test-UI-03-support_panel.R +++ /dev/null @@ -1,19 +0,0 @@ -# To run the diffviewer on these tests, you need to add the path: -# Doesn't work? testthat::snapshot_review('cookie-auth/', path='tests/test_dashboard/') - -app <- AppDriver$new( - name = "support_panel", - height = 846, - width = 1445, - load_timeout = 45 * 1000, - timeout = 20 * 1000, - wait = TRUE, - expect_values_screenshot_args = TRUE -) - -app$wait_for_idle(5) - -test_that("Support panel text renders", { - # Capture initial values - app$expect_values() -}) diff --git a/tests/test_dashboard/ui.R b/tests/test_dashboard/ui.R index 9bb0d6d..9ec7925 100644 --- a/tests/test_dashboard/ui.R +++ b/tests/test_dashboard/ui.R @@ -24,12 +24,23 @@ ui <- function(input, output, session) { id = "navlistPanel", widths = c(2, 8), well = FALSE, - support_panel( - team_email = "explore.statistics@education.gov.uk", - repo_name = "https://github.com/dfe-analytical-services/dfeshiny/", - form_url = "https://forms.office.com" + ## Support panel -------------------------------------------------------- + shiny::tabPanel( + value = "support_panel", + "Support and feedback", + support_panel( + team_email = "explore.statistics@education.gov.uk", + repo_name = "https://github.com/dfe-analytical-services/dfeshiny/", + form_url = "https://forms.office.com" + ) ), - cookies_panel_ui(google_analytics_key = ga_key) # nolint: [object_usage_linter] + + ## Cookies panel -------------------------------------------------------- + shiny::tabPanel( + value = "cookies_panel_ui", + "Cookies", + cookies_panel_ui(google_analytics_key = ga_key) # nolint: [object_usage_linter] + ) ) ) } diff --git a/tests/testthat/test-cookies_panel_ui.R b/tests/testthat/test-cookies_panel_ui.R new file mode 100644 index 0000000..0717104 --- /dev/null +++ b/tests/testthat/test-cookies_panel_ui.R @@ -0,0 +1,19 @@ +# Example output object ======================================================= +# This is used in the following tests +output <- cookies_panel_ui(google_analytics_key = "TESTYTESTY") + +test_that("Output has class 'shiny.tag'", { + expect_s3_class(output, class = "shiny.tag") +}) + +test_that("HTML headings output from function", { + # This checks the headings are in the expected positions in the HTML output the function returns + expect_equal(paste(output$children[[1]]), "

Cookies

") + expect_equal(paste(output$children[[4]]), "

Essential cookies

") + expect_equal(paste(output$children[[6]]), "

Analytics cookies

") + expect_equal(paste(output$children[[13]]), "

Change your cookie settings

") +}) + +test_that("GA key pulls into table output", { + expect_true(grepl("_ga_TESTYTESTY", paste(output$children[[11]]))) +}) diff --git a/tests/testthat/test-support_panel.R b/tests/testthat/test-support_panel.R index 948974b..a9d712b 100644 --- a/tests/testthat/test-support_panel.R +++ b/tests/testthat/test-support_panel.R @@ -84,9 +84,29 @@ test_that("repo URL needs to follow standard pattern", { ) # Testing that it will fail if there is no repo_name - expect_error( - support_panel( - team_email = "cam@education.gov.uk" - ) - ) + expect_error(support_panel(team_email = "cam@education.gov.uk")) +}) + +# Example output object ======================================================= +# This is used in the following tests + +output <- support_panel( + team_email = "my.team@education.gov.uk", + repo_name = "https://github.com/dfe-analytical-services/my-repo", + publication_name = "My publication title", + publication_slug = "my-publication-title", + form_url = "www.myform.com" +) + +test_that("Output has class 'shiny.tag'", { + expect_s3_class(output, class = "shiny.tag") +}) + +test_that("HTML headings output from function", { + # This checks the headings are in the expected positions in the HTML output the function returns + expect_equal(paste(output$children[[1]]), "

Support and feedback

") + expect_equal(paste(output$children[[2]]), "

Give us feedback

") + expect_equal(paste(output$children[[5]]), "

Find more information on the data

") + expect_equal(paste(output$children[[7]]), "

Contact us

") + expect_equal(paste(output$children[[9]]), "

See the source code

") }) diff --git a/vignettes/implementing-cookies.Rmd b/vignettes/implementing-cookies.Rmd index 9a07672..360bc3d 100644 --- a/vignettes/implementing-cookies.Rmd +++ b/vignettes/implementing-cookies.Rmd @@ -73,8 +73,10 @@ ui <- function(input, output, session) { id = "navlistPanel", widths = c(2, 8), well = FALSE, - dfeshiny::cookies_panel_ui( - google_analytics_key = google_analytics_key + shiny::tabPanel( + value = "cookies_panel_ui", + "Cookies", + cookies_panel_ui(google_analytics_key = google_analytics_key) ) ) )