Browse Source

log newjob image + hide settings on porter-hello-job

jusrhee 5 years ago
parent
commit
d9a2a70b16

+ 62 - 4
dashboard/src/main/home/cluster-dashboard/expanded-chart/ExpandedJobChart.tsx

@@ -3,6 +3,7 @@ import styled from "styled-components";
 import yaml from "js-yaml";
 import yaml from "js-yaml";
 import close from "assets/close.png";
 import close from "assets/close.png";
 import _ from "lodash";
 import _ from "lodash";
+import loading from "assets/loading.gif";
 
 
 import { ChartType, StorageType, ClusterType } from "shared/types";
 import { ChartType, StorageType, ClusterType } from "shared/types";
 import { Context } from "shared/Context";
 import { Context } from "shared/Context";
@@ -15,6 +16,7 @@ import TabRegion from "components/TabRegion";
 import JobList from "./jobs/JobList";
 import JobList from "./jobs/JobList";
 import SettingsSection from "./SettingsSection";
 import SettingsSection from "./SettingsSection";
 import FormWrapper from "components/values-form/FormWrapper";
 import FormWrapper from "components/values-form/FormWrapper";
+import { PlaceHolder } from "brace";
 
 
 type PropsType = {
 type PropsType = {
   namespace: string;
   namespace: string;
@@ -26,6 +28,7 @@ type PropsType = {
 
 
 type StateType = {
 type StateType = {
   currentChart: ChartType;
   currentChart: ChartType;
+  imageIsPlaceholder: boolean;
   loading: boolean;
   loading: boolean;
   jobs: any[];
   jobs: any[];
   tabOptions: any[];
   tabOptions: any[];
@@ -42,6 +45,7 @@ type StateType = {
 export default class ExpandedJobChart extends Component<PropsType, StateType> {
 export default class ExpandedJobChart extends Component<PropsType, StateType> {
   state = {
   state = {
     currentChart: this.props.currentChart,
     currentChart: this.props.currentChart,
+    imageIsPlaceholder: false,
     loading: true,
     loading: true,
     jobs: [] as any[],
     jobs: [] as any[],
     tabOptions: [] as any[],
     tabOptions: [] as any[],
@@ -76,9 +80,20 @@ export default class ExpandedJobChart extends Component<PropsType, StateType> {
         }
         }
       )
       )
       .then((res) => {
       .then((res) => {
-        this.setState({ currentChart: res.data, loading: false }, () => {
-          this.updateTabs();
-        });
+        let image = res.data?.config?.image?.repository;
+        if (image === "porterdev/hello-porter-job") {
+          this.setState({ 
+            currentChart: res.data, 
+            loading: false,
+            imageIsPlaceholder: true,
+          }, () => {
+            this.updateTabs();
+          });
+        } else {
+          this.setState({ currentChart: res.data, loading: false }, () => {
+            this.updateTabs();
+          });
+        }
       })
       })
       .catch(console.log);
       .catch(console.log);
   };
   };
@@ -86,6 +101,8 @@ export default class ExpandedJobChart extends Component<PropsType, StateType> {
   refreshChart = () => this.getChartData(this.state.currentChart);
   refreshChart = () => this.getChartData(this.state.currentChart);
 
 
   mergeNewJob = (newJob: any) => {
   mergeNewJob = (newJob: any) => {
+    console.log("newJob", newJob);
+    console.log("image?", newJob.values?.image?.repository);
     let jobs = this.state.jobs;
     let jobs = this.state.jobs;
     let exists = false;
     let exists = false;
     jobs.forEach((job: any, i: number, self: any[]) => {
     jobs.forEach((job: any, i: number, self: any[]) => {
@@ -238,6 +255,18 @@ export default class ExpandedJobChart extends Component<PropsType, StateType> {
   renderTabContents = (currentTab: string) => {
   renderTabContents = (currentTab: string) => {
     switch (currentTab) {
     switch (currentTab) {
       case "jobs":
       case "jobs":
+        if (this.state.imageIsPlaceholder) {
+          return (
+            <Placeholder>
+              <TextWrap>
+                <Header>
+                  <Spinner src={loading} /> This job is currently being deployed
+                </Header>
+                Navigate to the "Actions" tab of your GitHub repo to view live build logs.
+              </TextWrap>
+            </Placeholder>
+          )
+        }
         return (
         return (
           <TabWrapper>
           <TabWrapper>
             <JobList jobs={this.state.jobs} />
             <JobList jobs={this.state.jobs} />
@@ -325,7 +354,6 @@ export default class ExpandedJobChart extends Component<PropsType, StateType> {
   };
   };
 
 
   componentDidMount() {
   componentDidMount() {
-    let { currentCluster, currentProject } = this.context;
     let { currentChart } = this.state;
     let { currentChart } = this.state;
 
 
     window.analytics.track("Opened Chart", {
     window.analytics.track("Opened Chart", {
@@ -412,6 +440,7 @@ export default class ExpandedJobChart extends Component<PropsType, StateType> {
 
 
           <BodyWrapper>
           <BodyWrapper>
             <FormWrapper
             <FormWrapper
+              isReadOnly={this.state.imageIsPlaceholder}
               valuesToOverride={this.state.valuesToOverride}
               valuesToOverride={this.state.valuesToOverride}
               clearValuesToOverride={() =>
               clearValuesToOverride={() =>
                 this.setState({ valuesToOverride: {} })
                 this.setState({ valuesToOverride: {} })
@@ -433,6 +462,35 @@ export default class ExpandedJobChart extends Component<PropsType, StateType> {
 
 
 ExpandedJobChart.contextType = Context;
 ExpandedJobChart.contextType = Context;
 
 
+const TextWrap = styled.div`
+`;
+
+const Header = styled.div`
+  font-weight: 500;
+  color: #aaaabb;
+  font-size: 16px;
+  margin-bottom: 15px;
+`;
+
+const Placeholder = styled.div`
+  height: 100%;
+  padding: 30px;
+  padding-bottom: 70px;
+  font-size: 13px;
+  color: #ffffff44;
+  width: 100%;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+`;
+
+const Spinner = styled.img`
+  width: 15px;
+  height: 15px;
+  margin-right: 12px;
+  margin-bottom: -2px;
+`;
+
 const BodyWrapper = styled.div`
 const BodyWrapper = styled.div`
   width: 100%;
   width: 100%;
   height: 100%;
   height: 100%;

+ 1 - 15
dashboard/src/main/home/cluster-dashboard/expanded-chart/SettingsSection.tsx

@@ -179,20 +179,6 @@ export default class SettingsSection extends Component<PropsType, StateType> {
             Delete {this.props.currentChart.name}
             Delete {this.props.currentChart.name}
           </Button>
           </Button>
         </StyledSettingsSection>
         </StyledSettingsSection>
-        <SaveButton
-          text="Save Settings"
-          onClick={() =>
-            this.redeployWithNewImage(
-              this.state.selectedImageUrl,
-              this.state.selectedTag
-            )
-          }
-          status={this.state.saveValuesStatus}
-          makeFlush={true}
-          disabled={
-            this.state.selectedImageUrl && this.state.selectedTag ? false : true
-          }
-        />
       </Wrapper>
       </Wrapper>
     );
     );
   }
   }
@@ -286,7 +272,7 @@ const Wrapper = styled.div`
 
 
 const StyledSettingsSection = styled.div`
 const StyledSettingsSection = styled.div`
   width: 100%;
   width: 100%;
-  height: calc(100% - 65px);
+  height: calc(100%);
   background: #ffffff11;
   background: #ffffff11;
   padding: 0 35px;
   padding: 0 35px;
   padding-bottom: 50px;
   padding-bottom: 50px;

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

@@ -770,12 +770,6 @@ class LaunchTemplate extends Component<PropsType, StateType> {
 LaunchTemplate.contextType = Context;
 LaunchTemplate.contextType = Context;
 export default withRouter(LaunchTemplate);
 export default withRouter(LaunchTemplate);
 
 
-const Bold = styled.div`
-  font-weight: bold;
-  color: white;
-  margin-right: 5px;
-`;
-
 const CloseButton = styled.div`
 const CloseButton = styled.div`
   position: absolute;
   position: absolute;
   display: block;
   display: block;
@@ -997,12 +991,6 @@ const Polymer = styled.div`
   }
   }
 `;
 `;
 
 
-const Template = styled.div`
-  display: flex;
-  align-items: center;
-  margin-right: 13px;
-`;
-
 const ClusterSection = styled.div`
 const ClusterSection = styled.div`
   display: flex;
   display: flex;
   align-items: center;
   align-items: center;
@@ -1020,22 +1008,6 @@ const ClusterSection = styled.div`
   }
   }
 `;
 `;
 
 
-const Flex = styled.div`
-  display: flex;
-  align-items: center;
-
-  > i {
-    cursor: pointer;
-    font-size 24px;
-    color: #969Fbbaa;
-    padding: 3px;
-    border-radius: 100px;
-    :hover {
-      background: #ffffff11;
-    }
-  }
-`;
-
 const StyledLaunchTemplate = styled.div`
 const StyledLaunchTemplate = styled.div`
   width: 100%;
   width: 100%;
   padding-bottom: 150px;
   padding-bottom: 150px;