mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-21 23:43:15 +01:00
fix: no env select issue (#3247)
This commit is contained in:
parent
5c5e3d18fc
commit
ce8ebb0c1a
@ -19,7 +19,7 @@ import {
|
|||||||
runRequestEvent,
|
runRequestEvent,
|
||||||
scriptEnvironmentUpdateEvent
|
scriptEnvironmentUpdateEvent
|
||||||
} from 'providers/ReduxStore/slices/collections';
|
} from 'providers/ReduxStore/slices/collections';
|
||||||
import { collectionAddEnvFileEvent, openCollectionEvent, hydrateCollectionsWithUiStateSnapshot } from 'providers/ReduxStore/slices/collections/actions';
|
import { collectionAddEnvFileEvent, openCollectionEvent, hydrateCollectionWithUiStateSnapshot } from 'providers/ReduxStore/slices/collections/actions';
|
||||||
import toast from 'react-hot-toast';
|
import toast from 'react-hot-toast';
|
||||||
import { useDispatch } from 'react-redux';
|
import { useDispatch } from 'react-redux';
|
||||||
import { isElectron } from 'utils/common/platform';
|
import { isElectron } from 'utils/common/platform';
|
||||||
@ -150,7 +150,7 @@ const useIpcEvents = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const removeSnapshotHydrationListener = ipcRenderer.on('main:hydrate-app-with-ui-state-snapshot', (val) => {
|
const removeSnapshotHydrationListener = ipcRenderer.on('main:hydrate-app-with-ui-state-snapshot', (val) => {
|
||||||
dispatch(hydrateCollectionsWithUiStateSnapshot(val));
|
dispatch(hydrateCollectionWithUiStateSnapshot(val));
|
||||||
})
|
})
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
@ -971,17 +971,19 @@ export const selectEnvironment = (environmentUid, collectionUid) => (dispatch, g
|
|||||||
}
|
}
|
||||||
|
|
||||||
const collectionCopy = cloneDeep(collection);
|
const collectionCopy = cloneDeep(collection);
|
||||||
if (environmentUid) {
|
|
||||||
const environment = findEnvironmentInCollection(collectionCopy, environmentUid);
|
const environmentName = environmentUid
|
||||||
if (environment) {
|
? findEnvironmentInCollection(collectionCopy, environmentUid)?.name
|
||||||
ipcRenderer.invoke('renderer:update-ui-state-snapshot', { type: 'COLLECTION_ENVIRONMENT', data: { collectionPath: collection?.pathname, environmentName: environment?.name } })
|
: null;
|
||||||
dispatch(_selectEnvironment({ environmentUid, collectionUid }));
|
|
||||||
resolve();
|
if (environmentUid && !environmentName) {
|
||||||
}
|
return reject(new Error('Environment not found'));
|
||||||
else {
|
}
|
||||||
return reject(new Error('Environment not found'));
|
|
||||||
}
|
ipcRenderer.invoke('renderer:update-ui-state-snapshot', { type: 'COLLECTION_ENVIRONMENT', data: { collectionPath: collection?.pathname, environmentName }});
|
||||||
}
|
|
||||||
|
dispatch(_selectEnvironment({ environmentUid, collectionUid }));
|
||||||
|
resolve();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1146,7 +1148,7 @@ export const saveCollectionSecurityConfig = (collectionUid, securityConfig) => (
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export const hydrateCollectionsWithUiStateSnapshot = (payload) => (dispatch, getState) => {
|
export const hydrateCollectionWithUiStateSnapshot = (payload) => (dispatch, getState) => {
|
||||||
const collectionSnapshotData = payload;
|
const collectionSnapshotData = payload;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
|
@ -25,11 +25,11 @@ const { moveRequestUid, deleteRequestUid } = require('../cache/requestUids');
|
|||||||
const { deleteCookiesForDomain, getDomainsWithCookies } = require('../utils/cookies');
|
const { deleteCookiesForDomain, getDomainsWithCookies } = require('../utils/cookies');
|
||||||
const EnvironmentSecretsStore = require('../store/env-secrets');
|
const EnvironmentSecretsStore = require('../store/env-secrets');
|
||||||
const CollectionSecurityStore = require('../store/collection-security');
|
const CollectionSecurityStore = require('../store/collection-security');
|
||||||
const UiStateSnapshot = require('../store/ui-state-snapshot');
|
const UiStateSnapshotStore = require('../store/ui-state-snapshot');
|
||||||
|
|
||||||
const environmentSecretsStore = new EnvironmentSecretsStore();
|
const environmentSecretsStore = new EnvironmentSecretsStore();
|
||||||
const collectionSecurityStore = new CollectionSecurityStore();
|
const collectionSecurityStore = new CollectionSecurityStore();
|
||||||
const UiStateSnapshotStore = new UiStateSnapshot();
|
const uiStateSnapshotStore = new UiStateSnapshotStore();
|
||||||
|
|
||||||
const envHasSecrets = (environment = {}) => {
|
const envHasSecrets = (environment = {}) => {
|
||||||
const secrets = _.filter(environment.variables, (v) => v.secret);
|
const secrets = _.filter(environment.variables, (v) => v.secret);
|
||||||
@ -700,7 +700,7 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
|
|||||||
|
|
||||||
ipcMain.handle('renderer:update-ui-state-snapshot', (event, { type, data }) => {
|
ipcMain.handle('renderer:update-ui-state-snapshot', (event, { type, data }) => {
|
||||||
try {
|
try {
|
||||||
UiStateSnapshotStore.update({ type, data });
|
uiStateSnapshotStore.update({ type, data });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(error.message);
|
throw new Error(error.message);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
const Store = require('electron-store');
|
const Store = require('electron-store');
|
||||||
|
|
||||||
class UiStateSnapshot {
|
class UiStateSnapshotStore {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.store = new Store({
|
this.store = new Store({
|
||||||
name: 'ui-state-snapshot',
|
name: 'ui-state-snapshot',
|
||||||
@ -57,4 +57,4 @@ class UiStateSnapshot {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = UiStateSnapshot;
|
module.exports = UiStateSnapshotStore;
|
||||||
|
Loading…
Reference in New Issue
Block a user