Enable/disable image upload based on tenant settings

This commit is contained in:
riggraz
2025-02-04 13:28:53 +01:00
parent 9bc7a0257e
commit acd9d598e2
4 changed files with 20 additions and 9 deletions

View File

@@ -58,7 +58,7 @@ class PostsController < ApplicationController
@post.assign_attributes(post_create_params(is_anonymous: is_anonymous))
# handle attachments
if params[:post][:attachments].present?
if Current.tenant.tenant_setting.allow_attachment_upload && params[:post][:attachments].present?
@post.attachments.attach(params[:post][:attachments])
end

View File

@@ -115,6 +115,7 @@ class BoardP extends React.Component<Props> {
<Sidebar>
<NewPost
board={board}
tenantSetting={tenantSetting}
isLoggedIn={isLoggedIn}
currentUserFullName={currentUserFullName}
isAnonymousFeedbackAllowed={tenantSetting.allow_anonymous_feedback}

View File

@@ -16,9 +16,11 @@ import { POST_APPROVAL_STATUS_APPROVED } from '../../interfaces/IPost';
import ActionLink from '../common/ActionLink';
import { CancelIcon } from '../common/Icons';
import buildFormData from '../../helpers/buildFormData';
import ITenantSetting from '../../interfaces/ITenantSetting';
interface Props {
board: IBoard;
tenantSetting: ITenantSetting;
isLoggedIn: boolean;
currentUserFullName: string;
isAnonymousFeedbackAllowed: boolean;
@@ -189,6 +191,7 @@ class NewPost extends React.Component<Props, State> {
render() {
const {
board,
tenantSetting,
isLoggedIn,
currentUserFullName,
isAnonymousFeedbackAllowed
@@ -280,6 +283,7 @@ class NewPost extends React.Component<Props, State> {
handleDnf1Change={this.onDnf1Change}
handleDnf2Change={this.onDnf2Change}
tenantSetting={tenantSetting}
currentUserFullName={currentUserFullName}
isSubmissionAnonymous={isSubmissionAnonymous}
/>

View File

@@ -5,6 +5,7 @@ import Button from '../common/Button';
import { SmallMutedText } from '../common/CustomTexts';
import { MarkdownIcon } from '../common/Icons';
import Dropzone from '../common/Dropzone';
import ITenantSetting from '../../interfaces/ITenantSetting';
interface Props {
title: string;
@@ -21,6 +22,7 @@ interface Props {
handleDnf1Change(dnf1: string): void;
handleDnf2Change(dnf2: string): void;
tenantSetting: ITenantSetting;
currentUserFullName: string;
isSubmissionAnonymous: boolean;
}
@@ -40,6 +42,7 @@ const NewPostForm = ({
handleDnf1Change,
handleDnf2Change,
tenantSetting,
currentUserFullName,
isSubmissionAnonymous,
}: Props) => (
@@ -108,14 +111,17 @@ const NewPostForm = ({
</div>
{ /* Attachments */ }
<div className="form-group">
<Dropzone
files={attachments}
setFiles={handleAttachmentsChange}
maxSizeKB={2048}
maxFiles={5}
/>
</div>
{
tenantSetting.allow_attachment_upload &&
<div className="form-group">
<Dropzone
files={attachments}
setFiles={handleAttachmentsChange}
maxSizeKB={2048}
maxFiles={5}
/>
</div>
}
<Button onClick={e => handleSubmit(e)} className="submitBtn d-block mx-auto">
{I18n.t('board.new_post.submit_button')}