Răsfoiți Sursa

handle no config to show

jusrhee 5 ani în urmă
părinte
comite
f40e66c0b3

+ 2 - 0
dashboard/src/main/home/cluster-dashboard/expanded-chart/ExpandedJobChart.tsx

@@ -362,6 +362,8 @@ export default class ExpandedJobChart extends Component<PropsType, StateType> {
     let { currentChart } = this.state;
     let { currentChart } = this.state;
     let chart = currentChart;
     let chart = currentChart;
 
 
+    console.log(this.state.formData)
+
     return (
     return (
       <>
       <>
         <CloseOverlay onClick={closeChart} />
         <CloseOverlay onClick={closeChart} />

+ 38 - 19
dashboard/src/main/home/cluster-dashboard/expanded-chart/jobs/JobResource.tsx

@@ -96,6 +96,22 @@ export default class JobResource extends Component<PropsType, StateType> {
   };
   };
 
 
   renderConfigSection = () => {
   renderConfigSection = () => {
+    let { job } = this.props;
+    let commandString = job?.spec?.template?.spec?.containers[0]?.command?.join(
+      " "
+    );
+    let envArray = job?.spec?.template?.spec?.containers[0]?.env;
+    let envObject = {} as any;
+    envArray &&
+      envArray.forEach((env: any, i: number) => {
+        envObject[env.name] = env.value;
+      });
+    
+    // Handle no config to show
+    if (!commandString && _.isEmpty(envObject)) {
+      return;
+    }
+
     if (!this.state.configIsExpanded) {
     if (!this.state.configIsExpanded) {
       return (
       return (
         <ExpandConfigBar
         <ExpandConfigBar
@@ -106,17 +122,6 @@ export default class JobResource extends Component<PropsType, StateType> {
         </ExpandConfigBar>
         </ExpandConfigBar>
       );
       );
     } else {
     } else {
-      let { job } = this.props;
-      let commandString = job?.spec?.template?.spec?.containers[0]?.command?.join(
-        " "
-      );
-      let envArray = job?.spec?.template?.spec?.containers[0]?.env;
-      let envObject = {} as any;
-      envArray &&
-        envArray.forEach((env: any, i: number) => {
-          envObject[env.name] = env.value;
-        });
-
       return (
       return (
         <>
         <>
           <ExpandConfigBar
           <ExpandConfigBar
@@ -126,14 +131,23 @@ export default class JobResource extends Component<PropsType, StateType> {
             Hide Job Config
             Hide Job Config
           </ExpandConfigBar>
           </ExpandConfigBar>
           <ConfigSection>
           <ConfigSection>
-            Command: <Command>{commandString}</Command>
+            {
+              commandString ? (
+                <>Command: <Command>{commandString}</Command></>
+              ) : (
+                <DarkMatter size="-18px" />
+              )
+            }
             {!_.isEmpty(envObject) && (
             {!_.isEmpty(envObject) && (
-              <KeyValueArray
-                envLoader={true}
-                values={envObject}
-                label="Environment Variables:"
-                disabled={true}
-              />
+              <>
+                <KeyValueArray
+                  envLoader={true}
+                  values={envObject}
+                  label="Environment Variables:"
+                  disabled={true}
+                />
+                <DarkMatter />
+              </>
             )}
             )}
           </ConfigSection>
           </ConfigSection>
         </>
         </>
@@ -221,6 +235,11 @@ export default class JobResource extends Component<PropsType, StateType> {
 
 
 JobResource.contextType = Context;
 JobResource.contextType = Context;
 
 
+const DarkMatter = styled.div<{ size?: string }>`
+  width: 100%;
+  margin-bottom: ${props => props.size || "-13px"};
+`;
+
 const Command = styled.span`
 const Command = styled.span`
   font-family: monospace;
   font-family: monospace;
   color: #aaaabb;
   color: #aaaabb;
@@ -228,7 +247,7 @@ const Command = styled.span`
 `;
 `;
 
 
 const ConfigSection = styled.div`
 const ConfigSection = styled.div`
-  padding: 30px 30px 20px;
+  padding: 20px 30px;
   font-size: 13px;
   font-size: 13px;
   font-weight: 500;
   font-weight: 500;
 `;
 `;