Fixing bug in tabs where double clicks cause tab switching, new headers enabled by default, disabled headers rather than enabled, get requests can have bodies.
This commit is contained in:
parent
740ffae8c8
commit
a7743c8481
|
@ -27,6 +27,7 @@
|
|||
dispatch("select", thisSelected)
|
||||
} else if ($tab.title !== thisSelected) {
|
||||
thisSelected = $tab.title
|
||||
selected = $tab.title
|
||||
dispatch("select", thisSelected)
|
||||
}
|
||||
if ($tab.title !== thisSelected) {
|
||||
|
|
|
@ -26,13 +26,12 @@
|
|||
export let tooltip
|
||||
|
||||
let fields = Object.entries(object).map(([name, value]) => ({ name, value }))
|
||||
let fieldActivity = []
|
||||
let fieldActivity = buildFieldActivity(activity)
|
||||
|
||||
$: object = fields.reduce(
|
||||
(acc, next) => ({ ...acc, [next.name]: next.value }),
|
||||
{}
|
||||
)
|
||||
$: fieldActivity = buildFieldActivity(activity)
|
||||
|
||||
function buildFieldActivity(obj) {
|
||||
if (!obj || typeof obj !== "object") {
|
||||
|
@ -103,11 +102,7 @@
|
|||
/>
|
||||
{/if}
|
||||
{#if toggle}
|
||||
<Toggle
|
||||
bind:value={fieldActivity[idx]}
|
||||
on:change={changed}
|
||||
default={true}
|
||||
/>
|
||||
<Toggle bind:value={fieldActivity[idx]} on:change={changed} />
|
||||
{/if}
|
||||
{#if !readOnly}
|
||||
<Icon hoverable name="Close" on:click={() => deleteEntry(idx)} />
|
||||
|
|
|
@ -108,3 +108,14 @@ export function customQueryIconColor(datasource, query) {
|
|||
return
|
||||
}
|
||||
}
|
||||
|
||||
export function flipHeaderState(headersActivity) {
|
||||
if (!headersActivity) {
|
||||
return {}
|
||||
}
|
||||
const enabled = {}
|
||||
Object.entries(headersActivity).forEach(([key, value]) => {
|
||||
enabled[key] = !value
|
||||
})
|
||||
return enabled
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
buildQueryString,
|
||||
keyValueToQueryParameters,
|
||||
queryParametersToKeyValue,
|
||||
flipHeaderState,
|
||||
} from "helpers/data/utils"
|
||||
import {
|
||||
RestBodyTypes as bodyTypes,
|
||||
|
@ -48,7 +49,7 @@
|
|||
bindings = {}
|
||||
let url = ""
|
||||
let saveId
|
||||
let response, schema, isGet
|
||||
let response, schema, enabledHeaders
|
||||
let datasourceType, integrationInfo, queryConfig, responseSuccess
|
||||
|
||||
$: datasource = $datasources.list.find(ds => ds._id === query?.datasourceId)
|
||||
|
@ -57,7 +58,6 @@
|
|||
$: queryConfig = integrationInfo?.query
|
||||
$: url = buildUrl(url, breakQs)
|
||||
$: checkQueryName(url)
|
||||
$: isGet = query?.queryVerb === "read"
|
||||
$: responseSuccess =
|
||||
response?.info?.code >= 200 && response?.info?.code <= 206
|
||||
|
||||
|
@ -100,6 +100,7 @@
|
|||
const queryString = buildQueryString(breakQs)
|
||||
newQuery.fields.path = url.split("?")[0]
|
||||
newQuery.fields.queryString = queryString
|
||||
newQuery.fields.disabledHeaders = flipHeaderState(enabledHeaders)
|
||||
newQuery.schema = fieldsToSchema(schema)
|
||||
newQuery.parameters = keyValueToQueryParameters(bindings)
|
||||
return newQuery
|
||||
|
@ -139,6 +140,7 @@
|
|||
url = buildUrl(query.fields.path, breakQs)
|
||||
schema = schemaToFields(query.schema)
|
||||
bindings = queryParametersToKeyValue(query.parameters)
|
||||
enabledHeaders = flipHeaderState(query.fields.disabledHeaders)
|
||||
if (query && !query.transformer) {
|
||||
query.transformer = "return data"
|
||||
}
|
||||
|
@ -153,7 +155,7 @@
|
|||
})
|
||||
</script>
|
||||
|
||||
{#if query}
|
||||
{#if query && queryConfig}
|
||||
<div class="inner">
|
||||
<div class="top">
|
||||
<Layout gap="S">
|
||||
|
@ -201,7 +203,7 @@
|
|||
<Tab title="Headers">
|
||||
<KeyValueBuilder
|
||||
bind:object={query.fields.headers}
|
||||
bind:activity={query.fields.enabledHeaders}
|
||||
bind:activity={enabledHeaders}
|
||||
toggle
|
||||
name="header"
|
||||
headings
|
||||
|
@ -210,7 +212,7 @@
|
|||
<Tab title="Body">
|
||||
<RadioGroup
|
||||
bind:value={query.fields.bodyType}
|
||||
options={isGet ? [bodyTypes[0]] : bodyTypes}
|
||||
options={bodyTypes}
|
||||
direction="horizontal"
|
||||
getOptionLabel={option => option.name}
|
||||
getOptionValue={option => option.value}
|
||||
|
|
|
@ -45,7 +45,7 @@ module RestModule {
|
|||
path: string
|
||||
queryString?: string
|
||||
headers: { [key: string]: any }
|
||||
enabledHeaders: { [key: string]: any }
|
||||
disabledHeaders: { [key: string]: any }
|
||||
requestBody: any
|
||||
bodyType: string
|
||||
json: object
|
||||
|
@ -161,15 +161,15 @@ module RestModule {
|
|||
}
|
||||
|
||||
async _req(query: RestQuery) {
|
||||
const { path = "", queryString = "", headers = {}, method = "GET", enabledHeaders, bodyType, requestBody } = query
|
||||
const { path = "", queryString = "", headers = {}, method = "GET", disabledHeaders, bodyType, requestBody } = query
|
||||
this.headers = {
|
||||
...this.config.defaultHeaders,
|
||||
...headers,
|
||||
}
|
||||
|
||||
if (enabledHeaders) {
|
||||
if (disabledHeaders) {
|
||||
for (let headerKey of Object.keys(this.headers)) {
|
||||
if (!enabledHeaders[headerKey]) {
|
||||
if (disabledHeaders[headerKey]) {
|
||||
delete this.headers[headerKey]
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue