Skip to content

Commit 62eafdb

Browse files
Merge pull request #40413 from nextcloud/feature/sorbaugh/in-user-search
Add in:users as a search filter to limit searches to users
2 parents 6379c85 + d6e21c3 commit 62eafdb

File tree

7 files changed

+94
-3
lines changed

7 files changed

+94
-3
lines changed

apps/settings/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
'OCA\\Settings\\Middleware\\SubadminMiddleware' => $baseDir . '/../lib/Middleware/SubadminMiddleware.php',
4343
'OCA\\Settings\\Search\\AppSearch' => $baseDir . '/../lib/Search/AppSearch.php',
4444
'OCA\\Settings\\Search\\SectionSearch' => $baseDir . '/../lib/Search/SectionSearch.php',
45+
'OCA\\Settings\\Search\\UserSearch' => $baseDir . '/../lib/Search/UserSearch.php',
4546
'OCA\\Settings\\Sections\\Admin\\Additional' => $baseDir . '/../lib/Sections/Admin/Additional.php',
4647
'OCA\\Settings\\Sections\\Admin\\ArtificialIntelligence' => $baseDir . '/../lib/Sections/Admin/ArtificialIntelligence.php',
4748
'OCA\\Settings\\Sections\\Admin\\Delegation' => $baseDir . '/../lib/Sections/Admin/Delegation.php',

apps/settings/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class ComposerStaticInitSettings
5757
'OCA\\Settings\\Middleware\\SubadminMiddleware' => __DIR__ . '/..' . '/../lib/Middleware/SubadminMiddleware.php',
5858
'OCA\\Settings\\Search\\AppSearch' => __DIR__ . '/..' . '/../lib/Search/AppSearch.php',
5959
'OCA\\Settings\\Search\\SectionSearch' => __DIR__ . '/..' . '/../lib/Search/SectionSearch.php',
60+
'OCA\\Settings\\Search\\UserSearch' => __DIR__ . '/..' . '/../lib/Search/UserSearch.php',
6061
'OCA\\Settings\\Sections\\Admin\\Additional' => __DIR__ . '/..' . '/../lib/Sections/Admin/Additional.php',
6162
'OCA\\Settings\\Sections\\Admin\\ArtificialIntelligence' => __DIR__ . '/..' . '/../lib/Sections/Admin/ArtificialIntelligence.php',
6263
'OCA\\Settings\\Sections\\Admin\\Delegation' => __DIR__ . '/..' . '/../lib/Sections/Admin/Delegation.php',

apps/settings/lib/AppInfo/Application.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* @author Robin Appelman <robin@icewind.nl>
1616
* @author Roeland Jago Douma <roeland@famdouma.nl>
1717
* @author zulan <git@zulan.net>
18+
* @author Stephan Orbaugh <stephan.orbaugh@nextcloud.com>
1819
*
1920
* @license AGPL-3.0
2021
*
@@ -46,6 +47,7 @@
4647
use OCA\Settings\Middleware\SubadminMiddleware;
4748
use OCA\Settings\Search\AppSearch;
4849
use OCA\Settings\Search\SectionSearch;
50+
use OCA\Settings\Search\UserSearch;
4951
use OCA\Settings\UserMigration\AccountMigrator;
5052
use OCA\Settings\WellKnown\ChangePasswordHandler;
5153
use OCA\Settings\WellKnown\SecurityTxtHandler;
@@ -78,6 +80,7 @@ public function register(IRegistrationContext $context): void {
7880
$context->registerMiddleware(SubadminMiddleware::class);
7981
$context->registerSearchProvider(SectionSearch::class);
8082
$context->registerSearchProvider(AppSearch::class);
83+
$context->registerSearchProvider(UserSearch::class);
8184

8285
// Register listeners
8386
$context->registerEventListener(AppPasswordCreatedEvent::class, AppPasswordCreatedActivityListener::class);
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* @copyright Copyright (c) 2023 Stephan Orbaugh <stephan.orbaugh@nextcloud.com>
7+
*
8+
* @author Stephan Orbaugh <stephan.orbaugh@nextcloud.com>
9+
*
10+
*
11+
* @license GNU AGPL version 3 or any later version
12+
*
13+
* This program is free software: you can redistribute it and/or modify
14+
* it under the terms of the GNU Affero General Public License as
15+
* published by the Free Software Foundation, either version 3 of the
16+
* License, or (at your option) any later version.
17+
*
18+
* This program is distributed in the hope that it will be useful,
19+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
20+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21+
* GNU Affero General Public License for more details.
22+
*
23+
* You should have received a copy of the GNU Affero General Public License
24+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
25+
*
26+
*/
27+
namespace OCA\Settings\Search;
28+
29+
use OCP\IL10N;
30+
use OCP\IUser;
31+
use OCP\Search\IProvider;
32+
use OCP\Search\ISearchQuery;
33+
use OCP\Search\SearchResult;
34+
35+
class UserSearch implements IProvider {
36+
37+
38+
/** @var IL10N */
39+
protected $l;
40+
41+
public function __construct(
42+
IL10N $l) {
43+
$this->l = $l;
44+
}
45+
46+
/**
47+
* @inheritDoc
48+
*/
49+
public function getId(): string {
50+
return 'users';
51+
}
52+
53+
/**
54+
* @inheritDoc
55+
*/
56+
public function getName(): string {
57+
return $this->l->t('Users');
58+
}
59+
60+
/**
61+
* @inheritDoc
62+
*/
63+
public function getOrder(string $route, array $routeParameters): int {
64+
return 300;
65+
}
66+
67+
/**
68+
* @inheritDoc
69+
*/
70+
public function search(IUser $user, ISearchQuery $query): SearchResult {
71+
72+
return SearchResult::complete(
73+
$this->l->t('Users'),
74+
[]
75+
);
76+
}
77+
}

apps/settings/src/store/users.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* @author Julius Härtl <jus@bitgrid.net>
99
* @author Roeland Jago Douma <roeland@famdouma.nl>
1010
* @author Vincent Petry <vincent@nextcloud.com>
11+
* @author Stephan Orbaugh <stephan.orbaugh@nextcloud.com>
1112
*
1213
* @license AGPL-3.0-or-later
1314
*
@@ -327,6 +328,14 @@ const actions = {
327328
}
328329
searchRequestCancelSource = CancelToken.source()
329330
search = typeof search === 'string' ? search : ''
331+
332+
/**
333+
* Adding filters in the search bar such as in:files, in:users, etc.
334+
* collides with this particular search, so we need to remove them
335+
* here and leave only the original search query
336+
*/
337+
search = search.replace(/in:[^\s]+/g, '').trim()
338+
330339
group = typeof group === 'string' ? group : ''
331340
if (group !== '') {
332341
return api.get(generateOcsUrl('cloud/groups/{group}/users/details?offset={offset}&limit={limit}&search={search}', { group: encodeURIComponent(group), offset, limit, search }), {

dist/settings-vue-settings-apps-users-management.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/settings-vue-settings-apps-users-management.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.

0 commit comments

Comments
 (0)