Ivan Galakhov il y a 4 ans
Parent
commit
5af8b6fdea

+ 13 - 2
dashboard/src/main/home/cluster-dashboard/expanded-chart/ExpandedChart.tsx

@@ -1,11 +1,22 @@
-import React, { useCallback, useContext, useEffect, useMemo, useState } from "react";
+import React, {
+  useCallback,
+  useContext,
+  useEffect,
+  useMemo,
+  useState,
+} from "react";
 import styled from "styled-components";
 import yaml from "js-yaml";
 import backArrow from "assets/back_arrow.png";
 import _ from "lodash";
 import loadingSrc from "assets/loading.gif";
 
-import { ChartType, ClusterType, ResourceType, StorageType } from "shared/types";
+import {
+  ChartType,
+  ClusterType,
+  ResourceType,
+  StorageType,
+} from "shared/types";
 import { Context } from "shared/Context";
 import api from "shared/api";
 import StatusIndicator from "components/StatusIndicator";

+ 4 - 0
dashboard/src/main/home/cluster-dashboard/expanded-chart/NotificationSettingsSection.tsx

@@ -29,6 +29,7 @@ const NotificationSettingsSection: React.FC<Props> = (props) => {
   const [saveLoading, setSaveLoading] = useState(false);
   const [numSaves, setNumSaves] = useState(0);
   const [hasNotifications, setHasNotifications] = useState(null);
+  const [hasRelease, setHasRelease] = useState(false);
 
   const { currentProject, currentCluster } = useContext(Context);
 
@@ -63,6 +64,9 @@ const NotificationSettingsSection: React.FC<Props> = (props) => {
       )
       .then(({ data }) => {
         setHasNotifications(data.length > 0);
+      })
+      .catch((ret) => {
+        console.log(ret);
       });
   }, []);
 

+ 11 - 0
server/api/notifications_handler.go

@@ -4,6 +4,7 @@ import (
 	"encoding/json"
 	"github.com/go-chi/chi"
 	"github.com/porter-dev/porter/internal/models"
+	"gorm.io/gorm"
 	"net/http"
 	"net/url"
 	"strconv"
@@ -34,6 +35,11 @@ func (app *App) HandleUpdateNotificationConfig(w http.ResponseWriter, r *http.Re
 	release, err := app.Repo.Release.ReadRelease(form.ClusterID, name, form.Namespace)
 
 	if err != nil {
+		if err == gorm.ErrRecordNotFound {
+			w.WriteHeader(http.StatusNotFound)
+			return
+		}
+
 		app.sendExternalError(err, http.StatusInternalServerError, HTTPError{
 			Code:   ErrReleaseReadData,
 			Errors: []string{"release not found"},
@@ -98,6 +104,11 @@ func (app *App) HandleGetNotificationConfig(w http.ResponseWriter, r *http.Reque
 	release, err := app.Repo.Release.ReadRelease(uint(clusterID), name, namespace)
 
 	if err != nil {
+		if err == gorm.ErrRecordNotFound {
+			w.WriteHeader(http.StatusNotFound)
+			return
+		}
+
 		app.sendExternalError(err, http.StatusInternalServerError, HTTPError{
 			Code:   ErrReleaseReadData,
 			Errors: []string{"release not found"},