Add moderator button for marking posts sensitive or not sensitive
This commit is contained in:
parent
0671712f2f
commit
39b50e8fe1
|
@ -37,6 +37,10 @@ export const ADMIN_STATUS_DELETE_REQUEST = 'ADMIN_STATUS_DELETE_REQUEST';
|
||||||
export const ADMIN_STATUS_DELETE_SUCCESS = 'ADMIN_STATUS_DELETE_SUCCESS';
|
export const ADMIN_STATUS_DELETE_SUCCESS = 'ADMIN_STATUS_DELETE_SUCCESS';
|
||||||
export const ADMIN_STATUS_DELETE_FAIL = 'ADMIN_STATUS_DELETE_FAIL';
|
export const ADMIN_STATUS_DELETE_FAIL = 'ADMIN_STATUS_DELETE_FAIL';
|
||||||
|
|
||||||
|
export const ADMIN_STATUS_TOGGLE_SENSITIVITY_REQUEST = 'ADMIN_STATUS_TOGGLE_SENSITIVITY_REQUEST';
|
||||||
|
export const ADMIN_STATUS_TOGGLE_SENSITIVITY_SUCCESS = 'ADMIN_STATUS_TOGGLE_SENSITIVITY_SUCCESS';
|
||||||
|
export const ADMIN_STATUS_TOGGLE_SENSITIVITY_FAIL = 'ADMIN_STATUS_TOGGLE_SENSITIVITY_FAIL';
|
||||||
|
|
||||||
export const ADMIN_LOG_FETCH_REQUEST = 'ADMIN_LOG_FETCH_REQUEST';
|
export const ADMIN_LOG_FETCH_REQUEST = 'ADMIN_LOG_FETCH_REQUEST';
|
||||||
export const ADMIN_LOG_FETCH_SUCCESS = 'ADMIN_LOG_FETCH_SUCCESS';
|
export const ADMIN_LOG_FETCH_SUCCESS = 'ADMIN_LOG_FETCH_SUCCESS';
|
||||||
export const ADMIN_LOG_FETCH_FAIL = 'ADMIN_LOG_FETCH_FAIL';
|
export const ADMIN_LOG_FETCH_FAIL = 'ADMIN_LOG_FETCH_FAIL';
|
||||||
|
@ -167,6 +171,19 @@ export function deleteStatus(id) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function toggleStatusSensitivity(id, sensitive) {
|
||||||
|
return (dispatch, getState) => {
|
||||||
|
dispatch({ type: ADMIN_STATUS_TOGGLE_SENSITIVITY_REQUEST, id });
|
||||||
|
return api(getState)
|
||||||
|
.put(`/api/pleroma/admin/statuses/${id}`, { sensitive: !sensitive })
|
||||||
|
.then(() => {
|
||||||
|
dispatch({ type: ADMIN_STATUS_TOGGLE_SENSITIVITY_SUCCESS, id });
|
||||||
|
}).catch(error => {
|
||||||
|
dispatch({ type: ADMIN_STATUS_TOGGLE_SENSITIVITY_FAIL, error, id });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function fetchModerationLog(params) {
|
export function fetchModerationLog(params) {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
dispatch({ type: ADMIN_LOG_FETCH_REQUEST });
|
dispatch({ type: ADMIN_LOG_FETCH_REQUEST });
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { defineMessages } from 'react-intl';
|
import { defineMessages } from 'react-intl';
|
||||||
import { openModal } from 'soapbox/actions/modal';
|
import { openModal } from 'soapbox/actions/modal';
|
||||||
import { deactivateUsers, deleteUsers, deleteStatus } from 'soapbox/actions/admin';
|
import { deactivateUsers, deleteUsers, deleteStatus, toggleStatusSensitivity } from 'soapbox/actions/admin';
|
||||||
import snackbar from 'soapbox/actions/snackbar';
|
import snackbar from 'soapbox/actions/snackbar';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
|
@ -13,6 +13,12 @@ const messages = defineMessages({
|
||||||
deleteStatusPrompt: { id: 'confirmations.admin.delete_status.message', defaultMessage: 'You are about to delete a post by {acct}. This action cannot be undone.' },
|
deleteStatusPrompt: { id: 'confirmations.admin.delete_status.message', defaultMessage: 'You are about to delete a post by {acct}. This action cannot be undone.' },
|
||||||
deleteStatusConfirm: { id: 'confirmations.admin.delete_status.confirm', defaultMessage: 'Delete post' },
|
deleteStatusConfirm: { id: 'confirmations.admin.delete_status.confirm', defaultMessage: 'Delete post' },
|
||||||
statusDeleted: { id: 'admin.statuses.status_deleted_message', defaultMessage: 'Post by {acct} was deleted' },
|
statusDeleted: { id: 'admin.statuses.status_deleted_message', defaultMessage: 'Post by {acct} was deleted' },
|
||||||
|
markStatusSensitivePrompt: { id: 'confirmations.admin.mark_status_sensitive.message', defaultMessage: 'You are about to mark a post by {acct} sensitive.' },
|
||||||
|
markStatusNotSensitivePrompt: { id: 'confirmations.admin.mark_status_not_sensitive.message', defaultMessage: 'You are about to mark a post by {acct} not sensitive.' },
|
||||||
|
markStatusSensitiveConfirm: { id: 'confirmations.admin.mark_status_sensitive.confirm', defaultMessage: 'Mark post sensitive' },
|
||||||
|
markStatusNotSensitiveConfirm: { id: 'confirmations.admin.mark_status_not_sensitive.confirm', defaultMessage: 'Mark post not sensitive' },
|
||||||
|
statusMarkedSensitive: { id: 'admin.statuses.status_marked_message_sensitive', defaultMessage: 'Post by {acct} was marked sensitive' },
|
||||||
|
statusMarkedNotSensitive: { id: 'admin.statuses.status_marked_message_not_sensitive', defaultMessage: 'Post by {acct} was marked not sensitive' },
|
||||||
});
|
});
|
||||||
|
|
||||||
export function deactivateUserModal(intl, accountId, afterConfirm = () => {}) {
|
export function deactivateUserModal(intl, accountId, afterConfirm = () => {}) {
|
||||||
|
@ -51,6 +57,26 @@ export function deleteUserModal(intl, accountId, afterConfirm = () => {}) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function toggleStatusSensitivityModal(intl, statusId, sensitive, afterConfirm = () => {}) {
|
||||||
|
return function(dispatch, getState) {
|
||||||
|
const state = getState();
|
||||||
|
const accountId = state.getIn(['statuses', statusId, 'account']);
|
||||||
|
const acct = state.getIn(['accounts', accountId, 'acct']);
|
||||||
|
|
||||||
|
dispatch(openModal('CONFIRM', {
|
||||||
|
message: intl.formatMessage(sensitive === false ? messages.markStatusSensitivePrompt : messages.markStatusNotSensitivePrompt, { acct: `@${acct}` }),
|
||||||
|
confirm: intl.formatMessage(sensitive === false ? messages.markStatusSensitiveConfirm : messages.markStatusNotSensitiveConfirm),
|
||||||
|
onConfirm: () => {
|
||||||
|
dispatch(toggleStatusSensitivity(statusId, sensitive)).then(() => {
|
||||||
|
const message = intl.formatMessage(sensitive === false ? messages.statusMarkedSensitive : messages.statusMarkedNotSensitive, { acct: `@${acct}` });
|
||||||
|
dispatch(snackbar.success(message));
|
||||||
|
}).catch(() => {});
|
||||||
|
afterConfirm();
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function deleteStatusModal(intl, statusId, afterConfirm = () => {}) {
|
export function deleteStatusModal(intl, statusId, afterConfirm = () => {}) {
|
||||||
return function(dispatch, getState) {
|
return function(dispatch, getState) {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
|
|
|
@ -48,6 +48,8 @@ const messages = defineMessages({
|
||||||
deactivateUser: { id: 'admin.users.actions.deactivate_user', defaultMessage: 'Deactivate {acct}' },
|
deactivateUser: { id: 'admin.users.actions.deactivate_user', defaultMessage: 'Deactivate {acct}' },
|
||||||
deleteUser: { id: 'admin.users.actions.delete_user', defaultMessage: 'Delete {acct}' },
|
deleteUser: { id: 'admin.users.actions.delete_user', defaultMessage: 'Delete {acct}' },
|
||||||
deleteStatus: { id: 'admin.statuses.actions.delete_status', defaultMessage: 'Delete post' },
|
deleteStatus: { id: 'admin.statuses.actions.delete_status', defaultMessage: 'Delete post' },
|
||||||
|
markStatusSensitive: { id: 'admin.statuses.actions.mark_status_sensitive', defaultMessage: 'Mark post sensitive' },
|
||||||
|
markStatusNotSensitive: { id: 'admin.statuses.actions.mark_status_not_sensitive', defaultMessage: 'Mark post not sensitive' },
|
||||||
});
|
});
|
||||||
|
|
||||||
class StatusActionBar extends ImmutablePureComponent {
|
class StatusActionBar extends ImmutablePureComponent {
|
||||||
|
@ -72,6 +74,7 @@ class StatusActionBar extends ImmutablePureComponent {
|
||||||
onEmbed: PropTypes.func,
|
onEmbed: PropTypes.func,
|
||||||
onDeactivateUser: PropTypes.func,
|
onDeactivateUser: PropTypes.func,
|
||||||
onDeleteUser: PropTypes.func,
|
onDeleteUser: PropTypes.func,
|
||||||
|
onToggleStatusSensitivity: PropTypes.func,
|
||||||
onDeleteStatus: PropTypes.func,
|
onDeleteStatus: PropTypes.func,
|
||||||
onMuteConversation: PropTypes.func,
|
onMuteConversation: PropTypes.func,
|
||||||
onPin: PropTypes.func,
|
onPin: PropTypes.func,
|
||||||
|
@ -260,6 +263,10 @@ class StatusActionBar extends ImmutablePureComponent {
|
||||||
this.props.onDeleteStatus(this.props.status);
|
this.props.onDeleteStatus(this.props.status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleToggleStatusSensitivity = () => {
|
||||||
|
this.props.onToggleStatusSensitivity(this.props.status);
|
||||||
|
}
|
||||||
|
|
||||||
_makeMenu = (publicStatus) => {
|
_makeMenu = (publicStatus) => {
|
||||||
const { status, intl, withDismiss, withGroupAdmin, me, isStaff } = this.props;
|
const { status, intl, withDismiss, withGroupAdmin, me, isStaff } = this.props;
|
||||||
const mutingConversation = status.get('muted');
|
const mutingConversation = status.get('muted');
|
||||||
|
@ -311,6 +318,7 @@ class StatusActionBar extends ImmutablePureComponent {
|
||||||
// menu.push({ text: intl.formatMessage(messages.admin_status), href: `/admin/accounts/${status.getIn(['account', 'id'])}/statuses/${status.get('id')}` });
|
// menu.push({ text: intl.formatMessage(messages.admin_status), href: `/admin/accounts/${status.getIn(['account', 'id'])}/statuses/${status.get('id')}` });
|
||||||
menu.push({ text: intl.formatMessage(messages.deactivateUser, { acct: `@${status.getIn(['account', 'acct'])}` }), action: this.handleDeactivateUser });
|
menu.push({ text: intl.formatMessage(messages.deactivateUser, { acct: `@${status.getIn(['account', 'acct'])}` }), action: this.handleDeactivateUser });
|
||||||
menu.push({ text: intl.formatMessage(messages.deleteUser, { acct: `@${status.getIn(['account', 'acct'])}` }), action: this.handleDeleteUser });
|
menu.push({ text: intl.formatMessage(messages.deleteUser, { acct: `@${status.getIn(['account', 'acct'])}` }), action: this.handleDeleteUser });
|
||||||
|
menu.push({ text: intl.formatMessage(status.get('sensitive') === false ? messages.markStatusSensitive : messages.markStatusNotSensitive), action: this.handleToggleStatusSensitivity });
|
||||||
menu.push({ text: intl.formatMessage(messages.deleteStatus), action: this.handleDeleteStatus });
|
menu.push({ text: intl.formatMessage(messages.deleteStatus), action: this.handleDeleteStatus });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ import {
|
||||||
} from '../actions/groups';
|
} from '../actions/groups';
|
||||||
import { getSettings } from '../actions/settings';
|
import { getSettings } from '../actions/settings';
|
||||||
import { getSoapboxConfig } from 'soapbox/actions/soapbox';
|
import { getSoapboxConfig } from 'soapbox/actions/soapbox';
|
||||||
import { deactivateUserModal, deleteUserModal, deleteStatusModal } from 'soapbox/actions/moderation';
|
import { deactivateUserModal, deleteUserModal, deleteStatusModal, toggleStatusSensitivityModal } from 'soapbox/actions/moderation';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
deleteConfirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' },
|
deleteConfirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' },
|
||||||
|
@ -221,6 +221,10 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
|
||||||
dispatch(deleteStatusModal(intl, status.get('id')));
|
dispatch(deleteStatusModal(intl, status.get('id')));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onToggleStatusSensitivity(status) {
|
||||||
|
dispatch(toggleStatusSensitivityModal(intl, status.get('id'), status.get('sensitive')));
|
||||||
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default injectIntl(connect(makeMapStateToProps, mapDispatchToProps)(Status));
|
export default injectIntl(connect(makeMapStateToProps, mapDispatchToProps)(Status));
|
||||||
|
|
|
@ -39,6 +39,8 @@ const messages = defineMessages({
|
||||||
deactivateUser: { id: 'admin.users.actions.deactivate_user', defaultMessage: 'Deactivate {acct}' },
|
deactivateUser: { id: 'admin.users.actions.deactivate_user', defaultMessage: 'Deactivate {acct}' },
|
||||||
deleteUser: { id: 'admin.users.actions.delete_user', defaultMessage: 'Delete {acct}' },
|
deleteUser: { id: 'admin.users.actions.delete_user', defaultMessage: 'Delete {acct}' },
|
||||||
deleteStatus: { id: 'admin.statuses.actions.delete_status', defaultMessage: 'Delete post' },
|
deleteStatus: { id: 'admin.statuses.actions.delete_status', defaultMessage: 'Delete post' },
|
||||||
|
markStatusSensitive: { id: 'admin.statuses.actions.mark_status_sensitive', defaultMessage: 'Mark post sensitive' },
|
||||||
|
markStatusNotSensitive: { id: 'admin.statuses.actions.mark_status_not_sensitive', defaultMessage: 'Mark post not sensitive' },
|
||||||
});
|
});
|
||||||
|
|
||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
|
@ -80,6 +82,7 @@ class ActionBar extends React.PureComponent {
|
||||||
onDeactivateUser: PropTypes.func,
|
onDeactivateUser: PropTypes.func,
|
||||||
onDeleteUser: PropTypes.func,
|
onDeleteUser: PropTypes.func,
|
||||||
onDeleteStatus: PropTypes.func,
|
onDeleteStatus: PropTypes.func,
|
||||||
|
onToggleStatusSensitivity: PropTypes.func,
|
||||||
intl: PropTypes.object.isRequired,
|
intl: PropTypes.object.isRequired,
|
||||||
onOpenUnauthorizedModal: PropTypes.func.isRequired,
|
onOpenUnauthorizedModal: PropTypes.func.isRequired,
|
||||||
me: SoapboxPropTypes.me,
|
me: SoapboxPropTypes.me,
|
||||||
|
@ -235,6 +238,10 @@ class ActionBar extends React.PureComponent {
|
||||||
this.props.onDeleteUser(this.props.status);
|
this.props.onDeleteUser(this.props.status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleToggleStatusSensitivity = () => {
|
||||||
|
this.props.onToggleStatusSensitivity(this.props.status);
|
||||||
|
}
|
||||||
|
|
||||||
handleDeleteStatus = () => {
|
handleDeleteStatus = () => {
|
||||||
this.props.onDeleteStatus(this.props.status);
|
this.props.onDeleteStatus(this.props.status);
|
||||||
}
|
}
|
||||||
|
@ -296,6 +303,7 @@ class ActionBar extends React.PureComponent {
|
||||||
// menu.push({ text: intl.formatMessage(messages.admin_status), href: `/admin/accounts/${status.getIn(['account', 'id'])}/statuses/${status.get('id')}` });
|
// menu.push({ text: intl.formatMessage(messages.admin_status), href: `/admin/accounts/${status.getIn(['account', 'id'])}/statuses/${status.get('id')}` });
|
||||||
menu.push({ text: intl.formatMessage(messages.deactivateUser, { acct: `@${status.getIn(['account', 'acct'])}` }), action: this.handleDeactivateUser });
|
menu.push({ text: intl.formatMessage(messages.deactivateUser, { acct: `@${status.getIn(['account', 'acct'])}` }), action: this.handleDeactivateUser });
|
||||||
menu.push({ text: intl.formatMessage(messages.deleteUser, { acct: `@${status.getIn(['account', 'acct'])}` }), action: this.handleDeleteUser });
|
menu.push({ text: intl.formatMessage(messages.deleteUser, { acct: `@${status.getIn(['account', 'acct'])}` }), action: this.handleDeleteUser });
|
||||||
|
menu.push({ text: intl.formatMessage(status.get('sensitive') === false ? messages.markStatusSensitive : messages.markStatusNotSensitive), action: this.handleToggleStatusSensitivity });
|
||||||
menu.push({ text: intl.formatMessage(messages.deleteStatus), action: this.handleDeleteStatus });
|
menu.push({ text: intl.formatMessage(messages.deleteStatus), action: this.handleDeleteStatus });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ import { openModal } from '../../../actions/modal';
|
||||||
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||||||
import { showAlertForError } from '../../../actions/alerts';
|
import { showAlertForError } from '../../../actions/alerts';
|
||||||
import { getSettings } from 'soapbox/actions/settings';
|
import { getSettings } from 'soapbox/actions/settings';
|
||||||
import { deactivateUserModal, deleteUserModal, deleteStatusModal } from 'soapbox/actions/moderation';
|
import { deactivateUserModal, deleteUserModal, deleteStatusModal, toggleStatusSensitivityModal } from 'soapbox/actions/moderation';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
deleteConfirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' },
|
deleteConfirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' },
|
||||||
|
@ -199,6 +199,10 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
|
||||||
dispatch(deleteUserModal(intl, status.getIn(['account', 'id'])));
|
dispatch(deleteUserModal(intl, status.getIn(['account', 'id'])));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onToggleStatusSensitivity(status) {
|
||||||
|
dispatch(toggleStatusSensitivityModal(intl, status.get('id'), status.get('sensitive')));
|
||||||
|
},
|
||||||
|
|
||||||
onDeleteStatus(status) {
|
onDeleteStatus(status) {
|
||||||
dispatch(deleteStatusModal(intl, status.get('id')));
|
dispatch(deleteStatusModal(intl, status.get('id')));
|
||||||
},
|
},
|
||||||
|
|
|
@ -47,7 +47,7 @@ import { textForScreenReader, defaultMediaVisibility } from '../../components/st
|
||||||
import Icon from 'soapbox/components/icon';
|
import Icon from 'soapbox/components/icon';
|
||||||
import { getSettings } from 'soapbox/actions/settings';
|
import { getSettings } from 'soapbox/actions/settings';
|
||||||
import { getSoapboxConfig } from 'soapbox/actions/soapbox';
|
import { getSoapboxConfig } from 'soapbox/actions/soapbox';
|
||||||
import { deactivateUserModal, deleteUserModal, deleteStatusModal } from 'soapbox/actions/moderation';
|
import { deactivateUserModal, deleteUserModal, deleteStatusModal, toggleStatusSensitivityModal } from 'soapbox/actions/moderation';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
deleteConfirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' },
|
deleteConfirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' },
|
||||||
|
@ -313,6 +313,11 @@ class Status extends ImmutablePureComponent {
|
||||||
dispatch(deleteUserModal(intl, status.getIn(['account', 'id'])));
|
dispatch(deleteUserModal(intl, status.getIn(['account', 'id'])));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleToggleStatusSensitivity = (status) => {
|
||||||
|
const { dispatch, intl } = this.props;
|
||||||
|
dispatch(toggleStatusSensitivityModal(intl, status.get('id'), status.get('sensitive')));
|
||||||
|
}
|
||||||
|
|
||||||
handleDeleteStatus = (status) => {
|
handleDeleteStatus = (status) => {
|
||||||
const { dispatch, intl } = this.props;
|
const { dispatch, intl } = this.props;
|
||||||
dispatch(deleteStatusModal(intl, status.get('id')));
|
dispatch(deleteStatusModal(intl, status.get('id')));
|
||||||
|
@ -541,6 +546,7 @@ class Status extends ImmutablePureComponent {
|
||||||
onEmbed={this.handleEmbed}
|
onEmbed={this.handleEmbed}
|
||||||
onDeactivateUser={this.handleDeactivateUser}
|
onDeactivateUser={this.handleDeactivateUser}
|
||||||
onDeleteUser={this.handleDeleteUser}
|
onDeleteUser={this.handleDeleteUser}
|
||||||
|
onToggleStatusSensitivity={this.handleToggleStatusSensitivity}
|
||||||
onDeleteStatus={this.handleDeleteStatus}
|
onDeleteStatus={this.handleDeleteStatus}
|
||||||
allowedEmoji={this.props.allowedEmoji}
|
allowedEmoji={this.props.allowedEmoji}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in New Issue