|
|
@@ -1,13 +1,17 @@
|
|
|
-import React, { useState } from "react";
|
|
|
+import React, { useContext, useState } from "react";
|
|
|
import Heading from "../../../../components/form-components/Heading";
|
|
|
import CheckboxRow from "../../../../components/form-components/CheckboxRow";
|
|
|
import Helper from "../../../../components/form-components/Helper";
|
|
|
import SaveButton from "../../../../components/SaveButton";
|
|
|
+import api from "../../../../shared/api";
|
|
|
+import { Context } from "../../../../shared/Context";
|
|
|
+import { ChartType } from "../../../../shared/types";
|
|
|
|
|
|
const NOTIF_CATEGORIES = ["deploy", "success", "fail"];
|
|
|
|
|
|
interface Props {
|
|
|
disabled?: boolean;
|
|
|
+ currentChart: ChartType;
|
|
|
}
|
|
|
|
|
|
const NotificationSettingsSection: React.FC<Props> = (props) => {
|
|
|
@@ -21,6 +25,33 @@ const NotificationSettingsSection: React.FC<Props> = (props) => {
|
|
|
}, {})
|
|
|
);
|
|
|
|
|
|
+ const { currentProject, currentCluster } = useContext(Context);
|
|
|
+
|
|
|
+ const saveChanges = () => {
|
|
|
+ let payload = {
|
|
|
+ enabled: notificationsOn,
|
|
|
+ deploy: notificationsOn,
|
|
|
+ ...categories,
|
|
|
+ };
|
|
|
+
|
|
|
+ api
|
|
|
+ .updateNotificationConfig(
|
|
|
+ "<token>",
|
|
|
+ {
|
|
|
+ payload: JSON.stringify(payload),
|
|
|
+ namespace: props.currentChart.namespace,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ project_id: currentProject.id,
|
|
|
+ cluster_id: currentCluster.id,
|
|
|
+ name: props.currentChart.name,
|
|
|
+ }
|
|
|
+ )
|
|
|
+ .then((data) => {
|
|
|
+ console.log(data);
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
return (
|
|
|
<>
|
|
|
<Heading>Notification Settings</Heading>
|
|
|
@@ -55,7 +86,7 @@ const NotificationSettingsSection: React.FC<Props> = (props) => {
|
|
|
</>
|
|
|
)}
|
|
|
<SaveButton
|
|
|
- onClick={() => {}}
|
|
|
+ onClick={() => saveChanges()}
|
|
|
text={"Save Changes"}
|
|
|
clearPosition={true}
|
|
|
statusPosition={"right"}
|