Fix save button disabled state
This commit is contained in:
parent
9b0b4ba283
commit
33330a4b40
|
@ -50,6 +50,7 @@
|
||||||
toBindingsArray,
|
toBindingsArray,
|
||||||
} from "@/dataBinding"
|
} from "@/dataBinding"
|
||||||
import ConnectedQueryScreens from "./ConnectedQueryScreens.svelte"
|
import ConnectedQueryScreens from "./ConnectedQueryScreens.svelte"
|
||||||
|
import _ from "lodash"
|
||||||
|
|
||||||
export let queryId
|
export let queryId
|
||||||
|
|
||||||
|
@ -62,6 +63,7 @@
|
||||||
let dynamicVariables, addVariableModal, varBinding, globalDynamicBindings
|
let dynamicVariables, addVariableModal, varBinding, globalDynamicBindings
|
||||||
let restBindings = getRestBindings()
|
let restBindings = getRestBindings()
|
||||||
let nestedSchemaFields = {}
|
let nestedSchemaFields = {}
|
||||||
|
let originalQuery
|
||||||
|
|
||||||
$: staticVariables = datasource?.config?.staticVariables || {}
|
$: staticVariables = datasource?.config?.staticVariables || {}
|
||||||
|
|
||||||
|
@ -103,6 +105,9 @@
|
||||||
|
|
||||||
$: runtimeUrlQueries = readableToRuntimeMap(mergedBindings, breakQs)
|
$: runtimeUrlQueries = readableToRuntimeMap(mergedBindings, breakQs)
|
||||||
|
|
||||||
|
$: isModified =
|
||||||
|
JSON.stringify(originalQuery) !== JSON.stringify(buildQuery(query))
|
||||||
|
|
||||||
function getSelectedQuery() {
|
function getSelectedQuery() {
|
||||||
return cloneDeep(
|
return cloneDeep(
|
||||||
$queries.list.find(q => q._id === queryId) || {
|
$queries.list.find(q => q._id === queryId) || {
|
||||||
|
@ -148,8 +153,11 @@
|
||||||
return qs.length === 0 ? newUrl : `${newUrl}?${qs}`
|
return qs.length === 0 ? newUrl : `${newUrl}?${qs}`
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildQuery() {
|
function buildQuery(fromQuery = query) {
|
||||||
const newQuery = cloneDeep(query)
|
if (!fromQuery) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const newQuery = cloneDeep(fromQuery)
|
||||||
const queryString = restUtils.buildQueryString(runtimeUrlQueries)
|
const queryString = restUtils.buildQueryString(runtimeUrlQueries)
|
||||||
|
|
||||||
newQuery.parameters = restUtils.keyValueToQueryParameters(requestBindings)
|
newQuery.parameters = restUtils.keyValueToQueryParameters(requestBindings)
|
||||||
|
@ -158,7 +166,7 @@
|
||||||
? readableToRuntimeMap(mergedBindings, newQuery.fields.requestBody)
|
? readableToRuntimeMap(mergedBindings, newQuery.fields.requestBody)
|
||||||
: readableToRuntimeBinding(mergedBindings, newQuery.fields.requestBody)
|
: readableToRuntimeBinding(mergedBindings, newQuery.fields.requestBody)
|
||||||
|
|
||||||
newQuery.fields.path = url.split("?")[0]
|
newQuery.fields.path = url?.split("?")[0]
|
||||||
newQuery.fields.queryString = queryString
|
newQuery.fields.queryString = queryString
|
||||||
newQuery.fields.authConfigId = authConfigId
|
newQuery.fields.authConfigId = authConfigId
|
||||||
newQuery.fields.disabledHeaders = restUtils.flipHeaderState(enabledHeaders)
|
newQuery.fields.disabledHeaders = restUtils.flipHeaderState(enabledHeaders)
|
||||||
|
@ -481,6 +489,8 @@
|
||||||
staticVariables,
|
staticVariables,
|
||||||
restBindings
|
restBindings
|
||||||
)
|
)
|
||||||
|
|
||||||
|
originalQuery = _.cloneDeep(buildQuery())
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -532,7 +542,7 @@
|
||||||
</div>
|
</div>
|
||||||
<Button primary disabled={!url} on:click={runQuery}>Send</Button>
|
<Button primary disabled={!url} on:click={runQuery}>Send</Button>
|
||||||
<Button
|
<Button
|
||||||
disabled={!query.name}
|
disabled={!isModified}
|
||||||
cta
|
cta
|
||||||
on:click={saveQuery}
|
on:click={saveQuery}
|
||||||
tooltip={!hasSchema
|
tooltip={!hasSchema
|
||||||
|
|
Loading…
Reference in New Issue