Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Add copy shot to clipboard #4917

Merged
merged 1 commit into from
Sep 26, 2018

Conversation

chenba
Copy link
Collaborator

@chenba chenba commented Sep 18, 2018

Fixes #4776

document.addEventListener("addon-present", (e) => {
if (e.detail) {
const capabilities = JSON.parse(e.detail);
if (capabilities["copy-to-clipboard"]) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This prevents the copy button from being displayed to older versions of the addon.

style={{ height: "auto", width: Math.floor(clip.image.dimensions.x) + "px", maxWidth: "100%" }}
ref={clipImage => this.clipImage = clipImage}
src={clip.image.url}
alt={clip.image.text} />;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Only formatting changes.

<Editor clip={clip} pngToJpegCutoff={this.props.pngToJpegCutoff} onCancelEdit={this.onCancelEdit.bind(this)} onClickSave={this.onClickSave.bind(this)}></Editor>
<Editor clip={clip} pngToJpegCutoff={this.props.pngToJpegCutoff}
onCancelEdit={this.onCancelEdit.bind(this)}
onClickSave={this.onClickSave.bind(this)}></Editor>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Formatting changes.

onClick={this.onClickEdit.bind(this)}
onMouseOver={this.onMouseOverHighlight.bind(this)}
onMouseOut={this.onMouseOutHighlight.bind(this)}></div>
: null;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Formatting changes.

<span className="btn-text">Download</span>
</Localized>
</button>
</Localized></div>;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Formatting changes. ☝️

New button. 👇

<span>Download</span>
</Localized>
</button>
</Localized></div>;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Formatting changes. ☝️

New button. 👇

&:active {
background-color: $light-active;
}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Leftover styles from the report shot flag that was moved to the footer in #4687. The background image file is also removed in this PR.

@jaredhirsch
Copy link
Member

@chenba Looks like this needs a rebase

Copy link
Member

@jaredhirsch jaredhirsch left a comment

Choose a reason for hiding this comment

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

Looking at the code...I just don't know about all this. This copy button idea seems weird to me, and the implementation seems rather complex.

We are relying on the addon to actually do the copying, but don't want to show an unusable button if the addon's missing or an old version...which requires us to ping the addon first to see if it has the copy powers (messages sent as DOM events, which are slow). I'm not sure, but it seems likely to have some effect on page load time.

We're also showing website copy button click errors as desktop/Firefox notifications, which is odd, and breaks the permission model used by every other website (show a permission doorhanger before showing desktop notifications). Desktop notifications for Screenshots are fired when the addon shot creation flow fails, not when the website fails. Doing this also entails sending another message between website and addon :-(

This seems like relatively a lot of complexity for questionable value: seems likely that users who want to copy the image will know to right-click and choose "Copy Image" from the context menu. @johngruen What do you think, do we really need this copy button?

@chenba
Copy link
Collaborator Author

chenba commented Sep 20, 2018

We're also showing website copy button click errors as desktop/Firefox notifications, which is odd

+1

And good point about right click to copy.

@jaredhirsch
Copy link
Member

@chenba Yeah, sorry I didn't think to raise these points before you did all the work in this PR :-P

@jaredhirsch
Copy link
Member

Talked about this in the morning meeting, and @johngruen wants to land it and see if people like it. Merging 👍

@jaredhirsch jaredhirsch merged commit 5597b0b into mozilla-services:master Sep 26, 2018
const copyButton = <div className="copy-img-button" hidden={!this.state.canCopy}>
<Localized id="shotPageCopyButton">
<button className="nav-button icon-copy transparent copy"
title="Copy image to clipboard"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like this string wasn't exposed for localization. We'll extract is in #4935

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants