Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Bulk email from workspace #259

Merged
merged 8 commits into from
Dec 12, 2024
Merged

✨ Bulk email from workspace #259

merged 8 commits into from
Dec 12, 2024

Conversation

foysalit
Copy link
Contributor

@foysalit foysalit commented Dec 11, 2024

This PR adds email event to both quick action panel and workspace panel which allows moderators to send emails directly from quick action panel after a takedown or similar action and in bulk from workspace.

Screen.Recording.2024-12-11.at.20.44.51.mov

<SubjectSwitchButton
subject={subject}
setSubject={setSubject}
<div className="flex sm:w-1/2 flex-col">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff below looks scary because of this root level wrapper element change. Almost nothing changed below except for a level of indentation and positioning in line.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not would be a good time to actually re-factor this huge component into smaller ones ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah it just keeps growing but honestly, this is like the most used and impactful piece of code in the whole app so kinda nervous to do that along with a PR. let me do a separate PR for it.

@@ -52,7 +52,7 @@
"@tailwindcss/forms": "^0.5.3",
"@tailwindcss/typography": "^0.5.8",
"autoprefixer": "^10.4.13",
"cypress": "^12.14.0",
"cypress": "^13.16.1",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not related to the PR of course but i don't touch these tests often so wanted to take this opportunity to upgrade

Copy link
Contributor

@matthieusieben matthieusieben left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine 👍

Comment on lines +117 to +136
await toast.promise(
labelerAgent.tools.ozone.moderation.emitEvent({
event,
createdBy: labelerAgent.assertDid,
subject: { $type: 'com.atproto.admin.defs#repoRef', did },
}),
{
pending: 'Sending email...',
success: {
render() {
return 'Email sent to user'
},
},
},
error: {
render() {
return 'Error sending email'
error: {
render() {
return 'Error sending email'
},
},
},
},
)
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we make handleSubmit non-optional and use this implementation as handleSubmit wherever this is used ? Alternatively, a simpler re-factor would be to create a new component that provides this handleSubmit implementation:

export function EmailComposer ({ did }: { did: string }) {
  return <EmailComposerBase
    did={did}
    handleSubmit={
      // tools.ozone.moderation.emitEvent + toast here
    }
    />
})

export function EmailComposerBase ({
  did,
  replacePlaceholders = true,
  handleSubmit,
}: {
  did?: string
  replacePlaceholders?: boolean
  handleSubmit?: (emailData: EmailComposerData) => Promise<void>
}) {

}

})
results.succeeded.push(sub)
} catch (err) {
console.error(err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.error(err)

Comment on lines 55 to 59
return Array.from(
formRef.current?.querySelectorAll<HTMLInputElement>(
'input[type="checkbox"][name="workspaceItem"]:checked',
) || [],
).map((checkbox) => checkbox.value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you know: the second argument of Array.from is a map function ;-)

Suggested change
return Array.from(
formRef.current?.querySelectorAll<HTMLInputElement>(
'input[type="checkbox"][name="workspaceItem"]:checked',
) || [],
).map((checkbox) => checkbox.value)
return Array.from(
formRef.current?.querySelectorAll<HTMLInputElement>(
'input[type="checkbox"][name="workspaceItem"]:checked',
) || [],
(checkbox) => checkbox.value
)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope. TIL!

<SubjectSwitchButton
subject={subject}
setSubject={setSubject}
<div className="flex sm:w-1/2 flex-col">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not would be a good time to actually re-factor this huge component into smaller ones ?

@arcalinea arcalinea temporarily deployed to bulk-email - ozone-staging PR #259 December 12, 2024 15:41 — with Render Destroyed
@foysalit
Copy link
Contributor Author

refactored PR coming up soon.

@foysalit foysalit merged commit 35fd616 into main Dec 12, 2024
3 checks passed
@matthieusieben matthieusieben deleted the bulk-email branch December 17, 2024 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants