mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -08:00
fix: Don't show pin button in input panel when there's binary data (#11267)
This commit is contained in:
parent
fed7c3ec1f
commit
c0b5b92f62
|
@ -256,11 +256,19 @@ export default defineComponent({
|
||||||
return this.nodeTypesStore.isTriggerNode(this.node.type);
|
return this.nodeTypesStore.isTriggerNode(this.node.type);
|
||||||
},
|
},
|
||||||
showPinButton(): boolean {
|
showPinButton(): boolean {
|
||||||
return Boolean(
|
if (!this.rawInputData.length && !this.pinnedData.hasData.value) {
|
||||||
(this.canPinData || this.pinnedData.hasData.value || !!this.binaryData?.length) &&
|
return false;
|
||||||
(this.rawInputData.length || this.pinnedData.hasData.value) &&
|
}
|
||||||
!this.editMode.enabled,
|
|
||||||
);
|
if (this.editMode.enabled) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.binaryData?.length) {
|
||||||
|
return this.isPaneTypeOutput;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.canPinData;
|
||||||
},
|
},
|
||||||
pinButtonDisabled(): boolean {
|
pinButtonDisabled(): boolean {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -6,7 +6,7 @@ import RunData from '@/components/RunData.vue';
|
||||||
import { SET_NODE_TYPE, STORES, VIEWS } from '@/constants';
|
import { SET_NODE_TYPE, STORES, VIEWS } from '@/constants';
|
||||||
import { SETTINGS_STORE_DEFAULT_STATE } from '@/__tests__/utils';
|
import { SETTINGS_STORE_DEFAULT_STATE } from '@/__tests__/utils';
|
||||||
import { createComponentRenderer } from '@/__tests__/render';
|
import { createComponentRenderer } from '@/__tests__/render';
|
||||||
import type { INodeUi, IRunDataDisplayMode } from '@/Interface';
|
import type { INodeUi, IRunDataDisplayMode, NodePanelType } from '@/Interface';
|
||||||
import { useWorkflowsStore } from '@/stores/workflows.store';
|
import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||||
import { setActivePinia } from 'pinia';
|
import { setActivePinia } from 'pinia';
|
||||||
import { defaultNodeTypes } from '@/__tests__/mocks';
|
import { defaultNodeTypes } from '@/__tests__/mocks';
|
||||||
|
@ -24,6 +24,47 @@ const nodes = [
|
||||||
] as INodeUi[];
|
] as INodeUi[];
|
||||||
|
|
||||||
describe('RunData', () => {
|
describe('RunData', () => {
|
||||||
|
it("should render pin button in output panel disabled when there's binary data", () => {
|
||||||
|
const { getByTestId } = render(
|
||||||
|
[
|
||||||
|
{
|
||||||
|
json: {},
|
||||||
|
binary: {
|
||||||
|
data: {
|
||||||
|
fileName: 'test.xyz',
|
||||||
|
mimeType: 'application/octet-stream',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'binary',
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(getByTestId('ndv-pin-data')).toBeInTheDocument();
|
||||||
|
expect(getByTestId('ndv-pin-data')).toHaveAttribute('disabled');
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not render pin button in input panel when there's binary data", () => {
|
||||||
|
const { queryByTestId } = render(
|
||||||
|
[
|
||||||
|
{
|
||||||
|
json: {},
|
||||||
|
binary: {
|
||||||
|
data: {
|
||||||
|
fileName: 'test.xyz',
|
||||||
|
mimeType: 'application/octet-stream',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'binary',
|
||||||
|
undefined,
|
||||||
|
'input',
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(queryByTestId('ndv-pin-data')).not.toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
it('should render data correctly even when "item.json" has another "json" key', async () => {
|
it('should render data correctly even when "item.json" has another "json" key', async () => {
|
||||||
const { getByText, getAllByTestId, getByTestId } = render(
|
const { getByText, getAllByTestId, getByTestId } = render(
|
||||||
[
|
[
|
||||||
|
@ -117,6 +158,7 @@ describe('RunData', () => {
|
||||||
outputData: unknown[],
|
outputData: unknown[],
|
||||||
displayMode: IRunDataDisplayMode,
|
displayMode: IRunDataDisplayMode,
|
||||||
pinnedData?: INodeExecutionData[],
|
pinnedData?: INodeExecutionData[],
|
||||||
|
paneType: NodePanelType = 'output',
|
||||||
) => {
|
) => {
|
||||||
const pinia = createTestingPinia({
|
const pinia = createTestingPinia({
|
||||||
initialState: {
|
initialState: {
|
||||||
|
@ -196,6 +238,9 @@ describe('RunData', () => {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
global: {
|
global: {
|
||||||
|
stubs: {
|
||||||
|
RunDataPinButton: { template: '<button data-test-id="ndv-pin-data"></button>' },
|
||||||
|
},
|
||||||
mocks: {
|
mocks: {
|
||||||
$route: {
|
$route: {
|
||||||
name: VIEWS.WORKFLOW,
|
name: VIEWS.WORKFLOW,
|
||||||
|
@ -211,7 +256,7 @@ describe('RunData', () => {
|
||||||
},
|
},
|
||||||
nodes: [{ name: 'Test Node', indicies: [], depth: 1 }],
|
nodes: [{ name: 'Test Node', indicies: [], depth: 1 }],
|
||||||
runIndex: 0,
|
runIndex: 0,
|
||||||
paneType: 'output',
|
paneType,
|
||||||
isExecuting: false,
|
isExecuting: false,
|
||||||
mappingEnabled: true,
|
mappingEnabled: true,
|
||||||
distanceFromActive: 0,
|
distanceFromActive: 0,
|
||||||
|
|
Loading…
Reference in a new issue