Add setting to manage visibility of vote count, vote button and decide root page (#197)

This commit is contained in:
Riccardo Graziosi
2023-02-05 11:55:38 +01:00
committed by GitHub
parent d4242dd78e
commit e7335f5622
35 changed files with 246 additions and 48 deletions

View File

@@ -1,4 +1,5 @@
import * as React from 'react';
import { getLabel } from '../../helpers/formUtils';
import IBoard from '../../interfaces/IBoard';
@@ -25,7 +26,7 @@ const PostBoardSelect = ({
id="selectPickerBoard"
className="selectPicker"
>
<optgroup label="Boards">
<optgroup label={getLabel('board')}>
{boards.map((board, i) => (
<option value={board.id} key={i}>
{board.name}

View File

@@ -4,6 +4,7 @@ import ReactMarkdown from 'react-markdown';
import IPost from '../../interfaces/IPost';
import IPostStatus from '../../interfaces/IPostStatus';
import IBoard from '../../interfaces/IBoard';
import ITenantSetting from '../../interfaces/ITenantSetting';
import PostUpdateList from './PostUpdateList';
import PostEditForm from './PostEditForm';
@@ -39,6 +40,7 @@ interface Props {
isPowerUser: boolean;
currentUserFullName: string;
currentUserEmail: string;
tenantSetting: ITenantSetting;
authenticityToken: string;
requestPost(postId: number): void;
@@ -148,6 +150,7 @@ class PostP extends React.Component<Props> {
isLoggedIn,
isPowerUser,
currentUserEmail,
tenantSetting,
authenticityToken,
submitFollow,
@@ -176,11 +179,14 @@ class PostP extends React.Component<Props> {
error={comments.error}
/>
<LikeList
likes={likes.items}
areLoading={likes.areLoading}
error={likes.error}
/>
{
isPowerUser &&
<LikeList
likes={likes.items}
areLoading={likes.areLoading}
error={likes.error}
/>
}
<ActionBox
followed={followed}
@@ -213,7 +219,8 @@ class PostP extends React.Component<Props> {
<div className="postHeader">
<LikeButton
postId={post.id}
likesCount={likes.items.length}
likeCount={likes.items.length}
showLikeCount={isPowerUser || tenantSetting.show_vote_count}
liked={likes.items.find(like => like.email === currentUserEmail) ? 1 : 0}
isLoggedIn={isLoggedIn}
authenticityToken={authenticityToken}

View File

@@ -2,6 +2,7 @@ import * as React from 'react';
import I18n from 'i18n-js';
import IPostStatus from '../../interfaces/IPostStatus';
import { getLabel } from '../../helpers/formUtils';
const NO_POST_STATUS_VALUE = 'none';
@@ -28,16 +29,16 @@ const PostStatusSelect = ({
id="selectPickerStatus"
className="selectPicker"
>
<optgroup label="Post statuses">
<optgroup label={getLabel('post_status')}>
{postStatuses.map((postStatus, i) => (
<option value={postStatus.id} key={i}>
{postStatus.name}
</option>
))}
</optgroup>
<optgroup label="No post status">
<option value={NO_POST_STATUS_VALUE}>{I18n.t('post.post_status_select.no_post_status')}</option>
</optgroup>
<option value={NO_POST_STATUS_VALUE}>
{I18n.t('post.post_status_select.no_post_status')}
</option>
</select>
);

View File

@@ -10,6 +10,7 @@ import IPostStatus from '../../interfaces/IPostStatus';
import { Store } from 'redux';
import { State } from '../../reducers/rootReducer';
import ITenantSetting from '../../interfaces/ITenantSetting';
interface Props {
postId: number;
@@ -19,6 +20,7 @@ interface Props {
isPowerUser: boolean;
currentUserFullName: string;
currentUserEmail: string;
tenantSetting: ITenantSetting;
authenticityToken: string;
}
@@ -40,6 +42,7 @@ class PostRoot extends React.Component<Props> {
isPowerUser,
currentUserFullName,
currentUserEmail,
tenantSetting,
authenticityToken
} = this.props;
@@ -54,6 +57,7 @@ class PostRoot extends React.Component<Props> {
isPowerUser={isPowerUser}
currentUserFullName={currentUserFullName}
currentUserEmail={currentUserEmail}
tenantSetting={tenantSetting}
authenticityToken={authenticityToken}
/>
</Provider>