Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
cehune committed Oct 27, 2024
1 parent 8740170 commit 789fcc9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 52 deletions.
2 changes: 1 addition & 1 deletion emails/_common/watcloud-email.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { getAsset, registerAsset, WATcloudURI } from "../../utils/watcloud-uri";
registerAsset('watcloud-logo', new WATcloudURI("watcloud://v1/sha256:393767e36d5387815c15d11c506c3c820de5db41723ffc062751673621dedb15?name=1024x512%20black%401x.png"))

// Wrapper for WATcloud-themed emails
export function Email({
export function WATcloudEmail({
previewText,
children,
}: {
Expand Down
6 changes: 3 additions & 3 deletions emails/blog-update.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from "@react-email/components";
import { z } from "zod";
import { getAsset, registerAsset, WATcloudURI } from "../utils/watcloud-uri";
import { Email } from "./_common/watcloud-email";
import { WATcloudEmail } from "./_common/watcloud-email";

const WATcloudBlogUpdateEmailProps = z.object({
url: z.string().url(),
Expand Down Expand Up @@ -37,7 +37,7 @@ export function WATcloudBlogUpdateEmail(props: WATcloudBlogUpdateEmailProps) {
const imageSrc = getAsset(image).resolveFromCache();

return (
<Email previewText={previewText}>
<WATcloudEmail previewText={previewText}>
<Text>Hello! WATcloud has published a new blog post.</Text>
<Hr style={{ marginTop: "20px", marginBottom: "20px" }} />
<Img src={imageSrc} alt={title} height="200" />
Expand All @@ -51,7 +51,7 @@ export function WATcloudBlogUpdateEmail(props: WATcloudBlogUpdateEmailProps) {
<Link href={url}>Read more →</Link>
<Hr style={{ marginTop: "20px", marginBottom: "20px" }} />
<Text style={{ color: "#666", fontSize: "12px" }}>You are receiving this email because you are subscribed to the WATcloud blog.</Text>
</Email>
</WATcloudEmail>
);
};

Expand Down
57 changes: 12 additions & 45 deletions emails/file-expiry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
Text
} from "@react-email/components";
import { z } from "zod";
import { Email } from "./_common/watcloud-email";
import { WATcloudEmail } from "./_common/watcloud-email";

const EmailProps = z.object({
name: z.string(),
Expand All @@ -16,56 +16,23 @@ const EmailProps = z.object({

type EmailProps = z.infer<typeof EmailProps>;

export const FileExpiryEmail = (props: EmailProps) => {
const Email = (props: EmailProps) => {
const { name, paths, daysForExpiry, deletionDate} = EmailProps.parse(props);

const previewText = `You have expired files in the WATO drives`;
const mapPathToMachine = (): Record<string, string[]> => {
const pathMap: Record<string, string[]> = {};

paths.forEach((path: string) => {
const index = path.indexOf(":");
let machine = "";
let filepath = "";

if (index < 0) {
machine = "Shared storage across machines - Access on any machine";
filepath = path;
} else {
[machine, filepath] = path.split(":", 2);
}

// Initialize array for machine if it doesn't exist, then push the filepath
if (!pathMap[machine]) {
pathMap[machine] = [];
}
pathMap[machine].push(filepath);
});

return pathMap; // Return the pathMap object
};

const pathMap = mapPathToMachine();

const expiredPaths = (
<div>
{Object.keys(pathMap).map((machine) => (
<div key={machine}>
<ul key={machine} style={{ fontSize: "14px", lineHeight: "24px" }}>
<li>{machine}</li>
<ul>
{pathMap[machine]?.map((path, pathIndex) => (
<li key={pathIndex}>{path}</li>
))}
</ul>
</ul>
</div>
))}
<ul>
{paths.map(path => (
<li key={path}>{path}</li>
))}
</ul>
</div>
);

return (
<Email previewText={previewText}>
<WATcloudEmail previewText={previewText}>
<Text>Hi {name},</Text>
<Text>
In an ongoing effort to keep WATcloud's file storage efficient and maintain optimal performance, we routinely clean up specific directories that haven't been accessed in the past {daysForExpiry} days. </Text>
Expand All @@ -80,15 +47,15 @@ export const FileExpiryEmail = (props: EmailProps) => {
<Text>
If you have any questions, please reach out to your <Link href="https://cloud.watonomous.ca/docs/services#watcloud-contact" style={{ color: "#1e90ff", textDecoration: "none" }}>WATcloud contact</Link> or the WATcloud team at <Link href={`mailto:infra-outreach@watonomous.ca`} style={{ color: "#1e90ff", textDecoration: "none" }}>infra-outreach@watonomous.ca</Link>.
</Text>
</Email>
</WATcloudEmail>
);
};

FileExpiryEmail.PreviewProps = {
Email.PreviewProps = {
name: "John Doe",
paths: ["delta-ubuntu2:/var/lib/cluster/users/1234/docker", "tr-ubuntu3:/var/lib/cluster/users/1234/containers", "delta-ubuntu2:/var/lib/cluster/users/1234/containers", "/mnt/wato-drive2/someuser", "/mnt/wato-drive2/other"],
paths: ["delta-ubuntu2:/var/lib/cluster/users/1234/docker", "delta-ubuntu2:/var/lib/cluster/users/1234/containers", "tr-ubuntu3:/var/lib/cluster/users/1234/containers","/mnt/wato-drive2/someuser", "/mnt/wato-drive2/other"],
daysForExpiry: "70",
deletionDate: "2025-01-01"
} as EmailProps;

export default FileExpiryEmail;
export default Email;
6 changes: 3 additions & 3 deletions emails/onboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from "@react-email/components";
import dedent from "dedent-js";
import { z } from "zod";
import { Email } from "./_common/watcloud-email";
import { WATcloudEmail } from "./_common/watcloud-email";

const WATcloudOnboardingEmailProps = z.object({
name: z.string(),
Expand All @@ -28,7 +28,7 @@ export const WATcloudOnboardingEmail = (props: WATcloudOnboardingEmailProps) =>
)

return (
<Email previewText={previewText}>
<WATcloudEmail previewText={previewText}>
<Text>Hi {name},</Text>
<Text>
Welcome to WATcloud, WATonomous's compute cluster and infrastructure. We are excited to have you on board!
Expand Down Expand Up @@ -61,7 +61,7 @@ export const WATcloudOnboardingEmail = (props: WATcloudOnboardingEmailProps) =>
`)}
</pre>
<Text>WATcloud Onboarding Bot 🤖</Text>
</Email>
</WATcloudEmail>
);
};

Expand Down

0 comments on commit 789fcc9

Please sign in to comment.