mirror of
https://github.com/penpot/penpot.git
synced 2025-05-17 03:36:11 +02:00
✨ Add function to validate shape referential integrity
This commit is contained in:
parent
2ca28721f7
commit
730df04970
4 changed files with 348 additions and 19 deletions
frontend/src
|
@ -7,6 +7,7 @@
|
|||
(ns debug
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.logging :as l]
|
||||
[app.common.math :as mth]
|
||||
[app.common.transit :as t]
|
||||
|
@ -421,6 +422,23 @@
|
|||
[read-only?]
|
||||
(st/emit! (dw/set-workspace-read-only read-only?)))
|
||||
|
||||
|
||||
;; Validation and repair
|
||||
|
||||
(defn ^:export validate
|
||||
([] (validate nil))
|
||||
([shape-id]
|
||||
(let [file (assoc (get @st/state :workspace-file)
|
||||
:data (get @st/state :workspace-data))
|
||||
page (dm/get-in file [:data :pages-index (get @st/state :current-page-id)])
|
||||
libraries (get @st/state :workspace-libraries)
|
||||
|
||||
errors (ctf/validate-shape (or shape-id uuid/zero)
|
||||
file
|
||||
page
|
||||
libraries)]
|
||||
(clj->js errors))))
|
||||
|
||||
(defn ^:export fix-orphan-shapes
|
||||
[]
|
||||
(st/emit! (dw/fix-orphan-shapes)))
|
||||
|
@ -433,12 +451,10 @@
|
|||
[id shape-ref]
|
||||
(st/emit! (dw/set-shape-ref id shape-ref)))
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; SNAPSHOTS
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
||||
(defn ^:export list-available-snapshots
|
||||
[file-id]
|
||||
(let [file-id (d/parse-uuid file-id)]
|
||||
|
@ -453,7 +469,6 @@
|
|||
(update row :id str))))]
|
||||
(js/console.table (clj->js result))))))))
|
||||
|
||||
|
||||
(defn ^:export take-snapshot
|
||||
[file-id label]
|
||||
(let [file-id (d/parse-uuid file-id)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue