Skip to content

Commit

Permalink
fix(editor): RBAC frontend fixes (#9416)
Browse files Browse the repository at this point in the history
  • Loading branch information
cstuncsik authored May 16, 2024
1 parent 681c2bf commit 0f9fca6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
11 changes: 9 additions & 2 deletions packages/editor-ui/src/components/DeleteUserModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,16 @@
</el-radio>
<div v-if="operation === 'transfer'" :class="$style.optionInput">
<n8n-text color="text-dark">{{
$locale.baseText('projects.settings.delete.question.transfer.title')
$locale.baseText('settings.users.transferWorkflowsAndCredentials.user')
}}</n8n-text>
<ProjectSharing v-model="selectedProject" class="pt-2xs" :projects="projects" />
<ProjectSharing
v-model="selectedProject"
class="pt-2xs"
:projects="projects"
:placeholder="
$locale.baseText('settings.users.transferWorkflowsAndCredentials.placeholder')
"
/>
</div>
<el-radio v-model="operation" label="delete" @update:model-value="operation = 'delete'">
<n8n-text color="text-dark">{{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ const onExecutionsTab = computed(() => {
});
const workflowPermissions = computed<PermissionsMap<WorkflowScope>>(() => {
return getWorkflowPermissions(props.workflow);
return getWorkflowPermissions(workflowsStore.getWorkflowById(props.workflow.id));
});
const workflowMenuItems = computed<ActionDropdownItem[]>(() => {
Expand Down Expand Up @@ -178,7 +178,7 @@ const workflowMenuItems = computed<ActionDropdownItem[]>(() => {
disabled: !onWorkflowPage.value || isNewWorkflow.value,
});
if (workflowPermissions.value.delete && !props.readOnly) {
if ((workflowPermissions.value.delete && !props.readOnly) || isNewWorkflow.value) {
actions.push({
id: WORKFLOW_MENU_ACTIONS.DELETE,
label: locale.baseText('menuActions.delete'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const projectRoles = computed(() =>
name: projectRoleTranslations.value[role.role],
})),
);
const firstLicensedRole = computed(() => projectRoles.value.find((role) => role.licensed)?.role);
const onAddMember = (userId: string) => {
isDirty.value = true;
Expand All @@ -74,7 +75,9 @@ const onAddMember = (userId: string) => {
const { id, firstName, lastName, email } = user;
const relation = { id, firstName, lastName, email } as ProjectRelation;
relation.role = projectRoles.value[0].role;
if (firstLicensedRole.value) {
relation.role = firstLicensedRole.value;
}
formData.value.relations.push(relation);
};
Expand Down
4 changes: 3 additions & 1 deletion packages/editor-ui/src/plugins/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1578,7 +1578,9 @@
"settings.users.setupToInviteUsers": "To invite users, set up your own account",
"settings.users.setupToInviteUsersInfo": "Invited users won’t be able to see workflows and credentials of other users unless you upgrade. <a href=\"https://docs.n8n.io/user-management/\" target=\"_blank\">More info</a> <br /> <br />",
"settings.users.smtpToAddUsersWarning": "Set up SMTP before adding users (so that n8n can send them invitation emails). <a target=\"_blank\" href=\"https://docs.n8n.io/hosting/authentication/user-management-self-hosted/\">Instructions</a>",
"settings.users.transferWorkflowsAndCredentials": "Transfer their workflows and credentials to another project",
"settings.users.transferWorkflowsAndCredentials": "Transfer their workflows and credentials to another user",
"settings.users.transferWorkflowsAndCredentials.user": "User to transfer to",
"settings.users.transferWorkflowsAndCredentials.placeholder": "Select user",
"settings.users.transferredToUser": "Data transferred to {projectName}",
"settings.users.userDeleted": "User deleted",
"settings.users.userDeletedError": "Problem while deleting user",
Expand Down

0 comments on commit 0f9fca6

Please sign in to comment.