Adding to the REST query UI to make it more obvious when it needs saved, such as the user has changed a dynamic variable.
This commit is contained in:
parent
b4b65362f9
commit
fb1f941c76
|
@ -37,7 +37,7 @@
|
||||||
import AccessLevelSelect from "components/integration/AccessLevelSelect.svelte"
|
import AccessLevelSelect from "components/integration/AccessLevelSelect.svelte"
|
||||||
import DynamicVariableModal from "../../_components/DynamicVariableModal.svelte"
|
import DynamicVariableModal from "../../_components/DynamicVariableModal.svelte"
|
||||||
import Placeholder from "assets/bb-spaceship.svg"
|
import Placeholder from "assets/bb-spaceship.svg"
|
||||||
import { cloneDeep } from "lodash/fp"
|
import { cloneDeep, isEqual } from "lodash/fp"
|
||||||
import { RawRestBodyTypes } from "constants/backend"
|
import { RawRestBodyTypes } from "constants/backend"
|
||||||
|
|
||||||
let query, datasource
|
let query, datasource
|
||||||
|
@ -47,6 +47,7 @@
|
||||||
let response, schema, enabledHeaders
|
let response, schema, enabledHeaders
|
||||||
let authConfigId
|
let authConfigId
|
||||||
let dynamicVariables, addVariableModal, varBinding
|
let dynamicVariables, addVariableModal, varBinding
|
||||||
|
let baseQuery, baseDatasource, baseVariables
|
||||||
|
|
||||||
$: datasourceType = datasource?.source
|
$: datasourceType = datasource?.source
|
||||||
$: integrationInfo = $integrations[datasourceType]
|
$: integrationInfo = $integrations[datasourceType]
|
||||||
|
@ -62,6 +63,15 @@
|
||||||
$: hasSchema =
|
$: hasSchema =
|
||||||
Object.keys(schema || {}).length !== 0 ||
|
Object.keys(schema || {}).length !== 0 ||
|
||||||
Object.keys(query?.schema || {}).length !== 0
|
Object.keys(query?.schema || {}).length !== 0
|
||||||
|
$: baseQuery = !baseQuery ? cloneDeep(query) : baseQuery
|
||||||
|
$: baseDatasource = !baseDatasource ? cloneDeep(datasource) : baseDatasource
|
||||||
|
$: baseVariables = !baseVariables
|
||||||
|
? cloneDeep(dynamicVariables)
|
||||||
|
: baseVariables
|
||||||
|
$: hasChanged =
|
||||||
|
!isEqual(baseQuery, query) ||
|
||||||
|
!isEqual(baseDatasource, datasource) ||
|
||||||
|
!isEqual(baseVariables, dynamicVariables)
|
||||||
|
|
||||||
function getSelectedQuery() {
|
function getSelectedQuery() {
|
||||||
return cloneDeep(
|
return cloneDeep(
|
||||||
|
@ -120,6 +130,9 @@
|
||||||
datasource.config.dynamicVariables = rebuildVariables(saveId)
|
datasource.config.dynamicVariables = rebuildVariables(saveId)
|
||||||
datasource = await datasources.save(datasource)
|
datasource = await datasources.save(datasource)
|
||||||
}
|
}
|
||||||
|
baseQuery = query
|
||||||
|
baseDatasource = datasource
|
||||||
|
baseVariables = dynamicVariables
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
notifications.error(`Error saving query`)
|
notifications.error(`Error saving query`)
|
||||||
}
|
}
|
||||||
|
@ -333,7 +346,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={!query.name || !hasChanged}
|
||||||
cta
|
cta
|
||||||
on:click={saveQuery}
|
on:click={saveQuery}
|
||||||
tooltip={!hasSchema
|
tooltip={!hasSchema
|
||||||
|
|
Loading…
Reference in New Issue