From 155683dbe0883fbfe11336ff0b1abba4dc63cba7 Mon Sep 17 00:00:00 2001 From: Eva Marco Date: Wed, 29 Oct 2025 15:44:23 +0100 Subject: [PATCH] WIP --- .../main/ui/workspace/tokens/management/create/form.cljs | 8 ++++++-- .../tokens/management/create/input_tokens_value.cljs | 9 +++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/frontend/src/app/main/ui/workspace/tokens/management/create/form.cljs b/frontend/src/app/main/ui/workspace/tokens/management/create/form.cljs index e3ed6a6ad9..53c1dd6629 100644 --- a/frontend/src/app/main/ui/workspace/tokens/management/create/form.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/management/create/form.cljs @@ -119,7 +119,7 @@ (defn- validate-token-with [token validators] (if-let [error (some (fn [validate] (validate token)) validators)] - (rx/throw {:errors [error]}) + (rx/throw {:errors [error] :pepito "kakota"}) (rx/of token))) (def ^:private default-validators @@ -151,7 +151,10 @@ ;; Simple validation of the editing token (rx/mapcat #(validate-token-with % validators)) ;; Resolving token via StyleDictionary - (rx/mapcat #(validate-resolve-token % prev-token tokens))))) + (rx/mapcat #(validate-resolve-token % prev-token tokens)) + (rx/catch (fn [e] (if (contains? e :errors) + {:errors (:errors e)} + (rx/throw e))))))) (defn- check-coll-self-reference "Invalidate a collection of `token-vals` for a self-refernce against `token-name`.," @@ -626,6 +629,7 @@ :type token-type :on-blur on-update-value :on-change on-update-value + :on-external-update-value on-external-update-value :token-resolve-result token-resolve-result}]))] [:div {:class (stl/css :input-row)} [:> input* {:label (tr "workspace.tokens.token-description") diff --git a/frontend/src/app/main/ui/workspace/tokens/management/create/input_tokens_value.cljs b/frontend/src/app/main/ui/workspace/tokens/management/create/input_tokens_value.cljs index e8846804e2..69258b8a4e 100644 --- a/frontend/src/app/main/ui/workspace/tokens/management/create/input_tokens_value.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/management/create/input_tokens_value.cljs @@ -157,7 +157,7 @@ (mf/defc input-token* {::mf/forward-ref true ::mf/schema schema::input-token} - [{:keys [class label token-resolve-result tokens empty-to-end type] :rest props} ref] + [{:keys [class label token-resolve-result tokens empty-to-end type on-external-update-value] :rest props} ref] (let [error (not (nil? (:errors token-resolve-result))) id (mf/use-id) @@ -211,7 +211,7 @@ sorted-tokens) no-sets? (nil? sorted-tokens)] (generate-dropdown-options options no-sets?)))) - + update-input (mf/use-fn (mf/deps ref) @@ -231,7 +231,8 @@ option (get-option options id) name (get option :name) new-value (str "{" name "}")] - (update-input new-value)))) + (on-external-update-value new-value) + (reset! is-open* false)))) open-dropdown (mf/use-fn @@ -251,7 +252,7 @@ :ref open-dropdown-ref :on-click open-dropdown}])) :ref ref})] - + (mf/with-effect [dropdown-options] (mf/set-ref-val! options-ref dropdown-options)) [:*