Skip to content

Commit

Permalink
fix: handle scenario when no jobs are found for an app
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepanshKhurana committed May 14, 2024
1 parent 6faab5b commit 19df36e
Showing 1 changed file with 37 additions and 23 deletions.
60 changes: 37 additions & 23 deletions app/view/mod_job_list.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ box::use(
getReactableState,
reactable,
reactableOutput,
renderReactable
renderReactable,
reactableLang
],
shiny[
moduleServer,
NS,
reactive,
req
req,
isTruthy
],
shinycssloaders[withSpinner],
)
Expand Down Expand Up @@ -48,25 +50,31 @@ server <- function(id, state) {

output$job_list_table <- renderReactable({

processed_jobs <- job_list_data() %>%
select(id, key, start_time, end_time) %>%
mutate(
job = paste(
id,
key,
start_time,
end_time,
sep = "_-_"
)
) %>%
select(
-c(
id,
key,
start_time,
end_time
if (length(job_list_data())) {
processed_jobs <- job_list_data() %>%
select(id, key, start_time, end_time) %>%
mutate(
job = paste(
id,
key,
start_time,
end_time,
sep = "_-_"
)
) %>%
select(
-c(
id,
key,
start_time,
end_time
)
)
} else {
processed_jobs <- data.frame(
job = character()
)
}

reactable(
data = processed_jobs,
Expand All @@ -79,16 +87,22 @@ server <- function(id, state) {
process_job_data(job_data)
}
)
),
language = reactableLang(
noData = "No jobs found."
)
)

})

state$selected_job <- reactive({
index <- getReactableState("job_list_table", "selected")
list(
"key" = job_list_data()[index, ]$key,
"id" = job_list_data()[index, ]$id
)
if (isTruthy(index)) {
list(
"key" = job_list_data()[index, ]$key,
"id" = job_list_data()[index, ]$id
)
}
})

})
Expand Down

0 comments on commit 19df36e

Please sign in to comment.