Skip to content

Commit 0a38c19

Browse files
Merge pull request #1410 from Rajesh-Nagarajan-11/workspace-card-
[UI] Hide workspace actions for non-permitted users
2 parents b0f66da + 2edd38b commit 0a38c19

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

src/custom/Workspaces/WorkspaceCard.tsx

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -346,19 +346,19 @@ const CardBack = ({
346346
isEditWorkspaceAllowed
347347
}: CardBackProps) => {
348348
const isWorkspaceSelected = selectedWorkspaces?.includes(workspaceId);
349-
const isEditButtonDisabled = isWorkspaceSelected ? true : !isEditWorkspaceAllowed;
350-
const isDeleteButtonDisabled = isWorkspaceSelected ? true : !isDeleteWorkspaceAllowed;
351349

352350
const theme = useTheme();
353351
return (
354352
<CardBackWrapper elevation={2} onClick={onFlipBack}>
355353
<CardBackTopGrid size={12}>
356354
<CardBackTitleGrid size={6}>
357-
<BulkSelectCheckbox
358-
onClick={(e) => e.stopPropagation()}
359-
onChange={onSelect}
360-
disabled={deleted ? true : !isDeleteWorkspaceAllowed}
361-
/>
355+
{isDeleteWorkspaceAllowed && (
356+
<BulkSelectCheckbox
357+
onClick={(e) => e.stopPropagation()}
358+
onChange={onSelect}
359+
disabled={deleted}
360+
/>
361+
)}
362362
<CardTitle
363363
sx={{ color: theme.palette.background.constant?.white }}
364364
variant="body2"
@@ -368,18 +368,20 @@ const CardBack = ({
368368
</CardTitle>
369369
</CardBackTitleGrid>
370370
<CardBackActionsGrid size={6}>
371-
<L5EditIcon
372-
onClick={onEdit}
373-
disabled={isEditButtonDisabled}
374-
style={{ fill: theme.palette.background.constant?.white }}
375-
bulk={true}
376-
/>
377-
<L5DeleteIcon
378-
onClick={onDelete}
379-
style={{ fill: theme.palette.background.constant?.white }}
380-
disabled={isDeleteButtonDisabled}
381-
bulk={true}
382-
/>
371+
{!isWorkspaceSelected && isEditWorkspaceAllowed && (
372+
<L5EditIcon
373+
onClick={onEdit}
374+
style={{ fill: theme.palette.background.constant?.white }}
375+
bulk={true}
376+
/>
377+
)}
378+
{!isWorkspaceSelected && isDeleteWorkspaceAllowed && (
379+
<L5DeleteIcon
380+
onClick={onDelete}
381+
style={{ fill: theme.palette.background.constant?.white }}
382+
bulk={true}
383+
/>
384+
)}
383385
</CardBackActionsGrid>
384386
</CardBackTopGrid>
385387
<Grid2 sx={{ display: 'flex', alignItems: 'center', flexDirection: 'row' }}>

0 commit comments

Comments
 (0)