Ver Fonte

Merge pull request #2095 from porter-dev/belanger/fix-expandable-resource

Add fix for expandable resource button crashing when there's no button
abelanger5 há 4 anos atrás
pai
commit
2919bc1563

+ 10 - 8
dashboard/src/components/ExpandableResource.tsx

@@ -76,14 +76,16 @@ const ExpandableResource: React.FC<Props> = (props) => {
             </Pair>
           );
         })}
-        <StyledSaveButton
-          onClick={onSave}
-          clearPosition={true}
-          text={button.name}
-          helper={button.description}
-          statusPosition={"right"}
-          className="expanded-save-button"
-        />
+        {button && (
+          <StyledSaveButton
+            onClick={onSave}
+            clearPosition={true}
+            text={button.name}
+            helper={button.description}
+            statusPosition={"right"}
+            className="expanded-save-button"
+          />
+        )}
       </ExpandedWrapper>
     </ResourceTab>
   );

+ 4 - 1
dashboard/src/components/porter-form/field-components/ResourceList.tsx

@@ -97,7 +97,10 @@ const ResourceList: React.FC<ResourceListField> = (props) => {
           return (
             <ExpandableResource
               key={i}
-              button={props?.settings?.options["resource-button"]}
+              button={
+                props?.settings?.options &&
+                props?.settings?.options["resource-button"]
+              }
               resource={resource}
               isLast={i === resourceList.length - 1}
               roundAllCorners={true}