mirror of
https://github.com/wassname/talk.git
synced 2026-09-10 12:43:11 +08:00
withQuery and withMutation support for notifyOnError (default: true)
This commit is contained in:
@@ -10,7 +10,6 @@ import {
|
||||
} from 'coral-framework/graphql/mutations';
|
||||
import { compose } from 'react-apollo';
|
||||
import t from 'coral-framework/services/i18n';
|
||||
import { getErrorMessages } from 'coral-framework/utils';
|
||||
import { notify } from 'coral-framework/actions/notification';
|
||||
|
||||
class BanUserDialogContainer extends Component {
|
||||
@@ -22,16 +21,11 @@ class BanUserDialogContainer extends Component {
|
||||
banUser,
|
||||
setCommentStatus,
|
||||
hideBanUserDialog,
|
||||
notify,
|
||||
} = this.props;
|
||||
try {
|
||||
await banUser({ id: userId, message: '' });
|
||||
hideBanUserDialog();
|
||||
if (commentId && commentStatus && commentStatus !== 'REJECTED') {
|
||||
await setCommentStatus({ commentId, status: 'REJECTED' });
|
||||
}
|
||||
} catch (err) {
|
||||
notify('error', getErrorMessages(err));
|
||||
await banUser({ id: userId, message: '' });
|
||||
hideBanUserDialog();
|
||||
if (commentId && commentStatus && commentStatus !== 'REJECTED') {
|
||||
await setCommentStatus({ commentId, status: 'REJECTED' });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -85,7 +79,7 @@ const mapDispatchToProps = dispatch => ({
|
||||
});
|
||||
|
||||
export default compose(
|
||||
connect(mapStateToProps, mapDispatchToProps),
|
||||
withBanUser,
|
||||
withSetCommentStatus,
|
||||
connect(mapStateToProps, mapDispatchToProps)
|
||||
withSetCommentStatus
|
||||
)(BanUserDialogContainer);
|
||||
|
||||
@@ -11,7 +11,6 @@ import {
|
||||
import { compose, gql } from 'react-apollo';
|
||||
import t, { timeago } from 'coral-framework/services/i18n';
|
||||
import withQuery from 'coral-framework/hocs/withQuery';
|
||||
import { getErrorMessages } from 'coral-framework/utils';
|
||||
import get from 'lodash/get';
|
||||
import { notify } from 'coral-framework/actions/notification';
|
||||
|
||||
@@ -28,17 +27,13 @@ class SuspendUserDialogContainer extends Component {
|
||||
notify,
|
||||
} = this.props;
|
||||
hideSuspendUserDialog();
|
||||
try {
|
||||
await suspendUser({ id: userId, message, until });
|
||||
notify(
|
||||
'success',
|
||||
t('suspenduser.notify_suspend_until', username, timeago(until))
|
||||
);
|
||||
if (commentId && commentStatus && commentStatus !== 'REJECTED') {
|
||||
await setCommentStatus({ commentId, status: 'REJECTED' });
|
||||
}
|
||||
} catch (err) {
|
||||
notify('error', getErrorMessages(err));
|
||||
await suspendUser({ id: userId, message, until });
|
||||
notify(
|
||||
'success',
|
||||
t('suspenduser.notify_suspend_until', username, timeago(until))
|
||||
);
|
||||
if (commentId && commentStatus && commentStatus !== 'REJECTED') {
|
||||
await setCommentStatus({ commentId, status: 'REJECTED' });
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import UserDetailComment from './UserDetailComment';
|
||||
import update from 'immutability-helper';
|
||||
import { showBanUserDialog } from 'actions/banUserDialog';
|
||||
import { showSuspendUserDialog } from 'actions/suspendUserDialog';
|
||||
import { notifyOnMutationError, notifyOnDataError } from 'coral-framework/hocs';
|
||||
import { notify } from 'coral-framework/actions/notification';
|
||||
|
||||
const commentConnectionFragment = gql`
|
||||
fragment CoralAdmin_UserDetail_CommentConnection on CommentConnection {
|
||||
@@ -272,6 +272,7 @@ const mapDispatchToProps = dispatch => ({
|
||||
viewUserDetail,
|
||||
hideUserDetail,
|
||||
toggleSelectAllCommentInUserDetail,
|
||||
notify,
|
||||
},
|
||||
dispatch
|
||||
),
|
||||
@@ -282,7 +283,5 @@ export default compose(
|
||||
withUserDetailQuery,
|
||||
withSetCommentStatus,
|
||||
withUnbanUser,
|
||||
withUnsuspendUser,
|
||||
notifyOnMutationError(['unbanUser', 'unsuspendUser', 'setCommentStatus']),
|
||||
notifyOnDataError
|
||||
withUnsuspendUser
|
||||
)(UserDetailContainer);
|
||||
|
||||
@@ -15,7 +15,6 @@ import { handleFlaggedUsernameChange } from '../graphql';
|
||||
import { notify } from 'coral-framework/actions/notification';
|
||||
import { isFlaggedUserDangling } from '../utils';
|
||||
import t from 'coral-framework/services/i18n';
|
||||
import { notifyOnMutationError, notifyOnDataError } from 'coral-framework/hocs';
|
||||
|
||||
import FlaggedAccounts from '../components/FlaggedAccounts';
|
||||
import FlaggedUser from '../containers/FlaggedUser';
|
||||
@@ -295,7 +294,6 @@ const mapDispatchToProps = dispatch =>
|
||||
export default compose(
|
||||
connect(null, mapDispatchToProps),
|
||||
withApproveUsername,
|
||||
notifyOnMutationError(['approveUsername']),
|
||||
withQuery(
|
||||
gql`
|
||||
query TalkAdmin_Community_FlaggedAccounts {
|
||||
@@ -334,6 +332,5 @@ export default compose(
|
||||
fetchPolicy: 'network-only',
|
||||
},
|
||||
}
|
||||
),
|
||||
notifyOnDataError
|
||||
)
|
||||
)(FlaggedAccountsContainer);
|
||||
|
||||
@@ -16,7 +16,7 @@ import { appendNewNodes } from 'plugin-api/beta/client/utils';
|
||||
import update from 'immutability-helper';
|
||||
import { Spinner } from 'coral-ui';
|
||||
import withQuery from 'coral-framework/hocs/withQuery';
|
||||
import { notifyOnMutationError, notifyOnDataError } from 'coral-framework/hocs';
|
||||
import { notify } from 'coral-framework/actions/notification';
|
||||
|
||||
class PeopleContainer extends React.Component {
|
||||
timer = null;
|
||||
@@ -132,6 +132,7 @@ const mapDispatchToProps = dispatch =>
|
||||
viewUserDetail,
|
||||
showSuspendUserDialog,
|
||||
showBanUserDialog,
|
||||
notify,
|
||||
},
|
||||
dispatch
|
||||
);
|
||||
@@ -205,7 +206,6 @@ export default compose(
|
||||
withSetUserRole,
|
||||
withUnsuspendUser,
|
||||
withUnbanUser,
|
||||
notifyOnMutationError(['setUserRole', 'unsuspendUser', 'unbanUser']),
|
||||
withQuery(
|
||||
gql`
|
||||
query TalkAdmin_Community_People {
|
||||
@@ -241,6 +241,5 @@ export default compose(
|
||||
fetchPolicy: 'network-only',
|
||||
},
|
||||
}
|
||||
),
|
||||
notifyOnDataError
|
||||
)
|
||||
)(PeopleContainer);
|
||||
|
||||
@@ -5,7 +5,6 @@ import { connect } from 'react-redux';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import { compose } from 'react-apollo';
|
||||
import { notify } from 'coral-framework/actions/notification';
|
||||
import { notifyOnMutationError } from 'coral-framework/hocs';
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
user: state.community.user,
|
||||
@@ -23,6 +22,5 @@ const mapDispatchToProps = dispatch =>
|
||||
|
||||
export default compose(
|
||||
connect(mapStateToProps, mapDispatchToProps),
|
||||
withRejectUsername,
|
||||
notifyOnMutationError(['rejectUsername'])
|
||||
withRejectUsername
|
||||
)(RejectUsernameDialog);
|
||||
|
||||
@@ -12,7 +12,7 @@ import TechSettings from './TechSettings';
|
||||
import ModerationSettings from './ModerationSettings';
|
||||
import { clearPending, setActiveSection } from '../../../actions/configure';
|
||||
import Configure from '../components/Configure';
|
||||
import { notifyOnMutationError, notifyOnDataError } from 'coral-framework/hocs';
|
||||
import { notify } from 'coral-framework/actions/notification';
|
||||
|
||||
class ConfigureContainer extends Component {
|
||||
savePending = async () => {
|
||||
@@ -83,16 +83,15 @@ const mapDispatchToProps = dispatch =>
|
||||
{
|
||||
clearPending,
|
||||
setActiveSection,
|
||||
notify,
|
||||
},
|
||||
dispatch
|
||||
);
|
||||
|
||||
export default compose(
|
||||
withUpdateSettings,
|
||||
notifyOnMutationError(['updateSettings']),
|
||||
withConfigureQuery,
|
||||
notifyOnDataError,
|
||||
connect(mapStateToProps, mapDispatchToProps),
|
||||
withUpdateSettings,
|
||||
withConfigureQuery,
|
||||
withMergedSettings('root.settings', 'pending', 'mergedSettings')
|
||||
)(ConfigureContainer);
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@ import { Spinner } from 'coral-ui';
|
||||
import Moderation from '../components/Moderation';
|
||||
import Comment from './Comment';
|
||||
import baseQueueConfig from '../queueConfig';
|
||||
import { notifyOnMutationError, notifyOnDataError } from 'coral-framework/hocs';
|
||||
|
||||
function prepareNotificationText(text) {
|
||||
return truncate(text, { length: 50 }).replace('\n', ' ');
|
||||
@@ -535,7 +534,5 @@ export default compose(
|
||||
withQueueConfig(baseQueueConfig),
|
||||
connect(mapStateToProps, mapDispatchToProps),
|
||||
withSetCommentStatus,
|
||||
notifyOnMutationError(['setCommentStatus']),
|
||||
withModQueueQuery,
|
||||
notifyOnDataError
|
||||
withModQueueQuery
|
||||
)(ModerationContainer);
|
||||
|
||||
Reference in New Issue
Block a user