Skip to content

Commit 1e3a71c

Browse files
committed
add: executions:update permissions check in UI
1 parent 824d13d commit 1e3a71c

2 files changed

Lines changed: 43 additions & 33 deletions

File tree

packages/ui/src/views/agentexecutions/ExecutionDetails.jsx

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ import executionsApi from '@/api/executions'
4949
// Hooks
5050
import useApi from '@/hooks/useApi'
5151

52+
// RBAC
53+
import { Available } from '@/ui-component/rbac/available'
54+
5255
const getIconColor = (status) => {
5356
switch (status) {
5457
case 'FINISHED':
@@ -768,39 +771,43 @@ export const ExecutionDetails = ({ open, isPublic, execution, metadata, onClose,
768771
)}
769772

770773
{!isPublic && !localMetadata.isPublic && (
771-
<Chip
772-
sx={{ ml: 1, pl: 1 }}
773-
icon={
774-
updateExecutionApi.loading ? (
775-
<IconLoader size={15} className='spin-animation' />
776-
) : (
777-
<IconShare size={15} />
778-
)
779-
}
780-
variant='outlined'
781-
label={updateExecutionApi.loading ? 'Updating...' : 'Share'}
782-
className={'button'}
783-
onClick={() => onSharePublicly()}
784-
disabled={updateExecutionApi.loading}
785-
/>
774+
<Available permission='executions:update'>
775+
<Chip
776+
sx={{ ml: 1, pl: 1 }}
777+
icon={
778+
updateExecutionApi.loading ? (
779+
<IconLoader size={15} className='spin-animation' />
780+
) : (
781+
<IconShare size={15} />
782+
)
783+
}
784+
variant='outlined'
785+
label={updateExecutionApi.loading ? 'Updating...' : 'Share'}
786+
className={'button'}
787+
onClick={() => onSharePublicly()}
788+
disabled={updateExecutionApi.loading}
789+
/>
790+
</Available>
786791
)}
787792

788793
{!isPublic && localMetadata.isPublic && (
789-
<Chip
790-
sx={{ ml: 1, pl: 1 }}
791-
icon={
792-
updateExecutionApi.loading ? (
793-
<IconLoader size={15} className='spin-animation' />
794-
) : (
795-
<IconWorld size={15} />
796-
)
797-
}
798-
variant='outlined'
799-
label={updateExecutionApi.loading ? 'Updating...' : 'Public'}
800-
className={'button'}
801-
onClick={() => setShowShareDialog(true)}
802-
disabled={updateExecutionApi.loading}
803-
/>
794+
<Available permission='executions:update'>
795+
<Chip
796+
sx={{ ml: 1, pl: 1 }}
797+
icon={
798+
updateExecutionApi.loading ? (
799+
<IconLoader size={15} className='spin-animation' />
800+
) : (
801+
<IconWorld size={15} />
802+
)
803+
}
804+
variant='outlined'
805+
label={updateExecutionApi.loading ? 'Updating...' : 'Public'}
806+
className={'button'}
807+
onClick={() => setShowShareDialog(true)}
808+
disabled={updateExecutionApi.loading}
809+
/>
810+
</Available>
804811
)}
805812

806813
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', alignContent: 'center' }}>

packages/ui/src/views/agentexecutions/ShareExecutionDialog.jsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { enqueueSnackbar as enqueueSnackbarAction, closeSnackbar as closeSnackba
1414
// API
1515
import executionsApi from '@/api/executions'
1616
import useApi from '@/hooks/useApi'
17+
import { Available } from '@/ui-component/rbac/available'
1718

1819
const ShareExecutionDialog = ({ show, executionId, onClose, onUnshare }) => {
1920
const portalElement = document.getElementById('portal')
@@ -104,9 +105,11 @@ const ShareExecutionDialog = ({ show, executionId, onClose, onUnshare }) => {
104105

105106
{/* Actions */}
106107
<Box sx={{ display: 'flex', justifyContent: 'flex-end' }}>
107-
<Button color='error' onClick={handleUnshare} sx={{ mr: 1 }}>
108-
Unshare
109-
</Button>
108+
<Available permission='executions:update'>
109+
<Button color='error' onClick={handleUnshare} sx={{ mr: 1 }}>
110+
Unshare
111+
</Button>
112+
</Available>
110113
<Button onClick={onClose}>Close</Button>
111114
</Box>
112115
</DialogContent>

0 commit comments

Comments
 (0)