Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

:sparkles: Added Expand/Collapse response button. Fixes #320

Liyas Thomas463ef8225574
diff --git a/pages/index.vue b/pages/index.vue
index fbd1b924e..2bfbf9223 100644
--- a/pages/index.vue
+++ b/pages/index.vue
@@ -588,6 +588,20 @@
<div class="flex-wrap">
<label for="body">response</label>
<div>
+ <button
+ class="icon"
+ @click="ToggleExpandResponse"
+ ref="ToggleExpandResponse"
+ v-if="response.body"
+ v-tooltip="{
+ content: !expandResponse
+ ? 'Expand response'
+ : 'Collapse response'
+ }"
+ >
+ <i class="material-icons" v-if="!expandResponse">unfold_more</i>
+ <i class="material-icons" v-else>unfold_less</i>
+ </button>
<button
class="icon"
@click="copyResponse"
@@ -613,7 +627,7 @@
:value="responseBodyText"
:lang="responseBodyType"
:options="{
- maxLines: '16',
+ maxLines: responseBodyMaxLines,
minLines: '16',
fontSize: '16px',
autoScrollEditorIntoView: true,
@@ -861,6 +875,7 @@ export default {
},
previewEnabled: false,
paramsWatchEnabled: true,
+ expandResponse: false,
/**
* These are content types that can be automatically
@@ -887,7 +902,8 @@ export default {
urlExcludes: {},
responseBodyText: "",
- responseBodyType: "text"
+ responseBodyType: "text",
+ responseBodyMaxLines: 16
};
},
watch: {
@@ -1686,6 +1702,10 @@ export default {
1000
);
},
+ ToggleExpandResponse() {
+ this.expandResponse = !this.expandResponse;
+ this.responseBodyMaxLines = (this.responseBodyMaxLines == Infinity) ? 16 : Infinity;
+ },
copyResponse() {
this.$refs.copyResponse.innerHTML = this.doneButton;
this.$toast.success("Copied to clipboard", {