mirror of
https://github.com/penpot/penpot.git
synced 2025-01-20 05:34:23 -05:00
Renaming
This commit is contained in:
parent
8772cdf423
commit
ffe2abc992
4 changed files with 14 additions and 14 deletions
|
@ -820,13 +820,13 @@
|
|||
(apply-changes-local)))
|
||||
|
||||
(defn delete-token-set-path
|
||||
[changes token-set-path]
|
||||
[changes prefixed-full-set-path]
|
||||
(assert-library! changes)
|
||||
(let [library-data (::library-data (meta changes))
|
||||
prev-token-sets (some-> (get library-data :tokens-lib)
|
||||
(ctob/get-path-sets token-set-path))]
|
||||
(ctob/get-sets-at-prefix-path prefixed-full-set-path))]
|
||||
(-> changes
|
||||
(update :redo-changes conj {:type :del-token-set-path :path token-set-path})
|
||||
(update :redo-changes conj {:type :del-token-set-path :path prefixed-full-set-path})
|
||||
(update :undo-changes conj {:type :add-token-sets :token-sets prev-token-sets})
|
||||
(apply-changes-local))))
|
||||
|
||||
|
|
|
@ -387,7 +387,7 @@ When `before-set-name` is nil, move set to bottom")
|
|||
(get-set-tree [_] "get a nested tree of all sets in the library")
|
||||
(get-in-set-tree [_ path] "get `path` in nested tree of all sets in the library")
|
||||
(get-sets [_] "get an ordered sequence of all sets in the library")
|
||||
(get-path-sets [_ path] "get an ordered sequence of sets at `path` in the library")
|
||||
(get-sets-at-prefix-path [_ path] "get an ordered sequence of sets at `path` in the library")
|
||||
(get-ordered-set-names [_] "get an ordered sequence of all sets names in the library")
|
||||
(get-set [_ set-name] "get one set looking for name")
|
||||
(get-neighbor-set-name [_ set-name index-offset] "get neighboring set name offset by `index-offset`"))
|
||||
|
@ -644,18 +644,18 @@ When `before-set-name` is nil, move set to bottom")
|
|||
this token-sets))
|
||||
|
||||
(update-set [this set-name f]
|
||||
(let [path (set-full-name->prefixed-full-path set-name)
|
||||
set (get-in sets path)]
|
||||
(let [prefixed-full-path (set-full-name->prefixed-full-path set-name)
|
||||
set (get-in sets prefixed-full-path)]
|
||||
(if set
|
||||
(let [set' (-> (make-token-set (f set))
|
||||
(assoc :modified-at (dt/now)))
|
||||
path' (get-token-set-prefixed-path set')
|
||||
prefixed-full-path' (get-token-set-prefixed-path set')
|
||||
name-changed? (not= (:name set) (:name set'))]
|
||||
(check-token-set! set')
|
||||
(if name-changed?
|
||||
(TokensLib. (-> sets
|
||||
(d/oassoc-in-before path path' set')
|
||||
(d/dissoc-in path))
|
||||
(d/oassoc-in-before prefixed-full-path prefixed-full-path' set')
|
||||
(d/dissoc-in prefixed-full-path))
|
||||
(walk/postwalk
|
||||
(fn [form]
|
||||
(if (instance? TokenTheme form)
|
||||
|
@ -663,7 +663,7 @@ When `before-set-name` is nil, move set to bottom")
|
|||
form))
|
||||
themes)
|
||||
active-themes)
|
||||
(TokensLib. (d/oassoc-in sets path set')
|
||||
(TokensLib. (d/oassoc-in sets prefixed-full-path set')
|
||||
themes
|
||||
active-themes)))
|
||||
this)))
|
||||
|
@ -710,7 +710,7 @@ When `before-set-name` is nil, move set to bottom")
|
|||
(->> (tree-seq d/ordered-map? vals sets)
|
||||
(filter (partial instance? TokenSet))))
|
||||
|
||||
(get-path-sets [_ path]
|
||||
(get-sets-at-prefix-path [_ path]
|
||||
(some->> (get-in sets (split-token-set-path path))
|
||||
(tree-seq d/ordered-map? vals)
|
||||
(filter (partial instance? TokenSet))))
|
||||
|
|
|
@ -219,14 +219,14 @@
|
|||
update-token-set-change
|
||||
(wtu/update-workspace-tokens))))))
|
||||
|
||||
(defn delete-token-set-path [token-set-path]
|
||||
(defn delete-token-set-path [prefixed-full-set-path]
|
||||
(ptk/reify ::delete-token-set-path
|
||||
ptk/WatchEvent
|
||||
(watch [it state _]
|
||||
(let [data (get state :workspace-data)
|
||||
changes (-> (pcb/empty-changes it)
|
||||
(pcb/with-library-data data)
|
||||
(pcb/delete-token-set-path token-set-path))]
|
||||
(pcb/delete-token-set-path prefixed-full-set-path))]
|
||||
(rx/of
|
||||
(dch/commit-changes changes)
|
||||
(wtu/update-workspace-tokens))))))
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
[{:keys [tree-path]}]
|
||||
(let [{:keys [on-edit]} (sets-context/use-context)
|
||||
edit-name (mf/use-fn #(on-edit tree-path))
|
||||
delete-set (mf/use-fn #(st/emit! (wdt/delete-token-set-path tree-path)))]
|
||||
delete-set (mf/use-fn #(st/emit! (wdt/delete-token-set-prefix-full-path tree-path)))]
|
||||
[:ul {:class (stl/css :context-list)}
|
||||
[:& menu-entry {:title (tr "labels.rename") :on-click edit-name}]
|
||||
[:& menu-entry {:title (tr "labels.delete") :on-click delete-set}]]))
|
||||
|
|
Loading…
Add table
Reference in a new issue