Skip to content

Commit

Permalink
feat: pass props for visible of open in playground button
Browse files Browse the repository at this point in the history
Signed-off-by: Amit Amrutiya <[email protected]>
  • Loading branch information
amitamrutiya committed Oct 31, 2024
1 parent bcb4e01 commit 240567a
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 28 deletions.
48 changes: 26 additions & 22 deletions src/custom/CatalogDetail/ActionButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface ActionButtonsProps {
handleClone: (name: string, id: string) => void;
mode: string;
isCloneDisabled: boolean;
showOpenPlaygroundButton: boolean;
}

const ActionButtons: React.FC<ActionButtonsProps> = ({
Expand All @@ -28,7 +29,8 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
isCloneLoading,
handleClone,
mode,
isCloneDisabled
isCloneDisabled,
showOpenPlaygroundButton
}) => {
const cleanedType = type.replace('my-', '').replace(/s$/, '');
const resourcePlaygroundType = Object.values({
Expand All @@ -51,7 +53,7 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
<ActionButton
sx={{
borderRadius: '0.2rem',
backgroundColor: 'background.inverse',
backgroundColor: charcoal[10],
gap: '10px',
color: charcoal[100]
}}
Expand Down Expand Up @@ -87,27 +89,29 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
)}
</div>
)}
<LinkUrl
style={{ width: '100%' }}
href={`https://playground.meshery.io/extension/meshmap?mode=${mode}&type=${resourcePlaygroundType}&id=${cardId}&name=${slugify(
details.name
)}`}
target="_blank"
rel="noreferrer"
>
<ActionButton
sx={{
borderRadius: '0.2rem',
backgroundColor: 'background.cta.default',
color: charcoal[10],
gap: '10px',
width: '100%'
}}
{showOpenPlaygroundButton && (
<LinkUrl
style={{ width: '100%' }}
href={`https://playground.meshery.io/extension/meshmap?mode=${mode}&type=${resourcePlaygroundType}&id=${cardId}&name=${slugify(
details.name
)}`}
target="_blank"
rel="noreferrer"
>
<KanvasIcon width={24} height={24} primaryFill={charcoal[10]} fill={charcoal[10]} />
Open in Playground
</ActionButton>
</LinkUrl>
<ActionButton
sx={{
borderRadius: '0.2rem',
backgroundColor: 'background.cta.default',
color: charcoal[10],
gap: '10px',
width: '100%'
}}
>
<KanvasIcon width={24} height={24} primaryFill={charcoal[10]} fill={charcoal[10]} />
Open in Playground
</ActionButton>
</LinkUrl>
)}
</StyledActionWrapper>
);
};
Expand Down
5 changes: 4 additions & 1 deletion src/custom/CatalogDetail/LeftPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface LeftPanelProps {
technologySVGPath: string;
technologySVGSubpath: string;
fontFamily?: string;
showOpenPlaygroundButton?: boolean;
}

const LeftPanel: React.FC<LeftPanelProps> = ({
Expand All @@ -36,7 +37,8 @@ const LeftPanel: React.FC<LeftPanelProps> = ({
isCloneDisabled,
technologySVGPath,
technologySVGSubpath,
fontFamily
fontFamily,
showOpenPlaygroundButton = true
}) => {
const theme = useTheme();

Expand Down Expand Up @@ -77,6 +79,7 @@ const LeftPanel: React.FC<LeftPanelProps> = ({
handleClone={handleClone}
mode={mode}
isCloneDisabled={isCloneDisabled}
showOpenPlaygroundButton={showOpenPlaygroundButton}
/>
{showTechnologies && (
<TechnologySection
Expand Down
10 changes: 7 additions & 3 deletions src/custom/CatalogDetail/RelatedDesigns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,18 @@ interface RelatedDesignsProps {
patternsPerUser: PatternsPerUser;
onSuggestedPatternClick: (pattern: Pattern) => void;
userProfile?: UserProfile;
technologySVGPath: string;
technologySVGSubpath: string;
}

const RelatedDesigns: React.FC<RelatedDesignsProps> = ({
details,
type,
patternsPerUser,
onSuggestedPatternClick,
userProfile
userProfile,
technologySVGPath,
technologySVGSubpath
}) => {
const filteredPatternsPerUser = patternsPerUser?.patterns?.filter(
(pattern) => pattern.id !== details.id
Expand All @@ -45,8 +49,8 @@ const RelatedDesigns: React.FC<RelatedDesignsProps> = ({
onCardClick={() => onSuggestedPatternClick(pattern)}
UserName={`${userProfile?.first_name ?? ''} ${userProfile?.last_name ?? ''}`}
avatarUrl={userProfile?.avatar_url}
basePath="/static/img/meshmodels"
subBasePath="color"
basePath={technologySVGPath}
subBasePath={technologySVGSubpath}
cardTechnologies={true}
>
<CatalogCardDesignLogo
Expand Down
8 changes: 7 additions & 1 deletion src/custom/CatalogDetail/RightPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ interface RightPanelProps {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
useGetUserProfileByIdQuery: any;
fontFamily?: string;
technologySVGPath: string;
technologySVGSubpath: string;
}

const RightPanel: React.FC<RightPanelProps> = ({
Expand All @@ -39,7 +41,9 @@ const RightPanel: React.FC<RightPanelProps> = ({
onSuggestedPatternClick,
handleCopyUrl,
fontFamily,
useGetUserProfileByIdQuery
useGetUserProfileByIdQuery,
technologySVGPath,
technologySVGSubpath
}) => {
const cleanedType = type.replace('my-', '').replace(/s$/, '');
const { data: userProfile } = useGetUserProfileByIdQuery({
Expand Down Expand Up @@ -69,6 +73,8 @@ const RightPanel: React.FC<RightPanelProps> = ({
patternsPerUser={patternsPerUser}
onSuggestedPatternClick={onSuggestedPatternClick}
userProfile={userProfile}
technologySVGPath={technologySVGPath}
technologySVGSubpath={technologySVGSubpath}
/>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/custom/CatalogDetail/UserInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const UserInfo: React.FC<UserInfoProps> = ({ details, showVersion = true, userPr
target="_blank"
rel="noopener noreferrer"
>
<span style={{ fontWeight: 'normal', fontSize: '1.2rem' }}>
<span style={{ fontWeight: 'normal' }}>
{userProfile?.first_name} {userProfile?.last_name}
</span>
</RedirectLink>
Expand Down

0 comments on commit 240567a

Please sign in to comment.