From 65cbb1b692758ae5c6dd9bf93f1e2998d6ae9c98 Mon Sep 17 00:00:00 2001 From: "arsenij.ustjanzew" <arsenij.ustjanzew@mpi-bn.mpg.de> Date: Thu, 2 Apr 2020 11:48:12 +0200 Subject: [PATCH] removed default value and added warning if the package name could not be determined. --- R/vis_objects.R | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/R/vis_objects.R b/R/vis_objects.R index 0c4e333..5cc3917 100644 --- a/R/vis_objects.R +++ b/R/vis_objects.R @@ -5,7 +5,7 @@ #' @param package The name of the R package that defines the class(object). #' @param page The name of the page to add the object to. #' @param title An optional component title. -add_vis_object <- function(dashboard, object, package = NULL, page = "default", title = NULL, ...){ +add_vis_object <- function(dashboard, object, package, page = "default", title = NULL, ...){ sanitised_page <- i2dash:::.create_page_name(page) if (!(sanitised_page %in% names(dashboard@pages))) { warning(sprintf("i2dashboard does not contain a page named '%s'", sanitised_page)) @@ -17,8 +17,6 @@ add_vis_object <- function(dashboard, object, package = NULL, page = "default", return(dashboard) } - if(is.null(package)) package <- "unknown package name" - # Create random component for RDS filename component_id <- paste0("obj_", stringi::stri_rand_strings(1, 6)) @@ -71,5 +69,9 @@ setMethod("add_component", return(dashboard) } package <- packageSlot(component) + if(is.null(package)) { + warning("The package name of this HTML widget could not be determined. The component was not added to the dashboard.") + return(dashboard) + } add_vis_object(dashboard, component, package, page, title, ...) }) -- GitLab