Staff promotions: change action names to more closely match AdminAPI endpoints
This commit is contained in:
parent
412432a0bd
commit
b892c6fe22
2 changed files with 20 additions and 20 deletions
|
@ -53,13 +53,13 @@ export const ADMIN_USERS_UNTAG_REQUEST = 'ADMIN_USERS_UNTAG_REQUEST';
|
|||
export const ADMIN_USERS_UNTAG_SUCCESS = 'ADMIN_USERS_UNTAG_SUCCESS';
|
||||
export const ADMIN_USERS_UNTAG_FAIL = 'ADMIN_USERS_UNTAG_FAIL';
|
||||
|
||||
export const ADMIN_ADD_PERMISSION_REQUEST = 'ADMIN_ADD_PERMISSION_REQUEST';
|
||||
export const ADMIN_ADD_PERMISSION_SUCCESS = 'ADMIN_ADD_PERMISSION_SUCCESS';
|
||||
export const ADMIN_ADD_PERMISSION_FAIL = 'ADMIN_ADD_PERMISSION_FAIL';
|
||||
export const ADMIN_ADD_PERMISSION_GROUP_REQUEST = 'ADMIN_ADD_PERMISSION_GROUP_REQUEST';
|
||||
export const ADMIN_ADD_PERMISSION_GROUP_SUCCESS = 'ADMIN_ADD_PERMISSION_GROUP_SUCCESS';
|
||||
export const ADMIN_ADD_PERMISSION_GROUP_FAIL = 'ADMIN_ADD_PERMISSION_GROUP_FAIL';
|
||||
|
||||
export const ADMIN_REMOVE_PERMISSION_REQUEST = 'ADMIN_REMOVE_PERMISSION_REQUEST';
|
||||
export const ADMIN_REMOVE_PERMISSION_SUCCESS = 'ADMIN_REMOVE_PERMISSION_SUCCESS';
|
||||
export const ADMIN_REMOVE_PERMISSION_FAIL = 'ADMIN_REMOVE_PERMISSION_FAIL';
|
||||
export const ADMIN_REMOVE_PERMISSION_GROUP_REQUEST = 'ADMIN_REMOVE_PERMISSION_GROUP_REQUEST';
|
||||
export const ADMIN_REMOVE_PERMISSION_GROUP_SUCCESS = 'ADMIN_REMOVE_PERMISSION_GROUP_SUCCESS';
|
||||
export const ADMIN_REMOVE_PERMISSION_GROUP_FAIL = 'ADMIN_REMOVE_PERMISSION_GROUP_FAIL';
|
||||
|
||||
const nicknamesFromIds = (getState, ids) => ids.map(id => getState().getIn(['accounts', id, 'acct']));
|
||||
|
||||
|
@ -259,13 +259,13 @@ export function unverifyUser(accountId) {
|
|||
export function addPermission(accountIds, permissionGroup) {
|
||||
return (dispatch, getState) => {
|
||||
const nicknames = nicknamesFromIds(getState, accountIds);
|
||||
dispatch({ type: ADMIN_ADD_PERMISSION_REQUEST, accountIds, permissionGroup });
|
||||
dispatch({ type: ADMIN_ADD_PERMISSION_GROUP_REQUEST, accountIds, permissionGroup });
|
||||
return api(getState)
|
||||
.post(`/api/v1/pleroma/admin/users/permission_group/${permissionGroup}`, { nicknames })
|
||||
.then(({ data }) => {
|
||||
dispatch({ type: ADMIN_ADD_PERMISSION_SUCCESS, accountIds, permissionGroup, data });
|
||||
dispatch({ type: ADMIN_ADD_PERMISSION_GROUP_SUCCESS, accountIds, permissionGroup, data });
|
||||
}).catch(error => {
|
||||
dispatch({ type: ADMIN_ADD_PERMISSION_FAIL, error, accountIds, permissionGroup });
|
||||
dispatch({ type: ADMIN_ADD_PERMISSION_GROUP_FAIL, error, accountIds, permissionGroup });
|
||||
});
|
||||
};
|
||||
}
|
||||
|
@ -273,13 +273,13 @@ export function addPermission(accountIds, permissionGroup) {
|
|||
export function removePermission(accountIds, permissionGroup) {
|
||||
return (dispatch, getState) => {
|
||||
const nicknames = nicknamesFromIds(getState, accountIds);
|
||||
dispatch({ type: ADMIN_REMOVE_PERMISSION_REQUEST, accountIds, permissionGroup });
|
||||
dispatch({ type: ADMIN_REMOVE_PERMISSION_GROUP_REQUEST, accountIds, permissionGroup });
|
||||
return api(getState)
|
||||
.delete(`/api/v1/pleroma/admin/users/permission_group/${permissionGroup}`, { data: { nicknames } })
|
||||
.then(({ data }) => {
|
||||
dispatch({ type: ADMIN_REMOVE_PERMISSION_SUCCESS, accountIds, permissionGroup, data });
|
||||
dispatch({ type: ADMIN_REMOVE_PERMISSION_GROUP_SUCCESS, accountIds, permissionGroup, data });
|
||||
}).catch(error => {
|
||||
dispatch({ type: ADMIN_REMOVE_PERMISSION_FAIL, error, accountIds, permissionGroup });
|
||||
dispatch({ type: ADMIN_REMOVE_PERMISSION_GROUP_FAIL, error, accountIds, permissionGroup });
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -17,10 +17,10 @@ import {
|
|||
ADMIN_USERS_TAG_FAIL,
|
||||
ADMIN_USERS_UNTAG_REQUEST,
|
||||
ADMIN_USERS_UNTAG_FAIL,
|
||||
ADMIN_ADD_PERMISSION_REQUEST,
|
||||
ADMIN_ADD_PERMISSION_FAIL,
|
||||
ADMIN_REMOVE_PERMISSION_REQUEST,
|
||||
ADMIN_REMOVE_PERMISSION_FAIL,
|
||||
ADMIN_ADD_PERMISSION_GROUP_REQUEST,
|
||||
ADMIN_ADD_PERMISSION_GROUP_FAIL,
|
||||
ADMIN_REMOVE_PERMISSION_GROUP_REQUEST,
|
||||
ADMIN_REMOVE_PERMISSION_GROUP_FAIL,
|
||||
} from 'soapbox/actions/admin';
|
||||
import { ADMIN_USERS_DELETE_REQUEST } from 'soapbox/actions/admin';
|
||||
|
||||
|
@ -142,11 +142,11 @@ export default function accounts(state = initialState, action) {
|
|||
case ADMIN_USERS_UNTAG_REQUEST:
|
||||
case ADMIN_USERS_TAG_FAIL:
|
||||
return removeTags(state, action.accountIds, action.tags);
|
||||
case ADMIN_ADD_PERMISSION_REQUEST:
|
||||
case ADMIN_REMOVE_PERMISSION_FAIL:
|
||||
case ADMIN_ADD_PERMISSION_GROUP_REQUEST:
|
||||
case ADMIN_REMOVE_PERMISSION_GROUP_FAIL:
|
||||
return addPermission(state, action.accountIds, action.permissionGroup);
|
||||
case ADMIN_REMOVE_PERMISSION_REQUEST:
|
||||
case ADMIN_ADD_PERMISSION_FAIL:
|
||||
case ADMIN_REMOVE_PERMISSION_GROUP_REQUEST:
|
||||
case ADMIN_ADD_PERMISSION_GROUP_FAIL:
|
||||
return removePermission(state, action.accountIds, action.permissionGroup);
|
||||
case ADMIN_USERS_DELETE_REQUEST:
|
||||
return setDeactivated(state, action.nicknames);
|
||||
|
|
Loading…
Reference in a new issue