Skip to content

Commit

Permalink
✨ Add wrapper for comment
Browse files Browse the repository at this point in the history
  • Loading branch information
foysalit committed Dec 23, 2024
1 parent 0306a9a commit 2101f54
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
12 changes: 8 additions & 4 deletions app/reports/page-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -419,10 +419,14 @@ const getQueueItems = async (
const pageSize = 100

if (queueName && queueSetting?.queueNames.length) {
queryParams.queueCount = queueSetting.queueNames.length
queryParams.queueIndex = queueSetting.queueNames.indexOf(queueName)
if (queueSetting.queueSeed) {
queryParams.queueSeed = queueSetting.queueSeed
const queueIndex = queueSetting.queueNames.indexOf(queueName)
// Only apply queue filters if the user is looking at a queue that exists in the list of queues
if (queueIndex >= 0) {
queryParams.queueIndex = queueIndex

Check failure on line 425 in app/reports/page-content.tsx

View workflow job for this annotation

GitHub Actions / Build

Property 'queueIndex' does not exist on type 'QueryParams'.
queryParams.queueCount = queueSetting.queueNames.length

Check failure on line 426 in app/reports/page-content.tsx

View workflow job for this annotation

GitHub Actions / Build

Property 'queueCount' does not exist on type 'QueryParams'.
if (queueSetting.queueSeed) {
queryParams.queueSeed = queueSetting.queueSeed

Check failure on line 428 in app/reports/page-content.tsx

View workflow job for this annotation

GitHub Actions / Build

Property 'queueSeed' does not exist on type 'QueryParams'.
}
}
}
const { data } = await labelerAgent.tools.ozone.moderation.queryStatuses({
Expand Down
38 changes: 36 additions & 2 deletions components/mod-event/EventItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,38 @@ const LinkToAuthor = ({
)
}

// Utility function to detect and replace links with <a> tags
const wrapLinksInText = (text: string): JSX.Element[] => {
// Regular expression to match URLs
const urlRegex = /(https?:\/\/[^\s]+)/g

// Split text into parts, with URLs as matches
const parts = text.split(urlRegex)

return parts.map((part, index) => {
if (urlRegex.test(part)) {
// If part matches a URL, return it as a link
return (
<a
key={index}
href={part}
target="_blank"
rel="noopener noreferrer"
className="break-all underline"
>
{part}
</a>
)
}
// Otherwise, return it as plain text
return <span key={index}>{part}</span>
})
}

const TextWithLinks: React.FC<{ text: string }> = ({ text }) => {
return <p className="whitespace-pre-wrap">{wrapLinksInText(text)}</p>
}

const Comment = ({
modEvent,
}: {
Expand Down Expand Up @@ -60,7 +92,9 @@ const Comment = ({
)}
</div>
</div>
{modEvent.event.comment && <p>{modEvent.event.comment}</p>}
{modEvent.event.comment && (
<TextWithLinks text={modEvent.event.comment} />
)}
{/* This is only for legacy actions, new actions won't have these properties for these events */}
<EventLabels
header="Added: "
Expand Down Expand Up @@ -141,7 +175,7 @@ const Report = ({
</div>
</div>
{modEvent.event.comment && (
<p className="mt-1">{modEvent.event.comment}</p>
<TextWithLinks text={modEvent.event.comment} />
)}

{isMessageSubject(modEvent.subject) && (
Expand Down

0 comments on commit 2101f54

Please sign in to comment.