removing removed accounts
This commit is contained in:
parent
7b2d3aa281
commit
f13214f1f9
@ -39,6 +39,10 @@ export const GROUP_REMOVED_ACCOUNTS_EXPAND_REQUEST = 'GROUP_REMOVED_ACCOUNTS_EXP
|
|||||||
export const GROUP_REMOVED_ACCOUNTS_EXPAND_SUCCESS = 'GROUP_REMOVED_ACCOUNTS_EXPAND_SUCCESS';
|
export const GROUP_REMOVED_ACCOUNTS_EXPAND_SUCCESS = 'GROUP_REMOVED_ACCOUNTS_EXPAND_SUCCESS';
|
||||||
export const GROUP_REMOVED_ACCOUNTS_EXPAND_FAIL = 'GROUP_REMOVED_ACCOUNTS_EXPAND_FAIL';
|
export const GROUP_REMOVED_ACCOUNTS_EXPAND_FAIL = 'GROUP_REMOVED_ACCOUNTS_EXPAND_FAIL';
|
||||||
|
|
||||||
|
export const GROUP_REMOVED_ACCOUNTS_REMOVE_REQUEST = 'GROUP_REMOVED_ACCOUNTS_REMOVE_REQUEST';
|
||||||
|
export const GROUP_REMOVED_ACCOUNTS_REMOVE_SUCCESS = 'GROUP_REMOVED_ACCOUNTS_REMOVE_SUCCESS';
|
||||||
|
export const GROUP_REMOVED_ACCOUNTS_REMOVE_FAIL = 'GROUP_REMOVED_ACCOUNTS_REMOVE_FAIL';
|
||||||
|
|
||||||
export const fetchGroup = id => (dispatch, getState) => {
|
export const fetchGroup = id => (dispatch, getState) => {
|
||||||
if (!me) return;
|
if (!me) return;
|
||||||
|
|
||||||
@ -392,4 +396,43 @@ export function expandRemovedAccountsFail(id, error) {
|
|||||||
id,
|
id,
|
||||||
error,
|
error,
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export function removeRemovedAccount(groupId, id) {
|
||||||
|
return (dispatch, getState) => {
|
||||||
|
if (!me) return;
|
||||||
|
|
||||||
|
dispatch(removeRemovedAccountRequest(groupId, id));
|
||||||
|
|
||||||
|
api(getState).delete(`/api/v1/groups/${groupId}/removed_accounts?account_id=${id}`).then(response => {
|
||||||
|
dispatch(removeRemovedAccountSuccess(groupId, id));
|
||||||
|
}).catch(error => {
|
||||||
|
dispatch(removeRemovedAccountFail(groupId, id, error));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export function removeRemovedAccountRequest(groupId, id) {
|
||||||
|
return {
|
||||||
|
type: GROUP_REMOVED_ACCOUNTS_REMOVE_REQUEST,
|
||||||
|
groupId,
|
||||||
|
id,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export function removeRemovedAccountSuccess(groupId, id) {
|
||||||
|
return {
|
||||||
|
type: GROUP_REMOVED_ACCOUNTS_REMOVE_SUCCESS,
|
||||||
|
groupId,
|
||||||
|
id,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export function removeRemovedAccountFail(groupId, id, error) {
|
||||||
|
return {
|
||||||
|
type: GROUP_REMOVED_ACCOUNTS_REMOVE_FAIL,
|
||||||
|
groupId,
|
||||||
|
id,
|
||||||
|
error,
|
||||||
|
};
|
||||||
};
|
};
|
@ -8,11 +8,17 @@ import LoadingIndicator from '../../../components/loading_indicator';
|
|||||||
import {
|
import {
|
||||||
fetchRemovedAccounts,
|
fetchRemovedAccounts,
|
||||||
expandRemovedAccounts,
|
expandRemovedAccounts,
|
||||||
|
removeRemovedAccount,
|
||||||
} from '../../../actions/groups';
|
} from '../../../actions/groups';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
import AccountContainer from '../../../containers/account_container';
|
import AccountContainer from '../../../containers/account_container';
|
||||||
import Column from '../../ui/components/column';
|
import Column from '../../ui/components/column';
|
||||||
import ScrollableList from '../../../components/scrollable_list';
|
import ScrollableList from '../../../components/scrollable_list';
|
||||||
|
import { defineMessages, injectIntl } from 'react-intl';
|
||||||
|
|
||||||
|
const messages = defineMessages({
|
||||||
|
remove: { id: 'groups.removed_accounts', defaultMessage: 'Allow joining' },
|
||||||
|
});
|
||||||
|
|
||||||
const mapStateToProps = (state, { params: { id } }) => ({
|
const mapStateToProps = (state, { params: { id } }) => ({
|
||||||
group: state.getIn(['groups', id]),
|
group: state.getIn(['groups', id]),
|
||||||
@ -21,6 +27,7 @@ const mapStateToProps = (state, { params: { id } }) => ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export default @connect(mapStateToProps)
|
export default @connect(mapStateToProps)
|
||||||
|
@injectIntl
|
||||||
class GroupRemovedAccounts extends ImmutablePureComponent {
|
class GroupRemovedAccounts extends ImmutablePureComponent {
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
@ -47,7 +54,7 @@ class GroupRemovedAccounts extends ImmutablePureComponent {
|
|||||||
}, 300, { leading: true });
|
}, 300, { leading: true });
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { accountIds, hasMore, group } = this.props;
|
const { accountIds, hasMore, group, intl } = this.props;
|
||||||
|
|
||||||
if (!group || !accountIds) {
|
if (!group || !accountIds) {
|
||||||
return (
|
return (
|
||||||
@ -65,7 +72,13 @@ class GroupRemovedAccounts extends ImmutablePureComponent {
|
|||||||
onLoadMore={this.handleLoadMore}
|
onLoadMore={this.handleLoadMore}
|
||||||
emptyMessage={<FormattedMessage id='group.removed_accounts.empty' defaultMessage='This group does not has any removed accounts.' />}
|
emptyMessage={<FormattedMessage id='group.removed_accounts.empty' defaultMessage='This group does not has any removed accounts.' />}
|
||||||
>
|
>
|
||||||
{accountIds.map(id => <AccountContainer key={id} id={id} withNote={false} />)}
|
{accountIds.map(id => <AccountContainer
|
||||||
|
key={id}
|
||||||
|
id={id}
|
||||||
|
actionIcon="remove"
|
||||||
|
onActionClick={() => this.props.dispatch(removeRemovedAccount(group.get('id'), id))}
|
||||||
|
actionTitle={intl.formatMessage(messages.remove)}
|
||||||
|
/>)}
|
||||||
</ScrollableList>
|
</ScrollableList>
|
||||||
</Column>
|
</Column>
|
||||||
);
|
);
|
||||||
|
@ -26,6 +26,7 @@ import {
|
|||||||
GROUP_MEMBERS_EXPAND_SUCCESS,
|
GROUP_MEMBERS_EXPAND_SUCCESS,
|
||||||
GROUP_REMOVED_ACCOUNTS_FETCH_SUCCESS,
|
GROUP_REMOVED_ACCOUNTS_FETCH_SUCCESS,
|
||||||
GROUP_REMOVED_ACCOUNTS_EXPAND_SUCCESS,
|
GROUP_REMOVED_ACCOUNTS_EXPAND_SUCCESS,
|
||||||
|
GROUP_REMOVED_ACCOUNTS_REMOVE_SUCCESS,
|
||||||
} from '../actions/groups';
|
} from '../actions/groups';
|
||||||
|
|
||||||
const initialState = ImmutableMap({
|
const initialState = ImmutableMap({
|
||||||
@ -90,6 +91,8 @@ export default function userLists(state = initialState, action) {
|
|||||||
return normalizeList(state, 'groups_removed_accounts', action.id, action.accounts, action.next);
|
return normalizeList(state, 'groups_removed_accounts', action.id, action.accounts, action.next);
|
||||||
case GROUP_REMOVED_ACCOUNTS_EXPAND_SUCCESS:
|
case GROUP_REMOVED_ACCOUNTS_EXPAND_SUCCESS:
|
||||||
return appendToList(state, 'groups_removed_accounts', action.id, action.accounts, action.next);
|
return appendToList(state, 'groups_removed_accounts', action.id, action.accounts, action.next);
|
||||||
|
case GROUP_REMOVED_ACCOUNTS_REMOVE_SUCCESS:
|
||||||
|
return state.updateIn(['groups_removed_accounts', action.groupId, 'items'], list => list.filterNot(item => item === action.id));
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user