-
Notifications
You must be signed in to change notification settings - Fork 1
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
Feat: Graceful Handling of First-touch API Call (App List) #12
Changes from 6 commits
0ecce97
332c218
c0b2772
424e98a
f65a2f6
02ba4d8
1c9ae9d
33f64c7
ec075a9
2398cc4
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
box::use( | ||
shiny[ | ||
div, | ||
img, | ||
p, | ||
renderUI | ||
] | ||
) | ||
|
||
#' @description Function to generate an empty state UI | ||
#' @param text Text to display in the empty state | ||
#' @param image_path Path to the image to display in the empty state | ||
#' @export | ||
generate_empty_state_ui <- function( | ||
text = "Select an application and a job to view logs", | ||
image_path = "static/illustrations/empty_state.svg" | ||
) { | ||
renderUI({ | ||
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. suggestion: i think it's better to make a function that is not shiny-specific, i.e. remove |
||
div( | ||
class = "empty-state-container", | ||
p( | ||
class = "empty-state-text", | ||
text | ||
), | ||
img( | ||
src = image_path, | ||
class = "empty-state-image", | ||
alt = text | ||
) | ||
) | ||
}) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ box::use( | |
|
||
box::use( | ||
app/logic/api_utils[get_app_list], | ||
app/logic/empty_state_utils[generate_empty_state_ui], | ||
app/view/mod_app_table, | ||
app/view/mod_header, | ||
app/view/mod_job_list, | ||
|
@@ -79,18 +80,12 @@ server <- function(id) { | |
|
||
mod_app_table$server( | ||
"app_table", | ||
app_list() %>% | ||
select( | ||
guid, | ||
name, | ||
r_version, | ||
dashboard_url, | ||
last_deployed_time | ||
), | ||
app_list(), | ||
state | ||
) | ||
|
||
observeEvent(state$selected_app()$guid, { | ||
|
||
if (isTruthy(state$selected_app()$guid)) { | ||
|
||
output$job_list_pane <- renderUI({ | ||
|
@@ -101,12 +96,16 @@ server <- function(id) { | |
"job_list", | ||
state | ||
) | ||
|
||
} else { | ||
|
||
removeUI(ns("job_list_pane")) | ||
|
||
} | ||
}, ignoreInit = TRUE, ignoreNULL = TRUE) | ||
}, ignoreInit = FALSE, ignoreNULL = FALSE) | ||
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. nitpick: |
||
|
||
observeEvent(state$selected_job()$key, { | ||
|
||
if (isTruthy(state$selected_job()$key)) { | ||
|
||
output$logs_pane <- renderUI({ | ||
|
@@ -118,21 +117,22 @@ server <- function(id) { | |
state | ||
) | ||
} else { | ||
output$logs_pane <- renderUI({ | ||
div( | ||
class = "empty-state-container", | ||
p( | ||
class = "empty-state-text", | ||
"Select an application and a job to view logs" | ||
), | ||
img( | ||
src = "static/empty_state.svg", | ||
class = "empty-state-image", | ||
alt = "Select an application and a job to view logs" | ||
) | ||
|
||
if (class(app_list()) != "data.frame") { | ||
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. suggestion: prefer `inherits(app_list(), "data.frame") x <- dplyr::as_tibble(mtcars)
class(x) # "tbl_df" "tbl" "data.frame"
class(x) != "data.frame" TRUE TRUE FALSE
inherits(x, "data.frame") # TRUE |
||
empty_state <- generate_empty_state_ui( | ||
text = "Oops! Can't read apps from Posit Connect.", | ||
image_path = "static/illustrations/missing_apps.svg" | ||
) | ||
}) | ||
} else { | ||
empty_state <- generate_empty_state_ui( | ||
text = "Select an application and a job to view logs.", | ||
image_path = "static/illustrations/empty_state.svg" | ||
) | ||
} | ||
|
||
output$logs_pane <- empty_state | ||
} | ||
|
||
}, ignoreInit = FALSE, ignoreNULL = FALSE) | ||
|
||
}) | ||
|
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.
nitpick: prefer trailing comma