Skip to content

Commit

Permalink
fix(editor): Hide execution buttons in readonly mode in new canvas (n…
Browse files Browse the repository at this point in the history
…o-changelog) (#10603)
  • Loading branch information
alexgrozav authored Aug 29, 2024
1 parent 78f34f6 commit 1491cbd
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions packages/editor-ui/src/views/NodeView.v2.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -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[]>(() =>
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 1491cbd

Please sign in to comment.