mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 16:15:42 -06:00
* Add and configure eslint-plugin-import * Fix the lint:ts npm command * Autofix + prettier all the files * Manually fix remaining files * Move jquery code in jest-setup to external file to safely reorder imports * Resolve issue caused by circular dependencies within Prometheus * Update .betterer.results * Fix missing // @ts-ignore * ignore iconBundle.ts * Fix missing // @ts-ignore
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
|
|
|
|
import config from 'app/core/config';
|
|
import { OrgUser, UsersState } from 'app/types';
|
|
|
|
export const initialState: UsersState = {
|
|
users: [] as OrgUser[],
|
|
searchQuery: '',
|
|
searchPage: 1,
|
|
canInvite: !config.externalUserMngLinkName,
|
|
externalUserMngInfo: config.externalUserMngInfo,
|
|
externalUserMngLinkName: config.externalUserMngLinkName,
|
|
externalUserMngLinkUrl: config.externalUserMngLinkUrl,
|
|
hasFetched: false,
|
|
};
|
|
|
|
const usersSlice = createSlice({
|
|
name: 'users',
|
|
initialState,
|
|
reducers: {
|
|
usersLoaded: (state, action: PayloadAction<OrgUser[]>): UsersState => {
|
|
return { ...state, hasFetched: true, users: action.payload };
|
|
},
|
|
setUsersSearchQuery: (state, action: PayloadAction<string>): UsersState => {
|
|
// reset searchPage otherwise search results won't appear
|
|
return { ...state, searchQuery: action.payload, searchPage: initialState.searchPage };
|
|
},
|
|
setUsersSearchPage: (state, action: PayloadAction<number>): UsersState => {
|
|
return { ...state, searchPage: action.payload };
|
|
},
|
|
},
|
|
});
|
|
|
|
export const { setUsersSearchQuery, setUsersSearchPage, usersLoaded } = usersSlice.actions;
|
|
|
|
export const usersReducer = usersSlice.reducer;
|
|
|
|
export default {
|
|
users: usersReducer,
|
|
};
|