From 9c3fbc59b93009fe071713e4941b732ffc9bf623 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Valderrama?= Date: Fri, 20 Mar 2026 13:42:45 +0100 Subject: [PATCH] :bug: Fix visibility of go to nitrate cc option --- backend/src/app/nitrate.clj | 6 ++++-- .../src/app/main/ui/dashboard/sidebar.cljs | 21 ++++++++++++------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/backend/src/app/nitrate.clj b/backend/src/app/nitrate.clj index 4cb422389f..32e2b7ce5e 100644 --- a/backend/src/app/nitrate.clj +++ b/backend/src/app/nitrate.clj @@ -97,7 +97,8 @@ [:id ::sm/uuid] [:name ::sm/text] [:slug ::sm/text] - [:is-your-penpot :boolean]]) + [:is-your-penpot :boolean] + [:owner-id ::sm/uuid]]) (def ^:private schema:team [:map @@ -248,7 +249,7 @@ (defn add-org-info-to-team "Enriches a team map with organization information from Nitrate. - Adds organization-id, organization-name, organization-slug, and your-penpot fields. + Adds organization-id, organization-name, organization-slug, organization-owner-id, and your-penpot fields. Returns the original team unchanged if the request fails or org data is nil." [cfg team params] (try @@ -259,6 +260,7 @@ :organization-id (:id org) :organization-name (:name org) :organization-slug (:slug org) + :organization-owner-id (:owner-id org) :is-default (or (:is-default team) (true? (:is-your-penpot org)))) team)) (catch Throwable cause diff --git a/frontend/src/app/main/ui/dashboard/sidebar.cljs b/frontend/src/app/main/ui/dashboard/sidebar.cljs index 491b0d9800..b392d2abca 100644 --- a/frontend/src/app/main/ui/dashboard/sidebar.cljs +++ b/frontend/src/app/main/ui/dashboard/sidebar.cljs @@ -312,9 +312,11 @@ on-go-to-cc-click (mf/use-fn - (mf/deps organization) + (mf/deps organization profile) (fn [] - (if (:organization-id organization) + ;; Navigate to active org if user owns it, otherwise to last visited org + (if (and (:organization-id organization) + (= (:id profile) (:organization-owner-id organization))) (dnt/go-to-nitrate-cc organization) (dnt/go-to-nitrate-cc)))) @@ -324,7 +326,9 @@ first :id) (:default-team-id profile)) - organizations (dissoc organizations default-team-id)] + organizations (dissoc organizations default-team-id) + + is-valid-license? (dnt/is-valid-license? profile)] [:> dropdown-menu* props @@ -356,10 +360,11 @@ :class (stl/css :org-dropdown-item :action)} [:span {:class (stl/css :icon-wrapper)} add-org-icon] [:span {:class (stl/css :team-text)} (tr "dashboard.create-new-org")]] - [:> dropdown-menu-item* {:on-click on-go-to-cc-click - :class (stl/css :org-dropdown-item :action)} - [:span {:class (stl/css :icon-wrapper)} arrow-up-right-icon] - [:span {:class (stl/css :team-text)} (tr "dashboard.go-to-control-center")]]])) + (when is-valid-license? + [:> dropdown-menu-item* {:on-click on-go-to-cc-click + :class (stl/css :org-dropdown-item :action)} + [:span {:class (stl/css :icon-wrapper)} arrow-up-right-icon] + [:span {:class (stl/css :team-text)} (tr "dashboard.go-to-control-center")]])])) (mf/defc teams-selector-dropdown* {::mf/private true} @@ -575,7 +580,7 @@ (defn- team->org [team] - (assoc (dm/select-keys team [:id :organization-id :organization-slug]) + (assoc (dm/select-keys team [:id :organization-id :organization-slug :organization-owner-id]) :name (:organization-name team))) (mf/defc sidebar-org-switch*