diff --git a/packages/hoppscotch-common/src/components/cookies/EditCookie.vue b/packages/hoppscotch-common/src/components/cookies/EditCookie.vue
index 7d1582862..79c80f1a0 100644
--- a/packages/hoppscotch-common/src/components/cookies/EditCookie.vue
+++ b/packages/hoppscotch-common/src/components/cookies/EditCookie.vue
@@ -22,9 +22,9 @@
()
const rawCookieString = ref("")
-const linewrapEnabled = ref(true)
+const WRAP_LINES = useNestedSetting("WRAP_LINES", "cookie")
useCodemirror(
cookieEditor,
@@ -131,7 +133,7 @@ useCodemirror(
extendedEditorConfig: {
mode: "text/plain",
placeholder: `${t("cookies.modal.enter_cookie_string")}`,
- lineWrapping: linewrapEnabled,
+ lineWrapping: WRAP_LINES,
},
linter: null,
completer: null,
diff --git a/packages/hoppscotch-common/src/components/graphql/Headers.vue b/packages/hoppscotch-common/src/components/graphql/Headers.vue
index 6e273968b..4c3e9e25b 100644
--- a/packages/hoppscotch-common/src/components/graphql/Headers.vue
+++ b/packages/hoppscotch-common/src/components/graphql/Headers.vue
@@ -27,9 +27,9 @@
(null)
@@ -137,7 +139,7 @@ const prettifyQueryIcon = refAutoReset<
typeof IconWand | typeof IconCheck | typeof IconInfo
>(IconWand, 1000)
-const linewrapEnabled = ref(true)
+const WRAP_LINES = useNestedSetting("WRAP_LINES", "graphqlQuery")
const selectedOperation = ref(null)
@@ -184,7 +186,7 @@ useCodemirror(
extendedEditorConfig: {
mode: "graphql",
placeholder: `${t("request.query")}`,
- lineWrapping: linewrapEnabled,
+ lineWrapping: WRAP_LINES,
},
linter: createGQLQueryLinter(schema),
completer: queryCompleter(schema),
diff --git a/packages/hoppscotch-common/src/components/graphql/Response.vue b/packages/hoppscotch-common/src/components/graphql/Response.vue
index 1a5d31407..67c0639c0 100644
--- a/packages/hoppscotch-common/src/components/graphql/Response.vue
+++ b/packages/hoppscotch-common/src/components/graphql/Response.vue
@@ -16,9 +16,11 @@
{
})
const schemaEditor = ref(null)
+const WRAP_LINES = useNestedSetting("WRAP_LINES", "graphqlResponseBody")
const copyInterfaceTippyActions = ref(null)
-const linewrapEnabled = ref(true)
useCodemirror(
schemaEditor,
@@ -143,7 +147,7 @@ useCodemirror(
extendedEditorConfig: {
mode: "application/ld+json",
readOnly: true,
- lineWrapping: linewrapEnabled,
+ lineWrapping: WRAP_LINES,
},
linter: null,
completer: null,
diff --git a/packages/hoppscotch-common/src/components/graphql/Sidebar.vue b/packages/hoppscotch-common/src/components/graphql/Sidebar.vue
index 8d3def5f4..4ba5e6729 100644
--- a/packages/hoppscotch-common/src/components/graphql/Sidebar.vue
+++ b/packages/hoppscotch-common/src/components/graphql/Sidebar.vue
@@ -127,9 +127,9 @@
{
}
const schemaEditor = ref(null)
-const linewrapEnabled = ref(true)
+const WRAP_LINES = useNestedSetting("WRAP_LINES", "graphqlSchema")
useCodemirror(
schemaEditor,
@@ -358,7 +360,7 @@ useCodemirror(
extendedEditorConfig: {
mode: "graphql",
readOnly: true,
- lineWrapping: linewrapEnabled,
+ lineWrapping: WRAP_LINES,
},
linter: null,
completer: null,
diff --git a/packages/hoppscotch-common/src/components/graphql/Variable.vue b/packages/hoppscotch-common/src/components/graphql/Variable.vue
index 13aed9be4..bf5eee3a4 100644
--- a/packages/hoppscotch-common/src/components/graphql/Variable.vue
+++ b/packages/hoppscotch-common/src/components/graphql/Variable.vue
@@ -49,9 +49,9 @@
(null)
-const linewrapEnabled = ref(false)
+const WRAP_LINES = useNestedSetting("WRAP_LINES", "graphqlVariables")
const copyVariablesIcon = refAutoReset(
IconCopy,
@@ -131,7 +133,7 @@ useCodemirror(
extendedEditorConfig: {
mode: "application/ld+json",
placeholder: `${t("request.variables")}`,
- lineWrapping: linewrapEnabled,
+ lineWrapping: WRAP_LINES,
},
linter: computed(() =>
variableString.value.length > 0 ? jsonLinter : null
diff --git a/packages/hoppscotch-common/src/components/http/CodegenModal.vue b/packages/hoppscotch-common/src/components/http/CodegenModal.vue
index 6747a1c13..1c7fa178f 100644
--- a/packages/hoppscotch-common/src/components/http/CodegenModal.vue
+++ b/packages/hoppscotch-common/src/components/http/CodegenModal.vue
@@ -86,9 +86,9 @@
{
// Template refs
const tippyActions = ref(null)
const generatedCode = ref(null)
-const linewrapEnabled = ref(true)
+const WRAP_LINES = useNestedSetting("WRAP_LINES", "codeGen")
useCodemirror(
generatedCode,
@@ -233,7 +235,7 @@ useCodemirror(
extendedEditorConfig: {
mode: "text/plain",
readOnly: true,
- lineWrapping: linewrapEnabled,
+ lineWrapping: WRAP_LINES,
},
linter: null,
completer: null,
diff --git a/packages/hoppscotch-common/src/components/http/Headers.vue b/packages/hoppscotch-common/src/components/http/Headers.vue
index 49ec74461..60ef81c6c 100644
--- a/packages/hoppscotch-common/src/components/http/Headers.vue
+++ b/packages/hoppscotch-common/src/components/http/Headers.vue
@@ -29,9 +29,9 @@
v-if="bulkMode"
v-tippy="{ theme: 'tooltip' }"
:title="t('state.linewrap')"
- :class="{ '!text-accent': linewrapEnabled }"
+ :class="{ '!text-accent': WRAP_LINES }"
:icon="IconWrapText"
- @click.prevent="linewrapEnabled = !linewrapEnabled"
+ @click.prevent="toggleNestedSetting('WRAP_LINES', 'httpHeaders')"
/>
(null)
-const linewrapEnabled = ref(true)
+const WRAP_LINES = useNestedSetting("WRAP_LINES", "httpHeaders")
const deletionToast = ref<{ goAway: (delay: number) => void } | null>(null)
@@ -371,7 +374,7 @@ useCodemirror(
extendedEditorConfig: {
mode: "text/x-yaml",
placeholder: `${t("state.bulk_mode_placeholder")}`,
- lineWrapping: linewrapEnabled,
+ lineWrapping: WRAP_LINES,
},
linter,
completer: null,
diff --git a/packages/hoppscotch-common/src/components/http/ImportCurl.vue b/packages/hoppscotch-common/src/components/http/ImportCurl.vue
index 3ec3c8d21..cb60686c8 100644
--- a/packages/hoppscotch-common/src/components/http/ImportCurl.vue
+++ b/packages/hoppscotch-common/src/components/http/ImportCurl.vue
@@ -22,9 +22,9 @@
(null)
-const linewrapEnabled = ref(true)
+const WRAP_LINES = useNestedSetting("WRAP_LINES", "importCurl")
const props = defineProps<{ show: boolean; text: string }>()
@@ -117,7 +119,7 @@ useCodemirror(
extendedEditorConfig: {
mode: "application/x-sh",
placeholder: `${t("request.enter_curl")}`,
- lineWrapping: linewrapEnabled,
+ lineWrapping: WRAP_LINES,
},
linter: null,
completer: null,
diff --git a/packages/hoppscotch-common/src/components/http/Parameters.vue b/packages/hoppscotch-common/src/components/http/Parameters.vue
index 3c9179440..5f0507d64 100644
--- a/packages/hoppscotch-common/src/components/http/Parameters.vue
+++ b/packages/hoppscotch-common/src/components/http/Parameters.vue
@@ -24,9 +24,9 @@
v-if="bulkMode"
v-tippy="{ theme: 'tooltip' }"
:title="t('state.linewrap')"
- :class="{ '!text-accent': linewrapEnabled }"
+ :class="{ '!text-accent': WRAP_LINES }"
:icon="IconWrapText"
- @click.prevent="linewrapEnabled = !linewrapEnabled"
+ @click.prevent="toggleNestedSetting('WRAP_LINES', 'httpParams')"
/>
(null)
-const linewrapEnabled = ref(true)
+const WRAP_LINES = useNestedSetting("WRAP_LINES", "httpParams")
const deletionToast = ref<{ goAway: (delay: number) => void } | null>(null)
@@ -228,7 +230,7 @@ useCodemirror(
extendedEditorConfig: {
mode: "text/x-yaml",
placeholder: `${t("state.bulk_mode_placeholder")}`,
- lineWrapping: linewrapEnabled,
+ lineWrapping: WRAP_LINES,
},
linter,
completer: null,
diff --git a/packages/hoppscotch-common/src/components/http/PreRequestScript.vue b/packages/hoppscotch-common/src/components/http/PreRequestScript.vue
index 08c80a11e..31c88bbf2 100644
--- a/packages/hoppscotch-common/src/components/http/PreRequestScript.vue
+++ b/packages/hoppscotch-common/src/components/http/PreRequestScript.vue
@@ -23,9 +23,9 @@
@@ -72,6 +72,8 @@ import linter from "~/helpers/editor/linting/preRequest"
import completer from "~/helpers/editor/completion/preRequest"
import { useI18n } from "@composables/i18n"
import { useVModel } from "@vueuse/core"
+import { useNestedSetting } from "~/composables/settings"
+import { toggleNestedSetting } from "~/newstore/settings"
const t = useI18n()
@@ -85,7 +87,7 @@ const emit = defineEmits<{
const preRequestScript = useVModel(props, "modelValue", emit)
const preRequestEditor = ref(null)
-const linewrapEnabled = ref(true)
+const WRAP_LINES = useNestedSetting("WRAP_LINES", "httpPreRequest")
useCodemirror(
preRequestEditor,
@@ -93,7 +95,7 @@ useCodemirror(
reactive({
extendedEditorConfig: {
mode: "application/javascript",
- lineWrapping: linewrapEnabled,
+ lineWrapping: WRAP_LINES,
placeholder: `${t("preRequest.javascript_code")}`,
},
linter,
diff --git a/packages/hoppscotch-common/src/components/http/RawBody.vue b/packages/hoppscotch-common/src/components/http/RawBody.vue
index f829eef17..72b420793 100644
--- a/packages/hoppscotch-common/src/components/http/RawBody.vue
+++ b/packages/hoppscotch-common/src/components/http/RawBody.vue
@@ -23,9 +23,9 @@
isJSONContentType(body.value.contentType) ? jsonLinter : null
)
-const linewrapEnabled = ref(true)
+const WRAP_LINES = useNestedSetting("WRAP_LINES", "httpRequestBody")
const rawBodyParameters = ref(null)
const codemirrorValue: Ref =
@@ -148,7 +150,7 @@ useCodemirror(
codemirrorValue,
reactive({
extendedEditorConfig: {
- lineWrapping: linewrapEnabled,
+ lineWrapping: WRAP_LINES,
mode: rawInputEditorLang,
placeholder: t("request.raw_body").toString(),
},
diff --git a/packages/hoppscotch-common/src/components/http/Tests.vue b/packages/hoppscotch-common/src/components/http/Tests.vue
index 63316fe59..28cb128ca 100644
--- a/packages/hoppscotch-common/src/components/http/Tests.vue
+++ b/packages/hoppscotch-common/src/components/http/Tests.vue
@@ -23,9 +23,9 @@
@@ -72,6 +72,8 @@ import linter from "~/helpers/editor/linting/testScript"
import completer from "~/helpers/editor/completion/testScript"
import { useI18n } from "@composables/i18n"
import { useVModel } from "@vueuse/core"
+import { useNestedSetting } from "~/composables/settings"
+import { toggleNestedSetting } from "~/newstore/settings"
const t = useI18n()
@@ -81,7 +83,7 @@ const props = defineProps<{
const emit = defineEmits(["update:modelValue"])
const testScript = useVModel(props, "modelValue", emit)
const testScriptEditor = ref(null)
-const linewrapEnabled = ref(true)
+const WRAP_LINES = useNestedSetting("WRAP_LINES", "httpTest")
useCodemirror(
testScriptEditor,
@@ -89,7 +91,7 @@ useCodemirror(
reactive({
extendedEditorConfig: {
mode: "application/javascript",
- lineWrapping: linewrapEnabled,
+ lineWrapping: WRAP_LINES,
placeholder: `${t("test.javascript_code")}`,
},
linter,
diff --git a/packages/hoppscotch-common/src/components/http/URLEncodedParams.vue b/packages/hoppscotch-common/src/components/http/URLEncodedParams.vue
index ee6d4844d..b484ab82b 100644
--- a/packages/hoppscotch-common/src/components/http/URLEncodedParams.vue
+++ b/packages/hoppscotch-common/src/components/http/URLEncodedParams.vue
@@ -24,9 +24,9 @@
v-if="bulkMode"
v-tippy="{ theme: 'tooltip' }"
:title="t('state.linewrap')"
- :class="{ '!text-accent': linewrapEnabled }"
+ :class="{ '!text-accent': WRAP_LINES }"
:icon="IconWrapText"
- @click.prevent="linewrapEnabled = !linewrapEnabled"
+ @click.prevent="toggleNestedSetting('WRAP_LINES', 'httpUrlEncoded')"
/>
(null)
-const linewrapEnabled = ref(true)
+const WRAP_LINES = useNestedSetting("WRAP_LINES", "httpUrlEncoded")
const deletionToast = ref<{ goAway: (delay: number) => void } | null>(null)
@@ -231,7 +233,7 @@ useCodemirror(
extendedEditorConfig: {
mode: "text/x-yaml",
placeholder: `${t("state.bulk_mode_placeholder")}`,
- lineWrapping: linewrapEnabled,
+ lineWrapping: WRAP_LINES,
},
linter,
completer: null,
diff --git a/packages/hoppscotch-common/src/components/lenses/renderers/HTMLLensRenderer.vue b/packages/hoppscotch-common/src/components/lenses/renderers/HTMLLensRenderer.vue
index 23a8977a0..7e71fb370 100644
--- a/packages/hoppscotch-common/src/components/lenses/renderers/HTMLLensRenderer.vue
+++ b/packages/hoppscotch-common/src/components/lenses/renderers/HTMLLensRenderer.vue
@@ -11,9 +11,9 @@
v-if="response.body"
v-tippy="{ theme: 'tooltip' }"
:title="t('state.linewrap')"
- :class="{ '!text-accent': linewrapEnabled }"
+ :class="{ '!text-accent': WRAP_LINES }"
:icon="IconWrapText"
- @click.prevent="linewrapEnabled = !linewrapEnabled"
+ @click.prevent="toggleNestedSetting('WRAP_LINES', 'httpResponseBody')"
/>
()
const htmlResponse = ref(null)
-const linewrapEnabled = ref(true)
+const WRAP_LINES = useNestedSetting("WRAP_LINES", "httpResponseBody")
const { responseBodyText } = useResponseBody(props.response)
const { downloadIcon, downloadResponse } = useDownloadResponse(
@@ -104,7 +106,7 @@ useCodemirror(
extendedEditorConfig: {
mode: "htmlmixed",
readOnly: true,
- lineWrapping: linewrapEnabled,
+ lineWrapping: WRAP_LINES,
},
linter: null,
completer: null,
diff --git a/packages/hoppscotch-common/src/components/lenses/renderers/JSONLensRenderer.vue b/packages/hoppscotch-common/src/components/lenses/renderers/JSONLensRenderer.vue
index e1faa8c1a..6a2793141 100644
--- a/packages/hoppscotch-common/src/components/lenses/renderers/JSONLensRenderer.vue
+++ b/packages/hoppscotch-common/src/components/lenses/renderers/JSONLensRenderer.vue
@@ -14,9 +14,9 @@
v-if="response.body"
v-tippy="{ theme: 'tooltip' }"
:title="t('state.linewrap')"
- :class="{ '!text-accent': linewrapEnabled }"
+ :class="{ '!text-accent': WRAP_LINES }"
:icon="IconWrapText"
- @click.prevent="linewrapEnabled = !linewrapEnabled"
+ @click.prevent="toggleNestedSetting('WRAP_LINES', 'httpResponseBody')"
/>
(null)
const jsonResponse = ref(null)
+const WRAP_LINES = useNestedSetting("WRAP_LINES", "httpResponseBody")
const copyInterfaceTippyActions = ref(null)
-const linewrapEnabled = ref(true)
const { cursor } = useCodemirror(
jsonResponse,
@@ -381,7 +383,7 @@ const { cursor } = useCodemirror(
extendedEditorConfig: {
mode: "application/ld+json",
readOnly: true,
- lineWrapping: linewrapEnabled,
+ lineWrapping: WRAP_LINES,
},
linter: null,
completer: null,
diff --git a/packages/hoppscotch-common/src/components/lenses/renderers/RawLensRenderer.vue b/packages/hoppscotch-common/src/components/lenses/renderers/RawLensRenderer.vue
index f8a6dff19..8d328c5c8 100644
--- a/packages/hoppscotch-common/src/components/lenses/renderers/RawLensRenderer.vue
+++ b/packages/hoppscotch-common/src/components/lenses/renderers/RawLensRenderer.vue
@@ -11,9 +11,9 @@
v-if="response.body"
v-tippy="{ theme: 'tooltip' }"
:title="t('state.linewrap')"
- :class="{ '!text-accent': linewrapEnabled }"
+ :class="{ '!text-accent': WRAP_LINES }"
:icon="IconWrapText"
- @click.prevent="linewrapEnabled = !linewrapEnabled"
+ @click.prevent="toggleNestedSetting('WRAP_LINES', 'httpResponseBody')"
/>
(null)
-const linewrapEnabled = ref(true)
+const WRAP_LINES = useNestedSetting("WRAP_LINES", "httpResponseBody")
useCodemirror(
rawResponse,
@@ -106,7 +108,7 @@ useCodemirror(
extendedEditorConfig: {
mode: "text/plain",
readOnly: true,
- lineWrapping: linewrapEnabled,
+ lineWrapping: WRAP_LINES,
},
linter: null,
completer: null,
diff --git a/packages/hoppscotch-common/src/components/lenses/renderers/XMLLensRenderer.vue b/packages/hoppscotch-common/src/components/lenses/renderers/XMLLensRenderer.vue
index cef6aedad..6567862bb 100644
--- a/packages/hoppscotch-common/src/components/lenses/renderers/XMLLensRenderer.vue
+++ b/packages/hoppscotch-common/src/components/lenses/renderers/XMLLensRenderer.vue
@@ -11,9 +11,9 @@
v-if="response.body"
v-tippy="{ theme: 'tooltip' }"
:title="t('state.linewrap')"
- :class="{ '!text-accent': linewrapEnabled }"
+ :class="{ '!text-accent': WRAP_LINES }"
:icon="IconWrapText"
- @click.prevent="linewrapEnabled = !linewrapEnabled"
+ @click.prevent="toggleNestedSetting('WRAP_LINES', 'httpResponseBody')"
/>
(null)
-const linewrapEnabled = ref(true)
+const WRAP_LINES = useNestedSetting("WRAP_LINES", "httpResponseBody")
useCodemirror(
xmlResponse,
@@ -100,7 +102,7 @@ useCodemirror(
extendedEditorConfig: {
mode: "application/xml",
readOnly: true,
- lineWrapping: linewrapEnabled,
+ lineWrapping: WRAP_LINES,
},
linter: null,
completer: null,
diff --git a/packages/hoppscotch-common/src/composables/settings.ts b/packages/hoppscotch-common/src/composables/settings.ts
index 9aef1545a..8cfce63b6 100644
--- a/packages/hoppscotch-common/src/composables/settings.ts
+++ b/packages/hoppscotch-common/src/composables/settings.ts
@@ -13,7 +13,36 @@ export function useSetting(
settingsStore.dispatch({
dispatcher: "applySetting",
payload: {
+ // @ts-expect-error TS is not able to understand the type semantics here
settingKey,
+ // @ts-expect-error TS is not able to understand the type semantics here
+ value,
+ },
+ })
+ }
+ )
+}
+
+export function useNestedSetting<
+ K extends keyof SettingsDef,
+ P extends keyof SettingsDef[K],
+>(settingKey: K, property: P): Ref {
+ return useStream(
+ settingsStore.subject$.pipe(
+ pluck(settingKey),
+ pluck(property),
+ distinctUntilChanged()
+ ),
+ settingsStore.value[settingKey][property],
+ (value: SettingsDef[K][P]) => {
+ settingsStore.dispatch({
+ dispatcher: "applyNestedSetting",
+ payload: {
+ // @ts-expect-error TS is not able to understand the type semantics here
+ settingKey,
+ // @ts-expect-error TS is not able to understand the type semantics here
+ property,
+ // @ts-expect-error TS is not able to understand the type semantics here
value,
},
})
@@ -35,7 +64,9 @@ export function useSettingStatic(
settingsStore.dispatch({
dispatcher: "applySetting",
payload: {
+ // @ts-expect-error TS is not able to understand the type semantics here
settingKey,
+ // @ts-expect-error TS is not able to understand the type semantics here
value,
},
})
diff --git a/packages/hoppscotch-common/src/newstore/settings.ts b/packages/hoppscotch-common/src/newstore/settings.ts
index 1b695ed27..eb5249bf6 100644
--- a/packages/hoppscotch-common/src/newstore/settings.ts
+++ b/packages/hoppscotch-common/src/newstore/settings.ts
@@ -30,6 +30,24 @@ export type SettingsDef = {
PROXY_URL: string
+ WRAP_LINES: {
+ httpRequestBody: boolean
+ httpResponseBody: boolean
+ httpHeaders: boolean
+ httpParams: boolean
+ httpUrlEncoded: boolean
+ httpPreRequest: boolean
+ httpTest: boolean
+ graphqlQuery: boolean
+ graphqlResponseBody: boolean
+ graphqlHeaders: boolean
+ graphqlVariables: boolean
+ graphqlSchema: boolean
+ importCurl: boolean
+ codeGen: boolean
+ cookie: boolean
+ }
+
CURRENT_INTERCEPTOR_ID: string
URL_EXCLUDES: {
@@ -53,6 +71,24 @@ export const getDefaultSettings = (): SettingsDef => ({
syncHistory: true,
syncEnvironments: true,
+ WRAP_LINES: {
+ httpRequestBody: true,
+ httpResponseBody: true,
+ httpHeaders: true,
+ httpParams: true,
+ httpUrlEncoded: true,
+ httpPreRequest: true,
+ httpTest: true,
+ graphqlQuery: true,
+ graphqlResponseBody: true,
+ graphqlHeaders: false,
+ graphqlVariables: false,
+ graphqlSchema: true,
+ importCurl: true,
+ codeGen: true,
+ cookie: true,
+ },
+
CURRENT_INTERCEPTOR_ID: "browser", // TODO: Allow the platform definition to take this place
// TODO: Interceptor related settings should move under the interceptor systems
@@ -80,6 +116,16 @@ type ApplySettingPayload = {
}
}[keyof SettingsDef]
+type ApplyNestedSettingPayload = {
+ [K in KeysMatching>]: {
+ [P in keyof SettingsDef[K]]: {
+ settingKey: K
+ property: P
+ value: SettingsDef[K][P]
+ }
+ }[keyof SettingsDef[K]]
+}[KeysMatching>]
+
const dispatchers = defineDispatchers({
bulkApplySettings(_currentState: SettingsDef, payload: Partial) {
return payload
@@ -100,6 +146,29 @@ const dispatchers = defineDispatchers({
return result
},
+ toggleNestedSetting(
+ currentState: SettingsDef,
+ {
+ settingKey,
+ property,
+ }: {
+ settingKey: KeysMatching>
+ property: KeysMatching
+ }
+ ) {
+ if (!has(currentState, [settingKey, property])) {
+ return {}
+ }
+
+ const result: Partial = {
+ [settingKey]: {
+ ...currentState[settingKey],
+ [property]: !currentState[settingKey][property],
+ },
+ }
+
+ return result
+ },
applySetting(
_currentState: SettingsDef,
{ settingKey, value }: ApplySettingPayload
@@ -108,6 +177,18 @@ const dispatchers = defineDispatchers({
[settingKey]: value,
}
+ return result
+ },
+ applyNestedSetting(
+ _currentState: SettingsDef,
+ { settingKey, property, value }: ApplyNestedSettingPayload
+ ) {
+ const result: Partial = {
+ [settingKey]: {
+ [property]: value,
+ },
+ }
+
return result
},
})
@@ -144,6 +225,20 @@ export function toggleSetting(settingKey: KeysMatching) {
})
}
+export function toggleNestedSetting<
+ K extends KeysMatching>,
+ P extends keyof SettingsDef[K],
+>(settingKey: K, property: P) {
+ settingsStore.dispatch({
+ dispatcher: "toggleNestedSetting",
+ payload: {
+ settingKey,
+ // @ts-expect-error TS is not able to understand the type semantics here
+ property,
+ },
+ })
+}
+
export function applySetting(
settingKey: K,
value: SettingsDef[K]
@@ -159,6 +254,22 @@ export function applySetting(
})
}
+export function applyNestedSetting<
+ K extends KeysMatching>,
+ P extends keyof SettingsDef[K],
+ R extends SettingsDef[K][P],
+>(settingKey: K, property: P, value: R) {
+ settingsStore.dispatch({
+ dispatcher: "applyNestedSetting",
+ payload: {
+ settingKey,
+ // @ts-expect-error TS is not able to understand the type semantics here
+ property,
+ value,
+ },
+ })
+}
+
export function performSettingsDataMigrations(data: any): SettingsDef {
const source = cloneDeep(data)
diff --git a/packages/hoppscotch-common/src/services/persistence/validation-schemas/index.ts b/packages/hoppscotch-common/src/services/persistence/validation-schemas/index.ts
index f91194e15..ff7e975ec 100644
--- a/packages/hoppscotch-common/src/services/persistence/validation-schemas/index.ts
+++ b/packages/hoppscotch-common/src/services/persistence/validation-schemas/index.ts
@@ -45,6 +45,26 @@ const SettingsDefSchema = z.object({
SIDEBAR: z.boolean(),
SIDEBAR_ON_LEFT: z.boolean(),
COLUMN_LAYOUT: z.boolean(),
+
+ WRAP_LINES: z.optional(
+ z.object({
+ httpRequestBody: z.boolean(),
+ httpResponseBody: z.boolean(),
+ httpHeaders: z.boolean(),
+ httpParams: z.boolean(),
+ httpUrlEncoded: z.boolean(),
+ httpPreRequest: z.boolean(),
+ httpTest: z.boolean(),
+ graphqlQuery: z.boolean(),
+ graphqlResponseBody: z.boolean(),
+ graphqlHeaders: z.boolean(),
+ graphqlVariables: z.boolean(),
+ graphqlSchema: z.boolean(),
+ importCurl: z.boolean(),
+ codeGen: z.boolean(),
+ cookie: z.boolean(),
+ })
+ ),
})
// Common properties shared across REST & GQL collections