This commit is contained in:
Andrés Moya 2026-07-23 14:01:39 +02:00
parent c80a94d9a3
commit ca283f465e
5 changed files with 47 additions and 2 deletions

View File

@ -479,6 +479,18 @@
(:id file-data))]
(= source id)))
(defn editable-tokens?
"Returns true if the file-data owns its tokens (no external source or source is itself)."
[file-data]
(let [source (:tokens-source file-data)]
(or (nil? source) (= source (:id file-data)))))
(defn has-tokens-lib?
"Returns true if the file-data has its own tokens-lib (not an external source)."
[file-data]
(and (some? (:tokens-lib file-data))
(:nil? (:tokens-source file-data))))
(defn get-tokens-lib
[file-data]
(:tokens-lib file-data))

View File

@ -322,6 +322,23 @@
file-data (cfo/set-tokens-source (:data file) source-id)]
(t/is (false? (cfo/tokens-source? file-data (uuid/next)))))))
(t/deftest test-editable-tokens?
(t/testing "returns true when file-data has no tokens-source"
(let [file (thf/sample-file :file1)
file-data (:data file)]
(t/is (true? (cfo/editable-tokens? file-data)))))
(t/testing "returns true when tokens-source is the file's own id"
(let [file (thf/sample-file :file1)
file-data (cfo/set-tokens-source (:data file) (:id (:data file)))]
(t/is (true? (cfo/editable-tokens? file-data)))))
(t/testing "returns false when tokens-source is a different uuid"
(let [source-id (thi/new-id! :tokens-source)
file (thf/sample-file :file1)
file-data (cfo/set-tokens-source (:data file) source-id)]
(t/is (false? (cfo/editable-tokens? file-data))))))
(t/deftest test-get-tokens-status
(t/testing "returns tokens-status from file data"
(let [tokens-status (ctos/make-tokens-status)

View File

@ -9,6 +9,7 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.tokens :as cfo]
[app.common.files.variant :as cfv]
[app.common.types.components-list :as ctkl]
[app.common.types.file :as ctf]
@ -335,7 +336,10 @@
[:div {:class (stl/css :item-content)}
[:div {:class (stl/css :item-title)} (tr "workspace.libraries.file-library")]
[:ul {:class (stl/css :item-contents)}
[:> library-description* {:summary summary}]]]
[:> library-description* {:summary summary}]]
(when (contains? cf/flags :token-lib-sync)
(when (cfo/tokens-source? local-library (:id local-library))
[:div (tr "workspace.libraries.tokens-source")]))]
(if ^boolean is-shared
[:> button* {:variant "secondary"
@ -366,7 +370,11 @@
[:div {:class (stl/css :connected-to-wrapper)}
[:span "(" (tr "workspace.libraries.connected-to") " "]
[:span {:class (stl/css :connected-to-values)} (str/join ", " connected-to-names)]
[:span ")"]])])]]
[:span ")"]])])]
(when (contains? cf/flags :token-lib-sync)
(when (cfo/tokens-source? local-library id)
[:div (tr "workspace.libraries.tokens-source")]))]
[:div {:class (stl/css :library-actions)}
(when ^boolean has-tokens?
[:> icon-button*

View File

@ -7117,6 +7117,10 @@ msgstr "some templates in here"
msgid "workspace.libraries.file-library"
msgstr "File library"
#: src/app/main/ui/workspace/libraries.cljs:336
msgid "workspace.libraries.tokens-source"
msgstr "Tokens source"
#: src/app/main/ui/workspace/libraries.cljs:100, src/app/main/ui/workspace/libraries.cljs:124
msgid "workspace.libraries.graphics"
msgid_plural "workspace.libraries.graphics"

View File

@ -6944,6 +6944,10 @@ msgstr "algunas plantillas aquí"
msgid "workspace.libraries.file-library"
msgstr "Biblioteca del archivo"
#: src/app/main/ui/workspace/libraries.cljs:336
msgid "workspace.libraries.tokens-source"
msgstr "Fuente de tokens"
#: src/app/main/ui/workspace/libraries.cljs:100, src/app/main/ui/workspace/libraries.cljs:124
msgid "workspace.libraries.graphics"
msgid_plural "workspace.libraries.graphics"