Skip to content

Commit

Permalink
Merge branch 'master' into amit/workspace-sistent
Browse files Browse the repository at this point in the history
  • Loading branch information
amitamrutiya authored Nov 26, 2024
2 parents fc59b7f + d8f2d65 commit 034da1f
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 49 deletions.
112 changes: 70 additions & 42 deletions src/custom/CatalogDetail/ActionButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { CircularProgress } from '../../base';
import { CopyIcon, KanvasIcon, PublishIcon } from '../../icons';
import { CopyIcon, EditIcon, KanvasIcon, PublishIcon } from '../../icons';
import Download from '../../icons/Download/Download';
import { charcoal, useTheme } from '../../theme';
import { Pattern } from '../CustomCatalog/CustomCard';
Expand All @@ -19,6 +19,8 @@ interface ActionButtonsProps {
showUnpublishAction: boolean;
showOpenPlaygroundAction: boolean;
onOpenPlaygroundClick: (designId: string, name: string) => void;
showInfoAction?: boolean;
handleInfoClick?: () => void;
}

const ActionButtons: React.FC<ActionButtonsProps> = ({
Expand All @@ -31,12 +33,34 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
showUnpublishAction,
handleUnpublish,
showOpenPlaygroundAction,
onOpenPlaygroundClick
onOpenPlaygroundClick,
showInfoAction,
handleInfoClick
}) => {
const cleanedType = type.replace('my-', '').replace(/s$/, '');
const theme = useTheme();
return (
<StyledActionWrapper>
{showOpenPlaygroundAction && (
<ActionButton
sx={{
borderRadius: '0.2rem',
backgroundColor: theme.palette.background.cta?.default,
color: theme.palette.text.inverse,
gap: '10px',
width: '100%'
}}
onClick={() => onOpenPlaygroundClick(details.id, details.name)}
>
<KanvasIcon
width={24}
height={24}
primaryFill={theme.palette.icon.inverse}
fill={theme.palette.icon.default}
/>
Open in Playground
</ActionButton>
)}
{actionItems && (
<div
style={{
Expand All @@ -49,17 +73,18 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
<ActionButton
sx={{
borderRadius: '0.2rem',
backgroundColor: theme.palette.background.brand?.default,
backgroundColor: 'transparent',
border: `1px solid ${theme.palette.border.normal}`,
gap: '10px',
color: charcoal[100]
color: charcoal[10]
}}
onClick={() =>
cleanedType === RESOURCE_TYPES.FILTERS
? downloadFilter(details.id, details.name)
: downloadYaml(details.pattern_file, details.name)
}
>
<Download width={24} height={24} fill={charcoal[100]} />
<Download width={24} height={24} fill={charcoal[10]} />
Download
</ActionButton>

Expand All @@ -68,8 +93,9 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
sx={{
borderRadius: '0.2rem',
gap: '10px',
color: charcoal[100],
backgroundColor: theme.palette.background.cta?.default
color: theme.palette.text.default,
backgroundColor: 'transparent',
border: `1px solid ${theme.palette.border.normal}`
}}
onClick={() => handleClone(details?.name, details?.id)}
disabled={isCloneDisabled}
Expand All @@ -78,49 +104,51 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
<CircularProgress size={24} color={'inherit'} />
) : (
<>
<CopyIcon width={24} height={24} fill={charcoal[100]} />
<CopyIcon width={24} height={24} fill={charcoal[10]} />
Clone
</>
)}
</ActionButton>
)}
</div>
)}
{showOpenPlaygroundAction && (
<ActionButton
sx={{
borderRadius: '0.2rem',
backgroundColor: 'transparent',
border: `1px solid ${theme.palette.border.normal}`,
color: theme.palette.text.default,
gap: '10px',
width: '100%'
}}
onClick={() => onOpenPlaygroundClick(details.id, details.name)}
>
<KanvasIcon
width={24}
height={24}
primaryFill={theme.palette.icon.default}
fill={theme.palette.icon.default}
/>
Open in Playground
</ActionButton>
)}

