Pārlūkot izejas kodu

fix edge case with error message not showing properly

Alexander Belanger 4 gadi atpakaļ
vecāks
revīzija
6b8c74fb83

+ 13 - 9
dashboard/src/components/ProvisionerStatus.tsx

@@ -23,6 +23,7 @@ type Props = {
   project_id: number;
   setInfraStatus: (infra: Infrastructure) => void;
   auto_expanded?: boolean;
+  set_max_width?: boolean;
 };
 
 const nameMap: { [key: string]: string } = {
@@ -39,6 +40,7 @@ const ProvisionerStatus: React.FC<Props> = ({
   infras,
   project_id,
   auto_expanded,
+  set_max_width,
   setInfraStatus,
 }) => {
   const renderV1Infra = (infra: Infrastructure) => {
@@ -48,6 +50,7 @@ const ProvisionerStatus: React.FC<Props> = ({
         infra={infra}
         is_expanded={auto_expanded}
         is_collapsible={!auto_expanded}
+        set_max_width={set_max_width}
       />
     );
   };
@@ -66,6 +69,7 @@ const ProvisionerStatus: React.FC<Props> = ({
         infra={infra}
         is_expanded={auto_expanded}
         is_collapsible={!auto_expanded}
+        set_max_width={set_max_width}
         updateInfraStatus={updateInfraStatus}
       />
     );
@@ -90,12 +94,14 @@ type V1InfraObjectProps = {
   infra: Infrastructure;
   is_expanded: boolean;
   is_collapsible: boolean;
+  set_max_width?: boolean;
 };
 
 const V1InfraObject: React.FC<V1InfraObjectProps> = ({
   infra,
   is_expanded,
   is_collapsible,
+  set_max_width,
 }) => {
   const [isExpanded, setIsExpanded] = useState(is_expanded);
 
@@ -124,11 +130,9 @@ const V1InfraObject: React.FC<V1InfraObjectProps> = ({
 
   const renderErrorSection = () => {
     let errors: string[] = [];
-
     if (infra.status == "destroyed" || infra.status == "deleted") {
       errors.push("This infrastructure was destroyed.");
     }
-
     if (errors.length > 0) {
       return (
         <>
@@ -174,7 +178,7 @@ const V1InfraObject: React.FC<V1InfraObjectProps> = ({
   };
 
   return (
-    <StyledInfraObject key={infra.id}>
+    <StyledInfraObject key={infra.id} set_max_width={set_max_width}>
       <InfraHeader
         is_clickable={is_collapsible}
         onClick={() => {
@@ -210,6 +214,7 @@ type V2InfraObjectProps = {
   project_id: number;
   is_expanded: boolean;
   is_collapsible: boolean;
+  set_max_width?: boolean;
   updateInfraStatus: (infra: Infrastructure) => void;
 };
 
@@ -218,6 +223,7 @@ const V2InfraObject: React.FC<V2InfraObjectProps> = ({
   project_id,
   is_expanded,
   is_collapsible,
+  set_max_width,
   updateInfraStatus,
 }) => {
   const [isExpanded, setIsExpanded] = useState(is_expanded);
@@ -341,7 +347,7 @@ const V2InfraObject: React.FC<V2InfraObjectProps> = ({
   };
 
   return (
-    <StyledInfraObject key={infra.id}>
+    <StyledInfraObject key={infra.id} set_max_width={set_max_width}>
       <InfraHeader
         is_clickable={is_collapsible}
         onClick={() => {
@@ -694,10 +700,7 @@ const OperationDetails: React.FunctionComponent<OperationDetailsProps> = ({
   };
 
   const renderErrorSection = () => {
-    if (
-      erroredResources.length > 0 &&
-      infra?.latest_operation?.status == "errored"
-    ) {
+    if (erroredResources.length > 0 && infra?.latest_operation?.errored) {
       return (
         <>
           <Description>
@@ -807,12 +810,13 @@ const StyledProvisionerStatus = styled.div`
   margin-top: 25px;
 `;
 
-const StyledInfraObject = styled.div`
+const StyledInfraObject = styled.div<{ set_max_width?: boolean }>`
   background: #ffffff1a;
   border: 1px solid #aaaabb;
   border-radius: 5px;
   margin-bottom: 10px;
   position: relative;
+  width: ${(props) => (props.set_max_width ? "580px" : "100%")};
 `;
 
 const InfraHeader = styled.div<{ is_clickable: boolean }>`

+ 2 - 0
dashboard/src/main/home/onboarding/steps/ProvisionResources/ProvisionResources.tsx

@@ -166,6 +166,8 @@ const ProvisionResources: React.FC<Props> = () => {
               setInfraStatus={setInfraStatus}
               filterLatest
               auto_expanded
+              sortBy="id"
+              set_max_width={true}
             />
             <Br />
             <Helper>Note: Provisioning can take up to 15 minutes.</Helper>

+ 11 - 0
dashboard/src/main/home/onboarding/steps/ProvisionResources/forms/StatusPage.tsx

@@ -17,6 +17,8 @@ type Props = {
   notFoundText?: string;
   filterLatest?: boolean;
   retry_count?: number;
+  sortBy?: string; // if empty, sorts by last updated. options are "last_updated" or "id"
+  set_max_width?: boolean;
 };
 
 export const StatusPage = ({
@@ -27,6 +29,8 @@ export const StatusPage = ({
   filterLatest,
   auto_expanded,
   retry_count,
+  sortBy,
+  set_max_width,
 }: Props) => {
   const isMounted = useRef(false);
   const [isLoading, setIsLoading] = useState(true);
@@ -136,6 +140,12 @@ export const StatusPage = ({
       .then(({ data }) => {
         const matchedInfras = data.filter(filterBySelectedInfras);
 
+        if (sortBy == "id") {
+          matchedInfras.sort((a, b) => {
+            return b.id < a.id ? -1 : b.id > a.id ? 1 : 0;
+          });
+        }
+
         if (filterLatest) {
           // Get latest infras for each kind of infra on the array.
           const latestMatchedInfras = getLatestInfras(matchedInfras);
@@ -169,6 +179,7 @@ export const StatusPage = ({
       project_id={project_id}
       auto_expanded={auto_expanded}
       setInfraStatus={updateSingleInfraStatus}
+      set_max_width={set_max_width}
     />
   );
 };

+ 0 - 7
provisioner/server/grpc/store_log.go

@@ -33,13 +33,6 @@ func (s *ProvisionerServer) StoreLog(stream pb.Provisioner_StoreLogServer) error
 		tfLog, err := stream.Recv()
 
 		if err == io.EOF {
-			// push to the operation stream
-			err = redis_stream.SendOperationCompleted(s.config.RedisClient, infra, operation)
-
-			if err != nil {
-				return err
-			}
-
 			// push to the global stream
 			err := redis_stream.PushToGlobalStream(s.config.RedisClient, infra, operation, "created")
 

+ 9 - 0
provisioner/server/handlers/state/create_resource.go

@@ -15,6 +15,7 @@ import (
 	"github.com/porter-dev/porter/internal/kubernetes"
 	"github.com/porter-dev/porter/internal/kubernetes/envgroup"
 	"github.com/porter-dev/porter/internal/models"
+	"github.com/porter-dev/porter/provisioner/integrations/redis_stream"
 	"github.com/porter-dev/porter/provisioner/server/config"
 	ptypes "github.com/porter-dev/porter/provisioner/types"
 )
@@ -54,6 +55,14 @@ func (c *CreateResourceHandler) ServeHTTP(w http.ResponseWriter, r *http.Request
 		return
 	}
 
+	// push to the operation stream
+	err = redis_stream.SendOperationCompleted(c.Config.RedisClient, infra, operation)
+
+	if err != nil {
+		apierrors.HandleAPIError(c.Config.Logger, c.Config.Alerter, w, r, apierrors.NewErrInternal(err), true)
+		return
+	}
+
 	// update the infra to indicate completion
 	infra.Status = "created"
 

+ 9 - 0
provisioner/server/handlers/state/delete_resource.go

@@ -7,6 +7,7 @@ import (
 	"github.com/porter-dev/porter/api/server/shared/apierrors"
 	"github.com/porter-dev/porter/api/types"
 	"github.com/porter-dev/porter/internal/models"
+	"github.com/porter-dev/porter/provisioner/integrations/redis_stream"
 	"github.com/porter-dev/porter/provisioner/server/config"
 )
 
@@ -39,6 +40,14 @@ func (c *DeleteResourceHandler) ServeHTTP(w http.ResponseWriter, r *http.Request
 		return
 	}
 
+	// push to the operation stream
+	err = redis_stream.SendOperationCompleted(c.Config.RedisClient, infra, operation)
+
+	if err != nil {
+		apierrors.HandleAPIError(c.Config.Logger, c.Config.Alerter, w, r, apierrors.NewErrInternal(err), true)
+		return
+	}
+
 	// update the infra to indicate deletion
 	infra.Status = "deleted"
 

+ 9 - 0
provisioner/server/handlers/state/report_error.go

@@ -8,6 +8,7 @@ import (
 	"github.com/porter-dev/porter/api/server/shared/apierrors"
 	"github.com/porter-dev/porter/api/types"
 	"github.com/porter-dev/porter/internal/models"
+	"github.com/porter-dev/porter/provisioner/integrations/redis_stream"
 	"github.com/porter-dev/porter/provisioner/server/config"
 	ptypes "github.com/porter-dev/porter/provisioner/types"
 )
@@ -59,6 +60,14 @@ func (c *ReportErrorHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
 		return
 	}
 
+	// push to the operation stream
+	err = redis_stream.SendOperationCompleted(c.Config.RedisClient, infra, operation)
+
+	if err != nil {
+		apierrors.HandleAPIError(c.Config.Logger, c.Config.Alerter, w, r, apierrors.NewErrInternal(err), true)
+		return
+	}
+
 	// report the error to the error alerter but don't send to client
 	apierrors.HandleAPIError(c.Config.Logger, c.Config.Alerter, w, r, apierrors.NewErrInternal(
 		fmt.Errorf(req.Error),