From 5f4c8133a3db0618c93e21b6431f3e62c8226fdf Mon Sep 17 00:00:00 2001 From: Amit Amrutiya Date: Sat, 9 Nov 2024 10:01:27 +0530 Subject: [PATCH] feat: add open in playground button true Signed-off-by: Amit Amrutiya --- src/custom/CatalogDetail/ActionButton.tsx | 59 ++++++++--------------- src/custom/CatalogDetail/LeftPanel.tsx | 12 ++--- src/custom/CatalogDetail/style.tsx | 4 -- 3 files changed, 23 insertions(+), 52 deletions(-) diff --git a/src/custom/CatalogDetail/ActionButton.tsx b/src/custom/CatalogDetail/ActionButton.tsx index 1cd4ff66..97e12ad4 100644 --- a/src/custom/CatalogDetail/ActionButton.tsx +++ b/src/custom/CatalogDetail/ActionButton.tsx @@ -1,48 +1,37 @@ -import _ from 'lodash'; import React from 'react'; import { CircularProgress } from '../../base'; import { CopyIcon, KanvasIcon, PublishIcon } from '../../icons'; import Download from '../../icons/Download/Download'; import { charcoal } from '../../theme'; import { Pattern } from '../CustomCatalog/CustomCard'; -import { downloadFilter, downloadYaml, slugify } from './helper'; -import { ActionButton, LinkUrl, StyledActionWrapper, UnpublishAction } from './style'; +import { downloadFilter, downloadYaml } from './helper'; +import { ActionButton, StyledActionWrapper, UnpublishAction } from './style'; import { RESOURCE_TYPES } from './types'; interface ActionButtonsProps { actionItems: boolean; details: Pattern; type: string; - cardId: string; isCloneLoading: boolean; handleClone: (name: string, id: string) => void; - mode: string; handleUnpublish: () => void; isCloneDisabled: boolean; - showOpenPlaygroundButton: boolean; showUnpublishAction: boolean; + onOpenPlaygroundClick: (designId: string, name: string) => void; } const ActionButtons: React.FC = ({ actionItems, details, type, - cardId, isCloneLoading, handleClone, - mode, isCloneDisabled, - showOpenPlaygroundButton, showUnpublishAction, - handleUnpublish + handleUnpublish, + onOpenPlaygroundClick }) => { const cleanedType = type.replace('my-', '').replace(/s$/, ''); - const resourcePlaygroundType = Object.values({ - ..._.omit(RESOURCE_TYPES, ['FILTERS']), - CATALOG: 'catalog' - }).includes(cleanedType) - ? cleanedType - : 'design'; return ( {actionItems && ( @@ -93,29 +82,21 @@ const ActionButtons: React.FC = ({ )} )} - {showOpenPlaygroundButton && ( - - - - Open in Playground - - - )} + + onOpenPlaygroundClick(details.id, details.name)} + > + + Open in Playground + + {showUnpublishAction && ( void; showTechnologies?: boolean; - mode: string; filteredAcademyData: FilteredAcademyData; isCloneDisabled: boolean; technologySVGPath: string; technologySVGSubpath: string; fontFamily?: string; - showOpenPlaygroundButton?: boolean; handleUnpublish: () => void; showUnpublishAction?: boolean; + onOpenPlaygroundClick: (designId: string, name: string) => void; } const LeftPanel: React.FC = ({ details, type, - cardId = details.id, actionItems = true, isCloneLoading, handleClone, handleUnpublish, showTechnologies = true, - mode, filteredAcademyData, isCloneDisabled, technologySVGPath, technologySVGSubpath, fontFamily, showUnpublishAction = false, - showOpenPlaygroundButton = true + onOpenPlaygroundClick }) => { const theme = useTheme(); @@ -78,14 +74,12 @@ const LeftPanel: React.FC = ({ actionItems={actionItems} details={details} type={type} - cardId={cardId} isCloneLoading={isCloneLoading} handleClone={handleClone} showUnpublishAction={showUnpublishAction} handleUnpublish={handleUnpublish} - mode={mode} isCloneDisabled={isCloneDisabled} - showOpenPlaygroundButton={showOpenPlaygroundButton} + onOpenPlaygroundClick={onOpenPlaygroundClick} /> {showTechnologies && ( ({ alignItems: 'center' })); -export const LinkUrl = styled('a')(() => ({ - textDecoration: 'none' -})); - interface ActionButtonProps { disabled?: boolean; theme?: Theme;