Co-authored-by: liyasthomas <liyascthomas@gmail.com>
This commit is contained in:
@@ -308,7 +308,7 @@ import { GQLConnection } from "~/helpers/GQLConnection"
|
|||||||
import { makeGQLHistoryEntry, addGraphqlHistoryEntry } from "~/newstore/history"
|
import { makeGQLHistoryEntry, addGraphqlHistoryEntry } from "~/newstore/history"
|
||||||
import { logHoppRequestRunToAnalytics } from "~/helpers/fb/analytics"
|
import { logHoppRequestRunToAnalytics } from "~/helpers/fb/analytics"
|
||||||
import { getCurrentStrategyID } from "~/helpers/network"
|
import { getCurrentStrategyID } from "~/helpers/network"
|
||||||
import { makeGQLRequest } from "~/helpers/types/HoppGQLRequest"
|
import { GQLHeader, makeGQLRequest } from "~/helpers/types/HoppGQLRequest"
|
||||||
import { useCodemirror } from "~/helpers/editor/codemirror"
|
import { useCodemirror } from "~/helpers/editor/codemirror"
|
||||||
import jsonLinter from "~/helpers/editor/linting/json"
|
import jsonLinter from "~/helpers/editor/linting/json"
|
||||||
import { createGQLQueryLinter } from "~/helpers/editor/linting/gqlQuery"
|
import { createGQLQueryLinter } from "~/helpers/editor/linting/gqlQuery"
|
||||||
@@ -402,18 +402,11 @@ watch(
|
|||||||
{ deep: true }
|
{ deep: true }
|
||||||
)
|
)
|
||||||
|
|
||||||
const editBulkHeadersLine = (
|
const editBulkHeadersLine = (index: number, item?: GQLHeader | null) => {
|
||||||
index: number,
|
|
||||||
item?: {
|
|
||||||
key: string
|
|
||||||
value: string
|
|
||||||
active: boolean
|
|
||||||
}
|
|
||||||
) => {
|
|
||||||
bulkHeaders.value = headers.value
|
bulkHeaders.value = headers.value
|
||||||
.reduce((all, header, pIndex) => {
|
.reduce((all, header, pIndex) => {
|
||||||
const current =
|
const current =
|
||||||
index === pIndex && item !== null
|
index === pIndex && item != null
|
||||||
? `${item.active ? "" : "//"}${item.key}: ${item.value}`
|
? `${item.active ? "" : "//"}${item.key}: ${item.value}`
|
||||||
: `${header.active ? "" : "//"}${header.key}: ${header.value}`
|
: `${header.active ? "" : "//"}${header.key}: ${header.value}`
|
||||||
return [...all, current]
|
return [...all, current]
|
||||||
@@ -542,8 +535,27 @@ const updateRequestHeader = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
const removeRequestHeader = (index: number) => {
|
const removeRequestHeader = (index: number) => {
|
||||||
|
const headersBeforeDeletion = headers.value
|
||||||
|
|
||||||
removeGQLHeader(index)
|
removeGQLHeader(index)
|
||||||
editBulkHeadersLine(index, null)
|
editBulkHeadersLine(index, null)
|
||||||
|
|
||||||
|
const deletedItem = headersBeforeDeletion[index]
|
||||||
|
if (deletedItem.key || deletedItem.value) {
|
||||||
|
$toast.success(t("state.deleted").toString(), {
|
||||||
|
icon: "delete",
|
||||||
|
action: [
|
||||||
|
{
|
||||||
|
text: t("action.undo").toString(),
|
||||||
|
onClick: (_, toastObject) => {
|
||||||
|
setGQLHeaders(headersBeforeDeletion as GQLHeader[])
|
||||||
|
editBulkHeadersLine(index, deletedItem)
|
||||||
|
toastObject.goAway(0)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const clearContent = () => {
|
const clearContent = () => {
|
||||||
|
|||||||
@@ -172,7 +172,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, useContext, watch, onBeforeUpdate } from "@nuxtjs/composition-api"
|
import { onBeforeUpdate, ref, useContext, watch } from "@nuxtjs/composition-api"
|
||||||
import { useCodemirror } from "~/helpers/editor/codemirror"
|
import { useCodemirror } from "~/helpers/editor/codemirror"
|
||||||
import {
|
import {
|
||||||
addRESTHeader,
|
addRESTHeader,
|
||||||
@@ -238,13 +238,13 @@ watch(
|
|||||||
|
|
||||||
onBeforeUpdate(() => editBulkHeadersLine(-1, null))
|
onBeforeUpdate(() => editBulkHeadersLine(-1, null))
|
||||||
|
|
||||||
const editBulkHeadersLine = (index: number, item?: HoppRESTParam) => {
|
const editBulkHeadersLine = (index: number, item?: HoppRESTHeader | null) => {
|
||||||
const headers = headers$.value
|
const headers = headers$.value
|
||||||
|
|
||||||
bulkHeaders.value = headers
|
bulkHeaders.value = headers
|
||||||
.reduce((all, header, pIndex) => {
|
.reduce((all, header, pIndex) => {
|
||||||
const current =
|
const current =
|
||||||
index === pIndex && item !== null
|
index === pIndex && item != null
|
||||||
? `${item.active ? "" : "//"}${item.key}: ${item.value}`
|
? `${item.active ? "" : "//"}${item.key}: ${item.value}`
|
||||||
: `${header.active ? "" : "//"}${header.key}: ${header.value}`
|
: `${header.active ? "" : "//"}${header.key}: ${header.value}`
|
||||||
return [...all, current]
|
return [...all, current]
|
||||||
@@ -270,8 +270,27 @@ const updateHeader = (index: number, item: HoppRESTHeader) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const deleteHeader = (index: number) => {
|
const deleteHeader = (index: number) => {
|
||||||
|
const headersBeforeDeletion = headers$.value
|
||||||
|
|
||||||
deleteRESTHeader(index)
|
deleteRESTHeader(index)
|
||||||
editBulkHeadersLine(index, null)
|
editBulkHeadersLine(index, null)
|
||||||
|
|
||||||
|
const deletedItem = headersBeforeDeletion[index]
|
||||||
|
if (deletedItem.key || deletedItem.value) {
|
||||||
|
$toast.success(t("state.deleted").toString(), {
|
||||||
|
icon: "delete",
|
||||||
|
action: [
|
||||||
|
{
|
||||||
|
text: t("action.undo").toString(),
|
||||||
|
onClick: (_, toastObject) => {
|
||||||
|
setRESTHeaders(headersBeforeDeletion as HoppRESTHeader[])
|
||||||
|
editBulkHeadersLine(index, deletedItem)
|
||||||
|
toastObject.goAway(0)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const clearContent = () => {
|
const clearContent = () => {
|
||||||
|
|||||||
@@ -231,13 +231,13 @@ watch(
|
|||||||
|
|
||||||
onBeforeUpdate(() => editBulkParamsLine(-1, null))
|
onBeforeUpdate(() => editBulkParamsLine(-1, null))
|
||||||
|
|
||||||
const editBulkParamsLine = (index: number, item?: HoppRESTParam) => {
|
const editBulkParamsLine = (index: number, item?: HoppRESTParam | null) => {
|
||||||
const params = params$.value
|
const params = params$.value
|
||||||
|
|
||||||
bulkParams.value = params
|
bulkParams.value = params
|
||||||
.reduce((all, param, pIndex) => {
|
.reduce((all, param, pIndex) => {
|
||||||
const current =
|
const current =
|
||||||
index === pIndex && item !== null
|
index === pIndex && item != null
|
||||||
? `${item.active ? "" : "//"}${item.key}: ${item.value}`
|
? `${item.active ? "" : "//"}${item.key}: ${item.value}`
|
||||||
: `${param.active ? "" : "//"}${param.key}: ${param.value}`
|
: `${param.active ? "" : "//"}${param.key}: ${param.value}`
|
||||||
return [...all, current]
|
return [...all, current]
|
||||||
@@ -263,8 +263,27 @@ const updateParam = (index: number, item: HoppRESTParam) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const deleteParam = (index: number) => {
|
const deleteParam = (index: number) => {
|
||||||
|
const parametersBeforeDeletion = params$.value
|
||||||
|
|
||||||
deleteRESTParam(index)
|
deleteRESTParam(index)
|
||||||
editBulkParamsLine(index, null)
|
editBulkParamsLine(index, null)
|
||||||
|
|
||||||
|
const deletedItem = parametersBeforeDeletion[index]
|
||||||
|
if (deletedItem.key || deletedItem.value) {
|
||||||
|
$toast.success(t("state.deleted").toString(), {
|
||||||
|
icon: "delete",
|
||||||
|
action: [
|
||||||
|
{
|
||||||
|
text: t("action.undo").toString(),
|
||||||
|
onClick: (_, toastObject) => {
|
||||||
|
setRESTParams(parametersBeforeDeletion as HoppRESTParam[])
|
||||||
|
editBulkParamsLine(index, deletedItem)
|
||||||
|
toastObject.goAway(0)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const clearContent = () => {
|
const clearContent = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user