jusrhee 5 سال پیش
والد
کامیت
6271bd601b

+ 43 - 4
dashboard/src/main/home/cluster-dashboard/expanded-chart/ExpandedChart.tsx

@@ -19,6 +19,7 @@ import ValuesWrapper from '../../../../components/values-form/ValuesWrapper';
 import ValuesForm from '../../../../components/values-form/ValuesForm';
 import SettingsSection from './SettingsSection';
 import ConfirmOverlay from '../../../../components/ConfirmOverlay';
+import Loading from '../../../../components/Loading';
 
 type PropsType = {
   namespace: string,
@@ -45,6 +46,7 @@ type StateType = {
   websockets: Record<string, any>,
   url: string | null,
   showDeleteOverlay: boolean,
+  deleting: boolean,
 };
 
 export default class ExpandedChart extends Component<PropsType, StateType> {
@@ -64,6 +66,7 @@ export default class ExpandedChart extends Component<PropsType, StateType> {
     websockets : {} as Record<string, any>,
     url: null as string | null,
     showDeleteOverlay: false,
+    deleting: false,
   }
 
   // Retrieve full chart data (includes form and values)
@@ -526,12 +529,11 @@ export default class ExpandedChart extends Component<PropsType, StateType> {
   handleUninstallChart = () => {
     let { currentProject, currentCluster } = this.context;
     let { currentChart } = this.props;
-    console.log('here', currentChart.namespace, StorageType.Secret)
+    this.setState({ deleting: true });
     api.uninstallTemplate('<token>', {
+    }, {
       namespace: currentChart.namespace,
-      cluster_id: currentCluster.id,
       storage: StorageType.Secret,
-    }, {
       name: currentChart.name,
       id: currentProject.id,
       cluster_id: currentCluster.id,
@@ -539,11 +541,18 @@ export default class ExpandedChart extends Component<PropsType, StateType> {
       if (err) {
         console.log(err)
       } else {
-        console.log('worked i guess');
+        this.setState({ showDeleteOverlay: false });
+        this.props.setCurrentChart(null);
       }
     });
   }
 
+  renderDeleteOverlay = () => {
+    if (this.state.deleting) {
+      return <DeleteOverlay><Loading /></DeleteOverlay>;
+    }
+  }
+
   render() {
     let { currentChart, setCurrentChart } = this.props;
     let chart = currentChart;
@@ -559,6 +568,8 @@ export default class ExpandedChart extends Component<PropsType, StateType> {
             onYes={this.handleUninstallChart}
             onNo={() => this.setState({ showDeleteOverlay: false })}
           />
+          {this.renderDeleteOverlay()}
+          
           <HeaderWrapper>
             <TitleSection>
               <Title>
@@ -619,6 +630,34 @@ export default class ExpandedChart extends Component<PropsType, StateType> {
 
 ExpandedChart.contextType = Context;
 
+const DeleteOverlay = styled.div`
+  position: absolute;
+  top: 0px;
+  opacity: 100%;
+  left: 0px;
+  width: 100%;
+  height: 100%;
+  z-index: 999;
+  display: flex;
+  padding-bottom: 30px;
+  align-items: center;
+  justify-content: center;
+  font-family: 'Work Sans', sans-serif;
+  font-size: 18px;
+  font-weight: 500;
+  color: white;
+  flex-direction: column;
+  background: rgb(0,0,0,0.73);
+  opacity: 0;
+  animation: lindEnter 0.2s;
+  animation-fill-mode: forwards;
+
+  @keyframes lindEnter {
+    from { opacity: 0; }
+    to   { opacity: 1; }
+  }
+`;
+
 const Bolded = styled.div`
   font-weight: 500;
   color: #ffffff44;

+ 4 - 4
dashboard/src/shared/api.tsx

@@ -191,15 +191,15 @@ const deployTemplate = baseApi<{
 });
 
 const uninstallTemplate = baseApi<{
-  namespace: string,
-  cluster_id: number,
-  storage: StorageType,
 }, {
   id: number,
   name: string, 
   cluster_id: number,
+  namespace: string,
+  storage: StorageType,
 }>('POST', pathParams => {
-  return `/api/projects/${pathParams.id}/deploy/${pathParams.name}?cluster_id=${pathParams.cluster_id}`;
+  let { id, name, cluster_id, storage, namespace } = pathParams;
+  return `/api/projects/${id}/deploy/${name}?cluster_id=${cluster_id}&namespace=${namespace}&storage=${storage}`;
 });
 
 const getClusterIntegrations = baseApi('GET', '/api/integrations/cluster');

+ 5 - 1
internal/forms/release.go

@@ -1,6 +1,7 @@
 package forms
 
 import (
+	"fmt"
 	"net/url"
 	"strconv"
 
@@ -19,6 +20,7 @@ func (rf *ReleaseForm) PopulateHelmOptionsFromQueryParams(
 	vals url.Values,
 	repo repository.ClusterRepository,
 ) error {
+	fmt.Println(vals)
 	if clusterID, ok := vals["cluster_id"]; ok && len(clusterID) == 1 {
 		id, err := strconv.ParseUint(clusterID[0], 10, 64)
 
@@ -31,15 +33,17 @@ func (rf *ReleaseForm) PopulateHelmOptionsFromQueryParams(
 		if err != nil {
 			return err
 		}
-
+		fmt.Println("setting cluster")
 		rf.Cluster = cluster
 	}
 
 	if namespace, ok := vals["namespace"]; ok && len(namespace) == 1 {
+		fmt.Println("setting namespace")
 		rf.Namespace = namespace[0]
 	}
 
 	if storage, ok := vals["storage"]; ok && len(storage) == 1 {
+		fmt.Println("setting storage")
 		rf.Storage = storage[0]
 	}
 

+ 2 - 5
server/api/deploy_handler.go

@@ -2,7 +2,6 @@ package api
 
 import (
 	"encoding/json"
-	"fmt"
 	"math/rand"
 	"net/http"
 	"net/url"
@@ -126,7 +125,6 @@ func (app *App) HandleDeployTemplate(w http.ResponseWriter, r *http.Request) {
 // HandleUninstallTemplate triggers a chart deployment from a template
 func (app *App) HandleUninstallTemplate(w http.ResponseWriter, r *http.Request) {
 	name := chi.URLParam(r, "name")
-	fmt.Println(name)
 
 	form := &forms.GetReleaseForm{
 		ReleaseForm: &forms.ReleaseForm{
@@ -135,7 +133,7 @@ func (app *App) HandleUninstallTemplate(w http.ResponseWriter, r *http.Request)
 			},
 		},
 		Name:     name,
-		Revision: int(0),
+		Revision: 0,
 	}
 
 	agent, err := app.getAgentFromQueryParams(
@@ -147,13 +145,12 @@ func (app *App) HandleUninstallTemplate(w http.ResponseWriter, r *http.Request)
 
 	// errors are handled in app.getAgentFromQueryParams
 	if err != nil {
-		fmt.Println("asdf")
 		return
 	}
 
 	_, err = agent.UninstallChart(name)
 	if err != nil {
-		fmt.Println("gg")
+		return
 	}
 
 	w.WriteHeader(http.StatusOK)