Env management
This commit is contained in:
@@ -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
|
||||
// }
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user