fix(editor): Connect up new project viewer role to the FE (#9913)
This commit is contained in:
@@ -38,6 +38,7 @@ describe('useContextMenu', () => {
|
||||
|
||||
workflowsStore = useWorkflowsStore();
|
||||
workflowsStore.workflow.nodes = nodes;
|
||||
workflowsStore.workflow.scopes = ['workflow:update'];
|
||||
vi.spyOn(workflowsStore, 'getCurrentWorkflow').mockReturnValue({
|
||||
nodes,
|
||||
getNode: (_: string) => {
|
||||
@@ -127,6 +128,7 @@ describe('useContextMenu', () => {
|
||||
describe('Read-only mode', () => {
|
||||
it('should return the correct actions when right clicking a sticky', () => {
|
||||
vi.spyOn(uiStore, 'isReadOnlyView', 'get').mockReturnValue(true);
|
||||
workflowsStore.workflow.scopes = ['workflow:read'];
|
||||
const { open, isOpen, actions, targetNodeIds } = useContextMenu();
|
||||
const sticky = nodeFactory({ type: STICKY_NODE_TYPE });
|
||||
vi.spyOn(workflowsStore, 'getNodeById').mockReturnValue(sticky);
|
||||
|
||||
@@ -10,6 +10,7 @@ import { getMousePosition } from '../utils/nodeViewUtils';
|
||||
import { useI18n } from './useI18n';
|
||||
import { usePinnedData } from './usePinnedData';
|
||||
import { isPresent } from '../utils/typesUtils';
|
||||
import { getResourcePermissions } from '@/permissions';
|
||||
|
||||
export type ContextMenuTarget =
|
||||
| { source: 'canvas'; nodeIds: string[] }
|
||||
@@ -46,8 +47,15 @@ export const useContextMenu = (onAction: ContextMenuActionCallback = () => {}) =
|
||||
|
||||
const i18n = useI18n();
|
||||
|
||||
const workflowPermissions = computed(
|
||||
() => getResourcePermissions(workflowsStore.workflow.scopes).workflow,
|
||||
);
|
||||
|
||||
const isReadOnly = computed(
|
||||
() => sourceControlStore.preferences.branchReadOnly || uiStore.isReadOnlyView,
|
||||
() =>
|
||||
sourceControlStore.preferences.branchReadOnly ||
|
||||
uiStore.isReadOnlyView ||
|
||||
!workflowPermissions.value.update,
|
||||
);
|
||||
|
||||
const targetNodeIds = computed(() => {
|
||||
|
||||
Reference in New Issue
Block a user