mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-19 11:01:15 +00:00
feat: RBAC (#8922)
Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> Co-authored-by: Val <68596159+valya@users.noreply.github.com> Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in> Co-authored-by: Valya Bullions <valya@n8n.io> Co-authored-by: Danny Martini <danny@n8n.io> Co-authored-by: Danny Martini <despair.blue@gmail.com> Co-authored-by: Iván Ovejero <ivov.src@gmail.com> Co-authored-by: Omar Ajoue <krynble@gmail.com> Co-authored-by: oleg <me@olegivaniv.com> Co-authored-by: Michael Kret <michael.k@radency.com> Co-authored-by: Michael Kret <88898367+michael-radency@users.noreply.github.com> Co-authored-by: Elias Meire <elias@meire.dev> Co-authored-by: Giulio Andreini <andreini@netseven.it> Co-authored-by: Giulio Andreini <g.andreini@gmail.com> Co-authored-by: Ayato Hayashi <go12limchangyong@gmail.com>
This commit is contained in:
@@ -57,8 +57,6 @@ import Modal from '@/components/Modal.vue';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||
import type { IWorkflowDataUpdate } from '@/Interface';
|
||||
import type { IPermissions } from '@/permissions';
|
||||
import { getWorkflowPermissions } from '@/permissions';
|
||||
import { useUsersStore } from '@/stores/users.store';
|
||||
import { createEventBus } from 'n8n-design-system/utils';
|
||||
import { useCredentialsStore } from '@/stores/credentials.store';
|
||||
@@ -98,20 +96,6 @@ export default defineComponent({
|
||||
},
|
||||
computed: {
|
||||
...mapStores(useCredentialsStore, useUsersStore, useSettingsStore, useWorkflowsStore),
|
||||
workflowPermissions(): IPermissions {
|
||||
const isEmptyWorkflow = this.data.id === PLACEHOLDER_EMPTY_WORKFLOW_ID;
|
||||
const isCurrentWorkflowEmpty =
|
||||
this.workflowsStore.workflow.id === PLACEHOLDER_EMPTY_WORKFLOW_ID;
|
||||
|
||||
// If the workflow to be duplicated is empty and the current workflow is also empty
|
||||
// we need to use the current workflow to get the permissions
|
||||
const currentWorkflow =
|
||||
isEmptyWorkflow && isCurrentWorkflowEmpty
|
||||
? this.workflowsStore.workflow
|
||||
: this.workflowsStore.getWorkflowById(this.data.id);
|
||||
|
||||
return getWorkflowPermissions(this.usersStore.currentUser, currentWorkflow);
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
isActive(active) {
|
||||
@@ -156,8 +140,15 @@ export default defineComponent({
|
||||
try {
|
||||
let workflowToUpdate: IWorkflowDataUpdate | undefined;
|
||||
if (currentWorkflowId !== PLACEHOLDER_EMPTY_WORKFLOW_ID) {
|
||||
const { createdAt, updatedAt, usedCredentials, ...workflow } =
|
||||
await this.workflowsStore.fetchWorkflow(this.data.id);
|
||||
const {
|
||||
createdAt,
|
||||
updatedAt,
|
||||
usedCredentials,
|
||||
id,
|
||||
homeProject,
|
||||
sharedWithProjects,
|
||||
...workflow
|
||||
} = await this.workflowsStore.fetchWorkflow(this.data.id);
|
||||
workflowToUpdate = workflow;
|
||||
|
||||
this.workflowHelpers.removeForeignCredentialsFromWorkflow(
|
||||
@@ -180,7 +171,7 @@ export default defineComponent({
|
||||
this.$telemetry.track('User duplicated workflow', {
|
||||
old_workflow_id: currentWorkflowId,
|
||||
workflow_id: this.data.id,
|
||||
sharing_role: this.workflowPermissions.isOwner ? 'owner' : 'sharee',
|
||||
sharing_role: this.workflowHelpers.getWorkflowProjectRole(this.data.id),
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user