mirror of
https://github.com/penpot/penpot.git
synced 2026-05-19 23:13:39 +00:00
148 lines
5.5 KiB
Clojure
148 lines
5.5 KiB
Clojure
;; 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.ui.settings.sidebar
|
|
(:require-macros [app.main.style :as stl])
|
|
(:require
|
|
[app.config :as cf]
|
|
[app.main.data.common :as dcm]
|
|
[app.main.data.event :as ev]
|
|
[app.main.data.modal :as modal]
|
|
[app.main.data.team :as dtm]
|
|
[app.main.router :as rt]
|
|
[app.main.store :as st]
|
|
[app.main.ui.dashboard.sidebar :refer [profile-section*]]
|
|
[app.main.ui.icons :as deprecated-icon]
|
|
[app.util.i18n :as i18n :refer [tr]]
|
|
[app.util.keyboard :as kbd]
|
|
[potok.v2.core :as ptk]
|
|
[rumext.v2 :as mf]))
|
|
|
|
(def ^:private arrow-icon
|
|
(deprecated-icon/icon-xref :arrow (stl/css :arrow-icon)))
|
|
|
|
(def ^:private feedback-icon
|
|
(deprecated-icon/icon-xref :feedback (stl/css :feedback-icon)))
|
|
|
|
;; FIXME: move to common
|
|
(def ^:private go-settings-profile
|
|
#(st/emit! (rt/nav :settings-profile)))
|
|
|
|
(def ^:private go-settings-feedback
|
|
#(st/emit! (rt/nav :settings-feedback)))
|
|
|
|
(def ^:private go-settings-password
|
|
#(st/emit! (rt/nav :settings-password)))
|
|
|
|
(def ^:private go-settings-options
|
|
#(st/emit! (rt/nav :settings-options)))
|
|
|
|
(def ^:private go-settings-subscription
|
|
#(st/emit! (rt/nav :settings-subscription)))
|
|
|
|
(def ^:private go-settings-integrations
|
|
#(st/emit! (rt/nav :settings-integrations)))
|
|
|
|
(def ^:private go-settings-notifications
|
|
#(st/emit! (rt/nav :settings-notifications)))
|
|
|
|
(defn- show-release-notes
|
|
[event]
|
|
(let [version (:main cf/version)]
|
|
(st/emit! (ptk/event ::ev/event {::ev/name "show-release-notes" :version version}))
|
|
|
|
(if (and (kbd/alt? event) (kbd/mod? event))
|
|
(st/emit! (modal/show {:type :onboarding}))
|
|
(st/emit! (modal/show {:type :release-notes :version version})))))
|
|
|
|
(mf/defc sidebar-content
|
|
{::mf/props :obj}
|
|
[{:keys [profile section]}]
|
|
(let [profile? (= section :settings-profile)
|
|
password? (= section :settings-password)
|
|
options? (= section :settings-options)
|
|
feedback? (= section :settings-feedback)
|
|
subscription? (= section :settings-subscription)
|
|
integrations? (= section :settings-integrations)
|
|
notifications? (= section :settings-notifications)
|
|
team-id (or (dtm/get-last-team-id)
|
|
(:default-team-id profile))
|
|
|
|
go-dashboard
|
|
(mf/use-fn
|
|
(mf/deps team-id)
|
|
#(st/emit! (dcm/go-to-dashboard-recent :team-id team-id)))]
|
|
|
|
[:div {:class (stl/css :sidebar-content)}
|
|
[:div {:class (stl/css :sidebar-content-section)}
|
|
[:button {:class (stl/css :back-to-dashboard)
|
|
:on-click go-dashboard}
|
|
arrow-icon
|
|
[:span {:class (stl/css :back-text)} (tr "labels.dashboard")]]]
|
|
|
|
[:hr {:class (stl/css :sidebar-separator)}]
|
|
|
|
[:div {:class (stl/css :sidebar-content-section)}
|
|
[:ul {:class (stl/css :sidebar-nav-settings)}
|
|
[:li {:class (stl/css-case :current profile?
|
|
:settings-item true)
|
|
:on-click go-settings-profile}
|
|
[:span {:class (stl/css :element-title)} (tr "labels.profile")]]
|
|
|
|
[:li {:class (stl/css-case :current password?
|
|
:settings-item true)
|
|
:on-click go-settings-password}
|
|
[:span {:class (stl/css :element-title)} (tr "labels.password")]]
|
|
|
|
[:li {:class (stl/css-case :current notifications?
|
|
:settings-item true)
|
|
:on-click go-settings-notifications}
|
|
[:span {:class (stl/css :element-title)} (tr "labels.notifications")]]
|
|
|
|
[:li {:class (stl/css-case :current options?
|
|
:settings-item true)
|
|
:on-click go-settings-options
|
|
:data-testid "settings-profile"}
|
|
[:span {:class (stl/css :element-title)} (tr "labels.settings")]]
|
|
|
|
(when (contains? cf/flags :subscriptions)
|
|
[:li {:class (stl/css-case :current subscription?
|
|
:settings-item true)
|
|
:on-click go-settings-subscription
|
|
:data-testid "settings-subscription"}
|
|
[:span {:class (stl/css :element-title)} (tr "subscription.labels")]])
|
|
|
|
(when (or (contains? cf/flags :access-tokens)
|
|
(contains? cf/flags :mcp))
|
|
[:li {:class (stl/css-case :current integrations?
|
|
:settings-item true)
|
|
:on-click go-settings-integrations
|
|
:data-testid "settings-integrations"}
|
|
[:span {:class (stl/css :element-title)} (tr "labels.integrations")]])
|
|
|
|
[:hr {:class (stl/css :sidebar-separator)}]
|
|
|
|
[:li {:on-click show-release-notes :data-testid "release-notes"
|
|
:class (stl/css :settings-item)}
|
|
[:span {:class (stl/css :element-title)} (tr "labels.release-notes")]]
|
|
|
|
(when (contains? cf/flags :user-feedback)
|
|
[:li {:class (stl/css-case :current feedback?
|
|
:settings-item true)
|
|
:on-click go-settings-feedback}
|
|
feedback-icon
|
|
[:span {:class (stl/css :element-title)} (tr "labels.contact-us")]])]]]))
|
|
|
|
(mf/defc sidebar
|
|
{::mf/wrap [mf/memo]
|
|
::mf/props :obj}
|
|
[{:keys [profile section]}]
|
|
[:div {:class (stl/css :dashboard-sidebar :settings)}
|
|
[:& sidebar-content {:profile profile
|
|
:section section}]
|
|
[:> profile-section* {:profile profile}]])
|
|
|