From c25dda1050162e418fd7ed513bef69eeaf3f781f Mon Sep 17 00:00:00 2001 From: igoradamenko Date: Sun, 18 Mar 2018 23:13:31 +0200 Subject: [PATCH] add blocked-users to root component --- web/app/components/root/root.jsx | 89 +++++++++++++++++++++----------- 1 file changed, 59 insertions(+), 30 deletions(-) diff --git a/web/app/components/root/root.jsx b/web/app/components/root/root.jsx index b0e76f85..ea6f1e81 100644 --- a/web/app/components/root/root.jsx +++ b/web/app/components/root/root.jsx @@ -6,6 +6,7 @@ import { url } from 'common/settings'; import store from 'common/store'; import AuthPanel from 'components/auth-panel'; +import BlockedUsers from 'components/blocked-users'; import Comment from 'components/comment'; import Input from 'components/input'; import Preloader from 'components/preloader'; @@ -23,6 +24,8 @@ export default class Root extends Component { this.addComment = this.addComment.bind(this); this.onSignIn = this.onSignIn.bind(this); this.onSignOut = this.onSignOut.bind(this); + this.onBlockedUsersShow = this.onBlockedUsersShow.bind(this); + this.onBlockedUsersHide = this.onBlockedUsersHide.bind(this); this.checkUrlHash = this.checkUrlHash.bind(this); } @@ -96,6 +99,16 @@ export default class Root extends Component { }, checkMsDelay); } + onBlockedUsersShow() { + api.getBlocked().then(bannedUsers => { + this.setState({ bannedUsers, isBlockedVisible: true }); + }); + } + + onBlockedUsersHide() { + this.setState({ isBlockedVisible: false }); + } + addComment(data) { store.addComment(data); this.setState({ comments: store.get('comments') }); @@ -106,7 +119,7 @@ export default class Root extends Component { }); } - render({}, { config = {}, comments = [], user, loaded }) { + render({}, { config = {}, comments = [], user, loaded, isBlockedVisible, bannedUsers }) { if (!loaded) { return (
@@ -129,46 +142,62 @@ export default class Root extends Component { providers={config.auth_providers} onSignIn={this.onSignIn} onSignOut={this.onSignOut} + onBlockedUsersShow={this.onBlockedUsersShow} + onBlockedUsersHide={this.onBlockedUsersHide} /> { - !isGuest && ( - - ) - } - - { - !!pinnedComments.length && ( -
+ !isBlockedVisible && ( +
{ - pinnedComments.map(comment => ( - - )) + ) + } + + { + !!pinnedComments.length && ( +
+ { + pinnedComments.map(comment => ( + + )) + } +
+ ) + } + + { + !!comments.length && ( +
+ { + comments.map(thread => ( + + )) + } +
+ ) }
) } { - !!comments.length && ( -
- { - comments.map(thread => ( - - )) - } + isBlockedVisible && ( +
+
) }