-
-
Notifications
You must be signed in to change notification settings - Fork 41
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
910 Remove Report Previewer column #919
910 Remove Report Previewer column #919
Conversation
Code Coverage Summary
Diff against main
Results for commit: fe4f9c5 Minimum allowed coverage is ♻️ This comment has been updated with latest results |
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! 💯
Tested on {teal.gallery} longitudinal app with module_specific = TRUE
param.
It's unfortunate that we need to rely on a hardcoded string, but it's unlikely it will change.
Food for thought before merging:
- Do you think it's worth checking if it's also the last element
- that is: avoid removing modules if a user manually names one "Report previewer"
Tricky question. If an app dev decides to name a module I guess the question is how likely is it that an app dev names a module |
Tricky indeed. Then it would have to check if there is there is any That looks like a dark and long rabbit hole. As far as I can see, it's not easy to detect if the
I tried to name it and it seemed to work (and hide on filter manager) |
However, this seems so farfetched, that it may be better to accept this scenario or:
|
It does but I have a feeling it shouldn't and it didn't use to. @donyunardi @lcd2yyz do you think we can forbid that? |
This line will always force "Report previewer" to be the last module, after all other modules. Lines 238 to 240 in 139971a
An alternative way is to combine the ideas that you both presented: check if the last element of the
teal/R/reporter_previewer_module.R Lines 15 to 17 in 139971a
At the moment, I'd say it's very unlikely. @chlebowa WDYT?
I am not aware of any restrictions on module names. I'd suggest we pursue this option if we see it's happening to avoid scope creep of this PR. |
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.
Maybe a record in NEWS?
Not always because one can run an app with modules that do not use reporters and name the first module
Then again, the module is not meant to be called explicitly and is added automatically by
|
R/module_filter_manager.R
Outdated
# Report Previewer will not be displayed. | ||
mm[!grepl("Report previewer", names(mm))] |
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.
Not always because one can run an app with modules that do not use reporters and name the first module "Report previewer", however unlikely that may be.
I am aware of that. To make it clear, I was thinking something like this:
# Report Previewer will not be displayed. | |
mm[!grepl("Report previewer", names(mm))] | |
# Report Previewer will not be displayed. | |
if ("Report previewer" %in% names(mm)[length(mm)]) { | |
mm <- mm[, -length(mm)] | |
} | |
mm |
This way, even though we have a user module with "Report previewer" as the label name in the first module, it will not be removed. We only check the last element of mm
.
WDYT?
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.
Made suggestion on optimizing some code.
Everything else looks good.
Thanks @chlebowa !
stop( | ||
sprintf("module(label = \"%s\", ...\n ", label), | ||
"Label 'global_filters' is reserved in teal. Please change to something else.", | ||
call. = FALSE | ||
) | ||
} | ||
if (label == "Report previewer") { | ||
stop( | ||
sprintf("module(label = \"%s\", ...\n ", label), | ||
"Label 'Report previewer' is reserved in teal.", | ||
call. = FALSE | ||
) |
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.
stop( | |
sprintf("module(label = \"%s\", ...\n ", label), | |
"Label 'global_filters' is reserved in teal. Please change to something else.", | |
call. = FALSE | |
) | |
} | |
if (label == "Report previewer") { | |
stop( | |
sprintf("module(label = \"%s\", ...\n ", label), | |
"Label 'Report previewer' is reserved in teal.", | |
call. = FALSE | |
) | |
if (label %in% c("global_filters", "Report previewer")) { | |
stop( | |
sprintf( | |
"module(label = %1$s, ... | |
Label %1$s is reserved in teal. Please change to something else. | |
", | |
label | |
), | |
call. = FALSE | |
) | |
} |
Perhaps we can combine the code for optimization?
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.
The line break within the fmt
string adds loads of white space to the message, you should do
sprintf(
"module(label = \"%s\", ...\n %s",
label,
"Label 'global_filters' is reserved in teal. Please change to something else."
)
The benchmark is exactly the same, down to a microsecond.
Unit: microseconds
expr min lq mean median uq max neval cld
new 36.793 41.2085 51.34256 44.1210 52.019 275.206 500 a
current 36.873 41.2010 51.51580 44.2335 50.337 289.881 500 a
The current is 3 lines less.
Fixes #910
The column named
"Report previewer"
is removed from the mapping matrix display.Since the data.frame sent to
renderTable
potentially has one less column, thealign
argument is modified accordingly.Additionally,
"Report previewer"
has been reserved as a module label during module creation, much like"global_filters"
.Since the actual previewer is supposed to have that label, it is set after the module is created.
This will only work as long as the name
"Report previewer"
does not change.