-
Notifications
You must be signed in to change notification settings - Fork 4
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
First pass into workspace UI/server #124
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #124 +/- ##
===========================================
+ Coverage 64.90% 75.66% +10.76%
===========================================
Files 16 16
Lines 1681 1796 +115
===========================================
+ Hits 1091 1359 +268
+ Misses 590 437 -153 ☔ View full report in Codecov by Sentry. |
@@ -12,7 +12,7 @@ set_workspace <- function(..., title = "", settings = NULL, force = FALSE) { | |||
|
|||
set_workspace_title(title) | |||
set_workspace_settings(settings) | |||
set_workpsace_stacks(list(...)) | |||
set_workspace_stacks(list(...)) |
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.
minor typo fixed
R/ui.R
Outdated
|
||
ns <- NS(id) | ||
|
||
stacks <- get_workspace_stacks() |
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.
this feels actually a bit weird to have to get the stacks this way since workspace is not a structure like new_stack
or new_block
. I can make it work but this does not feel super in line with the rest of our API.
R/ui.R
Outdated
div( | ||
class = "d-flex justify-content-between stacks", | ||
lapply(seq_along(stacks), \(i) { | ||
generate_ui(stacks[[i]], id = ns(sprintf("mystack-%s", i))) |
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.
Same as above. I would have expected to loop over x (the workspace) and not over the result of get_workspace_stacks
.
Few notes for @nbenn:
|
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.
Lgtm. We should tweak the workspace API a bit. If in your scope you have the workspace available as x
, it feels wrong to call e.g. get_workspace_stacks()
instead of get_workspace_stacks(x)
. Happy to discuss your thoughts on whether the workspace object should remain implemented as environment or not.
|
||
ns <- NS(id) | ||
|
||
stacks <- get_workspace_stacks() |
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.
This is more a note-to-self: my workspace API here is not good. If the workspace is passed as x
you'd want to be able to call get_workspace_stacks()
as get_workspace_stacks(x)
.
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.
Yes this is weird. We can leave it as is if the time constaint is too high with other priorities. Anyway we still have #92 open so we can add a bullet point here.
}, { | ||
# We can't remove the data block if there are downstream consumers... | ||
stacks <- get_workspace_stacks() | ||
to_remove <- which(chr_ply(stacks, \(x) attr(x, "name")) == 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.
This is not wrong. From a design-perspective, it might be worthwhile to consider either passing the index from the parent scope, where it should be more easily available, no? This is also in anticipation of maybe not implementing the workspace as environment.
R/server.R
Outdated
moduleServer( | ||
id = id, | ||
function(input, output, session) { | ||
vals <- reactiveValues(stacks = list(), new_blocks = list()) |
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.
More of a naming issue (probably my understanding here is incomplete), but why the plural? Does new_blocks
actually hold on to multiple new blocks at the same time?
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.
Yes that's TRUE. This is a wrong naming because to the best of my knowledge, we only add 1 block at a time. Can you confirm @JohnCoene? That should also apply to the stack server as well:
#' @param new_blocks For dynamically inserted blocks.
#' @export
generate_server.stack <- function(x, id = NULL, new_blocks = NULL, ...) {
...
}
I can change it.
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.
Yes, this is correct.
I cannot run generate_server
on the workspace directly. I need to regenerate their UI on the correct tabs and their servers in their correct tabs/modules as well as pass the adequate new_block
reactive to each server.
R/ui.R
Outdated
radioButtons( | ||
ns("selected_block"), | ||
"Choose a block", | ||
choices = setNames(seq_len(length(list_blocks())), list_blocks()), |
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.
We have set_names()
in utils.R
, b/c I thought it was unnecessary to import an entire package for a 2-line function. This effort was thwarted by @christophsax in 3e1b971.
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.
Another remark: after checking with @JohnCoene in another PR, I might be wrong using list_blocks()
which is not exported. I should use available_blocks()
instead.
TO DO:
add way to edit stacks: pass blocks.Important: Cleanup stack inputs? observers and output (like for blocks). Below is how(OUT OF THE SCOPE OF THIS PR).input
looks like after stacks are added, cleared and reset