diff --git a/frontend/app/components/comment-form/comment-form.tsx b/frontend/app/components/comment-form/comment-form.tsx index a366d563..3f5242d6 100644 --- a/frontend/app/components/comment-form/comment-form.tsx +++ b/frontend/app/components/comment-form/comment-form.tsx @@ -7,6 +7,7 @@ import { User, Theme, Image, ApiError } from '@app/common/types'; import { StaticStore } from '@app/common/static_store'; import { pageTitle } from '@app/common/settings'; import { extractErrorMessageFromResponse } from '@app/utils/errorUtils'; +import { isUserAnonymous } from '@app/utils/isUserAnonymous'; import { sleep } from '@app/utils/sleep'; import { replaceSelection } from '@app/utils/replaceSelection'; import { Button } from '@app/components/button'; @@ -88,9 +89,14 @@ const messages = defineMessages({ id: 'commentForm.unexpected-error', defaultMessage: 'Something went wrong. Please try again a bit later.', }, + unauthorizedUploadingDisabled: { + id: 'commentForm.unauthorized-uploading-disabled', + defaultMessage: 'Image uploading is disabled for unauthorized users. You should login before uploading.', + }, anonymousUploadingDisabled: { id: 'commentForm.anonymous-uploading-disabled', - defaultMessage: 'Image uploading is disabled for unauthorized users. You should login before uploading.', + defaultMessage: + 'Image uploading is disabled for anonymous users. Please log in not as anonymous user to be able to attach images.', }, }); @@ -273,10 +279,13 @@ export class CommentForm extends Component { } onDrop(e: DragEvent) { - if (!this.props.user) { + const isAnonymous = this.props.user && isUserAnonymous(this.props.user); + if (!this.props.user || isAnonymous) { this.setState({ isErrorShown: true, - errorMessage: this.props.intl.formatMessage(messages.anonymousUploadingDisabled), + errorMessage: this.props.intl.formatMessage( + messages[isAnonymous ? 'anonymousUploadingDisabled' : 'unauthorizedUploadingDisabled'] + ), }); e.preventDefault(); return; diff --git a/frontend/app/locales/de.json b/frontend/app/locales/de.json index 4956725e..b17a9ae7 100644 --- a/frontend/app/locales/de.json +++ b/frontend/app/locales/de.json @@ -53,7 +53,7 @@ "comment.verified-user": "Bestätigter Benutzer", "comment.verify-user": "Möchtest du den Benutzer {userName} wirklich bestätigen?", "comment.vote-error": "Fehler beim Abstimmen: {voteErrorMessage}", - "commentForm.anonymous-uploading-disabled": "Der Upload von Bildern ist nur für registrierte Benutzer möglich. Bitte melde dich zuvor an.", + "commentForm.unauthorized-uploading-disabled": "Der Upload von Bildern ist nur für registrierte Benutzer möglich. Bitte melde dich zuvor an.", "commentForm.exceeded-size": "Die Datei {fileName} überschreitet das Größenlimit von {maxImageSize}", "commentForm.input-placeholder": "Gib hier deinen Kommentar ein", "commentForm.new-comment": "Neuer Kommentar", diff --git a/frontend/app/locales/en.json b/frontend/app/locales/en.json index fcd6d895..2c5da953 100644 --- a/frontend/app/locales/en.json +++ b/frontend/app/locales/en.json @@ -53,7 +53,7 @@ "comment.verified-user": "Verified user", "comment.verify-user": "Do you want to verify {userName}?", "comment.vote-error": "Voting error: {voteErrorMessage}", - "commentForm.anonymous-uploading-disabled": "Image uploading is disabled for unauthorized users. You should login before uploading.", + "commentForm.unauthorized-uploading-disabled": "Image uploading is disabled for unauthorized users. You should login before uploading.", "commentForm.exceeded-size": "{fileName} exceeds size limit of {maxImageSize}", "commentForm.input-placeholder": "Your comment here", "commentForm.new-comment": "New comment", diff --git a/frontend/app/locales/es.json b/frontend/app/locales/es.json index fd9c4345..a2ed9193 100644 --- a/frontend/app/locales/es.json +++ b/frontend/app/locales/es.json @@ -53,7 +53,7 @@ "comment.verified-user": "Usuario verificado", "comment.verify-user": "¿Quieres verificar a {userName}?", "comment.vote-error": "Error al votar: {voteErrorMessage}", - "commentForm.anonymous-uploading-disabled": "La subida de imágenes está deshabilitada para usuarios no autenticados. Deberías acceder antes de subir imágenes.", + "commentForm.unauthorized-uploading-disabled": "La subida de imágenes está deshabilitada para usuarios no autenticados. Deberías acceder antes de subir imágenes.", "commentForm.exceeded-size": "{fileName} excede el tamaño máximo de {maxImageSize}", "commentForm.input-placeholder": "Tu comentario aquí", "commentForm.new-comment": "Nuevo comentario", diff --git a/frontend/app/locales/fi.json b/frontend/app/locales/fi.json index 60ccc1dc..08754e6a 100644 --- a/frontend/app/locales/fi.json +++ b/frontend/app/locales/fi.json @@ -53,7 +53,7 @@ "comment.verified-user": "Vahvistettu käyttäjä", "comment.verify-user": "Haluatko vahvistaa käyttäjän {userName}?", "comment.vote-error": "Äänestysvirhe: {voteErrorMessage}", - "commentForm.anonymous-uploading-disabled": "Kuvien lataus on poistettu käytöstä luvattomilta käyttäjiltä. Kirjaudu sisään ennen lähettämistä.", + "commentForm.unauthorized-uploading-disabled": "Kuvien lataus on poistettu käytöstä luvattomilta käyttäjiltä. Kirjaudu sisään ennen lähettämistä.", "commentForm.exceeded-size": "{fileName} ylittää {maxImageSize}", "commentForm.input-placeholder": "Kirjoita kommenttisi tähän", "commentForm.new-comment": "Uusi kommentti", diff --git a/frontend/app/locales/ru.json b/frontend/app/locales/ru.json index c2aeba67..c5ced3ca 100644 --- a/frontend/app/locales/ru.json +++ b/frontend/app/locales/ru.json @@ -53,7 +53,7 @@ "comment.verified-user": "Подлинная учетная запись", "comment.verify-user": "Подвердить подлинность учетной записи для {userName}?", "comment.vote-error": "Ошибка голосования: {voteErrorMessage}", - "commentForm.anonymous-uploading-disabled": "Загрузка изображений не доступна для неавторизированных пользователей. Авторизуйтесь для загрузки изображений.", + "commentForm.unauthorized-uploading-disabled": "Загрузка изображений не доступна для неавторизированных пользователей. Авторизуйтесь для загрузки изображений.", "commentForm.exceeded-size": "Размер файла {fileName} должен быть меньше чем {maxImageSize}", "commentForm.input-placeholder": "Написать комментарий", "commentForm.new-comment": "Новый комментарий", diff --git a/frontend/app/locales/zh.json b/frontend/app/locales/zh.json index 948ee8fc..e295e8fd 100644 --- a/frontend/app/locales/zh.json +++ b/frontend/app/locales/zh.json @@ -53,7 +53,7 @@ "comment.verified-user": "认证用户", "comment.verify-user": "您是否要设置{userName}为认证用户?", "comment.vote-error": "投票失败: {voteErrorMessage}", - "commentForm.anonymous-uploading-disabled": "未经授权的用户无法上传图片。 上传之前,您应该先登录。", + "commentForm.unauthorized-uploading-disabled": "未经授权的用户无法上传图片。 上传之前,您应该先登录。", "commentForm.exceeded-size": "{fileName}超出了{maxImageSize}的大小限制", "commentForm.input-placeholder": "在此填写评论", "commentForm.new-comment": "新评论",