diff --git a/src/custom/CatalogDetail/ActionButton.tsx b/src/custom/CatalogDetail/ActionButton.tsx index 76d14edd..d1fa7149 100644 --- a/src/custom/CatalogDetail/ActionButton.tsx +++ b/src/custom/CatalogDetail/ActionButton.tsx @@ -1,6 +1,13 @@ import React from 'react'; import { CircularProgress } from '../../base'; -import { CopyIcon, EditIcon, KanvasIcon, PublishIcon } from '../../icons'; +import { + CopyIcon, + DeleteIcon, + EditIcon, + KanvasIcon, + PublishIcon, + ShareLineIcon +} from '../../icons'; import Download from '../../icons/Download/Download'; import { charcoal, useTheme } from '../../theme'; import { Pattern } from '../CustomCatalog/CustomCard'; @@ -21,6 +28,10 @@ interface ActionButtonsProps { onOpenPlaygroundClick: (designId: string, name: string) => void; showInfoAction?: boolean; handleInfoClick?: () => void; + showShareAction?: boolean; + handleShare: () => void; + showDeleteAction?: boolean; + handleDelete: () => void; } const ActionButtons: React.FC = ({ @@ -35,7 +46,11 @@ const ActionButtons: React.FC = ({ showOpenPlaygroundAction, onOpenPlaygroundClick, showInfoAction, - handleInfoClick + handleInfoClick, + showShareAction, + handleShare, + showDeleteAction, + handleDelete }) => { const cleanedType = type.replace('my-', '').replace(/s$/, ''); const theme = useTheme(); @@ -132,23 +147,51 @@ const ActionButtons: React.FC = ({ }} onClick={handleInfoClick} > - + Edit )} - {showUnpublishAction && ( + {showShareAction && ( + + + Share + + )} + {showDeleteAction && ( - - Unpublish + + Delete )} + + {showUnpublishAction && ( + + + Unpublish + + )} ); }; diff --git a/src/custom/CatalogDetail/LeftPanel.tsx b/src/custom/CatalogDetail/LeftPanel.tsx index 82d7fe99..57d2d698 100644 --- a/src/custom/CatalogDetail/LeftPanel.tsx +++ b/src/custom/CatalogDetail/LeftPanel.tsx @@ -25,6 +25,10 @@ interface LeftPanelProps { onOpenPlaygroundClick: (designId: string, name: string) => void; showInfoAction?: boolean; handleInfoClick?: () => void; + showShareAction?: boolean; + handleShare: () => void; + showDeleteAction?: boolean; + handleDelete: () => void; } const LeftPanel: React.FC = ({ @@ -44,7 +48,11 @@ const LeftPanel: React.FC = ({ showOpenPlaygroundAction = true, onOpenPlaygroundClick, showInfoAction = false, - handleInfoClick + handleInfoClick, + showShareAction = false, + handleShare, + showDeleteAction = false, + handleDelete }) => { const theme = useTheme(); @@ -89,6 +97,10 @@ const LeftPanel: React.FC = ({ onOpenPlaygroundClick={onOpenPlaygroundClick} showInfoAction={showInfoAction} handleInfoClick={handleInfoClick} + showShareAction={showShareAction} + handleShare={handleShare} + showDeleteAction={showDeleteAction} + handleDelete={handleDelete} /> {showTechnologies && ( = ({ cardId, title, getUrl, - handleCopyUrl, - showShareAction, - handleShare + handleCopyUrl }) => { const theme = useTheme(); const [anchorEl, setAnchorEl] = useState(null); @@ -55,41 +61,19 @@ const SocialSharePopper: React.FC = ({ onChange={() => {}} enabled={false} options={[ - [VIEW_VISIBILITY.PUBLIC, Public], - [VIEW_VISIBILITY.PRIVATE, Lock] + [VIEW_VISIBILITY.PUBLIC, PublicIcon], + [VIEW_VISIBILITY.PRIVATE, LockIcon] ]} /> - {showShareAction ? ( - - - - Share - - - - handleCopyUrl(cleanedType, details?.name, details?.id)} - > - - - - - ) : ( - <> - {details?.visibility !== 'private' && ( - - handleCopyUrl(cleanedType, details?.name, details?.id)} - > - - - - )} - - )} + + + handleCopyUrl(cleanedType, details?.name, details?.id)} + > + + + {(details?.visibility === 'published' || details?.visibility === 'public') && ( <> diff --git a/src/custom/ShareModal/ShareModal.tsx b/src/custom/ShareModal/ShareModal.tsx index fd8213d9..6150249c 100644 --- a/src/custom/ShareModal/ShareModal.tsx +++ b/src/custom/ShareModal/ShareModal.tsx @@ -14,6 +14,7 @@ import { import { ChainIcon, DeleteIcon, LockIcon, PublicIcon } from '../../icons'; import { useTheme } from '../../theme'; import { BLACK, WHITE } from '../../theme/colors'; +import { CustomTooltip } from '../CustomTooltip'; import { Modal, ModalBody, ModalButtonPrimary, ModalButtonSecondary, ModalFooter } from '../Modal'; import UserShareSearch from '../UserSearchField/UserSearchField'; import { @@ -97,13 +98,15 @@ const AccessList: React.FC = ({ {ownerData.id === actorData.id ? (
Owner
) : ( - handleDelete(actorData.email)} - > - - + + handleDelete(actorData.email)} + > + + + )} @@ -185,6 +188,9 @@ const ShareModal: React.FC = ({ const handleMenuClose = () => setMenu(false); const isShareDisabled = () => { + // Ensure at least one user other than the owner is selected + const otherUsersSelected = shareUserData.some((user) => user.id !== ownerData.id); + const existingAccessIds = shareUserData.map((user) => user.id); const ownerDataId = ownerData?.id; @@ -195,10 +201,10 @@ const ShareModal: React.FC = ({ const hasMismatchedUsers = !shareUserData.every((user) => existingAccessIds.includes(user.id)); return ( - shareUserData.length === existingAccessIds.length && - !hasMismatchedUsers && - (selectedOption === selectedResource?.visibility || - shareUserData.length !== existingAccessIds.length) + !otherUsersSelected || // Disable if no other users are selected + (shareUserData.length === existingAccessIds.length && + !hasMismatchedUsers && + selectedOption === selectedResource?.visibility) ); }; @@ -238,52 +244,60 @@ const ShareModal: React.FC = ({ } fetchSuggestions={fetchSuggestions} /> - - General Access - - - -
- - {selectedOption === SHARE_MODE.PUBLIC ? ( - - ) : ( - - )} - -
- setMenu(true)} - onChange={handleOptionClick} - disabled={isVisibilitySelectorDisabled} - > - {Object.values(SHARE_MODE).map((option) => ( - - {option.charAt(0).toUpperCase() + option.slice(1)} - - ))} - - - {selectedOption === SHARE_MODE.PRIVATE ? options.PRIVATE : options.PUBLIC} - -
-
-
-
+ {selectedResource?.visibility !== 'published' && ( + <> + + General Access + + + +
+ + {selectedOption === SHARE_MODE.PUBLIC ? ( + + ) : ( + + )} + +
+ setMenu(true)} + onChange={handleOptionClick} + disabled={isVisibilitySelectorDisabled} + > + {Object.values(SHARE_MODE).map((option) => ( + + {option.charAt(0).toUpperCase() + option.slice(1)} + + ))} + + + {selectedOption === SHARE_MODE.PRIVATE ? options.PRIVATE : options.PUBLIC} + +
+
+
+
+ + )}