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