-
-
Notifications
You must be signed in to change notification settings - Fork 46
Redesign the teal modules #1548
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
Open
vedhav
wants to merge
29
commits into
main
Choose a base branch
from
1525-redesign-modules@main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+567
−1,368
Open
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
575201a
feat: implement a dropdown buttons navigation for modules
vedhav 6834958
fix: make the nested modules work
vedhav db9f7f5
feat: do not allow deep nesting of modules
vedhav 48b3e12
test: add unit test to check for deep nested modules
vedhav cece6c6
chore: simplify the test
vedhav ec3ab27
feat: use the bootstrap navigation to simplify the widget
vedhav 45f71b7
chore: rename file + add function to extract reporter (both extractor…
vedhav 885dd0e
chore: reorganize the code
vedhav 499ce40
fix: restore input for bookmarking
vedhav 9f285da
revert: use the older modules structure and only flatten when needed
vedhav e0e1679
chore: rebuild docs
vedhav 41af8ae
feat: show module groups before the module buttons
vedhav f032ec1
chore: remove unused function
vedhav dabfd02
feat: mvp of data load sidebar
vedhav 71dfd2c
feat: display teal_data_module ui before everything
vedhav 886c787
Merge branch 'main' into 1525-redesign-modules@main
vedhav c91508d
chore: fix tests
vedhav 63caebf
chore: fix ci and update some docs
vedhav 1df8009
chore: fix spellcheck
vedhav cb92a68
docs: add docs for the sidebar overlay widget
vedhav dd7c130
chore: remove duplicate operation
vedhav af997b8
feat: use modals for teal_data_module
vedhav f57bd8a
fix: click the button using runjs
vedhav 953249c
feat: make the enable/disable state persist
vedhav f2a22a1
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
github-actions[bot] eb4bded
feat: enable/disable the close button based on validation
vedhav 60b37ab
chore: simplify the enable/disable logic
vedhav dab2d14
chore: remove extra enable
vedhav 5ac435b
fix: disable when not resolved
vedhav File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -51,54 +51,7 @@ ui_teal <- function(id, modules) { | |||
checkmate::assert_class(modules, "teal_modules") | ||||
ns <- NS(id) | ||||
|
||||
modules <- append_reporter_module(modules) | ||||
|
||||
# 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. | ||||
tags$div( | ||||
icon("arrows-rotate", class = "fa-spin", prefer_type = "solid"), | ||||
"Computing ...", | ||||
style = "position: fixed; bottom: 0; right: 0; | ||||
width: 140px; margin: 15px; padding: 5px 0 5px 10px; | ||||
text-align: left; font-weight: bold; font-size: 100%; | ||||
color: #ffffff; background-color: #347ab7; z-index: 105;" | ||||
) | ||||
) | ||||
|
||||
bslib::page_fluid( | ||||
id = id, | ||||
theme = get_teal_bs_theme(), | ||||
include_teal_css_js(), | ||||
shiny_busy_message_panel, | ||||
tags$div( | ||||
id = ns("tabpanel_wrapper"), | ||||
class = "teal-body", | ||||
ui_teal_module(id = ns("teal_modules"), modules = modules) | ||||
), | ||||
tags$div( | ||||
id = ns("options_buttons"), | ||||
style = "position: absolute; right: 10px;", | ||||
ui_bookmark_panel(ns("bookmark_manager"), modules), | ||||
ui_snapshot_manager_panel(ns("snapshot_manager_panel")), | ||||
ui_filter_manager_panel(ns("filter_manager_panel")) | ||||
), | ||||
tags$script( | ||||
HTML( | ||||
sprintf( | ||||
" | ||||
$(document).ready(function() { | ||||
$('#%s').appendTo('#%s'); | ||||
}); | ||||
", | ||||
ns("options_buttons"), | ||||
ns("teal_modules-active_tab") | ||||
) | ||||
) | ||||
), | ||||
tags$hr(style = "margin: 1rem 0 0.5rem 0;") | ||||
) | ||||
uiOutput(ns("main_teal_ui")) | ||||
} | ||||
|
||||
#' @rdname module_teal | ||||
|
@@ -109,7 +62,9 @@ srv_teal <- function(id, data, modules, filter = teal_slices()) { | |||
checkmate::assert_class(modules, "teal_modules") | ||||
checkmate::assert_class(filter, "teal_slices") | ||||
|
||||
modules <- drop_module(modules, "teal_module_landing") | ||||
modules <- append_reporter_module(modules) | ||||
teal_data_resolved_state <- reactiveVal(FALSE) | ||||
|
||||
moduleServer(id, function(input, output, session) { | ||||
logger::log_debug("srv_teal initializing.") | ||||
|
@@ -118,8 +73,40 @@ srv_teal <- function(id, data, modules, filter = teal_slices()) { | |||
shinyjs::showLog() | ||||
} | ||||
|
||||
# `JavaScript` code | ||||
run_js_files(files = "init.js") | ||||
output$main_teal_ui <- renderUI({ | ||||
# 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. | ||||
tags$div( | ||||
icon("arrows-rotate", class = "fa-spin", prefer_type = "solid"), | ||||
"Computing ...", | ||||
style = "position: fixed; bottom: 0; right: 0; | ||||
width: 140px; margin: 15px; padding: 5px 0 5px 10px; | ||||
text-align: left; font-weight: bold; font-size: 100%; | ||||
color: #ffffff; background-color: #347ab7; z-index: 105;" | ||||
) | ||||
) | ||||
bslib::page_fluid( | ||||
id = id, | ||||
theme = get_teal_bs_theme(), | ||||
include_teal_css_js(), | ||||
shiny_busy_message_panel, | ||||
tags$div( | ||||
id = session$ns("options_buttons"), | ||||
style = "position: absolute; right: 10px;", | ||||
ui_bookmark_panel(session$ns("bookmark_manager"), modules), | ||||
ui_snapshot_manager_panel(session$ns("snapshot_manager_panel")), | ||||
ui_filter_manager_panel(session$ns("filter_manager_panel")) | ||||
), | ||||
tags$div( | ||||
id = session$ns("tabpanel_wrapper"), | ||||
class = "teal-body", | ||||
ui_teal_module(id = session$ns("teal_modules"), modules = modules) | ||||
), | ||||
tags$hr(style = "margin: 1rem 0 0.5rem 0;") | ||||
) | ||||
}) | ||||
|
||||
# set timezone in shiny app | ||||
# timezone is set in the early beginning so it will be available also | ||||
|
@@ -165,8 +152,12 @@ srv_teal <- function(id, data, modules, filter = teal_slices()) { | |||
|
||||
data_load_status <- reactive({ | ||||
if (inherits(data_handled(), "teal_data")) { | ||||
shinyjs::enable(id = "close_teal_data_module_modal") | ||||
teal_data_resolved_state(TRUE) | ||||
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. Doesn't seem to be needed as
Suggested change
|
||||
"ok" | ||||
} else if (inherits(data, "teal_data_module")) { | ||||
shinyjs::disable(id = "close_teal_data_module_modal") | ||||
teal_data_resolved_state(FALSE) | ||||
"teal_data_module failed" | ||||
} else { | ||||
"external failed" | ||||
|
@@ -182,28 +173,47 @@ srv_teal <- function(id, data, modules, filter = teal_slices()) { | |||
} | ||||
|
||||
|
||||
|
||||
if (inherits(data, "teal_data_module")) { | ||||
setBookmarkExclude(c("teal_modules-active_tab")) | ||||
bslib::nav_insert( | ||||
id = "teal_modules-active_tab", | ||||
position = "before", | ||||
select = TRUE, | ||||
bslib::nav_panel( | ||||
title = icon("fas fa-database"), | ||||
value = "teal_data_module", | ||||
tags$div( | ||||
ui_init_data(session$ns("data")), | ||||
validate_ui | ||||
insertUI( | ||||
selector = ".teal-modules-wrapper .nav-item-custom", | ||||
where = "beforeBegin", | ||||
actionButton(session$ns("open_teal_data_module_ui"), NULL, icon = icon("database")) | ||||
) | ||||
observeEvent(input$open_teal_data_module_ui, ignoreInit = TRUE, ignoreNULL = FALSE, { | ||||
showModal( | ||||
div( | ||||
class = "teal teal-data-module-popup", | ||||
modalDialog( | ||||
id = session$ns("teal_data_module_ui"), | ||||
size = "xl", | ||||
tags$div( | ||||
ui_init_data(session$ns("data")), | ||||
validate_ui | ||||
), | ||||
easyClose = FALSE, | ||||
footer = tags$div(id = session$ns("close_teal_data_module_modal"), modalButton("Dismiss")) | ||||
) | ||||
) | ||||
) | ||||
) | ||||
if (teal_data_resolved_state()) { | ||||
shinyjs::enable(id = "close_teal_data_module_modal") | ||||
} else { | ||||
shinyjs::disable(id = "close_teal_data_module_modal") | ||||
} | ||||
}) | ||||
|
||||
if (attr(data, "once")) { | ||||
observeEvent(data_signatured(), once = TRUE, { | ||||
logger::log_debug("srv_teal@2 removing data tab.") | ||||
# when once = TRUE we pull data once and then remove data tab | ||||
removeTab("teal_modules-active_tab", target = "teal_data_module") | ||||
shinyjs::runjs( | ||||
sprintf( | ||||
"document.querySelector('#%s button').click();", | ||||
session$ns("close_teal_data_module_modal") | ||||
) | ||||
) | ||||
removeUI(sprintf("#%s", session$ns("open_teal_data_module_ui"))) | ||||
}) | ||||
} | ||||
} else { | ||||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Given that data module is a modal it is not needed so much to keep it in the server. IMO this can be moved to the UI