From e92d6a8b9daf0496605e939643ad497e42b802c4 Mon Sep 17 00:00:00 2001 From: Amit Amrutiya Date: Tue, 12 Nov 2024 12:02:55 +0530 Subject: [PATCH] feat: add 'Open in Playground' action button conditionally Signed-off-by: Amit Amrutiya --- src/custom/CatalogDetail/ActionButton.tsx | 43 ++++++++++++---------- src/custom/CatalogDetail/LeftPanel.tsx | 3 ++ src/custom/CustomTooltip/customTooltip.tsx | 2 +- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/src/custom/CatalogDetail/ActionButton.tsx b/src/custom/CatalogDetail/ActionButton.tsx index 41154b03..5e9b6350 100644 --- a/src/custom/CatalogDetail/ActionButton.tsx +++ b/src/custom/CatalogDetail/ActionButton.tsx @@ -17,6 +17,7 @@ interface ActionButtonsProps { handleUnpublish: () => void; isCloneDisabled: boolean; showUnpublishAction: boolean; + showOpenPlaygroundAction: boolean; onOpenPlaygroundClick: (designId: string, name: string) => void; } @@ -29,6 +30,7 @@ const ActionButtons: React.FC = ({ isCloneDisabled, showUnpublishAction, handleUnpublish, + showOpenPlaygroundAction, onOpenPlaygroundClick }) => { const cleanedType = type.replace('my-', '').replace(/s$/, ''); @@ -84,26 +86,27 @@ const ActionButtons: React.FC = ({ )} )} - - onOpenPlaygroundClick(details.id, details.name)} - > - - Open in Playground - + {showOpenPlaygroundAction && ( + onOpenPlaygroundClick(details.id, details.name)} + > + + Open in Playground + + )} {showUnpublishAction && ( void; showUnpublishAction?: boolean; + showOpenPlaygroundAction?: boolean; onOpenPlaygroundClick: (designId: string, name: string) => void; } @@ -38,6 +39,7 @@ const LeftPanel: React.FC = ({ technologySVGSubpath, fontFamily, showUnpublishAction = false, + showOpenPlaygroundAction = true, onOpenPlaygroundClick }) => { const theme = useTheme(); @@ -79,6 +81,7 @@ const LeftPanel: React.FC = ({ showUnpublishAction={showUnpublishAction} handleUnpublish={handleUnpublish} isCloneDisabled={isCloneDisabled} + showOpenPlaygroundAction={showOpenPlaygroundAction} onOpenPlaygroundClick={onOpenPlaygroundClick} /> {showTechnologies && ( diff --git a/src/custom/CustomTooltip/customTooltip.tsx b/src/custom/CustomTooltip/customTooltip.tsx index b18cb18e..7287c152 100644 --- a/src/custom/CustomTooltip/customTooltip.tsx +++ b/src/custom/CustomTooltip/customTooltip.tsx @@ -57,7 +57,7 @@ function CustomTooltip({ onClick={onClick} {...props} > - {children} + {children} ); }