Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add action button to leftPanel component #842

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions src/custom/CatalogDetail/ActionButton.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react';
import { CircularProgress } from '../../base';
import { CopyIcon, EditIcon, KanvasIcon, PublishIcon } from '../../icons';
import { CopyIcon, DeleteIcon, EditIcon, KanvasIcon, PublishIcon } from '../../icons';
import Download from '../../icons/Download/Download';
import { charcoal, useTheme } from '../../theme';
import { Pattern } from '../CustomCatalog/CustomCard';
import { downloadFilter, downloadYaml } from './helper';
import { ActionButton, StyledActionWrapper, UnpublishAction } from './style';
import { ActionButton, DangerActionButton, StyledActionWrapper } from './style';
import { RESOURCE_TYPES } from './types';

interface ActionButtonsProps {
Expand All @@ -21,6 +21,8 @@ interface ActionButtonsProps {
onOpenPlaygroundClick: (designId: string, name: string) => void;
showInfoAction?: boolean;
handleInfoClick?: () => void;
showDeletAction: boolean;
handleDelete: () => void;
}

const ActionButtons: React.FC<ActionButtonsProps> = ({
Expand All @@ -35,7 +37,9 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
showOpenPlaygroundAction,
onOpenPlaygroundClick,
showInfoAction,
handleInfoClick
handleInfoClick,
showDeletAction,
handleDelete
}) => {
const cleanedType = type.replace('my-', '').replace(/s$/, '');
const theme = useTheme();
Expand Down Expand Up @@ -137,7 +141,7 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
</ActionButton>
)}
{showUnpublishAction && (
<UnpublishAction
<DangerActionButton
sx={{
borderRadius: '0.2rem',
gap: '10px'
Expand All @@ -146,7 +150,19 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
>
<PublishIcon width={24} height={24} fill={charcoal[100]} />
Unpublish
</UnpublishAction>
</DangerActionButton>
)}
{showDeletAction && (
<DangerActionButton
sx={{
borderRadius: '0.2rem',
gap: '10px'
}}
onClick={handleDelete}
>
<DeleteIcon width={24} height={24} fill={charcoal[100]} />
Delete
</DangerActionButton>
)}
</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 @@ -25,6 +25,8 @@ interface LeftPanelProps {
onOpenPlaygroundClick: (designId: string, name: string) => void;
showInfoAction?: boolean;
handleInfoClick?: () => void;
showDeleteAction: boolean;
handleDelete: () => void;
}

const LeftPanel: React.FC<LeftPanelProps> = ({
Expand All @@ -44,7 +46,9 @@ const LeftPanel: React.FC<LeftPanelProps> = ({
showOpenPlaygroundAction = true,
onOpenPlaygroundClick,
showInfoAction = false,
handleInfoClick
handleInfoClick,
showDeleteAction = false,
handleDelete
}) => {
const theme = useTheme();

Expand Down Expand Up @@ -89,6 +93,8 @@ const LeftPanel: React.FC<LeftPanelProps> = ({
onOpenPlaygroundClick={onOpenPlaygroundClick}
showInfoAction={showInfoAction}
handleInfoClick={handleInfoClick}
showDeletAction={showDeleteAction}
handleDelete={handleDelete}
/>
{showTechnologies && (
<TechnologySection
Expand Down
30 changes: 16 additions & 14 deletions src/custom/CatalogDetail/style.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,22 @@ export const ActionButton = styled('div')<ActionButtonProps>(({ disabled = false
flex: '1'
}));

export const UnpublishAction = styled('div')<ActionButtonProps>(({ disabled = false, theme }) => ({
cursor: disabled ? 'not-allowed' : 'pointer',
opacity: disabled ? '0.5' : '1',
textAlign: 'center',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
borderRadius: '0.5rem',
backgroundColor: theme.palette.background.error?.default,
padding: '0.5rem',
color: theme.palette.text.inverse,
gap: '0.625rem',
flex: '1'
}));
export const DangerActionButton = styled('div')<ActionButtonProps>(
({ disabled = false, theme }) => ({
cursor: disabled ? 'not-allowed' : 'pointer',
opacity: disabled ? '0.5' : '1',
textAlign: 'center',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
borderRadius: '0.5rem',
backgroundColor: theme.palette.background.error?.default,
padding: '0.5rem',
color: theme.palette.text.inverse,
gap: '0.625rem',
flex: '1'
})
);

export const ContentDetailsText = styled(Typography)(({ theme, style }) => ({
fontFamily: 'inherit',
Expand Down
Loading