@@ -222,18 +222,6 @@ const ShareModal: React.FC<ShareModalProps> = ({
222222 }
223223 } , [ selectedResource ] ) ;
224224
225- useEffect ( ( ) => {
226- if ( selectedResource ?. visibility === 'published' ) {
227- setOption ( SHARE_MODE . PRIVATE ) ; // Force set to private if published
228- } else {
229- setOption ( selectedResource ?. visibility ) ;
230- }
231- } , [ selectedResource ] ) ;
232-
233- // Filter options dynamically to exclude PUBLIC when visibility is published
234- const filteredOptions =
235- selectedResource ?. visibility === 'published' ? [ SHARE_MODE . PRIVATE ] : Object . values ( SHARE_MODE ) ;
236-
237225 return (
238226 < div style = { { marginBottom : '1rem' } } >
239227 < Modal
@@ -256,52 +244,60 @@ const ShareModal: React.FC<ShareModalProps> = ({
256244 }
257245 fetchSuggestions = { fetchSuggestions }
258246 />
259- < CustomListItemText >
260- < Typography variant = "h6" > General Access</ Typography >
261- </ CustomListItemText >
262- < CustomDialogContentText >
263- < FormControlWrapper size = "small" >
264- < div style = { { display : 'flex' , justifyContent : 'start' , alignItems : 'center' } } >
265- < VisibilityIconWrapper >
266- { selectedOption === SHARE_MODE . PUBLIC ? (
267- < PublicIcon
268- width = { 24 }
269- height = { 24 }
270- stroke = { theme . palette . mode === 'dark' ? WHITE : BLACK }
271- />
272- ) : (
273- < LockIcon
274- width = { 24 }
275- height = { 24 }
276- stroke = { theme . palette . mode === 'dark' ? WHITE : BLACK }
277- />
278- ) }
279- </ VisibilityIconWrapper >
280- < div style = { { display : 'flex' , flexDirection : 'column' } } >
281- < CustomSelect
282- variant = "outlined"
283- defaultValue = { selectedOption }
284- labelId = "share-menu-select"
285- id = "share-menu"
286- open = { openMenu }
287- onClose = { handleMenuClose }
288- onOpen = { ( ) => setMenu ( true ) }
289- onChange = { handleOptionClick }
290- disabled = { isVisibilitySelectorDisabled }
291- >
292- { filteredOptions . map ( ( option ) => (
293- < MenuItem key = { option } selected = { option === selectedOption } value = { option } >
294- { option . charAt ( 0 ) . toUpperCase ( ) + option . slice ( 1 ) }
295- </ MenuItem >
296- ) ) }
297- </ CustomSelect >
298- < Typography component = "span" variant = "body2" >
299- { selectedOption === SHARE_MODE . PRIVATE ? options . PRIVATE : options . PUBLIC }
300- </ Typography >
301- </ div >
302- </ div >
303- </ FormControlWrapper >
304- </ CustomDialogContentText >
247+ { selectedResource ?. visibility !== 'published' && (
248+ < >
249+ < CustomListItemText >
250+ < Typography variant = "h6" > General Access</ Typography >
251+ </ CustomListItemText >
252+ < CustomDialogContentText >
253+ < FormControlWrapper size = "small" >
254+ < div style = { { display : 'flex' , justifyContent : 'start' , alignItems : 'center' } } >
255+ < VisibilityIconWrapper >
256+ { selectedOption === SHARE_MODE . PUBLIC ? (
257+ < PublicIcon
258+ width = { 24 }
259+ height = { 24 }
260+ stroke = { theme . palette . mode === 'dark' ? WHITE : BLACK }
261+ />
262+ ) : (
263+ < LockIcon
264+ width = { 24 }
265+ height = { 24 }
266+ stroke = { theme . palette . mode === 'dark' ? WHITE : BLACK }
267+ />
268+ ) }
269+ </ VisibilityIconWrapper >
270+ < div style = { { display : 'flex' , flexDirection : 'column' } } >
271+ < CustomSelect
272+ variant = "outlined"
273+ defaultValue = { selectedOption }
274+ labelId = "share-menu-select"
275+ id = "share-menu"
276+ open = { openMenu }
277+ onClose = { handleMenuClose }
278+ onOpen = { ( ) => setMenu ( true ) }
279+ onChange = { handleOptionClick }
280+ disabled = { isVisibilitySelectorDisabled }
281+ >
282+ { Object . values ( SHARE_MODE ) . map ( ( option ) => (
283+ < MenuItem
284+ key = { option }
285+ selected = { option === selectedOption }
286+ value = { option }
287+ >
288+ { option . charAt ( 0 ) . toUpperCase ( ) + option . slice ( 1 ) }
289+ </ MenuItem >
290+ ) ) }
291+ </ CustomSelect >
292+ < Typography component = "span" variant = "body2" >
293+ { selectedOption === SHARE_MODE . PRIVATE ? options . PRIVATE : options . PUBLIC }
294+ </ Typography >
295+ </ div >
296+ </ div >
297+ </ FormControlWrapper >
298+ </ CustomDialogContentText >
299+ </ >
300+ ) }
305301 </ ModalBody >
306302
307303 < ModalFooter
0 commit comments