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

Always enable avatars #3472

Merged
merged 1 commit into from
Feb 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 9 additions & 25 deletions apps/comments/js/commentstabview.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
var EDIT_COMMENT_TEMPLATE =
'<div class="newCommentRow comment" data-id="{{id}}">' +
' <div class="authorRow">' +
' {{#if avatarEnabled}}' +
' <div class="avatar" data-username="{{actorId}}"></div>' +
' {{/if}}' +
' <div class="author">{{actorDisplayName}}</div>' +
'{{#if isEditMode}}' +
' <a href="#" class="action delete icon icon-delete has-tooltip" title="{{deleteTooltip}}"></a>' +
Expand All @@ -44,9 +42,7 @@
var COMMENT_TEMPLATE =
'<li class="comment{{#if isUnread}} unread{{/if}}{{#if isLong}} collapsed{{/if}}" data-id="{{id}}">' +
' <div class="authorRow">' +
' {{#if avatarEnabled}}' +
' <div class="avatar" {{#if actorId}}data-username="{{actorId}}"{{/if}}> </div>' +
' {{/if}}' +
' <div class="author">{{actorDisplayName}}</div>' +
'{{#if isUserAuthor}}' +
' <a href="#" class="action edit icon icon-rename has-tooltip" title="{{editTooltip}}"></a>' +
Expand Down Expand Up @@ -85,8 +81,6 @@
this.collection.on('sync', this._onEndRequest, this);
this.collection.on('add', this._onAddModel, this);

this._avatarsEnabled = !!OC.config.enable_avatars;

this._commentMaxThreshold = this._commentMaxLength * 0.9;

