fix(editor): Replace isInstanceOwner checks with scopes where applicable (#7858)

Co-authored-by: Alex Grozav <alex@grozav.com>
This commit is contained in:
Csaba Tuncsik
2023-12-04 10:02:54 +01:00
committed by GitHub
parent 39fa8d21bb
commit 132d691cbf
21 changed files with 111 additions and 67 deletions

View File

@@ -184,6 +184,7 @@ import { getWorkflowPermissions } from '@/permissions';
import { createEventBus } from 'n8n-design-system/utils';
import { nodeViewEventBus } from '@/event-bus';
import { genericHelpers } from '@/mixins/genericHelpers';
import { hasPermission } from '@/rbac/permissions';
const hasChanged = (prev: string[], curr: string[]) => {
if (prev.length !== curr.length) {
@@ -247,10 +248,7 @@ export default defineComponent({
currentUser(): IUser | null {
return this.usersStore.currentUser;
},
currentUserIsOwner(): boolean {
return this.usersStore.currentUser?.isOwner ?? false;
},
contextBasedTranslationKeys(): NestedRecord<string> {
contextBasedTranslationKeys() {
return this.uiStore.contextBasedTranslationKeys;
},
isWorkflowActive(): boolean {
@@ -298,7 +296,7 @@ export default defineComponent({
].includes(this.$route.name || '');
},
workflowPermissions(): IPermissions {
return getWorkflowPermissions(this.usersStore.currentUser, this.workflow);
return getWorkflowPermissions(this.currentUser, this.workflow);
},
workflowMenuItems(): Array<{}> {
const actions = [
@@ -330,7 +328,7 @@ export default defineComponent({
);
}
if (this.currentUserIsOwner) {
if (hasPermission(['rbac'], { rbac: { scope: 'sourceControl:push' } })) {
actions.push({
id: WORKFLOW_MENU_ACTIONS.PUSH,
label: this.$locale.baseText('menuActions.push'),
@@ -338,8 +336,7 @@ export default defineComponent({
!this.sourceControlStore.isEnterpriseSourceControlEnabled ||
!this.onWorkflowPage ||
this.onExecutionsTab ||
this.readOnlyEnv ||
!this.currentUserIsOwner,
this.readOnlyEnv,
});
}