Skip to content

Commit f2edeb6

Browse files
Merge pull request #731 from sudhanshutech/yash/addShareModal
Share Modal
2 parents cc64f06 + cbc755a commit f2edeb6

File tree

17 files changed

+752
-33
lines changed

17 files changed

+752
-33
lines changed

src/custom/CatalogDetail/OverviewSection.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ interface OverviewSectionProps {
2323
fontFamily?: string;
2424
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2525
userProfile?: any;
26+
showShareAction: boolean;
27+
handleShare: () => void;
2628
}
2729

2830
const OverviewSection: React.FC<OverviewSectionProps> = ({
@@ -37,7 +39,9 @@ const OverviewSection: React.FC<OverviewSectionProps> = ({
3739
classes,
3840
handleCopyUrl,
3941
fontFamily,
40-
userProfile
42+
userProfile,
43+
showShareAction,
44+
handleShare
4145
}) => {
4246
return (
4347
<OverviewContainer>
@@ -58,6 +62,8 @@ const OverviewSection: React.FC<OverviewSectionProps> = ({
5862
title={title}
5963
getUrl={getUrl}
6064
handleCopyUrl={handleCopyUrl}
65+
showShareAction={showShareAction}
66+
handleShare={handleShare}
6167
/>
6268
</div>
6369
<Grid container spacing={2}>

src/custom/CatalogDetail/RightPanel.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ interface RightPanelProps {
2626
technologySVGSubpath: string;
2727
orgName: string;
2828
fetchingOrgError: boolean;
29+
showShareAction: boolean;
30+
handleShare: () => void;
2931
}
3032

3133
const RightPanel: React.FC<RightPanelProps> = ({
@@ -47,7 +49,9 @@ const RightPanel: React.FC<RightPanelProps> = ({
4749
technologySVGPath,
4850
technologySVGSubpath,
4951
orgName,
50-
fetchingOrgError
52+
fetchingOrgError,
53+
showShareAction,
54+
handleShare
5155
}) => {
5256
const cleanedType = type.replace('my-', '').replace(/s$/, '');
5357
const { data: userProfile } = useGetUserProfileByIdQuery({
@@ -69,6 +73,8 @@ const RightPanel: React.FC<RightPanelProps> = ({
6973
handleCopyUrl={handleCopyUrl}
7074
fontFamily={fontFamily}
7175
userProfile={userProfile}
76+
showShareAction={showShareAction}
77+
handleShare={handleShare}
7278
/>
7379
{showCaveats && <CaveatsSection details={details} />}
7480
<RelatedDesigns

src/custom/CatalogDetail/SocialSharePopper.tsx

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { useTheme } from '../../theme';
66
import { Pattern } from '../CustomCatalog/CustomCard';
77
import { CustomTooltip } from '../CustomTooltip';
88
import { ErrorBoundary } from '../ErrorBoundary';
9-
import { CopyShareIconWrapper, VisibilityChip } from './style';
9+
import { ActionButton, CopyShareIconWrapper, VisibilityChip } from './style';
1010

1111
interface SocialSharePopperProps {
1212
details: Pattern;
@@ -15,6 +15,8 @@ interface SocialSharePopperProps {
1515
title: string;
1616
getUrl: (type: string, id: string) => string;
1717
handleCopyUrl: (type: string, name: string, id: string) => void;
18+
showShareAction: boolean;
19+
handleShare: () => void;
1820
}
1921

2022
const SocialSharePopper: React.FC<SocialSharePopperProps> = ({
@@ -23,7 +25,9 @@ const SocialSharePopper: React.FC<SocialSharePopperProps> = ({
2325
cardId,
2426
title,
2527
getUrl,
26-
handleCopyUrl
28+
handleCopyUrl,
29+
showShareAction,
30+
handleShare
2731
}) => {
2832
const theme = useTheme();
2933
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
@@ -50,15 +54,26 @@ const SocialSharePopper: React.FC<SocialSharePopperProps> = ({
5054
{details?.visibility}
5155
</VisibilityChip>
5256

53-
{details?.visibility !== 'private' && (
54-
<CustomTooltip title="Copy Link" placement="top" arrow>
55-
<IconButton
56-
sx={{ borderRadius: '0.1rem', padding: '0.5rem' }}
57-
onClick={() => handleCopyUrl(cleanedType, details?.name, details?.id)}
58-
>
59-
<ChainIcon height={'24'} width={'24'} fill={theme.palette.icon.secondary} />
60-
</IconButton>
57+
{showShareAction ? (
58+
<CustomTooltip title="Share" placement="top" arrow>
59+
<ActionButton sx={{ borderRadius: '0.2rem', padding: '0.4rem' }} onClick={handleShare}>
60+
<ChainIcon height={'24'} width={'24'} fill={theme.palette.icon.inverse} />
61+
Share
62+
</ActionButton>
6163
</CustomTooltip>
64+
) : (
65+
<>
66+
{details?.visibility !== 'private' && (
67+
<CustomTooltip title="Copy Link" placement="top" arrow>
68+
<IconButton
69+
sx={{ borderRadius: '0.1rem', padding: '0.5rem' }}
70+
onClick={() => handleCopyUrl(cleanedType, details?.name, details?.id)}
71+
>
72+
<ChainIcon height={'24'} width={'24'} fill={theme.palette.icon.secondary} />
73+
</IconButton>
74+
</CustomTooltip>
75+
)}
76+
</>
6277
)}
6378

6479
{(details?.visibility === 'published' || details?.visibility === 'public') && (

src/custom/Modal/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import { CustomTooltip } from '../CustomTooltip';
1010
interface ModalProps extends DialogProps {
1111
closeModal: () => void;
1212
title: string;
13-
headerIcon: React.ReactNode;
14-
reactNode: React.ReactNode;
13+
headerIcon?: React.ReactNode;
14+
reactNode?: React.ReactNode;
1515
}
1616

1717
interface ModalFooterProps {

0 commit comments

Comments
 (0)