Skip to content

Commit 7a83103

Browse files
Merge pull request #792 from sudhanshutech/unpublish/action
Add unpublish action in details page
2 parents c34b3da + 1f4fce9 commit 7a83103

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

src/custom/CatalogDetail/ActionButton.tsx

+20-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import _ from 'lodash';
22
import React from 'react';
33
import { CircularProgress } from '../../base';
4-
import { CopyIcon, KanvasIcon } from '../../icons';
4+
import { CopyIcon, KanvasIcon, PublishIcon } from '../../icons';
55
import Download from '../../icons/Download/Download';
66
import { charcoal } from '../../theme';
77
import { Pattern } from '../CustomCatalog/CustomCard';
88
import { downloadFilter, downloadYaml, slugify } from './helper';
9-
import { ActionButton, LinkUrl, StyledActionWrapper } from './style';
9+
import { ActionButton, LinkUrl, StyledActionWrapper, UnpublishAction } from './style';
1010
import { RESOURCE_TYPES } from './types';
1111

1212
interface ActionButtonsProps {
@@ -17,8 +17,10 @@ interface ActionButtonsProps {
1717
isCloneLoading: boolean;
1818
handleClone: (name: string, id: string) => void;
1919
mode: string;
20+
handleUnpublish: () => void;
2021
isCloneDisabled: boolean;
2122
showOpenPlaygroundButton: boolean;
23+
showUnpublishAction: boolean;
2224
}
2325

2426
const ActionButtons: React.FC<ActionButtonsProps> = ({
@@ -30,7 +32,9 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
3032
handleClone,
3133
mode,
3234
isCloneDisabled,
33-
showOpenPlaygroundButton
35+
showOpenPlaygroundButton,
36+
showUnpublishAction,
37+
handleUnpublish
3438
}) => {
3539
const cleanedType = type.replace('my-', '').replace(/s$/, '');
3640
const resourcePlaygroundType = Object.values({
@@ -112,6 +116,19 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
112116
</ActionButton>
113117
</LinkUrl>
114118
)}
119+
{showUnpublishAction && (
120+
<UnpublishAction
121+
sx={{
122+
borderRadius: '0.2rem',
123+
gap: '10px',
124+
width: '100%'
125+
}}
126+
onClick={handleUnpublish}
127+
>
128+
<PublishIcon width={24} height={24} fill={charcoal[10]} />
129+
Unpublish
130+
</UnpublishAction>
131+
)}
115132
</StyledActionWrapper>
116133
);
117134
};

src/custom/CatalogDetail/LeftPanel.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ interface LeftPanelProps {
2222
technologySVGSubpath: string;
2323
fontFamily?: string;
2424
showOpenPlaygroundButton?: boolean;
25+
handleUnpublish: () => void;
26+
showUnpublishAction?: boolean;
2527
}
2628

2729
const LeftPanel: React.FC<LeftPanelProps> = ({
@@ -31,13 +33,15 @@ const LeftPanel: React.FC<LeftPanelProps> = ({
3133
actionItems = true,
3234
isCloneLoading,
3335
handleClone,
36+
handleUnpublish,
3437
showTechnologies = true,
3538
mode,
3639
filteredAcademyData,
3740
isCloneDisabled,
3841
technologySVGPath,
3942
technologySVGSubpath,
4043
fontFamily,
44+
showUnpublishAction = false,
4145
showOpenPlaygroundButton = true
4246
}) => {
4347
const theme = useTheme();
@@ -77,6 +81,8 @@ const LeftPanel: React.FC<LeftPanelProps> = ({
7781
cardId={cardId}
7882
isCloneLoading={isCloneLoading}
7983
handleClone={handleClone}
84+
showUnpublishAction={showUnpublishAction}
85+
handleUnpublish={handleUnpublish}
8086
mode={mode}
8187
isCloneDisabled={isCloneDisabled}
8288
showOpenPlaygroundButton={showOpenPlaygroundButton}

src/custom/CatalogDetail/style.tsx

+16
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,22 @@ export const ActionButton = styled('div')<ActionButtonProps>(({ disabled = false
3939
flex: '1'
4040
}));
4141

42+
export const UnpublishAction = styled('div')<ActionButtonProps>(({ disabled = false, theme }) => ({
43+
cursor: disabled ? 'not-allowed' : 'pointer',
44+
opacity: disabled ? '0.5' : '1',
45+
textAlign: 'center',
46+
display: 'flex',
47+
justifyContent: 'center',
48+
alignItems: 'center',
49+
borderRadius: '0.5rem',
50+
backgroundColor: 'transparent',
51+
border: `1px solid ${theme.palette.border.normal}`,
52+
padding: '0.5rem',
53+
color: theme.palette.text.default,
54+
gap: '0.625rem',
55+
flex: '1'
56+
}));
57+
4258
export const ContentDetailsText = styled(Typography)(({ theme }) => ({
4359
fontFamily: 'inherit',
4460
fontSize: '1rem',

0 commit comments

Comments
 (0)