fix: support setting undefined states

This commit is contained in:
Ruben Fiszel
2023-01-02 04:22:56 +01:00
parent 21f98e29ea
commit ab0aeb0df8
11 changed files with 42 additions and 26 deletions
+11 -11
View File
@@ -4095,7 +4095,7 @@ dependencies = [
[[package]]
name = "windmill-api"
version = "1.56.1"
version = "1.57.0"
dependencies = [
"anyhow",
"argon2",
@@ -4146,7 +4146,7 @@ dependencies = [
[[package]]
name = "windmill-api-client"
version = "1.56.1"
version = "1.57.0"
dependencies = [
"base64",
"chrono",
@@ -4161,7 +4161,7 @@ dependencies = [
[[package]]
name = "windmill-audit"
version = "1.56.1"
version = "1.57.0"
dependencies = [
"chrono",
"serde",
@@ -4174,7 +4174,7 @@ dependencies = [
[[package]]
name = "windmill-common"
version = "1.56.1"
version = "1.57.0"
dependencies = [
"anyhow",
"axum",
@@ -4198,7 +4198,7 @@ dependencies = [
[[package]]
name = "windmill-parser"
version = "1.56.1"
version = "1.57.0"
dependencies = [
"serde",
"serde_json",
@@ -4206,7 +4206,7 @@ dependencies = [
[[package]]
name = "windmill-parser-bash"
version = "1.56.1"
version = "1.57.0"
dependencies = [
"anyhow",
"itertools",
@@ -4220,7 +4220,7 @@ dependencies = [
[[package]]
name = "windmill-parser-go"
version = "1.56.1"
version = "1.57.0"
dependencies = [
"anyhow",
"itertools",
@@ -4232,7 +4232,7 @@ dependencies = [
[[package]]
name = "windmill-parser-py"
version = "1.56.1"
version = "1.57.0"
dependencies = [
"anyhow",
"itertools",
@@ -4247,7 +4247,7 @@ dependencies = [
[[package]]
name = "windmill-parser-ts"
version = "1.56.1"
version = "1.57.0"
dependencies = [
"anyhow",
"deno_core",
@@ -4261,7 +4261,7 @@ dependencies = [
[[package]]
name = "windmill-queue"
version = "1.56.1"
version = "1.57.0"
dependencies = [
"anyhow",
"chrono",
@@ -4284,7 +4284,7 @@ dependencies = [
[[package]]
name = "windmill-worker"
version = "1.56.1"
version = "1.57.0"
dependencies = [
"anyhow",
"async-recursion",
+4 -1
View File
@@ -1436,7 +1436,10 @@ paths:
required: true
content:
application/json:
schema: {}
schema:
type: object
properties:
value: {}
responses:
"200":
description: resource value updated
+7 -2
View File
@@ -403,18 +403,23 @@ async fn update_resource(
Ok(format!("resource {} updated (npath: {:?})", path, npath))
}
#[derive(FromRow, Serialize, Deserialize)]
struct UpdateResource {
value: Option<serde_json::Value>,
}
async fn update_resource_value(
authed: Authed,
Extension(user_db): Extension<UserDB>,
Path((w_id, path)): Path<(String, StripPath)>,
Json(nv): Json<serde_json::Value>,
Json(nv): Json<UpdateResource>,
) -> Result<String> {
let path = path.to_path();
let mut tx = user_db.begin(&authed).await?;
sqlx::query!(
"UPDATE resource SET value = $1 WHERE path = $2 AND workspace_id = $3",
nv,
nv.value,
path,
w_id
)
+1 -1
View File
@@ -72,7 +72,7 @@ export async function setResource(value: any, path?: string, initializeToTypeIfN
path = path ?? getStatePath()
const workspace = getWorkspace()
if (await ResourceService.existsResource({ workspace, path })) {
await ResourceService.updateResourceValue({ workspace, path, requestBody: value })
await ResourceService.updateResourceValue({ workspace, path, requestBody: { value } })
} else if (initializeToTypeIfNotExist) {
await ResourceService.createResource({ workspace, requestBody: { path, value, resource_type: initializeToTypeIfNotExist } })
} else {
@@ -8,7 +8,7 @@
<div class="flex flex-row flex-wrap justify-between mt-4 mb-2 min-h-[48px]">
{#if primary}
<span class="flex items-center space-x-2">
<span class="flex items-center space-x-2 mb-2">
<h1>{title}</h1>
{#if tooltip}
<Tooltip>{tooltip}</Tooltip>
@@ -227,8 +227,8 @@
/>
<CenteredPage>
<div class="flex flex-col md:flex-row gap-2 items-center sm:justify-between w-full">
<div>
<div class="flex flex-wrap gap-2 items-center justify-between w-full">
<div class="flex justify-start">
<ToggleButtonGroup bind:selected={itemKind}>
<ToggleButton light position="left" value="all" size="sm">All</ToggleButton>
<ToggleButton light position="center" value="script" size="sm">
@@ -252,7 +252,7 @@
</ToggleButtonGroup>
</div>
<div class="relative text-gray-600 w-full">
<div class="relative text-gray-600 grow min-w-[100px]">
<!-- svelte-ignore a11y-autofocus -->
<input
autofocus
@@ -130,7 +130,7 @@
</Alert>
{/if}
<PageHeader title="Home">
<div class="flex flex-row gap-3 flex-wrap">
<div class="flex flex-row gap-3 flex-wrap justify-end">
{#if !$userStore?.operator}
<CreateActionsScript />
<CreateActionsFlow />
@@ -277,7 +277,7 @@
title="Resources"
tooltip="Save and permission rich objects (JSON) including credentials obtained through OAuth."
>
<div class="flex flex-row space-x-4">
<div class="flex flex-row justify-end gap-4">
<Button variant="border" size="md" startIcon={{ icon: faPlus }} on:click={startNewType}
>Add a resource type</Button
>
@@ -108,9 +108,11 @@
title="Variables"
tooltip="Save and permission strings to be reused in Scripts and Flows."
>
<Button size="md" startIcon={{ icon: faPlus }} on:click={() => variableEditor.initNew()}>
New&nbsp;variable
</Button>
<div class="flex flex-row justify-end">
<Button size="md" startIcon={{ icon: faPlus }} on:click={() => variableEditor.initNew()}>
New&nbsp;variable
</Button>
</div>
</PageHeader>
<VariableEditor bind:this={variableEditor} on:create={loadVariables} />
+4 -1
View File
@@ -73,7 +73,10 @@ func SetResource(path string, value interface{}) error {
if err != nil {
return err
}
res, err := client.Client.UpdateResourceValueWithResponse(context.Background(), client.Workspace, path, value)
res, err := client.Client.UpdateResourceValueWithResponse(
context.Background(),
client.Workspace, path,
api.UpdateResourceValueJSONRequestBody{Value: &value})
if err != nil {
return err
}
+4 -1
View File
@@ -203,6 +203,9 @@ def set_resource(
Set the resource at a given path as a string, creating it if it does not exist
"""
from windmill_api.models.create_resource_json_body import CreateResourceJsonBody
from windmill_api.models.update_resource_value_json_body import (
UpdateResourceValueJsonBody,
)
from windmill_api.api.resource import (
exists_resource,
update_resource_value,
@@ -227,7 +230,7 @@ def set_resource(
workspace=get_workspace(),
client=client,
path=path,
json_body=value,
json_body=UpdateResourceValueJsonBody(value=value),
)