mirror of
https://github.com/penpot/penpot.git
synced 2025-07-08 23:27:16 +02:00
Merge pull request #3578 from penpot/superalex-fix-list-view-is-discarded-on-tab-change-for-assets-sidebar-tab
🐛 Fix list view is discarded on tab change for assets sidebar
This commit is contained in:
commit
ad4e489312
4 changed files with 53 additions and 5 deletions
|
@ -1,5 +1,11 @@
|
||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
|
|
||||||
|
## 1.19.3
|
||||||
|
|
||||||
|
### :bug: Bugs fixed
|
||||||
|
|
||||||
|
- List view is discarded on tab change on Workspace Assets Sidebar tab [Github #3547](https://github.com/penpot/penpot/issues/3547)
|
||||||
|
|
||||||
## 1.19.2
|
## 1.19.2
|
||||||
|
|
||||||
### :sparkles: New features
|
### :sparkles: New features
|
||||||
|
|
28
frontend/src/app/main/data/workspace/assets.cljs
Normal file
28
frontend/src/app/main/data/workspace/assets.cljs
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
;; 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 INC
|
||||||
|
|
||||||
|
(ns app.main.data.workspace.assets
|
||||||
|
"Workspace assets management events and helpers."
|
||||||
|
(:require
|
||||||
|
[app.util.storage :refer [storage]]))
|
||||||
|
|
||||||
|
(defn get-current-assets-ordering
|
||||||
|
[]
|
||||||
|
(let [ordering (::ordering @storage)]
|
||||||
|
(or ordering :asc)))
|
||||||
|
|
||||||
|
(defn set-current-assets-ordering!
|
||||||
|
[ordering]
|
||||||
|
(swap! storage assoc ::ordering ordering))
|
||||||
|
|
||||||
|
(defn get-current-assets-list-style
|
||||||
|
[]
|
||||||
|
(let [list-style (::list-style @storage)]
|
||||||
|
(or list-style :thumbs)))
|
||||||
|
|
||||||
|
(defn set-current-assets-list-style!
|
||||||
|
[list-style]
|
||||||
|
(swap! storage assoc ::list-style list-style))
|
|
@ -16,6 +16,7 @@
|
||||||
[app.main.data.events :as ev]
|
[app.main.data.events :as ev]
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
[app.main.data.workspace :as dw]
|
[app.main.data.workspace :as dw]
|
||||||
|
[app.main.data.workspace.assets :as dwa]
|
||||||
[app.main.data.workspace.colors :as dc]
|
[app.main.data.workspace.colors :as dc]
|
||||||
[app.main.data.workspace.libraries :as dwl]
|
[app.main.data.workspace.libraries :as dwl]
|
||||||
[app.main.data.workspace.media :as dwm]
|
[app.main.data.workspace.media :as dwm]
|
||||||
|
@ -2424,19 +2425,32 @@
|
||||||
[]
|
[]
|
||||||
(let [components-v2 (mf/use-ctx ctx/components-v2)
|
(let [components-v2 (mf/use-ctx ctx/components-v2)
|
||||||
read-only? (mf/use-ctx ctx/workspace-read-only?)
|
read-only? (mf/use-ctx ctx/workspace-read-only?)
|
||||||
|
|
||||||
filters* (mf/use-state
|
filters* (mf/use-state
|
||||||
{:term ""
|
{:term ""
|
||||||
:section :all
|
:section :all
|
||||||
:ordering :asc
|
:ordering (dwa/get-current-assets-ordering)
|
||||||
:list-style :thumbs})
|
:list-style (dwa/get-current-assets-list-style)})
|
||||||
filters (deref filters*)
|
filters (deref filters*)
|
||||||
term (:term filters)
|
term (:term filters)
|
||||||
|
ordering (:ordering filters)
|
||||||
|
list-style (:list-style filters)
|
||||||
|
|
||||||
toggle-ordering
|
toggle-ordering
|
||||||
(mf/use-fn #(swap! filters* update :ordering toggle-values [:asc :desc]))
|
(mf/use-fn
|
||||||
|
(mf/deps ordering)
|
||||||
|
(fn []
|
||||||
|
(let [new-value (toggle-values ordering [:asc :desc])]
|
||||||
|
(swap! filters* assoc :ordering new-value)
|
||||||
|
(dwa/set-current-assets-ordering! new-value))))
|
||||||
|
|
||||||
toggle-list-style
|
toggle-list-style
|
||||||
(mf/use-fn #(swap! filters* update :list-style toggle-values [:thumbs :list]))
|
(mf/use-fn
|
||||||
|
(mf/deps list-style)
|
||||||
|
(fn []
|
||||||
|
(let [new-value (toggle-values list-style [:thumbs :list])]
|
||||||
|
(swap! filters* assoc :list-style new-value)
|
||||||
|
(dwa/set-current-assets-list-style! new-value))))
|
||||||
|
|
||||||
on-search-term-change
|
on-search-term-change
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
1.19.2
|
1.19.3
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue