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

Sharing user consolidation #11899

Merged
merged 24 commits into from
Oct 30, 2018
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6dde7e1
Improve share select list
juliusknorr Oct 10, 2018
45d8aeb
Remove federated sharing address books which are the same as local ones
juliusknorr Oct 17, 2018
ce79e58
Filter out local users from address book remote searches
juliusknorr Oct 17, 2018
d7caf84
Filter out generic remote result for local users
juliusknorr Oct 17, 2018
e5cae30
Highlight search term in sharing results
juliusknorr Oct 17, 2018
a1c6e44
Add collaborators uuid to properly render the avatar and for later gr…
juliusknorr Oct 17, 2018
06d8438
Group share suggestions by userid
juliusknorr Oct 17, 2018
8b92a6c
Add type of properties to address book results
juliusknorr Oct 18, 2018
870e015
Add type to Remote and Mail plugins
juliusknorr Oct 18, 2018
3e11515
Merge contacts and add type of result to the UI
juliusknorr Oct 18, 2018
5059605
Increase max-width of the share autocompletion suggestions
juliusknorr Oct 18, 2018
fd08dd6
Add talk icon
juliusknorr Oct 18, 2018
3313c01
Simplify share list text
juliusknorr Oct 18, 2018
192324e
Make dropdown height 6 1/2 entries
juliusknorr Oct 23, 2018
61af607
Make enhancing entries with type property optional
juliusknorr Oct 29, 2018
7a65779
Add local share if remote cloud id matches a local user ones
juliusknorr Oct 23, 2018
e8e898e
Use tab to complete selected entry to the share entry
juliusknorr Oct 25, 2018
f116461
Show one share method per contact for inaccurate results
juliusknorr Oct 26, 2018
cb463d7
Add name field to mail and remote results
juliusknorr Oct 26, 2018
a0d759b
Add uuid/name entry to Remote/MailPlugin tests
juliusknorr Oct 30, 2018
e6952ed
Don't enforce merged property
juliusknorr Oct 30, 2018
5a73a9b
Fix injection to get the user id
juliusknorr Oct 30, 2018
b9c5e56
Update AddressBookImpl documentation
juliusknorr Oct 30, 2018
ffc3222
Styling papercuts
juliusknorr Oct 30, 2018
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
25 changes: 20 additions & 5 deletions apps/dav/lib/CardDAV/AddressBookImpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,11 @@ public function getDisplayName() {
public function search($pattern, $searchProperties, $options) {
$results = $this->backend->search($this->getKey(), $pattern, $searchProperties);

$withTypes = \array_key_exists('types', $options) && $options['types'] === true;

$vCards = [];
foreach ($results as $result) {
$vCards[] = $this->vCard2Array($result['uri'], $this->readCard($result['carddata']));
$vCards[] = $this->vCard2Array($result['uri'], $this->readCard($result['carddata']), $withTypes);
}

return $vCards;
Expand Down Expand Up @@ -220,7 +222,7 @@ protected function createEmptyVCard($uid) {
* @param VCard $vCard
juliusknorr marked this conversation as resolved.
Show resolved Hide resolved
* @return array
*/
protected function vCard2Array($uri, VCard $vCard) {
protected function vCard2Array($uri, VCard $vCard, $withTypes = false) {
$result = [
'URI' => $uri,
];
Expand Down Expand Up @@ -255,15 +257,28 @@ protected function vCard2Array($uri, VCard $vCard) {
$result[$property->name] = [];
}

$result[$property->name][] = $property->getValue();
$type = $this->getTypeFromProperty($property);
if ($withTypes) {
$result[$property->name][] = [
'type' => $type,
'value' => $property->getValue()
];
} else {
$result[$property->name][] = $property->getValue();
}


} else {
$result[$property->name] = $property->getValue();
}
}

if ($this->addressBookInfo['principaluri'] === 'principals/system/system' &&
$this->addressBookInfo['uri'] === 'system') {
if (
$this->addressBookInfo['principaluri'] === 'principals/system/system' && (
$this->addressBookInfo['uri'] === 'system' ||
$this->addressBookInfo['{DAV:}displayname'] === $this->urlGenerator->getBaseUrl()
)
) {
$result['isLocalSystemBook'] = true;
}
return $result;
Expand Down
24 changes: 22 additions & 2 deletions apps/files_sharing/css/sharetabview.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

.share-autocomplete-item {
display: flex;

&.merged {
margin-left: 32px;
}
.autocomplete-item-text {
margin-left: 10px;
margin-right: 10px;
Expand All @@ -12,6 +16,22 @@
overflow: hidden;
line-height: 32px;
vertical-align: middle;
flex-grow: 1;
.ui-state-highlight {
border: none;
margin: 0;
}
}
&.with-description {
.autocomplete-item-text {
line-height: 100%;
}
}
.autocomplete-item-details {
display: block;
line-height: 130%;
font-size: 90%;
opacity: 0.7;
}
}

Expand Down Expand Up @@ -204,8 +224,8 @@
}

.ui-autocomplete {
/* limit dropdown height to 4 1/2 entries */
max-height: calc(36px * 4.5);;
/* limit dropdown height to 6 1/2 entries */
max-height: calc(36px * 6.5);
overflow-y: auto;
overflow-x: hidden;
z-index: 1550 !important;
Expand Down
4 changes: 4 additions & 0 deletions core/css/icons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -466,3 +466,7 @@ img, object, video, button, textarea, input, select, div[contenteditable='true']
@include icon-color('search', 'actions', $color-black, 1, true);
}


.icon-talk {
@include icon-color('app-dark', 'spreed', $color-black, 1);
}
6 changes: 5 additions & 1 deletion core/css/jquery-ui-fixes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
border: 1px solid var(--color-main-background);
background: var(--color-main-background) none;
color: var(--color-text-lighter);
font-weight: 600;
juliusknorr marked this conversation as resolved.
Show resolved Hide resolved
}
.ui-state-highlight a,
.ui-widget-content .ui-state-highlight a,
Expand Down Expand Up @@ -171,9 +172,12 @@
&.ui-menu {
padding: 0;
.ui-menu-item a {
color: var(--color-text-lighter);
padding: 4px 4px 4px 14px;

&.ui-state-focus, &.ui-state-active {
font-weight: inherit;
box-shadow: inset 4px 0 var(--color-primary);
color: var(--color-text);
}
}
}
Expand Down
110 changes: 99 additions & 11 deletions core/js/sharedialogview.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,41 @@

var suggestions = exactMatches.concat(users).concat(groups).concat(remotes).concat(remoteGroups).concat(emails).concat(circles).concat(rooms).concat(lookup);

function dynamicSort(property) {
return function (a,b) {
var aProperty = '';
var bProperty = '';
if (typeof a[property] !== 'undefined') {
aProperty = a[property];
}
if (typeof b[property] !== 'undefined') {
bProperty = b[property];
}
return (aProperty < bProperty) ? -1 : (aProperty > bProperty) ? 1 : 0;
}
}

/**
* Sort share entries by uuid to properly group them
*/
var grouped = suggestions.sort(dynamicSort('uuid'));

var previousUuid = null;
var groupedLength = grouped.length;
var result = [];
/**
* build the result array that only contains all contact entries from
* merged contacts, if the search term matches its contact name
*/
for (i = 0; i < groupedLength; i++) {
if (typeof grouped[i].uuid !== 'undefined' && grouped[i].uuid === previousUuid) {
grouped[i].merged = true;
}
if (searchTerm === grouped[i].name || typeof grouped[i].merged === 'undefined') {
result.push(grouped[i]);
}
previousUuid = grouped[i].uuid;
}
var moreResultsAvailable =
(
oc_config['sharing.maxAutocompleteResults'] > 0
Expand All @@ -328,7 +363,7 @@
)
);

deferred.resolve(suggestions, exactMatches, moreResultsAvailable);
deferred.resolve(result, exactMatches, moreResultsAvailable);
} else {
deferred.reject(result.ocs.meta.message);
}
Expand Down Expand Up @@ -441,33 +476,72 @@
},

