feat: updates

This commit is contained in:
lohxt1 2024-09-30 16:36:19 +05:30
parent d8bf27f288
commit f088cdb504
3 changed files with 42 additions and 5 deletions

View File

@ -59,7 +59,7 @@ const EnvironmentVariables = ({ environment, collection, setIsModified, original
const ErrorMessage = ({ name }) => {
const meta = formik.getFieldMeta(name);
if (!meta.error) {
if (!meta.error || !meta.touched) {
return null;
}

View File

@ -62,7 +62,7 @@ const EnvironmentVariables = ({ environment, setIsModified, originalEnvironmentV
const ErrorMessage = ({ name }) => {
const meta = formik.getFieldMeta(name);
if (!meta.error) {
if (!meta.error || !meta.touched) {
return null;
}

View File

@ -1,5 +1,6 @@
const _ = require('lodash');
const Store = require('electron-store');
const { encryptString, decryptString } = require('../utils/encryption');
class GlobalEnvironmentsStore {
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() {
return this.store.get('environments', []);
let globalEnvironments = this.store.get('environments', []);
globalEnvironments = this.decryptGlobalEnvironmentVariables({ globalEnvironments });
return globalEnvironments;
}
getActiveGlobalEnvironmentUid() {
return this.store.get('activeGlobalEnvironmentUid', null);
}
setGlobalEnvironments(environments) {
return this.store.set('environments', environments);
setGlobalEnvironments(globalEnvironments) {
globalEnvironments = this.encryptGlobalEnvironmentVariables({ globalEnvironments });
return this.store.set('environments', globalEnvironments);
}
setActiveGlobalEnvironmentUid(uid) {