diff --git a/CHANGES.md b/CHANGES.md index e8f11258b..406336ce0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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) diff --git a/frontend/resources/styles/main/partials/exception-page.scss b/frontend/resources/styles/main/partials/exception-page.scss index c2ab1a3a8..d46261f89 100644 --- a/frontend/resources/styles/main/partials/exception-page.scss +++ b/frontend/resources/styles/main/partials/exception-page.scss @@ -13,6 +13,8 @@ align-items: center; padding: 32px; + cursor: pointer; + svg { height: 55px; width: 170px; diff --git a/frontend/src/app/main.cljs b/frontend/src/app/main.cljs index 0ad0b2437..2126bead2 100644 --- a/frontend/src/app/main.cljs +++ b/frontend/src/app/main.cljs @@ -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)) diff --git a/frontend/src/app/main/data/auth.cljs b/frontend/src/app/main/data/auth.cljs index b040a8d2c..00612a6b0 100644 --- a/frontend/src/app/main/data/auth.cljs +++ b/frontend/src/app/main/data/auth.cljs @@ -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})) diff --git a/frontend/src/app/main/ui/dashboard.cljs b/frontend/src/app/main/ui/dashboard.cljs index 028d54454..52e024ade 100644 --- a/frontend/src/app/main/ui/dashboard.cljs +++ b/frontend/src/app/main/ui/dashboard.cljs @@ -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])) diff --git a/frontend/src/app/main/ui/dashboard/sidebar.cljs b/frontend/src/app/main/ui/dashboard/sidebar.cljs index 23aa64539..bf602d7b4 100644 --- a/frontend/src/app/main/ui/dashboard/sidebar.cljs +++ b/frontend/src/app/main/ui/dashboard/sidebar.cljs @@ -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 diff --git a/frontend/src/app/main/ui/settings/sidebar.cljs b/frontend/src/app/main/ui/settings/sidebar.cljs index dd7a49d05..3b00c1220 100644 --- a/frontend/src/app/main/ui/settings/sidebar.cljs +++ b/frontend/src/app/main/ui/settings/sidebar.cljs @@ -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 diff --git a/frontend/src/app/main/ui/static.cljs b/frontend/src/app/main/ui/static.cljs index 184aa8f78..8b33ecac7 100644 --- a/frontend/src/app/main/ui/static.cljs +++ b/frontend/src/app/main/ui/static.cljs @@ -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