From 9a46c604d8f8d59173210d0d3b9ea3f7d19da695 Mon Sep 17 00:00:00 2001 From: "Tom (plebeius.eth)" Date: Sat, 6 Jul 2024 09:21:49 +0200 Subject: [PATCH 1/7] style(post): slice hostname instead of css text-overflow --- src/components/post/post.module.css | 2 -- src/components/post/post.tsx | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/components/post/post.module.css b/src/components/post/post.module.css index e3cbd42d..6d15ab6e 100644 --- a/src/components/post/post.module.css +++ b/src/components/post/post.module.css @@ -122,9 +122,7 @@ display: inline-block; overflow: hidden; white-space: nowrap; - text-overflow: ellipsis; vertical-align: middle; - max-width: 19em; text-decoration: none; } diff --git a/src/components/post/post.tsx b/src/components/post/post.tsx index 97e43645..bbe59732 100644 --- a/src/components/post/post.tsx +++ b/src/components/post/post.tsx @@ -208,7 +208,7 @@ const Post = ({ index, post = {} }: PostProps) => { ( - {linkUrl} + {linkUrl.length > 25 ? linkUrl.slice(0, 25) + '...' : linkUrl} ) From 9bc3dec8dbc094639dfc3caedb22b40d00cdf157 Mon Sep 17 00:00:00 2001 From: "Tom (plebeius.eth)" Date: Sat, 6 Jul 2024 12:58:04 +0200 Subject: [PATCH 2/7] change directory, fix undefined --- src/app.tsx | 2 +- .../subplebbit-settings/index.ts | 0 .../subplebbit-settings.module.css | 0 .../subplebbit-settings.tsx | 40 +++++++++---------- 4 files changed, 21 insertions(+), 21 deletions(-) rename src/views/{subplebbit => }/subplebbit-settings/index.ts (100%) rename src/views/{subplebbit => }/subplebbit-settings/subplebbit-settings.module.css (100%) rename src/views/{subplebbit => }/subplebbit-settings/subplebbit-settings.tsx (97%) diff --git a/src/app.tsx b/src/app.tsx index 01b0530b..f5c50150 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -15,7 +15,7 @@ import Profile from './views/profile'; import Settings from './views/settings'; import SubmitPage from './views/submit-page'; import Subplebbit from './views/subplebbit'; -import SubplebbitSettings from './views/subplebbit/subplebbit-settings'; +import SubplebbitSettings from './views/subplebbit-settings'; import Subplebbits from './views/subplebbits'; import AccountBar from './components/account-bar/'; import ChallengeModal from './components/challenge-modal'; diff --git a/src/views/subplebbit/subplebbit-settings/index.ts b/src/views/subplebbit-settings/index.ts similarity index 100% rename from src/views/subplebbit/subplebbit-settings/index.ts rename to src/views/subplebbit-settings/index.ts diff --git a/src/views/subplebbit/subplebbit-settings/subplebbit-settings.module.css b/src/views/subplebbit-settings/subplebbit-settings.module.css similarity index 100% rename from src/views/subplebbit/subplebbit-settings/subplebbit-settings.module.css rename to src/views/subplebbit-settings/subplebbit-settings.module.css diff --git a/src/views/subplebbit/subplebbit-settings/subplebbit-settings.tsx b/src/views/subplebbit-settings/subplebbit-settings.tsx similarity index 97% rename from src/views/subplebbit/subplebbit-settings/subplebbit-settings.tsx rename to src/views/subplebbit-settings/subplebbit-settings.tsx index a258f2ae..cd1a5010 100644 --- a/src/views/subplebbit/subplebbit-settings/subplebbit-settings.tsx +++ b/src/views/subplebbit-settings/subplebbit-settings.tsx @@ -9,17 +9,17 @@ import { useSubplebbit, usePublishSubplebbitEdit, } from '@plebbit/plebbit-react-hooks'; -import { Roles } from '../../../lib/utils/user-utils'; +import { Roles } from '../../lib/utils/user-utils'; import { useTranslation } from 'react-i18next'; import { create } from 'zustand'; import styles from './subplebbit-settings.module.css'; -import { isValidURL } from '../../../lib/utils/url-utils'; -import { isCreateSubplebbitView, isSubplebbitSettingsView } from '../../../lib/utils/view-utils'; -import useChallengesOptions from '../../../hooks/use-challenges-options'; -import useChallengeSettings from '../../../hooks/use-challenge-settings'; -import LoadingEllipsis from '../../../components/loading-ellipsis'; -import Markdown from '../../../components/markdown'; -import Sidebar from '../../../components/sidebar'; +import { isValidURL } from '../../lib/utils/url-utils'; +import { isCreateSubplebbitView, isSubplebbitSettingsView } from '../../lib/utils/view-utils'; +import useChallengesOptions from '../../hooks/use-challenges-options'; +import useChallengeSettings from '../../hooks/use-challenge-settings'; +import LoadingEllipsis from '../../components/loading-ellipsis'; +import Markdown from '../../components/markdown'; +import Sidebar from '../../components/sidebar'; import _ from 'lodash'; type SubplebbitSettingsState = { @@ -315,7 +315,7 @@ const Moderators = ({ isReadOnly = false }: { isReadOnly?: boolean }) => { )} {roles && - Object.entries(roles).map(([address, role], index) => ( + Object.entries(roles)?.map(([address, role], index) => (
{t('moderator')} #{index + 1} {!isReadOnly && (isReadOnly ? {} : handleDeleteModerator(address))} />} @@ -399,7 +399,7 @@ const ChallengeSettings = ({ challenge, index, isReadOnly, setSubplebbitSettings const handleOptionChange = (optionName: string, newValue: string) => { const updatedOptions = { ...options, [optionName]: newValue }; - const updatedChallenges = settings.challenges.map((ch: any, idx: number) => (idx === index ? { ...ch, options: updatedOptions } : ch)); + const updatedChallenges = settings.challenges?.map((ch: any, idx: number) => (idx === index ? { ...ch, options: updatedOptions } : ch)); setSubplebbitSettingsStore({ settings: { ...settings, challenges: updatedChallenges } }); }; @@ -431,9 +431,9 @@ const ChallengeSettings = ({ challenge, index, isReadOnly, setSubplebbitSettings }; const handleExcludeChange = (excludeIndex: number, type: keyof Exclude | 'not post' | 'not reply' | 'not vote', value: any) => { - const updatedChallenges = settings.challenges.map((ch: any, idx: number) => { + const updatedChallenges = settings.challenges?.map((ch: any, idx: number) => { if (idx === index) { - const updatedExclude = ch.exclude.map((ex: any, exIdx: number) => { + const updatedExclude = ch.exclude?.map((ex: any, exIdx: number) => { if (exIdx === excludeIndex) { let newEx = { ...ex }; @@ -483,7 +483,7 @@ const ChallengeSettings = ({ challenge, index, isReadOnly, setSubplebbitSettings const handleExcludeAddress = (excludeIndex: number, value: string) => { const addresses = value .split(',') - .map((addr) => addr.trim()) + ?.map((addr) => addr.trim()) .filter((addr) => addr !== ''); handleExcludeChange(excludeIndex, 'address', addresses); }; @@ -498,7 +498,7 @@ const ChallengeSettings = ({ challenge, index, isReadOnly, setSubplebbitSettings ) : (
{challengeSettings?.description}
)} - {challengeSettings?.optionInputs.map((setting: OptionInput) => ( + {challengeSettings?.optionInputs?.map((setting: OptionInput) => (
{setting?.label}
@@ -594,7 +594,7 @@ const ChallengeSettings = ({ challenge, index, isReadOnly, setSubplebbitSettings
User's role
Is any of the following:
- {rolesToExclude.map((role) => + {rolesToExclude?.map((role) => isReadOnly && !exclude?.role?.includes(role) ? null : (
{isReadOnly ? ( @@ -619,7 +619,7 @@ const ChallengeSettings = ({ challenge, index, isReadOnly, setSubplebbitSettings
User's action
Is all of the following:
- {actionsToExclude.map((action) => + {actionsToExclude?.map((action) => isReadOnly && !exclude?.[action] ? null : (
{isReadOnly ? ( @@ -638,7 +638,7 @@ const ChallengeSettings = ({ challenge, index, isReadOnly, setSubplebbitSettings
), )} - {nonActionsToExclude.map((nonAction) => + {nonActionsToExclude?.map((nonAction) => isReadOnly && exclude?.[nonAction.replace('not ', '')] !== null ? null : (
{isReadOnly ? ( @@ -717,7 +717,7 @@ const Challenges = ({ isReadOnly, readOnlyChallenges }: { isReadOnly: boolean; r const { t } = useTranslation(); const { settings, setSubplebbitSettingsStore } = useSubplebbitSettingsStore(); const challenges = settings?.challenges || readOnlyChallenges || []; - const [showSettings, setShowSettings] = useState(challenges.map(() => false)); + const [showSettings, setShowSettings] = useState(challenges?.map(() => false)); const challengeOptions = useChallengesOptions(); const location = useLocation(); @@ -764,7 +764,7 @@ const Challenges = ({ isReadOnly, readOnlyChallenges }: { isReadOnly: boolean; r )} {challenges.length === 0 && !isInCreateSubplebbitView && {t('warning_spam')}} - {challenges.map((challenge: any, index: number) => ( + {challenges?.map((challenge: any, index: number) => (
Challenge #{index + 1} {!isReadOnly && (isReadOnly ? {} : handleDeleteChallenge(index))} />} @@ -773,7 +773,7 @@ const Challenges = ({ isReadOnly, readOnlyChallenges }: { isReadOnly: boolean; r {challenge?.name} ) : (