Merge pull request #18144 from nextcloud/enh/gs/always_search_lookup
Sharee API GS fixes
This commit is contained in:
commit
6f540fc09d
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -112,6 +112,11 @@ class Capabilities implements ICapability {
|
||||||
'expire_date' => ['enabled' => true]
|
'expire_date' => ['enabled' => true]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Sharee searches
|
||||||
|
$res['sharee'] = [
|
||||||
|
'query_lookup_default' => $this->config->getSystemValueBool('gs.enabled', false)
|
||||||
|
];
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'files_sharing' => $res,
|
'files_sharing' => $res,
|
||||||
];
|
];
|
||||||
|
|
|
@ -207,6 +207,14 @@ class ShareesAPIController extends OCSController {
|
||||||
$this->limit = (int) $perPage;
|
$this->limit = (int) $perPage;
|
||||||
$this->offset = $perPage * ($page - 1);
|
$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);
|
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
|
// extra treatment for 'exact' subarray, with a single merge expected keys might be lost
|
||||||
|
@ -214,7 +222,6 @@ class ShareesAPIController extends OCSController {
|
||||||
$result['exact'] = array_merge($this->result['exact'], $result['exact']);
|
$result['exact'] = array_merge($this->result['exact'], $result['exact']);
|
||||||
}
|
}
|
||||||
$this->result = array_merge($this->result, $result);
|
$this->result = array_merge($this->result, $result);
|
||||||
$this->result['lookupEnabled'] = $this->config->getAppValue('files_sharing', 'lookupServerEnabled', 'yes') === 'yes';
|
|
||||||
$response = new DataResponse($this->result);
|
$response = new DataResponse($this->result);
|
||||||
|
|
||||||
if ($hasMoreResults) {
|
if ($hasMoreResults) {
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
<template>
|
<template>
|
||||||
<Multiselect ref="multiselect"
|
<Multiselect ref="multiselect"
|
||||||
class="sharing-input"
|
class="sharing-input"
|
||||||
|
:clear-on-select="false"
|
||||||
:disabled="!canReshare"
|
:disabled="!canReshare"
|
||||||
:hide-selected="true"
|
:hide-selected="true"
|
||||||
:internal-search="false"
|
:internal-search="false"
|
||||||
|
@ -176,10 +177,12 @@ export default {
|
||||||
* @param {string} search the search query
|
* @param {string} search the search query
|
||||||
* @param {boolean} [lookup=false] search on lookup server
|
* @param {boolean} [lookup=false] search on lookup server
|
||||||
*/
|
*/
|
||||||
async getSuggestions(search, lookup) {
|
async getSuggestions(search, lookup = false) {
|
||||||
this.loading = true
|
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', {
|
const request = await axios.get(generateOcsUrl('apps/files_sharing/api/v1') + 'sharees', {
|
||||||
params: {
|
params: {
|
||||||
|
@ -215,8 +218,9 @@ export default {
|
||||||
.sort((a, b) => a.shareType - b.shareType)
|
.sort((a, b) => a.shareType - b.shareType)
|
||||||
|
|
||||||
// lookup clickable entry
|
// lookup clickable entry
|
||||||
|
// show if enabled and not already requested
|
||||||
const lookupEntry = []
|
const lookupEntry = []
|
||||||
if (data.lookupEnabled) {
|
if (data.lookupEnabled && !lookup) {
|
||||||
lookupEntry.push({
|
lookupEntry.push({
|
||||||
isNoUser: true,
|
isNoUser: true,
|
||||||
displayName: t('files_sharing', 'Search globally'),
|
displayName: t('files_sharing', 'Search globally'),
|
||||||
|
@ -388,9 +392,18 @@ export default {
|
||||||
*/
|
*/
|
||||||
async addShare(value) {
|
async addShare(value) {
|
||||||
if (value.lookup) {
|
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
|
// handle externalResults from OCA.Sharing.ShareSearch
|
||||||
if (value.handler) {
|
if (value.handler) {
|
||||||
const share = await value.handler(this)
|
const share = await value.handler(this)
|
||||||
|
|
Loading…
Reference in New Issue