Removing .result from evaluation side panel.
This commit is contained in:
parent
9d2f93fd1d
commit
afef511664
|
@ -5,7 +5,8 @@
|
||||||
import { fade } from "svelte/transition"
|
import { fade } from "svelte/transition"
|
||||||
import { UserScriptError } from "@budibase/string-templates"
|
import { UserScriptError } from "@budibase/string-templates"
|
||||||
|
|
||||||
export let expressionResult: string | { result: string } | undefined =
|
// this can be essentially any primitive response from the JS function
|
||||||
|
export let expressionResult: string | boolean | object | number | undefined =
|
||||||
undefined
|
undefined
|
||||||
export let expressionError: string | undefined = undefined
|
export let expressionError: string | undefined = undefined
|
||||||
export let evaluating = false
|
export let evaluating = false
|
||||||
|
@ -14,11 +15,7 @@
|
||||||
$: error = expressionError != null
|
$: error = expressionError != null
|
||||||
$: empty = expression == null || expression?.trim() === ""
|
$: empty = expression == null || expression?.trim() === ""
|
||||||
$: success = !error && !empty
|
$: success = !error && !empty
|
||||||
$: highlightedResult = highlight(
|
$: highlightedResult = highlight(expressionResult)
|
||||||
expressionResult && typeof expressionResult === "object"
|
|
||||||
? expressionResult.result
|
|
||||||
: expressionResult
|
|
||||||
)
|
|
||||||
|
|
||||||
const formatError = (err: any) => {
|
const formatError = (err: any) => {
|
||||||
if (err.code === UserScriptError.code) {
|
if (err.code === UserScriptError.code) {
|
||||||
|
@ -27,7 +24,7 @@
|
||||||
return err.toString()
|
return err.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
const highlight = (json?: string | null) => {
|
const highlight = (json?: any | null) => {
|
||||||
if (json == null) {
|
if (json == null) {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
@ -38,7 +35,7 @@
|
||||||
jsonString = JSON.stringify(JSON.parse(json), null, 2)
|
jsonString = JSON.stringify(JSON.parse(json), null, 2)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// Ignore
|
// Ignore
|
||||||
jsonString = ""
|
jsonString = json
|
||||||
}
|
}
|
||||||
|
|
||||||
return JsonFormatter.format(jsonString, {
|
return JsonFormatter.format(jsonString, {
|
||||||
|
@ -52,10 +49,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const copy = () => {
|
const copy = () => {
|
||||||
let clipboardVal =
|
let clipboardVal = expressionResult
|
||||||
expressionResult && typeof expressionResult === "object"
|
|
||||||
? expressionResult.result
|
|
||||||
: expressionResult
|
|
||||||
if (typeof clipboardVal === "object") {
|
if (typeof clipboardVal === "object") {
|
||||||
clipboardVal = JSON.stringify(clipboardVal, null, 2)
|
clipboardVal = JSON.stringify(clipboardVal, null, 2)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue