فهرست منبع

Merge branch 'staging' of github.com:porter-dev/porter into staging

Stefan McShane 3 سال پیش
والد
کامیت
b29b87dcf4

+ 1 - 1
dashboard/src/components/CredentialsForm.tsx

@@ -138,7 +138,7 @@ const CredentialsForm: React.FC<Props> = ({
         <StyledForm>
           {
             awsCredentials.length > 0 && (
-              <CloseButton width="172px" onClick={() => setShowCreateForm(false)}>
+              <CloseButton onClick={() => setShowCreateForm(false)}>
                 <i className="material-icons">close</i>
               </CloseButton>
             )

+ 9 - 1
dashboard/src/components/ProvisionerSettings.tsx

@@ -115,6 +115,7 @@ const ProvisionerSettings: React.FC<Props> = props => {
       data["cluster"]["clusterId"] = props.clusterId;
     }
 
+    console.log(0);
     try {
       const res = await api.createContract(
         "<token>",
@@ -122,8 +123,12 @@ const ProvisionerSettings: React.FC<Props> = props => {
         { project_id: currentProject.id }
       );
 
+      console.log("res is:", res);
+      console.log("cluster id is:", res.data.contract_revision?.cluster_id);
+
       // Only refresh and set clusters on initial create
       if (!props.clusterId) {
+        console.log(1);
         setShouldRefreshClusters(true);
         api.getClusters(
           "<token>",
@@ -131,9 +136,12 @@ const ProvisionerSettings: React.FC<Props> = props => {
           { id: currentProject.id },
         )
           .then(({ data }) => {
+            console.log(2);
             data.forEach((cluster: ClusterType) => {
-              if (cluster.id === res.data.cluster_id) {
+              console.log("cluster id:", cluster.id)
+              if (cluster.id === res.data.contract_revision?.cluster_id) {
                 // setHasFinishedOnboarding(true);
+                console.log(3);
                 setCurrentCluster(cluster);
                 OFState.actions.goTo("clean_up");
                 pushFiltered(props, "/cluster-dashboard", ["project_id"], {

+ 1 - 1
dashboard/src/main/home/cluster-dashboard/DashboardHeader.tsx

@@ -8,7 +8,7 @@ import TitleSection from "components/TitleSection";
 type PropsType = {
   image?: any;
   title: any;
-  description?: string;
+  description?: any;
   materialIconClass?: string;
   disableLineBreak?: boolean;
   capitalize?: boolean;

+ 66 - 52
dashboard/src/main/home/cluster-dashboard/dashboard/ClusterRevisionSelector.tsx

@@ -33,6 +33,7 @@ const ClusterRevisionSelector: React.FC<Props> = ({
   const [selectedId, setSelectedId] = useState(null);
   const [pendingContract, setPendingContract] = useState(null);
   const [failedContractId, setFailedContractId] = useState("");
+  const [hideSelector, setHideSelector] = useState(false);
 
   const processVersions = (data: any) => {
     setFailedContractId("");
@@ -76,7 +77,12 @@ const ClusterRevisionSelector: React.FC<Props> = ({
         const filtered_data = data.filter((x: any) => {
           return x.cluster_id === currentCluster.id;
         });
-        processVersions(filtered_data);
+        if (filtered_data.length === 0) {
+          setHideSelector(true);
+        } else {
+          setHideSelector(false);
+          processVersions(filtered_data);
+        }
       })
       .catch((err) => {
         console.error(err);
@@ -195,59 +201,67 @@ const deleteContract = () => {
   };
 
   return (
-    <StyledClusterRevisionSelector>
-      <ExpandableSection
-        isInitiallyExpanded={false}
-        color={selectedId <= 0 ? "#ffffff66" : "#f5cb42"}
-        Header={(
-          <>
-            <Label isCurrent={selectedId <= 0}>
-              {
-                selectedId === 0 ? (
-                  "Current version -"
-                ) : (
-                  selectedId === -1 ? (
-                    failedContractId ? (
-                      ""
+    <>
+      {
+        hideSelector ? (
+          <></>
+        ) : (
+          <StyledClusterRevisionSelector>
+            <ExpandableSection
+              isInitiallyExpanded={false}
+              color={selectedId <= 0 ? "#ffffff66" : "#f5cb42"}
+              Header={(
+                <>
+                  <Label isCurrent={selectedId <= 0}>
+                    {
+                      selectedId === 0 ? (
+                        "Current version -"
+                      ) : (
+                        selectedId === -1 ? (
+                          failedContractId ? (
+                            ""
+                          ) : (
+                            "In progress -"
+                          )
+                        ) : (
+                          "Previewing version (not deployed) -"
+                        )
+                      )
+                    }
+                  </Label>
+                  {
+                    selectedId === -1 ? (
+                      failedContractId ? (
+                        <><WarningIcon src={warning} /> Last update failed</>
+                      ) : (
+                        <><Img src={loading} /> Updating</>
+                      )
                     ) : (
-                      "In progress -"
+                      `No. ${versions?.length - selectedId}`
                     )
-                  ) : (
-                    "Previewing version (not deployed) -"
-                  )
-                )
-              }
-            </Label>
-            {
-              selectedId === -1 ? (
-                failedContractId ? (
-                  <><WarningIcon src={warning} /> Last update failed</>
-                ) : (
-                  <><Img src={loading} /> Updating</>
-                )
-              ) : (
-                `No. ${versions?.length - selectedId}`
-              )
-            }
-          </>
-        )}
-        ExpandedSection={(
-          <TableWrapper>
-            <RevisionsTable>
-              <tbody>
-                <Tr disableHover={true}>
-                  <Th>Version no.</Th>
-                  <Th>Created</Th>
-                  {/* <Th>Rollback</Th> */}
-                </Tr>
-                {(pendingContract || failedContractId) && renderActiveAttempt()}
-                {renderVersionList()}
-              </tbody>
-            </RevisionsTable>
-          </TableWrapper>
-        )}
-      />
-    </StyledClusterRevisionSelector>
+                  }
+                </>
+              )}
+              ExpandedSection={(
+                <TableWrapper>
+                  <RevisionsTable>
+                    <tbody>
+                      <Tr disableHover={true}>
+                        <Th>Version no.</Th>
+                        <Th>Created</Th>
+                        {/* <Th>Rollback</Th> */}
+                      </Tr>
+                      {(pendingContract || failedContractId) && renderActiveAttempt()}
+                      {renderVersionList()}
+                    </tbody>
+                  </RevisionsTable>
+                </TableWrapper>
+              )}
+            />
+          </StyledClusterRevisionSelector>
+        )
+      }
+    </>
   );
 };
 

+ 11 - 23
dashboard/src/main/home/cluster-dashboard/dashboard/Dashboard.tsx

@@ -222,28 +222,17 @@ export const Dashboard: React.FunctionComponent = () => {
       <DashboardHeader
         image={settings}
         title={context.currentCluster.name}
-        description={`Cluster settings and status for ${context.currentCluster.name}.`}
+        description={
+          ingressIp ? (
+            <>{renderIngressIp(ingressIp, ingressError)}</>
+          ) : (
+            `Cluster settings and status for ${context.currentCluster.name}.`
+          )
+        }
         disableLineBreak
         capitalize={false}
       />
 
-      {/*
-      <TitleSection>
-        <DashboardIcon>
-          <i className="material-icons">device_hub</i>
-        </DashboardIcon>
-        {context.currentCluster.name}
-      </TitleSection>
-      <InfoSection>
-        <TopRow>
-          <InfoLabel>
-            <i className="material-icons">info</i> Info
-          </InfoLabel>
-        </TopRow>
-        <Description>{renderIngressIp(ingressIp, ingressError)}</Description>
-      </InfoSection>
-      */}
-
       {renderContents()}
     </>
   );
@@ -347,10 +336,9 @@ const InfoLabel = styled.div`
 `;
 
 const InfoSection = styled.div`
-  margin-top: 36px;
-  font-family: "Work Sans", sans-serif;
-  margin-left: 0px;
-  margin-bottom: 30px;
+  margin-top: -20px;
+  font-size: 13px;
+  margin-bottom: 25px;
 `;
 
 const Url = styled.a`
@@ -373,7 +361,7 @@ const Url = styled.a`
 `;
 
 const Bolded = styled.span`
-  color: #8b949f;
+  color: #aaaabb;
   margin-right: 6px;
   white-space: nowrap;
 `;