Skip to content

Commit 395e3b6

Browse files
feat: update build assets and introduce VariableInfoPopup component
- Updated asset manifest to reflect new CSS and JS file names after build. - Removed old CSS and JS files to clean up the build directory. - Introduced VariableInfoPopup component for displaying and editing environment variable values in a user-friendly manner. - Enhanced VariableUrlInput component to utilize VariableInfoPopup for better variable management and user interaction.
1 parent ebbde04 commit 395e3b6

4 files changed

Lines changed: 32 additions & 12 deletions

File tree

‎src/components/layout/HomeLayout.tsx‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,14 @@ export function HomeLayout() {
6969
const refreshEnvironments = () => {
7070
const envs = loadEnvironments();
7171
setEnvironments(envs);
72-
setActiveEnvironmentState(getActiveEnvironment());
72+
// Get fresh environment to ensure React detects the change
73+
const activeEnv = getActiveEnvironment();
74+
// Force update by creating a new object reference
75+
if (activeEnv) {
76+
setActiveEnvironmentState({ ...activeEnv });
77+
} else {
78+
setActiveEnvironmentState(null);
79+
}
7380
};
7481

7582
const handleEnvironmentChange = (environmentId: string) => {

‎src/components/request/VariableInfoPopup.tsx‎

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export function VariableInfoPopup({
2222
onEdit,
2323
onVariableUpdated,
2424
}: VariableInfoPopupProps) {
25+
// Get fresh variable value - recalculate on every render to get latest value
2526
const variableValue = getVariableValue(variableKey, environment);
2627
const hasValue = variableValue !== null && variableValue.trim() !== '';
2728
const [isEditing, setIsEditing] = useState(false);
@@ -32,7 +33,7 @@ export function VariableInfoPopup({
3233
if (!isEditing) {
3334
setEditValue(variableValue || '');
3435
}
35-
}, [variableValue, isEditing]);
36+
}, [variableValue, isEditing, environment?.updatedAt]);
3637

3738
const handleEdit = () => {
3839
if (onEdit) {
@@ -46,13 +47,19 @@ export function VariableInfoPopup({
4647
const handleSave = () => {
4748
if (!environment) return;
4849
// Import updateVariable here to avoid circular dependency
49-
import('../../services/environmentService').then(({ updateVariable }) => {
50-
const success = updateVariable(environment.id, variableKey, editValue);
51-
if (success) {
52-
onVariableUpdated?.();
53-
setIsEditing(false);
50+
import('../../services/environmentService').then(
51+
({ updateVariable }) => {
52+
const success = updateVariable(
53+
environment.id,
54+
variableKey,
55+
editValue
56+
);
57+
if (success) {
58+
onVariableUpdated?.();
59+
setIsEditing(false);
60+
}
5461
}
55-
});
62+
);
5663
};
5764

5865
return (
@@ -127,7 +134,9 @@ export function VariableInfoPopup({
127134
<div className="flex items-center gap-2">
128135
<div className="w-5 h-5 rounded-full bg-green-500 flex items-center justify-center">
129136
<span className="text-white text-xs font-bold">
130-
{environment.name.charAt(0).toUpperCase()}
137+
{environment.name
138+
.charAt(0)
139+
.toUpperCase()}
131140
</span>
132141
</div>
133142
<span className="text-xs text-muted-foreground">
@@ -159,4 +168,3 @@ export function VariableInfoPopup({
159168
</div>
160169
);
161170
}
162-

‎src/components/request/VariableUrlInput.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ export function VariableUrlInput({
289289
}}
290290
onVariableUpdated={() => {
291291
onEnvironmentUpdate?.();
292+
// Close popup after update to show fresh data on next open
293+
setSelectedVariable(null);
292294
}}
293295
/>
294296
</div>

‎src/services/environmentService.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,12 @@ export function getActiveEnvironment(): Environment | null {
9393
// Try to find any active environment
9494
const environments = loadEnvironments();
9595
const active = environments.find((e) => e.isActive);
96-
return active || null;
96+
// Return a new object reference to ensure React detects changes
97+
return active ? { ...active, variables: [...active.variables] } : null;
9798
}
98-
return getEnvironment(activeId);
99+
const env = getEnvironment(activeId);
100+
// Return a new object reference to ensure React detects changes
101+
return env ? { ...env, variables: [...env.variables] } : null;
99102
}
100103

101104
export function setActiveEnvironment(id: string): boolean {

0 commit comments

Comments
 (0)