fix(editor): Hide execution buttons in readonly mode in new canvas (no-changelog) (#10603)

This commit is contained in:
Alex Grozav 2024-08-29 16:31:45 +03:00 committed by GitHub
parent 78f34f66c6
commit 1491cbd228
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -96,6 +96,7 @@ import { createEventBus } from 'n8n-design-system';
import type { PinDataSource } from '@/composables/usePinnedData';
import { useClipboard } from '@/composables/useClipboard';
import { useBeforeUnload } from '@/composables/useBeforeUnload';
import { getResourcePermissions } from '@/permissions';
const LazyNodeCreation = defineAsyncComponent(
async () => await import('@/components/Node/NodeCreation.vue'),
@ -203,7 +204,11 @@ const isReadOnlyEnvironment = computed(() => {
});
const isCanvasReadOnly = computed(() => {
return isDemoRoute.value || isReadOnlyEnvironment.value;
return (
isDemoRoute.value ||
isReadOnlyEnvironment.value ||
!(workflowPermissions.value.update ?? projectPermissions.value.workflow.update)
);
});
const fallbackNodes = computed<INodeUi[]>(() =>
@ -885,6 +890,21 @@ function onClickConnectionAdd(connection: Connection) {
});
}
/**
* Permissions
*/
const workflowPermissions = computed(() => {
return getResourcePermissions(workflowsStore.getWorkflowById(workflowId.value)?.scopes).workflow;
});
const projectPermissions = computed(() => {
const project = route.query?.projectId
? projectsStore.myProjects.find((p) => p.id === route.query.projectId)
: projectsStore.currentProject ?? projectsStore.personalProject;
return getResourcePermissions(project?.scopes);
});
/**
* Executions
*/
@ -1516,7 +1536,7 @@ onDeactivated(() => {
@create:workflow="onCreateWorkflow"
@viewport-change="onViewportChange"
>
<div :class="$style.executionButtons">
<div v-if="!isCanvasReadOnly" :class="$style.executionButtons">
<CanvasRunWorkflowButton
:waiting-for-webhook="isExecutionWaitingForWebhook"
:disabled="isExecutionDisabled"