Skip to content

Commit 96a9b23

Browse files
authored
fix: flowise 370 (#6409)
* add: new executions:update permissions and apply it to PUT /api/v1/executions endpoint * add: executions:update permissions check in UI * fix: review feedback
1 parent f4e2794 commit 96a9b23

4 files changed

Lines changed: 28 additions & 19 deletions

File tree

packages/server/src/enterprise/rbac/Permissions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export class Permissions {
8888

8989
const executionsCategory = new PermissionCategory('executions')
9090
executionsCategory.addPermission(new Permission('executions:view', 'View', true, true, true))
91+
executionsCategory.addPermission(new Permission('executions:update', 'Update', true, true, true))
9192
executionsCategory.addPermission(new Permission('executions:delete', 'Delete', true, true, true))
9293
this.categories.push(executionsCategory)
9394

packages/server/src/routes/executions/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ router.get('/', checkAnyPermission('executions:view'), executionController.getAl
88
router.get(['/', '/:id'], checkAnyPermission('executions:view'), executionController.getExecutionById)
99

1010
// PUT
11-
router.put(['/', '/:id'], executionController.updateExecution)
11+
router.put(['/', '/:id'], checkAnyPermission('executions:update'), executionController.updateExecution)
1212

1313
// DELETE - single execution or multiple executions
1414
router.delete('/:id', checkAnyPermission('executions:delete'), executionController.deleteExecutions)

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

Lines changed: 20 additions & 15 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,21 +771,23 @@ 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 && (

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)