Allow creators to assign moderators from a comment context-menu.
This commit is contained in:
parent
9f9d0a651b
commit
3db845b9bf
3 changed files with 53 additions and 9 deletions
|
@ -7,6 +7,7 @@ import {
|
||||||
doCommentModBlock,
|
doCommentModBlock,
|
||||||
doCommentModBlockAsAdmin,
|
doCommentModBlockAsAdmin,
|
||||||
doCommentModBlockAsModerator,
|
doCommentModBlockAsModerator,
|
||||||
|
doCommentModAddDelegate,
|
||||||
} from 'redux/actions/comments';
|
} from 'redux/actions/comments';
|
||||||
import { doChannelMute } from 'redux/actions/blocked';
|
import { doChannelMute } from 'redux/actions/blocked';
|
||||||
// import { doSetActiveChannel } from 'redux/actions/app';
|
// import { doSetActiveChannel } from 'redux/actions/app';
|
||||||
|
@ -36,6 +37,8 @@ const perform = (dispatch) => ({
|
||||||
commentModBlockAsAdmin: (commenterUri, blockerId) => dispatch(doCommentModBlockAsAdmin(commenterUri, blockerId)),
|
commentModBlockAsAdmin: (commenterUri, blockerId) => dispatch(doCommentModBlockAsAdmin(commenterUri, blockerId)),
|
||||||
commentModBlockAsModerator: (commenterUri, creatorId, blockerId) =>
|
commentModBlockAsModerator: (commenterUri, creatorId, blockerId) =>
|
||||||
dispatch(doCommentModBlockAsModerator(commenterUri, creatorId, blockerId)),
|
dispatch(doCommentModBlockAsModerator(commenterUri, creatorId, blockerId)),
|
||||||
|
commentModAddDelegate: (modChanId, modChanName, creatorChannelClaim) =>
|
||||||
|
dispatch(doCommentModAddDelegate(modChanId, modChanName, creatorChannelClaim, true)),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(select, perform)(CommentMenuList);
|
export default connect(select, perform)(CommentMenuList);
|
||||||
|
|
|
@ -4,6 +4,7 @@ import React from 'react';
|
||||||
import { MenuList, MenuItem } from '@reach/menu-button';
|
import { MenuList, MenuItem } from '@reach/menu-button';
|
||||||
import ChannelThumbnail from 'component/channelThumbnail';
|
import ChannelThumbnail from 'component/channelThumbnail';
|
||||||
import Icon from 'component/common/icon';
|
import Icon from 'component/common/icon';
|
||||||
|
import { parseURI } from 'lbry-redux';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
uri: string,
|
uri: string,
|
||||||
|
@ -25,6 +26,7 @@ type Props = {
|
||||||
commentModBlock: (string) => void,
|
commentModBlock: (string) => void,
|
||||||
commentModBlockAsAdmin: (string, string) => void,
|
commentModBlockAsAdmin: (string, string) => void,
|
||||||
commentModBlockAsModerator: (string, string, string) => void,
|
commentModBlockAsModerator: (string, string, string) => void,
|
||||||
|
commentModAddDelegate: (string, string, ChannelClaim) => void,
|
||||||
playingUri: ?PlayingUri,
|
playingUri: ?PlayingUri,
|
||||||
disableEdit?: boolean,
|
disableEdit?: boolean,
|
||||||
disableRemove?: boolean,
|
disableRemove?: boolean,
|
||||||
|
@ -51,6 +53,7 @@ function CommentMenuList(props: Props) {
|
||||||
commentModBlock,
|
commentModBlock,
|
||||||
commentModBlockAsAdmin,
|
commentModBlockAsAdmin,
|
||||||
commentModBlockAsModerator,
|
commentModBlockAsModerator,
|
||||||
|
commentModAddDelegate,
|
||||||
playingUri,
|
playingUri,
|
||||||
disableEdit,
|
disableEdit,
|
||||||
disableRemove,
|
disableRemove,
|
||||||
|
@ -93,6 +96,13 @@ function CommentMenuList(props: Props) {
|
||||||
muteChannel(authorUri);
|
muteChannel(authorUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function assignAsModerator() {
|
||||||
|
if (activeChannelClaim && authorUri) {
|
||||||
|
const { channelName, channelClaimId } = parseURI(authorUri);
|
||||||
|
commentModAddDelegate(channelClaimId, channelName, activeChannelClaim);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function blockCommentAsModerator() {
|
function blockCommentAsModerator() {
|
||||||
if (activeChannelClaim && contentChannelClaim) {
|
if (activeChannelClaim && contentChannelClaim) {
|
||||||
commentModBlockAsModerator(authorUri, contentChannelClaim.claim_id, activeChannelClaim.claim_id);
|
commentModBlockAsModerator(authorUri, contentChannelClaim.claim_id, activeChannelClaim.claim_id);
|
||||||
|
@ -121,6 +131,20 @@ function CommentMenuList(props: Props) {
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{activeChannelIsCreator && (
|
||||||
|
<MenuItem className="comment__menu-option" onSelect={assignAsModerator}>
|
||||||
|
<div className="menu__link">
|
||||||
|
<Icon aria-hidden icon={ICONS.ADD} />
|
||||||
|
{__('Add as moderator')}
|
||||||
|
</div>
|
||||||
|
<span className="comment__menu-help">
|
||||||
|
{__('Assign this user to moderate %channel%', {
|
||||||
|
channel: activeChannelClaim ? activeChannelClaim.name : __('your channel'),
|
||||||
|
})}
|
||||||
|
</span>
|
||||||
|
</MenuItem>
|
||||||
|
)}
|
||||||
|
|
||||||
{!disableRemove &&
|
{!disableRemove &&
|
||||||
activeChannelClaim &&
|
activeChannelClaim &&
|
||||||
(activeChannelClaim.permanent_url === authorUri ||
|
(activeChannelClaim.permanent_url === authorUri ||
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// @flow
|
// @flow
|
||||||
import * as ACTIONS from 'constants/action_types';
|
import * as ACTIONS from 'constants/action_types';
|
||||||
import * as REACTION_TYPES from 'constants/reactions';
|
import * as REACTION_TYPES from 'constants/reactions';
|
||||||
|
import * as PAGES from 'constants/pages';
|
||||||
import { BLOCK_LEVEL } from 'constants/comment';
|
import { BLOCK_LEVEL } from 'constants/comment';
|
||||||
import { Lbry, parseURI, buildURI, selectClaimsById, selectClaimsByUri, selectMyChannelClaims } from 'lbry-redux';
|
import { Lbry, parseURI, buildURI, selectClaimsById, selectClaimsByUri, selectMyChannelClaims } from 'lbry-redux';
|
||||||
import { doToast, doSeeNotifications } from 'redux/actions/notifications';
|
import { doToast, doSeeNotifications } from 'redux/actions/notifications';
|
||||||
|
@ -941,7 +942,8 @@ export const doUpdateBlockListForPublishedChannel = (channelClaim: ChannelClaim)
|
||||||
export function doCommentModAddDelegate(
|
export function doCommentModAddDelegate(
|
||||||
modChannelId: string,
|
modChannelId: string,
|
||||||
modChannelName: string,
|
modChannelName: string,
|
||||||
creatorChannelClaim: ChannelClaim
|
creatorChannelClaim: ChannelClaim,
|
||||||
|
showToast: boolean = false
|
||||||
) {
|
) {
|
||||||
return async (dispatch: Dispatch, getState: GetState) => {
|
return async (dispatch: Dispatch, getState: GetState) => {
|
||||||
let signature: ?{
|
let signature: ?{
|
||||||
|
@ -966,14 +968,29 @@ export function doCommentModAddDelegate(
|
||||||
creator_channel_name: creatorChannelClaim.name,
|
creator_channel_name: creatorChannelClaim.name,
|
||||||
signature: signature.signature,
|
signature: signature.signature,
|
||||||
signing_ts: signature.signing_ts,
|
signing_ts: signature.signing_ts,
|
||||||
}).catch((err) => {
|
})
|
||||||
dispatch(
|
.then(() => {
|
||||||
doToast({
|
if (showToast) {
|
||||||
message: err.message,
|
dispatch(
|
||||||
isError: true,
|
doToast({
|
||||||
})
|
message: __('Added %user% as moderator for %myChannel%', {
|
||||||
);
|
user: modChannelName,
|
||||||
});
|
myChannel: creatorChannelClaim.name,
|
||||||
|
}),
|
||||||
|
linkText: __('Manage'),
|
||||||
|
linkTarget: `/${PAGES.SETTINGS_CREATOR}`,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
dispatch(
|
||||||
|
doToast({
|
||||||
|
message: err.message,
|
||||||
|
isError: true,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue