-
-
Notifications
You must be signed in to change notification settings - Fork 59
Fixes reporter bug where buttons would appear in other tabs when reporter is NULL (alternative)
#1737
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes reporter bug where buttons would appear in other tabs when reporter is NULL (alternative)
#1737
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,9 +45,10 @@ NULL | |
|
|
||
| #' @rdname module_teal | ||
| #' @export | ||
| ui_teal <- function(id, modules) { | ||
| ui_teal <- function(id, modules, reporter = teal.reporter::Reporter$new()) { | ||
| checkmate::assert_character(id, max.len = 1, any.missing = FALSE) | ||
| checkmate::assert_class(modules, "teal_modules") | ||
| checkmate::assert_class(reporter, "Reporter", null.ok = TRUE) | ||
| ns <- NS(id) | ||
|
|
||
| mod <- extract_module(modules, class = "teal_module_previewer") | ||
|
|
@@ -67,32 +68,34 @@ ui_teal <- function(id, modules) { | |
| ) | ||
| ) | ||
|
|
||
| navbar <- ui_teal_module(id = ns("teal_modules"), modules = modules) | ||
| navbar <- ui_teal_module(id = ns("teal_modules"), modules = modules, reporter = reporter) | ||
| nav_elements <- list( | ||
| withr::with_options(reporter_opts, { # for backwards compatibility of the report_previewer_module$server_args | ||
| tags$div( | ||
| id = ns("reporter_menu_container"), | ||
| .teal_navbar_menu( | ||
| label = "Report", | ||
| icon = "file-text-fill", | ||
| class = "reporter-menu", | ||
| if ("preview" %in% getOption("teal.reporter.nav_buttons")) { | ||
| teal.reporter::preview_report_button_ui(ns("preview_report"), label = "Preview Report") | ||
| }, | ||
| tags$hr(style = "margin: 0.5rem;"), | ||
| if ("download" %in% getOption("teal.reporter.nav_buttons")) { | ||
| teal.reporter::download_report_button_ui(ns("download_report"), label = "Download Report") | ||
| }, | ||
| if ("load" %in% getOption("teal.reporter.nav_buttons")) { | ||
| teal.reporter::report_load_ui(ns("load_report"), label = "Load Report") | ||
| }, | ||
| tags$hr(style = "margin: 0.5rem;"), | ||
| if ("reset" %in% getOption("teal.reporter.nav_buttons")) { | ||
| teal.reporter::reset_report_button_ui(ns("reset_reports"), label = "Reset Report") | ||
| } | ||
| if (!is.null(reporter)) { | ||
| withr::with_options(reporter_opts, { # for backwards compatibility of the report_previewer_module$server_args | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am surprised
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, we can use |
||
| tags$div( | ||
| id = ns("reporter_menu_container"), | ||
| .teal_navbar_menu( | ||
| label = "Report", | ||
| icon = "file-text-fill", | ||
| class = "reporter-menu", | ||
| if ("preview" %in% getOption("teal.reporter.nav_buttons")) { | ||
| teal.reporter::preview_report_button_ui(ns("preview_report"), label = "Preview Report") | ||
| }, | ||
| tags$hr(style = "margin: 0.5rem;"), | ||
| if ("download" %in% getOption("teal.reporter.nav_buttons")) { | ||
| teal.reporter::download_report_button_ui(ns("download_report"), label = "Download Report") | ||
| }, | ||
| if ("load" %in% getOption("teal.reporter.nav_buttons")) { | ||
| teal.reporter::report_load_ui(ns("load_report"), label = "Load Report") | ||
| }, | ||
| tags$hr(style = "margin: 0.5rem;"), | ||
| if ("reset" %in% getOption("teal.reporter.nav_buttons")) { | ||
| teal.reporter::reset_report_button_ui(ns("reset_reports"), label = "Reset Report") | ||
| } | ||
| ) | ||
| ) | ||
| ) | ||
| }), | ||
| }) | ||
| }, | ||
| tags$span(style = "margin-left: auto;"), | ||
| ui_bookmark_panel(ns("bookmark_manager"), modules), | ||
| ui_snapshot_manager_panel(ns("snapshot_manager_panel")), | ||
|
|
@@ -317,9 +320,6 @@ srv_teal <- function(id, data, modules, filter = teal_slices(), reporter = teal. | |
| teal.reporter::report_load_srv("load_report", reporter) | ||
| teal.reporter::download_report_button_srv(id = "download_report", reporter = reporter) | ||
| teal.reporter::reset_report_button_srv("reset_reports", reporter) | ||
| } else { | ||
| removeUI(selector = sprintf("#%s", session$ns("reporter_menu_container"))) | ||
| removeUI(selector = ".report_add_wrapper") | ||
| } | ||
| } | ||
| ) | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can make small update in vignette
teal-as-shiny-moduleto show the usage of reporter argument for functionui_teal