-
Notifications
You must be signed in to change notification settings - Fork 83
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
Email notifications for create,update,delete deployment #182
Changes from 14 commits
069e07d
7006df1
70c05fe
5286bf0
4f3b044
02fd980
d22a83d
9d0deba
b9a5dc9
e500a51
fa42080
1d1fb57
fc5579d
d176819
bf43e99
3e8ea66
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ Firebase environment variables can be found in project settings section of your | |
- `NEXT_PUBLIC_NOTIFICATION_TOPIC` - Topic created for notifications | ||
- `NEXT_PUBLIC_NOTIFICATION_SUB` - Subscription created for notifications | ||
- `NEXT_PUBLIC_GIT_API_URL` - Url of the public repo to pull the deployment modules | ||
- `SECRET_MANAGER_LOCATION` - Google Cloud region of the Secret Manager instance | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2 Questions:
SOLUTION: If its manually set and we want to automate it like other variables we can expose the above There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
## Git Hub repo envs | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<html> | ||
<head> | ||
<style></style> | ||
</head> | ||
<body> | ||
<h3>Hello!</h3> | ||
<p> | ||
RAD Lab Module with deployment ID - | ||
<a href="{{{deployment_link}}}" style="border: 0" target="_blank"> | ||
{{deploymentId}}</a | ||
> | ||
has been successfully deleted! | ||
</p> | ||
|
||
<br /> | ||
<p>Thank you<br /></p> | ||
<img | ||
style="width: 8rem; height: 2rem" | ||
src="https://github.com/GPS-Demos/rad-lab/blob/main/radlab-ui/webapp/public/assets/images/logo.png?raw=true" | ||
/> | ||
<p>P.S:- This is an auto generated email. Please do not reply!</p> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<html> | ||
<head> | ||
<style> | ||
table { | ||
font-family: arial, sans-serif; | ||
border-collapse: collapse; | ||
width: 40%; | ||
} | ||
|
||
td, | ||
th { | ||
border: 1px solid #dddddd; | ||
text-align: left; | ||
padding: 8px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<h3>Hello!</h3> | ||
<p>{{mailBodyTitle}}</p> | ||
<p>Please use below details to access the same.</p> | ||
|
||
<table id="myTable"> | ||
<tr> | ||
<th>Name</th> | ||
<th>value</th> | ||
</tr> | ||
<tr> | ||
<td>Project Id</td> | ||
<td> | ||
<a href="{{{gcp_project_link}}}" style="border: 0" target="_blank" | ||
>{{projectId}}</a | ||
> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td>Deployment Id</td> | ||
<td> | ||
<a href="{{{deployment_link}}}" style="border: 0" target="_blank" | ||
>{{deploymentId}}</a | ||
> | ||
</td> | ||
</tr> | ||
{{#outputs}} | ||
<tr> | ||
<td>{{name}}</td> | ||
<td>{{value}}</td> | ||
</tr> | ||
{{/outputs}} | ||
</table> | ||
|
||
<br /> | ||
<p>Thank you<br /></p> | ||
<img | ||
style="width: 8rem; height: 2rem" | ||
src="https://github.com/GPS-Demos/rad-lab/blob/main/radlab-ui/webapp/public/assets/images/logo.png?raw=true" | ||
/> | ||
<p>P.S:- This is an auto generated email. Please do not reply!</p> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,11 +6,13 @@ import { | |
ALERT_TYPE, | ||
Dictionary, | ||
IFormData, | ||
ISecretManagerReq, | ||
IUIVariable, | ||
IVariables, | ||
} from "@/utils/types" | ||
import { mergeAllSafe } from "@/utils/variables" | ||
import axios from "axios" | ||
import { FormikValues } from "formik" | ||
import { useTranslation } from "next-i18next" | ||
import React, { useEffect, useState } from "react" | ||
import { useNavigate } from "react-router-dom" | ||
|
@@ -34,9 +36,20 @@ const DefaultCreateForm: React.FC<IDefaultCreateFormProps> = ({ | |
const setAlert = alertStore((state) => state.setAlert) | ||
const user = userStore((state) => state.user) | ||
const navigate = useNavigate() | ||
const [answerValueData, setAnswerValueData] = useState<FormikValues>({}) | ||
|
||
const handleSubmit = async (values: IFormData) => { | ||
handleLoading(true) | ||
|
||
if (values.email_notifications) { | ||
const secretManagerPayload: ISecretManagerReq = { | ||
key: "mailBoxCred", | ||
value: values.mail_server_password, | ||
} | ||
await saveMailBoxCred(secretManagerPayload) | ||
} | ||
|
||
delete values.mail_server_password | ||
const payload = Object.assign(values, { | ||
email: user?.email, | ||
}) | ||
|
@@ -75,14 +88,55 @@ const DefaultCreateForm: React.FC<IDefaultCreateFormProps> = ({ | |
return mergeAllSafe([initialFormData, defaultSettingVariables]) | ||
} | ||
|
||
const saveMailBoxCred = async (payload: ISecretManagerReq) => { | ||
try { | ||
await axios.post("/api/secret", payload) | ||
} catch (error: any) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we put a proper type here? I believe it's some sort of AxiosErrorResponse There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
setAlert({ | ||
message: error.message, | ||
type: ALERT_TYPE.ERROR, | ||
}) | ||
} | ||
} | ||
|
||
const handleChangeValues = (answerValues: FormikValues) => { | ||
setAnswerValueData(answerValues) | ||
} | ||
|
||
const formatDependsVariables = ( | ||
formVariablesData: IUIVariable[], | ||
currentAnswerValueData: FormikValues, | ||
) => { | ||
const allNonDependsVars = formVariablesData.filter( | ||
(formVariableData) => | ||
formVariableData.name !== "mail_server_email" && | ||
formVariableData.name !== "mail_server_password", | ||
) | ||
const allDependsVars = formVariablesData.filter( | ||
(formVariableData) => | ||
formVariableData.name === "mail_server_email" || | ||
formVariableData.name === "mail_server_password", | ||
) | ||
|
||
const notificationAnswer = currentAnswerValueData.email_notifications | ||
const releventParse = allNonDependsVars.concat( | ||
notificationAnswer ? allDependsVars : [], | ||
) | ||
return releventParse | ||
} | ||
|
||
useEffect(() => { | ||
if (formVariables.length > 0) { | ||
const initialFormVariable = setDefaultSettingVariables() | ||
setInitialData(initialFormVariable) | ||
const groupedVariableList = groupVariables(formVariables) | ||
const releventParse = formatDependsVariables( | ||
formVariables, | ||
answerValueData, | ||
) | ||
const groupedVariableList = groupVariables(releventParse) | ||
setFormData(groupedVariableList) | ||
} | ||
}, formVariables) | ||
}, [formVariables, answerValueData]) | ||
|
||
return ( | ||
<div className="w-full"> | ||
|
@@ -98,6 +152,7 @@ const DefaultCreateForm: React.FC<IDefaultCreateFormProps> = ({ | |
variableList={group} | ||
idx={index} | ||
key={grpId} | ||
handleChangeValues={handleChangeValues} | ||
/> | ||
) : ( | ||
<></> | ||
|
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.
I think the best place for this section is under Global Admin Variables section compared to Troubleshooting section.
And also we should remove the mention of
Preferred Google Cloud Region and Zone
from Global Admin Variables.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.
Moved
Email Notifications
section toGlobal Admin Variables