fix: prevent clear response action in response examples and test runner (#5641)

This commit is contained in:
Nivedin 2025-12-02 13:28:53 +05:30 committed by GitHub
parent ab52efc075
commit 217563e7dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 65 additions and 8 deletions

View file

@ -17,6 +17,7 @@
:is-savable="isSavable"
:is-editable="isEditable"
:tab-id="props.tabId"
:is-test-runner="props.isTestRunner"
@save-as-example="$emit('save-as-example')"
/>
</HoppSmartTab>

View file

@ -35,6 +35,7 @@
@keyup.escape="hide()"
>
<HoppSmartItem
v-if="!isTestRunner"
:label="t('action.clear_response')"
:icon="IconEraser"
:shortcut="[getSpecialKey(), 'Delete']"
@ -75,6 +76,7 @@ const props = defineProps<{
type: "success" | "fail"
}
isEditable: boolean
isTestRunner?: boolean
}>()
const emit = defineEmits<{
@ -115,8 +117,13 @@ const { downloadIcon, downloadResponse } = useDownloadResponse(
})
)
/**
* Erases the response body.
* Do not erase if the tab is a saved example or test runner.
*
*/
const eraseResponse = () => {
emit("update:response", null)
if (!props.isEditable && !props.isTestRunner) emit("update:response", null)
}
defineActionHandler("response.file.download", () => downloadResponse())

View file

@ -76,6 +76,7 @@
@keyup.escape="hide()"
>
<HoppSmartItem
v-if="!isTestRunner"
:label="t('action.clear_response')"
:icon="IconEraser"
:shortcut="[getSpecialKey(), 'Delete']"
@ -142,6 +143,7 @@ const props = defineProps<{
isSavable: boolean
isEditable: boolean
tabId: string
isTestRunner?: boolean
}>()
const { containerRef } = useScrollerRef(
@ -206,8 +208,13 @@ const doTogglePreview = async () => {
const { copyIcon, copyResponse } = useCopyResponse(responseBodyText)
/**
* Erases the response body.
* Do not erase if the tab is a saved example or test runner.
*
*/
const eraseResponse = () => {
emit("update:response", null)
if (!props.isEditable && !props.isTestRunner) emit("update:response", null)
}
const saveAsExample = () => {

View file

@ -35,6 +35,7 @@
@keyup.escape="hide()"
>
<HoppSmartItem
v-if="!isTestRunner"
:label="t('action.clear_response')"
:icon="IconEraser"
:shortcut="[getSpecialKey(), 'Delete']"
@ -76,6 +77,7 @@ const t = useI18n()
const props = defineProps<{
response: HoppRESTResponse & { type: "success" | "fail" }
isEditable: boolean
isTestRunner?: boolean
}>()
const emit = defineEmits<{
@ -137,8 +139,13 @@ onMounted(() => {
reader.readAsDataURL(blob)
})
/**
* Erases the response body.
* Do not erase if the tab is a saved example or test runner.
*
*/
const eraseResponse = () => {
emit("update:response", null)
if (!props.isEditable && !props.isTestRunner) emit("update:response", null)
}
defineActionHandler("response.file.download", () => downloadResponse())

View file

@ -88,6 +88,7 @@
"
/>
<HoppSmartItem
v-if="!isTestRunner"
:label="t('action.clear_response')"
:icon="IconEraser"
:shortcut="[getSpecialKey(), 'Delete']"
@ -293,6 +294,7 @@ const props = defineProps<{
isSavable: boolean
isEditable: boolean
tabId: string
isTestRunner?: boolean
}>()
const { containerRef } = useScrollerRef(
@ -466,8 +468,13 @@ const saveAsExample = () => {
const { copyIcon, copyResponse } = useCopyResponse(jsonBodyText)
/**
* Erases the response body.
* Do not erase if the tab is a saved example or test runner.
*
*/
const eraseResponse = () => {
emit("update:response", null)
if (!props.isEditable && !props.isTestRunner) emit("update:response", null)
}
const { downloadIcon, downloadResponse } = useDownloadResponse(

View file

@ -35,6 +35,7 @@
@keyup.escape="hide()"
>
<HoppSmartItem
v-if="!isTestRunner"
:label="t('action.clear_response')"
:icon="IconEraser"
:shortcut="[getSpecialKey(), 'Delete']"
@ -73,6 +74,7 @@ const props = defineProps<{
type: "success" | "fail"
}
isEditable: boolean
isTestRunner?: boolean
}>()
const emit = defineEmits<{
@ -97,8 +99,13 @@ const { downloadIcon, downloadResponse } = useDownloadResponse(
`${filename}.pdf`
)
/**
* Erases the response body.
* Do not erase if the tab is a saved example or test runner.
*
*/
const eraseResponse = () => {
emit("update:response", null)
if (!props.isEditable && !props.isTestRunner) emit("update:response", null)
}
defineActionHandler("response.file.download", () => downloadResponse())

View file

@ -67,6 +67,7 @@
@keyup.escape="hide()"
>
<HoppSmartItem
v-if="!isTestRunner"
:label="t('action.clear_response')"
:icon="IconEraser"
:shortcut="[getSpecialKey(), 'Delete']"
@ -122,6 +123,7 @@ const props = defineProps<{
isEditable: boolean
isSavable: boolean
tabId: string
isTestRunner?: boolean
}>()
const emit = defineEmits<{
@ -166,8 +168,13 @@ const saveAsExample = () => {
emit("save-as-example")
}
/**
* Erases the response body.
* Do not erase if the tab is a saved example or test runner.
*
*/
const eraseResponse = () => {
emit("update:response", null)
if (!props.isEditable && !props.isTestRunner) emit("update:response", null)
}
const responseType = computed(() =>

View file

@ -35,6 +35,7 @@
@keyup.escape="hide()"
>
<HoppSmartItem
v-if="!isTestRunner"
:label="t('action.clear_response')"
:icon="IconEraser"
:shortcut="[getSpecialKey(), 'Delete']"
@ -75,6 +76,7 @@ const props = defineProps<{
type: "success" | "fail"
}
isEditable: boolean
isTestRunner?: boolean
}>()
const emit = defineEmits<{
@ -115,8 +117,13 @@ const { downloadIcon, downloadResponse } = useDownloadResponse(
})
)
/**
* Erases the response body.
* Do not erase if the tab is a saved example or test runner.
*
*/
const eraseResponse = () => {
emit("update:response", null)
if (!props.isEditable && !props.isTestRunner) emit("update:response", null)
}
defineActionHandler("response.file.download", () => downloadResponse())

View file

@ -66,6 +66,7 @@
@keyup.escape="hide()"
>
<HoppSmartItem
v-if="!isTestRunner"
:label="t('action.clear_response')"
:icon="IconEraser"
:shortcut="[getSpecialKey(), 'Delete']"
@ -119,6 +120,7 @@ const props = defineProps<{
isEditable: boolean
isSavable: boolean
tabId: string
isTestRunner?: boolean
}>()
const { containerRef } = useScrollerRef(
@ -139,8 +141,13 @@ const emit = defineEmits<{
): void
}>()
/**
* Erases the response body.
* Do not erase if the tab is a saved example or test runner.
*
*/
const eraseResponse = () => {
emit("update:response", null)
if (!props.isEditable && !props.isTestRunner) emit("update:response", null)
}
const { responseBodyText } = useResponseBody(props.response)