From 38b6c2253ed637e238d2fb3cb92e716aa41d4eee Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Fri, 26 Jan 2024 15:06:50 +0100 Subject: [PATCH 01/13] update challenge settings --- src/lib/utils/challenge-utils.ts | 51 ++++++++- .../subplebbit-settings.tsx | 104 +++++++----------- 2 files changed, 92 insertions(+), 63 deletions(-) diff --git a/src/lib/utils/challenge-utils.ts b/src/lib/utils/challenge-utils.ts index 6fad2311..a3b51ea4 100644 --- a/src/lib/utils/challenge-utils.ts +++ b/src/lib/utils/challenge-utils.ts @@ -92,7 +92,56 @@ export const getDefaultChallengeDescription = (challengeType: string) => { } }; -export const getDefaultOptionInputs = (challengeType: string) => { +export const getDefaultChallengeOptions = (challengeType: string) => { + switch (challengeType) { + case 'text-math': + return { + difficulty: '1', + }; + case 'captcha-canvas-v3': + return { + characters: '', + height: '', + width: '', + color: '', + }; + case 'fail': + return { + error: "You're not allowed to publish.", + }; + case 'blacklist': + return { + blacklist: '', + error: "You're blacklisted.", + }; + case 'question': + return { + question: '', + answer: '', + }; + case 'evm-contract-call': + return { + chainTicker: 'eth', + address: '', + abi: '', + condition: '', + error: "Contract call response doesn't pass condition.", + }; + default: + return {}; + } +}; + +export type ChallengeSetting = { + option: string; + label: string; + description: string; + default?: string; + placeholder?: string; + required?: boolean; +}; + +export const getDefaultChallengeSettings = (challengeType: string) => { switch (challengeType) { case 'text-math': return [ diff --git a/src/views/subplebbit/subplebbit-settings/subplebbit-settings.tsx b/src/views/subplebbit/subplebbit-settings/subplebbit-settings.tsx index dfc52e1a..5e13a409 100644 --- a/src/views/subplebbit/subplebbit-settings/subplebbit-settings.tsx +++ b/src/views/subplebbit/subplebbit-settings/subplebbit-settings.tsx @@ -6,7 +6,13 @@ import { useTranslation } from 'react-i18next'; import { create } from 'zustand'; import styles from './subplebbit-settings.module.css'; import { isValidURL } from '../../../lib/utils/url-utils'; -import { getDefaultChallengeDescription, getDefaultExclude, getDefaultOptionInputs } from '../../../lib/utils/challenge-utils'; +import { + ChallengeSetting, + getDefaultChallengeDescription, + getDefaultExclude, + getDefaultChallengeOptions, + getDefaultChallengeSettings, +} from '../../../lib/utils/challenge-utils'; import LoadingEllipsis from '../../../components/loading-ellipsis'; import Sidebar from '../../../components/sidebar'; @@ -298,24 +304,16 @@ interface ChallengeSettingsProps { showSettings: boolean; } -type OptionInput = { - option: string; - value?: string; - label: string; - default?: string; - description: string; - placeholder?: string; - required?: boolean; -}; +const rolesToExclude = ['moderator', 'admin', 'owner']; +const actionsToExclude: Array<'post' | 'reply' | 'vote'> = ['post', 'reply', 'vote']; const ChallengeSettings = ({ challenge, index, setSubmitStore, settings, showSettings }: ChallengeSettingsProps) => { - const { exclude, name, optionInputs } = challenge || {}; + const { exclude, name, options } = challenge || {}; + const challengeSettings: ChallengeSetting[] = getDefaultChallengeSettings(name); const handleOptionChange = (optionName: string, newValue: string) => { - const updatedOptionInputs = optionInputs.map((input: any) => (input.option === optionName ? { ...input, value: newValue } : input)); - - const updatedChallenges = settings.challenges.map((ch: any, idx: number) => (idx === index ? { ...ch, optionInputs: updatedOptionInputs } : ch)); - + const updatedOptions = { ...options, [optionName]: newValue }; + const updatedChallenges = settings.challenges.map((ch: any, idx: number) => (idx === index ? { ...ch, options: updatedOptions } : ch)); setSubmitStore({ settings: { ...settings, challenges: updatedChallenges } }); }; @@ -344,16 +342,16 @@ const ChallengeSettings = ({ challenge, index, setSubmitStore, settings, showSet return (
{getDefaultChallengeDescription(name)}
- {challenge?.optionInputs?.map((inputOption: OptionInput) => ( -
- {inputOption.label} -
{inputOption.description}
+ {challengeSettings.map((setting) => ( +
+
{setting.label}
+
{setting.description}
handleOptionChange(inputOption.option, e.target.value)} - required={inputOption.required || false} + value={options[setting.option] || setting.default || ''} + placeholder={setting.placeholder || ''} + onChange={(e) => handleOptionChange(setting.option, e.target.value)} + required={setting.required || false} />
))} @@ -361,46 +359,26 @@ const ChallengeSettings = ({ challenge, index, setSubmitStore, settings, showSet
Moderators
Exclude a specific moderator role
-
- -
-
- -
-
- -
+ {rolesToExclude.map((role) => ( +
+ +
+ ))}
Actions
Exclude a specific user action
-
- -
-
- -
-
- -
+ {actionsToExclude.map((action) => ( +
+ +
+ ))}
); @@ -419,9 +397,11 @@ const Challenges = () => { }; const handleAddChallenge = () => { + const defaultChallenge = 'captcha-canvas-v3'; + const options = getDefaultChallengeOptions(defaultChallenge); const newChallenge = { - name: 'captcha-canvas-v3', - optionInputs: getDefaultOptionInputs('captcha-canvas-v3'), + name: defaultChallenge, + options, exclude: getDefaultExclude(), }; const updatedChallenges = [...(settings?.challenges || []), newChallenge]; @@ -437,7 +417,7 @@ const Challenges = () => { const handleChallengeTypeChange = (index: number, newType: string) => { const updatedChallenges = [...challenges]; - updatedChallenges[index] = { ...updatedChallenges[index], name: newType, optionInputs: getDefaultOptionInputs(newType) }; + updatedChallenges[index] = { ...updatedChallenges[index], name: newType, options: getDefaultChallengeOptions(newType) }; setSubmitStore({ settings: { ...settings, challenges: updatedChallenges } }); }; From 592a8893d04b148ced67a7237cad8052afd70e95 Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Fri, 26 Jan 2024 15:40:18 +0100 Subject: [PATCH 02/13] feat(subplebbit settings): exclude specific user addresses from challenges, minimum user karma --- src/lib/utils/challenge-utils.ts | 14 ++++++ .../subplebbit-settings.module.css | 8 ++-- .../subplebbit-settings.tsx | 44 +++++++++++-------- 3 files changed, 43 insertions(+), 23 deletions(-) diff --git a/src/lib/utils/challenge-utils.ts b/src/lib/utils/challenge-utils.ts index a3b51ea4..4c10d29b 100644 --- a/src/lib/utils/challenge-utils.ts +++ b/src/lib/utils/challenge-utils.ts @@ -141,6 +141,20 @@ export type ChallengeSetting = { required?: boolean; }; +export type Exclude = { + postScore?: number; + postReply?: number; + firstCommentTimestamp?: number; + challenges?: number[]; + post?: boolean; + reply?: boolean; + vote?: boolean; + role?: string[]; + address?: string[]; + rateLimit?: number; + rateLimitChallengeSuccess?: boolean; +}; + export const getDefaultChallengeSettings = (challengeType: string) => { switch (challengeType) { case 'text-math': diff --git a/src/views/subplebbit/subplebbit-settings/subplebbit-settings.module.css b/src/views/subplebbit/subplebbit-settings/subplebbit-settings.module.css index 1f095954..8f3df7de 100644 --- a/src/views/subplebbit/subplebbit-settings/subplebbit-settings.module.css +++ b/src/views/subplebbit/subplebbit-settings/subplebbit-settings.module.css @@ -114,13 +114,13 @@ } .challengeOption { - font-size: 15px; - margin-top: 10px !important; + font-size: 14px; + margin-top: 10px; } .challengeDescription { - margin: 15px 0 15px 0; - font-size: 15px; + margin: 20px 0 0 0; + font-size: 16px; } .challengeOptionDescription { diff --git a/src/views/subplebbit/subplebbit-settings/subplebbit-settings.tsx b/src/views/subplebbit/subplebbit-settings/subplebbit-settings.tsx index 5e13a409..824454b4 100644 --- a/src/views/subplebbit/subplebbit-settings/subplebbit-settings.tsx +++ b/src/views/subplebbit/subplebbit-settings/subplebbit-settings.tsx @@ -8,6 +8,7 @@ import styles from './subplebbit-settings.module.css'; import { isValidURL } from '../../../lib/utils/url-utils'; import { ChallengeSetting, + Exclude, getDefaultChallengeDescription, getDefaultExclude, getDefaultChallengeOptions, @@ -317,28 +318,21 @@ const ChallengeSettings = ({ challenge, index, setSubmitStore, settings, showSet setSubmitStore({ settings: { ...settings, challenges: updatedChallenges } }); }; - const handleExcludeChange = (type: 'role' | 'post' | 'reply' | 'vote', value: string | boolean) => { - const updatedExclude = { ...exclude[0] }; // Clone the first exclude object - - if (type === 'role') { - if (typeof value === 'string') { - const roleIndex = updatedExclude.role.indexOf(value); - if (roleIndex > -1) { - updatedExclude.role.splice(roleIndex, 1); // Remove role - } else { - updatedExclude.role.push(value); // Add role - } - } - } else { - // Handle post, reply, vote - updatedExclude[type] = value; - } - - const updatedChallenges = [...settings.challenges]; - updatedChallenges[index] = { ...updatedChallenges[index], exclude: [updatedExclude] }; + const handleExcludeChange = (type: keyof Exclude, value: string | boolean | number | string[] | number[]) => { + const updatedExclude = { ...exclude[0], [type]: value }; + const updatedChallenges = settings.challenges.map((ch: any, idx: number) => (idx === index ? { ...ch, exclude: [updatedExclude] } : ch)); setSubmitStore({ settings: { ...settings, challenges: updatedChallenges } }); }; + const handleExcludeAddress = (value: string) => { + // Split the input by commas, trim spaces, and filter out empty strings + const addresses = value + .split(',') + .map((addr) => addr.trim()) + .filter((addr) => addr !== ''); + handleExcludeChange('address', addresses); + }; + return (
{getDefaultChallengeDescription(name)}
@@ -356,6 +350,18 @@ const ChallengeSettings = ({ challenge, index, setSubmitStore, settings, showSet
))}
Exclude from challenge
+
+ Specific Users +
Exclude specific user addresses, separated by a comma
+ handleExcludeAddress(e.target.value)} /> +
+
+ User Karma +
Minimum post karma required:
+ handleExcludeChange('postScore', e.target.value)} /> +
Minimum comment karma required:
+ handleExcludeChange('postReply', e.target.value)} /> +
Moderators
Exclude a specific moderator role
From ba4ad420d2e62d35470dac657cff61100f3a00c6 Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Fri, 26 Jan 2024 16:35:18 +0100 Subject: [PATCH 03/13] chore: rename communities/vote routes --- src/app.tsx | 4 ++-- src/lib/utils/view-utils.ts | 8 ++++---- src/views/subplebbits/subplebbits.tsx | 16 ++++++++-------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/app.tsx b/src/app.tsx index 3b7eb136..c4ef875e 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -109,8 +109,8 @@ function App() { } /> } /> } /> - } /> - } /> + } /> + } /> diff --git a/src/lib/utils/view-utils.ts b/src/lib/utils/view-utils.ts index 1643ceea..30a080c1 100644 --- a/src/lib/utils/view-utils.ts +++ b/src/lib/utils/view-utils.ts @@ -148,10 +148,10 @@ export const isSubplebbitsVoteView = (pathname: string): boolean => { return pathname === '/communities/vote'; }; -export const isSubplebbitsVotePassedView = (pathname: string): boolean => { - return pathname === '/communities/vote/passed'; +export const isSubplebbitsVotePassingView = (pathname: string): boolean => { + return pathname === '/communities/vote/passing'; }; -export const isSubplebbitsVoteRejectedView = (pathname: string): boolean => { - return pathname === '/communities/vote/rejected'; +export const isSubplebbitsVoteRejectingView = (pathname: string): boolean => { + return pathname === '/communities/vote/rejecting'; }; diff --git a/src/views/subplebbits/subplebbits.tsx b/src/views/subplebbits/subplebbits.tsx index 51599c00..fe4f68cd 100644 --- a/src/views/subplebbits/subplebbits.tsx +++ b/src/views/subplebbits/subplebbits.tsx @@ -13,8 +13,8 @@ import { isSubplebbitsAdminView, isSubplebbitsOwnerView, isSubplebbitsVoteView, - isSubplebbitsVotePassedView, - isSubplebbitsVoteRejectedView, + isSubplebbitsVotePassingView, + isSubplebbitsVoteRejectingView, } from '../../lib/utils/view-utils'; import { useDefaultSubplebbitAddresses } from '../../lib/utils/addresses-utils'; import { RoleLabel } from '../../components/post/label/label'; @@ -58,8 +58,8 @@ const VoteTabs = () => { const { t } = useTranslation(); const location = useLocation(); const isInSubplebbitsVoteView = isSubplebbitsVoteView(location.pathname); - const isInSubplebbitsVotePassedView = isSubplebbitsVotePassedView(location.pathname); - const isInSubplebbitsVoteRejectedView = isSubplebbitsVoteRejectedView(location.pathname); + const isInSubplebbitsVotePassingView = isSubplebbitsVotePassingView(location.pathname); + const isInSubplebbitsVoteRejectingView = isSubplebbitsVoteRejectingView(location.pathname); return (
@@ -67,12 +67,12 @@ const VoteTabs = () => { {t('all')} | - e.preventDefault()}> - {t('passed')} + e.preventDefault()}> + {t('passing')} | - e.preventDefault()}> - {t('rejected')} + e.preventDefault()}> + {t('rejecting')}
); From 39e5d192b327eaf7fac4a5b315509ec2ac70e7e8 Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Fri, 26 Jan 2024 16:44:13 +0100 Subject: [PATCH 04/13] style(subplebbits): remove online status and set description hidden by default --- src/views/subplebbits/subplebbits.tsx | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/views/subplebbits/subplebbits.tsx b/src/views/subplebbits/subplebbits.tsx index fe4f68cd..42c81ad9 100644 --- a/src/views/subplebbits/subplebbits.tsx +++ b/src/views/subplebbits/subplebbits.tsx @@ -5,7 +5,7 @@ import { Subplebbit as SubplebbitType, useAccount, useAccountSubplebbits, useSub import styles from './subplebbits.module.css'; import Sidebar from '../../components/sidebar'; import SubscribeButton from '../../components/subscribe-button'; -import { getFormattedTimeDuration, getFormattedTimeAgo } from '../../lib/utils/time-utils'; +import { getFormattedTimeDuration } from '../../lib/utils/time-utils'; import { isSubplebbitsView, isSubplebbitsSubscriberView, @@ -18,7 +18,6 @@ import { } from '../../lib/utils/view-utils'; import { useDefaultSubplebbitAddresses } from '../../lib/utils/addresses-utils'; import { RoleLabel } from '../../components/post/label/label'; -const isMobile = window.innerWidth <= 768; interface SubplebbitProps { index?: number; @@ -104,9 +103,9 @@ const Infobar = () => { const Subplebbit = ({ subplebbit }: SubplebbitProps) => { const { t } = useTranslation(); - const { address, createdAt, description, roles, shortAddress, settings, suggested, title, updatedAt } = subplebbit || {}; + const { address, createdAt, description, roles, shortAddress, settings, suggested, title } = subplebbit || {}; - const [showDescription, setShowDescription] = useState(isMobile ? false : true); + const [showDescription, setShowDescription] = useState(false); const buttonType = showDescription ? 'closeButton' : 'textButton'; const toggleExpanded = () => setShowDescription(!showDescription); @@ -122,11 +121,7 @@ const Subplebbit = ({ subplebbit }: SubplebbitProps) => { const downvoteCount = 0; const postScore = upvoteCount === 0 && downvoteCount === 0 ? '•' : upvoteCount - downvoteCount || '•'; - const isOnline = updatedAt && updatedAt > Date.now() / 1000 - 60 * 30; - const { allActiveUserCount, hourActiveUserCount } = useSubplebbitStats({ subplebbitAddress: address }); - const onlineNotice = t('users_online', { count: hourActiveUserCount }); - const offlineNotice = updatedAt && t('posts_last_synced', { dateAgo: getFormattedTimeAgo(updatedAt) }); - const onlineStatus = isOnline ? onlineNotice : offlineNotice; + const { allActiveUserCount } = useSubplebbitStats({ subplebbitAddress: address }); useEffect(() => { document.title = `${t('communities')} - seedit`; @@ -175,9 +170,6 @@ const Subplebbit = ({ subplebbit }: SubplebbitProps) => { )} {t('settings')} - - {onlineStatus} -
From 7f0d5be5ad70c0e467b572fad7f07c26ec0cd0bd Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Fri, 26 Jan 2024 17:23:19 +0100 Subject: [PATCH 05/13] style(subplebbits): add offline label --- src/components/post/label/label.module.css | 4 ++++ src/components/post/label/label.tsx | 6 ++++++ src/views/subplebbits/subplebbits.module.css | 20 ++++---------------- src/views/subplebbits/subplebbits.tsx | 8 +++++--- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/components/post/label/label.module.css b/src/components/post/label/label.module.css index dadec646..a2157c99 100644 --- a/src/components/post/label/label.module.css +++ b/src/components/post/label/label.module.css @@ -26,4 +26,8 @@ .green { color: var(--green); border-color: var(--green); +} + +.uppercase { + text-transform: uppercase; } \ No newline at end of file diff --git a/src/components/post/label/label.tsx b/src/components/post/label/label.tsx index 2017c839..7d9052af 100644 --- a/src/components/post/label/label.tsx +++ b/src/components/post/label/label.tsx @@ -36,3 +36,9 @@ export const RoleLabel = ({ role }: { role: string }) => { return {t(role).toUpperCase()}; }; + +export const OfflineLabel = () => { + const { t } = useTranslation(); + + return {t('offline')}; +}; diff --git a/src/views/subplebbits/subplebbits.module.css b/src/views/subplebbits/subplebbits.module.css index 1bcb6dde..3d711d72 100644 --- a/src/views/subplebbits/subplebbits.module.css +++ b/src/views/subplebbits/subplebbits.module.css @@ -167,14 +167,14 @@ .subplebbitPreferences { padding: 0 1px; line-height: 1.6em; - text-transform: lowercase; margin-top: 1px; + margin-left: 28px; } .subplebbitPreferences a { color: var(--gray-contrast); font-weight: bold; - margin-right: 5px; + margin-left: 1px; } .subplebbitPreferences a:hover { @@ -182,20 +182,8 @@ cursor: pointer; } -.onlineStatus { - margin-right: 5px; -} - -.green { - color: var(--green); -} - -.red { - color: var(--red); -} - -.roleLabel { - padding-right: 2px; +.label { + padding: 0 1px; } .subplebbitsTabs { diff --git a/src/views/subplebbits/subplebbits.tsx b/src/views/subplebbits/subplebbits.tsx index 42c81ad9..c4caf5ee 100644 --- a/src/views/subplebbits/subplebbits.tsx +++ b/src/views/subplebbits/subplebbits.tsx @@ -17,7 +17,7 @@ import { isSubplebbitsVoteRejectingView, } from '../../lib/utils/view-utils'; import { useDefaultSubplebbitAddresses } from '../../lib/utils/addresses-utils'; -import { RoleLabel } from '../../components/post/label/label'; +import { OfflineLabel, RoleLabel } from '../../components/post/label/label'; interface SubplebbitProps { index?: number; @@ -103,7 +103,7 @@ const Infobar = () => { const Subplebbit = ({ subplebbit }: SubplebbitProps) => { const { t } = useTranslation(); - const { address, createdAt, description, roles, shortAddress, settings, suggested, title } = subplebbit || {}; + const { address, createdAt, description, roles, shortAddress, settings, suggested, title, updatedAt } = subplebbit || {}; const [showDescription, setShowDescription] = useState(false); const buttonType = showDescription ? 'closeButton' : 'textButton'; @@ -122,6 +122,7 @@ const Subplebbit = ({ subplebbit }: SubplebbitProps) => { const postScore = upvoteCount === 0 && downvoteCount === 0 ? '•' : upvoteCount - downvoteCount || '•'; const { allActiveUserCount } = useSubplebbitStats({ subplebbitAddress: address }); + const isOnline = updatedAt && updatedAt > Date.now() / 1000 - 60 * 30; useEffect(() => { document.title = `${t('communities')} - seedit`; @@ -164,8 +165,9 @@ const Subplebbit = ({ subplebbit }: SubplebbitProps) => { {t('members_count', { count: allActiveUserCount })}, {t('community_for', { date: getFormattedTimeDuration(createdAt) })}
+ {!isOnline && } {(userRole || isUserOwner) && ( - + )} From 52533e8b801207b9366477c22e7b346461d9f94e Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Fri, 26 Jan 2024 20:47:01 +0100 Subject: [PATCH 06/13] feat(subplebbit settings): exclude users from challenge by account age, and by free actions per hour --- src/lib/utils/challenge-utils.ts | 4 ++-- .../subplebbit-settings.module.css | 1 + .../subplebbit-settings.tsx | 24 +++++++++++++++---- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/lib/utils/challenge-utils.ts b/src/lib/utils/challenge-utils.ts index 4c10d29b..651b49c1 100644 --- a/src/lib/utils/challenge-utils.ts +++ b/src/lib/utils/challenge-utils.ts @@ -132,11 +132,11 @@ export const getDefaultChallengeOptions = (challengeType: string) => { } }; -export type ChallengeSetting = { +export type OptionInput = { option: string; label: string; - description: string; default?: string; + description: string; placeholder?: string; required?: boolean; }; diff --git a/src/views/subplebbit/subplebbit-settings/subplebbit-settings.module.css b/src/views/subplebbit/subplebbit-settings/subplebbit-settings.module.css index 8f3df7de..f774db75 100644 --- a/src/views/subplebbit/subplebbit-settings/subplebbit-settings.module.css +++ b/src/views/subplebbit/subplebbit-settings/subplebbit-settings.module.css @@ -137,6 +137,7 @@ width: auto !important; outline: none; cursor: pointer; + margin-top: 2px; } .challengesArray { diff --git a/src/views/subplebbit/subplebbit-settings/subplebbit-settings.tsx b/src/views/subplebbit/subplebbit-settings/subplebbit-settings.tsx index 824454b4..1a672f72 100644 --- a/src/views/subplebbit/subplebbit-settings/subplebbit-settings.tsx +++ b/src/views/subplebbit/subplebbit-settings/subplebbit-settings.tsx @@ -7,7 +7,7 @@ import { create } from 'zustand'; import styles from './subplebbit-settings.module.css'; import { isValidURL } from '../../../lib/utils/url-utils'; import { - ChallengeSetting, + OptionInput, Exclude, getDefaultChallengeDescription, getDefaultExclude, @@ -310,7 +310,7 @@ const actionsToExclude: Array<'post' | 'reply' | 'vote'> = ['post', 'reply', 'vo const ChallengeSettings = ({ challenge, index, setSubmitStore, settings, showSettings }: ChallengeSettingsProps) => { const { exclude, name, options } = challenge || {}; - const challengeSettings: ChallengeSetting[] = getDefaultChallengeSettings(name); + const challengeSettings: OptionInput[] = getDefaultChallengeSettings(name); const handleOptionChange = (optionName: string, newValue: string) => { const updatedOptions = { ...options, [optionName]: newValue }; @@ -351,17 +351,22 @@ const ChallengeSettings = ({ challenge, index, setSubmitStore, settings, showSet ))}
Exclude from challenge
- Specific Users -
Exclude specific user addresses, separated by a comma
+ Users +
Exclude specific users by their addresses, separated by a comma
handleExcludeAddress(e.target.value)} />
- User Karma + Users with Karma
Minimum post karma required:
handleExcludeChange('postScore', e.target.value)} />
Minimum comment karma required:
handleExcludeChange('postReply', e.target.value)} />
+
+ Users by account age +
Minimum account age in Unix Timestamp (seconds):
+ handleExcludeChange('firstCommentTimestamp', e.target.value)} /> +
Moderators
Exclude a specific moderator role
@@ -386,6 +391,15 @@ const ChallengeSettings = ({ challenge, index, setSubmitStore, settings, showSet
))}
+
+ Rate Limit +
Number of free user actions per hour:
+ handleExcludeChange('rateLimit', e.target.value)} /> + +
); }; From b06212bc029c414e4c771e9c917e814ce205abac Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Fri, 26 Jan 2024 20:59:54 +0100 Subject: [PATCH 07/13] style(label): make all labels uppercase --- src/components/post/label/label.module.css | 5 +---- src/components/post/label/label.tsx | 14 +++++++------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/components/post/label/label.module.css b/src/components/post/label/label.module.css index a2157c99..a37b93a0 100644 --- a/src/components/post/label/label.module.css +++ b/src/components/post/label/label.module.css @@ -6,6 +6,7 @@ line-height: 14px; padding: 0 4px; margin: 0 2px 2px 0; + text-transform: uppercase; } .black { @@ -26,8 +27,4 @@ .green { color: var(--green); border-color: var(--green); -} - -.uppercase { - text-transform: uppercase; } \ No newline at end of file diff --git a/src/components/post/label/label.tsx b/src/components/post/label/label.tsx index 7d9052af..5d525b6a 100644 --- a/src/components/post/label/label.tsx +++ b/src/components/post/label/label.tsx @@ -4,41 +4,41 @@ import styles from './label.module.css'; export const DeletedLabel = () => { const { t } = useTranslation(); - return {t('deleted').toUpperCase()}; + return {t('deleted')}; }; export const FailedLabel = () => { const { t } = useTranslation(); - return {t('failed').toUpperCase()}; + return {t('failed')}; }; export const PendingLabel = () => { const { t } = useTranslation(); - return {t('pending').toUpperCase()}; + return {t('pending')}; }; export const RemovedLabel = () => { const { t } = useTranslation(); - return {t('removed').toUpperCase()}; + return {t('removed')}; }; export const SpoilerLabel = () => { const { t } = useTranslation(); - return {t('spoiler').toUpperCase()}; + return {t('spoiler')}; }; export const RoleLabel = ({ role }: { role: string }) => { const { t } = useTranslation(); - return {t(role).toUpperCase()}; + return {t(role)}; }; export const OfflineLabel = () => { const { t } = useTranslation(); - return {t('offline')}; + return {t('offline')}; }; From 53c8759451caed8912f852e8ca1479a2e2ac6b7b Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Fri, 26 Jan 2024 21:00:10 +0100 Subject: [PATCH 08/13] style(subplebbits): use same padding as posts --- src/views/subplebbits/subplebbits.module.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/views/subplebbits/subplebbits.module.css b/src/views/subplebbits/subplebbits.module.css index 3d711d72..bcfbc3f3 100644 --- a/src/views/subplebbits/subplebbits.module.css +++ b/src/views/subplebbits/subplebbits.module.css @@ -20,7 +20,7 @@ } .subplebbit { - margin-bottom: 10px; + padding-bottom: 1px; height: auto; overflow: hidden; } @@ -38,7 +38,7 @@ .arrowWrapper { padding-left: 11px; - padding-top: 2px; + padding-top: 1px; } .arrowCommon { From 337373fdf5ebc1d7a9e2b416c36967842ae24c1b Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Fri, 26 Jan 2024 22:25:48 +0100 Subject: [PATCH 09/13] fix(markdown): remove regex, adopting conventional markdown rules --- src/components/markdown/markdown.tsx | 8 +------- .../subplebbit-settings/subplebbit-settings.tsx | 14 +++++++------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/components/markdown/markdown.tsx b/src/components/markdown/markdown.tsx index 65f0fc21..d4f81058 100644 --- a/src/components/markdown/markdown.tsx +++ b/src/components/markdown/markdown.tsx @@ -6,12 +6,6 @@ import breaks from 'remark-breaks'; import remarkGfm from 'remark-gfm'; const Markdown = ({ content }: { content: string }) => { - // replace \n with \n\n when it follows a sentence starting with '>' - let preserveNewlineAfterQuote = content?.replace(/(^|\n)(>[^>].*?)(\n)/gm, '$1\n$2\n\n'); - - // replace \n\n with \n for list items separated by two newlines - let adjustListNewlines = preserveNewlineAfterQuote?.replace(/(\n\n)([*-]|[0-9]+\.) (.+?)(?=\n\n([*-]|[0-9]+\.) )/gms, '\n$2 $3'); - const customSchema = useMemo( () => ({ ...defaultSchema, @@ -41,7 +35,7 @@ const Markdown = ({ content }: { content: string }) => { return (
{getDefaultChallengeDescription(name)}
{challengeSettings.map((setting) => ( -
-
{setting.label}
-
{setting.description}
+
+
{setting?.label}
+
{setting?.description}
handleOptionChange(setting.option, e.target.value)} - required={setting.required || false} + value={options && (options[setting?.option] || setting?.default || '')} + placeholder={setting?.placeholder || ''} + onChange={(e) => handleOptionChange(setting?.option, e.target.value)} + required={setting?.required || false} />
))} From feb97edf6a27cd21efaebab3411ae21f88f92094 Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Fri, 26 Jan 2024 22:40:50 +0100 Subject: [PATCH 10/13] style(subplebbit settings): add placeholders for exclude values --- .../subplebbit-settings.tsx | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/views/subplebbit/subplebbit-settings/subplebbit-settings.tsx b/src/views/subplebbit/subplebbit-settings/subplebbit-settings.tsx index f28c849c..f1744e97 100644 --- a/src/views/subplebbit/subplebbit-settings/subplebbit-settings.tsx +++ b/src/views/subplebbit/subplebbit-settings/subplebbit-settings.tsx @@ -353,19 +353,29 @@ const ChallengeSettings = ({ challenge, index, setSubmitStore, settings, showSet
Users
Exclude specific users by their addresses, separated by a comma
- handleExcludeAddress(e.target.value)} /> + handleExcludeAddress(e.target.value)} + />
Users with Karma
Minimum post karma required:
- handleExcludeChange('postScore', e.target.value)} /> + handleExcludeChange('postScore', e.target.value)} />
Minimum comment karma required:
- handleExcludeChange('postReply', e.target.value)} /> + handleExcludeChange('postReply', e.target.value)} />
Users by account age
Minimum account age in Unix Timestamp (seconds):
- handleExcludeChange('firstCommentTimestamp', e.target.value)} /> + handleExcludeChange('firstCommentTimestamp', e.target.value)} + />
Moderators @@ -394,7 +404,7 @@ const ChallengeSettings = ({ challenge, index, setSubmitStore, settings, showSet
Rate Limit
Number of free user actions per hour:
- handleExcludeChange('rateLimit', e.target.value)} /> + handleExcludeChange('rateLimit', e.target.value)} />