Skip to content

Commit 9b8c44a

Browse files
Merge pull request #861 from sudhanshutech/visibility/sel
feat(visibilitySelector): add visibility selector to change catalog visibility
2 parents 9bbe475 + 9455e31 commit 9b8c44a

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

src/custom/CatalogDetail/OverviewSection.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import { Grid } from '../../base';
33
import { Pattern } from '../CustomCatalog/CustomCard';
4+
import { VIEW_VISIBILITY } from '../VisibilityChipMenu/VisibilityChipMenu';
45
import ContentClassInfo from './ContentClassInfo';
56
import MetricsDisplay from './MetricsDisplay';
67
import PatternInfo from './PatternInfo';
@@ -25,6 +26,8 @@ interface OverviewSectionProps {
2526
userProfile?: any;
2627
showShareAction: boolean;
2728
handleShare: () => void;
29+
isVisibilityEnabled: boolean;
30+
handleVisibilityChange: (visibility: VIEW_VISIBILITY) => void;
2831
}
2932

3033
const OverviewSection: React.FC<OverviewSectionProps> = ({
@@ -41,7 +44,9 @@ const OverviewSection: React.FC<OverviewSectionProps> = ({
4144
fontFamily,
4245
userProfile,
4346
showShareAction,
44-
handleShare
47+
handleShare,
48+
isVisibilityEnabled,
49+
handleVisibilityChange
4550
}) => {
4651
return (
4752
<OverviewContainer>
@@ -64,6 +69,8 @@ const OverviewSection: React.FC<OverviewSectionProps> = ({
6469
handleCopyUrl={handleCopyUrl}
6570
showShareAction={showShareAction}
6671
handleShare={handleShare}
72+
isVisibilityEnabled={isVisibilityEnabled}
73+
handleVisibilityChange={handleVisibilityChange}
6774
/>
6875
</div>
6976
<Grid container spacing={2}>

src/custom/CatalogDetail/RightPanel.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import { Pattern } from '../CustomCatalog/CustomCard';
3+
import { VIEW_VISIBILITY } from '../VisibilityChipMenu/VisibilityChipMenu';
34
import CaveatsSection from './CaveatsSection';
45
import OverviewSection from './OverviewSection';
56
import RelatedDesigns, { PatternsPerUser } from './RelatedDesigns';
@@ -28,6 +29,8 @@ interface RightPanelProps {
2829
fetchingOrgError: boolean;
2930
showShareAction: boolean;
3031
handleShare: () => void;
32+
isVisibilityEnabled: boolean;
33+
handleVisibilityChange: (visibility: VIEW_VISIBILITY) => void;
3134
}
3235

3336
const RightPanel: React.FC<RightPanelProps> = ({
@@ -51,7 +54,9 @@ const RightPanel: React.FC<RightPanelProps> = ({
5154
orgName,
5255
fetchingOrgError,
5356
showShareAction,
54-
handleShare
57+
handleShare,
58+
isVisibilityEnabled = false,
59+
handleVisibilityChange
5560
}) => {
5661
const cleanedType = type.replace('my-', '').replace(/s$/, '');
5762
const { data: userProfile } = useGetUserProfileByIdQuery({
@@ -75,6 +80,8 @@ const RightPanel: React.FC<RightPanelProps> = ({
7580
userProfile={userProfile}
7681
showShareAction={showShareAction}
7782
handleShare={handleShare}
83+
isVisibilityEnabled={isVisibilityEnabled}
84+
handleVisibilityChange={handleVisibilityChange}
7885
/>
7986
{showCaveats && <CaveatsSection details={details} />}
8087
<RelatedDesigns

src/custom/CatalogDetail/SocialSharePopper.tsx

+7-3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ interface SocialSharePopperProps {
2929
handleCopyUrl: (type: string, name: string, id: string) => void;
3030
showShareAction: boolean;
3131
handleShare: () => void;
32+
isVisibilityEnabled: boolean;
33+
handleVisibilityChange: (visibility: VIEW_VISIBILITY) => void;
3234
}
3335

3436
const SocialSharePopper: React.FC<SocialSharePopperProps> = ({
@@ -38,7 +40,9 @@ const SocialSharePopper: React.FC<SocialSharePopperProps> = ({
3840
title,
3941
getUrl,
4042
handleCopyUrl,
41-
handleShare
43+
handleShare,
44+
isVisibilityEnabled,
45+
handleVisibilityChange
4246
}) => {
4347
const theme = useTheme();
4448
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
@@ -59,8 +63,8 @@ const SocialSharePopper: React.FC<SocialSharePopperProps> = ({
5963
<CopyShareIconWrapper style={{ marginBottom: '2rem' }}>
6064
<VisibilityChipMenu
6165
value={details?.visibility as VIEW_VISIBILITY}
62-
onChange={() => {}}
63-
enabled={false}
66+
onChange={(value) => handleVisibilityChange(value as VIEW_VISIBILITY)}
67+
enabled={isVisibilityEnabled}
6468
options={[
6569
[VIEW_VISIBILITY.PUBLIC, PublicIcon],
6670
[VIEW_VISIBILITY.PRIVATE, LockIcon]

0 commit comments

Comments
 (0)