Skip to content

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

Closed
wants to merge 3 commits into from

Conversation

rpkyle
Copy link
Contributor

@rpkyle rpkyle commented Jun 25, 2019

This PR proposes to 🔪 these Dash for R elements, which do not exist in Dash for Python:

  • layout_container_id()
  • welcome_page()
  • is.layout() -- this checked that is.component() returned TRUE, and that id == layout_container_id()

In addition, componentify() is renamed to validate_component(), which is somewhat clearer.

The primary motivation is to enforce parity with Dash for Python, and to properly expose the layout object to work with layout validation checks which are already in place.

@alexcjohnson

@rpkyle rpkyle requested a review from alexcjohnson June 25, 2019 19:21
@rpkyle rpkyle self-assigned this Jun 25, 2019
@rpkyle rpkyle added the parity Modifications to improve parity across Dash implementations label Jun 25, 2019
@@ -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)
Copy link
Collaborator

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:

dash.exceptions.NoLayoutException:
Layout must be a dash component or a function that returns a dash component.

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 into layout = function(value) {, and this whole validate_component might as well be 🔪 since it'll just be if (!is.component(x)) stop(...)

@@ -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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a case we can actually hit this stop? Doesn't the one in layout_render cover us?

Copy link
Contributor Author

@rpkyle rpkyle Jun 26, 2019

Choose a reason for hiding this comment

The 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 htmlDiv and wanted to ensure the layout was a list.

Here I'm actively trying to avoid that, so it probably does make sense to 🔪 this.

@alexcjohnson
Copy link
Collaborator

@rpkyle is this PR still relevant?

@rpkyle
Copy link
Contributor Author

rpkyle commented Aug 13, 2019

@rpkyle is this PR still relevant?

Yes, I believe so:

dashR/R/utils.R

Lines 18 to 25 in fcfedcb

# layout is really a special type of component
is.layout <- function(x) {
is.component(x) && identical(x[["props"]][["id"]], layout_container_id())
}
layout_container_id <- function() {
"_dashR-layout-container"
}

...and also:

dashR/R/dash.R

Lines 950 to 951 in fcfedcb

validate_dependency <- function(layout_, dependency) {
if (!is.layout(layout_)) stop("`layout` must be a dash layout object", call. = FALSE)

But I think that ☝️ this is now redundant, and could be removed.

We did remove welcome_page() previously, however:

#96

@alexcjohnson
Copy link
Collaborator

I notice this PR is also targeting a somewhat old branch, so perhaps it would be best to pluck the still-relevant pieces of this PR into a new branch, make a new PR, and close this one? Your call how to manage it, but it would be nice to wrap this up before it gets even more stale.

@rpkyle
Copy link
Contributor Author

rpkyle commented Aug 13, 2019

I'll do that as soon as #111 is resolved.

@rpkyle
Copy link
Contributor Author

rpkyle commented Aug 23, 2019

This PR has become stale, opening another which addresses the issues that remain and which are now summarized in #120.

@rpkyle rpkyle closed this Aug 23, 2019
@rpkyle rpkyle deleted the eliminate-layout-container-div branch August 23, 2019 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parity Modifications to improve parity across Dash implementations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants