Undo header/param/body param deletion (#350)

Undo header/param/body param deletion
This commit is contained in:
Liyas Thomas
2019-11-27 15:09:56 +05:30
committed by GitHub
2 changed files with 46 additions and 4 deletions

View File

@@ -604,10 +604,22 @@ export default {
return false; return false;
}, },
removeRequestHeader(index) { removeRequestHeader(index) {
// .slice() is used so we get a separate array, rather than just a reference
const oldHeaders = this.headers.slice();
this.$store.commit("removeGQLHeader", index); this.$store.commit("removeGQLHeader", index);
this.$toast.error("Deleted", { this.$toast.error("Deleted", {
icon: "delete" icon: "delete",
action: {
text: "Undo",
duration: 4000,
onClick: (e, toastObject) => {
this.headers = oldHeaders;
toastObject.remove();
}
}
}); });
console.log(oldHeaders);
} }
} }
}; };

View File

@@ -1606,9 +1606,19 @@ export default {
return false; return false;
}, },
removeRequestHeader(index) { removeRequestHeader(index) {
// .slice() gives us an entirely new array rather than giving us just the reference
const oldHeaders = this.headers.slice();
this.$store.commit("removeHeaders", index); this.$store.commit("removeHeaders", index);
this.$toast.error("Deleted", { this.$toast.error("Deleted", {
icon: "delete" icon: "delete",
action: {
text: "Undo",
onClick: (e, toastObject) => {
this.headers = oldHeaders;
toastObject.remove();
}
}
}); });
}, },
addRequestParam() { addRequestParam() {
@@ -1616,9 +1626,19 @@ export default {
return false; return false;
}, },
removeRequestParam(index) { removeRequestParam(index) {
// .slice() gives us an entirely new array rather than giving us just the reference
const oldParams = this.params.slice();
this.$store.commit("removeParams", index); this.$store.commit("removeParams", index);
this.$toast.error("Deleted", { this.$toast.error("Deleted", {
icon: "delete" icon: "delete",
action: {
text: "Undo",
onClick: (e, toastObject) => {
this.params = oldParams;
toastObject.remove();
}
}
}); });
}, },
addRequestBodyParam() { addRequestBodyParam() {
@@ -1626,9 +1646,19 @@ export default {
return false; return false;
}, },
removeRequestBodyParam(index) { removeRequestBodyParam(index) {
// .slice() gives us an entirely new array rather than giving us just the reference
const oldBodyParams = this.bodyParams.slice();
this.$store.commit("removeBodyParams", index); this.$store.commit("removeBodyParams", index);
this.$toast.error("Deleted", { this.$toast.error("Deleted", {
icon: "delete" icon: "delete",
action: {
text: "Undo",
onClick: (e, toastObject) => {
this.bodyParams = oldBodyParams;
toastObject.remove();
}
}
}); });
}, },
formatRawParams(event) { formatRawParams(event) {