grafana/public/app/features/users/state/selectors.ts
Eric Leijonmarck f05607d4c0 UserTableView: Show user name in table view (#18108)
* refactor to multiple rows

* added name for org user struct

* added name getorgusers

* added user name to tableview

* made test pass

* updated userMocks to user name field

* added missing UsersTable snapshot

* added name on teammembers page, be able to search query for name, login and email

* added the updated snapshots

* conform to same sorting as output form

* conform to previous way of using it

* sort first by login and after by email, as it was before
2019-11-21 12:44:46 +02:00

21 lines
657 B
TypeScript

import { UsersState } from 'app/types';
export const getUsers = (state: UsersState) => {
const regex = new RegExp(state.searchQuery, 'i');
return state.users.filter(user => {
return regex.test(user.login) || regex.test(user.email) || regex.test(user.name);
});
};
export const getInvitees = (state: UsersState) => {
const regex = new RegExp(state.searchQuery, 'i');
return state.invitees.filter(invitee => {
return regex.test(invitee.name) || regex.test(invitee.email);
});
};
export const getInviteesCount = (state: UsersState) => state.invitees.length;
export const getUsersSearchQuery = (state: UsersState) => state.searchQuery;