Added user search filed for assignee
parent
8697d52079
commit
9e584b4191
@ -1,36 +0,0 @@
|
|||||||
// Copyright (C) 2020 Intel Corporation
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: MIT
|
|
||||||
|
|
||||||
import { ActionUnion, createAction, ThunkAction } from 'utils/redux';
|
|
||||||
import getCore from 'cvat-core-wrapper';
|
|
||||||
|
|
||||||
const core = getCore();
|
|
||||||
|
|
||||||
export enum UsersActionTypes {
|
|
||||||
GET_USERS = 'GET_USERS',
|
|
||||||
GET_USERS_SUCCESS = 'GET_USERS_SUCCESS',
|
|
||||||
GET_USERS_FAILED = 'GET_USERS_FAILED',
|
|
||||||
}
|
|
||||||
|
|
||||||
const usersActions = {
|
|
||||||
getUsers: () => createAction(UsersActionTypes.GET_USERS),
|
|
||||||
getUsersSuccess: (users: any[]) => createAction(UsersActionTypes.GET_USERS_SUCCESS, { users }),
|
|
||||||
getUsersFailed: (error: any) => createAction(UsersActionTypes.GET_USERS_FAILED, { error }),
|
|
||||||
};
|
|
||||||
|
|
||||||
export type UsersActions = ActionUnion<typeof usersActions>;
|
|
||||||
|
|
||||||
export function getUsersAsync(): ThunkAction {
|
|
||||||
return async (dispatch): Promise<void> => {
|
|
||||||
dispatch(usersActions.getUsers());
|
|
||||||
|
|
||||||
try {
|
|
||||||
const users = await core.users.get();
|
|
||||||
const wrappedUsers = users.map((userData: any): any => new core.classes.User(userData));
|
|
||||||
dispatch(usersActions.getUsersSuccess(wrappedUsers));
|
|
||||||
} catch (error) {
|
|
||||||
dispatch(usersActions.getUsersFailed(error));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@ -1,48 +0,0 @@
|
|||||||
// Copyright (C) 2020 Intel Corporation
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: MIT
|
|
||||||
|
|
||||||
import { BoundariesActionTypes, BoundariesActions } from 'actions/boundaries-actions';
|
|
||||||
import { AuthActionTypes, AuthActions } from 'actions/auth-actions';
|
|
||||||
import { UsersActionTypes, UsersActions } from 'actions/users-actions';
|
|
||||||
import { UsersState } from './interfaces';
|
|
||||||
|
|
||||||
const defaultState: UsersState = {
|
|
||||||
users: [],
|
|
||||||
fetching: false,
|
|
||||||
initialized: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function (
|
|
||||||
state: UsersState = defaultState,
|
|
||||||
action: UsersActions | AuthActions | BoundariesActions,
|
|
||||||
): UsersState {
|
|
||||||
switch (action.type) {
|
|
||||||
case UsersActionTypes.GET_USERS: {
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
fetching: true,
|
|
||||||
initialized: false,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
case UsersActionTypes.GET_USERS_SUCCESS:
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
fetching: false,
|
|
||||||
initialized: true,
|
|
||||||
users: action.payload.users,
|
|
||||||
};
|
|
||||||
case UsersActionTypes.GET_USERS_FAILED:
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
fetching: false,
|
|
||||||
initialized: true,
|
|
||||||
};
|
|
||||||
case BoundariesActionTypes.RESET_AFTER_ERROR:
|
|
||||||
case AuthActionTypes.LOGOUT_SUCCESS: {
|
|
||||||
return { ...defaultState };
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue