@@ -71,7 +71,7 @@ tm_front_page <- function(label = "Front page",
7171 tables = list (),
7272 additional_tags = tagList(),
7373 footnotes = character (0 ),
74- show_metadata = TRUE ,
74+ show_metadata = FALSE ,
7575 datanames = if (isTRUE(show_metadata )) " all" else NULL ) {
7676 message(" Initializing tm_front_page" )
7777
@@ -81,11 +81,15 @@ tm_front_page <- function(label = "Front page",
8181 checkmate :: assert_list(tables , types = " data.frame" , names = " named" , any.missing = FALSE )
8282 checkmate :: assert_multi_class(additional_tags , classes = c(" shiny.tag.list" , " html" ))
8383 checkmate :: assert_character(footnotes , min.len = 0 , any.missing = FALSE )
84- if (! is.null(show_metadata )) {
84+ checkmate :: assert_flag(show_metadata )
85+ if (! missing(show_metadata )) {
8586 lifecycle :: deprecate_soft(
8687 when = " 0.4.0" ,
8788 what = " tm_front_page(show_metadata)" ,
88- with = " tm_front_page(datanames)"
89+ with = " tm_front_page(datanames)" ,
90+ details = c(
91+ " With `datanames` you can select which datasets are displayed." ,
92+ i = " Use `tm_front_page(datanames = 'all')` to keep the previous behavior and avoid this warning." )
8993 )
9094 }
9195 checkmate :: assert_character(datanames ,
@@ -134,11 +138,12 @@ ui_front_page <- function(id, ...) {
134138 class = " my-4" ,
135139 args $ additional_tags
136140 ),
137- tags $ div(
138- id = " front_page_metabutton" ,
139- class = " m-4" ,
140- actionButton(ns(" metadata_button" ), " Show metadata" )
141- ),
141+ if (length(args $ datanames ) > 0L ) {
142+ tags $ div(
143+ id = " front_page_metabutton" ,
144+ class = " m-4" ,
145+ actionButton(ns(" metadata_button" ), " Show metadata" )
146+ )},
142147 tags $ footer(
143148 class = " .small" ,
144149 get_footer_tags(args $ footnotes )
@@ -166,30 +171,31 @@ srv_front_page <- function(id, data, tables) {
166171 caption.placement = " top"
167172 )
168173 })
169-
170- observeEvent(
171- input $ metadata_button , showModal(
172- modalDialog(
173- title = " Metadata" ,
174- dataTableOutput(ns(" metadata_table" )),
175- size = " l" ,
176- easyClose = TRUE
174+ if (length(isolate(names(data()))) > 0L ) {
175+ observeEvent(
176+ input $ metadata_button , showModal(
177+ modalDialog(
178+ title = " Metadata" ,
179+ dataTableOutput(ns(" metadata_table" )),
180+ size = " l" ,
181+ easyClose = TRUE
182+ )
177183 )
178184 )
179- )
180185
181- metadata_data_frame <- reactive({
182- datanames <- names(data())
183- convert_metadata_to_dataframe(
184- lapply(datanames , function (dataname ) attr(data()[[dataname ]], " metadata" )),
185- datanames
186- )
187- })
186+ metadata_data_frame <- reactive({
187+ datanames <- names(data())
188+ convert_metadata_to_dataframe(
189+ lapply(datanames , function (dataname ) attr(data()[[dataname ]], " metadata" )),
190+ datanames
191+ )
192+ })
188193
189- output $ metadata_table <- renderDataTable({
190- validate(need(nrow(metadata_data_frame()) > 0 , " The data has no associated metadata" ))
191- metadata_data_frame()
192- })
194+ output $ metadata_table <- renderDataTable({
195+ validate(need(nrow(metadata_data_frame()) > 0 , " The data has no associated metadata" ))
196+ metadata_data_frame()
197+ })
198+ }
193199 })
194200}
195201
0 commit comments