Sfoglia il codice sorgente

Merge branch 'nafees/preview-apps-initial-cli' of https://github.com/porter-dev/porter into nafees/preview-apps-initial-cli

Alexander Belanger 4 anni fa
parent
commit
8013273cd1

+ 5 - 1
dashboard/src/main/home/cluster-dashboard/chart/Chart.tsx

@@ -18,6 +18,7 @@ type Props = {
   controllers: Record<string, any>;
   jobStatus: JobStatusWithTimeType;
   isJob: boolean;
+  closeChartRedirectUrl?: string;
 };
 
 const Chart: React.FunctionComponent<Props> = ({
@@ -25,6 +26,7 @@ const Chart: React.FunctionComponent<Props> = ({
   controllers,
   jobStatus,
   isJob,
+  closeChartRedirectUrl,
 }) => {
   const [expand, setExpand] = useState<boolean>(false);
   const [chartControllers, setChartControllers] = useState<any>([]);
@@ -100,7 +102,9 @@ const Chart: React.FunctionComponent<Props> = ({
         let route = `${isJob ? "/jobs" : "/applications"}/${cluster}/${
           chart.namespace
         }/${chart.name}`;
-        pushFiltered({ location, history }, route, ["project_id"]);
+        pushFiltered({ location, history }, route, ["project_id"], {
+          closeChartRedirectUrl,
+        });
       }}
     >
       <Title>

+ 3 - 0
dashboard/src/main/home/cluster-dashboard/chart/ChartList.tsx

@@ -25,6 +25,7 @@ type Props = {
   sortType: string;
   currentView: PorterUrl;
   disableBottomPadding?: boolean;
+  closeChartRedirectUrl?: string;
 };
 
 interface JobStatusWithTimeAndVersion extends JobStatusWithTimeType {
@@ -37,6 +38,7 @@ const ChartList: React.FunctionComponent<Props> = ({
   sortType,
   currentView,
   disableBottomPadding,
+  closeChartRedirectUrl,
 }) => {
   const {
     newWebsocket,
@@ -390,6 +392,7 @@ const ChartList: React.FunctionComponent<Props> = ({
             null
           )}
           isJob={currentView === "jobs"}
+          closeChartRedirectUrl={closeChartRedirectUrl}
         />
       );
     });

+ 1 - 0
dashboard/src/main/home/cluster-dashboard/dashboard/preview-environments/EnvironmentDetail.tsx

@@ -127,6 +127,7 @@ const EnvironmentDetail = () => {
           sortType="Newest"
           namespace={params.namespace}
           disableBottomPadding
+          closeChartRedirectUrl={`${window.location.pathname}${window.location.search}`}
         />
       </ChartListWrapper>
     </StyledExpandedChart>

+ 11 - 5
dashboard/src/main/home/cluster-dashboard/expanded-chart/ExpandedChartWrapper.tsx

@@ -94,11 +94,17 @@ class ExpandedChartWrapper extends Component<PropsType, StateType> {
           currentChart={currentChart}
           currentCluster={this.context.currentCluster}
           closeChart={() => {
-            // pushFiltered(this.props, "/applications", ["project_id"], {
-            //   cluster: this.context.currentCluster.name,
-            //   namespace: namespace,
-            // })
-            this.props.history.goBack();
+            let urlParams = new URLSearchParams(window.location.search);
+
+            if (urlParams.get("closeChartRedirectUrl")) {
+              this.props.history.push(urlParams.get("closeChartRedirectUrl"));
+              return;
+            }
+
+            pushFiltered(this.props, "/applications", ["project_id"], {
+              cluster: this.context.currentCluster.name,
+              namespace: namespace,
+            });
           }}
           setSidebar={setSidebar}
         />