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

Sharee API GS fixes #18144

Merged
merged 3 commits into from
Dec 5, 2019
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
2 changes: 1 addition & 1 deletion apps/files_sharing/js/dist/files_sharing_tab.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/files_sharing/js/dist/files_sharing_tab.js.map

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions apps/files_sharing/lib/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ public function getCapabilities() {
'expire_date' => ['enabled' => true]
];

// Sharee searches
$res['sharee'] = [
'query_lookup_default' => $this->config->getSystemValueBool('gs.enabled', false)
];

return [
'files_sharing' => $res,
];
Expand Down
9 changes: 8 additions & 1 deletion apps/files_sharing/lib/Controller/ShareesAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,21 @@ public function search(string $search = '', string $itemType = null, int $page =
$this->limit = (int) $perPage;
$this->offset = $perPage * ($page - 1);

// In global scale mode we always search the loogup server
if ($this->config->getSystemValueBool('gs.enabled', false)) {
$lookup = true;
$this->result['lookupEnabled'] = true;
} else {
$this->result['lookupEnabled'] = $this->config->getAppValue('files_sharing', 'lookupServerEnabled', 'yes') === 'yes';
}

list($result, $hasMoreResults) = $this->collaboratorSearch->search($search, $shareTypes, $lookup, $this->limit, $this->offset);

// extra treatment for 'exact' subarray, with a single merge expected keys might be lost
if(isset($result['exact'])) {
$result['exact'] = array_merge($this->result['exact'], $result['exact']);
}
$this->result = array_merge($this->result, $result);
$this->result['lookupEnabled'] = $this->config->getAppValue('files_sharing', 'lookupServerEnabled', 'yes') === 'yes';
$response = new DataResponse($this->result);

if ($hasMoreResults) {
Expand Down
23 changes: 18 additions & 5 deletions apps/files_sharing/src/components/SharingInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<template>
<Multiselect ref="multiselect"
class="sharing-input"
:clear-on-select="false"
:disabled="!canReshare"
:hide-selected="true"
:internal-search="false"
Expand Down Expand Up @@ -176,10 +177,12 @@ export default {
* @param {string} search the search query
* @param {boolean} [lookup=false] search on lookup server
*/
async getSuggestions(search, lookup) {
async getSuggestions(search, lookup = false) {
this.loading = true
lookup = lookup || false
console.info(search, lookup)

if (OC.getCapabilities().files_sharing.sharee.query_lookup_default === true) {
lookup = true
}

const request = await axios.get(generateOcsUrl('apps/files_sharing/api/v1') + 'sharees', {
params: {
Expand Down Expand Up @@ -215,8 +218,9 @@ export default {
.sort((a, b) => a.shareType - b.shareType)

// lookup clickable entry
// show if enabled and not already requested
const lookupEntry = []
if (data.lookupEnabled) {
if (data.lookupEnabled && !lookup) {
lookupEntry.push({
isNoUser: true,
displayName: t('files_sharing', 'Search globally'),
Expand Down Expand Up @@ -388,9 +392,18 @@ export default {
*/
async addShare(value) {
if (value.lookup) {
return this.getSuggestions(this.query, true)
await this.getSuggestions(this.query, true)

// focus the input again
this.$nextTick(() => {
this.$refs.multiselect.$el.querySelector('.multiselect__input').focus()
})
return true
}

// TODO: reset the search string when done
// https://github.com/shentao/vue-multiselect/issues/633

// handle externalResults from OCA.Sharing.ShareSearch
if (value.handler) {
const share = await value.handler(this)
Expand Down