mirror of
https://github.com/penpot/penpot.git
synced 2026-11-20 09:00:49 +00:00
✨ Explain why a library cannot be disconnected in its modal (#12921)
* ✨ Explain why a library cannot be disconnected in its modal A library that another connected library uses cannot be disconnected from a file, but the Libraries modal showed it with the same disconnect button as any other library, only disabled, and said nothing about why. Replace that button with an icon and a tooltip. A nested library ("Connected through ...") says it is inherited from its parent, and a direct library that another connected library uses says which one. Both name the library to disconnect first. A library nothing else uses keeps its button. library-disconnect-hint decides the case from the same data the disabled state used, so the buttons that were disabled are the ones that change. The legacy libraries tab keeps its button. Closes #12838 AI-assisted-by: claude-opus-5-5 AI-assisted-by: claude-sonnet-5-5 Signed-off-by: Filip Sajdak <filip.sajdak@siili.com> * 🐛 Name every library to disconnect in the disconnect hint The hint named only the parent of a nested library as the one to disconnect. That was wrong when several libraries use it (disconnecting one leaves it linked through the others) and no help when the parent is nested too and has no disconnect button either. The removal step now lists the libraries the user can actually disconnect: those that use the library directly or through others, and that no linked library uses. The parent is still named as the reason it is inherited. In a cycle nothing is removable, so the parent is named as before. Tests cover a shared dependency, a deep chain and a cycle. AI-assisted-by: claude-opus-5-5 AI-assisted-by: claude-sonnet-5-5 Signed-off-by: Filip Sajdak <filip.sajdak@siili.com> * 🐛 List directly linked libraries in the disconnect hint A library linked to the file directly stays until the user disconnects it, even when another linked library uses it. The hint skipped those: for a file linked to A and B, with A using B and B using C, it told the user to disconnect only A, and C stayed linked through B. Collect the libraries that use it, however far up, and that are either linked directly or used by no linked library. A directly linked library that another one uses cannot be disconnected yet, and its own tooltip says to disconnect that one first. The test covers a directly linked intermediate library. AI-assisted-by: claude-opus-5-5 AI-assisted-by: claude-sonnet-5-5 Signed-off-by: Filip Sajdak <filip.sajdak@siili.com> * 🐛 Count a library linked in this session as direct in the hint Only the libraries fetched when the workspace opens carry :is-indirect. One linked afterwards comes back without it, so the hint did not treat it as directly linked: after connecting B (which uses C) and then A (which uses B) without reloading, C's tooltip said to disconnect only A, and C stayed linked through B. A library the user linked has no flag and is direct by construction, so only one known to be indirect is skipped. The test covers that sequence. AI-assisted-by: claude-opus-5-5 AI-assisted-by: claude-sonnet-5-5 Signed-off-by: Filip Sajdak <filip.sajdak@siili.com> * 🐛 Flag libraries linked in this session as direct or indirect Only the libraries fetched when the workspace opens carried :is-indirect. Linking a library afterwards loads it and its dependencies through load-library-file, and none of them got the flag, so a missing flag could mean either. The disconnect hint in the Libraries modal reads it to tell which libraries the user can disconnect, and it listed the wrong ones for a chain connected in the same session (it named a dependency that has no disconnect button). Set the flag where the library is loaded: the library the user links is direct and the libraries it brings in are indirect. The hint is back to trusting only a flag that says false, because a missing one no longer means a direct link. The test links a library with one dependency and checks both flags. AI-assisted-by: claude-opus-5-5 AI-assisted-by: claude-sonnet-5-5 Signed-off-by: Filip Sajdak <filip.sajdak@siili.com> * 🐛 Keep a library's direct flag when it is loaded twice When links overlap, a library can be requested twice: once because the user linked it and once because a library linked right after brings it in. Each load stored its own :is-indirect value, so whichever answer landed last won, and an indirect one could erase the direct link. The disconnect hint then listed the wrong libraries. Store a loaded library through one event that never turns a known direct link into an indirect one. The reverse order already ends direct, since the user's link is stored with the flag false. The test links a library and then one that uses it before the first answer arrives, and answers in the order that used to lose the flag. AI-assisted-by: claude-opus-5-5 AI-assisted-by: claude-sonnet-5-5 Signed-off-by: Filip Sajdak <filip.sajdak@siili.com> * 🐛 Scope a library's kept direct flag to the file it belongs to The flag kept when a library is loaded twice was read from :files, which outlives a workspace. A library that was a direct link of the file visited before could keep that flag in the next file, where another library only brings it in, and the disconnect hint then listed one library too many. Keep the flag only when it was recorded for the file being loaded, using the :library-of the entry already carries. The test leaves a library flagged direct for another file and links a library that brings it in. AI-assisted-by: claude-opus-5-5 AI-assisted-by: claude-sonnet-5-5 Signed-off-by: Filip Sajdak <filip.sajdak@siili.com> * 💄 Name the libraries in the disconnect hint as design asked The nested library hint now reads "Connected through <parent>. To remove it, disconnect <libraries>." instead of "Inherited from ...". The library names in both hints (connected through and used by) show in the primary foreground color, so they stand out from the text. The translation is split on its two placeholders instead of rendered as HTML, because the library names are written by users. The full plain sentence stays as the aria label of the icon. The new key is workspace.libraries.connected-through-hint, since workspace.libraries.connected-through already labels the parent in the list. AI-assisted-by: claude-sonnet-5-5 Signed-off-by: Filip Sajdak <filip.sajdak@siili.com> --------- Signed-off-by: Filip Sajdak <filip.sajdak@siili.com> Co-authored-by: Eva Marco <evamarcod@gmail.com>
This commit is contained in:
parent
454e461c1e
commit
c40287254c
@ -1821,8 +1821,30 @@
|
||||
(d/index-by :id))))))
|
||||
|
||||
|
||||
(defn- library-loaded
|
||||
"Stores `file`, a library of `file-id`, with its `:is-indirect` flag. A
|
||||
library can be requested twice when links overlap, once because the
|
||||
user linked it and once because another library brings it in. The
|
||||
direct link wins whichever answer lands last. Only a flag recorded for
|
||||
`file-id` counts: `:files` outlives the workspace, and a library can be
|
||||
direct in the file visited before and indirect in this one."
|
||||
[file-id file indirect?]
|
||||
(ptk/reify ::library-loaded
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(let [known (get-in state [:files (:id file)])
|
||||
known-direct? (and (= file-id (:library-of known))
|
||||
(false? (:is-indirect known)))]
|
||||
(update state :files assoc (:id file)
|
||||
(assoc file
|
||||
:library-of file-id
|
||||
:is-indirect (and indirect? (not known-direct?))))))))
|
||||
|
||||
(defn- load-library-file
|
||||
[file-id library-id]
|
||||
"Loads a library of `file-id`. `indirect?` tells whether it is there
|
||||
only because another library uses it, like the flag the libraries
|
||||
fetched when the workspace opens carry."
|
||||
[file-id library-id indirect?]
|
||||
(ptk/reify ::load-library-file
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
@ -1832,7 +1854,7 @@
|
||||
(rx/merge-map fpmap/resolve-file)
|
||||
(rx/mapcat (fn [file]
|
||||
(rx/of
|
||||
(libraries-fetched file-id [file])))))
|
||||
(library-loaded file-id file indirect?)))))
|
||||
(->> (rp/cmd! :get-file-object-thumbnails {:file-id library-id :tag "component"})
|
||||
(rx/map (fn [thumbnails]
|
||||
(fn [state]
|
||||
@ -1867,7 +1889,7 @@
|
||||
(as-> libraries-to-load $
|
||||
(remove loaded-libraries $)
|
||||
(conj $ library-id)
|
||||
(map #(load-library-file file-id %) $))))
|
||||
(map #(load-library-file file-id % (not= % library-id)) $))))
|
||||
(rx/catch (fn [cause]
|
||||
(let [error (ex-data cause)]
|
||||
(if (= (:code error) :circular-library-reference)
|
||||
|
||||
@ -40,6 +40,7 @@
|
||||
[app.main.ui.ds.foundations.typography.text :refer [text*]]
|
||||
[app.main.ui.ds.layout.tab-switcher :refer [tab-switcher*]]
|
||||
[app.main.ui.ds.product.empty-state :refer [empty-state*]]
|
||||
[app.main.ui.ds.tooltip.tooltip :refer [tooltip*]]
|
||||
[app.main.ui.hooks :as h]
|
||||
[app.main.ui.icons :as deprecated-icon]
|
||||
[app.main.ui.workspace.tokens.import-from-library]
|
||||
@ -159,6 +160,83 @@
|
||||
(reduce #(visit %1 %2 nil) $ (sort-by-name libraries))
|
||||
(first $))))
|
||||
|
||||
(defn- linked-users
|
||||
[{:keys [connected-to]} libraries-by-id]
|
||||
(into [] (keep libraries-by-id) connected-to))
|
||||
|
||||
(defn- removable-users
|
||||
"The linked libraries to disconnect to release `library`: those that use
|
||||
it, directly or through other libraries, and that either are linked to
|
||||
the file directly or are used by no linked library. A directly linked
|
||||
library stays until it is disconnected, even when another one uses it.
|
||||
Empty when the libraries only use each other in a cycle."
|
||||
[library libraries-by-id]
|
||||
(loop [pending (linked-users library libraries-by-id)
|
||||
seen #{(:id library)}
|
||||
removable []]
|
||||
(if-let [user (first pending)]
|
||||
(if (contains? seen (:id user))
|
||||
(recur (rest pending) seen removable)
|
||||
(let [users (linked-users user libraries-by-id)]
|
||||
(recur (into (rest pending) users)
|
||||
(conj seen (:id user))
|
||||
(cond-> removable
|
||||
(or (empty? users) (false? (:is-indirect user)))
|
||||
(conj user)))))
|
||||
removable)))
|
||||
|
||||
(defn library-disconnect-hint
|
||||
"Why a linked library cannot be disconnected from this file, or nil when
|
||||
it can. A library that another linked library uses stays connected as
|
||||
long as that one does. Returns `{:reason :inherited}` for a nested
|
||||
library, with the name of its parent, and `{:reason :used-by}` for a
|
||||
direct one, with the name of the first library by name that uses it.
|
||||
|
||||
Both carry `:removable`, the names of the libraries to disconnect to
|
||||
release this one, sorted by name. The parent can be nested itself, a
|
||||
library can have several parents, and a parent can be linked directly
|
||||
as well. In a cycle nothing is removable, and `:removable` holds the
|
||||
name given in `:library-name`. `libraries-by-id` indexes the linked
|
||||
libraries by id."
|
||||
[{:keys [nested? parent-name] :as library} libraries-by-id]
|
||||
(let [users (linked-users library libraries-by-id)]
|
||||
(when (seq users)
|
||||
(let [library-name (if nested?
|
||||
parent-name
|
||||
(->> users (sort-by (comp str/lower :name)) first :name))
|
||||
removable (->> (removable-users library libraries-by-id)
|
||||
(map :name)
|
||||
(sort-by str/lower)
|
||||
(vec))]
|
||||
{:reason (if nested? :inherited :used-by)
|
||||
:library-name library-name
|
||||
:removable (if (seq removable) removable [library-name])}))))
|
||||
|
||||
(defn disconnect-hint-segments
|
||||
"Splits a translated disconnect hint template, which holds two `%s`
|
||||
(the library that keeps this one, then the libraries to disconnect),
|
||||
into `[:text s]` and `[:name s]` segments in reading order, so the UI
|
||||
can highlight the library names. Each of `removable` is its own name
|
||||
segment, separated by `[:text \", \"]`."
|
||||
[template library-name removable]
|
||||
(let [[before between after] (vec (.split ^string template "%s"))
|
||||
names (into []
|
||||
(comp (map (fn [n] [:name n]))
|
||||
(interpose [:text ", "]))
|
||||
removable)]
|
||||
(-> [[:text before] [:name library-name] [:text between]]
|
||||
(into names)
|
||||
(conj [:text after]))))
|
||||
|
||||
(mf/defc disconnect-hint-text*
|
||||
{::mf/private true}
|
||||
[{:keys [template library-name removable]}]
|
||||
[:*
|
||||
(for [[idx [kind text]] (map-indexed vector (disconnect-hint-segments template library-name removable))]
|
||||
(if (= kind :name)
|
||||
[:span {:key idx :class (stl/css :library-name-highlight)} text]
|
||||
[:span {:key idx} text]))])
|
||||
|
||||
(defn- describe-library
|
||||
[components-count graphics-count colors-count typography-count]
|
||||
(let [all-zero? (and (zero? components-count)
|
||||
@ -732,9 +810,9 @@
|
||||
(map #(assoc % :connected-to (find-connected-to (:id %))))
|
||||
(sort-linked-libraries)))
|
||||
|
||||
linked-libraries-ids
|
||||
libraries-by-id
|
||||
(mf/with-memo [linked-libraries]
|
||||
(into #{} d/xf:map-id linked-libraries))
|
||||
(d/index-by :id linked-libraries))
|
||||
|
||||
unlink-library
|
||||
(mf/use-fn
|
||||
@ -865,8 +943,10 @@
|
||||
:class (stl/css :title-spacing-lib)
|
||||
:title-class (stl/css :connected-libraries-title)}]
|
||||
(if (seq linked-libraries)
|
||||
(for [{:keys [id name data connected-to nested? parent-name] :as library} linked-libraries]
|
||||
(let [disabled? (some #(contains? linked-libraries-ids %) connected-to)
|
||||
(for [{:keys [id name data nested? parent-name] :as library} linked-libraries]
|
||||
(let [hint (library-disconnect-hint library libraries-by-id)
|
||||
hint-library (:library-name hint)
|
||||
hint-removable (str/join ", " (:removable hint))
|
||||
can-import-tokens? (and (has-tokens? library)
|
||||
(cfo/editable-tokens? local-library)
|
||||
(contains? cf/flags :token-import-from-library))]
|
||||
@ -904,13 +984,31 @@
|
||||
:variant "secondary"
|
||||
:on-click import-tokens}]))
|
||||
|
||||
[:> icon-button* {:type "button"
|
||||
:aria-label (tr "workspace.libraries.unlink-library-btn")
|
||||
:icon i/detach
|
||||
:data-library-id (dm/str id)
|
||||
:variant "secondary"
|
||||
:disabled disabled?
|
||||
:on-click unlink-library}]]]))
|
||||
(if (some? hint)
|
||||
[:> tooltip* {:class (stl/css :library-locked)
|
||||
:tab-index 0
|
||||
:data-testid "library-locked"
|
||||
:aria-label (case (:reason hint)
|
||||
:inherited (tr "workspace.libraries.connected-through-hint"
|
||||
hint-library hint-removable)
|
||||
:used-by (tr "workspace.libraries.used-by"
|
||||
hint-library hint-removable))
|
||||
:content #(mf/html
|
||||
[:> disconnect-hint-text*
|
||||
{:template (case (:reason hint)
|
||||
:inherited (tr "workspace.libraries.connected-through-hint")
|
||||
:used-by (tr "workspace.libraries.used-by"))
|
||||
:library-name hint-library
|
||||
:removable (:removable hint)}])}
|
||||
[:> icon* {:icon-id (case (:reason hint)
|
||||
:inherited i/arrow-up
|
||||
:used-by i/info)}]]
|
||||
[:> icon-button* {:type "button"
|
||||
:aria-label (tr "workspace.libraries.unlink-library-btn")
|
||||
:icon i/detach
|
||||
:data-library-id (dm/str id)
|
||||
:variant "secondary"
|
||||
:on-click unlink-library}])]]))
|
||||
[:div {:class (stl/css :shared-libraries-empty)}
|
||||
[:> text* {:class (stl/css :empty-libraries-text)
|
||||
:as "span"
|
||||
|
||||
@ -308,6 +308,19 @@
|
||||
gap: var(--sp-xs);
|
||||
}
|
||||
|
||||
.library-name-highlight {
|
||||
color: var(--color-foreground-primary);
|
||||
}
|
||||
|
||||
.library-locked {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
inline-size: $sz-32;
|
||||
block-size: $sz-32;
|
||||
color: var(--color-foreground-secondary);
|
||||
}
|
||||
|
||||
.element-count-legacy {
|
||||
white-space: nowrap;
|
||||
|
||||
|
||||
@ -0,0 +1,109 @@
|
||||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; Copyright (c) KALEIDOS SUBSIDIARY SL
|
||||
|
||||
(ns frontend-tests.data.workspace-libraries-link-test
|
||||
"The libraries a file links to while it is open, loaded after the
|
||||
workspace was."
|
||||
(:require
|
||||
[app.common.test-helpers.files :as cthf]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.main.data.workspace.libraries :as dwl]
|
||||
[app.main.repo :as rp]
|
||||
[beicon.v2.core :as rx]
|
||||
[cljs.test :as t :include-macros true]
|
||||
[frontend-tests.helpers.async :as async]
|
||||
[frontend-tests.helpers.mock :as mock]
|
||||
[frontend-tests.helpers.state :as ths]
|
||||
[potok.v2.core :as ptk]))
|
||||
|
||||
(defn- library-cmd
|
||||
"An RPC mock for linking a library whose dependencies are `dependencies`."
|
||||
[dependencies]
|
||||
(mock/stub
|
||||
(fn [command params]
|
||||
(case command
|
||||
:link-file-to-library (rx/of dependencies)
|
||||
:get-file (rx/of {:id (:id params) :name "Library" :data {}})
|
||||
:get-file-object-thumbnails (rx/of {})))))
|
||||
|
||||
(t/deftest ^:async linking-a-library-marks-it-direct-and-its-dependencies-indirect
|
||||
;; Only the flags fetched when the workspace opens say how a library is
|
||||
;; linked. The ones loaded after that must say it too: the Libraries
|
||||
;; modal reads it to tell which libraries the user can disconnect.
|
||||
(let [file (cthf/sample-file :file1)
|
||||
library (uuid/next)
|
||||
dependency (uuid/next)
|
||||
store (ths/setup-store file)]
|
||||
(await
|
||||
(mock/with-mocks*
|
||||
{rp/cmd! (library-cmd [dependency])}
|
||||
(ptk/emit! store (dwl/link-file-to-library (:id file) library))
|
||||
(await (async/wait-for
|
||||
#(every? (fn [id] (some? (get-in @store [:files id :library-of])))
|
||||
[library dependency])
|
||||
"both libraries loaded"))
|
||||
(t/is (false? (get-in @store [:files library :is-indirect])))
|
||||
(t/is (true? (get-in @store [:files dependency :is-indirect])))))))
|
||||
|
||||
(defn- deferred-cmd
|
||||
"An RPC mock whose :get-file answers only when the test pushes the file
|
||||
to the subject it records in `gets`, so the test decides the order."
|
||||
[dependencies gets]
|
||||
(mock/stub
|
||||
(fn [command params]
|
||||
(case command
|
||||
:link-file-to-library (rx/of (get dependencies (:library-id params)))
|
||||
:get-file (let [subject (rx/subject)]
|
||||
(swap! gets conj {:id (:id params) :subject subject})
|
||||
subject)
|
||||
:get-file-object-thumbnails (rx/of {})))))
|
||||
|
||||
(t/deftest ^:async a-library-loaded-twice-stays-direct
|
||||
;; Link a (which uses c), then b (which uses a) before a has loaded: a is
|
||||
;; requested twice, once because the user linked it and once because b
|
||||
;; brings it in. The user's link has to win whichever answer lands last.
|
||||
(let [file (cthf/sample-file :file1)
|
||||
a (uuid/next)
|
||||
b (uuid/next)
|
||||
c (uuid/next)
|
||||
gets (atom [])
|
||||
store (ths/setup-store file)
|
||||
calls (fn [id] (filterv #(= id (:id %)) @gets))
|
||||
answer (fn [call]
|
||||
(rx/push! (:subject call) {:id (:id call) :name "Library" :data {}}))]
|
||||
(await
|
||||
(mock/with-mocks*
|
||||
{rp/cmd! (deferred-cmd {a [c] b [a c]} gets)}
|
||||
(ptk/emit! store (dwl/link-file-to-library (:id file) a))
|
||||
(await (async/wait-for #(seq (calls a)) "a requested because it was linked"))
|
||||
(ptk/emit! store (dwl/link-file-to-library (:id file) b))
|
||||
(await (async/wait-for #(= 2 (count (calls a))) "a requested again through b"))
|
||||
(answer (first (calls a)))
|
||||
(await (async/wait-for #(some? (get-in @store [:files a :library-of])) "a loaded"))
|
||||
(answer (second (calls a)))
|
||||
(await (async/settle))
|
||||
(t/is (false? (get-in @store [:files a :is-indirect])))))))
|
||||
|
||||
(t/deftest ^:async a-direct-flag-from-another-file-does-not-carry-over
|
||||
;; :files outlives a workspace, so a library can still be there as a
|
||||
;; direct link of the file visited before. In this file it is only
|
||||
;; brought in by b.
|
||||
(let [file (cthf/sample-file :file1)
|
||||
other (uuid/next)
|
||||
a (uuid/next)
|
||||
b (uuid/next)
|
||||
store (ths/setup-store file {:libraries [{:id a
|
||||
:library-of other
|
||||
:is-indirect false}]})]
|
||||
(await
|
||||
(mock/with-mocks*
|
||||
{rp/cmd! (library-cmd [a])}
|
||||
(ptk/emit! store (dwl/link-file-to-library (:id file) b))
|
||||
(await (async/wait-for
|
||||
#(= (:id file) (get-in @store [:files a :library-of]))
|
||||
"a loaded for this file"))
|
||||
(t/is (true? (get-in @store [:files a :is-indirect])))
|
||||
(t/is (false? (get-in @store [:files b :is-indirect])))))))
|
||||
@ -44,6 +44,7 @@
|
||||
[frontend-tests.data.workspace-focus-test]
|
||||
[frontend-tests.data.workspace-interactions-test]
|
||||
[frontend-tests.data.workspace-layout-other-page-test]
|
||||
[frontend-tests.data.workspace-libraries-link-test]
|
||||
[frontend-tests.data.workspace-libraries-load-test]
|
||||
[frontend-tests.data.workspace-libraries-sync-test]
|
||||
[frontend-tests.data.workspace-mcp-test]
|
||||
@ -276,6 +277,7 @@
|
||||
'frontend-tests.data.workspace-focus-test
|
||||
'frontend-tests.data.workspace-interactions-test
|
||||
'frontend-tests.data.workspace-layout-other-page-test
|
||||
'frontend-tests.data.workspace-libraries-link-test
|
||||
'frontend-tests.data.workspace-libraries-load-test
|
||||
'frontend-tests.data.workspace-libraries-sync-test
|
||||
'frontend-tests.data.workspace-mcp-test
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
|
||||
(ns frontend-tests.ui.workspace-libraries-test
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.main.ui.workspace.libraries :as wl]
|
||||
[cljs.test :as t :include-macros true]))
|
||||
|
||||
@ -99,3 +100,104 @@
|
||||
(t/is (= [[:a false nil]
|
||||
[:b false nil]]
|
||||
(summarize (wl/sort-linked-libraries libraries))))))
|
||||
|
||||
(defn- disconnect-hints
|
||||
"The disconnect hint of every library, by id, once sorted as the
|
||||
Libraries modal shows them."
|
||||
[libraries]
|
||||
(let [sorted (wl/sort-linked-libraries libraries)
|
||||
by-id (d/index-by :id sorted)]
|
||||
(into {} (map (juxt :id #(wl/library-disconnect-hint % by-id))) sorted)))
|
||||
|
||||
(t/deftest library-disconnect-hint-none-when-no-linked-library-uses-it
|
||||
;; Only the file uses it, so the user can disconnect it
|
||||
(t/is (= {:a nil}
|
||||
(disconnect-hints [(lib :a false [:file])]))))
|
||||
|
||||
(t/deftest library-disconnect-hint-nested-library-is-inherited-from-its-parent
|
||||
;; file -> a -> b: b stays while a is connected
|
||||
(t/is (= {:a nil
|
||||
:b {:reason :inherited :library-name "a" :removable ["a"]}}
|
||||
(disconnect-hints [(lib :a false [:file])
|
||||
(lib :b true [:a])]))))
|
||||
|
||||
(t/deftest library-disconnect-hint-direct-library-is-used-by-another-one
|
||||
;; file -> a, b; a -> b: b is linked directly but a needs it
|
||||
(t/is (= {:a nil
|
||||
:b {:reason :used-by :library-name "a" :removable ["a"]}}
|
||||
(disconnect-hints [(lib :a false [:file])
|
||||
(lib :b false [:file :a])]))))
|
||||
|
||||
(t/deftest library-disconnect-hint-names-the-first-user-by-name
|
||||
(t/is (= {:c {:reason :used-by :library-name "a" :removable ["a" "b"]}
|
||||
:a nil
|
||||
:b nil}
|
||||
(disconnect-hints [(lib :c false [:file :b :a])
|
||||
(lib :b false [:file])
|
||||
(lib :a false [:file])]))))
|
||||
|
||||
(t/deftest library-disconnect-hint-ignores-users-that-are-not-linked
|
||||
;; `other` uses a, but it is not one of the file's libraries
|
||||
(t/is (= {:a nil}
|
||||
(disconnect-hints [(lib :a false [:file :other])]))))
|
||||
|
||||
(t/deftest library-disconnect-hint-shared-dependency-lists-every-removable-parent
|
||||
;; file -> a, b; a -> c; b -> c: disconnecting a alone leaves c linked
|
||||
;; through b, so both have to go
|
||||
(t/is (= {:a nil
|
||||
:b nil
|
||||
:c {:reason :inherited :library-name "a" :removable ["a" "b"]}}
|
||||
(disconnect-hints [(lib :a false [:file])
|
||||
(lib :b false [:file])
|
||||
(lib :c true [:a :b])]))))
|
||||
|
||||
(t/deftest library-disconnect-hint-deep-chain-points-to-the-removable-library
|
||||
;; file -> a -> b -> c: b is nested too and has no button, so the
|
||||
;; removal step names a, the only library the user can disconnect
|
||||
(t/is (= {:a nil
|
||||
:b {:reason :inherited :library-name "a" :removable ["a"]}
|
||||
:c {:reason :inherited :library-name "b" :removable ["a"]}}
|
||||
(disconnect-hints [(lib :c true [:b])
|
||||
(lib :b true [:a])
|
||||
(lib :a false [:file])]))))
|
||||
|
||||
(t/deftest library-disconnect-hint-lists-a-directly-linked-intermediate-library
|
||||
;; file -> a, b; a -> b -> c: disconnecting a leaves the direct link to b,
|
||||
;; which keeps c, so b has to go as well. b only becomes removable once a is gone.
|
||||
(t/is (= {:a nil
|
||||
:b {:reason :used-by :library-name "a" :removable ["a"]}
|
||||
:c {:reason :inherited :library-name "b" :removable ["a" "b"]}}
|
||||
(disconnect-hints [(lib :a false [:file])
|
||||
(lib :b false [:file :a])
|
||||
(lib :c true [:b])]))))
|
||||
|
||||
(t/deftest library-disconnect-hint-cycle-falls-back-to-the-parent
|
||||
;; a <-> b, nothing removable: name the parent rather than nothing
|
||||
(t/is (= {:a {:reason :used-by :library-name "b" :removable ["b"]}
|
||||
:b {:reason :inherited :library-name "a" :removable ["a"]}}
|
||||
(disconnect-hints [(lib :a true [:b])
|
||||
(lib :b true [:a])]))))
|
||||
|
||||
(t/deftest disconnect-hint-segments-highlight-every-library-name
|
||||
(t/is (= [[:text "Connected through "]
|
||||
[:name "App"]
|
||||
[:text ". To remove it, disconnect "]
|
||||
[:name "App"]
|
||||
[:text ", "]
|
||||
[:name "Brand"]
|
||||
[:text "."]]
|
||||
(wl/disconnect-hint-segments
|
||||
"Connected through %s. To remove it, disconnect %s."
|
||||
"App"
|
||||
["App" "Brand"]))))
|
||||
|
||||
(t/deftest disconnect-hint-segments-keep-the-text-after-the-last-name
|
||||
(t/is (= [[:text "Used by "]
|
||||
[:name "a"]
|
||||
[:text ". To remove it, disconnect "]
|
||||
[:name "b"]
|
||||
[:text " first."]]
|
||||
(wl/disconnect-hint-segments
|
||||
"Used by %s. To remove it, disconnect %s first."
|
||||
"a"
|
||||
["b"]))))
|
||||
|
||||
@ -7175,6 +7175,10 @@ msgstr "Connected library"
|
||||
msgid "workspace.libraries.connected-through"
|
||||
msgstr "Connected through"
|
||||
|
||||
#: src/app/main/ui/workspace/libraries.cljs:934
|
||||
msgid "workspace.libraries.connected-through-hint"
|
||||
msgstr "Connected through %s. To remove it, disconnect %s."
|
||||
|
||||
#: src/app/main/ui/workspace/libraries.cljs:507
|
||||
msgid "workspace.libraries.connected-to"
|
||||
msgstr "Connected to"
|
||||
@ -7321,6 +7325,10 @@ msgstr "see all changes"
|
||||
msgid "workspace.libraries.updates"
|
||||
msgstr "UPDATES"
|
||||
|
||||
#: src/app/main/ui/workspace/libraries.cljs:936
|
||||
msgid "workspace.libraries.used-by"
|
||||
msgstr "Used by %s. To remove it, disconnect %s first."
|
||||
|
||||
#: src/app/main/ui/ds/notifications/shared/notification_pill.cljs:61
|
||||
msgid "workspace.notification-pill.detail"
|
||||
msgstr "Details"
|
||||
|
||||
@ -7253,6 +7253,10 @@ msgstr "Biblioteca conectada"
|
||||
msgid "workspace.libraries.connected-through"
|
||||
msgstr "Conectada mediante"
|
||||
|
||||
#: src/app/main/ui/workspace/libraries.cljs:934
|
||||
msgid "workspace.libraries.connected-through-hint"
|
||||
msgstr "Conectada mediante %s. Para quitar esta biblioteca, desconecta %s."
|
||||
|
||||
#: src/app/main/ui/workspace/libraries.cljs:507
|
||||
msgid "workspace.libraries.connected-to"
|
||||
msgstr "Conectada con"
|
||||
@ -7399,6 +7403,10 @@ msgstr "ver todos los cambios"
|
||||
msgid "workspace.libraries.updates"
|
||||
msgstr "ACTUALIZACIONES"
|
||||
|
||||
#: src/app/main/ui/workspace/libraries.cljs:936
|
||||
msgid "workspace.libraries.used-by"
|
||||
msgstr "Usada por %s. Para quitar esta biblioteca, desconecta primero %s."
|
||||
|
||||
#: src/app/main/ui/ds/notifications/shared/notification_pill.cljs:61
|
||||
msgid "workspace.notification-pill.detail"
|
||||
msgstr "Detalles"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user