// TODO: error handling
Expand All @@ -99,7 +93,6 @@
}
var currentUser = OC.getCurrentUser();
return this._template(_.extend({
avatarEnabled: this._avatarsEnabled,
actorId: currentUser.uid,
actorDisplayName: currentUser.displayName
}, params));
Expand All @@ -111,7 +104,6 @@
}
var currentUser = OC.getCurrentUser();
return this._editCommentTemplate(_.extend({
avatarEnabled: this._avatarsEnabled,
actorId: currentUser.uid,
actorDisplayName: currentUser.displayName,
newMessagePlaceholder: t('comments', 'New comment …'),
Expand All @@ -127,7 +119,6 @@
}

params = _.extend({
avatarEnabled: this._avatarsEnabled,
editTooltip: t('comments', 'Edit comment'),
isUserAuthor: OC.getCurrentUser().uid === params.actorId,
isLong: this._isLong(params.message)
Expand Down Expand Up @@ -169,9 +160,7 @@
this.$el.find('.comments').before(this.editCommentTemplate({}));
this.$el.find('.has-tooltip').tooltip();
this.$container = this.$el.find('ul.comments');
if (this._avatarsEnabled) {
this.$el.find('.avatar').avatar(OC.getCurrentUser().uid, 32);
}
this.$el.find('.avatar').avatar(OC.getCurrentUser().uid, 32);
this.delegateEvents();
this.$el.find('.message').on('keydown input change', this._onTypeComment);

Expand Down Expand Up @@ -239,12 +228,10 @@

_postRenderItem: function($el) {
$el.find('.has-tooltip').tooltip();
if(this._avatarsEnabled) {
$el.find('.avatar').each(function() {
var $this = $(this);
$this.avatar($this.attr('data-username'), 32);
});
}
$el.find('.avatar').each(function() {
var $this = $(this);
$this.avatar($this.attr('data-username'), 32);
});
},

/**
Expand All @@ -257,13 +244,10 @@
for(var i in mentions) {
var mention = '@' + mentions[i].mentionId;

var avatar = '';
if(this._avatarsEnabled) {
avatar = '<div class="avatar" '
+ 'data-user="' + _.escape(mentions[i].mentionId) + '"'
+' data-user-display-name="'
+ _.escape(mentions[i].mentionDisplayName) + '"></div>';
}
var avatar = '<div class="avatar" '
+ 'data-user="' + _.escape(mentions[i].mentionId) + '"'
+' data-user-display-name="'
+ _.escape(mentions[i].mentionDisplayName) + '"></div>';

// escape possible regex characters in the name
mention = mention.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
Expand Down
17 changes: 3 additions & 14 deletions apps/comments/tests/js/commentstabviewSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ describe('OCA.Comments.CommentsTabView tests', function() {
clock = sinon.useFakeTimers(Date.UTC(2016, 1, 3, 10, 5, 9));
fetchStub = sinon.stub(OCA.Comments.CommentCollection.prototype, 'fetchNext');
view = new OCA.Comments.CommentsTabView();
view._avatarsEnabled = false;
fileInfoModel = new OCA.Files.FileInfoModel({
id: 5,
name: 'One.txt',
Expand Down Expand Up @@ -146,7 +145,6 @@ describe('OCA.Comments.CommentsTabView tests', function() {
});

it('renders mentioned user id to avatar and displayname', function() {
view._avatarsEnabled = true;
view.collection.set(testComments);

var $comment = view.$el.find('.comment[data-id=3] .message');
Expand All @@ -158,18 +156,6 @@ describe('OCA.Comments.CommentsTabView tests', function() {
expect($comment.find('strong:last-child').text()).toEqual('Lord Banquo');
});

it('renders mentioned user id to displayname, avatars disabled', function() {
view.collection.set(testComments);

var $comment = view.$el.find('.comment[data-id=3] .message');
expect($comment.length).toEqual(1);
expect($comment.find('.avatar[data-user=macbeth]').length).toEqual(0);
expect($comment.find('strong:first-child').text()).toEqual('Thane of Cawdor');

expect($comment.find('.avatar[data-user=banquo]').length).toEqual(0);
expect($comment.find('strong:last-child').text()).toEqual('Lord Banquo');
});

});
describe('more comments', function() {
var hasMoreResultsStub;
Expand Down Expand Up @@ -316,11 +302,13 @@ describe('OCA.Comments.CommentsTabView tests', function() {
describe('editing comments', function() {
var saveStub;
var fetchStub;
var avatarStub;
var currentUserStub;

beforeEach(function() {
saveStub = sinon.stub(OCA.Comments.CommentModel.prototype, 'save');
fetchStub = sinon.stub(OCA.Comments.CommentModel.prototype, 'fetch');
avatarStub = sinon.stub($.fn, 'avatar');
currentUserStub = sinon.stub(OC, 'getCurrentUser');
currentUserStub.returns({
uid: 'testuser',
Expand Down Expand Up @@ -348,6 +336,7 @@ describe('OCA.Comments.CommentsTabView tests', function() {
afterEach(function() {
saveStub.restore();
fetchStub.restore();
avatarStub.restore();
currentUserStub.restore();
});

Expand Down
2 changes: 1 addition & 1 deletion apps/files_sharing/js/files_drop.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
};

$(document).ready(function() {
if($('#upload-only-interface').val() === "1" && oc_config.enable_avatars) {
if($('#upload-only-interface').val() === "1") {
$('.avatardiv').avatar($('#sharingUserId').val(), 128, true);
}

Expand Down
9 changes: 0 additions & 9 deletions config/config.sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,6 @@
*/
'knowledgebaseenabled' => true,

/**
* ``true`` enables avatars, or user profile photos. These appear on the User
* page, on user's Personal pages and are used by some apps (contacts, mail,
* etc). ``false`` disables them.
*
* Defaults to ``true``
*/
'enable_avatars' => true,

/**
* ``true`` allows users to change their display names (on their Personal
* pages), and ``false`` prevents them from changing their display names.
Expand Down
3 changes: 2 additions & 1 deletion core/js/shareconfigmodel.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@

/**
* @returns {boolean}
* @deprecated here for legacy reasons - will always return true
*/
areAvatarsEnabled: function() {
return oc_config.enable_avatars === true;
return true;
},

/**
Expand Down
13 changes: 4 additions & 9 deletions core/js/sharedialogresharerinfoview.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

var TEMPLATE =
'<span class="reshare">' +
' {{#if avatarEnabled}}' +
' <div class="avatar" data-userName="{{reshareOwner}}"></div>' +
' {{/if}}' +
' {{sharedByText}}' +
'</span><br/>'
;
Expand Down Expand Up @@ -93,17 +91,14 @@
}

this.$el.html(reshareTemplate({
avatarEnabled: this.configModel.areAvatarsEnabled(),
reshareOwner: this.model.getReshareOwner(),
sharedByText: sharedByText
}));

if(this.configModel.areAvatarsEnabled()) {
this.$el.find('.avatar').each(function() {
var $this = $(this);
$this.avatar($this.data('username'), 32);
});
}
this.$el.find('.avatar').each(function() {
var $this = $(this);
$this.avatar($this.data('username'), 32);
});

return this;
},
Expand Down
28 changes: 10 additions & 18 deletions core/js/sharedialogshareelistview.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
'<ul id="shareWithList" class="shareWithList">' +
'{{#each sharees}}' +
'<li data-share-id="{{shareId}}" data-share-type="{{shareType}}" data-share-with="{{shareWith}}">' +
'{{#if avatarEnabled}}' +
'<div class="avatar {{#if modSeed}}imageplaceholderseed{{/if}}" data-username="{{shareWith}}" data-displayname="{{shareWithDisplayName}}" {{#if modSeed}}data-seed="{{shareWith}} {{shareType}}"{{/if}}></div>' +
'{{/if}}' +
'<span class="has-tooltip username" title="{{shareWithTitle}}">{{shareWithDisplayName}}</span>' +
'<span class="sharingOptionsGroup">' +
'{{#if editPermissionPossible}}' +
Expand All @@ -41,9 +39,7 @@
'{{/each}}' +
'{{#each linkReshares}}' +
'<li data-share-id="{{shareId}}" data-share-type="{{shareType}}">' +
'{{#if avatarEnabled}}' +
'<div class="avatar" data-username="{{shareInitiator}}"></div>' +
'{{/if}}' +
'<span class="has-tooltip username" title="{{shareInitiator}}">' + t('core', '{{shareInitiatorDisplayName}} shared via link') + '</span>' +

'<span class="sharingOptionsGroup">' +
Expand Down Expand Up @@ -193,7 +189,6 @@

getShareProperties: function() {
return {
avatarEnabled: this.configModel.areAvatarsEnabled(),
unshareLabel: t('core', 'Unshare'),
canShareLabel: t('core', 'can reshare'),
canEditLabel: t('core', 'can edit'),
Expand Down Expand Up @@ -247,7 +242,6 @@
getLinkReshares: function() {
var universal = {
unshareLabel: t('core', 'Unshare'),
avatarEnabled: this.configModel.areAvatarsEnabled(),
};

if(!this.model.hasUserShares()) {
Expand Down Expand Up @@ -281,18 +275,16 @@
linkReshares: this.getLinkReshares()
}));

if (this.configModel.areAvatarsEnabled()) {
this.$('.avatar').each(function () {
var $this = $(this);
if ($this.hasClass('imageplaceholderseed')) {
$this.css({width: 32, height: 32});
$this.imageplaceholder($this.data('seed'));
} else {
// user, size, ie8fix, hidedefault, callback, displayname
$this.avatar($this.data('username'), 32, undefined, undefined, undefined, $this.data('displayname'));
}
});
}
this.$('.avatar').each(function () {
var $this = $(this);
if ($this.hasClass('imageplaceholderseed')) {
$this.css({width: 32, height: 32});
$this.imageplaceholder($this.data('seed'));
} else {
// user, size, ie8fix, hidedefault, callback, displayname
$this.avatar($this.data('username'), 32, undefined, undefined, undefined, $this.data('displayname'));
}
});

this.$('.has-tooltip').tooltip({
placement: 'bottom'
Expand Down
23 changes: 1 addition & 22 deletions core/js/tests/specs/sharedialogviewSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ describe('OC.Share.ShareDialogView', function() {
var $container;
var oldAppConfig;
var autocompleteStub;
var oldEnableAvatars;
var avatarStub;
var placeholderStub;
var oldCurrentUser;
Expand Down Expand Up @@ -103,8 +102,6 @@ describe('OC.Share.ShareDialogView', function() {
return $el;
});

oldEnableAvatars = oc_config.enable_avatars;
oc_config.enable_avatars = false;
avatarStub = sinon.stub($.fn, 'avatar');
placeholderStub = sinon.stub($.fn, 'imageplaceholder');

Expand All @@ -123,7 +120,6 @@ describe('OC.Share.ShareDialogView', function() {
autocompleteStub.restore();
avatarStub.restore();
placeholderStub.restore();
oc_config.enable_avatars = oldEnableAvatars;
});
describe('Share with link', function() {
// TODO: test ajax calls
Expand Down Expand Up @@ -440,18 +436,13 @@ describe('OC.Share.ShareDialogView', function() {

describe('avatars enabled', function() {
beforeEach(function() {
oc_config.enable_avatars = true;
avatarStub.reset();
dialog.render();
});

afterEach(function() {
oc_config.enable_avatars = false;
});

it('test correct function calls', function() {
expect(avatarStub.calledTwice).toEqual(true);
expect(placeholderStub.calledTwice).toEqual(true);
expect(placeholderStub.callCount).toEqual(4);
expect(dialog.$('.shareWithList').children().length).toEqual(3);
expect(dialog.$('.avatar').length).toEqual(4);
});
Expand Down Expand Up @@ -481,18 +472,6 @@ describe('OC.Share.ShareDialogView', function() {
expect(args[0]).toEqual('foo@bar.com/baz ' + OC.Share.SHARE_TYPE_REMOTE);
});
});

describe('avatars disabled', function() {
beforeEach(function() {
dialog.render();
});

it('no avatar classes', function() {
expect($('.avatar').length).toEqual(0);
expect(avatarStub.callCount).toEqual(0);
expect(placeholderStub.callCount).toEqual(0);
});
});
});
describe('remote sharing', function() {
it('shows remote share info when allowed', function() {
Expand Down
2 changes: 0 additions & 2 deletions core/templates/layout.user.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
</form>
<div id="settings">
<div id="expand" tabindex="6" role="link" class="menutoggle">
<?php if ($_['enableAvatars']): ?>
<div class="avatardiv<?php if ($_['userAvatarSet']) { print_unescaped(' avatardiv-shown'); } else { print_unescaped('" style="display: none'); } ?>">
<?php if ($_['userAvatarSet']): ?>
<img alt="" width="32" height="32"
Expand All @@ -82,7 +81,6 @@
>
<?php endif; ?>
</div>
<?php endif; ?>
<span id="expandDisplayName"><?php p(trim($_['user_displayname']) != '' ? $_['user_displayname'] : $_['user_uid']) ?></span>
<div class="icon-caret"></div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Template/JSConfigHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public function getConfig() {
'session_keepalive' => $this->config->getSystemValue('session_keepalive', true),
'version' => implode('.', \OCP\Util::getVersion()),
'versionstring' => \OC_Util::getVersionString(),
'enable_avatars' => $this->config->getSystemValue('enable_avatars', true) === true,
'enable_avatars' => true, // here for legacy reasons - to not crash existing code that relies on this value
'lost_password_link'=> $this->config->getSystemValue('lost_password_link', null),
'modRewriteWorking' => (\OC::$server->getConfig()->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true'),
]),
Expand Down
1 change: 0 additions & 1 deletion lib/private/TemplateLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ public function __construct( $renderAs, $appId = '' ) {
$this->assign('user_displayname', $userDisplayName);
$this->assign('user_uid', \OC_User::getUser());
$this->assign('appsmanagement_active', $appsMgmtActive);
$this->assign('enableAvatars', $this->config->getSystemValue('enable_avatars', true) === true);

if (\OC_User::getUser() === false) {
$this->assign('userAvatarSet', false);
Expand Down
6 changes: 2 additions & 4 deletions lib/private/legacy/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,8 @@ public static function initTemplateEngine($renderAs) {
OC_Util::addStyle("styles",null,true);

// avatars
if (\OC::$server->getSystemConfig()->getValue('enable_avatars', true) === true) {
\OC_Util::addScript('jquery.avatar', null, true);
\OC_Util::addScript('placeholder', null, true);
}
\OC_Util::addScript('jquery.avatar', null, true);
\OC_Util::addScript('placeholder', null, true);

OC_Util::addVendorScript('select2/select2');
OC_Util::addVendorStyle('select2/select2', null, true);
Expand Down
Loading