Skip to content

Commit 6f540fc

Browse files
authored
Merge pull request #18144 from nextcloud/enh/gs/always_search_lookup
Sharee API GS fixes
2 parents c3d223f + 9b82225 commit 6f540fc

File tree

5 files changed

+33
-8
lines changed

5 files changed

+33
-8
lines changed

apps/files_sharing/js/dist/files_sharing_tab.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/files_sharing/js/dist/files_sharing_tab.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/files_sharing/lib/Capabilities.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ public function getCapabilities() {
112112
'expire_date' => ['enabled' => true]
113113
];
114114

115+
// Sharee searches
116+
$res['sharee'] = [
117+
'query_lookup_default' => $this->config->getSystemValueBool('gs.enabled', false)
118+
];
119+
115120
return [
116121
'files_sharing' => $res,
117122
];

apps/files_sharing/lib/Controller/ShareesAPIController.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,21 @@ public function search(string $search = '', string $itemType = null, int $page =
207207
$this->limit = (int) $perPage;
208208
$this->offset = $perPage * ($page - 1);
209209

210+
// In global scale mode we always search the loogup server
211+
if ($this->config->getSystemValueBool('gs.enabled', false)) {
212+
$lookup = true;
213+
$this->result['lookupEnabled'] = true;
214+
} else {
215+
$this->result['lookupEnabled'] = $this->config->getAppValue('files_sharing', 'lookupServerEnabled', 'yes') === 'yes';
216+
}
217+
210218
list($result, $hasMoreResults) = $this->collaboratorSearch->search($search, $shareTypes, $lookup, $this->limit, $this->offset);
211219

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

220227
if ($hasMoreResults) {

apps/files_sharing/src/components/SharingInput.vue

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<template>
2424
<Multiselect ref="multiselect"
2525
class="sharing-input"
26+
:clear-on-select="false"
2627
:disabled="!canReshare"
2728
:hide-selected="true"
2829
:internal-search="false"
@@ -176,10 +177,12 @@ export default {
176177
* @param {string} search the search query
177178
* @param {boolean} [lookup=false] search on lookup server
178179
*/
179-
async getSuggestions(search, lookup) {
180+
async getSuggestions(search, lookup = false) {
180181
this.loading = true
181-
lookup = lookup || false
182-
console.info(search, lookup)
182+
183+
if (OC.getCapabilities().files_sharing.sharee.query_lookup_default === true) {
184+
lookup = true
185+
}
183186
184187
const request = await axios.get(generateOcsUrl('apps/files_sharing/api/v1') + 'sharees', {
185188
params: {
@@ -215,8 +218,9 @@ export default {
215218
.sort((a, b) => a.shareType - b.shareType)
216219
217220
// lookup clickable entry
221+
// show if enabled and not already requested
218222
const lookupEntry = []
219-
if (data.lookupEnabled) {
223+
if (data.lookupEnabled && !lookup) {
220224
lookupEntry.push({
221225
isNoUser: true,
222226
displayName: t('files_sharing', 'Search globally'),
@@ -388,9 +392,18 @@ export default {
388392
*/
389393
async addShare(value) {
390394
if (value.lookup) {
391-
return this.getSuggestions(this.query, true)
395+
await this.getSuggestions(this.query, true)
396+
397+
// focus the input again
398+
this.$nextTick(() => {
399+
this.$refs.multiselect.$el.querySelector('.multiselect__input').focus()
400+
})
401+
return true
392402
}
393403
404+
// TODO: reset the search string when done
405+
// https://github.com/shentao/vue-multiselect/issues/633
406+
394407
// handle externalResults from OCA.Sharing.ShareSearch
395408
if (value.handler) {
396409
const share = await value.handler(this)

0 commit comments

Comments
 (0)