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

[stable10] use a multi line approach to display share autocomplete #35397

Merged
merged 8 commits into from
Jun 14, 2019
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 (.*)$/
Copy link
Contributor

Choose a reason for hiding this comment

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

This is specially useful for setting up a share on the remote (federated) server, and giving it some permissions.
We want to use the API to set up stuff on the remote server, rather than the webUI, because we do not want to depend on particular details of the webUI on the remote server. (The remote server might be running some older release/code that has a bit different webUI behaviour, but it should have compatible API behaviour within the same major version)

Copy link
Contributor

@phil-davis phil-davis Jun 3, 2019

Choose a reason for hiding this comment

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

In the case of this particular PR, the webUI dropdown sharing list has changed its format/text a bit, and so trying to run the new webUI sharing acceptance test code against a remote server without the PR would fail.

*
* @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 @@ -126,7 +126,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 @@ -139,6 +139,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