diff --git a/components/environments/addEnvironment.vue b/components/environments/addEnvironment.vue
new file mode 100644
index 000000000..b68768213
--- /dev/null
+++ b/components/environments/addEnvironment.vue
@@ -0,0 +1,77 @@
+
+
+
+
+ -
+
+
{{ $t("new_environment") }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/components/environments/editEnvironment.vue b/components/environments/editEnvironment.vue
new file mode 100644
index 000000000..adb3dc920
--- /dev/null
+++ b/components/environments/editEnvironment.vue
@@ -0,0 +1,206 @@
+
+
+
+
+ -
+
+
{{ $t("edit_environment") }}
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/components/environments/environment.vue b/components/environments/environment.vue
new file mode 100644
index 000000000..8fda53198
--- /dev/null
+++ b/components/environments/environment.vue
@@ -0,0 +1,65 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/components/environments/importExportEnvironment.vue b/components/environments/importExportEnvironment.vue
new file mode 100644
index 000000000..3072f6ad4
--- /dev/null
+++ b/components/environments/importExportEnvironment.vue
@@ -0,0 +1,170 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/components/environments/index.vue b/components/environments/index.vue
new file mode 100644
index 000000000..c66e2fd0f
--- /dev/null
+++ b/components/environments/index.vue
@@ -0,0 +1,133 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Create new environment
+
+
+
+ -
+
+
+ -
+
+
+
+
+
+
+
+
+
+
diff --git a/lang/en-US.js b/lang/en-US.js
index 9191cec5f..eba422b4b 100644
--- a/lang/en-US.js
+++ b/lang/en-US.js
@@ -45,6 +45,14 @@ export default {
preview_html: "Preview HTML",
history: "History",
collections: "Collections",
+ environment: "Environment",
+ new_environment: "New Environment",
+ my_new_environment: "My New Environment",
+ edit_environment: "Edit Environment",
+ env_variable_list: "Variable List",
+ invalid_environment_name: "Please provide a valid name for the environment",
+ use_environment: "Use environment",
+ add_one_variable: "(add at least one variable)",
import_curl: "Import cURL",
import: "Import",
generate_code: "Generate code",
diff --git a/pages/index.vue b/pages/index.vue
index e74fd46ea..7096306ad 100644
--- a/pages/index.vue
+++ b/pages/index.vue
@@ -1075,6 +1075,11 @@
+
+
+
+
+
@@ -1451,7 +1456,8 @@ export default {
saveRequestAs: () => import("../components/collections/saveRequestAs"),
Editor: AceEditor,
inputform: () => import("../components/firebase/inputform"),
- ballsfeed: () => import("../components/firebase/feeds")
+ ballsfeed: () => import("../components/firebase/feeds"),
+ environments: () => import("../components/environments")
},
data() {
return {
@@ -2039,6 +2045,14 @@ export default {
}
},
methods: {
+ useSelectedEnvironment(environment) {
+ let preRequestScriptString = ''
+ for (let variable of environment.variables) {
+ preRequestScriptString = preRequestScriptString + `pw.env.set('${variable.key}', '${variable.value}');\n`
+ }
+ this.preRequestScript = preRequestScriptString
+ this.showPreRequestScript = true
+ },
checkCollections() {
const checkCollectionAvailability =
this.$store.state.postwoman.collections &&
diff --git a/store/postwoman.js b/store/postwoman.js
index ab79729ef..945932e33 100644
--- a/store/postwoman.js
+++ b/store/postwoman.js
@@ -74,6 +74,13 @@ export const state = () => ({
requests: []
}
],
+ environments: [
+ {
+ name: "My Env Variables",
+ variables: []
+ }
+ ],
+ editingEnvironment: {},
selectedRequest: {},
editingRequest: {}
});
@@ -102,6 +109,61 @@ export const mutations = {
settings[key] = value;
},
+ removeVariables({ editingEnvironment }, value) {
+ editingEnvironment.variables = value
+ },
+
+ setEditingEnvironment(state, value ) {
+ state.editingEnvironment = {...value}
+ },
+
+ setVariableKey({ editingEnvironment }, { index, value }) {
+ editingEnvironment.variables[index].key = value;
+ },
+
+ setVariableValue({ editingEnvironment }, { index, value }) {
+ editingEnvironment.variables[index].value = value;
+ },
+
+ removeVariable({ editingEnvironment }, variables) {
+ editingEnvironment.variables = variables;
+ },
+
+ addVariable({ editingEnvironment }, value) {
+ editingEnvironment.variables.push(value);
+ },
+
+ replaceEnvironments(state, environments) {
+ state.environments = environments;
+ },
+
+ importAddEnvironments(state, environments) {
+ state.environments = [...state.environments, ...environments];
+
+ let index = 0;
+ for (let environment of state.environments) {
+ environment.environmentIndex = index;
+ index += 1;
+ }
+ },
+
+ removeEnvironment({ environments }, environmentIndex) {
+ environments.splice(environmentIndex, 1);
+ },
+
+ saveEnvironment({ environments }, payload) {
+ const { environment, environmentIndex } = payload;
+ const { name } = environment;
+ const duplicateEnvironment = environments.some(item => {
+ return item.environmentIndex !== environmentIndex && item.name.toLowerCase() === name.toLowerCase()
+ });
+ if (duplicateEnvironment) {
+ this.$toast.info("Duplicate environment");
+ return;
+ }
+ environments[environmentIndex] = environment;
+ },
+
replaceCollections(state, collections) {
state.collections = collections;
},
@@ -323,3 +385,9 @@ export const mutations = {
state.selectedRequest = Object.assign({}, request);
}
};
+
+// export const getters = {
+// getEditingEnvironment: state => {
+// return state.editingEnvironment
+// }
+// }