Add message of image upload try by anonymous user

This commit is contained in:
Serge Adamovich
2020-04-18 17:24:54 +03:00
parent b5e31f3081
commit 5fc67f1c12
7 changed files with 18 additions and 9 deletions
@@ -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<Props, State> {
}
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;
+1 -1
View File
@@ -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",
+1 -1
View File
@@ -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",
+1 -1
View File
@@ -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",
+1 -1
View File
@@ -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",
+1 -1
View File
@@ -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": "Новый комментарий",
+1 -1
View File
@@ -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": "新评论",