mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(editor): Fix copy selection behavior (#6112)
🐛 Fix copy selection behavior
This commit is contained in:
parent
c99f158120
commit
1607aeb9f9
|
@ -83,6 +83,7 @@ import { useNDVStore } from '@/stores/ndv';
|
||||||
import MappingPill from './MappingPill.vue';
|
import MappingPill from './MappingPill.vue';
|
||||||
import { getMappedExpression } from '@/utils/mappingUtils';
|
import { getMappedExpression } from '@/utils/mappingUtils';
|
||||||
import { useWorkflowsStore } from '@/stores/workflows';
|
import { useWorkflowsStore } from '@/stores/workflows';
|
||||||
|
import { nonExistingJsonPath } from '@/components/RunDataJsonActions.vue';
|
||||||
|
|
||||||
const runDataJsonActions = () => import('@/components/RunDataJsonActions.vue');
|
const runDataJsonActions = () => import('@/components/RunDataJsonActions.vue');
|
||||||
|
|
||||||
|
@ -125,7 +126,7 @@ export default mixins(externalHooks).extend({
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
selectedJsonPath: null as null | string,
|
selectedJsonPath: nonExistingJsonPath,
|
||||||
draggingPath: null as null | string,
|
draggingPath: null as null | string,
|
||||||
displayMode: 'json',
|
displayMode: 'json',
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,14 @@
|
||||||
<template>
|
<template>
|
||||||
<div :class="$style.actionsGroup">
|
<div :class="$style.actionsGroup">
|
||||||
<el-dropdown trigger="click" @command="handleCopyClick">
|
<n8n-icon-button
|
||||||
|
v-if="noSelection"
|
||||||
|
:title="$locale.baseText('runData.copyToClipboard')"
|
||||||
|
icon="copy"
|
||||||
|
type="tertiary"
|
||||||
|
:circle="false"
|
||||||
|
@click="handleCopyClick({ command: 'value' })"
|
||||||
|
/>
|
||||||
|
<el-dropdown v-else trigger="click" @command="handleCopyClick">
|
||||||
<span class="el-dropdown-link">
|
<span class="el-dropdown-link">
|
||||||
<n8n-icon-button
|
<n8n-icon-button
|
||||||
:title="$locale.baseText('runData.copyToClipboard')"
|
:title="$locale.baseText('runData.copyToClipboard')"
|
||||||
|
@ -47,7 +55,7 @@ type JsonPathData = {
|
||||||
};
|
};
|
||||||
|
|
||||||
// A path that does not exist so that nothing is selected by default
|
// A path that does not exist so that nothing is selected by default
|
||||||
const nonExistingJsonPath = '_!^&*';
|
export const nonExistingJsonPath = '_!^&*';
|
||||||
|
|
||||||
export default mixins(genericHelpers, nodeHelpers, pinData, copyPaste).extend({
|
export default mixins(genericHelpers, nodeHelpers, pinData, copyPaste).extend({
|
||||||
name: 'run-data-json-actions',
|
name: 'run-data-json-actions',
|
||||||
|
@ -87,15 +95,17 @@ export default mixins(genericHelpers, nodeHelpers, pinData, copyPaste).extend({
|
||||||
activeNode(): INodeUi | null {
|
activeNode(): INodeUi | null {
|
||||||
return this.ndvStore.activeNode;
|
return this.ndvStore.activeNode;
|
||||||
},
|
},
|
||||||
|
noSelection() {
|
||||||
|
return this.selectedJsonPath === nonExistingJsonPath;
|
||||||
|
},
|
||||||
normalisedJsonPath(): string {
|
normalisedJsonPath(): string {
|
||||||
const isNotSelected = this.selectedJsonPath === nonExistingJsonPath;
|
return this.noSelection ? '[""]' : this.selectedJsonPath;
|
||||||
return isNotSelected ? '[""]' : this.selectedJsonPath;
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getJsonValue(): string {
|
getJsonValue(): string {
|
||||||
let selectedValue = jp.query(this.jsonData, `$${this.normalisedJsonPath}`)[0];
|
let selectedValue = jp.query(this.jsonData, `$${this.normalisedJsonPath}`)[0];
|
||||||
if (this.selectedJsonPath === nonExistingJsonPath) {
|
if (this.noSelection) {
|
||||||
if (this.hasPinData) {
|
if (this.hasPinData) {
|
||||||
selectedValue = clearJsonKey(this.pinData as object);
|
selectedValue = clearJsonKey(this.pinData as object);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue