Skip to content

Commit fea308e

Browse files
authored
Merge pull request #806 from amitamrutiya/open-playground
add 'Open in Playground' action button conditionally
2 parents 983711b + e92d6a8 commit fea308e

File tree

3 files changed

+27
-21
lines changed

3 files changed

+27
-21
lines changed

src/custom/CatalogDetail/ActionButton.tsx

+23-20
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ interface ActionButtonsProps {
1717
handleUnpublish: () => void;
1818
isCloneDisabled: boolean;
1919
showUnpublishAction: boolean;
20+
showOpenPlaygroundAction: boolean;
2021
onOpenPlaygroundClick: (designId: string, name: string) => void;
2122
}
2223

@@ -29,6 +30,7 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
2930
isCloneDisabled,
3031
showUnpublishAction,
3132
handleUnpublish,
33+
showOpenPlaygroundAction,
3234
onOpenPlaygroundClick
3335
}) => {
3436
const cleanedType = type.replace('my-', '').replace(/s$/, '');
@@ -84,26 +86,27 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
8486
)}
8587
</div>
8688
)}
87-
88-
<ActionButton
89-
sx={{
90-
borderRadius: '0.2rem',
91-
backgroundColor: 'transparent',
92-
border: `1px solid ${theme.palette.border.normal}`,
93-
color: theme.palette.text.default,
94-
gap: '10px',
95-
width: '100%'
96-
}}
97-
onClick={() => onOpenPlaygroundClick(details.id, details.name)}
98-
>
99-
<KanvasIcon
100-
width={24}
101-
height={24}
102-
primaryFill={theme.palette.icon.default}
103-
fill={theme.palette.icon.default}
104-
/>
105-
Open in Playground
106-
</ActionButton>
89+
{showOpenPlaygroundAction && (
90+
<ActionButton
91+
sx={{
92+
borderRadius: '0.2rem',
93+
backgroundColor: 'transparent',
94+
border: `1px solid ${theme.palette.border.normal}`,
95+
color: theme.palette.text.default,
96+
gap: '10px',
97+
width: '100%'
98+
}}
99+
onClick={() => onOpenPlaygroundClick(details.id, details.name)}
100+
>
101+
<KanvasIcon
102+
width={24}
103+
height={24}
104+
primaryFill={theme.palette.icon.default}
105+
fill={theme.palette.icon.default}
106+
/>
107+
Open in Playground
108+
</ActionButton>
109+
)}
107110

108111
{showUnpublishAction && (
109112
<UnpublishAction

src/custom/CatalogDetail/LeftPanel.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ interface LeftPanelProps {
2121
fontFamily?: string;
2222
handleUnpublish: () => void;
2323
showUnpublishAction?: boolean;
24+
showOpenPlaygroundAction?: boolean;
2425
onOpenPlaygroundClick: (designId: string, name: string) => void;
2526
}
2627

@@ -38,6 +39,7 @@ const LeftPanel: React.FC<LeftPanelProps> = ({
3839
technologySVGSubpath,
3940
fontFamily,
4041
showUnpublishAction = false,
42+
showOpenPlaygroundAction = true,
4143
onOpenPlaygroundClick
4244
}) => {
4345
const theme = useTheme();
@@ -79,6 +81,7 @@ const LeftPanel: React.FC<LeftPanelProps> = ({
7981
showUnpublishAction={showUnpublishAction}
8082
handleUnpublish={handleUnpublish}
8183
isCloneDisabled={isCloneDisabled}
84+
showOpenPlaygroundAction={showOpenPlaygroundAction}
8285
onOpenPlaygroundClick={onOpenPlaygroundClick}
8386
/>
8487
{showTechnologies && (

src/custom/CustomTooltip/customTooltip.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function CustomTooltip({
5757
onClick={onClick}
5858
{...props}
5959
>
60-
<span>{children}</span>
60+
{children}
6161
</Tooltip>
6262
);
6363
}

0 commit comments

Comments
 (0)