mirror of
https://github.com/usebruno/bruno.git
synced 2025-02-16 09:50:17 +01:00
feat: updates
This commit is contained in:
parent
d8bf27f288
commit
f088cdb504
@ -59,7 +59,7 @@ const EnvironmentVariables = ({ environment, collection, setIsModified, original
|
|||||||
|
|
||||||
const ErrorMessage = ({ name }) => {
|
const ErrorMessage = ({ name }) => {
|
||||||
const meta = formik.getFieldMeta(name);
|
const meta = formik.getFieldMeta(name);
|
||||||
if (!meta.error) {
|
if (!meta.error || !meta.touched) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ const EnvironmentVariables = ({ environment, setIsModified, originalEnvironmentV
|
|||||||
|
|
||||||
const ErrorMessage = ({ name }) => {
|
const ErrorMessage = ({ name }) => {
|
||||||
const meta = formik.getFieldMeta(name);
|
const meta = formik.getFieldMeta(name);
|
||||||
if (!meta.error) {
|
if (!meta.error || !meta.touched) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const Store = require('electron-store');
|
const Store = require('electron-store');
|
||||||
|
const { encryptString, decryptString } = require('../utils/encryption');
|
||||||
|
|
||||||
class GlobalEnvironmentsStore {
|
class GlobalEnvironmentsStore {
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -9,16 +10,52 @@ class GlobalEnvironmentsStore {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isValidValue(val) {
|
||||||
|
return typeof val === 'string' && val.length >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
encryptGlobalEnvironmentVariables({ globalEnvironments }) {
|
||||||
|
return globalEnvironments?.map(env => {
|
||||||
|
const variables = env.variables?.map(v => ({
|
||||||
|
...v,
|
||||||
|
value: v?.secret ? (this.isValidValue(v.value) ? encryptString(v.value) : '') : v?.value
|
||||||
|
})) || [];
|
||||||
|
|
||||||
|
return {
|
||||||
|
...env,
|
||||||
|
variables
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
decryptGlobalEnvironmentVariables({ globalEnvironments }) {
|
||||||
|
return globalEnvironments?.map(env => {
|
||||||
|
const variables = env.variables?.map(v => ({
|
||||||
|
...v,
|
||||||
|
value: v?.secret ? (this.isValidValue(v.value) ? decryptString(v.value) : '') : v?.value
|
||||||
|
})) || [];
|
||||||
|
|
||||||
|
return {
|
||||||
|
...env,
|
||||||
|
variables
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
getGlobalEnvironments() {
|
getGlobalEnvironments() {
|
||||||
return this.store.get('environments', []);
|
let globalEnvironments = this.store.get('environments', []);
|
||||||
|
globalEnvironments = this.decryptGlobalEnvironmentVariables({ globalEnvironments });
|
||||||
|
return globalEnvironments;
|
||||||
}
|
}
|
||||||
|
|
||||||
getActiveGlobalEnvironmentUid() {
|
getActiveGlobalEnvironmentUid() {
|
||||||
return this.store.get('activeGlobalEnvironmentUid', null);
|
return this.store.get('activeGlobalEnvironmentUid', null);
|
||||||
}
|
}
|
||||||
|
|
||||||
setGlobalEnvironments(environments) {
|
setGlobalEnvironments(globalEnvironments) {
|
||||||
return this.store.set('environments', environments);
|
globalEnvironments = this.encryptGlobalEnvironmentVariables({ globalEnvironments });
|
||||||
|
return this.store.set('environments', globalEnvironments);
|
||||||
}
|
}
|
||||||
|
|
||||||
setActiveGlobalEnvironmentUid(uid) {
|
setActiveGlobalEnvironmentUid(uid) {
|
||||||
|
Loading…
Reference in New Issue
Block a user