Skip to content

Commit 5ab4c7b

Browse files
paleolimbotlionel-
authored andcommitted
Store context in case objects and display it in the shiny app (#61)
1 parent 456e9da commit 5ab4c7b

File tree

5 files changed

+1419
-50
lines changed

5 files changed

+1419
-50
lines changed

R/shiny-server.R

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ vdiffrServer <- function(cases) {
2727
validateSingleCase(input, cases)
2828

2929
output$status <- renderStatus(input, cases)
30+
output$case_context <- renderCaseContext(input, cases)
3031

3132
quitApp(input)
3233
})
@@ -179,6 +180,21 @@ validateGroupCases <- function(input, reactive_cases) {
179180
})
180181
}
181182

183+
renderCaseContext <- function(input, reactive_cases) {
184+
shiny::renderUI({
185+
if(length(reactive_cases$active()) > 0 && !is.null(input$case)) {
186+
active_case <- reactive_cases$active()[[input$case]]
187+
shiny::p(
188+
shiny::strong("Context: "),
189+
shiny::span(
190+
title = active_case$path %||% "",
191+
active_case$context %||% "<none>"
192+
)
193+
)
194+
}
195+
})
196+
}
197+
182198
renderStatus <- function(input, reactive_cases) {
183199
shiny::renderUI({
184200
cases <- reactive_cases$all

R/shiny-ui.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ sidebarPanel <- function() {
1818
shiny::actionButton("group_validation_button", "Validate these"),
1919
shiny::br(),
2020
shiny::br(),
21+
shiny::uiOutput("case_context"),
2122
shiny::uiOutput("case_controls"),
2223
shiny::actionButton("case_validation_button", "Validate this"),
2324
shiny::uiOutput("status"),

R/testthat-ui.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ expect_doppelganger <- function(title,
148148
case <- case(list(
149149
name = fig_name,
150150
path = path,
151-
testcase = testcase
151+
testcase = testcase,
152+
context = context
152153
))
153154

154155
if (file.exists(path)) {

0 commit comments

Comments
 (0)