-
Notifications
You must be signed in to change notification settings - Fork 39
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
Conversation
<SubjectSwitchButton | ||
subject={subject} | ||
setSubject={setSubject} | ||
<div className="flex sm:w-1/2 flex-col"> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine 👍
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' | ||
}, | ||
}, | ||
}, | ||
}, | ||
) | ||
) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console.error(err) |
components/workspace/Panel.tsx
Outdated
return Array.from( | ||
formRef.current?.querySelectorAll<HTMLInputElement>( | ||
'input[type="checkbox"][name="workspaceItem"]:checked', | ||
) || [], | ||
).map((checkbox) => checkbox.value) |
There was a problem hiding this comment.
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 ;-)
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 | |
) |
There was a problem hiding this comment.
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"> |
There was a problem hiding this comment.
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 ?
refactored PR coming up soon. |
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