mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(editor): Enable pin data button to also un-pin (#13642)
This commit is contained in:
parent
d9e3cfe13f
commit
24681f843c
|
@ -166,14 +166,14 @@ describe('RunData', () => {
|
|||
expect(queryByTestId('ndv-pin-data')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should disable pin data button when data is pinned', async () => {
|
||||
it('should not disable pin data button when data is pinned [ADO-3143]', async () => {
|
||||
const { getByTestId } = render({
|
||||
defaultRunItems: [],
|
||||
displayMode: 'table',
|
||||
pinnedData: [{ json: { name: 'Test' } }],
|
||||
});
|
||||
const pinDataButton = getByTestId('ndv-pin-data');
|
||||
expect(pinDataButton).toBeDisabled();
|
||||
expect(pinDataButton).not.toBeDisabled();
|
||||
});
|
||||
|
||||
it('should render callout when data is pinned in output panel', async () => {
|
||||
|
|
|
@ -528,8 +528,7 @@ const showPinButton = computed(() => {
|
|||
|
||||
const pinButtonDisabled = computed(
|
||||
() =>
|
||||
pinnedData.hasData.value ||
|
||||
!rawInputData.value.length ||
|
||||
(!rawInputData.value.length && !pinnedData.hasData.value) ||
|
||||
!!binaryData.value?.length ||
|
||||
isReadOnlyRoute.value ||
|
||||
readOnlyEnv.value,
|
||||
|
|
|
@ -30,7 +30,7 @@ const renderComponent = createComponentRenderer(RunDataPinButton, {
|
|||
},
|
||||
dataPinningDocsUrl: '',
|
||||
pinnedData: {
|
||||
hasData: false,
|
||||
hasData: { value: false },
|
||||
},
|
||||
disabled: false,
|
||||
},
|
||||
|
@ -121,4 +121,30 @@ describe('RunDataPinButton.vue', () => {
|
|||
expect(getByRole('tooltip')).toBeVisible();
|
||||
expect(getByRole('tooltip')).toHaveTextContent('disabled');
|
||||
});
|
||||
|
||||
it('pins data on button click', async () => {
|
||||
const { getByTestId, getByRole, emitted } = renderComponent({});
|
||||
// Should show 'Pin data' tooltip and emit togglePinData event
|
||||
await userEvent.hover(getByTestId('ndv-pin-data'));
|
||||
expect(getByRole('tooltip')).toBeVisible();
|
||||
expect(getByRole('tooltip').textContent).toContain('Pin data');
|
||||
await userEvent.click(getByTestId('ndv-pin-data'));
|
||||
expect(emitted().togglePinData).toBeDefined();
|
||||
});
|
||||
|
||||
it('should show correct tooltip and unpin data on button click', async () => {
|
||||
const { getByTestId, getByRole, emitted } = renderComponent({
|
||||
props: {
|
||||
pinnedData: {
|
||||
hasData: { value: true },
|
||||
},
|
||||
},
|
||||
});
|
||||
// Should show 'Unpin data' tooltip and emit togglePinData event
|
||||
await userEvent.hover(getByTestId('ndv-pin-data'));
|
||||
expect(getByRole('tooltip')).toBeVisible();
|
||||
expect(getByRole('tooltip').textContent).toContain('Unpin data');
|
||||
await userEvent.click(getByTestId('ndv-pin-data'));
|
||||
expect(emitted().togglePinData).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -37,14 +37,19 @@ const visible = computed(() =>
|
|||
{{ locale.baseText('node.discovery.pinData.ndv') }}
|
||||
</div>
|
||||
<div v-else>
|
||||
<strong>{{ locale.baseText('ndv.pinData.pin.title') }}</strong>
|
||||
<N8nText size="small" tag="p">
|
||||
{{ locale.baseText('ndv.pinData.pin.description') }}
|
||||
<div v-if="pinnedData.hasData.value">
|
||||
<strong>{{ locale.baseText('ndv.pinData.unpin.title') }}</strong>
|
||||
</div>
|
||||
<div v-else>
|
||||
<strong>{{ locale.baseText('ndv.pinData.pin.title') }}</strong>
|
||||
<N8nText size="small" tag="p">
|
||||
{{ locale.baseText('ndv.pinData.pin.description') }}
|
||||
|
||||
<N8nLink :to="props.dataPinningDocsUrl" size="small">
|
||||
{{ locale.baseText('ndv.pinData.pin.link') }}
|
||||
</N8nLink>
|
||||
</N8nText>
|
||||
<N8nLink :to="props.dataPinningDocsUrl" size="small">
|
||||
{{ locale.baseText('ndv.pinData.pin.link') }}
|
||||
</N8nLink>
|
||||
</N8nText>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<N8nIconButton
|
||||
|
|
|
@ -1042,9 +1042,10 @@
|
|||
"ndv.title.rename": "Rename",
|
||||
"ndv.title.renameNode": "Rename node",
|
||||
"ndv.pinData.pin.title": "Pin data",
|
||||
"ndv.pinData.pin.description": "Node will always output this data instead of executing.",
|
||||
"ndv.pinData.pin.description": "Node will always output current data instead of executing. Doesn't apply to production executions.",
|
||||
"ndv.pinData.pin.binary": "Pin Data is disabled as this node's output contains binary data.",
|
||||
"ndv.pinData.pin.link": "More info",
|
||||
"ndv.pinData.unpin.title": "Unpin data",
|
||||
"ndv.pinData.pin.multipleRuns.title": "Run #{index} was pinned",
|
||||
"ndv.pinData.pin.multipleRuns.description": "This run will be outputted each time the node is run.",
|
||||
"ndv.pinData.unpinAndExecute.title": "Unpin output data?",
|
||||
|
|
Loading…
Reference in a new issue