Skip to content

Commit

Permalink
Merge pull request #78 from openpharma/ls_77_bug_fix_shinymanager
Browse files Browse the repository at this point in the history
fix bugs with shinymanager configuration
  • Loading branch information
jthompson-arcus authored Sep 11, 2024
2 parents 2345b75 + 0b98c19 commit b5ab475
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: clinsight
Title: ClinSight
Version: 0.0.0.9017
Version: 0.0.0.9018
Authors@R: c(
person("Leonard Daniël", "Samson", , "[email protected]", role = c("cre", "aut")),
person("GCP-Service International Ltd.& Co. KG", role = "fnd")
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ to minimize the package dependencies of the production version.
- Fixed issue with the timeline figure when a subject had no completed events.
- Fixed pre-processing bug where `get_metadata()` would error when a metadata.xlsx tab exist, but were empty
- Fixed error when running `golem::run_dev()` when `clinsight` was not installed.
- Fixed error that the app did not recognize the user roles when using `shinymanager`.
4 changes: 2 additions & 2 deletions R/app_authentication.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ initialize_credentials <- function(
"admin" = TRUE,
"name" = "Admin",
"mail" = "",
"roles" = names(get_roles_from_config())[1],
"roles" = get_roles_from_config()[1],
"sites" = "",
stringsAsFactors = FALSE,
check.names = FALSE
Expand Down Expand Up @@ -130,7 +130,7 @@ authenticate_server <- function(
inputs_list = list(
"roles" = list(
fun = "selectInput",
args = list(choices = names(all_roles), multiple = TRUE)
args = list(choices = all_roles, multiple = TRUE)
),
"sites" = list(
fun = "selectInput",
Expand Down
10 changes: 7 additions & 3 deletions R/app_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,12 @@ app_server <- function(

user_error <- reactiveVal()
observeEvent(res_auth, {
if(identical(get_golem_config("user_identification"), "shinymanager")){
req(res_auth[["user"]])
}
r$user_name <- res_auth[["name"]] %||% res_auth[["user"]] %||% ""
r$user_roles <- names(res_auth[["roles"]]) %||% ""
r$user_role <- names(res_auth[["roles"]])[1] %||% ""
r$user_roles <- names(get_valid_roles(res_auth[["roles"]])) %||% ""
r$user_role <- r$user_roles[1]
user_error(NULL)
if(r$user_name == ""){
user_error("No valid user name provided. ")
Expand Down Expand Up @@ -286,6 +289,7 @@ app_server <- function(
shiny::exportTestValues(
user_db = user_db,
active_participant = r$subject_id,
active_form = navinfo$active_form
active_form = navinfo$active_form,
user_error = user_error()
)
}
4 changes: 2 additions & 2 deletions R/mod_queries.R
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ mod_queries_server <- function(id, r, navinfo, all_forms, db_path, table_names){

initial_queries <- reactive({
df <- with(r$query_data, r$query_data[n == 1, ] )
if(nrow(df) == 0) return(df)
if(identical(nrow(df),0)) return(df)
df <- df |>
dplyr::slice_min(timestamp, by = c(subject_id, event_label, query_id)) |>
dplyr::arrange(.data[["resolved"]], .data[["type"]])

if(input$show_resolved) return(df)
if(isTRUE(input$show_resolved)) return(df)
with(df, df[resolved == "No", ] )
})

Expand Down
2 changes: 1 addition & 1 deletion inst/golem-config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
default:
golem_name: clinsight
golem_version: 0.0.0.9017
golem_version: 0.0.0.9018
app_prod: no
user_identification: test_user
study_data: !expr clinsight::clinsightful_data
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-app_authentication.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ describe(
app$click("auth-go_auth")
app$wait_for_idle()
app$expect_values(input = TRUE, output = TRUE)
expect_null(app$get_value(export = "user_error"))

# After login, connection with the shiny app is lost in shinytest2, and
# therefore further automated tests dont work. Dont know how to solve this at the moment.
Expand Down

0 comments on commit b5ab475

Please sign in to comment.