Skip to content
This repository has been archived by the owner on May 22, 2021. It is now read-only.

Handle copy clipboard disabled #409

Merged
merged 1 commit into from
Aug 4, 2017
Merged

Handle copy clipboard disabled #409

merged 1 commit into from
Aug 4, 2017

Conversation

Johann-S
Copy link
Contributor

@Johann-S Johann-S commented Aug 3, 2017

Should handle disabled copy to clipboard.

But I have to find a way for something better than that :
image

Fixes #108

@ericawright ericawright self-requested a review August 3, 2017 14:24
@@ -18,6 +18,21 @@ if (storage.has('referrer')) {
window.referrer = 'external';
}

const allowedCopy = () => {
const support = !!document.queryCommandSupported
return support ? document.queryCommandSupported('copy') : false
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oups I should add semicolons here

$('#link').attr('disabled', false);
$copyBtn.attr('data-l10n-id', 'copyUrlFormButton');
}, 3000);
const copyResult = copyToClipboard($('#link').attr('value'));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

copyResult not necessary

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@@ -79,23 +94,21 @@ $(document).ready(function() {
sendEvent('sender', 'copied', {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we move the GA event inside of the if (allowedCopy()) { block?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure 👍

$('#link').attr('disabled', false);
$copyBtn.attr('data-l10n-id', 'copyUrlFormButton');
}, 3000);
const copyResult = copyToClipboard($('#link').attr('value'));
Copy link
Contributor

Choose a reason for hiding this comment

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

copyToClipboard($('#link').attr('value')) should also move inside the if block

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure that's what I'll do 👍

@@ -504,6 +509,7 @@ tbody {
background: #05a700;
border: 1px solid #05a700;
cursor: auto;
opacity: 0.3;
Copy link
Contributor

Choose a reason for hiding this comment

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

what's this for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just a question of opinion but for me it's a better visual feedbacks for the users

Copy link
Contributor

Choose a reason for hiding this comment

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

oh sorry, I read it wrong. I thought it was within .popup. this is good

@@ -345,6 +358,9 @@ $(document).ready(function() {
class: 'icon-copy',
'data-l10n-id': 'copyUrlHover'
});
if (!allowedCopy()) {
$copyIcon.addClass('disabled');
Copy link
Contributor

@ericawright ericawright Aug 3, 2017

Choose a reason for hiding this comment

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

since 'disabled' is really common, can we add a 'disabled' attribute instead? Then check the css with :disabled
we already have a rule for #copy-btn:disabled that can be reused.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure 👍

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 push changes you asked, but for this change #copy-btn:disabled rule cannot be reused because .icon-copy is an image but I used disabled attribute instead of .disabled

@ericawright
Copy link
Contributor

thanks so much @Johann-S for taking this one :)

@Johann-S
Copy link
Contributor Author

Johann-S commented Aug 4, 2017

You're welcome @ericawright a pleasure to help Mozilla 👍

Just a question out of the scope of this PR, are you open for some refactorisation of your front JavaScript because I noticed some bad practices (events alias, duplicate selectors...) ?

@ericawright
Copy link
Contributor

ericawright commented Aug 4, 2017

@Johann-S of course, you can open a bug explaining each of the changes needed, or you can just go ahead and open a PR.
oh, but not for this one preferably

@Johann-S
Copy link
Contributor Author

Johann-S commented Aug 4, 2017

Oh ok so should I revert this change : https://github.com/Johann-S/send/blob/patch-1/frontend/src/upload.js#L113-L119 ?

@ericawright
Copy link
Contributor

It's a good change, but it's unrelated to the current changes. if it's just that then it's fine, might as well leave it in. but if there are other unrelated changes then a separate PR would make it clearer to review

@Johann-S
Copy link
Contributor Author

Johann-S commented Aug 4, 2017

No it's the only one 👍

My last concern about this PR, it's when we want to copy an old uploaded file link and if copy/paste command isn't available currently it's isn't possible 🤔

That's why I shown this image :
image

Should I change the icon by an input with the URL ? Maybe If we can have a QRCode for each link it will be a good solution to show a Popover with the QRCode (asked feature here : #423)

@ericawright
Copy link
Contributor

ericawright commented Aug 4, 2017

I see. I'd be willing to merge this without that enhancement, but yes, it would be more convenient to show the URL there.
Design wise, I think it could work if it is in an container that is the length of the header, but no longer. And the text inside can scroll to select it all. then we don't stretch the table wider nor higher.
Fortunately very few people should actually have copy disabled.

@Johann-S
Copy link
Contributor Author

Johann-S commented Aug 4, 2017

I think if it's ok for you, you can merge this PR, and I'll make a new PR for this issue when I'll find time to work on that 👍

@ericawright ericawright merged commit 6dcbc19 into mozilla:master Aug 4, 2017
@Johann-S Johann-S deleted the patch-1 branch August 4, 2017 14:41
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.

2 participants