mirror of
https://github.com/grafana/grafana.git
synced 2025-02-10 23:55:47 -06:00
09b434bdd0
Allow api to accept inviting existing users when login form is disabled. UI shows invite button when login form is disabled.
34 lines
983 B
TypeScript
34 lines
983 B
TypeScript
import { Invitee, OrgUser, UsersState } from 'app/types';
|
|
import { Action, ActionTypes } from './actions';
|
|
import config from 'app/core/config';
|
|
|
|
export const initialState: UsersState = {
|
|
invitees: [] as Invitee[],
|
|
users: [] as OrgUser[],
|
|
searchQuery: '',
|
|
canInvite: !config.externalUserMngLinkName,
|
|
externalUserMngInfo: config.externalUserMngInfo,
|
|
externalUserMngLinkName: config.externalUserMngLinkName,
|
|
externalUserMngLinkUrl: config.externalUserMngLinkUrl,
|
|
hasFetched: false,
|
|
};
|
|
|
|
export const usersReducer = (state = initialState, action: Action): UsersState => {
|
|
switch (action.type) {
|
|
case ActionTypes.LoadUsers:
|
|
return { ...state, hasFetched: true, users: action.payload };
|
|
|
|
case ActionTypes.LoadInvitees:
|
|
return { ...state, hasFetched: true, invitees: action.payload };
|
|
|
|
case ActionTypes.SetUsersSearchQuery:
|
|
return { ...state, searchQuery: action.payload };
|
|
}
|
|
|
|
return state;
|
|
};
|
|
|
|
export default {
|
|
users: usersReducer,
|
|
};
|