Skip to content

Commit 1bcc943

Browse files
authored
Merge pull request #788 from amitamrutiya/amit/catalog-detail
make open in playground button dynamic for playground and cloud
2 parents f88d007 + d6b34d9 commit 1bcc943

File tree

5 files changed

+45
-28
lines changed

5 files changed

+45
-28
lines changed

src/custom/CatalogDetail/ActionButton.tsx

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ interface ActionButtonsProps {
1818
handleClone: (name: string, id: string) => void;
1919
mode: string;
2020
isCloneDisabled: boolean;
21+
showOpenPlaygroundButton: boolean;
2122
}
2223

2324
const ActionButtons: React.FC<ActionButtonsProps> = ({
@@ -28,7 +29,8 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
2829
isCloneLoading,
2930
handleClone,
3031
mode,
31-
isCloneDisabled
32+
isCloneDisabled,
33+
showOpenPlaygroundButton
3234
}) => {
3335
const cleanedType = type.replace('my-', '').replace(/s$/, '');
3436
const resourcePlaygroundType = Object.values({
@@ -51,7 +53,7 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
5153
<ActionButton
5254
sx={{
5355
borderRadius: '0.2rem',
54-
backgroundColor: 'background.inverse',
56+
backgroundColor: charcoal[10],
5557
gap: '10px',
5658
color: charcoal[100]
5759
}}
@@ -87,27 +89,29 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
8789
)}
8890
</div>
8991
)}
90-
<LinkUrl
91-
style={{ width: '100%' }}
92-
href={`https://playground.meshery.io/extension/meshmap?mode=${mode}&type=${resourcePlaygroundType}&id=${cardId}&name=${slugify(
93-
details.name
94-
)}`}
95-
target="_blank"
96-
rel="noreferrer"
97-
>
98-
<ActionButton
99-
sx={{
100-
borderRadius: '0.2rem',
101-
backgroundColor: 'background.cta.default',
102-
color: charcoal[10],
103-
gap: '10px',
104-
width: '100%'
105-
}}
92+
{showOpenPlaygroundButton && (
93+
<LinkUrl
94+
style={{ width: '100%' }}
95+
href={`https://playground.meshery.io/extension/meshmap?mode=${mode}&type=${resourcePlaygroundType}&id=${cardId}&name=${slugify(
96+
details.name
97+
)}`}
98+
target="_blank"
99+
rel="noreferrer"
106100
>
107-
<KanvasIcon width={24} height={24} primaryFill={charcoal[10]} fill={charcoal[10]} />
108-
Open in Playground
109-
</ActionButton>
110-
</LinkUrl>
101+
<ActionButton
102+
sx={{
103+
borderRadius: '0.2rem',
104+
backgroundColor: 'background.cta.default',
105+
color: charcoal[10],
106+
gap: '10px',
107+
width: '100%'
108+
}}
109+
>
110+
<KanvasIcon width={24} height={24} primaryFill={charcoal[10]} fill={charcoal[10]} />
111+
Open in Playground
112+
</ActionButton>
113+
</LinkUrl>
114+
)}
111115
</StyledActionWrapper>
112116
);
113117
};

src/custom/CatalogDetail/LeftPanel.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ interface LeftPanelProps {
2121
technologySVGPath: string;
2222
technologySVGSubpath: string;
2323
fontFamily?: string;
24+
showOpenPlaygroundButton?: boolean;
2425
}
2526

2627
const LeftPanel: React.FC<LeftPanelProps> = ({
@@ -36,7 +37,8 @@ const LeftPanel: React.FC<LeftPanelProps> = ({
3637
isCloneDisabled,
3738
technologySVGPath,
3839
technologySVGSubpath,
39-
fontFamily
40+
fontFamily,
41+
showOpenPlaygroundButton = true
4042
}) => {
4143
const theme = useTheme();
4244

@@ -77,6 +79,7 @@ const LeftPanel: React.FC<LeftPanelProps> = ({
7779
handleClone={handleClone}
7880
mode={mode}
7981
isCloneDisabled={isCloneDisabled}
82+
showOpenPlaygroundButton={showOpenPlaygroundButton}
8083
/>
8184
{showTechnologies && (
8285
<TechnologySection

src/custom/CatalogDetail/RelatedDesigns.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,18 @@ interface RelatedDesignsProps {
1414
patternsPerUser: PatternsPerUser;
1515
onSuggestedPatternClick: (pattern: Pattern) => void;
1616
userProfile?: UserProfile;
17+
technologySVGPath: string;
18+
technologySVGSubpath: string;
1719
}
1820

1921
const RelatedDesigns: React.FC<RelatedDesignsProps> = ({
2022
details,
2123
type,
2224
patternsPerUser,
2325
onSuggestedPatternClick,
24-
userProfile
26+
userProfile,
27+
technologySVGPath,
28+
technologySVGSubpath
2529
}) => {
2630
const filteredPatternsPerUser = patternsPerUser?.patterns?.filter(
2731
(pattern) => pattern.id !== details.id
@@ -45,8 +49,8 @@ const RelatedDesigns: React.FC<RelatedDesignsProps> = ({
4549
onCardClick={() => onSuggestedPatternClick(pattern)}
4650
UserName={`${userProfile?.first_name ?? ''} ${userProfile?.last_name ?? ''}`}
4751
avatarUrl={userProfile?.avatar_url}
48-
basePath="/static/img/meshmodels"
49-
subBasePath="color"
52+
basePath={technologySVGPath}
53+
subBasePath={technologySVGSubpath}
5054
cardTechnologies={true}
5155
>
5256
<CatalogCardDesignLogo

src/custom/CatalogDetail/RightPanel.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ interface RightPanelProps {
2222
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2323
useGetUserProfileByIdQuery: any;
2424
fontFamily?: string;
25+
technologySVGPath: string;
26+
technologySVGSubpath: string;
2527
}
2628

2729
const RightPanel: React.FC<RightPanelProps> = ({
@@ -39,7 +41,9 @@ const RightPanel: React.FC<RightPanelProps> = ({
3941
onSuggestedPatternClick,
4042
handleCopyUrl,
4143
fontFamily,
42-
useGetUserProfileByIdQuery
44+
useGetUserProfileByIdQuery,
45+
technologySVGPath,
46+
technologySVGSubpath
4347
}) => {
4448
const cleanedType = type.replace('my-', '').replace(/s$/, '');
4549
const { data: userProfile } = useGetUserProfileByIdQuery({
@@ -69,6 +73,8 @@ const RightPanel: React.FC<RightPanelProps> = ({
6973
patternsPerUser={patternsPerUser}
7074
onSuggestedPatternClick={onSuggestedPatternClick}
7175
userProfile={userProfile}
76+
technologySVGPath={technologySVGPath}
77+
technologySVGSubpath={technologySVGSubpath}
7278
/>
7379
</div>
7480
);

src/custom/CatalogDetail/UserInfo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const UserInfo: React.FC<UserInfoProps> = ({ details, showVersion = true, userPr
2121
target="_blank"
2222
rel="noopener noreferrer"
2323
>
24-
<span style={{ fontWeight: 'normal', fontSize: '1.2rem' }}>
24+
<span style={{ fontWeight: 'normal' }}>
2525
{userProfile?.first_name} {userProfile?.last_name}
2626
</span>
2727
</RedirectLink>

0 commit comments

Comments
 (0)