From 22beb4e0ea6a2c300422fa8a21b5f230af985ec0 Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Sat, 9 Mar 2024 15:44:50 +0100 Subject: [PATCH] feat(mod menu): community moderators can ban their users --- public/translations/ar/default.json | 3 +- public/translations/bn/default.json | 3 +- public/translations/cs/default.json | 3 +- public/translations/da/default.json | 3 +- public/translations/de/default.json | 3 +- public/translations/el/default.json | 3 +- public/translations/en/default.json | 3 +- public/translations/es/default.json | 3 +- public/translations/fa/default.json | 3 +- public/translations/fi/default.json | 3 +- public/translations/fil/default.json | 3 +- public/translations/fr/default.json | 3 +- public/translations/he/default.json | 3 +- public/translations/hi/default.json | 3 +- public/translations/hu/default.json | 3 +- public/translations/id/default.json | 3 +- public/translations/it/default.json | 3 +- public/translations/ja/default.json | 3 +- public/translations/ko/default.json | 3 +- public/translations/mr/default.json | 3 +- public/translations/nl/default.json | 3 +- public/translations/no/default.json | 3 +- public/translations/pl/default.json | 3 +- public/translations/pt/default.json | 3 +- public/translations/ro/default.json | 3 +- public/translations/ru/default.json | 3 +- public/translations/sq/default.json | 3 +- public/translations/sv/default.json | 3 +- public/translations/te/default.json | 3 +- public/translations/th/default.json | 3 +- public/translations/tr/default.json | 3 +- public/translations/uk/default.json | 3 +- public/translations/ur/default.json | 3 +- public/translations/vi/default.json | 3 +- public/translations/zh/default.json | 3 +- .../post/comment-tools/comment-tools.tsx | 49 ++++++++++++------- .../comment-tools/hide-menu/hide-menu.tsx | 6 +-- .../mod-menu/mod-menu.module.css | 2 +- .../post/comment-tools/mod-menu/mod-menu.tsx | 47 ++++++++++++++++-- 39 files changed, 148 insertions(+), 61 deletions(-) diff --git a/public/translations/ar/default.json b/public/translations/ar/default.json index c0b7084d..77bfa2ec 100644 --- a/public/translations/ar/default.json +++ b/public/translations/ar/default.json @@ -287,5 +287,6 @@ "missing_token_address": "عنوان الرمز المفقود", "missing_token_id": "معرف الرمز المفقود", "missing_signature": "التوقيع المفقود", - "edited_timestamp": "تم التحرير {{timestamp}}" + "edited_timestamp": "تم التحرير {{timestamp}}", + "ban_user_for": "حظر المستخدم لمدة <1> يوم(أيام)" } \ No newline at end of file diff --git a/public/translations/bn/default.json b/public/translations/bn/default.json index c8959008..7f653bbf 100644 --- a/public/translations/bn/default.json +++ b/public/translations/bn/default.json @@ -287,5 +287,6 @@ "missing_token_address": "নিখোঁজ টোকেন ঠিকানা", "missing_token_id": "নিখোঁজ টোকেন আইডি", "missing_signature": "নিখোঁজ স্বাক্ষর", - "edited_timestamp": "সম্পাদনা করা হয়েছে {{timestamp}}" + "edited_timestamp": "সম্পাদনা করা হয়েছে {{timestamp}}", + "ban_user_for": "ব্যবহারকারীকে <1> দিনের জন্য বন্ধ করুন" } \ No newline at end of file diff --git a/public/translations/cs/default.json b/public/translations/cs/default.json index d19c8e03..6f95e2f5 100644 --- a/public/translations/cs/default.json +++ b/public/translations/cs/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Chybějící tokenová adresa", "missing_token_id": "Chybějící ID tokenu", "missing_signature": "Chybějící podpis", - "edited_timestamp": "Upraveno {{timestamp}}" + "edited_timestamp": "Upraveno {{timestamp}}", + "ban_user_for": "Zakázat uživatele na <1> den (dní)" } \ No newline at end of file diff --git a/public/translations/da/default.json b/public/translations/da/default.json index d01f6b20..bced100c 100644 --- a/public/translations/da/default.json +++ b/public/translations/da/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Manglende tokensadresse", "missing_token_id": "Manglende token-id", "missing_signature": "Manglende signatur", - "edited_timestamp": "Redigeret {{timestamp}}" + "edited_timestamp": "Redigeret {{timestamp}}", + "ban_user_for": "Udeluk brugeren i <1> dag(e)" } \ No newline at end of file diff --git a/public/translations/de/default.json b/public/translations/de/default.json index b2c20df8..b2ec389f 100644 --- a/public/translations/de/default.json +++ b/public/translations/de/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Fehlende Tokenadresse", "missing_token_id": "Fehlende Token-ID", "missing_signature": "Fehlende Signatur", - "edited_timestamp": "Bearbeitet {{timestamp}}" + "edited_timestamp": "Bearbeitet {{timestamp}}", + "ban_user_for": "Benutzer für <1> Tag(e) sperren" } \ No newline at end of file diff --git a/public/translations/el/default.json b/public/translations/el/default.json index 54fb4e48..c25591ab 100644 --- a/public/translations/el/default.json +++ b/public/translations/el/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Ελλειπτική διεύθυνση του token", "missing_token_id": "Ελλειπτικό αναγνωριστικό token", "missing_signature": "Ελλειπτική υπογραφή", - "edited_timestamp": "Επεξεργάστηκε {{timestamp}}" + "edited_timestamp": "Επεξεργάστηκε {{timestamp}}", + "ban_user_for": "Αποκλεισμός χρήστη για <1> ημέρα(ες)" } \ No newline at end of file diff --git a/public/translations/en/default.json b/public/translations/en/default.json index 634136dd..617aa635 100644 --- a/public/translations/en/default.json +++ b/public/translations/en/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Missing token address", "missing_token_id": "Missing token ID", "missing_signature": "Missing signature", - "edited_timestamp": "Edited {{timestamp}}" + "edited_timestamp": "Edited {{timestamp}}", + "ban_user_for": "Ban user for <1> day(s)" } \ No newline at end of file diff --git a/public/translations/es/default.json b/public/translations/es/default.json index b4755036..023f7ac4 100644 --- a/public/translations/es/default.json +++ b/public/translations/es/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Falta de dirección de token", "missing_token_id": "Falta de ID de token", "missing_signature": "Falta de firma", - "edited_timestamp": "Editado {{timestamp}}" + "edited_timestamp": "Editado {{timestamp}}", + "ban_user_for": "Prohibir al usuario durante <1> día(s)" } \ No newline at end of file diff --git a/public/translations/fa/default.json b/public/translations/fa/default.json index 5d1d6fba..3e163c46 100644 --- a/public/translations/fa/default.json +++ b/public/translations/fa/default.json @@ -287,5 +287,6 @@ "missing_token_address": "آدرس توکن گم شده", "missing_token_id": "شناسه توکن گم شده", "missing_signature": "امضای گم شده", - "edited_timestamp": "ویرایش شده {{timestamp}}" + "edited_timestamp": "ویرایش شده {{timestamp}}", + "ban_user_for": "بستن کاربر برای <1> روز" } \ No newline at end of file diff --git a/public/translations/fi/default.json b/public/translations/fi/default.json index c0af8b92..b18bade7 100644 --- a/public/translations/fi/default.json +++ b/public/translations/fi/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Puuttuva token-osoite", "missing_token_id": "Puuttuva token-id", "missing_signature": "Puuttuva allekirjoitus", - "edited_timestamp": "Muokattu {{timestamp}}" + "edited_timestamp": "Muokattu {{timestamp}}", + "ban_user_for": "Estä käyttäjä <1> päiväksi" } \ No newline at end of file diff --git a/public/translations/fil/default.json b/public/translations/fil/default.json index c6e1d826..93934d7e 100644 --- a/public/translations/fil/default.json +++ b/public/translations/fil/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Kulang na address ng token", "missing_token_id": "Kulang na ID ng token", "missing_signature": "Kulang na lagda", - "edited_timestamp": "Na-edit na ang {{timestamp}}" + "edited_timestamp": "Na-edit na ang {{timestamp}}", + "ban_user_for": "I-ban ang user para sa <1> araw" } \ No newline at end of file diff --git a/public/translations/fr/default.json b/public/translations/fr/default.json index ed16c715..0e028afa 100644 --- a/public/translations/fr/default.json +++ b/public/translations/fr/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Adresse de token manquante", "missing_token_id": "ID de token manquant", "missing_signature": "Signature manquante", - "edited_timestamp": "Édité {{timestamp}}" + "edited_timestamp": "Édité {{timestamp}}", + "ban_user_for": "Bannir l'utilisateur pendant <1> jour(s)" } \ No newline at end of file diff --git a/public/translations/he/default.json b/public/translations/he/default.json index af942e88..10890b70 100644 --- a/public/translations/he/default.json +++ b/public/translations/he/default.json @@ -287,5 +287,6 @@ "missing_token_address": "כתובת הטוקן חסרה", "missing_token_id": "מזהה הטוקן חסר", "missing_signature": "חתימה חסרה", - "edited_timestamp": "נערך {{timestamp}}" + "edited_timestamp": "נערך {{timestamp}}", + "ban_user_for": "אסור למשתמש למשך <1> יום" } \ No newline at end of file diff --git a/public/translations/hi/default.json b/public/translations/hi/default.json index 6ed30be5..82662964 100644 --- a/public/translations/hi/default.json +++ b/public/translations/hi/default.json @@ -287,5 +287,6 @@ "missing_token_address": "गायब टोकन पता", "missing_token_id": "गायब टोकन आईडी", "missing_signature": "गायब हस्ताक्षर", - "edited_timestamp": "संपादित {{timestamp}}" + "edited_timestamp": "संपादित {{timestamp}}", + "ban_user_for": "उपयोगकर्ता को <1> दिनों के लिए प्रतिबंधित करें" } \ No newline at end of file diff --git a/public/translations/hu/default.json b/public/translations/hu/default.json index fa295e3d..f1a07ff7 100644 --- a/public/translations/hu/default.json +++ b/public/translations/hu/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Hiányzó token cím", "missing_token_id": "Hiányzó token azonosító", "missing_signature": "Hiányzó aláírás", - "edited_timestamp": "Szerkesztve {{timestamp}}" + "edited_timestamp": "Szerkesztve {{timestamp}}", + "ban_user_for": "Felhasználó letiltása <1> napra" } \ No newline at end of file diff --git a/public/translations/id/default.json b/public/translations/id/default.json index a83e1692..ffb08ac5 100644 --- a/public/translations/id/default.json +++ b/public/translations/id/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Alamat token yang hilang", "missing_token_id": "ID token yang hilang", "missing_signature": "Tanda tangan yang hilang", - "edited_timestamp": "Diedit {{timestamp}}" + "edited_timestamp": "Diedit {{timestamp}}", + "ban_user_for": "Blokir pengguna selama <1> hari" } \ No newline at end of file diff --git a/public/translations/it/default.json b/public/translations/it/default.json index e8d3146d..773e421b 100644 --- a/public/translations/it/default.json +++ b/public/translations/it/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Indirizzo del token mancante", "missing_token_id": "ID del token mancante", "missing_signature": "Firma mancante", - "edited_timestamp": "Modificato {{timestamp}}" + "edited_timestamp": "Modificato {{timestamp}}", + "ban_user_for": "Banna l'utente per <1> giorno/i" } \ No newline at end of file diff --git a/public/translations/ja/default.json b/public/translations/ja/default.json index 17356953..4ad8c532 100644 --- a/public/translations/ja/default.json +++ b/public/translations/ja/default.json @@ -287,5 +287,6 @@ "missing_token_address": "不足しているトークンアドレス", "missing_token_id": "不足しているトークンID", "missing_signature": "不足している署名", - "edited_timestamp": "編集済み {{timestamp}}" + "edited_timestamp": "編集済み {{timestamp}}", + "ban_user_for": "ユーザーを<1>日間禁止する" } \ No newline at end of file diff --git a/public/translations/ko/default.json b/public/translations/ko/default.json index bf78366b..25ae4bbd 100644 --- a/public/translations/ko/default.json +++ b/public/translations/ko/default.json @@ -287,5 +287,6 @@ "missing_token_address": "부재중인 토큰 주소", "missing_token_id": "부재중인 토큰 ID", "missing_signature": "부재중인 서명", - "edited_timestamp": "편집됨 {{timestamp}}" + "edited_timestamp": "편집됨 {{timestamp}}", + "ban_user_for": "사용자를 <1>일 동안 차단하기" } \ No newline at end of file diff --git a/public/translations/mr/default.json b/public/translations/mr/default.json index f4873e78..31f45b7a 100644 --- a/public/translations/mr/default.json +++ b/public/translations/mr/default.json @@ -287,5 +287,6 @@ "missing_token_address": "गुमलेला टोकन पत्ता", "missing_token_id": "गुमलेला टोकन आयडी", "missing_signature": "गुमलेली स्वाक्षरे", - "edited_timestamp": "{{timestamp}} संपादित" + "edited_timestamp": "{{timestamp}} संपादित", + "ban_user_for": "वापरकर्ता ब्लॉक करा <1> दिवस" } \ No newline at end of file diff --git a/public/translations/nl/default.json b/public/translations/nl/default.json index 4509ff7c..13401ca9 100644 --- a/public/translations/nl/default.json +++ b/public/translations/nl/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Ontbrekend tokenadres", "missing_token_id": "Ontbrekend token-ID", "missing_signature": "Ontbrekende handtekening", - "edited_timestamp": "Bewerkt {{timestamp}}" + "edited_timestamp": "Bewerkt {{timestamp}}", + "ban_user_for": "Gebruiker verbannen voor <1> dag(en)" } \ No newline at end of file diff --git a/public/translations/no/default.json b/public/translations/no/default.json index de91716d..262fa4a5 100644 --- a/public/translations/no/default.json +++ b/public/translations/no/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Manglende tokenadresse", "missing_token_id": "Manglende token-ID", "missing_signature": "Manglende signatur", - "edited_timestamp": "Redigert {{timestamp}}" + "edited_timestamp": "Redigert {{timestamp}}", + "ban_user_for": "Blokker bruker i <1> dag(er)" } \ No newline at end of file diff --git a/public/translations/pl/default.json b/public/translations/pl/default.json index 29479df6..f370195b 100644 --- a/public/translations/pl/default.json +++ b/public/translations/pl/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Brakujący adres tokena", "missing_token_id": "Brakujące ID tokenu", "missing_signature": "Brakujący podpis", - "edited_timestamp": "Edytowane {{timestamp}}" + "edited_timestamp": "Edytowane {{timestamp}}", + "ban_user_for": "Zablokuj użytkownika na <1> dzień (dni)" } \ No newline at end of file diff --git a/public/translations/pt/default.json b/public/translations/pt/default.json index 431a66d9..b877a9fc 100644 --- a/public/translations/pt/default.json +++ b/public/translations/pt/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Endereço do token em falta", "missing_token_id": "ID de token em falta", "missing_signature": "Assinatura em falta", - "edited_timestamp": "Editado {{timestamp}}" + "edited_timestamp": "Editado {{timestamp}}", + "ban_user_for": "Banir usuário por <1> dia(s)" } \ No newline at end of file diff --git a/public/translations/ro/default.json b/public/translations/ro/default.json index 871572cd..1ba194c3 100644 --- a/public/translations/ro/default.json +++ b/public/translations/ro/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Lipsește adresa tokenului", "missing_token_id": "Lipsește ID-ul tokenului", "missing_signature": "Lipsește semnătura", - "edited_timestamp": "Editat {{timestamp}}" + "edited_timestamp": "Editat {{timestamp}}", + "ban_user_for": "Interzice utilizatorul pentru <1> zi(zile)" } \ No newline at end of file diff --git a/public/translations/ru/default.json b/public/translations/ru/default.json index b01c1b69..488f7ee7 100644 --- a/public/translations/ru/default.json +++ b/public/translations/ru/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Отсутствующий адрес токена", "missing_token_id": "Отсутствующий идентификатор токена", "missing_signature": "Отсутствующая подпись", - "edited_timestamp": "Отредактировано {{timestamp}}" + "edited_timestamp": "Отредактировано {{timestamp}}", + "ban_user_for": "Заблокировать пользователя на <1> день(дней)" } \ No newline at end of file diff --git a/public/translations/sq/default.json b/public/translations/sq/default.json index d736ee7b..1bd609c5 100644 --- a/public/translations/sq/default.json +++ b/public/translations/sq/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Adresa e munguar e tokenit", "missing_token_id": "ID e munguar e tokenit", "missing_signature": "Nënshkrimi i munguar", - "edited_timestamp": "Redaktuar {{timestamp}}" + "edited_timestamp": "Redaktuar {{timestamp}}", + "ban_user_for": "Ndalo përdoruesin për <1> ditë" } \ No newline at end of file diff --git a/public/translations/sv/default.json b/public/translations/sv/default.json index c25cf8a2..f3bec0e9 100644 --- a/public/translations/sv/default.json +++ b/public/translations/sv/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Saknad tokenadress", "missing_token_id": "Saknad token-ID", "missing_signature": "Saknad signatur", - "edited_timestamp": "Redigerat {{timestamp}}" + "edited_timestamp": "Redigerat {{timestamp}}", + "ban_user_for": "Blockera användaren i <1> dag(ar)" } \ No newline at end of file diff --git a/public/translations/te/default.json b/public/translations/te/default.json index 789972ef..86b33e1a 100644 --- a/public/translations/te/default.json +++ b/public/translations/te/default.json @@ -287,5 +287,6 @@ "missing_token_address": "తప్పని టోకెన్ చిరునామా", "missing_token_id": "తప్పని టోకెన్ ఐడి", "missing_signature": "తప్పని సంతకం", - "edited_timestamp": "{{timestamp}} ముందు సవరించబడింది" + "edited_timestamp": "{{timestamp}} ముందు సవరించబడింది", + "ban_user_for": "<1> రోజుల కోసం వాడుకరినీ బ్యాన్ చేయండి" } \ No newline at end of file diff --git a/public/translations/th/default.json b/public/translations/th/default.json index 26fb3790..3f4dfe5d 100644 --- a/public/translations/th/default.json +++ b/public/translations/th/default.json @@ -287,5 +287,6 @@ "missing_token_address": "เหตุที่หายไปของที่อยู่โทเค็น", "missing_token_id": "เหตุที่หายไปของรหัสของโทเค็น", "missing_signature": "เหตุที่หายไปของลายเซ็น", - "edited_timestamp": "แก้ไขเมื่อ {{timestamp}}" + "edited_timestamp": "แก้ไขเมื่อ {{timestamp}}", + "ban_user_for": "แบนผู้ใช้ <1> วัน" } \ No newline at end of file diff --git a/public/translations/tr/default.json b/public/translations/tr/default.json index b0e13344..8d72b8f8 100644 --- a/public/translations/tr/default.json +++ b/public/translations/tr/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Eksik token adresi", "missing_token_id": "Eksik token kimliği", "missing_signature": "Eksik imza", - "edited_timestamp": "{{timestamp}} önce düzenlendi" + "edited_timestamp": "{{timestamp}} önce düzenlendi", + "ban_user_for": "Kullanıcıyı <1> gün boyunca yasakla" } \ No newline at end of file diff --git a/public/translations/uk/default.json b/public/translations/uk/default.json index 735c1a30..13abede6 100644 --- a/public/translations/uk/default.json +++ b/public/translations/uk/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Відсутня адреса токена", "missing_token_id": "Відсутній ідентифікатор токена", "missing_signature": "Відсутній підпис", - "edited_timestamp": "Відредаговано {{timestamp}}" + "edited_timestamp": "Відредаговано {{timestamp}}", + "ban_user_for": "Заборонити користувача на <1> день (днів)" } \ No newline at end of file diff --git a/public/translations/ur/default.json b/public/translations/ur/default.json index 7eb017ad..5fee55c7 100644 --- a/public/translations/ur/default.json +++ b/public/translations/ur/default.json @@ -287,5 +287,6 @@ "missing_token_address": "گمشدہ ٹوکن ایڈریس", "missing_token_id": "گمشدہ ٹوکن شناختی نمبر", "missing_signature": "گمشدہ دستخط", - "edited_timestamp": "{{timestamp}} پہلے ترمیم شدہ" + "edited_timestamp": "{{timestamp}} پہلے ترمیم شدہ", + "ban_user_for": "<1> دنوں کے لیے صارف کو پابندی عائد کریں" } \ No newline at end of file diff --git a/public/translations/vi/default.json b/public/translations/vi/default.json index 7d04ae1b..f5041668 100644 --- a/public/translations/vi/default.json +++ b/public/translations/vi/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Địa chỉ token bị thiếu", "missing_token_id": "Thiếu ID của token", "missing_signature": "Thiếu chữ ký", - "edited_timestamp": "Đã chỉnh sửa {{timestamp}}" + "edited_timestamp": "Đã chỉnh sửa {{timestamp}}", + "ban_user_for": "Cấm người dùng trong <1> ngày" } \ No newline at end of file diff --git a/public/translations/zh/default.json b/public/translations/zh/default.json index 3d7047a0..ff4133d3 100644 --- a/public/translations/zh/default.json +++ b/public/translations/zh/default.json @@ -287,5 +287,6 @@ "missing_token_address": "缺失的代币地址", "missing_token_id": "缺失的代币ID", "missing_signature": "缺失的签名", - "edited_timestamp": "编辑于{{timestamp}}" + "edited_timestamp": "编辑于{{timestamp}}", + "ban_user_for": "封禁用户 <1> 天" } \ No newline at end of file diff --git a/src/components/post/comment-tools/comment-tools.tsx b/src/components/post/comment-tools/comment-tools.tsx index 9c1eab4e..a6ff279f 100644 --- a/src/components/post/comment-tools/comment-tools.tsx +++ b/src/components/post/comment-tools/comment-tools.tsx @@ -18,7 +18,8 @@ interface CommentToolsProps { hasLabel?: boolean; index?: number; isAuthor?: boolean; - isMod?: boolean; + isAccountMod?: boolean; + isCommentAuthorMod?: boolean; isReply?: boolean; isSingleReply?: boolean; parentCid?: string; @@ -34,14 +35,15 @@ interface CommentToolsProps { interface ModOrReportButtonProps { cid: string; isAuthor: boolean | undefined; - isMod: boolean | undefined; + isAccountMod: boolean | undefined; + isCommentAuthorMod?: boolean; } -const ModOrReportButton = ({ cid, isAuthor, isMod }: ModOrReportButtonProps) => { +const ModOrReportButton = ({ cid, isAuthor, isAccountMod, isCommentAuthorMod }: ModOrReportButtonProps) => { const { t } = useTranslation(); - return isMod ? ( - + return isAccountMod ? ( + ) : ( !isAuthor && (
  • @@ -58,7 +60,8 @@ const PostTools = ({ hasLabel, index, isAuthor, - isMod, + isAccountMod, + isCommentAuthorMod, subplebbitAddress, replyCount = 0, showCommentEditForm, @@ -97,13 +100,13 @@ const PostTools = ({
  • */} {isAuthor && } - + {/* TODO: Implement crosspost functionality
  • {t('crosspost')}
  • */} - + ); }; @@ -115,7 +118,8 @@ const ReplyTools = ({ hasLabel, index, isAuthor, - isMod, + isAccountMod, + isCommentAuthorMod, showReplyForm, subplebbitAddress, showCommentEditForm, @@ -135,11 +139,11 @@ const ReplyTools = ({ */} {isAuthor && } - +
  • cid && showReplyForm?.()}>{t('reply_reply')}
  • - + ); }; @@ -150,7 +154,8 @@ const SingleReplyTools = ({ hasLabel, index, isAuthor, - isMod, + isAccountMod, + isCommentAuthorMod, parentCid, postCid, showReplyForm, @@ -192,11 +197,11 @@ const SingleReplyTools = ({ {isAuthor && }
  • {contextButton}
  • {fullCommentsButton}
  • - +
  • cid && showReplyForm?.()}>{t('reply_reply')}
  • - + ); }; @@ -241,8 +246,11 @@ const CommentTools = ({ }: CommentToolsProps) => { const account = useAccount(); const isAuthor = account?.author?.address === author?.address; - const authorRole = useSubplebbit({ subplebbitAddress })?.roles?.[account?.author?.address]?.role; - const isMod = authorRole === 'admin' || authorRole === 'owner' || authorRole === 'moderator'; + const subplebbit = useSubplebbit({ subplebbitAddress }); + const accountAuthorRole = subplebbit?.roles?.[account?.author?.address]?.role; + const commentAuthorRole = subplebbit?.roles?.[author?.address]?.role; + const isAccountMod = accountAuthorRole === 'admin' || accountAuthorRole === 'owner' || accountAuthorRole === 'moderator'; + const isCommentAuthorMod = commentAuthorRole === 'admin' || commentAuthorRole === 'owner' || commentAuthorRole === 'moderator'; const isInInboxView = isInboxView(useLocation().pathname); return ( @@ -256,7 +264,8 @@ const CommentTools = ({ hasLabel={hasLabel} index={index} isAuthor={isAuthor} - isMod={isMod} + isAccountMod={isAccountMod} + isCommentAuthorMod={isCommentAuthorMod} parentCid={parentCid} postCid={postCid} showCommentEditForm={showCommentEditForm} @@ -272,7 +281,8 @@ const CommentTools = ({ hasLabel={hasLabel} index={index} isAuthor={isAuthor} - isMod={isMod} + isAccountMod={isAccountMod} + isCommentAuthorMod={isCommentAuthorMod} showCommentEditForm={showCommentEditForm} showReplyForm={showReplyForm} spoiler={spoiler} @@ -298,7 +308,8 @@ const CommentTools = ({ hasLabel={hasLabel} index={index} isAuthor={isAuthor} - isMod={isMod} + isAccountMod={isAccountMod} + isCommentAuthorMod={isCommentAuthorMod} replyCount={replyCount} showCommentEditForm={showCommentEditForm} spoiler={spoiler} diff --git a/src/components/post/comment-tools/hide-menu/hide-menu.tsx b/src/components/post/comment-tools/hide-menu/hide-menu.tsx index 18bf3932..c4ee7ac9 100644 --- a/src/components/post/comment-tools/hide-menu/hide-menu.tsx +++ b/src/components/post/comment-tools/hide-menu/hide-menu.tsx @@ -8,7 +8,7 @@ import Plebbit from '@plebbit/plebbit-js/dist/browser/index.js'; type HideMenuProps = { author?: Author | undefined; cid?: string; - isMod?: boolean; + isAccountMod?: boolean; toggleIsMenuOpen?: () => void; subplebbitAddress?: string; }; @@ -52,7 +52,7 @@ const BlockCommentButton = ({ cid }: HideMenuProps) => { ); }; -const HideMenu = ({ author, cid, isMod, subplebbitAddress }: HideMenuProps) => { +const HideMenu = ({ author, cid, isAccountMod, subplebbitAddress }: HideMenuProps) => { const { t } = useTranslation(); const [isHideMenuOpen, setIsHideMenuOpen] = useState(false); const toggleIsMenuOpen = () => setIsHideMenuOpen(!isHideMenuOpen); @@ -85,7 +85,7 @@ const HideMenu = ({ author, cid, isMod, subplebbitAddress }: HideMenuProps) => { - {!isMod &&
    {t('report')}
    } + {!isAccountMod &&
    {t('report')}
    } diff --git a/src/components/post/comment-tools/mod-menu/mod-menu.module.css b/src/components/post/comment-tools/mod-menu/mod-menu.module.css index f0497fef..e92bfe47 100644 --- a/src/components/post/comment-tools/mod-menu/mod-menu.module.css +++ b/src/components/post/comment-tools/mod-menu/mod-menu.module.css @@ -14,7 +14,7 @@ color: var(--text); font-size: 12px; border: 1px solid var(--border-text); - width: 200px; + min-width: 200px; } .modal input[type="checkbox"] { diff --git a/src/components/post/comment-tools/mod-menu/mod-menu.tsx b/src/components/post/comment-tools/mod-menu/mod-menu.tsx index 1d576a91..ef6ae24c 100644 --- a/src/components/post/comment-tools/mod-menu/mod-menu.tsx +++ b/src/components/post/comment-tools/mod-menu/mod-menu.tsx @@ -1,6 +1,6 @@ import { useState } from 'react'; import { autoUpdate, flip, FloatingFocusManager, offset, shift, useClick, useDismiss, useFloating, useId, useInteractions, useRole } from '@floating-ui/react'; -import { useTranslation } from 'react-i18next'; +import { Trans, useTranslation } from 'react-i18next'; import { PublishCommentEditOptions, useComment, useEditedComment, usePublishCommentEdit } from '@plebbit/plebbit-react-hooks'; import styles from './mod-menu.module.css'; import { alertChallengeVerificationFailed } from '../../../../lib/utils/challenge-utils'; @@ -10,9 +10,10 @@ const { addChallenge } = challengesStore.getState(); type ModMenuProps = { cid: string; + isCommentAuthorMod?: boolean; }; -const ModMenu = ({ cid }: ModMenuProps) => { +const ModMenu = ({ cid, isCommentAuthorMod }: ModMenuProps) => { const { t } = useTranslation(); let post: any; @@ -31,6 +32,7 @@ const ModMenu = ({ cid }: ModMenuProps) => { locked: post?.locked, spoiler: post?.spoiler, pinned: post?.pinned, + banExpiresAt: post?.banExpiresAt, commentCid: post?.cid, subplebbitAddress: post?.subplebbitAddress, onChallenge: (...args: any) => addChallenge([...args, post]), @@ -44,7 +46,34 @@ const ModMenu = ({ cid }: ModMenuProps) => { const [publishCommentEditOptions, setPublishCommentEditOptions] = useState(defaultPublishOptions); const { publishCommentEdit } = usePublishCommentEdit(publishCommentEditOptions); - const onCheckbox = (e: React.ChangeEvent) => setPublishCommentEditOptions((state) => ({ ...state, [e.target.id]: e.target.checked })); + const [banDuration, setBanDuration] = useState(1); + + const daysToTimestampInSeconds = (days: number) => { + const now = new Date(); + now.setDate(now.getDate() + days); + return Math.floor(now.getTime() / 1000); + }; + + const onCheckbox = (e: React.ChangeEvent) => { + const { id, checked } = e.target; + if (id === 'banUser') { + setPublishCommentEditOptions((state) => ({ + ...state, + banExpiresAt: checked ? daysToTimestampInSeconds(banDuration) : undefined, + })); + } else { + setPublishCommentEditOptions((state) => ({ ...state, [id]: checked })); + } + }; + + const onBanDurationChange = (e: React.ChangeEvent) => { + const days = parseInt(e.target.value, 10) || 1; + setBanDuration(days); + setPublishCommentEditOptions((state) => ({ + ...state, + banExpiresAt: daysToTimestampInSeconds(days), + })); + }; const onReason = (e: React.ChangeEvent) => setPublishCommentEditOptions((state) => ({ ...state, reason: e.target.value ? e.target.value : undefined })); @@ -105,6 +134,18 @@ const ModMenu = ({ cid }: ModMenuProps) => { {isReply ? t('stickied_comment') : t('announcement')} + {!isCommentAuthorMod && ( +
    + +
    + )}
    {t('reason')} ({t('optional')})