🐛 Added support for importing Postman global environments. Fixes #907
This commit is contained in:
@@ -107,7 +107,7 @@ export default {
|
|||||||
},
|
},
|
||||||
replaceWithJSON() {
|
replaceWithJSON() {
|
||||||
let reader = new FileReader()
|
let reader = new FileReader()
|
||||||
reader.onload = event => {
|
reader.onload = (event) => {
|
||||||
let content = event.target.result
|
let content = event.target.result
|
||||||
let environments = JSON.parse(content)
|
let environments = JSON.parse(content)
|
||||||
this.$store.commit("postwoman/replaceEnvironments", environments)
|
this.$store.commit("postwoman/replaceEnvironments", environments)
|
||||||
@@ -117,10 +117,13 @@ export default {
|
|||||||
},
|
},
|
||||||
importFromJSON() {
|
importFromJSON() {
|
||||||
let reader = new FileReader()
|
let reader = new FileReader()
|
||||||
reader.onload = event => {
|
reader.onload = (event) => {
|
||||||
let content = event.target.result
|
let content = event.target.result
|
||||||
let importFileObj = JSON.parse(content)
|
let importFileObj = JSON.parse(content)
|
||||||
if (importFileObj["_postman_variable_scope"] === "environment") {
|
if (
|
||||||
|
importFileObj["_postman_variable_scope"] === "environment" ||
|
||||||
|
importFileObj["_postman_variable_scope"] === "globals"
|
||||||
|
) {
|
||||||
this.importFromPostman(importFileObj)
|
this.importFromPostman(importFileObj)
|
||||||
} else {
|
} else {
|
||||||
this.importFromPostwoman(importFileObj)
|
this.importFromPostwoman(importFileObj)
|
||||||
@@ -137,8 +140,10 @@ export default {
|
|||||||
},
|
},
|
||||||
importFromPostman(importFileObj) {
|
importFromPostman(importFileObj) {
|
||||||
let environment = { name: importFileObj.name, variables: [] }
|
let environment = { name: importFileObj.name, variables: [] }
|
||||||
importFileObj.values.forEach(element => environment.variables.push({ key: element.key, value: element.value }));
|
importFileObj.values.forEach((element) =>
|
||||||
let environments = [ environment ]
|
environment.variables.push({ key: element.key, value: element.value })
|
||||||
|
)
|
||||||
|
let environments = [environment]
|
||||||
this.importFromPostwoman(environments)
|
this.importFromPostwoman(environments)
|
||||||
},
|
},
|
||||||
exportJSON() {
|
exportJSON() {
|
||||||
|
|||||||
Reference in New Issue
Block a user