diff --git a/static/app-strings.json b/static/app-strings.json index 095953ba2..2e5e62543 100644 --- a/static/app-strings.json +++ b/static/app-strings.json @@ -1718,6 +1718,10 @@ "Level %current_level%": "Level %current_level%", "Creator tools": "Creator tools", "Prevent this channel from interacting with you.": "Prevent this channel from interacting with you.", + "Choose a permanent or temporary ban.": "Choose a permanent or temporary ban.", + "Personal | Moderator | Admin": "Personal | Moderator | Admin", + "Personal | Moderator": "Personal | Moderator", + "Personal | Admin": "Personal | Admin", "Hide this channel for you only.": "Hide this channel for you only.", "Interacting as %channelName%": "Interacting as %channelName%", "Page Not Found": "Page Not Found", diff --git a/ui/component/commentMenuList/index.js b/ui/component/commentMenuList/index.js index 9d8c4ce48..b03992d37 100644 --- a/ui/component/commentMenuList/index.js +++ b/ui/component/commentMenuList/index.js @@ -7,7 +7,7 @@ import { doOpenModal } from 'redux/actions/app'; import { doSetPlayingUri } from 'redux/actions/content'; import { selectActiveChannelClaim } from 'redux/selectors/app'; import { selectPlayingUri } from 'redux/selectors/content'; - +import { selectModerationDelegatorsById } from 'redux/selectors/comments'; import CommentMenuList from './view'; const select = (state, props) => ({ @@ -16,6 +16,7 @@ const select = (state, props) => ({ contentChannelPermanentUrl: makeSelectChannelPermUrlForClaimUri(props.uri)(state), activeChannelClaim: selectActiveChannelClaim(state), playingUri: selectPlayingUri(state), + moderationDelegatorsById: selectModerationDelegatorsById(state), }); const perform = (dispatch) => ({ diff --git a/ui/component/commentMenuList/view.jsx b/ui/component/commentMenuList/view.jsx index d008c153d..8cc902340 100644 --- a/ui/component/commentMenuList/view.jsx +++ b/ui/component/commentMenuList/view.jsx @@ -6,6 +6,7 @@ import { MenuList, MenuItem } from '@reach/menu-button'; import ChannelThumbnail from 'component/channelThumbnail'; import Icon from 'component/common/icon'; import { parseURI } from 'lbry-redux'; +import { getChannelFromClaim } from 'util/claim'; type Props = { uri: ?string, @@ -24,6 +25,7 @@ type Props = { contentChannelPermanentUrl: any, activeChannelClaim: ?ChannelClaim, playingUri: ?PlayingUri, + moderationDelegatorsById: { [string]: { global: boolean, delegators: { name: string, claimId: string } } }, // --- perform --- openModal: (id: string, {}) => void, clearPlayingUri: () => void, @@ -50,6 +52,7 @@ function CommentMenuList(props: Props) { handleEditComment, commentModAddDelegate, playingUri, + moderationDelegatorsById, disableEdit, disableRemove, openModal, @@ -57,7 +60,15 @@ function CommentMenuList(props: Props) { setQuickReply, } = props; + const contentChannelClaim = getChannelFromClaim(claim); + const activeModeratorInfo = activeChannelClaim && moderationDelegatorsById[activeChannelClaim.claim_id]; const activeChannelIsCreator = activeChannelClaim && activeChannelClaim.permanent_url === contentChannelPermanentUrl; + const activeChannelIsAdmin = activeChannelClaim && activeModeratorInfo && activeModeratorInfo.global; + const activeChannelIsModerator = + activeChannelClaim && + contentChannelClaim && + activeModeratorInfo && + Object.values(activeModeratorInfo.delegators).includes(contentChannelClaim.claim_id); function handlePinComment(commentId, claimId, remove) { pinComment(commentId, claimId, remove); @@ -91,6 +102,59 @@ function CommentMenuList(props: Props) { } } + function getBlockOptionElem() { + const isPersonalBlockTheOnlyOption = !activeChannelIsModerator && !activeChannelIsAdmin; + const isTimeoutBlockAvailable = (claim && claim.is_my_output) || activeChannelIsModerator; + const personalPermanentBlockOnly = isPersonalBlockTheOnlyOption && !isTimeoutBlockAvailable; + + function getSubtitle() { + if (personalPermanentBlockOnly) { + return { + line1: __('Prevent this channel from interacting with you.'), + line2: null, + }; + } else { + if (activeChannelIsModerator && activeChannelIsAdmin) { + return { + line1: __('Personal | Moderator | Admin'), + line2: __('Choose a permanent or temporary ban.'), + }; + } else if (activeChannelIsModerator && !activeChannelIsAdmin) { + return { + line1: __('Personal | Moderator'), + line2: __('Choose a permanent or temporary ban.'), + }; + } else if (!activeChannelIsModerator && activeChannelIsAdmin) { + return { + line1: __('Personal | Admin'), + line2: __('Choose a permanent or temporary ban.'), + }; + } else { + return { + line1: null, + line2: __('Choose a permanent or temporary ban.'), + }; + } + } + } + + const subtitle = getSubtitle(); + return ( + <> +