Possible solution for Global variables (#1289)
fix for #1164 This takes enviroments called "Global" or "global" and appends them after the current scripts. Seems to work, but proabbly a cleaner way to acheive Co-authored-by: Liyas Thomas <liyascthomas@gmail.com>
This commit is contained in:
@@ -34,7 +34,9 @@
|
|||||||
:environmentIndex="index"
|
:environmentIndex="index"
|
||||||
:environment="environment"
|
:environment="environment"
|
||||||
@edit-environment="editEnvironment(environment, index)"
|
@edit-environment="editEnvironment(environment, index)"
|
||||||
@select-environment="$emit('use-environment', environment)"
|
@select-environment="
|
||||||
|
$emit('use-environment', { environment: environment, environments: environments })
|
||||||
|
"
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -1829,14 +1829,28 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
useSelectedEnvironment(environment) {
|
useSelectedEnvironment(args) {
|
||||||
|
let environment = args.environment
|
||||||
|
let environments = args.environments
|
||||||
let preRequestScriptString = ""
|
let preRequestScriptString = ""
|
||||||
for (let variable of environment.variables) {
|
for (let variable of environment.variables) {
|
||||||
preRequestScriptString =
|
preRequestScriptString += `pw.env.set('${variable.key}', '${variable.value}');\n`
|
||||||
preRequestScriptString + `pw.env.set('${variable.key}', '${variable.value}');\n`
|
}
|
||||||
|
for (let env of environments) {
|
||||||
|
if (env.name === environment.name) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if (env.name === "Globals" || env.name === "globals") {
|
||||||
|
preRequestScriptString += this.useSelectedEnvironment({
|
||||||
|
environment: env,
|
||||||
|
environments: environments,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.preRequestScript = preRequestScriptString
|
this.preRequestScript = preRequestScriptString
|
||||||
this.showPreRequestScript = true
|
this.showPreRequestScript = true
|
||||||
|
return preRequestScriptString
|
||||||
},
|
},
|
||||||
checkCollections() {
|
checkCollections() {
|
||||||
const checkCollectionAvailability =
|
const checkCollectionAvailability =
|
||||||
|
|||||||
Reference in New Issue
Block a user