Skip to content

Commit

Permalink
Merge pull request #35397 from owncloud/bugfix/35098
Browse files Browse the repository at this point in the history
[stable10] use a multi line approach to display share autocomplete
  • Loading branch information
micbar authored Jun 14, 2019
2 parents 343f593 + 4644552 commit b214052
Show file tree
Hide file tree
Showing 10 changed files with 268 additions and 95 deletions.
6 changes: 5 additions & 1 deletion core/css/share.css
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,18 @@
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
line-height: 32px;
vertical-align: middle;
}

.share-autocomplete-item .autocomplete-item-displayname {
margin-right: 5px;
}

.share-autocomplete-item .autocomplete-item-typeInfo {
font-size: smaller;
font-style: italic;
}

.share-autocomplete-item .avatardiv {
flex-shrink: 0;
}
Expand Down
22 changes: 12 additions & 10 deletions core/js/sharedialogview.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@
'<div class="autocomplete-item-text">' +
'<span class="autocomplete-item-displayname">{{displayName}}</span>' +
'{{#if additionalInfo}}' +
'<span class="autocomplete-item-additional-info">({{additionalInfo}})</span>' +
'<br/><span class="autocomplete-item-additional-info">({{additionalInfo}})</span>' +
'{{/if}}' +
'<br/><span class="autocomplete-item-typeInfo">{{typeInfo}}</span>' +
'</div>' +
'</div>' +
'</a>' +
Expand Down Expand Up @@ -310,27 +311,28 @@
autocompleteRenderItem: function(ul, item) {

var text = item.label;
var typeInfo = t('core', 'User');
if (item.value.shareType === OC.Share.SHARE_TYPE_GROUP) {
text = t('core', '{sharee} (group)', {
sharee: text
}, null, {escape: false});
} else if (item.value.shareType === OC.Share.SHARE_TYPE_REMOTE) {
typeInfo = t('core', 'Group');
}
if (item.value.shareType === OC.Share.SHARE_TYPE_GUEST) {
typeInfo = t('core', 'Guest');
}
if (item.value.shareType === OC.Share.SHARE_TYPE_REMOTE) {
if (item.value.server) {
text = t('core', '{sharee} (at {server})', {
sharee: text,
typeInfo = t('core', 'At {server}', {
server: item.value.server
});
} else {
text = t('core', '{sharee} (federated)', {
sharee: text
});
typeInfo = t('core', 'Federated');
}
}

var template = this._getAutocompleteItemTemplate();
var $el = $(template({
showAvatar: this.configModel.areAvatarsEnabled(),
displayName: text,
typeInfo: typeInfo,
additionalInfo: item.value.shareWithAdditionalInfo,
shareTypeClass: (item.value.shareType === OC.Share.SHARE_TYPE_GROUP) ? 'group' : 'user'
}));
Expand Down
15 changes: 15 additions & 0 deletions core/js/tests/specs/sharedialogviewSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,14 @@ describe('OC.Share.ShareDialogView', function() {
'shareType': OC.Share.SHARE_TYPE_REMOTE,
'shareWith': 'foo2@bar.com/baz'
}
},
{
'label': 'foo@knowncloud.com',
'value': {
'shareType': OC.Share.SHARE_TYPE_REMOTE,
'shareWith': 'foo@knowncloud.com',
'server': 'knowncloud.com'
}
}
]
}
Expand All @@ -625,6 +633,13 @@ describe('OC.Share.ShareDialogView', function() {
expect(response.getCall(0).args[0]).toEqual([{
'label': 'foo2@bar.com/baz',
'value': {'shareType': OC.Share.SHARE_TYPE_REMOTE, 'shareWith': 'foo2@bar.com/baz'}
},{
'label': 'foo@knowncloud.com',
'value': {
'shareType': OC.Share.SHARE_TYPE_REMOTE,
'shareWith': 'foo@knowncloud.com',
'server': 'knowncloud.com'
}
}]);
expect(autocompleteStub.calledWith("option", "autoFocus", true)).toEqual(true);
});
Expand Down
50 changes: 48 additions & 2 deletions tests/acceptance/features/bootstrap/FederationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,26 @@ class FederationContext implements Context {
*/
public function userFromServerSharesWithUserFromServerUsingTheSharingAPI(
$sharerUser, $sharerServer, $sharerPath, $shareeUser, $shareeServer
) {
$this->userFromServerSharesWithUserFromServerUsingTheSharingAPIWithPermissions(
$sharerUser, $sharerServer, $sharerPath, $shareeUser, $shareeServer
);
}

/**
* @When /^user "([^"]*)" from server "(LOCAL|REMOTE)" shares "([^"]*)" with user "([^"]*)" from server "(LOCAL|REMOTE)" using the sharing API with permissions (.*)$/
*
* @param string $sharerUser
* @param string $sharerServer "LOCAL" or "REMOTE"
* @param string $sharerPath
* @param string $shareeUser
* @param string $shareeServer "LOCAL" or "REMOTE"
* @param int $permissions
*
* @return void
*/
public function userFromServerSharesWithUserFromServerUsingTheSharingAPIWithPermissions(
$sharerUser, $sharerServer, $sharerPath, $shareeUser, $shareeServer, $permissions = null
) {
if ($shareeServer == "REMOTE") {
$shareWith
Expand All @@ -68,11 +88,11 @@ public function userFromServerSharesWithUserFromServerUsingTheSharingAPI(
}
$previous = $this->featureContext->usingServer($sharerServer);
$this->featureContext->createShare(
$sharerUser, $sharerPath, 6, $shareWith, null, null, null
$sharerUser, $sharerPath, 6, $shareWith, null, null, $permissions
);
$this->featureContext->usingServer($previous);
}

/**
* @Given /^user "([^"]*)" from server "(LOCAL|REMOTE)" has shared "([^"]*)" with user "([^"]*)" from server "(LOCAL|REMOTE)"$/
*
Expand All @@ -98,6 +118,32 @@ public function userFromServerHasSharedWithUserFromServer(
);
}

/**
* @Given /^user "([^"]*)" from server "(LOCAL|REMOTE)" has shared "([^"]*)" with user "([^"]*)" from server "(LOCAL|REMOTE)" with permissions (.*)$/
*
* @param string $sharerUser
* @param string $sharerServer "LOCAL" or "REMOTE"
* @param string $sharerPath
* @param string $shareeUser
* @param string $shareeServer "LOCAL" or "REMOTE"
* @param int $permissions
*
* @return void
*/
public function userFromServerHasSharedWithUserFromServerWithPermissions(
$sharerUser, $sharerServer, $sharerPath, $shareeUser, $shareeServer, $permissions = null
) {
$this->userFromServerSharesWithUserFromServerUsingTheSharingAPIWithPermissions(
$sharerUser, $sharerServer, $sharerPath, $shareeUser, $shareeServer, $permissions
);
$this->ocsContext->assertOCSResponseIndicatesSuccess(
'Could not share file/folder! message: "' .
$this->ocsContext->getOCSResponseStatusMessage(
$this->featureContext->getResponse()
) . '"'
);
}

/**
* @When /^user "([^"]*)" from server "(LOCAL|REMOTE)" accepts the last pending share using the sharing API$/
*
Expand Down
18 changes: 17 additions & 1 deletion tests/acceptance/features/bootstrap/Provisioning.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function getUserDisplayName($username) {
}

/**
* returns an array of the display names, keyed by username
* returns an array of the user display names, keyed by username
* if no "Display Name" is set the user-name is returned instead
*
* @return array
Expand All @@ -140,6 +140,22 @@ public function getCreatedUserDisplayNames() {
return $result;
}

/**
* returns an array of the group display names, keyed by group name
* currently group name and display name are always the same, so this
* function is a convenience for getting the group names in a similar
* format to what getCreatedUserDisplayNames() returns
*
* @return array
*/
public function getCreatedGroupDisplayNames() {
$result = [];
foreach ($this->getCreatedGroups() as $groupName => $groupData) {
$result[$groupName] = $groupName;
}
return $result;
}

/**
*
* @param string $username
Expand Down
Loading

0 comments on commit b214052

Please sign in to comment.