Просмотр исходного кода

Added param to close chart to given URL

jnfrati 4 лет назад
Родитель
Сommit
4251bc7c53

+ 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}
         />
       );
     });

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

@@ -94,11 +94,16 @@ 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"));
+            }
+
+            pushFiltered(this.props, "/applications", ["project_id"], {
+              cluster: this.context.currentCluster.name,
+              namespace: namespace,
+            });
           }}
           setSidebar={setSidebar}
         />