sunguroku 5 лет назад
Родитель
Сommit
282cf429a2

+ 8 - 6
dashboard/src/components/Selector.tsx

@@ -82,15 +82,17 @@ export default class Selector extends Component<PropsType, StateType> {
   renderAddButton = () => {
     if (this.props.addButton) {
       return (
-        <NewOption onClick={() => {
-          this.context.setCurrentModal('NamespaceModal')
-        }}>
+        <NewOption
+          onClick={() => {
+            this.context.setCurrentModal("NamespaceModal");
+          }}
+        >
           <Plus>+</Plus>
           Add Namespace
         </NewOption>
-      )
+      );
     }
-  }
+  };
 
   renderDropdown = () => {
     if (this.state.expanded) {
@@ -131,7 +133,7 @@ export default class Selector extends Component<PropsType, StateType> {
           ref={this.parentRef}
           onClick={() => {
             this.props.refreshOptions();
-            this.setState({ expanded: !this.state.expanded })
+            this.setState({ expanded: !this.state.expanded });
           }}
           expanded={this.state.expanded}
           width={this.props.width}

+ 5 - 5
dashboard/src/main/home/Home.tsx

@@ -511,12 +511,12 @@ class Home extends Component<PropsType, StateType> {
         )}
         {currentModal === "NamespaceModal" && (
           <Modal
-          onRequestClose={() => setCurrentModal(null, null)}
-          width="600px"
-          height="220px"
+            onRequestClose={() => setCurrentModal(null, null)}
+            width="600px"
+            height="220px"
           >
-          <NamespaceModal />
-        </Modal>
+            <NamespaceModal />
+          </Modal>
         )}
 
         {this.renderSidebar()}

+ 1 - 1
dashboard/src/main/home/launch/expanded-template/LaunchTemplate.tsx

@@ -686,7 +686,7 @@ class LaunchTemplate extends Component<PropsType, StateType> {
   };
 
   render() {
-    console.log("RENDERING")
+    console.log("RENDERING");
     let { name, icon } = this.props.currentTemplate;
     let { currentTemplate } = this.props;
 

+ 3 - 1
dashboard/src/main/home/launch/launch-flow/SettingsPage.tsx

@@ -253,7 +253,9 @@ export default class SettingsPage extends Component<PropsType, StateType> {
             </NamespaceLabel>
             <Selector
               key={"namespace"}
-              refreshOptions={() => {this.updateNamespaces(this.context.currentCluster.id)}}
+              refreshOptions={() => {
+                this.updateNamespaces(this.context.currentCluster.id);
+              }}
               addButton={true}
               activeValue={selectedNamespace}
               setActiveValue={setSelectedNamespace}

+ 23 - 24
dashboard/src/main/home/modals/NamespaceModal.tsx

@@ -11,40 +11,39 @@ import InputRow from "components/values-form/InputRow";
 type PropsType = {};
 
 type StateType = {
-    namespaceName: string;
-    status: string | null; 
+  namespaceName: string;
+  status: string | null;
 };
 
-
 export default class NamespaceModal extends Component<PropsType, StateType> {
   state = {
     namespaceName: "",
     status: null as string | null,
-  }
+  };
 
   createNamespace = () => {
     api
-    .createNamespace(
-      "<token>",
-      {
-        name: this.state.namespaceName,
-      },
-      {
-        id: this.context.currentProject.id,
-        cluster_id: this.context.currentCluster.id,
-      }
-    )
-    .then((res) => {
-      this.setState({ status: "successful" }, () => {
-        setTimeout(() => {     
-          this.context.setCurrentModal(null, null) 
-        }, 1000);
+      .createNamespace(
+        "<token>",
+        {
+          name: this.state.namespaceName,
+        },
+        {
+          id: this.context.currentProject.id,
+          cluster_id: this.context.currentCluster.id,
+        }
+      )
+      .then((res) => {
+        this.setState({ status: "successful" }, () => {
+          setTimeout(() => {
+            this.context.setCurrentModal(null, null);
+          }, 1000);
+        });
+      })
+      .catch((err) => {
+        this.setState({ status: "Could not create" });
       });
-    })
-    .catch((err) => {
-      this.setState({ status: "Could not create" });
-    });
-  }
+  };
 
   render() {
     return (

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

@@ -802,7 +802,7 @@ const createNamespace = baseApi<
   {
     name: string;
   },
-  { id: number; cluster_id: number;  }
+  { id: number; cluster_id: number }
 >("POST", (pathParams) => {
   let { id, cluster_id } = pathParams;
   return `/api/projects/${id}/k8s/namespaces/create?cluster_id=${cluster_id}`;
@@ -813,7 +813,7 @@ const deleteNamespace = baseApi<
     name: string;
     cluster_id: number;
   },
-  { id: number;}
+  { id: number }
 >("DELETE", (pathParams) => {
   let { id } = pathParams;
   return `/api/projects/${id}/k8s/namespaces/delete`;