Skip to content

Commit d9575ad

Browse files
[BUGFIX] Allow render large simulation file (#10)
Co-authored-by: Julien Roy <julien.r@bridgeapi.io>
1 parent 9292a17 commit d9575ad

File tree

5 files changed

+11
-12
lines changed

5 files changed

+11
-12
lines changed

intellij-plugin/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
[Unreleased]: https://github.com/Lemick/hoverfly-ui/commits
66

7+
## [1.0.2]
8+
9+
- Fix render large simulation file
10+
711
## [1.0.1]
812

913
- Fix icon display (seems to fix a IDE render issue)

intellij-plugin/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pluginGroup=com.lemick
22
pluginName=hoverfly-ui-intellij-plugin
33
pluginRepositoryUrl=https://github.com/Lemick/hoverfly-ui
4-
pluginVersion=1.0.1
4+
pluginVersion=1.0.2
55
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
66
pluginSinceBuild=222
77
pluginUntilBuild=232.*

intellij-plugin/src/main/kotlin/com/github/lemick/hoverflyui/intellij/plugin/SimulationsFileEditor.kt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import org.cef.CefApp
1616
import org.cef.browser.CefBrowser
1717
import org.cef.handler.CefLoadHandlerAdapter
1818
import java.beans.PropertyChangeListener
19+
import java.util.Base64
1920
import javax.swing.JComponent
2021

2122
internal class SimulationsFileEditor(private val project: Project, private val file: VirtualFile) :
@@ -80,13 +81,7 @@ internal class SimulationsFileEditor(private val project: Project, private val f
8081
}
8182

8283
private fun getContent(): String {
83-
return String(file.contentsToByteArray())
84-
.replace("\"", "\\\"") // Escape double quotes
85-
.replace("'", "\\'") // Escape single quotes
86-
.replace("/", "\\/") // Escape slash
87-
.replace("\n", "\\\n") // Escape LF of file
88-
.replace("\r", "\\\r") // Escape CR of file
89-
.replace("\\n", "\\\\n") // Escape already escaped EOL from embedded JSON
84+
return Base64.getEncoder().encodeToString(file.contentsToByteArray());
9085
}
9186

9287
private fun enablePluginModeUI() {

ui/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default function App() {
1616
if (window.hoverflyUi_enablePluginMode) {
1717
return (
1818
<PluginEditorPage
19-
simulationJson={simulationData}
19+
simulationData={simulationData}
2020
onSimulationUpdate={window.hoverflyUi_onUiSimulationChange}
2121
/>
2222
);

ui/src/components/pages/PluginEditorPage.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ import { RequestResponsePair } from '../../types/hoverfly';
44
import { parse, stringify } from '../../services/json-service';
55

66
type PluginEditorPageProps = {
7-
simulationJson?: string;
7+
simulationData?: string;
88
onSimulationUpdate?: (simulationJson: string) => void;
99
};
1010

1111
/**
1212
* A light page that only provides the UI to edit simulations.
1313
*/
1414
export default function PluginEditorPage({
15-
simulationJson,
15+
simulationData,
1616
onSimulationUpdate
1717
}: PluginEditorPageProps) {
18-
const parsedJson = parse(simulationJson);
18+
const parsedJson = parse(atob(simulationData||""));
1919
// TODO provide a way to start from scratch
2020

2121
function onChangeFromForms(updatedPairs: RequestResponsePair[]) {

0 commit comments

Comments
 (0)