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

Avatars in share dialog fixes #14582

Merged
merged 1 commit into from
Mar 4, 2015
Merged

Avatars in share dialog fixes #14582

merged 1 commit into from
Mar 4, 2015

Conversation

rullzer
Copy link
Contributor

@rullzer rullzer commented Feb 27, 2015

  • Avatar for "xxxx share with you..." to the left
  • Avatars for groups and remote shares (use default placeholder)
  • Modified and added unit tests

PR for #14457. Should add more consistency to the sharedialog

@rullzer
Copy link
Contributor Author

rullzer commented Feb 27, 2015

CC @PVince81 @jancborchardt

@rullzer rullzer added this to the 8.1-current milestone Feb 27, 2015
$('#avatar-group-' + escapeHTML(shareWith)).imageplaceholder(shareWith + ' group', shareWith);
} else if (shareType === OC.Share.SHARE_TYPE_REMOTE) {
var tmpShareWith = escapeHTML(shareWith).replace(/[@\.\/]/g,"_");
$('#avatar-remote-' + tmpShareWith).imageplaceholder(shareWith);
Copy link
Contributor

Choose a reason for hiding this comment

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

The code looks ok, but I'm a bit worried that this is getting big on code duplication. But also I don't have any good idea yet how to make this look better.

Copy link
Contributor

Choose a reason for hiding this comment

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

Would be cool if we could find a way to not need to distinguish the ids between "#avatar-{user,group,remote}" but only have the same div format for all. This might be possible by using data attributes, for example "data-sharetype='user'" and "data-sharewith='someuser'".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah that could work indeed. Would require some rewriting of the avatar code. Or maybe a new function since extra logic is required. But should be doable.

Copy link
Contributor

Choose a reason for hiding this comment

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

As you like: optional.
I'm not sure it's worth spending that time, especially if at some point we want to rewrite this as a popup dialog anyway (and with using handlebars)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah better then to keep it a bit duplicated for now. And make it all nice and fancy once the popup dialog is available.

@PVince81
Copy link
Contributor

This PR will clash with: #14585

@LukasReschke did use a custom attribute there, a bit like we discussed above.

@LukasReschke
Copy link
Member

Yes – don't do what you do right now 🙈

@rullzer
Copy link
Contributor Author

rullzer commented Feb 27, 2015

Ah that looks better indeed. I'll have a look.

$('.avatar[data-user="' + escapeHTML(shareWith) + '"]').avatar(escapeHTML(shareWith), 32);
if (oc_config.enable_avatars === true) {
if (shareType === OC.Share.SHARE_TYPE_USER) {
$('.avatar[data-sharetype="user"][data-sharewith="' + escapeHTML(shareWith) + '"]').avatar(escapeHTML(shareWith), 32);
Copy link
Contributor

Choose a reason for hiding this comment

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

I know we don't have too magic characters in user names, but usually it is best to use .filterAttr('data-sharewith', shareWith') instead. This would solve all possible escaping/injection issues.

Copy link
Contributor

Choose a reason for hiding this comment

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

Store $(html) in a variable, for example $shareRow = $(html); then append it to #shareWithList.
Then you can use $shareRow.find('.avatar') without the complex filtering, because you're still working on the same row which only contains a single avatar. Will also be better for performance because it avoids complex lookups.

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 are right. That is much nicer! Fix is on the way.

@rullzer
Copy link
Contributor Author

rullzer commented Mar 2, 2015

Probably @owncloud-bot is failing because of the forced pushes... otherwise I do not really see a reason.

@scrutinizer-notifier
Copy link

The inspection completed: No issues found

@PVince81
Copy link
Contributor

PVince81 commented Mar 3, 2015

Yeah... if you see errors like "Could not checkout null" then it's the classic Jenkins fail.
For that there is a magical solution: create a second branch based on this one and make a separate PR, call it "Jenkins PR".

html += '</span>';
} else {
html += '<span class="reshare">'+t('core', 'Shared with you by {owner}', {owner: data.reshare.displayname_owner});
html += '<span class="reshare">';
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like you could move this outside the if block ?
The "span" and avatar "div" are currently repeated.
It seems the only different between the if and else is the text.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True will fix that

@PVince81
Copy link
Contributor

PVince81 commented Mar 3, 2015

This is a huge step forward since last time 😄

@rullzer
Copy link
Contributor Author

rullzer commented Mar 3, 2015

This is a huge step forward since last time 😄

Yeah my javascript fu is coming back bit by bit :P

* Avatar for "xxxx share with you..." to the left
* Avatars for groups and remote shares (use default placeholder)
* Modified and added unit tests
* Use the same css for all the avatars in the dropdown
@scrutinizer-notifier
Copy link

A new inspection was created.

@rullzer rullzer mentioned this pull request Mar 3, 2015
@scrutinizer-notifier
Copy link

The inspection completed: 3 new issues

@rullzer
Copy link
Contributor Author

rullzer commented Mar 3, 2015

Jenkins is happy in #14679

@PVince81
Copy link
Contributor

PVince81 commented Mar 4, 2015

Great stuff!

avatar-dropdown

👍

@PVince81
Copy link
Contributor

PVince81 commented Mar 4, 2015

Needs a second reviewer @jancborchardt @MorrisJobke @nickvergessen

@MorrisJobke
Copy link
Contributor

Works 👍

MorrisJobke added a commit that referenced this pull request Mar 4, 2015
Avatars in share dialog fixes
@MorrisJobke MorrisJobke merged commit f507601 into owncloud:master Mar 4, 2015
@rullzer rullzer deleted the avatar_fixes branch May 22, 2015 11:50
@lock lock bot locked as resolved and limited conversation to collaborators Aug 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants