Skip to content
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

Add shiny:filedownload Javascript event #1559

Merged
merged 5 commits into from Feb 1, 2017
Merged

Add shiny:filedownload Javascript event #1559

merged 5 commits into from Feb 1, 2017

Conversation

wch
Copy link
Collaborator

@wch wch commented Jan 26, 2017

This PR does a few things that are needed for testing file downloads:

  • It adds a shiny:filedownload event in Javascript. The event object contains the ID of the downloadButton/Link. It does not contain the href, because it changes each time the application is run (if the ID is downloadData, the link looks something like session/4b3259d8737d682d272e02ecc3faba5e/download/downloadData?w=).
  • It adds the function markOutputAttrs, which can be used to mark the object returned from a render function (which is a reactive) with an attribute. When the reactive is assigned to an output value, the attribute will be copied to the corresponding observer.
  • It marks downloadHandlers so that their values are not snapshotted. As mentioned above, the value -- the href -- changes with each run of the application, so it doesn't make sense to snapshot it for testing.

// Trigger shiny:filedownload event whenever a downloadButton/Link is clicked
$(document).on('click.shinyDownloadLink', 'a.shiny-download-link', function(e) {
var evt = jQuery.Event('shiny:filedownload');
evt.name = this.id;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should set evt.href here.

#' @inheritParams markRenderFunction
#' @param snapshotExclude If TRUE, exclude the output from test snapshots.
#'
#' @export
Copy link
Collaborator Author

@wch wch Jan 31, 2017

Choose a reason for hiding this comment

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

Don't export, and make snapshotExclude() a wrapper function.

@wch wch merged commit ef5e4cd into master Feb 1, 2017
@wch wch deleted the wch/download-event branch February 1, 2017 02:29
@wch wch removed the review label Feb 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant