Skip to content

Commit 88457c0

Browse files
committed
Update JSONVisualizer.tsx
1 parent d818814 commit 88457c0

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

frontend/src/components/visualizations/JSONVisualizer/JSONVisualizer.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ export default function JSONVisualizer(props: jsonProps) {
9494
fileName &&
9595
fileData.fileSummary?.content_type
9696
) {
97-
// Parse the jsonContent to ensure it's valid JSON
9897
const textBlob = new Blob([jsonContent], { type: "text/plain" });
9998
const file = new File([textBlob], fileName, {
10099
type: fileData.fileSummary.content_type.content_type,
@@ -103,12 +102,19 @@ export default function JSONVisualizer(props: jsonProps) {
103102
setLoading(true);
104103
await updateFile(file, fileId);
105104
setLoading(false);
105+
106+
// Refreshing the page to reflect the changes. TODO: Find a better way to update the version
107+
window.location.reload();
106108
}
107109
} catch (error) {
108110
console.error("Error updating file:", error);
109111
}
110112
};
111-
113+
114+
const disableSaveButton = () => {
115+
return originalContent === jsonContent || !validJson;
116+
}
117+
112118
return (
113119
<Card>
114120
<CardContent>
@@ -124,7 +130,7 @@ export default function JSONVisualizer(props: jsonProps) {
124130
)}
125131
</CardContent>
126132
<CardActions>
127-
<Button variant="contained" color="primary" onClick={handleSave}>
133+
<Button variant="contained" color="primary" onClick={handleSave} disabled={disableSaveButton()}>
128134
Save Changes
129135
</Button>
130136
</CardActions>

0 commit comments

Comments
 (0)