mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -08:00
fix(editor): Plus node button should not be visible on readonly mode (#10692)
Some checks are pending
Test Master / install-and-build (push) Waiting to run
Test Master / Unit tests (18.x) (push) Blocked by required conditions
Test Master / Unit tests (20.x) (push) Blocked by required conditions
Test Master / Unit tests (22.4) (push) Blocked by required conditions
Test Master / Lint (push) Blocked by required conditions
Test Master / Notify Slack on failure (push) Blocked by required conditions
Some checks are pending
Test Master / install-and-build (push) Waiting to run
Test Master / Unit tests (18.x) (push) Blocked by required conditions
Test Master / Unit tests (20.x) (push) Blocked by required conditions
Test Master / Unit tests (22.4) (push) Blocked by required conditions
Test Master / Lint (push) Blocked by required conditions
Test Master / Notify Slack on failure (push) Blocked by required conditions
This commit is contained in:
parent
3adbcab27d
commit
62cb189985
|
@ -121,12 +121,14 @@ export function createCanvasHandleProvide({
|
||||||
type = NodeConnectionType.Main,
|
type = NodeConnectionType.Main,
|
||||||
isConnected = false,
|
isConnected = false,
|
||||||
isConnecting = false,
|
isConnecting = false,
|
||||||
|
isReadOnly = false,
|
||||||
}: {
|
}: {
|
||||||
label?: string;
|
label?: string;
|
||||||
mode?: CanvasConnectionMode;
|
mode?: CanvasConnectionMode;
|
||||||
type?: NodeConnectionType;
|
type?: NodeConnectionType;
|
||||||
isConnected?: boolean;
|
isConnected?: boolean;
|
||||||
isConnecting?: boolean;
|
isConnecting?: boolean;
|
||||||
|
isReadOnly?: boolean;
|
||||||
} = {}) {
|
} = {}) {
|
||||||
return {
|
return {
|
||||||
[`${CanvasNodeHandleKey}`]: {
|
[`${CanvasNodeHandleKey}`]: {
|
||||||
|
@ -135,6 +137,7 @@ export function createCanvasHandleProvide({
|
||||||
type: ref(type),
|
type: ref(type),
|
||||||
isConnected: ref(isConnected),
|
isConnected: ref(isConnected),
|
||||||
isConnecting: ref(isConnecting),
|
isConnecting: ref(isConnecting),
|
||||||
|
isReadOnly: ref(isReadOnly),
|
||||||
} satisfies CanvasNodeHandleInjectionData,
|
} satisfies CanvasNodeHandleInjectionData,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ const props = defineProps<{
|
||||||
mode: CanvasConnectionMode;
|
mode: CanvasConnectionMode;
|
||||||
isConnected?: boolean;
|
isConnected?: boolean;
|
||||||
isConnecting?: boolean;
|
isConnecting?: boolean;
|
||||||
|
isReadOnly?: boolean;
|
||||||
label?: string;
|
label?: string;
|
||||||
type: CanvasConnectionPort['type'];
|
type: CanvasConnectionPort['type'];
|
||||||
index: CanvasConnectionPort['index'];
|
index: CanvasConnectionPort['index'];
|
||||||
|
@ -99,6 +100,7 @@ function onAdd() {
|
||||||
const label = toRef(props, 'label');
|
const label = toRef(props, 'label');
|
||||||
const isConnected = toRef(props, 'isConnected');
|
const isConnected = toRef(props, 'isConnected');
|
||||||
const isConnecting = toRef(props, 'isConnecting');
|
const isConnecting = toRef(props, 'isConnecting');
|
||||||
|
const isReadOnly = toRef(props, 'isReadOnly');
|
||||||
const mode = toRef(props, 'mode');
|
const mode = toRef(props, 'mode');
|
||||||
const type = toRef(props, 'type');
|
const type = toRef(props, 'type');
|
||||||
|
|
||||||
|
@ -108,6 +110,7 @@ provide(CanvasNodeHandleKey, {
|
||||||
type,
|
type,
|
||||||
isConnected,
|
isConnected,
|
||||||
isConnecting,
|
isConnecting,
|
||||||
|
isReadOnly,
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ const renderComponent = createComponentRenderer(CanvasHandleMainOutput);
|
||||||
describe('CanvasHandleMainOutput', () => {
|
describe('CanvasHandleMainOutput', () => {
|
||||||
it('should render correctly', async () => {
|
it('should render correctly', async () => {
|
||||||
const label = 'Test Label';
|
const label = 'Test Label';
|
||||||
const { container, getByText } = renderComponent({
|
const { container, getByText, getByTestId } = renderComponent({
|
||||||
global: {
|
global: {
|
||||||
provide: {
|
provide: {
|
||||||
...createCanvasHandleProvide({ label }),
|
...createCanvasHandleProvide({ label }),
|
||||||
|
@ -16,6 +16,19 @@ describe('CanvasHandleMainOutput', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(container.querySelector('.canvas-node-handle-main-output')).toBeInTheDocument();
|
expect(container.querySelector('.canvas-node-handle-main-output')).toBeInTheDocument();
|
||||||
|
expect(getByTestId('canvas-handle-plus')).toBeInTheDocument();
|
||||||
expect(getByText(label)).toBeInTheDocument();
|
expect(getByText(label)).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not render CanvasHandlePlus when isReadOnly', () => {
|
||||||
|
const { queryByTestId } = renderComponent({
|
||||||
|
global: {
|
||||||
|
provide: {
|
||||||
|
...createCanvasHandleProvide({ isReadOnly: true }),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(queryByTestId('canvas-handle-plus')).not.toBeInTheDocument();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,7 +9,7 @@ const emit = defineEmits<{
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const { render } = useCanvasNode();
|
const { render } = useCanvasNode();
|
||||||
const { label, isConnected, isConnecting } = useCanvasNodeHandle();
|
const { label, isConnected, isConnecting, isReadOnly } = useCanvasNodeHandle();
|
||||||
|
|
||||||
const handleClasses = 'source';
|
const handleClasses = 'source';
|
||||||
const isHovered = ref(false);
|
const isHovered = ref(false);
|
||||||
|
@ -45,8 +45,9 @@ function onClickAdd() {
|
||||||
<CanvasHandleDot :handle-classes="handleClasses" />
|
<CanvasHandleDot :handle-classes="handleClasses" />
|
||||||
<Transition name="canvas-node-handle-main-output">
|
<Transition name="canvas-node-handle-main-output">
|
||||||
<CanvasHandlePlus
|
<CanvasHandlePlus
|
||||||
v-if="!isConnected"
|
v-if="!isConnected && !isReadOnly"
|
||||||
v-show="isHandlePlusVisible"
|
v-show="isHandlePlusVisible"
|
||||||
|
data-test-id="canvas-handle-plus"
|
||||||
:line-size="plusLineSize"
|
:line-size="plusLineSize"
|
||||||
:handle-classes="handleClasses"
|
:handle-classes="handleClasses"
|
||||||
@mouseenter="onMouseEnter"
|
@mouseenter="onMouseEnter"
|
||||||
|
|
|
@ -271,6 +271,7 @@ onBeforeUnmount(() => {
|
||||||
:offset="source.offset"
|
:offset="source.offset"
|
||||||
:is-connected="source.isConnected"
|
:is-connected="source.isConnected"
|
||||||
:is-connecting="source.isConnecting"
|
:is-connecting="source.isConnecting"
|
||||||
|
:is-read-only="readOnly"
|
||||||
:is-valid-connection="isValidConnection"
|
:is-valid-connection="isValidConnection"
|
||||||
@add="onAdd"
|
@add="onAdd"
|
||||||
/>
|
/>
|
||||||
|
@ -287,6 +288,7 @@ onBeforeUnmount(() => {
|
||||||
:offset="target.offset"
|
:offset="target.offset"
|
||||||
:is-connected="target.isConnected"
|
:is-connected="target.isConnected"
|
||||||
:is-connecting="target.isConnecting"
|
:is-connecting="target.isConnecting"
|
||||||
|
:is-read-only="readOnly"
|
||||||
:is-valid-connection="isValidConnection"
|
:is-valid-connection="isValidConnection"
|
||||||
@add="onAdd"
|
@add="onAdd"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -16,11 +16,13 @@ export function useCanvasNodeHandle() {
|
||||||
const isConnecting = computed(() => handle?.isConnecting.value ?? false);
|
const isConnecting = computed(() => handle?.isConnecting.value ?? false);
|
||||||
const type = computed(() => handle?.type.value ?? NodeConnectionType.Main);
|
const type = computed(() => handle?.type.value ?? NodeConnectionType.Main);
|
||||||
const mode = computed(() => handle?.mode.value ?? CanvasConnectionMode.Input);
|
const mode = computed(() => handle?.mode.value ?? CanvasConnectionMode.Input);
|
||||||
|
const isReadOnly = computed(() => handle?.isReadOnly.value);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
label,
|
label,
|
||||||
isConnected,
|
isConnected,
|
||||||
isConnecting,
|
isConnecting,
|
||||||
|
isReadOnly,
|
||||||
type,
|
type,
|
||||||
mode,
|
mode,
|
||||||
};
|
};
|
||||||
|
|
|
@ -165,6 +165,7 @@ export interface CanvasNodeHandleInjectionData {
|
||||||
type: Ref<NodeConnectionType>;
|
type: Ref<NodeConnectionType>;
|
||||||
isConnected: Ref<boolean | undefined>;
|
isConnected: Ref<boolean | undefined>;
|
||||||
isConnecting: Ref<boolean | undefined>;
|
isConnecting: Ref<boolean | undefined>;
|
||||||
|
isReadOnly: Ref<boolean | undefined>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ConnectStartEvent = { handleId: string; handleType: string; nodeId: string };
|
export type ConnectStartEvent = { handleId: string; handleType: string; nodeId: string };
|
||||||
|
|
Loading…
Reference in a new issue