-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
19 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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(), | ||
|
@@ -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> | ||
|
@@ -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:[email protected]`} style={{ color: "#1e90ff", textDecoration: "none" }}>[email protected]</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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters