mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
AdminUsers: reset page to zero on query change (#26293)
This commit is contained in:
@@ -10,8 +10,10 @@ import {
|
|||||||
userMappingInfoLoadedAction,
|
userMappingInfoLoadedAction,
|
||||||
userProfileLoadedAction,
|
userProfileLoadedAction,
|
||||||
userSessionsLoadedAction,
|
userSessionsLoadedAction,
|
||||||
|
userListAdminReducer,
|
||||||
|
queryChanged,
|
||||||
} from './reducers';
|
} from './reducers';
|
||||||
import { LdapState, LdapUser, UserAdminState, UserDTO } from 'app/types';
|
import { LdapState, LdapUser, UserAdminState, UserDTO, UserListAdminState } from 'app/types';
|
||||||
|
|
||||||
const makeInitialLdapState = (): LdapState => ({
|
const makeInitialLdapState = (): LdapState => ({
|
||||||
connectionInfo: [],
|
connectionInfo: [],
|
||||||
@@ -29,6 +31,15 @@ const makeInitialUserAdminState = (): UserAdminState => ({
|
|||||||
isLoading: true,
|
isLoading: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const makeInitialUserListAdminState = (): UserListAdminState => ({
|
||||||
|
users: [],
|
||||||
|
query: '',
|
||||||
|
page: 0,
|
||||||
|
perPage: 50,
|
||||||
|
totalPages: 1,
|
||||||
|
showPaging: false,
|
||||||
|
});
|
||||||
|
|
||||||
const getTestUserMapping = (): LdapUser => ({
|
const getTestUserMapping = (): LdapUser => ({
|
||||||
info: {
|
info: {
|
||||||
email: { cfgAttrValue: 'mail', ldapValue: 'user@localhost' },
|
email: { cfgAttrValue: 'mail', ldapValue: 'user@localhost' },
|
||||||
@@ -261,3 +272,23 @@ describe('Edit Admin user page reducer', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('User List Admin reducer', () => {
|
||||||
|
describe('When query changed', () => {
|
||||||
|
it('should reset page to 0', () => {
|
||||||
|
const initialState = {
|
||||||
|
...makeInitialUserListAdminState(),
|
||||||
|
page: 3,
|
||||||
|
};
|
||||||
|
|
||||||
|
reducerTester<UserListAdminState>()
|
||||||
|
.givenReducer(userListAdminReducer, initialState)
|
||||||
|
.whenActionIsDispatched(queryChanged('test'))
|
||||||
|
.thenStateShouldEqual({
|
||||||
|
...makeInitialUserListAdminState(),
|
||||||
|
query: 'test',
|
||||||
|
page: 0,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@@ -156,6 +156,7 @@ export const userListAdminSlice = createSlice({
|
|||||||
queryChanged: (state, action: PayloadAction<string>) => ({
|
queryChanged: (state, action: PayloadAction<string>) => ({
|
||||||
...state,
|
...state,
|
||||||
query: action.payload,
|
query: action.payload,
|
||||||
|
page: 0,
|
||||||
}),
|
}),
|
||||||
pageChanged: (state, action: PayloadAction<number>) => ({
|
pageChanged: (state, action: PayloadAction<number>) => ({
|
||||||
...state,
|
...state,
|
||||||
|
|||||||
Reference in New Issue
Block a user