mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-09 06:55:03 +00:00
feat/rename collectionVariables variable name to runtimeVariables (#2638)
* pr review changes * collection root object in export json * import environment updates * tests run execution order fix for collection runs * updated validations * collectionVariables -> runtimeVariables * removed husky, adjusted indentation --------- Co-authored-by: Anoop M D <anoop.md1421@gmail.com>
This commit is contained in:
@@ -73,7 +73,7 @@ const GenerateCodeItem = ({ collection, item, onClose }) => {
|
||||
const interpolatedUrl = interpolateUrl({
|
||||
url: requestUrl,
|
||||
envVars,
|
||||
collectionVariables: collection.collectionVariables,
|
||||
runtimeVariables: collection.runtimeVariables,
|
||||
processEnvVars: collection.processEnvVariables
|
||||
});
|
||||
|
||||
|
||||
@@ -62,10 +62,10 @@ const EnvVariables = ({ collection, theme }) => {
|
||||
);
|
||||
};
|
||||
|
||||
const CollectionVariables = ({ collection, theme }) => {
|
||||
const collectionVariablesFound = Object.keys(collection.collectionVariables).length > 0;
|
||||
const RuntimeVariables = ({ collection, theme }) => {
|
||||
const runtimeVariablesFound = Object.keys(collection.runtimeVariables).length > 0;
|
||||
|
||||
const collectionVariableArray = Object.entries(collection.collectionVariables).map(([name, value]) => ({
|
||||
const runtimeVariableArray = Object.entries(collection.runtimeVariables).map(([name, value]) => ({
|
||||
name,
|
||||
value,
|
||||
secret: false
|
||||
@@ -73,11 +73,11 @@ const CollectionVariables = ({ collection, theme }) => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<h1 className="font-semibold mb-2">Collection Variables</h1>
|
||||
{collectionVariablesFound ? (
|
||||
<KeyValueExplorer data={collectionVariableArray} theme={theme} />
|
||||
<h1 className="font-semibold mb-2">Runtime Variables</h1>
|
||||
{runtimeVariablesFound ? (
|
||||
<KeyValueExplorer data={runtimeVariableArray} theme={theme} />
|
||||
) : (
|
||||
<div className="muted text-xs">No collection variables found</div>
|
||||
<div className="muted text-xs">No runtime variables found</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
@@ -90,13 +90,13 @@ const VariablesEditor = ({ collection }) => {
|
||||
|
||||
return (
|
||||
<StyledWrapper className="px-4 py-4">
|
||||
<CollectionVariables collection={collection} theme={reactInspectorTheme} />
|
||||
<RuntimeVariables collection={collection} theme={reactInspectorTheme} />
|
||||
<EnvVariables collection={collection} theme={reactInspectorTheme} />
|
||||
|
||||
<div className="mt-8 muted text-xs">
|
||||
Note: As of today, collection variables can only be set via the API -{' '}
|
||||
<span className="font-medium">getVar()</span> and <span className="font-medium">setVar()</span>. <br />
|
||||
In the next release, we will add a UI to set and modify collection variables.
|
||||
Note: As of today, runtime variables can only be set via the API - <span className="font-medium">getVar()</span>{' '}
|
||||
and <span className="font-medium">setVar()</span>. <br />
|
||||
In the next release, we will add a UI to set and modify runtime variables.
|
||||
</div>
|
||||
</StyledWrapper>
|
||||
);
|
||||
|
||||
@@ -195,7 +195,7 @@ export const sendCollectionOauth2Request = (collectionUid, itemUid) => (dispatch
|
||||
const externalSecrets = getExternalCollectionSecretsForActiveEnvironment({ collection });
|
||||
const secretVariables = getFormattedCollectionSecretVariables({ externalSecrets });
|
||||
|
||||
_sendCollectionOauth2Request(collection, environment, collectionCopy.collectionVariables, itemUid, secretVariables)
|
||||
_sendCollectionOauth2Request(collection, environment, collectionCopy.runtimeVariables, itemUid, secretVariables)
|
||||
.then((response) => {
|
||||
if (response?.data?.error) {
|
||||
toast.error(response?.data?.error);
|
||||
@@ -224,7 +224,7 @@ export const sendRequest = (item, collectionUid) => (dispatch, getState) => {
|
||||
const collectionCopy = cloneDeep(collection);
|
||||
|
||||
const environment = findEnvironmentInCollection(collectionCopy, collectionCopy.activeEnvironmentUid);
|
||||
sendNetworkRequest(itemCopy, collectionCopy, environment, collectionCopy.collectionVariables)
|
||||
sendNetworkRequest(itemCopy, collectionCopy, environment, collectionCopy.runtimeVariables)
|
||||
.then((response) => {
|
||||
return dispatch(
|
||||
responseReceived({
|
||||
@@ -314,7 +314,7 @@ export const runCollectionFolder = (collectionUid, folderUid, recursive) => (dis
|
||||
folder,
|
||||
collectionCopy,
|
||||
environment,
|
||||
collectionCopy.collectionVariables,
|
||||
collectionCopy.runtimeVariables,
|
||||
recursive
|
||||
)
|
||||
.then(resolve)
|
||||
@@ -1036,7 +1036,7 @@ export const openCollectionEvent = (uid, pathname, brunoConfig) => (dispatch, ge
|
||||
name: brunoConfig.name,
|
||||
pathname: pathname,
|
||||
items: [],
|
||||
collectionVariables: {},
|
||||
runtimeVariables: {},
|
||||
brunoConfig: brunoConfig
|
||||
};
|
||||
|
||||
|
||||
@@ -200,7 +200,7 @@ export const collectionsSlice = createSlice({
|
||||
}
|
||||
},
|
||||
scriptEnvironmentUpdateEvent: (state, action) => {
|
||||
const { collectionUid, envVariables, collectionVariables } = action.payload;
|
||||
const { collectionUid, envVariables, runtimeVariables } = action.payload;
|
||||
const collection = findCollectionByUid(state.collections, collectionUid);
|
||||
|
||||
if (collection) {
|
||||
@@ -230,7 +230,7 @@ export const collectionsSlice = createSlice({
|
||||
});
|
||||
}
|
||||
|
||||
collection.collectionVariables = collectionVariables;
|
||||
collection.runtimeVariables = runtimeVariables;
|
||||
}
|
||||
},
|
||||
processEnvUpdateEvent: (state, action) => {
|
||||
|
||||
@@ -798,7 +798,7 @@ export const getAllVariables = (collection, item) => {
|
||||
return {
|
||||
...environmentVariables,
|
||||
...requestVariables,
|
||||
...collection.collectionVariables,
|
||||
...collection.runtimeVariables,
|
||||
pathParams: {
|
||||
...pathParams
|
||||
},
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { safeStringifyJSON } from 'utils/common';
|
||||
|
||||
export const sendNetworkRequest = async (item, collection, environment, collectionVariables) => {
|
||||
export const sendNetworkRequest = async (item, collection, environment, runtimeVariables) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (['http-request', 'graphql-request'].includes(item.type)) {
|
||||
sendHttpRequest(item, collection, environment, collectionVariables)
|
||||
sendHttpRequest(item, collection, environment, runtimeVariables)
|
||||
.then((response) => {
|
||||
resolve({
|
||||
state: 'success',
|
||||
@@ -22,22 +22,22 @@ export const sendNetworkRequest = async (item, collection, environment, collecti
|
||||
});
|
||||
};
|
||||
|
||||
const sendHttpRequest = async (item, collection, environment, collectionVariables) => {
|
||||
const sendHttpRequest = async (item, collection, environment, runtimeVariables) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const { ipcRenderer } = window;
|
||||
|
||||
ipcRenderer
|
||||
.invoke('send-http-request', item, collection, environment, collectionVariables)
|
||||
.invoke('send-http-request', item, collection, environment, runtimeVariables)
|
||||
.then(resolve)
|
||||
.catch(reject);
|
||||
});
|
||||
};
|
||||
|
||||
export const sendCollectionOauth2Request = async (collection, environment, collectionVariables) => {
|
||||
export const sendCollectionOauth2Request = async (collection, environment, runtimeVariables) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const { ipcRenderer } = window;
|
||||
ipcRenderer
|
||||
.invoke('send-collection-oauth2-request', collection, environment, collectionVariables)
|
||||
.invoke('send-collection-oauth2-request', collection, environment, runtimeVariables)
|
||||
.then(resolve)
|
||||
.catch(reject);
|
||||
});
|
||||
|
||||
@@ -107,14 +107,14 @@ export const isValidUrl = (url) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const interpolateUrl = ({ url, envVars, collectionVariables, processEnvVars }) => {
|
||||
export const interpolateUrl = ({ url, envVars, runtimeVariables, processEnvVars }) => {
|
||||
if (!url || !url.length || typeof url !== 'string') {
|
||||
return;
|
||||
}
|
||||
|
||||
return interpolate(url, {
|
||||
...envVars,
|
||||
...collectionVariables,
|
||||
...runtimeVariables,
|
||||
process: {
|
||||
env: {
|
||||
...processEnvVars
|
||||
|
||||
@@ -129,10 +129,10 @@ describe('Url Utils - interpolateUrl, interpolateUrlPathParams', () => {
|
||||
const expectedUrl = 'https://example.com/api/:id/path?foo=foo_value&bar=bar_value&baz=baz_value';
|
||||
|
||||
const envVars = { host: 'https://example.com', foo: 'foo_value' };
|
||||
const collectionVariables = { bar: 'bar_value' };
|
||||
const runtimeVariables = { bar: 'bar_value' };
|
||||
const processEnvVars = { baz: 'baz_value' };
|
||||
|
||||
const result = interpolateUrl({ url, envVars, collectionVariables, processEnvVars });
|
||||
const result = interpolateUrl({ url, envVars, runtimeVariables, processEnvVars });
|
||||
|
||||
expect(result).toEqual(expectedUrl);
|
||||
});
|
||||
@@ -153,10 +153,10 @@ describe('Url Utils - interpolateUrl, interpolateUrlPathParams', () => {
|
||||
const expectedUrl = 'https://example.com/api/123/path?foo=foo_value&bar=bar_value&baz=baz_value';
|
||||
|
||||
const envVars = { host: 'https://example.com', foo: 'foo_value' };
|
||||
const collectionVariables = { bar: 'bar_value' };
|
||||
const runtimeVariables = { bar: 'bar_value' };
|
||||
const processEnvVars = { baz: 'baz_value' };
|
||||
|
||||
const intermediateResult = interpolateUrl({ url, envVars, collectionVariables, processEnvVars });
|
||||
const intermediateResult = interpolateUrl({ url, envVars, runtimeVariables, processEnvVars });
|
||||
const result = interpolateUrlPathParams(intermediateResult, params);
|
||||
|
||||
expect(result).toEqual(expectedUrl);
|
||||
|
||||
Reference in New Issue
Block a user