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

New: Watermarking preferences #721

Merged
merged 2 commits into from
Mar 20, 2018
Merged

Conversation

tonyjin
Copy link
Contributor

@tonyjin tonyjin commented Mar 15, 2018

Add support for two new watermarking preferences: previewWMPref and downloadWM. previewWMPref allows configuration of the preview experience for watermarked files (do you see watermarked versions of the file or not) and downloadWM controls whether watermarked files or the original is downloaded via the download button and download() API.

Also fixed some flaky tests.

@boxcla
Copy link

boxcla commented Mar 15, 2018

Verified that @tonyjin has signed the CLA. Thanks for the pull request!

if (!canDownload(this.file, this.options)) {
this.ui.showNotification(downloadErrorMsg);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why would we show a button if they can't download? If we don't know till reps come back this will get interesting...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a public method so one could call preview.download() directly

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds good!

}
});

queryParams.response_content_disposition_type = 'attachment';
Copy link
Contributor

Choose a reason for hiding this comment

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

What does setting this to attachment accomplish?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You had this in your original PR to force Content Disposition to attachment instead of the default (inline?). I assume this came out of a conversation between you and Albert.

Copy link
Contributor

Choose a reason for hiding this comment

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

If you decide to keep this line, I think you should do an object spread / Object.assign for this. If you add this here, you will be modifying the options the user passes in, and all further uses of this.options.queryParams will have response_content_disposition_type which may not be intended

Copy link
Contributor

Choose a reason for hiding this comment

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

@tonyjin yeah I think that came from him as a way to force the browser to treat it like a DL. We should experiment if we can replace opening in the iframe with that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll be removing response_content_disposition_type since we don't need it, but I'll definitely be using Object.assign other places instead of directly modifying queryParams. Thanks for the reminder @DanDeMicco.

// are at least a `Viewer-Uploader` and no preview otherwise.
// 'none' - Forces non-watermarked previews. If the file type cannot be watermarked or the user is not at least
// a `Viewer-Uploader`, no preview is shown.
this.options.previewWMPref = options.previewWMPref || 'any';
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think the "Pref" at the end adds much

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wanted to distinguish some way between previewWM and downloadWM since one takes a string and one takes a boolean, but I'm open to dropping Pref

Copy link
Contributor

Choose a reason for hiding this comment

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

ah makes sense, make the download one a boolean like verb by adding should or force to the front?

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 to prefixing the property name to help us distinguish boolean type

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I considered shouldDownloadWM and forceDownloadWM but I'm going to keep as downloadWM since download is already a verb and I interpret the option as downloadWatermarked, which implies true/false to me, whereas I interpret previewWMPref as previewWatermark(ed/ing)Preference, which implies options other than just true/false.

*
* @return {Object} Box representation used/to be used by Preview
*/
getRepresentation() {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 good call

Add support for two new watermarking preferences: `previewWMPref` and `downloadWM`. `previewWMPref` allows configuration of the preview experience for watermarked files (do you see watermarked versions of the file or not) and `downloadWM` controls whether watermarked files or the original is downloaded via the download button and download() API.

Also fixed some flaky tests.
@tonyjin tonyjin merged commit a49f234 into box:master Mar 20, 2018
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

5 participants