mirror of
https://github.com/penpot/penpot.git
synced 2026-11-23 19:00:36 +00:00
🐛 List each file once when deleting libraries it uses
Deleting or unpublishing several libraries at once listed a file that uses more than one of them once per library, and React logged a duplicate key error for the repeated rows. The references of each library were joined without removing repeated files. The dialog now lists each file once (`distinct-references`). Found by the components Qase run (PENPOT-1473). Test: `delete-shared-test`. AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
5808c873f6
commit
934cdb8532
@ -7,6 +7,7 @@
|
||||
(ns app.main.ui.delete-shared
|
||||
(:require-macros [app.main.style :as stl])
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.data.macros :as dm]
|
||||
[app.main.data.modal :as modal]
|
||||
[app.main.repo :as rp]
|
||||
@ -24,6 +25,12 @@
|
||||
|
||||
(def ^:private noop (constantly nil))
|
||||
|
||||
(defn- distinct-references
|
||||
"The `[file-id file-name]` pairs of `references` without repeated files: a
|
||||
file that uses several of the libraries is listed once."
|
||||
[references]
|
||||
(into [] (d/distinct-xf first) references))
|
||||
|
||||
(mf/defc delete-shared-dialog
|
||||
{::mf/register modal/components
|
||||
::mf/register-as :delete-shared-libraries
|
||||
@ -84,6 +91,7 @@
|
||||
(rx/mapcat identity)
|
||||
(rx/map (juxt :id :name))
|
||||
(rx/reduce conj [])
|
||||
(rx/map distinct-references)
|
||||
(rx/subs! #(reset! references* %))))
|
||||
|
||||
(mf/with-effect [accept-fn]
|
||||
|
||||
@ -190,6 +190,7 @@
|
||||
[frontend-tests.ui.context-menu-prototype-test]
|
||||
[frontend-tests.ui.dashboard-import-errors-test]
|
||||
[frontend-tests.ui.dashboard-import-linking-test]
|
||||
[frontend-tests.ui.delete-shared-test]
|
||||
[frontend-tests.ui.drawarea-test]
|
||||
[frontend-tests.ui.ds-controls-numeric-input-test]
|
||||
[frontend-tests.ui.ds-input-with-meta-test]
|
||||
@ -448,6 +449,7 @@
|
||||
'frontend-tests.ui.context-menu-prototype-test
|
||||
'frontend-tests.ui.dashboard-import-errors-test
|
||||
'frontend-tests.ui.dashboard-import-linking-test
|
||||
'frontend-tests.ui.delete-shared-test
|
||||
'frontend-tests.ui.drawarea-test
|
||||
'frontend-tests.ui.ds-controls-numeric-input-test
|
||||
'frontend-tests.ui.ds-input-with-meta-test
|
||||
|
||||
20
frontend/test/frontend_tests/ui/delete_shared_test.cljs
Normal file
20
frontend/test/frontend_tests/ui/delete_shared_test.cljs
Normal file
@ -0,0 +1,20 @@
|
||||
;; 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.ui.delete-shared-test
|
||||
(:require
|
||||
[app.common.uuid :as uuid]
|
||||
[app.main.ui.delete-shared :as delete-shared]
|
||||
[cljs.test :as t :include-macros true]))
|
||||
|
||||
(def ^:private distinct-references
|
||||
@#'delete-shared/distinct-references)
|
||||
|
||||
(t/deftest a-file-using-several-of-the-libraries-is-listed-once
|
||||
(let [file-a (uuid/next)
|
||||
file-b (uuid/next)]
|
||||
(t/is (= [[file-a "File A"] [file-b "File B"]]
|
||||
(distinct-references [[file-a "File A"] [file-b "File B"] [file-a "File A"]])))))
|
||||
Loading…
x
Reference in New Issue
Block a user