refactor: Improve warnings and error messages to users about sharing (#4687) (no-changelog)
* refactor: Improve warnings and error messages to users about sharing
This commit is contained in:
@@ -87,7 +87,7 @@ EEWorkflowController.get(
|
||||
|
||||
if (!workflow) {
|
||||
throw new ResponseHelper.ResponseError(
|
||||
`Workflow with ID "${workflowId}" could not be found.`,
|
||||
`Workflow with ID "${workflowId}" does not exist`,
|
||||
undefined,
|
||||
404,
|
||||
);
|
||||
@@ -96,7 +96,11 @@ EEWorkflowController.get(
|
||||
const userSharing = workflow.shared?.find((shared) => shared.user.id === req.user.id);
|
||||
|
||||
if (!userSharing && req.user.globalRole.name !== 'owner') {
|
||||
throw new ResponseHelper.ResponseError(`Forbidden.`, undefined, 403);
|
||||
throw new ResponseHelper.ResponseError(
|
||||
'It looks like you cannot access this workflow. Ask the owner to share it with you.',
|
||||
undefined,
|
||||
403,
|
||||
);
|
||||
}
|
||||
|
||||
return EEWorkflows.addCredentialsToWorkflow(
|
||||
@@ -140,7 +144,7 @@ EEWorkflowController.post(
|
||||
EEWorkflows.validateCredentialPermissionsToUser(newWorkflow, allCredentials);
|
||||
} catch (error) {
|
||||
throw new ResponseHelper.ResponseError(
|
||||
'The workflow contains credentials that you do not have access to',
|
||||
'The workflow you are trying to save contains credentials that are not shared with you',
|
||||
undefined,
|
||||
400,
|
||||
);
|
||||
@@ -169,7 +173,9 @@ EEWorkflowController.post(
|
||||
|
||||
if (!savedWorkflow) {
|
||||
LoggerProxy.error('Failed to create workflow', { userId: req.user.id });
|
||||
throw new ResponseHelper.ResponseError('Failed to save workflow');
|
||||
throw new ResponseHelper.ResponseError(
|
||||
'An error occurred while saving your workflow. Please try again.',
|
||||
);
|
||||
}
|
||||
|
||||
if (tagIds && !config.getEnv('workflowTagsDisabled') && savedWorkflow.tags) {
|
||||
|
||||
@@ -223,7 +223,7 @@ workflowsController.get(
|
||||
userId: req.user.id,
|
||||
});
|
||||
throw new ResponseHelper.ResponseError(
|
||||
`Workflow with ID "${workflowId}" could not be found.`,
|
||||
'Could not load the workflow - you can only access workflows owned by you',
|
||||
undefined,
|
||||
404,
|
||||
);
|
||||
@@ -298,7 +298,7 @@ workflowsController.delete(
|
||||
userId: req.user.id,
|
||||
});
|
||||
throw new ResponseHelper.ResponseError(
|
||||
`Workflow with ID "${workflowId}" could not be found to be deleted.`,
|
||||
'Could not delete the workflow - you can only remove workflows owned by you',
|
||||
undefined,
|
||||
400,
|
||||
);
|
||||
|
||||
@@ -197,7 +197,7 @@ export class WorkflowsService {
|
||||
userId: user.id,
|
||||
});
|
||||
throw new ResponseHelper.ResponseError(
|
||||
`Workflow with ID "${workflowId}" could not be found to be updated.`,
|
||||
'You do not have permission to update this workflow. Ask the owner to share it with you.',
|
||||
undefined,
|
||||
404,
|
||||
);
|
||||
@@ -205,7 +205,7 @@ export class WorkflowsService {
|
||||
|
||||
if (!forceSave && workflow.hash !== '' && workflow.hash !== shared.workflow.hash) {
|
||||
throw new ResponseHelper.ResponseError(
|
||||
`Workflow ID ${workflowId} cannot be saved because it was changed by another user.`,
|
||||
'We are sorry, but the workflow has been changed in the meantime. Please reload the workflow and try again.',
|
||||
undefined,
|
||||
400,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user