Răsfoiți Sursa

Moved CLI modal icon next to run job button

jnfrati 4 ani în urmă
părinte
comite
05bd816cb5

+ 1 - 42
dashboard/src/main/home/cluster-dashboard/expanded-chart/ExpandedJobChart.tsx

@@ -26,8 +26,6 @@ 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 & {
@@ -596,6 +594,7 @@ class ExpandedJobChart extends Component<PropsType, StateType> {
               isAuthorized={this.props.isAuthorized}
               isAuthorized={this.props.isAuthorized}
               saveValuesStatus={this.state.saveValuesStatus}
               saveValuesStatus={this.state.saveValuesStatus}
               expandJob={(job: any) => this.setJobRun(job)}
               expandJob={(job: any) => this.setJobRun(job)}
+              chartName={this.state.currentChart?.name}
             />
             />
           </TabWrapper>
           </TabWrapper>
         );
         );
@@ -811,12 +810,6 @@ 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>
@@ -988,12 +981,6 @@ 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>
@@ -1051,12 +1038,6 @@ class ExpandedJobChart extends Component<PropsType, StateType> {
         ) : (
         ) : (
           <>{this.renderExpandedJobRun()}</>
           <>{this.renderExpandedJobRun()}</>
         )}
         )}
-
-        <ConnectToJobInstructionsModal
-          show={this.state.showConnectionModal}
-          onClose={() => this.setState({ showConnectionModal: false })}
-          chart={this.state.currentChart}
-        />
       </>
       </>
     );
     );
   }
   }
@@ -1374,25 +1355,3 @@ 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;
-  }
-`;

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

@@ -6,8 +6,8 @@ import styled from "styled-components";
 const ConnectToJobInstructionsModal: React.FC<{
 const ConnectToJobInstructionsModal: React.FC<{
   show: boolean;
   show: boolean;
   onClose: () => void;
   onClose: () => void;
-  chart: ChartType;
-}> = ({ show, chart, onClose }) => {
+  chartName: string;
+}> = ({ show, chartName, onClose }) => {
   if (!show) {
   if (!show) {
     return null;
     return null;
   }
   }
@@ -29,7 +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 {chart?.name || "[APP-NAME]"} -- [COMMAND]</Code>
+      <Code>porter run {chartName || "[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>

+ 37 - 0
dashboard/src/main/home/cluster-dashboard/expanded-chart/jobs/TempJobList.tsx

@@ -4,6 +4,8 @@ import styled from "styled-components";
 import { PorterFormContext } from "components/porter-form/PorterFormContextProvider";
 import { PorterFormContext } from "components/porter-form/PorterFormContextProvider";
 import JobList from "./JobList";
 import JobList from "./JobList";
 import SaveButton from "components/SaveButton";
 import SaveButton from "components/SaveButton";
+import CommandLineIcon from "assets/command-line-icon";
+import ConnectToJobInstructionsModal from "./ConnectToJobInstructionsModal";
 
 
 interface Props {
 interface Props {
   isAuthorized: any;
   isAuthorized: any;
@@ -12,6 +14,7 @@ interface Props {
   jobs: any;
   jobs: any;
   handleSaveValues: any;
   handleSaveValues: any;
   expandJob: any;
   expandJob: any;
+  chartName: string;
 }
 }
 
 
 /**
 /**
@@ -20,6 +23,7 @@ interface Props {
  */
  */
 const TempJobList: React.FC<Props> = (props) => {
 const TempJobList: React.FC<Props> = (props) => {
   const { getSubmitValues } = useContext(PorterFormContext);
   const { getSubmitValues } = useContext(PorterFormContext);
+  const [showConnectionModal, setShowConnectionModal] = useState(false);
   const [searchInput, setSearchInput] = useState("");
   const [searchInput, setSearchInput] = useState("");
 
 
   let saveButton = (
   let saveButton = (
@@ -36,6 +40,12 @@ const TempJobList: React.FC<Props> = (props) => {
       >
       >
         <i className="material-icons">play_arrow</i> Run Job
         <i className="material-icons">play_arrow</i> Run Job
       </SaveButton>
       </SaveButton>
+      <CLIModalIcon
+        onClick={(e) => {
+          e.preventDefault();
+          setShowConnectionModal(true);
+        }}
+      />
     </ButtonWrapper>
     </ButtonWrapper>
   );
   );
 
 
@@ -51,6 +61,11 @@ const TempJobList: React.FC<Props> = (props) => {
         setJobs={props.setJobs}
         setJobs={props.setJobs}
         expandJob={props.expandJob}
         expandJob={props.expandJob}
       />
       />
+      <ConnectToJobInstructionsModal
+        show={showConnectionModal}
+        onClose={() => setShowConnectionModal(false)}
+        chartName={props.chartName}
+      />
     </>
     </>
   );
   );
 };
 };
@@ -60,3 +75,25 @@ export default TempJobList;
 const ButtonWrapper = styled.div`
 const ButtonWrapper = styled.div`
   margin: 5px 0 35px;
   margin: 5px 0 35px;
 `;
 `;
+
+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;
+  }
+`;