-
-
Notifications
You must be signed in to change notification settings - Fork 45
Redesign of teal.reporter #1499
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
base: main
Are you sure you want to change the base?
Conversation
# Conflicts: # R/module_nested_tabs.R # R/module_teal.R # R/module_transform_data.R
# Conflicts: # R/module_nested_tabs.R
# Conflicts: # DESCRIPTION # R/module_data_summary.R # R/module_nested_tabs.R # R/module_teal.R # R/module_transform_data.R
# Conflicts: # R/module_teal.R
Hey @vedhav @gogonzo just letting you know that I am merging `main` into `test@bslib@main` branch, so that on other repositories, like `tmg`, we can install `teal` from this branch and also we can satisfy condition for `teal` to be `>= 0.16.0`. https://github.com/insightsengineering/teal.modules.general/blob/report_redesign_poc%40main/DESCRIPTION#L83 https://github.com/insightsengineering/teal.modules.general/blob/report_redesign_poc%40main/DESCRIPTION#L30 --------- Co-authored-by: Dony Unardi <[email protected]> Co-authored-by: insights-engineering-bot <[email protected]>
…g/teal into redesign@main
# We want to have a match in parameter names in new_server and original_server | ||
# assuming we don't know names of parameters in original_server. | ||
# modify_reactive_output is the final implementation that shows how to do it without knowing parameters. | ||
modify_reactive_output <- function(teal_module, ...) { |
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.
@gogonzo modify_reactive_output
as agreed is not the best name for the function, especially since we consider the output to not be reactive
if (is.reactive(original_outputs[[output_name]])) {
reactive({
res <- original_outputs[[output_name]]()
output_funs[[output_name]](res)
})
} else {
res <- original_outputs[[output_name]]
output_funs[[output_name]](res)
}
Some potential ideas on the names are below. Given that the function operates on the outputs of a Shiny module's server, I'm also thinking about including 'output' or 'module_output'
- modify_server_output
- mutate_module_output
- remap_module_output (like purrr:map)
- chain_module_output
- wrap_server
In general it could be some verb like wrap/edit and then the object name like output/server_output
When it comes to reusing some names from base R or from tidyverse
- local (evaluates an expression in a local environment, potentially modifying variables within that local scope - module's server outputs being defined in a specific scope)
- transform (base function)
- modify (purrr)
- mutate (dplyr)
- update (base function, used to modify and re-fit model objects, update.lm / update.packages)
however I don't think there is a base equivalent to the fact that we are editing an output of a function (server) that is a part of a list (module)
Making it a regular PR so we can get CI/CD running |
Unit Tests Summary 1 files 26 suites 3m 27s ⏱️ For more details on these failures and errors, see this check. Results for commit e90a5d5. ♻️ This comment has been updated with latest results. |
Unit Test Performance Difference
Additional test case details
Results for commit 826e632 ♻️ This comment has been updated with latest results. |
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.
Some comments to discuss with @m7pr
R/module_nested_tabs.R
Outdated
if (!is.null(reporter)) { | ||
reporter_card_out <- reactive({ | ||
card <- if (is.list(module_out())) { | ||
module_out()$report_card() | ||
} | ||
}) | ||
|
||
output$reporter_add_container <- renderUI({ | ||
req(reporter_card_out()) | ||
tags$div( | ||
class = "teal add-reporter-container", | ||
teal.reporter::add_card_button_ui(session$ns("reporter_add")) | ||
) | ||
}) | ||
|
||
add_document_button_srv("reporter_add", reporter = reporter, r_card_fun = reporter_card_out) | ||
} |
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.
Could we move this to a shiny module to simplify and keep it contained?
Something like
# replacing UI above
ui_teal_reporter(ns("reporter_wrapper")),
# replacing all of this chunk in srv
srv_teal_reporter("reporter_wrapper", reporter, module_out)
ui_teal_reporter <- function(id) uiOutput(NS(id, "reporter_add_container"))
srv_teal_reporter <- function(id, reporter, module_out) {
if (is.null(reporter)) return(FALSE) # early exit
moduleServer(id, function(input, output, session) {
reporter_card_out <- reactive({
if (is.list(module_out())) {
module_out()$report_card()
}
})
output$reporter_add_container <- renderUI({
req(reporter_card_out())
tags$div(
class = "teal add-reporter-container",
teal.reporter::add_card_button_ui(session$ns("reporter_add"))
)
})
add_document_button_srv("reporter_add", reporter = reporter, r_card_fun = reporter_card_out)
TRUE
})
}
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 during the redesign of nested tabs? or you think it could be applied even now? sounds like a nice cleanup
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.
Even now, I merged it in a47a24a
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.
One less thing to do with nested tabs :-) as it can then reuse this module
Thanks @averissimo for the thorough review! Those are all really useful updates to the current flow :)! |
@averissimo the bug that you reported I was aware of
This is because you are adding a second card, that has the same content as the first card (they have just different names, but the content is the same). There is some reactiveVal that keeps the state of the last added card, and if a new card is added with the same name, it prevents adding this card. If you add a new card inside the same module, and you at least specify a comment, then the content of the second card will be different and this will be possible to be added. |
Signed-off-by: André Veríssimo <[email protected]>
* pr@redesign@main: chore: simplification of code into moduleServers feat: use common structure for js autofocus input and enter to submit
Companion to
Code examples of dealing with reporter