{showUnpublishAction && (
<UnpublishAction
sx={{
borderRadius: '0.2rem',
gap: '10px',
width: '100%'
}}
onClick={handleUnpublish}
>
<PublishIcon width={24} height={24} fill={charcoal[10]} />
Unpublish
</UnpublishAction>
)}
<div
style={{
display: 'flex',
flexDirection: 'row',
gap: '0.75rem',
width: '100%'
}}
>
{showInfoAction && (
<ActionButton
sx={{
borderRadius: '0.2rem',
backgroundColor: 'transparent',
border: `1px solid ${theme.palette.border.normal}`,
gap: '10px',
color: charcoal[10]
}}
onClick={handleInfoClick}
>
<EditIcon width={24} height={24} fill={charcoal[10]} />
Edit
</ActionButton>
)}
{showUnpublishAction && (
<UnpublishAction
sx={{
borderRadius: '0.2rem',
gap: '10px'
}}
onClick={handleUnpublish}
>
<PublishIcon width={24} height={24} fill={charcoal[100]} />
Unpublish
</UnpublishAction>
)}
</div>
</StyledActionWrapper>
);
};
Expand Down
8 changes: 7 additions & 1 deletion src/custom/CatalogDetail/LeftPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ interface LeftPanelProps {
showUnpublishAction?: boolean;
showOpenPlaygroundAction?: boolean;
onOpenPlaygroundClick: (designId: string, name: string) => void;
showInfoAction?: boolean;
handleInfoClick?: () => void;
}

const LeftPanel: React.FC<LeftPanelProps> = ({
Expand All @@ -40,7 +42,9 @@ const LeftPanel: React.FC<LeftPanelProps> = ({
fontFamily,
showUnpublishAction = false,
showOpenPlaygroundAction = true,
onOpenPlaygroundClick
onOpenPlaygroundClick,
showInfoAction = false,
handleInfoClick
}) => {
const theme = useTheme();

Expand Down Expand Up @@ -83,6 +87,8 @@ const LeftPanel: React.FC<LeftPanelProps> = ({
isCloneDisabled={isCloneDisabled}
showOpenPlaygroundAction={showOpenPlaygroundAction}
onOpenPlaygroundClick={onOpenPlaygroundClick}
showInfoAction={showInfoAction}
handleInfoClick={handleInfoClick}
/>
{showTechnologies && (
<TechnologySection
Expand Down
5 changes: 2 additions & 3 deletions src/custom/CatalogDetail/style.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ export const UnpublishAction = styled('div')<ActionButtonProps>(({ disabled = fa
justifyContent: 'center',
alignItems: 'center',
borderRadius: '0.5rem',
backgroundColor: 'transparent',
border: `1px solid ${theme.palette.border.normal}`,
backgroundColor: theme.palette.background.error?.default,
padding: '0.5rem',
color: theme.palette.text.default,
color: theme.palette.text.inverse,
gap: '0.625rem',
flex: '1'
}));
Expand Down
9 changes: 6 additions & 3 deletions src/custom/Prompt/promt-component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ interface State {
primaryOption: string;
showInfoIcon?: string;
variant?: PromptVariant;
headerIcon?: React.ReactNode;
}

interface ShowParams {
Expand All @@ -33,6 +34,7 @@ interface ShowParams {
primaryOption: string;
variant: PromptVariant;
showInfoIcon?: string;
headerIcon?: React.ReactNode;
}

export interface PromptRef {
Expand All @@ -46,7 +48,8 @@ const PromptComponent = forwardRef<PromptRef, PromptProps>(({ variant }, ref) =>
subtitle: '',
primaryOption: '',
showInfoIcon: '',
variant
variant,
headerIcon: undefined
});

/* This ref is used to store the resolve and reject functions of the promise returned by the show method */
Expand Down Expand Up @@ -78,7 +81,7 @@ const PromptComponent = forwardRef<PromptRef, PromptProps>(({ variant }, ref) =>
show
}));

const { isOpen, primaryOption, title, subtitle, showInfoIcon } = state;
const { isOpen, primaryOption, title, subtitle, showInfoIcon, headerIcon } = state;
const { resolve } = promiseInfoRef.current;

return (
Expand All @@ -87,7 +90,7 @@ const PromptComponent = forwardRef<PromptRef, PromptProps>(({ variant }, ref) =>
closeModal={hide}
title={title}
id="searchClick"
headerIcon={undefined}
headerIcon={headerIcon}
reactNode={undefined}
>
{subtitle && (
Expand Down

0 comments on commit 034da1f

Please sign in to comment.