adjust tests and apply sorting
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
parent
3a1d8fa45f
commit
9d95391ff1
|
@ -220,9 +220,14 @@
|
||||||
// note: we only update the data attribute because updateIcon()
|
// note: we only update the data attribute because updateIcon()
|
||||||
if (recipients.length) {
|
if (recipients.length) {
|
||||||
$tr.attr('data-share-recipients', OCA.Sharing.Util.formatRecipients(recipients));
|
$tr.attr('data-share-recipients', OCA.Sharing.Util.formatRecipients(recipients));
|
||||||
|
var recipientData = _.mapObject(shareModel.get('shares'), function (share) {
|
||||||
|
return {shareWith: share.share_with, shareWithDisplayName: share.share_with_displayname};
|
||||||
|
});
|
||||||
|
$tr.attr('data-share-recipient-data', JSON.stringify(recipientData));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$tr.removeAttr('data-share-recipients');
|
$tr.removeAttr('data-share-recipients');
|
||||||
|
$tr.removeAttr('data-share-recipient-data');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -355,7 +355,10 @@
|
||||||
// only store the first ones, they will be the only ones
|
// only store the first ones, they will be the only ones
|
||||||
// displayed
|
// displayed
|
||||||
data.recipients[recipient] = true;
|
data.recipients[recipient] = true;
|
||||||
data.recipientData[recipientId] = recipient;
|
data.recipientData[data.recipientsCount] = {
|
||||||
|
'shareWith': recipientId,
|
||||||
|
'shareWithDisplayName': recipient
|
||||||
|
};
|
||||||
}
|
}
|
||||||
data.recipientsCount++;
|
data.recipientsCount++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,6 +140,7 @@ describe('OCA.Sharing.Util tests', function() {
|
||||||
size: 12,
|
size: 12,
|
||||||
permissions: OC.PERMISSION_ALL,
|
permissions: OC.PERMISSION_ALL,
|
||||||
shareOwner: 'User One',
|
shareOwner: 'User One',
|
||||||
|
shareOwnerId: 'User One',
|
||||||
etag: 'abc',
|
etag: 'abc',
|
||||||
shareTypes: []
|
shareTypes: []
|
||||||
}]);
|
}]);
|
||||||
|
@ -161,6 +162,16 @@ describe('OCA.Sharing.Util tests', function() {
|
||||||
size: 12,
|
size: 12,
|
||||||
permissions: OC.PERMISSION_ALL,
|
permissions: OC.PERMISSION_ALL,
|
||||||
recipientsDisplayName: 'User One, User Two',
|
recipientsDisplayName: 'User One, User Two',
|
||||||
|
recipientData: {
|
||||||
|
0: {
|
||||||
|
shareWith: 'User One',
|
||||||
|
shareWithDisplayName: 'User One'
|
||||||
|
},
|
||||||
|
1: {
|
||||||
|
shareWith: 'User Two',
|
||||||
|
shareWithDisplayName: 'User Two'
|
||||||
|
}
|
||||||
|
},
|
||||||
etag: 'abc',
|
etag: 'abc',
|
||||||
shareTypes: [OC.Share.SHARE_TYPE_USER]
|
shareTypes: [OC.Share.SHARE_TYPE_USER]
|
||||||
}]);
|
}]);
|
||||||
|
@ -264,10 +275,10 @@ describe('OCA.Sharing.Util tests', function() {
|
||||||
// simulate updating shares
|
// simulate updating shares
|
||||||
shareTab._dialog.model.set({
|
shareTab._dialog.model.set({
|
||||||
shares: [
|
shares: [
|
||||||
{share_with_displayname: 'User One'},
|
{share_with_displayname: 'User One', share_with: 'User One'},
|
||||||
{share_with_displayname: 'User Two'},
|
{share_with_displayname: 'User Two', share_with: 'User Two'},
|
||||||
{share_with_displayname: 'Group One'},
|
{share_with_displayname: 'Group One', share_with: 'Group One'},
|
||||||
{share_with_displayname: 'Group Two'}
|
{share_with_displayname: 'Group Two', share_with: 'Group Two'}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -298,9 +309,9 @@ describe('OCA.Sharing.Util tests', function() {
|
||||||
// simulate updating shares
|
// simulate updating shares
|
||||||
shareTab._dialog.model.set({
|
shareTab._dialog.model.set({
|
||||||
shares: [
|
shares: [
|
||||||
{share_with_displayname: 'User One'},
|
{share_with_displayname: 'User One', share_with: 'User One'},
|
||||||
{share_with_displayname: 'User Two'},
|
{share_with_displayname: 'User Two', share_with: 'User Two'},
|
||||||
{share_with_displayname: 'User Three'}
|
{share_with_displayname: 'User Three', share_with: 'User Three'}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -348,7 +359,8 @@ describe('OCA.Sharing.Util tests', function() {
|
||||||
size: 12,
|
size: 12,
|
||||||
permissions: OC.PERMISSION_ALL,
|
permissions: OC.PERMISSION_ALL,
|
||||||
etag: 'abc',
|
etag: 'abc',
|
||||||
shareOwner: 'User One'
|
shareOwner: 'User One',
|
||||||
|
shareOwnerId: 'User One'
|
||||||
}]);
|
}]);
|
||||||
$action = fileList.$el.find('tbody tr:first .action-share');
|
$action = fileList.$el.find('tbody tr:first .action-share');
|
||||||
$tr = fileList.$el.find('tr:first');
|
$tr = fileList.$el.find('tr:first');
|
||||||
|
@ -379,7 +391,9 @@ describe('OCA.Sharing.Util tests', function() {
|
||||||
permissions: OC.PERMISSION_ALL,
|
permissions: OC.PERMISSION_ALL,
|
||||||
etag: 'abc',
|
etag: 'abc',
|
||||||
shareOwner: 'User One',
|
shareOwner: 'User One',
|
||||||
recipients: 'User Two'
|
shareOwnerId: 'User One',
|
||||||
|
recipients: 'User Two',
|
||||||
|
recipientData: {'User Two': 'User Two'}
|
||||||
}]);
|
}]);
|
||||||
$action = fileList.$el.find('tbody tr:first .action-share');
|
$action = fileList.$el.find('tbody tr:first .action-share');
|
||||||
$tr = fileList.$el.find('tr:first');
|
$tr = fileList.$el.find('tr:first');
|
||||||
|
|
|
@ -240,13 +240,14 @@ OC.Share = _.extend(OC.Share || {}, {
|
||||||
* Loop over all recipients in the list and format them using
|
* Loop over all recipients in the list and format them using
|
||||||
* all kind of fancy magic.
|
* all kind of fancy magic.
|
||||||
*
|
*
|
||||||
* @param {String[]} recipients array of all the recipients
|
* @param {Object} recipients array of all the recipients
|
||||||
* @return {String[]} modified list of recipients
|
* @return {String[]} modified list of recipients
|
||||||
*/
|
*/
|
||||||
_formatShareList: function(recipients) {
|
_formatShareList: function(recipients) {
|
||||||
var _parent = this;
|
var _parent = this;
|
||||||
return $.map(recipients, function(shareWithDisplayName, shareWith) {
|
recipients = _.sortBy(_.toArray(recipients), 'shareWithDisplayName');
|
||||||
return _parent._formatRemoteShare(shareWith, shareWithDisplayName, t('core', 'Shared with'));
|
return $.map(recipients, function(recipient) {
|
||||||
|
return _parent._formatRemoteShare(recipient.shareWith, recipient.shareWithDisplayName, t('core', 'Shared with'));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -181,64 +181,133 @@ describe('OC.Share tests', function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
it('displays the local share owner as is', function() {
|
it('displays the local share owner as is', function() {
|
||||||
checkRecipients({'User One': 'User One'}, 'Shared with User One', null);
|
var input = {
|
||||||
|
0: {
|
||||||
|
shareWith: 'User One',
|
||||||
|
shareWithDisplayName: 'User One'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
checkRecipients(input, 'Shared with User One', null);
|
||||||
});
|
});
|
||||||
it('displays the user name part of a remote recipient', function() {
|
it('displays the user name part of a remote recipient', function() {
|
||||||
|
var input = {
|
||||||
|
0: {
|
||||||
|
shareWith: 'User One@someserver.com',
|
||||||
|
shareWithDisplayName: 'User One@someserver.com'
|
||||||
|
}
|
||||||
|
};
|
||||||
checkRecipients(
|
checkRecipients(
|
||||||
{'User One@someserver.com': 'User One@someserver.com'},
|
input,
|
||||||
'User One@…',
|
'User One@…',
|
||||||
'Shared with User One@someserver.com'
|
'Shared with User One@someserver.com'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
input = {
|
||||||
|
0: {
|
||||||
|
shareWith: 'User One@someserver.com/',
|
||||||
|
shareWithDisplayName: 'User One@someserver.com/'
|
||||||
|
}
|
||||||
|
};
|
||||||
checkRecipients(
|
checkRecipients(
|
||||||
'{User One@someserver.com/: User One@someserver.com/}',
|
input,
|
||||||
'User One@…',
|
'User One@…',
|
||||||
'Shared with User One@someserver.com'
|
'Shared with User One@someserver.com'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
input = {
|
||||||
|
0: {
|
||||||
|
shareWith: 'User One@someserver.com/root/of/nextcloud',
|
||||||
|
shareWithDisplayName: 'User One@someserver.com/root/of/nextcloud'
|
||||||
|
}
|
||||||
|
};
|
||||||
checkRecipients(
|
checkRecipients(
|
||||||
{'User One@someserver.com/root/of/owncloud': 'User One@someserver.com/root/of/owncloud'},
|
input,
|
||||||
'User One@…',
|
'User One@…',
|
||||||
'Shared with User One@someserver.com'
|
'Shared with User One@someserver.com'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('displays the user name part with domain of a remote share owner', function() {
|
it('displays the user name part with domain of a remote share owner', function() {
|
||||||
|
var input = {
|
||||||
|
0: {
|
||||||
|
shareWith: 'User One@example.com@someserver.com',
|
||||||
|
shareWithDisplayName: 'User One@example.com@someserver.com'
|
||||||
|
}
|
||||||
|
};
|
||||||
checkRecipients(
|
checkRecipients(
|
||||||
{'User One@example.com@someserver.com': 'User One@example.com@someserver.com'},
|
input,
|
||||||
'User One@example.com',
|
'User One@example.com',
|
||||||
'Shared with User One@example.com@someserver.com'
|
'Shared with User One@example.com@someserver.com'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
input = {
|
||||||
|
0: {
|
||||||
|
shareWith: 'User One@example.com@someserver.com/',
|
||||||
|
shareWithDisplayName: 'User One@example.com@someserver.com/'
|
||||||
|
}
|
||||||
|
};
|
||||||
checkRecipients(
|
checkRecipients(
|
||||||
{'User One@example.com@someserver.com/': 'User One@example.com@someserver.com/'},
|
input,
|
||||||
'User One@example.com',
|
'User One@example.com',
|
||||||
'Shared with User One@example.com@someserver.com'
|
'Shared with User One@example.com@someserver.com'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
input = {
|
||||||
|
0: {
|
||||||
|
shareWith: 'User One@example.com@someserver.com/root/of/nextcloud',
|
||||||
|
shareWithDisplayName: 'User One@example.com@someserver.com/root/of/nextcloud'
|
||||||
|
}
|
||||||
|
};
|
||||||
checkRecipients(
|
checkRecipients(
|
||||||
{'User One@example.com@someserver.com/root/of/nextcloud': 'User One@example.com@someserver.com/root/of/nextcloud'},
|
input,
|
||||||
'User One@example.com',
|
'User One@example.com',
|
||||||
'Shared with User One@example.com@someserver.com'
|
'Shared with User One@example.com@someserver.com'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('display multiple remote recipients', function() {
|
it('display multiple remote recipients', function() {
|
||||||
checkRecipients(
|
var input = {
|
||||||
{
|
0: {
|
||||||
'One@someserver.com': 'One@someserver.com',
|
shareWith: 'One@someserver.com',
|
||||||
'two@otherserver.com': 'two@otherserver.com'
|
shareWithDisplayName: 'One@someserver.com'
|
||||||
},
|
},
|
||||||
|
1: {
|
||||||
|
shareWith: 'two@someserver.com',
|
||||||
|
shareWithDisplayName: 'two@someserver.com'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
checkRecipients(
|
||||||
|
input,
|
||||||
'One@… two@…',
|
'One@… two@…',
|
||||||
['Shared with One@someserver.com', 'Shared with two@otherserver.com']
|
['Shared with One@someserver.com', 'Shared with two@otherserver.com']
|
||||||
);
|
);
|
||||||
checkRecipients(
|
|
||||||
{
|
input = {
|
||||||
'One@someserver.com/': 'One@someserver.com/',
|
0: {
|
||||||
'two@otherserver.com': 'two@otherserver.com'
|
shareWith: 'One@someserver.com/',
|
||||||
|
shareWithDisplayName: 'One@someserver.com/'
|
||||||
},
|
},
|
||||||
|
1: {
|
||||||
|
shareWith: 'two@someserver.com',
|
||||||
|
shareWithDisplayName: 'two@someserver.com'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
checkRecipients(
|
||||||
|
input,
|
||||||
'One@… two@…',
|
'One@… two@…',
|
||||||
['Shared with One@someserver.com', 'Shared with two@otherserver.com']
|
['Shared with One@someserver.com', 'Shared with two@otherserver.com']
|
||||||
);
|
);
|
||||||
checkRecipients(
|
|
||||||
{
|
input = {
|
||||||
'One@someserver.com/root/of/owncloud': 'One@someserver.com/root/of/owncloud',
|
0: {
|
||||||
'two@otherserver.com': 'two@otherserver.com'
|
shareWith: 'One@someserver.com/root/of/nextcloud',
|
||||||
|
shareWithDisplayName: 'One@someserver.com/root/of/nextcloud'
|
||||||
},
|
},
|
||||||
|
1: {
|
||||||
|
shareWith: 'two@someserver.com',
|
||||||
|
shareWithDisplayName: 'two@someserver.com'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
checkRecipients(
|
||||||
|
input,
|
||||||
'One@… two@…',
|
'One@… two@…',
|
||||||
['Shared with One@someserver.com', 'Shared with two@otherserver.com']
|
['Shared with One@someserver.com', 'Shared with two@otherserver.com']
|
||||||
);
|
);
|
||||||
|
@ -246,8 +315,14 @@ describe('OC.Share tests', function() {
|
||||||
it('display mixed recipients', function() {
|
it('display mixed recipients', function() {
|
||||||
checkRecipients(
|
checkRecipients(
|
||||||
{
|
{
|
||||||
'One': 'One',
|
0: {
|
||||||
'two@otherserver.com': 'two@otherserver.com'
|
shareWith: 'One',
|
||||||
|
shareWithDisplayName: 'One'
|
||||||
|
},
|
||||||
|
1: {
|
||||||
|
shareWith: 'two@someserver.com',
|
||||||
|
shareWithDisplayName: 'two@someserver.com'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
'Shared with One two@…',
|
'Shared with One two@…',
|
||||||
['Shared with two@otherserver.com']
|
['Shared with two@otherserver.com']
|
||||||
|
@ -256,9 +331,18 @@ describe('OC.Share tests', function() {
|
||||||
it('display multiple with divergent displaynames', function() {
|
it('display multiple with divergent displaynames', function() {
|
||||||
checkRecipients(
|
checkRecipients(
|
||||||
{
|
{
|
||||||
'One': 'Yoko Ono',
|
0: {
|
||||||
'two@otherserver.com': 'two@otherserver.com',
|
shareWith: 'One',
|
||||||
'Three': 'Green, Mina'
|
shareWithDisplayName: 'Yoko Ono'
|
||||||
|
},
|
||||||
|
1: {
|
||||||
|
shareWith: 'two@someserver.com',
|
||||||
|
shareWithDisplayName: 'two@someserver.com'
|
||||||
|
},
|
||||||
|
2: {
|
||||||
|
shareWith: 'Three',
|
||||||
|
shareWithDisplayName: 'Green, Mina'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
'Shared with Yoko Ono two@… Shared with Green, Mina',
|
'Shared with Yoko Ono two@… Shared with Green, Mina',
|
||||||
['Shared with two@otherserver.com']
|
['Shared with two@otherserver.com']
|
||||||
|
|
Loading…
Reference in New Issue