Skip to content

Commit

Permalink
feat(catalog): unpublish action
Browse files Browse the repository at this point in the history
Signed-off-by: Sudhanshu Dasgupta <[email protected]>
  • Loading branch information
sudhanshutech committed Nov 2, 2024
1 parent 5e86e48 commit cd01819
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
29 changes: 26 additions & 3 deletions src/custom/CatalogDetail/ActionButton.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import _ from 'lodash';
import React from 'react';
import { CircularProgress } from '../../base';
import { CopyIcon, KanvasIcon } from '../../icons';
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 } from './style';
import { ActionButton, LinkUrl, StyledActionWrapper, UnpublishAction } from './style';
import { RESOURCE_TYPES } from './types';

interface ActionButtonsProps {
Expand All @@ -17,8 +17,10 @@ interface ActionButtonsProps {
isCloneLoading: boolean;
handleClone: (name: string, id: string) => void;
mode: string;
handleUnpublish?: () => void;
isCloneDisabled: boolean;
showOpenPlaygroundButton: boolean;
showUnpublishAction: boolean;
}

const ActionButtons: React.FC<ActionButtonsProps> = ({
Expand All @@ -30,7 +32,9 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
handleClone,
mode,
isCloneDisabled,
showOpenPlaygroundButton
showOpenPlaygroundButton,
showUnpublishAction,
handleUnpublish
}) => {
const cleanedType = type.replace('my-', '').replace(/s$/, '');
const resourcePlaygroundType = Object.values({
Expand Down Expand Up @@ -112,6 +116,25 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
</ActionButton>
</LinkUrl>
)}
{showUnpublishAction && (
<LinkUrl
style={{ width: '100%' }}
onClick={handleUnpublish}
target="_blank"
rel="noreferrer"
>
<UnpublishAction
sx={{
borderRadius: '0.2rem',
gap: '10px',
width: '100%'
}}
>
<PublishIcon width={24} height={24} fill={charcoal[10]} />
Unpublish
</UnpublishAction>
</LinkUrl>
)}
</StyledActionWrapper>
);
};
Expand Down
16 changes: 16 additions & 0 deletions src/custom/CatalogDetail/style.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,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: 'transparent',
border: theme.palette.border.default,
padding: '0.5rem',
color: theme.palette.text.default,
gap: '0.625rem',
flex: '1'
}));

export const ContentDetailsText = styled(Typography)(({ theme }) => ({
fontFamily: 'inherit',
fontSize: '1rem',
Expand Down

0 comments on commit cd01819

Please sign in to comment.