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

FEATURE: Filter users by role #5209

Open
wants to merge 1 commit into
base: 8.4
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,50 @@ protected function initializeAction()
* @param string $sortDirection
* @return void
*/
public function indexAction(string $searchTerm = '', string $sortBy = 'accounts.accountIdentifier', string $sortDirection = QueryInterface::ORDER_ASCENDING): void
{
public function indexAction(
string $searchTerm = '',
string $sortBy = 'accounts.accountIdentifier',
string $sortDirection = QueryInterface::ORDER_ASCENDING,
string $role = null,
): void {
$allowedRoles = $this->getAllowedRoles();

if (empty($searchTerm)) {
$users = $this->userService->getUsers($sortBy, $sortDirection);
} else {
$users = $this->userService->searchUsers($searchTerm, $sortBy, $sortDirection);
}

if ($role) {
$roleExists = false;
foreach ($allowedRoles as $allowedRole) {
if ($allowedRole->getIdentifier() === $role) {
$roleExists = true;
break;
}
}
if (!$roleExists) {
throw new NoSuchRoleException(sprintf('The role "%s" does not exist.', $role), 1723796893);
}

$query = $users->getQuery();
$constraints = $query->getConstraint();
$users = $query
->matching($query->logicalAnd(
$constraints,
// FIXME: The like query could yield incorrect results if the role identifier is a substring of another role identifier
$query->like('accounts.roleIdentifiers', '%' . $role . '%', false),
))->execute();
}

$this->view->assignMultiple([
'currentUser' => $this->currentUser,
'users' => $users,
'searchTerm' => $searchTerm,
'sortBy' => $sortBy,
'sortDirection' => $sortDirection,
'allowedRoles' => $allowedRoles,
'role' => $role,
]);
}

Expand Down
9 changes: 2 additions & 7 deletions Neos.Neos/Resources/Private/Styles/Modules/_Modules.scss
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,8 @@
}

.neos-search-bar {
button.neos-button {
border-right: 1px solid $grayDark;
}

a.neos-button {
border-left: 1px solid $grayDark;
}
display: flex;
gap: 1px;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
<f:form action="index">
<div class="neos-search-bar">
<f:spaceless>
<button class="neos-button"><i class="fas fa-search"></i></button>
<f:form.textfield type="search" name="searchTerm" placeholder="{neos:backend.translate(id: 'search', package: 'Neos.Neos')}" value="{searchTerm}" autofocus="autofocus" />
<f:link.action action="index" class="neos-button"><i class="fas fa-times"></i></f:link.action>
<f:form.select options="{allowedRoles}" name="role" value="{role}" optionLabelField="label" prependOptionLabel="Any role" prependOptionValue="" />
<button class="neos-button"><i class="fas fa-search"></i></button>
</f:spaceless>
</div>
</f:form>
Expand Down
2 changes: 1 addition & 1 deletion Neos.Neos/Resources/Public/JavaScript/Main.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Neos.Neos/Resources/Public/JavaScript/Main.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Neos.Neos/Resources/Public/Styles/Lite.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Neos.Neos/Resources/Public/Styles/Lite.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Neos.Neos/Resources/Public/Styles/Main.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Neos.Neos/Resources/Public/Styles/Main.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Neos.Neos/Resources/Public/Styles/Minimal.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Neos.Neos/Resources/Public/Styles/Minimal.css.map

Large diffs are not rendered by default.

Loading