import React, { useState } from 'react'; import get from 'lodash/get'; import filter from 'lodash/filter'; import { Inspector } from 'react-inspector'; import { useTheme } from 'providers/Theme'; import { findEnvironmentInCollection, maskInputValue } from 'utils/collections'; import StyledWrapper from './StyledWrapper'; import { IconEye, IconEyeOff } from '@tabler/icons'; const KeyValueExplorer = ({ data = [], theme }) => { const [showSecret, setShowSecret] = useState(false); return (
setShowSecret(!showSecret)} /> {data.toSorted((a, b) => a.name.localeCompare(b.name)).map((envVar) => ( ))}
{envVar.name}
); }; const EnvVariables = ({ collection, theme }) => { const environment = findEnvironmentInCollection(collection, collection.activeEnvironmentUid); if (!environment) { return ( <>

Environment Variables

No environment selected
); } const envVars = get(environment, 'variables', []); const enabledEnvVars = filter(envVars, (variable) => variable.enabled); return ( <>

Environment Variables

({environment.name})
{enabledEnvVars.length > 0 ? ( ) : (
No environment variables found
)} ); }; const RuntimeVariables = ({ collection, theme }) => { const runtimeVariablesFound = Object.keys(collection.runtimeVariables).length > 0; const runtimeVariableArray = Object.entries(collection.runtimeVariables).map(([name, value]) => ({ name, value, secret: false })); return ( <>

Runtime Variables

{runtimeVariablesFound ? ( ) : (
No runtime variables found
)} ); }; const VariablesEditor = ({ collection }) => { const { storedTheme } = useTheme(); const reactInspectorTheme = storedTheme === 'light' ? 'chromeLight' : 'chromeDark'; return (
Note: As of today, runtime variables can only be set via the API - getVar(){' '} and setVar().
); }; export default VariablesEditor; const SecretToggle = ({ showSecret, onClick }) => (
{showSecret ? : } {showSecret ? 'Hide secret variable values' : 'Show secret variable values'}
);