0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-28 15:41:25 -05:00

🎉 Remember last team visited

This commit is contained in:
Andrés Moya 2021-03-23 13:11:47 +01:00 committed by Andrey Antukh
parent 013fc2fc9c
commit ec217d8201
8 changed files with 30 additions and 14 deletions

View file

@ -26,6 +26,7 @@
- Import SVG will create Penpot's shapes [Taiga #1006](https://tree.taiga.io/project/penpot/us/1066)
- Improve french translations [#731](https://github.com/penpot/penpot/pull/731)
- Reimplement workspace presence (remove database state).
- Remember last visited team when you re-enter the application [Taiga #1376](https://tree.taiga.io/project/penpot/us/1376)
- Replace Slate-Editor with DraftJS [Taiga #1346](https://tree.taiga.io/project/penpot/us/1346)
- Set proper page title [Taiga #1377](https://tree.taiga.io/project/penpot/us/1377)
- Several enhancements in shape selection [Taiga #1195](https://tree.taiga.io/project/penpot/us/1195)

View file

@ -13,6 +13,8 @@
align-items: center;
padding: 32px;
cursor: pointer;
svg {
height: 55px;
width: 170px;

View file

@ -12,7 +12,7 @@
[app.common.spec :as us]
[app.common.uuid :as uuid]
[app.config :as cfg]
[app.main.data.auth :refer [logout]]
[app.main.data.auth :as da]
[app.main.data.messages :as dm]
[app.main.data.users :as udu]
[app.main.repo :as rp]
@ -65,7 +65,7 @@
(->> (rp/query! :profile)
(rx/subs (fn [profile]
(if (not= uuid/zero profile)
(st/emit! (rt/nav :dashboard-projects {:team-id (:default-team-id profile)}))
(st/emit! (rt/nav :dashboard-projects {:team-id (da/current-team-id profile)}))
(st/emit! (rt/nav :auth-login))))))
(and (not authed?) (nil? match))

View file

@ -26,6 +26,17 @@
(s/def ::password string?)
(s/def ::fullname string?)
;; --- Current team for a profile
(defn current-team-id
[profile]
(let [team-id (:current-team-id storage)]
(or team-id (:default-team-id profile))))
(defn set-current-team!
[team-id]
(swap! storage assoc :current-team-id team-id))
;; --- Logged In
(defn logged-in
@ -33,7 +44,7 @@
(ptk/reify ::logged-in
ptk/WatchEvent
(watch [this state stream]
(let [team-id (:default-team-id profile)]
(let [team-id (current-team-id profile)]
(rx/merge
(rx/of (du/profile-fetched profile)
(rt/nav' :dashboard-projects {:team-id team-id}))

View file

@ -26,7 +26,6 @@
[app.main.ui.icons :as i]
[app.util.i18n :as i18n :refer [t]]
[app.util.router :as rt]
[app.util.storage :refer [storage]]
[cuerdas.core :as str]
[okulary.core :as l]
[rumext.alpha :as mf]))

View file

@ -211,8 +211,11 @@
(mf/use-callback
(st/emitf (modal/show :team-form {})))
go-projects
(mf/use-callback #(st/emit! (rt/nav :dashboard-projects {:team-id %})))]
team-selected
(mf/use-callback
(fn [team-id]
(da/set-current-team! team-id)
(st/emit! (rt/nav :dashboard-projects {:team-id team-id}))))]
(mf/use-layout-effect
(mf/deps (:id team))
@ -223,13 +226,13 @@
[:ul.dropdown.teams-dropdown
[:li.title (t locale "dashboard.switch-team")]
[:hr]
[:li.team-name {:on-click (partial go-projects (:default-team-id profile))}
[:li.team-name {:on-click (partial team-selected (:default-team-id profile))}
[:span.team-icon i/logo-icon]
[:span.team-text (t locale "dashboard.your-penpot")]]
(for [team (remove :is-default @teams)]
[:* {:key (:id team)}
[:li.team-name {:on-click (partial go-projects (:id team))}
[:li.team-name {:on-click (partial team-selected (:id team))}
[:span.team-icon
[:img {:src (cfg/resolve-team-photo-url team)}]]
[:span.team-text {:title (:name team)} (:name team)]]])
@ -305,9 +308,6 @@
(mf/deps team)
(st/emitf (rt/nav :dashboard-team-settings {:team-id (:id team)})))
go-projects
(mf/use-callback #(st/emit! (rt/nav :dashboard-projects {:team-id %})))
on-create-clicked
(mf/use-callback
(st/emitf (modal/show :team-form {})))
@ -320,7 +320,9 @@
on-leaved-success
(mf/use-callback
(mf/deps team profile)
(st/emitf (rt/nav :dashboard-projects {:team-id (:default-team-id profile)})))
(let [team-id (:default-team-id profile)]
(da/set-current-team! team-id)
(st/emit! (rt/nav :dashboard-projects {:team-id team-id}))))
leave-fn
(mf/use-callback

View file

@ -10,6 +10,7 @@
(ns app.main.ui.settings.sidebar
(:require
[app.config :as cfg]
[app.main.data.auth :as da]
[app.main.store :as st]
[app.main.ui.dashboard.sidebar :refer [profile-section]]
[app.main.ui.icons :as i]
@ -27,7 +28,7 @@
go-dashboard
(mf/use-callback
(mf/deps profile)
(st/emitf (rt/nav :dashboard-projects {:team-id (:default-team-id profile)})))
(st/emitf (rt/nav :dashboard-projects {:team-id (da/current-team-id profile)})))
go-settings-profile
(mf/use-callback

View file

@ -23,7 +23,7 @@
(defn- go-to-dashboard
[profile]
(let [team-id (:default-team-id profile)]
(let [team-id (da/current-team-id profile)]
(st/emit! (rt/nav :dashboard-projects {:team-id team-id}))))
(mf/defc not-found