mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(editor): Fix pin data button disappearing after reload (#11198)
This commit is contained in:
parent
fcf8629c6e
commit
3b2f63e248
|
@ -117,7 +117,8 @@ describe('Debug', () => {
|
||||||
workflowPage.getters.canvasNodes().last().find('.node-info-icon').should('be.empty');
|
workflowPage.getters.canvasNodes().last().find('.node-info-icon').should('be.empty');
|
||||||
|
|
||||||
workflowPage.getters.canvasNodes().first().dblclick();
|
workflowPage.getters.canvasNodes().first().dblclick();
|
||||||
ndv.getters.pinDataButton().click();
|
ndv.actions.unPinData();
|
||||||
|
|
||||||
ndv.actions.close();
|
ndv.actions.close();
|
||||||
|
|
||||||
workflowPage.actions.saveWorkflowUsingKeyboardShortcut();
|
workflowPage.actions.saveWorkflowUsingKeyboardShortcut();
|
||||||
|
|
|
@ -20,7 +20,8 @@ export class NDV extends BasePage {
|
||||||
outputDataContainer: () => this.getters.outputPanel().findChildByTestId('ndv-data-container'),
|
outputDataContainer: () => this.getters.outputPanel().findChildByTestId('ndv-data-container'),
|
||||||
outputDisplayMode: () =>
|
outputDisplayMode: () =>
|
||||||
this.getters.outputPanel().findChildByTestId('ndv-run-data-display-mode').first(),
|
this.getters.outputPanel().findChildByTestId('ndv-run-data-display-mode').first(),
|
||||||
pinDataButton: () => cy.getByTestId('ndv-pin-data'),
|
pinDataButton: () => this.getters.outputPanel().findChildByTestId('ndv-pin-data'),
|
||||||
|
unpinDataLink: () => this.getters.outputPanel().findChildByTestId('ndv-unpin-data'),
|
||||||
editPinnedDataButton: () => cy.getByTestId('ndv-edit-pinned-data'),
|
editPinnedDataButton: () => cy.getByTestId('ndv-edit-pinned-data'),
|
||||||
pinnedDataEditor: () => this.getters.outputPanel().find('.cm-editor .cm-scroller .cm-content'),
|
pinnedDataEditor: () => this.getters.outputPanel().find('.cm-editor .cm-scroller .cm-content'),
|
||||||
runDataPaneHeader: () => cy.getByTestId('run-data-pane-header'),
|
runDataPaneHeader: () => cy.getByTestId('run-data-pane-header'),
|
||||||
|
@ -147,6 +148,9 @@ export class NDV extends BasePage {
|
||||||
pinData: () => {
|
pinData: () => {
|
||||||
this.getters.pinDataButton().click({ force: true });
|
this.getters.pinDataButton().click({ force: true });
|
||||||
},
|
},
|
||||||
|
unPinData: () => {
|
||||||
|
this.getters.unpinDataLink().click({ force: true });
|
||||||
|
},
|
||||||
editPinnedData: () => {
|
editPinnedData: () => {
|
||||||
this.getters.editPinnedDataButton().click();
|
this.getters.editPinnedDataButton().click();
|
||||||
},
|
},
|
||||||
|
|
|
@ -255,6 +255,22 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
return this.nodeTypesStore.isTriggerNode(this.node.type);
|
return this.nodeTypesStore.isTriggerNode(this.node.type);
|
||||||
},
|
},
|
||||||
|
showPinButton(): boolean {
|
||||||
|
return Boolean(
|
||||||
|
(this.canPinData || this.pinnedData.hasData.value || !!this.binaryData?.length) &&
|
||||||
|
(this.rawInputData.length || this.pinnedData.hasData.value) &&
|
||||||
|
!this.editMode.enabled,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
pinButtonDisabled(): boolean {
|
||||||
|
return (
|
||||||
|
this.pinnedData.hasData.value ||
|
||||||
|
!this.rawInputData.length ||
|
||||||
|
!!this.binaryData?.length ||
|
||||||
|
this.isReadOnlyRoute ||
|
||||||
|
this.readOnlyEnv
|
||||||
|
);
|
||||||
|
},
|
||||||
canPinData(): boolean {
|
canPinData(): boolean {
|
||||||
if (this.node === null) {
|
if (this.node === null) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -1199,6 +1215,7 @@ export default defineComponent({
|
||||||
size="small"
|
size="small"
|
||||||
underline
|
underline
|
||||||
bold
|
bold
|
||||||
|
data-test-id="ndv-unpin-data"
|
||||||
@click.stop="onTogglePinData({ source: 'banner-link' })"
|
@click.stop="onTogglePinData({ source: 'banner-link' })"
|
||||||
>
|
>
|
||||||
{{ $locale.baseText('runData.pindata.unpin') }}
|
{{ $locale.baseText('runData.pindata.unpin') }}
|
||||||
|
@ -1269,13 +1286,8 @@ export default defineComponent({
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<RunDataPinButton
|
<RunDataPinButton
|
||||||
v-if="(canPinData || !!binaryData?.length) && rawInputData.length && !editMode.enabled"
|
v-if="showPinButton"
|
||||||
:disabled="
|
:disabled="pinButtonDisabled"
|
||||||
(!rawInputData.length && !pinnedData.hasData.value) ||
|
|
||||||
isReadOnlyRoute ||
|
|
||||||
readOnlyEnv ||
|
|
||||||
!!binaryData?.length
|
|
||||||
"
|
|
||||||
:tooltip-contents-visibility="{
|
:tooltip-contents-visibility="{
|
||||||
binaryDataTooltipContent: !!binaryData?.length,
|
binaryDataTooltipContent: !!binaryData?.length,
|
||||||
pinDataDiscoveryTooltipContent:
|
pinDataDiscoveryTooltipContent:
|
||||||
|
|
|
@ -10,6 +10,7 @@ import type { INodeUi, IRunDataDisplayMode } 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';
|
||||||
|
import type { INodeExecutionData } from 'n8n-workflow';
|
||||||
|
|
||||||
const nodes = [
|
const nodes = [
|
||||||
{
|
{
|
||||||
|
@ -95,7 +96,28 @@ describe('RunData', () => {
|
||||||
expect(getByTestId('ndv-binary-data_0')).toBeInTheDocument();
|
expect(getByTestId('ndv-binary-data_0')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
const render = (outputData: unknown[], displayMode: IRunDataDisplayMode) => {
|
it('should not render pin data button when there is no output data', async () => {
|
||||||
|
const { queryByTestId } = render([], 'table');
|
||||||
|
expect(queryByTestId('ndv-pin-data')).not.toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should disable pin data button when data is pinned', async () => {
|
||||||
|
const { getByTestId } = render([], 'table', [{ json: { name: 'Test' } }]);
|
||||||
|
const pinDataButton = getByTestId('ndv-pin-data');
|
||||||
|
expect(pinDataButton).toBeDisabled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should enable pin data button when data is not pinned', async () => {
|
||||||
|
const { getByTestId } = render([{ json: { name: 'Test' } }], 'table');
|
||||||
|
const pinDataButton = getByTestId('ndv-pin-data');
|
||||||
|
expect(pinDataButton).toBeEnabled();
|
||||||
|
});
|
||||||
|
|
||||||
|
const render = (
|
||||||
|
outputData: unknown[],
|
||||||
|
displayMode: IRunDataDisplayMode,
|
||||||
|
pinnedData?: INodeExecutionData[],
|
||||||
|
) => {
|
||||||
const pinia = createTestingPinia({
|
const pinia = createTestingPinia({
|
||||||
initialState: {
|
initialState: {
|
||||||
[STORES.SETTINGS]: {
|
[STORES.SETTINGS]: {
|
||||||
|
@ -154,12 +176,18 @@ describe('RunData', () => {
|
||||||
|
|
||||||
const workflowsStore = useWorkflowsStore();
|
const workflowsStore = useWorkflowsStore();
|
||||||
vi.mocked(workflowsStore).getNodeByName.mockReturnValue(nodes[0]);
|
vi.mocked(workflowsStore).getNodeByName.mockReturnValue(nodes[0]);
|
||||||
|
if (pinnedData) {
|
||||||
|
vi.mocked(workflowsStore).pinDataByNodeName.mockReturnValue(pinnedData);
|
||||||
|
}
|
||||||
|
|
||||||
return createComponentRenderer(RunData, {
|
return createComponentRenderer(RunData, {
|
||||||
props: {
|
props: {
|
||||||
node: {
|
node: {
|
||||||
name: 'Test Node',
|
name: 'Test Node',
|
||||||
},
|
},
|
||||||
|
workflow: {
|
||||||
|
nodes,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in a new issue