diff --git a/.circleci/config.yml b/.circleci/config.yml index 741d3bfb..d0c5eda6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,14 +9,14 @@ workflows: version: 2 Prepare-All-R-Editions: jobs: - - Build-for-r4_0_5 + - Build-for-r4_2_0 - Build-for-rLATEST jobs: - Build-for-r4_0_5: + Build-for-r4_2_0: docker: - - image: rocker/verse:4.0.5 + - image: rocker/verse:4.2 steps: - checkout @@ -34,12 +34,11 @@ jobs: - run: name: Install R dependencies command: | - R -e 'install.packages("shiny", repos = "https://cran.rstudio.com/")' - R -e 'install.packages("bs4Dash", repos = "https://cran.rstudio.com/")' R -e 'install.packages(c("shinyWidgets", "yaml", "DT", "writexl", "fresh", "miniUI", "shinyFeedback"))' - R -e 'install.packages(c("canvasXpress", "waiter", "shinyjs", "openxlsx", "spelling", "colourpicker", "lifecycle"))' + R -e 'install.packages(c("canvasXpress", "waiter", "shinyjs", "openxlsx", "openxlsx2", "spelling", "colourpicker", "lifecycle"))' + R -e 'install.packages("covr")' R -e 'install.packages("reactable")' - R -e 'install.packages("openxlsx2", repos = "https://cloud.r-project.org")' + R -e 'install.packages("bs4Dash", repos = "https://cran.rstudio.com/")' - run: name: Session information and installed package versions @@ -61,6 +60,7 @@ jobs: R CMD check *tar.gz + Build-for-rLATEST: docker: - image: rocker/verse:latest diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml deleted file mode 100644 index b3e70c68..00000000 --- a/.github/workflows/R-CMD-check.yaml +++ /dev/null @@ -1,29 +0,0 @@ -# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples -# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help -on: - push: - branches: [can-dev] - pull_request: - branches: [can-dev] - -name: R-CMD-check - -jobs: - R-CMD-check: - runs-on: ubuntu-latest - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - R_KEEP_PKG_SOURCE: yes - steps: - - uses: actions/checkout@v3 - - - uses: r-lib/actions/setup-r@v2 - with: - use-public-rspm: true - - - uses: r-lib/actions/setup-r-dependencies@v2 - with: - extra-packages: any::rcmdcheck - needs: check - - - uses: r-lib/actions/check-r-package@v2 diff --git a/DESCRIPTION b/DESCRIPTION index 1086dd70..6ea0d20c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: periscope2 Type: Package Title: Enterprise Streamlined 'shiny' Application Framework Using 'bs4Dash' -Version: 0.3.1.9000 +Version: 0.4.0.9001 Authors@R: c( person("Mohammed", "Ali", role = c("aut", "cre"), email = "mohammed@aggregate-genius.com"), person("Constance", "Brett", role = c("ctb")), @@ -18,7 +18,7 @@ License: GPL-3 Encoding: UTF-8 Language: en-US Depends: - R (>= 4.0) + R (>= 4.2) Imports: shiny (>= 1.7), bs4Dash (>= 2.3), @@ -52,3 +52,4 @@ Suggests: waiter VignetteBuilder: knitr Roxygen: list(markdown = TRUE) +StagedInstall: no diff --git a/NEWS.md b/NEWS.md index 35dc7369..20491a7d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,7 @@ -# periscope2 0.3.1 +# periscope2 0.4.0 + +## New Features +- Bumped minimum R version to 4.2 to keep up with modern shiny/promises/httr2/testthat. ## Enhancements diff --git a/R/downloadableReactTable.R b/R/downloadableReactTable.R index 6f88b9f8..f9b10bac 100644 --- a/R/downloadableReactTable.R +++ b/R/downloadableReactTable.R @@ -217,12 +217,16 @@ downloadableReactTable <- function(id, logger = NULL) { shiny::moduleServer(id, function(input, output, session) { + downloadable_module_state <- shiny::reactiveVal(list(selected_rows = NULL, table_state = NULL)) + is_stale <- shiny::reactiveVal(FALSE) + if (is.null(table_data) || !is.function(table_data)) { logerror("'table_data' parameter must be a function or reactive expression.", logger = logger) output$reactTableOutputID <- reactable::renderReactable({ NULL }) } else { table_react_params <- shiny::reactiveValues(table_data = NULL, pre_selected_rows = NULL) + if (is.null(file_name_root)) { logwarn("'file_name_root' parameter should not be NULL. Setting default value 'data_file'.", logger = logger) file_name_root <- "data_file" @@ -243,7 +247,9 @@ downloadableReactTable <- function(id, pre_selected_rows <- NULL } - shiny::observe({ + shiny::observeEvent(table_data(), { + is_stale(TRUE) + if (!is.data.frame(table_data())) { table_data <- shiny::reactiveVal(data.frame(table_data())) } @@ -256,7 +262,7 @@ downloadableReactTable <- function(id, } shiny::outputOptions(output, "displayButton", suspendWhenHidden = FALSE) - }) + }, priority = 10) shiny::observe({ table_react_params$pre_selected_rows <- NULL @@ -351,14 +357,35 @@ downloadableReactTable <- function(id, table_output }) } - shiny::reactive({ + shiny::observe({ + table_state <- reactable::getReactableState("reactTableOutputID") selected_rows <- NULL - if (!is.null(table_state) && !is.null(table_state$selected) && is.data.frame(table_data())) { - selected_rows <- table_data()[table_state$selected, ] + + # data is just re/set and new react state is not ready yet + if (is_stale()) { + # If the state is NULL or empty, it means the browser just finished resetting. + # We can turn off the stale flag. + if (is.null(table_state) || is.null(table_state$selected)) { + is_stale(FALSE) + if (!is.null(table_react_params) && !is.null(table_react_params$pre_selected_rows) && is.data.frame(table_data())) { + selected_rows <- table_data()[table_react_params$pre_selected_rows, ] + } + } + + downloadable_module_state(list(selected_rows = selected_rows, table_state = NULL)) + + } else { # the table is rendered, get the state directly from react table + if (!is.null(table_state)) { + if (!is.null(table_state$selected) && is.data.frame(table_data())) { + selected_rows <- table_data()[table_state$selected, ] + } + downloadable_module_state(list(selected_rows = selected_rows, table_state = table_state)) + } } - list(selected_rows = selected_rows, table_state = table_state) }) + + downloadable_module_state } ) } diff --git a/tests/testthat/_snaps/log_viewer.md b/tests/testthat/_snaps/log_viewer.md index 99c835d9..d7bc6408 100644 --- a/tests/testthat/_snaps/log_viewer.md +++ b/tests/testthat/_snaps/log_viewer.md @@ -23,7 +23,3 @@
-# logViewer - valid sample log - - {"x":{"tag":{"name":"Reactable","attribs":{"data":{"action":["Be Sure to Remember to Log ALL user actions","Sample Title (click for an info pop-up) started with log level