sunguroku пре 5 година
родитељ
комит
6f038063b3

+ 4 - 4
dashboard/src/components/image-selector/TagList.tsx

@@ -8,7 +8,7 @@ import { Context } from "shared/Context";
 
 import Loading from "../Loading";
 
-var ecrRepoRegex = /(^[a-zA-Z0-9][a-zA-Z0-9-_]*)\.dkr\.ecr(\-fips)?\.([a-zA-Z0-9][a-zA-Z0-9-_]*)\.amazonaws\.com(\.cn)?/igm
+var ecrRepoRegex = /(^[a-zA-Z0-9][a-zA-Z0-9-_]*)\.dkr\.ecr(\-fips)?\.([a-zA-Z0-9][a-zA-Z0-9-_]*)\.amazonaws\.com(\.cn)?/gim;
 
 type PropsType = {
   setSelectedTag: (x: string) => void;
@@ -38,12 +38,12 @@ export default class TagList extends Component<PropsType, StateType> {
     let splits = this.props.selectedImageUrl.split("/");
     let repoName = splits[splits.length - 1];
 
-    let matches = this.props.selectedImageUrl.match(ecrRepoRegex)
+    let matches = this.props.selectedImageUrl.match(ecrRepoRegex);
 
     if (matches) {
-      repoName = this.props.selectedImageUrl.split(/\/(.+)/)[1]
+      repoName = this.props.selectedImageUrl.split(/\/(.+)/)[1];
     }
-  
+
     api
       .getImageTags(
         "<token>",

+ 13 - 8
dashboard/src/main/Main.tsx

@@ -55,13 +55,14 @@ export default class Main extends Component<PropsType, StateType> {
         }
       })
       .catch((err) => this.setState({ isLoggedIn: false, loading: false }));
-    
-    api.getCapabilities("", {}, {})
-    .then((res) => {
-      console.log(res.data)
-      this.setState({local: !res.data?.provisioner})
-    })
-    .catch((err) => console.log(err));
+
+    api
+      .getCapabilities("", {}, {})
+      .then((res) => {
+        console.log(res.data);
+        this.setState({ local: !res.data?.provisioner });
+      })
+      .catch((err) => console.log(err));
   }
 
   initialize = () => {
@@ -109,7 +110,11 @@ export default class Main extends Component<PropsType, StateType> {
     }
 
     // if logged in but not verified, block until email verification
-    if (!this.state.local && this.state.isLoggedIn && !this.state.isEmailVerified) {
+    if (
+      !this.state.local &&
+      this.state.isLoggedIn &&
+      !this.state.isEmailVerified
+    ) {
       return (
         <Switch>
           <Route

+ 12 - 11
dashboard/src/main/auth/Login.tsx

@@ -40,11 +40,12 @@ export default class Login extends Component<PropsType, StateType> {
       : document.addEventListener("keydown", this.handleKeyDown);
 
     // get capabilities to case on github
-    api.getCapabilities("", {}, {})
-    .then((res) => {
-      this.setState({hasGithub: res.data?.github})
-    })
-    .catch((err) => console.log(err));
+    api
+      .getCapabilities("", {}, {})
+      .then((res) => {
+        this.setState({ hasGithub: res.data?.github });
+      })
+      .catch((err) => console.log(err));
   }
 
   componentWillUnmount() {
@@ -119,19 +120,19 @@ export default class Login extends Component<PropsType, StateType> {
       return (
         <>
           <OAuthButton onClick={this.githubRedirect}>
-          <IconWrapper>
-            <Icon src={github} />
-            Log in with GitHub
-          </IconWrapper>
+            <IconWrapper>
+              <Icon src={github} />
+              Log in with GitHub
+            </IconWrapper>
           </OAuthButton>
           <OrWrapper>
             <Line />
             <Or>or</Or>
           </OrWrapper>
         </>
-      )
+      );
     }
-  }
+  };
 
   render() {
     let { email, password, credentialError, emailError } = this.state;

+ 17 - 17
dashboard/src/main/auth/Register.tsx

@@ -38,11 +38,12 @@ export default class Register extends Component<PropsType, StateType> {
     document.addEventListener("keydown", this.handleKeyDown);
 
     // get capabilities to case on github
-    api.getCapabilities("", {}, {})
-    .then((res) => {      
-      this.setState({hasGithub: res.data?.github})
-    })
-    .catch((err) => console.log(err));
+    api
+      .getCapabilities("", {}, {})
+      .then((res) => {
+        this.setState({ hasGithub: res.data?.github });
+      })
+      .catch((err) => console.log(err));
   }
 
   componentWillUnmount() {
@@ -120,20 +121,19 @@ export default class Register extends Component<PropsType, StateType> {
       return (
         <>
           <OAuthButton onClick={this.githubRedirect}>
-              <IconWrapper>
-                <Icon src={github} />
-                Sign up with GitHub
-              </IconWrapper>
-            </OAuthButton>
-            <OrWrapper>
-              <Line />
-              <Or>or</Or>
-            </OrWrapper>
+            <IconWrapper>
+              <Icon src={github} />
+              Sign up with GitHub
+            </IconWrapper>
+          </OAuthButton>
+          <OrWrapper>
+            <Line />
+            <Or>or</Or>
+          </OrWrapper>
         </>
-      )
+      );
     }
-  }
-
+  };
 
   render() {
     let {

+ 4 - 8
dashboard/src/main/home/Home.tsx

@@ -87,18 +87,14 @@ class Home extends Component<PropsType, StateType> {
     if (!currentProject) return;
 
     api
-      .getCapabilities(
-        "<token>",
-        {},
-        {}
-      )
+      .getCapabilities("<token>", {}, {})
       .then((res) => {
-        this.context.setCapabilities(res.data)
+        this.context.setCapabilities(res.data);
       })
       .catch((err) => {
-        console.log(err)
+        console.log(err);
       });
-  }
+  };
 
   getProjects = (id?: number) => {
     let { user, setProjects } = this.context;

+ 8 - 8
dashboard/src/main/home/cluster-dashboard/expanded-chart/status/ControllerTab.tsx

@@ -102,16 +102,16 @@ export default class ControllerTab extends Component<PropsType, StateType> {
       selectors = this.props.selectors;
     }
 
-    this.setState({ selectors }, () =>{
+    this.setState({ selectors }, () => {
       callback();
-    })
-  }
+    });
+  };
 
   componentDidMount() {
     this.getPodSelectors(() => {
       this.updatePods();
-      this.setControllerWebsockets([this.props.controller.kind, "pod"])
-    })
+      this.setControllerWebsockets([this.props.controller.kind, "pod"]);
+    });
   }
 
   componentWillUnmount() {
@@ -132,10 +132,10 @@ export default class ControllerTab extends Component<PropsType, StateType> {
   setupWebsocket = (kind: string) => {
     let { currentCluster, currentProject } = this.context;
     let protocol = process.env.NODE_ENV == "production" ? "wss" : "ws";
-    let connString = `${protocol}://${process.env.API_SERVER}/api/projects/${currentProject.id}/k8s/${kind}/status?cluster_id=${currentCluster.id}`
-    
+    let connString = `${protocol}://${process.env.API_SERVER}/api/projects/${currentProject.id}/k8s/${kind}/status?cluster_id=${currentCluster.id}`;
+
     if (kind == "pod" && this.state.selectors) {
-      connString += `&selectors=${this.state.selectors[0]}`
+      connString += `&selectors=${this.state.selectors[0]}`;
     }
     let ws = new WebSocket(connString);
 

+ 3 - 5
dashboard/src/main/home/dashboard/Dashboard.tsx

@@ -102,12 +102,10 @@ class Dashboard extends Component<PropsType, StateType> {
       { label: "Project Overview", value: "overview" },
       { label: "Create a Cluster", value: "create-cluster" },
       { label: "Provisioner Status", value: "provisioner" },
-    ]
-    
+    ];
+
     if (!capabilities?.provisioner) {
-      tabOptions = [
-        { label: "Project Overview", value: "overview" },
-      ]
+      tabOptions = [{ label: "Project Overview", value: "overview" }];
     }
 
     return (

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

@@ -586,17 +586,19 @@ class LaunchTemplate extends Component<PropsType, StateType> {
     if (this.state.sourceType === "") {
       return (
         <BlockList>
-          {capabilities.github && (<Block
-            onClick={() => {
-              this.setState({ sourceType: "repo" });
-            }}
-          >
-            <BlockIcon src="https://3.bp.blogspot.com/-xhNpNJJyQhk/XIe4GY78RQI/AAAAAAAAItc/ouueFUj2Hqo5dntmnKqEaBJR4KQ4Q2K3ACK4BGAYYCw/s1600/logo%2Bgit%2Bicon.png" />
-            <BlockTitle>Git Repository</BlockTitle>
-            <BlockDescription>
-              Deploy using source from a Git repo.
-            </BlockDescription>
-          </Block>)}
+          {capabilities.github && (
+            <Block
+              onClick={() => {
+                this.setState({ sourceType: "repo" });
+              }}
+            >
+              <BlockIcon src="https://3.bp.blogspot.com/-xhNpNJJyQhk/XIe4GY78RQI/AAAAAAAAItc/ouueFUj2Hqo5dntmnKqEaBJR4KQ4Q2K3ACK4BGAYYCw/s1600/logo%2Bgit%2Bicon.png" />
+              <BlockTitle>Git Repository</BlockTitle>
+              <BlockDescription>
+                Deploy using source from a Git repo.
+              </BlockDescription>
+            </Block>
+          )}
           <Block
             onClick={() => {
               this.setState({ sourceType: "registry" });

+ 2 - 4
dashboard/src/main/home/navbar/Navbar.tsx

@@ -42,11 +42,9 @@ export default class Navbar extends Component<PropsType, StateType> {
 
   renderFeedbackButton = () => {
     if (this.context?.capabilities?.provisioner) {
-      return (
-        <Feedback currentView={this.props.currentView} />
-      )
+      return <Feedback currentView={this.props.currentView} />;
     }
-  }
+  };
 
   render() {
     return (

+ 5 - 1
dashboard/src/main/home/new-project/NewProject.tsx

@@ -59,7 +59,11 @@ export default class NewProject extends Component<PropsType, StateType> {
             width="470px"
           />
         </InputWrapper>
-        <ProvisionerSettings isInNewProject={true} projectName={projectName} provisioner={capabilities?.provisioner} />
+        <ProvisionerSettings
+          isInNewProject={true}
+          projectName={projectName}
+          provisioner={capabilities?.provisioner}
+        />
         <Br />
       </StyledNewProject>
     );

+ 12 - 17
dashboard/src/main/home/provisioner/ProvisionerSettings.tsx

@@ -52,7 +52,6 @@ class NewProject extends Component<PropsType, StateType> {
     }
 
     let renderSkipHelper = () => {
-
       if (!this.props.provisioner) {
         return;
       }
@@ -139,7 +138,9 @@ class NewProject extends Component<PropsType, StateType> {
     let { selectedProvider } = this.state;
     let { isInNewProject } = this.props;
     let { provisioner } = this.props;
-    let helper = provisioner ? "Note: Provisioning can take up to 15 minutes" : ""
+    let helper = provisioner
+      ? "Note: Provisioning can take up to 15 minutes"
+      : "";
 
     if (isInNewProject && !selectedProvider) {
       return (
@@ -161,24 +162,22 @@ class NewProject extends Component<PropsType, StateType> {
             helper={helper}
           />
         </>
-      )
+      );
     }
-  }
+  };
 
   componentDidMount() {
     let { provisioner } = this.props;
 
     if (!provisioner) {
-      this.setState({selectedProvider: "skipped"})
+      this.setState({ selectedProvider: "skipped" });
     }
   }
 
   componentDidUpdate(prevProps: PropsType) {
-    if (
-      prevProps.provisioner !== this.props.provisioner
-    ) {
+    if (prevProps.provisioner !== this.props.provisioner) {
       if (!this.props.provisioner) {
-        this.setState({selectedProvider: "skipped"})
+        this.setState({ selectedProvider: "skipped" });
       }
     }
   }
@@ -194,22 +193,18 @@ class NewProject extends Component<PropsType, StateType> {
         <>
           Select your hosting backend:<Required>*</Required>
         </>
-      )
+      );
     } else {
-      return (
-        "Need a cluster? Provision through Porter:"
-      )
+      return "Need a cluster? Provision through Porter:";
     }
-  }
+  };
 
   render() {
     let { selectedProvider } = this.state;
 
     return (
       <StyledProvisionerSettings>
-        <Helper>
-          {this.renderHelperText()}
-        </Helper>
+        <Helper>{this.renderHelperText()}</Helper>
         {!selectedProvider ? (
           <BlockList>
             {providers.map((provider: string, i: number) => {

+ 1 - 1
dashboard/src/shared/Context.tsx

@@ -65,7 +65,7 @@ class ContextProvider extends Component {
     },
     capabilities: null as CapabilityType,
     setCapabilities: (capabilities: CapabilityType) => {
-      this.setState({ capabilities })
+      this.setState({ capabilities });
     },
     clearContext: () => {
       this.setState({

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

@@ -171,4 +171,4 @@ export interface ActionConfigType {
 export interface CapabilityType {
   github: boolean;
   provisioner: boolean;
-}
+}