Selaa lähdekoodia

run formatter on files (#4126)

d-g-town 2 vuotta sitten
vanhempi
sitoutus
0d40084cb6

+ 27 - 20
dashboard/src/main/home/modals/UpdateClusterModal.tsx

@@ -1,18 +1,18 @@
 import React, { Component } from "react";
+import { withRouter, type RouteComponentProps } from "react-router";
 import styled from "styled-components";
-import close from "assets/close.png";
+
+import ConfirmOverlay from "components/ConfirmOverlay";
+import InputRow from "components/form-components/InputRow";
+import SaveButton from "components/SaveButton";
+import { OFState } from "main/home/onboarding/state";
 
 import api from "shared/api";
 import { Context } from "shared/Context";
 import { pushFiltered } from "shared/routing";
-import { OFState } from "main/home/onboarding/state";
-import { Onboarding as OnboardingSaveType } from "../onboarding/types"
-
+import close from "assets/close.png";
 
-import SaveButton from "components/SaveButton";
-import InputRow from "components/form-components/InputRow";
-import ConfirmOverlay from "components/ConfirmOverlay";
-import { RouteComponentProps, withRouter } from "react-router";
+import { Onboarding as OnboardingSaveType } from "../onboarding/types";
 
 type PropsType = RouteComponentProps & {
   setRefreshClusters: (x: boolean) => void;
@@ -37,7 +37,7 @@ class UpdateClusterModal extends Component<PropsType, StateType> {
   };
 
   handleDelete = async () => {
-    let { currentProject, currentCluster, setCurrentCluster } = this.context;
+    const { currentProject, currentCluster, setCurrentCluster } = this.context;
     this.setState({ status: "loading" });
 
     await api.updateOnboardingStep(
@@ -65,7 +65,6 @@ class UpdateClusterModal extends Component<PropsType, StateType> {
             tab: "overview",
           });
 
-
           // Handle destroying infra we've provisioned
           api
             .destroyInfra(
@@ -76,9 +75,12 @@ class UpdateClusterModal extends Component<PropsType, StateType> {
                 infra_id: currentCluster.infra_id,
               }
             )
-            .then(() =>
-              console.log("destroyed provisioned infra:", currentCluster.infra_id)
-            )
+            .then(() => {
+              console.log(
+                "destroyed provisioned infra:",
+                currentCluster.infra_id
+              );
+            })
             .catch(console.log);
 
           if (currentProject.simplified_view_enabled) {
@@ -86,9 +88,9 @@ class UpdateClusterModal extends Component<PropsType, StateType> {
               .getClusters("<token>", {}, { id: currentProject?.id })
               .then(async (res) => {
                 if (res.data) {
-                  let clusters = res.data;
+                  const clusters = res.data;
                   if (clusters.length == 0 || !currentProject.multi_cluster) {
-                    setCurrentCluster(null)
+                    setCurrentCluster(null);
                     await api.saveOnboardingState(
                       "<token>",
                       { current_step: "connect_source" },
@@ -96,9 +98,8 @@ class UpdateClusterModal extends Component<PropsType, StateType> {
                     );
                     window.location.reload();
                   }
-
                 }
-              })
+              });
           }
           return;
         }
@@ -141,7 +142,9 @@ class UpdateClusterModal extends Component<PropsType, StateType> {
             disabled={true}
             type="string"
             value={this.state.clusterName}
-            setValue={(x: string) => this.setState({ clusterName: x })}
+            setValue={(x: string) => {
+              this.setState({ clusterName: x });
+            }}
             placeholder="ex: perspective-vortex"
             width="490px"
           />
@@ -159,7 +162,9 @@ class UpdateClusterModal extends Component<PropsType, StateType> {
         <SaveButton
           text="Delete cluster"
           color="#b91133"
-          onClick={() => this.setState({ showDeleteOverlay: true })}
+          onClick={() => {
+            this.setState({ showDeleteOverlay: true });
+          }}
           status={this.state.status}
         />
 
@@ -167,7 +172,9 @@ class UpdateClusterModal extends Component<PropsType, StateType> {
           show={this.state.showDeleteOverlay}
           message={`Are you sure you want to delete this cluster?`}
           onYes={this.handleDelete}
-          onNo={() => this.setState({ showDeleteOverlay: false })}
+          onNo={() => {
+            this.setState({ showDeleteOverlay: false });
+          }}
         />
       </>
     );

+ 41 - 34
dashboard/src/shared/Context.tsx

@@ -1,15 +1,15 @@
 import React, { Component } from "react";
 
+import { pushQueryParams } from "shared/routing";
 import {
-  CapabilityType,
-  ClusterType,
-  ContextProps,
-  ProjectListType,
-  ProjectType,
-  UsageData,
+  type CapabilityType,
+  type ClusterType,
+  type ContextProps,
+  type ProjectListType,
+  type ProjectType,
+  type UsageData,
 } from "shared/types";
 
-import { pushQueryParams } from "shared/routing";
 import api from "./api";
 
 const Context = React.createContext<Partial<ContextProps>>(null);
@@ -24,7 +24,7 @@ type PropsType = {
 
 type StateType = GlobalContextType;
 
-export interface GlobalContextType {
+export type GlobalContextType = {
   currentModal: string;
   currentModalData: any;
   setCurrentModal: (currentModal: string, currentModalData?: any) => void;
@@ -71,7 +71,7 @@ export interface GlobalContextType {
   setFeaturePreview: (featurePreview: boolean) => void;
   soc2Data: any;
   setSoc2Data: (x: any) => void;
-}
+};
 
 /**
  * Component managing a universal (application-wide) data store.
@@ -92,7 +92,9 @@ class ContextProvider extends Component<PropsType, StateType> {
       this.setState({ currentModal, currentModalData });
     },
     currentOverlay: null,
-    setCurrentOverlay: (x: any) => this.setState({ currentOverlay: x }),
+    setCurrentOverlay: (x: any) => {
+      this.setState({ currentOverlay: x });
+    },
     currentError: null,
     setCurrentError: (currentError: string) => {
       this.setState({ currentError });
@@ -112,7 +114,7 @@ class ContextProvider extends Component<PropsType, StateType> {
         JSON.stringify(currentCluster)
       );
       this.setState({ currentCluster }, () => {
-        callback && callback();
+        callback?.();
       });
       if (window.intercomSettings) {
         window.intercomSettings["Cluster ID"] = currentCluster.id;
@@ -129,7 +131,7 @@ class ContextProvider extends Component<PropsType, StateType> {
         localStorage.removeItem("currentProject");
       }
       this.setState({ currentProject }, () => {
-        callback && callback();
+        callback?.();
       });
       if (window.intercomSettings) {
         window.intercomSettings["Project ID"] = currentProject.id;
@@ -223,39 +225,44 @@ class ContextProvider extends Component<PropsType, StateType> {
       this.setState({ featurePreview });
     },
     soc2Data: {
-      "preflight_checks": {
+      preflight_checks: {
         "Public SSH Access": {
-          "message": "Porter-provisioned instances do not allow remote SSH access. Users are not allowed to invoke commands directly on the host, and all commands are invoked via the EKS Control Plane.",
-          "enabled": true,
-          "hideToggle": true,
-          "status": "ENABLED"
+          message:
+            "Porter-provisioned instances do not allow remote SSH access. Users are not allowed to invoke commands directly on the host, and all commands are invoked via the EKS Control Plane.",
+          enabled: true,
+          hideToggle: true,
+          status: "ENABLED",
         },
         "Cluster Secret Encryption": {
-          "message": "Cluster secrets can be encrypted using an AWS KMS Key. Secrets will be encrypted at rest, and encryption cannot be disabled for secrets.",
-          "enabled": false,
-          "disabledTooltip": "Enable KMS encryption for the cluster to enable SOC 2 compliance.",
-          "link": "https://aws.amazon.com/about-aws/whats-new/2020/03/amazon-eks-adds-envelope-encryption-for-secrets-with-aws-kms/",
-          "locked": true,
-          "status": "",
+          message:
+            "Cluster secrets can be encrypted using an AWS KMS Key. Secrets will be encrypted at rest, and encryption cannot be disabled for secrets.",
+          enabled: false,
+          disabledTooltip:
+            "Enable KMS encryption for the cluster to enable SOC 2 compliance.",
+          link: "https://aws.amazon.com/about-aws/whats-new/2020/03/amazon-eks-adds-envelope-encryption-for-secrets-with-aws-kms/",
+          locked: true,
+          status: "",
         },
         "Control Plane Log Retention": {
-          "message": "EKS Control Plane logs are by default available for a minimal amount of time, typically 1 hour or less. EKS CloudTrail Forwarding automatically sends control plane logs to CloudTrail for longer retention and later inspection.",
-          "enabled": false,
-          "enabledField": "Retain CloudTrail logs for 365 days",
-          "status": "",
+          message:
+            "EKS Control Plane logs are by default available for a minimal amount of time, typically 1 hour or less. EKS CloudTrail Forwarding automatically sends control plane logs to CloudTrail for longer retention and later inspection.",
+          enabled: false,
+          enabledField: "Retain CloudTrail logs for 365 days",
+          status: "",
         },
         "Enhanced Image Vulnerability Scanning": {
-          "message": "AWS ECR scans for CVEs from the open-source Clair database on push image push. Enhanced scanning provides continuous, automated scans against images as new vulnerabilities appear.",
-          "link": "https://docs.aws.amazon.com/AmazonECR/latest/userguide/image-scanning-enhanced.html",
-          "enabled": false,
-          "info": "",
-          "status": ""
+          message:
+            "AWS ECR scans for CVEs from the open-source Clair database on push image push. Enhanced scanning provides continuous, automated scans against images as new vulnerabilities appear.",
+          link: "https://docs.aws.amazon.com/AmazonECR/latest/userguide/image-scanning-enhanced.html",
+          enabled: false,
+          info: "",
+          status: "",
         },
-      }
+      },
     },
     setSoc2Data: (soc2Data) => {
       localStorage.setItem("soc2Data", JSON.stringify(soc2Data));
-    }
+    },
   };
 
   render() {

+ 8 - 8
dashboard/src/shared/types.tsx

@@ -14,7 +14,7 @@ export type ClusterType = {
   status?: string;
   cloud_provider: string;
   gpuCluster?: boolean;
-}
+};
 
 export type AddonCard = {
   id: string;
@@ -34,7 +34,7 @@ export type DetailedIngressError = {
 };
 export type Annotations = {
   category: string;
-}
+};
 
 export type ChartType = {
   stack_id: string;
@@ -251,15 +251,15 @@ export type FormElement = {
 export type RepoType = {
   FullName: string;
 } & (
-    | {
+  | {
       Kind: "github";
       GHRepoID: number;
     }
-    | {
+  | {
       Kind: "gitlab";
       GitIntegrationId: number;
     }
-  );
+);
 
 export type FileType = {
   path: string;
@@ -335,15 +335,15 @@ export type ActionConfigType = {
   image_repo_uri: string;
   dockerfile_path?: string;
 } & (
-    | {
+  | {
       kind: "gitlab";
       gitlab_integration_id: number;
     }
-    | {
+  | {
       kind: "github";
       git_repo_id: number;
     }
-  );
+);
 
 export type GithubActionConfigType = ActionConfigType & {
   kind: "github";