-
-
Notifications
You must be signed in to change notification settings - Fork 31
Remove welcome_page() and layout_container_id() #99
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
Changes from all commits
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 |
---|---|---|
|
@@ -445,7 +445,7 @@ Dash <- R6::R6Class( | |
if (render) private$layout_render() else private$layout_ | ||
}, | ||
layout = function(...) { | ||
private$layout_ <- if (is.function(..1)) ..1 else list(...) | ||
private$layout_ <- if (is.function(..1)) ..1 else (...) | ||
# render the layout, and then return the rendered layout without printing | ||
invisible(private$layout_render()) | ||
}, | ||
|
@@ -554,22 +554,14 @@ Dash <- R6::R6Class( | |
dependencies_internal = list(), | ||
|
||
# layout stuff | ||
layout_ = welcome_page(), | ||
layout_ = NULL, | ||
layout_ids = NULL, | ||
layout_render = function() { | ||
# assuming private$layout is either a function or a list of components... | ||
layout_ <- if (is.function(private$layout_)) private$layout_() else private$layout_ | ||
|
||
# accomodate functions that return a single component | ||
if (is.component(layout_)) layout_ <- list(layout_) | ||
|
||
# make sure we are working with a list of components | ||
layout_ <- lapply(layout_, private$componentify) | ||
|
||
# Put the list of components into a container div. I'm pretty sure dash | ||
# requires the layout to be one component, but R folks are used to | ||
# being able to supply "components" to ... | ||
layout_ <- dashHtmlComponents::htmlDiv(children = layout_, id = layout_container_id()) | ||
# ensure layout is a Dash component or collection of components | ||
layout_ <- private$validate_component(layout_) | ||
|
||
# store the layout as a (flattened) vector form since we query the | ||
# vector names several times to verify ID naming (among other things) | ||
|
@@ -731,7 +723,7 @@ Dash <- R6::R6Class( | |
other = other_files_map)) | ||
}, | ||
|
||
componentify = function(x) { | ||
validate_component = function(x) { | ||
if (is.component(x)) return(x) | ||
if (all(vapply(x, is.component, logical(1)))) return(x) | ||
stop("The layout must be a component or a collection of components", call. = FALSE) | ||
|
@@ -920,7 +912,7 @@ Dash <- R6::R6Class( | |
# @param layout | ||
# @param component a component (should be a dependency) | ||
validate_dependency <- function(layout_, dependency) { | ||
if (!is.layout(layout_)) stop("`layout` must be a dash layout object", call. = FALSE) | ||
if (!is.component(layout_)) stop("`layout` must be a Dash component or collection of components", call. = 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. Is there a case we can actually hit this 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. I have trouble seeing where this gets tripped as well; this is leftover code from the early revisions of the package. I suspect it made more sense when we wrapped the layout in an Here I'm actively trying to avoid that, so it probably does make sense to 🔪 this. |
||
if (!is.dependency(dependency)) stop("`dependency` must be a dash dependency object", call. = FALSE) | ||
|
||
valid_props <- component_props_given_id(layout, dependency$id) | ||
|
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.
In python the error we get is:
As discussed on slack earlier, seems like the same holds in R, we can't have a list/collection here either. And if this is where you'd see the error if layout was given a function with an invalid return, I'd give exactly the same error message as in Python.
That has knock-on effects - so
layout = function(...) {
should turn intolayout = function(value) {
, and this wholevalidate_component
might as well be 🔪 since it'll just beif (!is.component(x)) stop(...)