🐛 Fix incorrect version visibility on workspace (#8463)

* 🐛 Add missing order by clause to snapshot query

This fixes the incorrect snapshot visibility when file
has a lot of versions.

*  Reduce allocation on milestone-group* component

* 🐛 Fix milestone group timestamp formatting

* 📎 Update changelog

* 🐛 Fix scroll on history panel

---------

Co-authored-by: Eva Marco <evamarcod@gmail.com>
This commit is contained in:
Andrey Antukh 2026-03-04 09:27:51 +01:00 committed by GitHub
parent 1f2a234458
commit 86e851f408
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 29 additions and 19 deletions

View File

@ -1,5 +1,12 @@
# CHANGELOG # CHANGELOG
## 2.13.4
### :bug: Bugs fixed
- Fix incorrect query for file versions [Github #8463](https://github.com/penpot/penpot/pull/8463)
## 2.13.3 ## 2.13.3
### :bug: Bugs fixed ### :bug: Bugs fixed

View File

@ -138,6 +138,7 @@
c.deleted_at c.deleted_at
FROM snapshots1 AS c FROM snapshots1 AS c
WHERE c.file_id = ? WHERE c.file_id = ?
ORDER BY c.created_at DESC
), snapshots3 AS ( ), snapshots3 AS (
(SELECT * FROM snapshots2 (SELECT * FROM snapshots2
WHERE created_by = 'system' WHERE created_by = 'system'
@ -150,8 +151,7 @@
AND deleted_at IS NULL AND deleted_at IS NULL
LIMIT 500) LIMIT 500)
) )
SELECT * FROM snapshots3 SELECT * FROM snapshots3;"))
ORDER BY created_at DESC"))
(defn get-visible-snapshots (defn get-visible-snapshots
"Return a list of snapshots fecheable from the API, it has a limited "Return a list of snapshots fecheable from the API, it has a limited

View File

@ -208,7 +208,7 @@
(dfn-format v "p") (dfn-format v "p")
:localized-date-time :localized-date-time
(dfn-format v "PPPp") (dfn-format v "PPP . p")
(if (string? fmt) (if (string? fmt)
(dfn-format v fmt) (dfn-format v fmt)

View File

@ -114,4 +114,5 @@
width: 100%; width: 100%;
height: 100%; height: 100%;
outline: $b-1 solid var(--tab-panel-outline-color); outline: $b-1 solid var(--tab-panel-outline-color);
overflow-y: auto;
} }

View File

@ -39,7 +39,6 @@
(mf/spread-props props (mf/spread-props props
{:class [class class'] {:class [class class']
:data-testid "milestone"}) :data-testid "milestone"})
open* open*
(mf/use-state false) (mf/use-state false)
@ -57,7 +56,13 @@
(dom/get-data "index") (dom/get-data "index")
(d/parse-integer))] (d/parse-integer))]
(when (fn? on-menu-click) (when (fn? on-menu-click)
(on-menu-click index event)))))] (on-menu-click index event)))))
snapshots
(mf/with-memo [snapshots]
(map-indexed (fn [index date]
(d/vec2 date index))
snapshots))]
[:> :div props [:> :div props
[:> text* {:as "span" :typography t/body-small :class (stl/css :name)} label] [:> text* {:as "span" :typography t/body-small :class (stl/css :name)} label]
@ -76,14 +81,14 @@
:icon-arrow-toggled open?)}]] :icon-arrow-toggled open?)}]]
(when ^boolean open? (when ^boolean open?
(for [[idx d] (d/enumerate snapshots)] (for [[date index] snapshots]
[:div {:key (dm/str "entry-" idx) [:div {:key (dm/str "entry-" index)
:class (stl/css :version-entry)} :class (stl/css :version-entry)}
[:> date* {:date d :class (stl/css :date) :typography t/body-small}] [:> date* {:date date :class (stl/css :date) :typography t/body-small}]
[:> icon-button* {:class (stl/css :entry-button) [:> icon-button* {:class (stl/css :entry-button)
:variant "ghost" :variant "ghost"
:icon i/menu :icon i/menu
:aria-label (tr "workspace.versions.version-menu") :aria-label (tr "workspace.versions.version-menu")
:data-index idx :data-index index
:on-click on-menu-click}]]))]])) :on-click on-menu-click}]]))]]))

View File

@ -6,10 +6,8 @@
(ns app.main.ui.ds.utilities.date (ns app.main.ui.ds.utilities.date
(:require-macros (:require-macros
[app.common.data.macros :as dm]
[app.main.style :as stl]) [app.main.style :as stl])
(:require (:require
[app.common.data :as d]
[app.common.time :as ct] [app.common.time :as ct]
[app.main.ui.ds.foundations.typography :as t] [app.main.ui.ds.foundations.typography :as t]
[app.main.ui.ds.foundations.typography.text :refer [text*]] [app.main.ui.ds.foundations.typography.text :refer [text*]]
@ -30,15 +28,10 @@
(mf/defc date* (mf/defc date*
{::mf/schema schema:date} {::mf/schema schema:date}
[{:keys [class date selected typography] :rest props}] [{:keys [class date selected typography] :rest props}]
(let [class (d/append-class class (stl/css-case :date true :is-selected selected)) (let [date (cond-> date (not (ct/inst? date)) ct/inst)
date (cond-> date (not (ct/inst? date)) ct/inst)
typography (or typography t/body-medium)] typography (or typography t/body-medium)]
[:> text* {:as "time" [:> text* {:as "time"
:typography typography :typography typography
:class class :class [class (stl/css-case :date true :is-selected selected)]
:date-time (ct/format-inst date :iso)} :date-time (ct/format-inst date :iso)}
(dm/str (ct/format-inst date :localized-date-time)]))
(ct/format-inst date :localized-date)
" . "
(ct/format-inst date :localized-time)
"h")]))

View File

@ -159,3 +159,7 @@
overflow: hidden; overflow: hidden;
height: calc(100vh - deprecated.$s-88); height: calc(100vh - deprecated.$s-88);
} }
.history-tab {
overflow-y: auto;
}