mirror of
https://github.com/astuto/astuto.git
synced 2025-12-16 03:37:56 +01:00
Add setting to manage visibility of vote count, vote button and decide root page (#197)
This commit is contained in:
committed by
GitHub
parent
d4242dd78e
commit
e7335f5622
@@ -7,6 +7,7 @@ import PostList from './PostList';
|
||||
import Sidebar from '../common/Sidebar';
|
||||
|
||||
import IBoard from '../../interfaces/IBoard';
|
||||
import ITenantSetting from '../../interfaces/ITenantSetting';
|
||||
|
||||
import { PostsState } from '../../reducers/postsReducer';
|
||||
import { PostStatusesState } from '../../reducers/postStatusesReducer';
|
||||
@@ -14,6 +15,8 @@ import { PostStatusesState } from '../../reducers/postStatusesReducer';
|
||||
interface Props {
|
||||
board: IBoard;
|
||||
isLoggedIn: boolean;
|
||||
isPowerUser: boolean;
|
||||
tenantSetting: ITenantSetting;
|
||||
authenticityToken: string;
|
||||
posts: PostsState;
|
||||
postStatuses: PostStatusesState;
|
||||
@@ -63,6 +66,8 @@ class BoardP extends React.Component<Props> {
|
||||
const {
|
||||
board,
|
||||
isLoggedIn,
|
||||
isPowerUser,
|
||||
tenantSetting,
|
||||
authenticityToken,
|
||||
posts,
|
||||
postStatuses,
|
||||
@@ -97,6 +102,8 @@ class BoardP extends React.Component<Props> {
|
||||
|
||||
<PostList
|
||||
posts={posts.items}
|
||||
showLikeCount={isPowerUser || tenantSetting.show_vote_count}
|
||||
showLikeButtons={tenantSetting.show_vote_button_in_board}
|
||||
postStatuses={postStatuses.items}
|
||||
areLoading={posts.areLoading}
|
||||
error={posts.error}
|
||||
|
||||
@@ -14,6 +14,8 @@ import IPostStatus from '../../interfaces/IPostStatus';
|
||||
|
||||
interface Props {
|
||||
posts: Array<IPost>;
|
||||
showLikeCount: boolean;
|
||||
showLikeButtons: boolean;
|
||||
postStatuses: Array<IPostStatus>;
|
||||
areLoading: boolean;
|
||||
error: string;
|
||||
@@ -27,6 +29,8 @@ interface Props {
|
||||
|
||||
const PostList = ({
|
||||
posts,
|
||||
showLikeCount,
|
||||
showLikeButtons,
|
||||
postStatuses,
|
||||
areLoading,
|
||||
error,
|
||||
@@ -53,7 +57,9 @@ const PostList = ({
|
||||
title={post.title}
|
||||
description={post.description}
|
||||
postStatus={postStatuses.find(postStatus => postStatus.id === post.postStatusId)}
|
||||
likesCount={post.likesCount}
|
||||
likeCount={post.likeCount}
|
||||
showLikeCount={showLikeCount}
|
||||
showLikeButtons={showLikeButtons}
|
||||
liked={post.liked}
|
||||
commentsCount={post.commentsCount}
|
||||
|
||||
|
||||
@@ -12,7 +12,9 @@ interface Props {
|
||||
title: string;
|
||||
description?: string;
|
||||
postStatus: IPostStatus;
|
||||
likesCount: number;
|
||||
likeCount: number;
|
||||
showLikeCount: boolean;
|
||||
showLikeButtons: boolean;
|
||||
liked: number;
|
||||
commentsCount: number;
|
||||
|
||||
@@ -25,7 +27,9 @@ const PostListItem = ({
|
||||
title,
|
||||
description,
|
||||
postStatus,
|
||||
likesCount,
|
||||
likeCount,
|
||||
showLikeCount,
|
||||
showLikeButtons,
|
||||
liked,
|
||||
commentsCount,
|
||||
|
||||
@@ -35,7 +39,9 @@ const PostListItem = ({
|
||||
<div onClick={() => window.location.href = `/posts/${id}`} className="postListItem">
|
||||
<LikeButton
|
||||
postId={id}
|
||||
likesCount={likesCount}
|
||||
likeCount={likeCount}
|
||||
showLikeCount={showLikeCount}
|
||||
showLikeButton={showLikeButtons}
|
||||
liked={liked}
|
||||
isLoggedIn={isLoggedIn}
|
||||
authenticityToken={authenticityToken}
|
||||
|
||||
@@ -8,10 +8,13 @@ import IBoard from '../../interfaces/IBoard';
|
||||
|
||||
import { Store } from 'redux';
|
||||
import { State } from '../../reducers/rootReducer';
|
||||
import ITenantSetting from '../../interfaces/ITenantSetting';
|
||||
|
||||
interface Props {
|
||||
board: IBoard;
|
||||
isLoggedIn: boolean;
|
||||
isPowerUser: boolean;
|
||||
tenantSetting: ITenantSetting;
|
||||
authenticityToken: string;
|
||||
}
|
||||
|
||||
@@ -25,13 +28,21 @@ class BoardRoot extends React.Component<Props> {
|
||||
}
|
||||
|
||||
render() {
|
||||
const { board, isLoggedIn, authenticityToken } = this.props;
|
||||
const {
|
||||
board,
|
||||
isLoggedIn,
|
||||
isPowerUser,
|
||||
tenantSetting,
|
||||
authenticityToken,
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
<Provider store={this.store}>
|
||||
<Board
|
||||
board={board}
|
||||
isLoggedIn={isLoggedIn}
|
||||
isPowerUser={isPowerUser}
|
||||
tenantSetting={tenantSetting}
|
||||
authenticityToken={authenticityToken}
|
||||
/>
|
||||
</Provider>
|
||||
|
||||
Reference in New Issue
Block a user