feat(core, editor): Support pairedItem for pinned data (#3843)

* 📘 Adjust interface

*  Adjust pindata in state store

*  Add utils

*  Replace utils calls

*  Adjust pindata intake and display

* 🔥 Remove excess BE fixes

* 📝 Update comment

* 🧪 Adjust tests

* 🔥 Remove unneeded helper

* 🚚 Improve naming

* 🧹 Clean up `ormconfig.ts`

* 📘 Add types and type guards

*  Improve serializer for sqlite

*  Create migration utils

*  Set up sqlite serializer

* 🗃️ Write sqlite migration

* 🗃️ Write MySQL migration

* 🗃️ Write Postgres migration

*  Add imports and exports to barrels

* 🚚 Rename `runChunked` to `runInBatches`

*  Improve migration loggers

* ♻️ Address feedback

* 🚚 Improve naming
This commit is contained in:
Iván Ovejero
2022-08-22 17:46:22 +02:00
committed by GitHub
parent 6bd7a09a45
commit b1e715299d
24 changed files with 399 additions and 143 deletions

View File

@@ -381,6 +381,7 @@ import { CodeEditor } from "@/components/forms";
import { dataPinningEventBus } from '../event-bus/data-pinning-event-bus';
import { stringSizeInBytes } from './helpers';
import RunDataTable from './RunDataTable.vue';
import { isJsonKeyObject } from '@/utils';
// A path that does not exist so that nothing is selected by default
const deselectedPlaceholder = '_!^&*';
@@ -631,13 +632,7 @@ export default mixins(
let inputData = this.rawInputData;
if (this.node && this.pinData) {
inputData = Array.isArray(this.pinData)
? this.pinData.map((value) => ({
json: value,
}))
: [{
json: this.pinData,
}];
inputData = this.pinData;
}
const offset = this.pageSize * (this.currentPage - 1);
@@ -734,7 +729,10 @@ export default mixins(
localStorage.setItem(LOCAL_STORAGE_PIN_DATA_DISCOVERY_CANVAS_FLAG, 'true');
},
enterEditMode({ origin }: EnterEditModeArgs) {
const inputData = this.pinData ? this.pinData : this.convertToJson(this.rawInputData);
const inputData = this.pinData
? this.clearJsonKey(this.pinData)
: this.convertToJson(this.rawInputData);
const data = inputData.length > 0
? inputData
: TEST_PIN_DATA;
@@ -773,25 +771,18 @@ export default mixins(
}
this.$store.commit('ui/setOutputPanelEditModeEnabled', false);
this.$store.commit('pinData', { node: this.node, data: this.removeJsonKeys(value) });
this.$store.commit('pinData', { node: this.node, data: this.clearJsonKey(value) });
this.onDataPinningSuccess({ source: 'save-edit' });
this.onExitEditMode({ type: 'save' });
},
removeJsonKeys(value: string) {
const parsed = JSON.parse(value);
clearJsonKey(userInput: string | object) {
const parsedUserInput = typeof userInput === 'string' ? JSON.parse(userInput) : userInput;
return Array.isArray(parsed)
? parsed.map(item => this.isJsonKeyObject(item) ? item.json : item)
: parsed;
},
isJsonKeyObject(item: unknown): item is { json: unknown } {
if (!this.isObjectLiteral(item)) return false;
if (!Array.isArray(parsedUserInput)) return parsedUserInput;
const keys = Object.keys(item);
return keys.length === 1 && keys[0] === 'json';
return parsedUserInput.map(item => isJsonKeyObject(item) ? item.json : item);
},
onExitEditMode({ type }: { type: 'save' | 'cancel' }) {
this.$telemetry.track('User closed ndv edit state', {
@@ -1186,7 +1177,7 @@ export default mixins(
let selectedValue = this.selectedOutput.value;
if (isNotSelected) {
if (this.hasPinData) {
selectedValue = this.pinData as object;
selectedValue = this.clearJsonKey(this.pinData as object);
} else {
selectedValue = this.convertToJson(this.getNodeInputData(this.node, this.runIndex, this.currentOutputIndex));
}