Procházet zdrojové kódy

Merge branch 'master' of github.com:porter-dev/porter into hide-revision-selector

Justin Rhee před 2 roky
rodič
revize
e8a9e68253

+ 2 - 1
cli/cmd/stack/apply.go

@@ -186,7 +186,8 @@ func convertToBuild(porterApp *types.PorterApp) Build {
 		bpSlice := strings.Split(porterApp.Buildpacks, ",")
 		buildpacks = make([]*string, len(bpSlice))
 		for i, bp := range bpSlice {
-			buildpacks[i] = &bp
+			temp := bp
+			buildpacks[i] = &temp
 		}
 	}
 

+ 14 - 10
dashboard/src/main/home/app-dashboard/expanded-app/activity-feed/ActivityFeed.tsx

@@ -81,6 +81,8 @@ const ActivityFeed: React.FC<Props> = ({ chart, stackName, appData }) => {
         if (err.response?.status === 404) {
           setHasPorterAgent(false);
         }
+      } finally {
+        setLoading(false);
       }
     };
 
@@ -89,7 +91,8 @@ const ActivityFeed: React.FC<Props> = ({ chart, stackName, appData }) => {
     } else {
       getEvents();
     }
-  }, [currentProject, currentCluster, hasPorterAgent]);
+
+  }, [currentProject, currentCluster, hasPorterAgent, page]);
 
 
   const installAgent = async () => {
@@ -97,20 +100,21 @@ const ActivityFeed: React.FC<Props> = ({ chart, stackName, appData }) => {
     const cluster_id = currentCluster?.id;
 
     setIsPorterAgentInstalling(true);
-
-    api
-      .installPorterAgent("<token>", {}, { project_id, cluster_id })
-      .then()
-      .catch((err) => {
-        setIsPorterAgentInstalling(false);
-        console.log(err);
-      });
+    try {
+      await api.installPorterAgent("<token>", {}, { project_id, cluster_id });
+      window.location.reload();
+    } catch (err) {
+      setIsPorterAgentInstalling(false);
+      console.log(err);
+    }
   };
 
   if (isPorterAgentInstalling) {
     return (
       <Fieldset>
         <Text size={16}>Installing agent...</Text>
+        <Spacer y={0.5} />
+        <Text color="helper">If you are not redirected automatically after a minute, you may need to refresh this page.</Text>
       </Fieldset>
     );
   }
@@ -142,7 +146,7 @@ const ActivityFeed: React.FC<Props> = ({ chart, stackName, appData }) => {
         </Text>
         <Spacer y={0.5} />
         <Text color="helper">
-          In order to use the events tab, you need to install the Porter agent.
+          In order to use the Activity tab, you need to install the Porter agent.
         </Text>
         <Spacer y={1} />
         <Button onClick={() => installAgent()}>

+ 14 - 10
dashboard/src/main/home/app-dashboard/expanded-app/activity-feed/events/utils.ts

@@ -11,25 +11,29 @@ export const getDuration = (event: PorterAppEvent): string => {
     const timeDifferenceMilliseconds = endTimeStamp - startTimeStamp;
 
     const seconds = Math.floor(timeDifferenceMilliseconds / 1000);
-    const hours = Math.floor(seconds / 3600);
-    const minutes = Math.floor((seconds % 3600) / 60);
+    const weeks = Math.floor(seconds / 604800);
+    const remainingDays = Math.floor((seconds % 604800) / 86400);
+    const remainingHours = Math.floor((seconds % 86400) / 3600);
+    const remainingMinutes = Math.floor((seconds % 3600) / 60);
     const remainingSeconds = seconds % 60;
 
-    let formattedTime = "";
+    if (weeks > 0) {
+        return `${weeks}w ${remainingDays}d`;
+    }
 
-    if (hours > 0) {
-        formattedTime += `${hours}h `;
+    if (remainingDays > 0) {
+        return `${remainingDays}d ${remainingHours}h`;
     }
 
-    if (minutes > 0) {
-        formattedTime += `${minutes}m `;
+    if (remainingHours > 0) {
+        return `${remainingHours}h ${remainingMinutes}m`;
     }
 
-    if (hours === 0 && minutes === 0) {
-        formattedTime += `${remainingSeconds}s`;
+    if (remainingMinutes > 0) {
+        return `${remainingMinutes}m ${remainingSeconds}s`;
     }
 
-    return formattedTime.trim();
+    return `${remainingSeconds}s`;
 };
 
 export const getStatusIcon = (status: string) => {