autocompleteRenderItem: function(ul, item) {

var icon = 'icon-user';
var text = item.label;
if (typeof item.name !== 'undefined') {
text = item.name;
}
if (item.value.shareType === OC.Share.SHARE_TYPE_GROUP) {
text = t('core', '{sharee} (group)', { sharee: text }, undefined, { escape: false });
icon = 'icon-contacts-dark';
} else if (item.value.shareType === OC.Share.SHARE_TYPE_REMOTE) {
text = t('core', '{sharee} (remote)', {sharee: text}, undefined, {escape: false});
icon = 'icon-shared';
} else if (item.value.shareType === OC.Share.SHARE_TYPE_REMOTE_GROUP) {
text = t('core', '{sharee} (remote group)', { sharee: text }, undefined, { escape: false });
icon = 'icon-shared';
} else if (item.value.shareType === OC.Share.SHARE_TYPE_EMAIL) {
text = t('core', '{sharee} (email)', { sharee: text }, undefined, { escape: false });
icon = 'icon-mail';
} else if (item.value.shareType === OC.Share.SHARE_TYPE_CIRCLE) {
text = t('core', '{sharee} ({type}, {owner})', {sharee: text, type: item.value.circleInfo, owner: item.value.circleOwner}, undefined, {escape: false});
icon = 'icon-circle';
} else if (item.value.shareType === OC.Share.SHARE_TYPE_ROOM) {
text = t('core', '{sharee} (conversation)', { sharee: text }, undefined, { escape: false });
icon = 'icon-talk';
}
var description = '';
var getTranslatedType = function(type) {
switch (type) {
case 'HOME':
return t('core', 'Home');
case 'WORK':
return t('core', 'Home');
case 'OTHER':
return t('core', 'Other');
default:
return type;
}
};
if (typeof item.type !== 'undefined' && item.type !== null) {
description = getTranslatedType(item.type);
}
var insert = $("<div class='share-autocomplete-item'/>");
var avatar = $("<div class='avatardiv'></div>").appendTo(insert);
if (item.value.shareType === OC.Share.SHARE_TYPE_USER || item.value.shareType === OC.Share.SHARE_TYPE_CIRCLE) {
avatar.avatar(item.value.shareWith, 32, undefined, undefined, undefined, item.label);
if (item.merged) {
insert.addClass('merged');
text = item.value.shareWith;
} else {
avatar.imageplaceholder(text, undefined, 32);
var avatar = $("<div class='avatardiv'></div>").appendTo(insert);
if (item.value.shareType === OC.Share.SHARE_TYPE_USER || item.value.shareType === OC.Share.SHARE_TYPE_CIRCLE) {
avatar.avatar(item.value.shareWith, 32, undefined, undefined, undefined, item.label);
} else {
if (typeof item.uuid === 'undefined') {
item.uuid = text;
}
avatar.imageplaceholder(item.uuid, text, 32);
}
description = item.value.shareWith;
}
if (description !== '') {
insert.addClass('with-description');
}

$("<div class='autocomplete-item-text'></div>")
.text(text)
.html(
text.replace(
new RegExp(this.term, "gi"),
"<span class='ui-state-highlight'>$&</span>")
+ '<span class="autocomplete-item-details">' + description + '</span>'
)
.appendTo(insert);
insert.attr('title', item.value.shareWith);
insert.append('<span class="icon '+icon+'" title="' + text + '"></span>');
insert = $("<a>")
.append(insert);
return $("<li>")
Expand All @@ -479,6 +553,20 @@
_onSelectRecipient: function(e, s) {
var self = this;

if (e.keyCode == 9) {
e.preventDefault();
if (typeof s.item.name !== 'undefined') {
e.target.value = s.item.name;
} else {
e.target.value = s.item.label;
}
setTimeout(function() {
$(e.target).attr('disabled', false)
.autocomplete('search', $(e.target).val());
}, 0);
return false;
}

e.preventDefault();
// Ensure that the keydown handler for the input field is not
// called; otherwise it would try to add the recipient again, which
Expand Down
21 changes: 19 additions & 2 deletions lib/private/Collaboration/Collaborators/MailPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,17 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) {
foreach ($addressBookContacts as $contact) {
if (isset($contact['EMAIL'])) {
$emailAddresses = $contact['EMAIL'];
if (!is_array($emailAddresses)) {
if (\is_string($emailAddresses)) {
$emailAddresses = [$emailAddresses];
}
foreach ($emailAddresses as $emailAddress) {
foreach ($emailAddresses as $type => $emailAddress) {
$displayName = $emailAddress;
$emailAddressType = null;
if (\is_array($emailAddress)) {
$emailAddressData = $emailAddress;
$emailAddress = $emailAddressData['value'];
$emailAddressType = $emailAddressData['type'];
}
if (isset($contact['FN'])) {
$displayName = $contact['FN'] . ' (' . $emailAddress . ')';
}
Expand Down Expand Up @@ -121,6 +127,8 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) {
if (!$this->isCurrentUser($cloud) && !$searchResult->hasResult($userType, $cloud->getUser())) {
$singleResult = [[
'label' => $displayName,
'uuid' => $contact['UID'],
'name' => $contact['FN'],
'value' => [
'shareType' => Share::SHARE_TYPE_USER,
'shareWith' => $cloud->getUser(),
Expand All @@ -142,6 +150,8 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) {
if (!$this->isCurrentUser($cloud) && !$searchResult->hasResult($userType, $cloud->getUser())) {
$userResults['wide'][] = [
'label' => $displayName,
'uuid' => $contact['UID'],
'name' => $contact['FN'],
'value' => [
'shareType' => Share::SHARE_TYPE_USER,
'shareWith' => $cloud->getUser(),
Expand All @@ -160,6 +170,9 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) {
}
$result['exact'][] = [
'label' => $displayName,
'uuid' => $contact['UID'],
'name' => $contact['FN'],
'type' => $emailAddressType ?? '',
'value' => [
'shareType' => Share::SHARE_TYPE_EMAIL,
'shareWith' => $emailAddress,
Expand All @@ -168,6 +181,9 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) {
} else {
$result['wide'][] = [
'label' => $displayName,
'uuid' => $contact['UID'],
'name' => $contact['FN'],
'type' => $emailAddressType ?? '',
'value' => [
'shareType' => Share::SHARE_TYPE_EMAIL,
'shareWith' => $emailAddress,
Expand All @@ -194,6 +210,7 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) {
if (!$searchResult->hasExactIdMatch($emailType) && filter_var($search, FILTER_VALIDATE_EMAIL)) {
$result['exact'][] = [
'label' => $search,
'uuid' => $search,
'value' => [
'shareType' => Share::SHARE_TYPE_EMAIL,
'shareWith' => $search,
Expand Down
Loading