Browse Source

Moved cli button to title

jnfrati 4 years ago
parent
commit
8bd64fcaf0

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

@@ -26,6 +26,8 @@ import { RouteComponentProps, withRouter } from "react-router";
 import Banner from "components/Banner";
 import Banner from "components/Banner";
 import KeyValueArray from "components/form-components/KeyValueArray";
 import KeyValueArray from "components/form-components/KeyValueArray";
 import { onlyInLeft } from "shared/array_utils";
 import { onlyInLeft } from "shared/array_utils";
+import CommandLineIcon from "assets/command-line-icon";
+import ConnectToJobInstructionsModal from "./jobs/ConnectToJobInstructionsModal";
 
 
 type PropsType = WithAuthProps &
 type PropsType = WithAuthProps &
   RouteComponentProps & {
   RouteComponentProps & {
@@ -54,6 +56,7 @@ type StateType = {
   upgradeVersion: string;
   upgradeVersion: string;
   expandedJobRun: any;
   expandedJobRun: any;
   pods: any;
   pods: any;
+  showConnectionModal: boolean;
 };
 };
 
 
 class ExpandedJobChart extends Component<PropsType, StateType> {
 class ExpandedJobChart extends Component<PropsType, StateType> {
@@ -76,6 +79,7 @@ class ExpandedJobChart extends Component<PropsType, StateType> {
 
 
     expandedJobRun: null as any,
     expandedJobRun: null as any,
     pods: null as any,
     pods: null as any,
+    showConnectionModal: false,
   };
   };
 
 
   getPods = (job: any, callback?: () => void) => {
   getPods = (job: any, callback?: () => void) => {
@@ -807,6 +811,12 @@ class ExpandedJobChart extends Component<PropsType, StateType> {
               <TagWrapper>
               <TagWrapper>
                 Namespace <NamespaceTag>{chart.namespace}</NamespaceTag>
                 Namespace <NamespaceTag>{chart.namespace}</NamespaceTag>
               </TagWrapper>
               </TagWrapper>
+              <CLIModalIcon
+                onClick={(e) => {
+                  e.preventDefault();
+                  this.setState({ showConnectionModal: true });
+                }}
+              />
             </TitleSection>
             </TitleSection>
 
 
             <InfoWrapper>
             <InfoWrapper>
@@ -978,6 +988,12 @@ class ExpandedJobChart extends Component<PropsType, StateType> {
           >
           >
             {chart.name}{" "}
             {chart.name}{" "}
             <Gray>at {this.readableDate(run.status.startTime)}</Gray>
             <Gray>at {this.readableDate(run.status.startTime)}</Gray>
+            <CLIModalIcon
+              onClick={(e) => {
+                e.preventDefault();
+                this.setState({ showConnectionModal: true });
+              }}
+            />
           </TitleSection>
           </TitleSection>
 
 
           <InfoWrapper>
           <InfoWrapper>
@@ -1035,6 +1051,12 @@ class ExpandedJobChart extends Component<PropsType, StateType> {
         ) : (
         ) : (
           <>{this.renderExpandedJobRun()}</>
           <>{this.renderExpandedJobRun()}</>
         )}
         )}
+
+        <ConnectToJobInstructionsModal
+          show={this.state.showConnectionModal}
+          onClose={() => this.setState({ showConnectionModal: false })}
+          chart={this.state.currentChart}
+        />
       </>
       </>
     );
     );
   }
   }
@@ -1352,3 +1374,25 @@ const A = styled.a`
   margin-left: 5px;
   margin-left: 5px;
   cursor: pointer;
   cursor: pointer;
 `;
 `;
+
+const CLIModalIcon = styled(CommandLineIcon)`
+  width: 25px;
+  padding: 5px;
+  margin: 0 5px;
+  border: 1px solid #ffffff55;
+  border-radius: 100px;
+  background: #ffffff11;
+  color: white;
+  margin-bottom: -3px;
+  :hover {
+    cursor: pointer;
+    background: #ffffff22;
+    > path {
+      fill: #ffffff77;
+    }
+  }
+
+  > path {
+    fill: #ffffff99;
+  }
+`;

+ 4 - 6
dashboard/src/main/home/cluster-dashboard/expanded-chart/jobs/ConnectToJobInstructionsModal.tsx

@@ -1,12 +1,13 @@
 import Modal from "main/home/modals/Modal";
 import Modal from "main/home/modals/Modal";
 import React from "react";
 import React from "react";
+import { ChartType } from "shared/types";
 import styled from "styled-components";
 import styled from "styled-components";
 
 
 const ConnectToJobInstructionsModal: React.FC<{
 const ConnectToJobInstructionsModal: React.FC<{
   show: boolean;
   show: boolean;
   onClose: () => void;
   onClose: () => void;
-  job: any;
-}> = ({ show, job, onClose }) => {
+  chart: ChartType;
+}> = ({ show, chart, onClose }) => {
   if (!show) {
   if (!show) {
     return null;
     return null;
   }
   }
@@ -28,10 +29,7 @@ const ConnectToJobInstructionsModal: React.FC<{
       <br />
       <br />
       Run the following line of code, and make sure to change the command to
       Run the following line of code, and make sure to change the command to
       something your container can run:
       something your container can run:
-      <Code>
-        porter run {job?.metadata?.labels["meta.helm.sh/release-name"]} --
-        [COMMAND]
-      </Code>
+      <Code>porter run {chart?.name || "[APP-NAME]"} -- [COMMAND]</Code>
       Note that this will create a copy of the most recent job run for this
       Note that this will create a copy of the most recent job run for this
       template.
       template.
     </Modal>
     </Modal>

+ 0 - 24
dashboard/src/main/home/cluster-dashboard/expanded-chart/jobs/JobResource.tsx

@@ -290,12 +290,6 @@ export default class JobResource extends Component<PropsType, StateType> {
               <CommandString>{commandString}</CommandString>
               <CommandString>{commandString}</CommandString>
               {this.renderStatus()}
               {this.renderStatus()}
               <MaterialIconTray disabled={false}>
               <MaterialIconTray disabled={false}>
-                <CLIModalIcon
-                  onClick={(e) => {
-                    e.preventDefault();
-                    this.setState({ showConnectionModal: true });
-                  }}
-                />
                 {this.renderStopButton()}
                 {this.renderStopButton()}
                 {!this.props.readOnly && (
                 {!this.props.readOnly && (
                   <i
                   <i
@@ -319,11 +313,6 @@ export default class JobResource extends Component<PropsType, StateType> {
           </MainRow>
           </MainRow>
           {this.renderLogsSection()}
           {this.renderLogsSection()}
         </StyledJob>
         </StyledJob>
-        <ConnectToJobInstructionsModal
-          show={this.state.showConnectionModal}
-          onClose={() => this.setState({ showConnectionModal: false })}
-          job={this.props.job}
-        />
       </>
       </>
     );
     );
   }
   }
@@ -405,19 +394,6 @@ const Icon = styled.img`
   margin-right: 18px;
   margin-right: 18px;
 `;
 `;
 
 
-const CLIModalIcon = styled(CommandLineIcon)`
-  border-radius: 20px;
-  width: 26px;
-  padding: 5px;
-  margin: 0 5px;
-  :hover {
-    background: #ffffff11;
-  }
-  > path {
-    fill: #ffffff44;
-  }
-`;
-
 const Flex = styled.div`
 const Flex = styled.div`
   display: flex;
   display: flex;
   align-items: center;
   align-items: center;