From a6d0779790ded5533de755662570b9582f53b247 Mon Sep 17 00:00:00 2001 From: Sudhanshu Dasgupta Date: Sun, 22 Dec 2024 18:21:11 +0530 Subject: [PATCH 1/3] feat(visibility): add visibility selector to change its visibility Signed-off-by: Sudhanshu Dasgupta --- src/custom/CatalogDetail/OverviewSection.tsx | 8 +++++++- src/custom/CatalogDetail/RightPanel.tsx | 8 +++++++- src/custom/CatalogDetail/SocialSharePopper.tsx | 10 +++++++--- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/custom/CatalogDetail/OverviewSection.tsx b/src/custom/CatalogDetail/OverviewSection.tsx index 825ed48a1..ef0ffcf86 100644 --- a/src/custom/CatalogDetail/OverviewSection.tsx +++ b/src/custom/CatalogDetail/OverviewSection.tsx @@ -25,6 +25,8 @@ interface OverviewSectionProps { userProfile?: any; showShareAction: boolean; handleShare: () => void; + isVisibilityEnabled: boolean; + handleVisibilityChange: () => void; } const OverviewSection: React.FC = ({ @@ -41,7 +43,9 @@ const OverviewSection: React.FC = ({ fontFamily, userProfile, showShareAction, - handleShare + handleShare, + isVisibilityEnabled, + handleVisibilityChange }) => { return ( @@ -64,6 +68,8 @@ const OverviewSection: React.FC = ({ handleCopyUrl={handleCopyUrl} showShareAction={showShareAction} handleShare={handleShare} + isVisibilityEnabled={isVisibilityEnabled} + handleVisibilityChange={handleVisibilityChange} /> diff --git a/src/custom/CatalogDetail/RightPanel.tsx b/src/custom/CatalogDetail/RightPanel.tsx index 98c83698d..027f7334f 100644 --- a/src/custom/CatalogDetail/RightPanel.tsx +++ b/src/custom/CatalogDetail/RightPanel.tsx @@ -28,6 +28,8 @@ interface RightPanelProps { fetchingOrgError: boolean; showShareAction: boolean; handleShare: () => void; + isVisibilityEnabled: boolean; + handleVisibilityChange: () => void; } const RightPanel: React.FC = ({ @@ -51,7 +53,9 @@ const RightPanel: React.FC = ({ orgName, fetchingOrgError, showShareAction, - handleShare + handleShare, + isVisibilityEnabled = false, + handleVisibilityChange }) => { const cleanedType = type.replace('my-', '').replace(/s$/, ''); const { data: userProfile } = useGetUserProfileByIdQuery({ @@ -75,6 +79,8 @@ const RightPanel: React.FC = ({ userProfile={userProfile} showShareAction={showShareAction} handleShare={handleShare} + isVisibilityEnabled={isVisibilityEnabled} + handleVisibilityChange={handleVisibilityChange} /> {showCaveats && } void; showShareAction: boolean; handleShare: () => void; + isVisibilityEnabled: boolean; + handleVisibilityChange: () => void; } const SocialSharePopper: React.FC = ({ @@ -38,7 +40,9 @@ const SocialSharePopper: React.FC = ({ title, getUrl, handleCopyUrl, - handleShare + handleShare, + isVisibilityEnabled, + handleVisibilityChange }) => { const theme = useTheme(); const [anchorEl, setAnchorEl] = useState(null); @@ -59,8 +63,8 @@ const SocialSharePopper: React.FC = ({ {}} - enabled={false} + onChange={handleVisibilityChange} + enabled={isVisibilityEnabled} options={[ [VIEW_VISIBILITY.PUBLIC, PublicIcon], [VIEW_VISIBILITY.PRIVATE, LockIcon] From 4617e90d9022a84d1cf0d948e1b08117c1465d57 Mon Sep 17 00:00:00 2001 From: Sudhanshu Dasgupta Date: Mon, 23 Dec 2024 13:13:15 +0530 Subject: [PATCH 2/3] fix(selector): prop for visibility change Signed-off-by: Sudhanshu Dasgupta --- src/custom/CatalogDetail/SocialSharePopper.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/custom/CatalogDetail/SocialSharePopper.tsx b/src/custom/CatalogDetail/SocialSharePopper.tsx index 23571b3dd..53cf79685 100644 --- a/src/custom/CatalogDetail/SocialSharePopper.tsx +++ b/src/custom/CatalogDetail/SocialSharePopper.tsx @@ -30,7 +30,7 @@ interface SocialSharePopperProps { showShareAction: boolean; handleShare: () => void; isVisibilityEnabled: boolean; - handleVisibilityChange: () => void; + handleVisibilityChange: (visibility: VIEW_VISIBILITY) => void; } const SocialSharePopper: React.FC = ({ @@ -63,7 +63,7 @@ const SocialSharePopper: React.FC = ({ handleVisibilityChange(value as VIEW_VISIBILITY)} enabled={isVisibilityEnabled} options={[ [VIEW_VISIBILITY.PUBLIC, PublicIcon], From 9455e313b539aca6f915504de90341d9df716c2e Mon Sep 17 00:00:00 2001 From: Sudhanshu Dasgupta Date: Mon, 23 Dec 2024 13:16:21 +0530 Subject: [PATCH 3/3] fix(prop): pass props correctly Signed-off-by: Sudhanshu Dasgupta --- src/custom/CatalogDetail/OverviewSection.tsx | 3 ++- src/custom/CatalogDetail/RightPanel.tsx | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/custom/CatalogDetail/OverviewSection.tsx b/src/custom/CatalogDetail/OverviewSection.tsx index ef0ffcf86..57b2cf661 100644 --- a/src/custom/CatalogDetail/OverviewSection.tsx +++ b/src/custom/CatalogDetail/OverviewSection.tsx @@ -1,6 +1,7 @@ import React from 'react'; import { Grid } from '../../base'; import { Pattern } from '../CustomCatalog/CustomCard'; +import { VIEW_VISIBILITY } from '../VisibilityChipMenu/VisibilityChipMenu'; import ContentClassInfo from './ContentClassInfo'; import MetricsDisplay from './MetricsDisplay'; import PatternInfo from './PatternInfo'; @@ -26,7 +27,7 @@ interface OverviewSectionProps { showShareAction: boolean; handleShare: () => void; isVisibilityEnabled: boolean; - handleVisibilityChange: () => void; + handleVisibilityChange: (visibility: VIEW_VISIBILITY) => void; } const OverviewSection: React.FC = ({ diff --git a/src/custom/CatalogDetail/RightPanel.tsx b/src/custom/CatalogDetail/RightPanel.tsx index 027f7334f..570119ab7 100644 --- a/src/custom/CatalogDetail/RightPanel.tsx +++ b/src/custom/CatalogDetail/RightPanel.tsx @@ -1,5 +1,6 @@ import React from 'react'; import { Pattern } from '../CustomCatalog/CustomCard'; +import { VIEW_VISIBILITY } from '../VisibilityChipMenu/VisibilityChipMenu'; import CaveatsSection from './CaveatsSection'; import OverviewSection from './OverviewSection'; import RelatedDesigns, { PatternsPerUser } from './RelatedDesigns'; @@ -29,7 +30,7 @@ interface RightPanelProps { showShareAction: boolean; handleShare: () => void; isVisibilityEnabled: boolean; - handleVisibilityChange: () => void; + handleVisibilityChange: (visibility: VIEW_VISIBILITY) => void; } const RightPanel: React.FC = ({