From b892c6fe22d2c08be2512a9bdd99d2048344caf8 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 13 Jul 2021 12:34:58 -0500 Subject: [PATCH] Staff promotions: change action names to more closely match AdminAPI endpoints --- app/soapbox/actions/admin.js | 24 ++++++++++++------------ app/soapbox/reducers/accounts.js | 16 ++++++++-------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/app/soapbox/actions/admin.js b/app/soapbox/actions/admin.js index f4c141d48..6a93b1682 100644 --- a/app/soapbox/actions/admin.js +++ b/app/soapbox/actions/admin.js @@ -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 }); }); }; } diff --git a/app/soapbox/reducers/accounts.js b/app/soapbox/reducers/accounts.js index dd52247c4..7bab5aad4 100644 --- a/app/soapbox/reducers/accounts.js +++ b/app/soapbox/reducers/accounts.js @@ -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);