feat: Replace Vue.delete with native alternative (no-changelog) (#6444)

* feat: replace Vue.delete with native alternative (no-changelog)

* fix: fix linting issues
This commit is contained in:
Alex Grozav 2023-06-15 18:27:35 +03:00 committed by GitHub
parent 1dbca44025
commit 618b1aba30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 48 additions and 22 deletions

View file

@ -282,7 +282,7 @@
</template>
<script lang="ts">
import Vue, { defineComponent } from 'vue';
import { defineComponent } from 'vue';
import { mapStores } from 'pinia';
import ExecutionTime from '@/components/ExecutionTime.vue';
import ExecutionFilter from '@/components/ExecutionFilter.vue';
@ -439,7 +439,9 @@ export default defineComponent({
},
handleCheckboxChanged(executionId: string) {
if (this.selectedItems[executionId]) {
Vue.delete(this.selectedItems, executionId);
const { [executionId]: removedSelectedItem, ...remainingSelectedItems } =
this.selectedItems;
this.selectedItems = remainingSelectedItems;
} else {
this.selectedItems = {
...this.selectedItems,

View file

@ -158,7 +158,7 @@
<script lang="ts">
import type { PropType } from 'vue';
import Vue, { defineComponent } from 'vue';
import { defineComponent } from 'vue';
import { mapStores } from 'pinia';
import type {
INodeTypeDescription,
@ -529,8 +529,8 @@ export default defineComponent({
// Data is on top level
if (value === null) {
// Property should be deleted
// @ts-ignore
Vue.delete(this.nodeValues, lastNamePart);
const { [lastNamePart]: removedNodeValue, ...remainingNodeValues } = this.nodeValues;
this.nodeValues = remainingNodeValues;
} else {
// Value should be set
this.nodeValues = {
@ -542,18 +542,21 @@ export default defineComponent({
// Data is on lower level
if (value === null) {
// Property should be deleted
// @ts-ignore
let tempValue = get(this.nodeValues, nameParts.join('.')) as
| INodeParameters
| INodeParameters[];
Vue.delete(tempValue as object, lastNamePart as string);
const { [lastNamePart]: removedNodeValue, ...remainingNodeValues } = tempValue;
tempValue = remainingNodeValues;
if (isArray === true && (tempValue as INodeParameters[]).length === 0) {
// If a value from an array got delete and no values are left
// delete also the parent
lastNamePart = nameParts.pop();
tempValue = get(this.nodeValues, nameParts.join('.')) as INodeParameters;
Vue.delete(tempValue as object, lastNamePart as string);
const { [lastNamePart]: removedArrayNodeValue, ...remainingArrayNodeValues } =
tempValue;
tempValue = remainingArrayNodeValues;
}
} else {
// Value should be set

View file

@ -86,7 +86,8 @@ export const useCommunityNodesStore = defineStore(STORES.COMMUNITY_NODES, {
);
},
removePackageByName(name: string): void {
Vue.delete(this.installedPackages, name);
const { [name]: removedPackage, ...remainingPackages } = this.installedPackages;
this.installedPackages = remainingPackages;
},
updatePackageObject(newPackage: PublicInstalledPackage) {
this.installedPackages[newPackage.packageName] = newPackage;

View file

@ -317,7 +317,8 @@ export const useCredentialsStore = defineStore(STORES.CREDENTIALS, {
const rootStore = useRootStore();
const deleted = await deleteCredential(rootStore.getRestApiContext, id);
if (deleted) {
Vue.delete(this.credentials, id);
const { [id]: deletedCredential, ...rest } = this.credentials;
this.credentials = rest;
}
},
async oAuth2Authorize(data: ICredentialsResponse): Promise<string> {

View file

@ -58,7 +58,8 @@ export const useTagsStore = defineStore(STORES.TAGS, {
});
},
deleteTag(id: string): void {
Vue.delete(this.tags, id);
const { [id]: deleted, ...rest } = this.tags;
this.tags = rest;
},
async fetchAll(params?: { force?: boolean; withUsageCount?: boolean }): Promise<ITag[]> {

View file

@ -854,19 +854,18 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, {
uiStore.lastSelectedNode = nameData.new;
}
this.nodeMetadata = { ...this.nodeMetadata, [nameData.new]: this.nodeMetadata[nameData.old] };
Vue.delete(this.nodeMetadata, nameData.old);
const { [nameData.old]: removed, ...rest } = this.nodeMetadata;
this.nodeMetadata = { ...rest, [nameData.new]: this.nodeMetadata[nameData.old] };
if (this.workflow.pinData && this.workflow.pinData.hasOwnProperty(nameData.old)) {
const { [nameData.old]: renamed, ...restPinData } = this.workflow.pinData;
this.workflow = {
...this.workflow,
pinData: {
...this.workflow.pinData,
[nameData.new]: this.workflow.pinData[nameData.old],
...restPinData,
[nameData.new]: renamed,
},
};
Vue.delete(this.workflow.pinData!, nameData.old);
}
this.workflowExecutionPairedItemMappings = getPairedItemsMapping(this.workflowExecutionData);
@ -911,8 +910,10 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, {
return true;
}
// @ts-ignore
Vue.delete(node.issues, nodeIssueData.type);
const { [nodeIssueData.type]: removedNodeIssue, ...remainingNodeIssues } = node.issues;
this.updateNodeAtIndex(nodeIndex, {
issues: remainingNodeIssues,
});
} else {
if (node.issues === undefined) {
this.updateNodeAtIndex(nodeIndex, {
@ -945,10 +946,15 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, {
},
removeNode(node: INodeUi): void {
Vue.delete(this.nodeMetadata, node.name);
const { [node.name]: removedNodeMetadata, ...remainingNodeMetadata } = this.nodeMetadata;
this.nodeMetadata = remainingNodeMetadata;
if (this.workflow.pinData && this.workflow.pinData.hasOwnProperty(node.name)) {
Vue.delete(this.workflow.pinData, node.name);
const { [node.name]: removedPinData, ...remainingPinData } = this.workflow.pinData;
this.workflow = {
...this.workflow,
pinData: remainingPinData,
};
}
for (let i = 0; i < this.workflow.nodes.length; i++) {
@ -1094,7 +1100,19 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, {
if (this.workflowExecutionData === null || !this.workflowExecutionData.data) {
return;
}
Vue.delete(this.workflowExecutionData.data.resultData.runData, nodeName);
const { [nodeName]: removedRunData, ...remainingRunData } =
this.workflowExecutionData.data.resultData.runData;
this.workflowExecutionData = {
...this.workflowExecutionData,
data: {
...this.workflowExecutionData.data,
resultData: {
...this.workflowExecutionData.data.resultData,
runData: remainingRunData,
},
},
};
},
pinDataByNodeName(nodeName: string): INodeExecutionData[] | undefined {