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

View file

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

View file

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

View file

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

View file

@ -58,7 +58,8 @@ export const useTagsStore = defineStore(STORES.TAGS, {
}); });
}, },
deleteTag(id: string): void { 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[]> { 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; uiStore.lastSelectedNode = nameData.new;
} }
this.nodeMetadata = { ...this.nodeMetadata, [nameData.new]: this.nodeMetadata[nameData.old] }; const { [nameData.old]: removed, ...rest } = this.nodeMetadata;
Vue.delete(this.nodeMetadata, nameData.old); this.nodeMetadata = { ...rest, [nameData.new]: this.nodeMetadata[nameData.old] };
if (this.workflow.pinData && this.workflow.pinData.hasOwnProperty(nameData.old)) { if (this.workflow.pinData && this.workflow.pinData.hasOwnProperty(nameData.old)) {
const { [nameData.old]: renamed, ...restPinData } = this.workflow.pinData;
this.workflow = { this.workflow = {
...this.workflow, ...this.workflow,
pinData: { pinData: {
...this.workflow.pinData, ...restPinData,
[nameData.new]: this.workflow.pinData[nameData.old], [nameData.new]: renamed,
}, },
}; };
Vue.delete(this.workflow.pinData!, nameData.old);
} }
this.workflowExecutionPairedItemMappings = getPairedItemsMapping(this.workflowExecutionData); this.workflowExecutionPairedItemMappings = getPairedItemsMapping(this.workflowExecutionData);
@ -911,8 +910,10 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, {
return true; return true;
} }
// @ts-ignore const { [nodeIssueData.type]: removedNodeIssue, ...remainingNodeIssues } = node.issues;
Vue.delete(node.issues, nodeIssueData.type); this.updateNodeAtIndex(nodeIndex, {
issues: remainingNodeIssues,
});
} else { } else {
if (node.issues === undefined) { if (node.issues === undefined) {
this.updateNodeAtIndex(nodeIndex, { this.updateNodeAtIndex(nodeIndex, {
@ -945,10 +946,15 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, {
}, },
removeNode(node: INodeUi): void { 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)) { 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++) { 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) { if (this.workflowExecutionData === null || !this.workflowExecutionData.data) {
return; 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 { pinDataByNodeName(nodeName: string): INodeExecutionData[] | undefined {