From 029283b1f91574359a7549cfd527824fe047d09e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marina=20L=C3=B3pez?= Date: Thu, 12 Nov 2026 14:54:56 +0100 Subject: [PATCH] :bug: Hide standalone Enterprise plans for team owners (#13017) --- .../app/main/ui/dashboard/subscription.cljs | 44 ++++++++++++------- frontend/test/frontend_tests/runner.cljs | 1 + .../frontend_tests/ui/subscription_test.cljs | 40 +++++++++++++++++ 3 files changed, 70 insertions(+), 15 deletions(-) create mode 100644 frontend/test/frontend_tests/ui/subscription_test.cljs diff --git a/frontend/src/app/main/ui/dashboard/subscription.cljs b/frontend/src/app/main/ui/dashboard/subscription.cljs index fa675fb9e2..b7434d5279 100644 --- a/frontend/src/app/main/ui/dashboard/subscription.cljs +++ b/frontend/src/app/main/ui/dashboard/subscription.cljs @@ -28,6 +28,18 @@ type "professional")) +(defn get-team-plan-type + [team] + (if (some? (dm/get-in team [:organization :id])) + "enterprise" + (get-subscription-type (:subscription team)))) + +(defn show-team-plan? + [is-owner team] + (not (and is-owner + (nil? (dm/get-in team [:organization :id])) + (= "enterprise" (get-subscription-type (:subscription team)))))) + (mf/defc cta-power-up* [{:keys [top-title top-description bottom-description bottom-button bottom-button-href has-dropdown is-highlighted]}] (let [show-data* (mf/use-state false) @@ -310,6 +322,7 @@ [{:keys [is-owner team]}] (let [subscription (:subscription team) subscription-type (get-subscription-type subscription) + team-plan-type (get-team-plan-type team) subscription-is-trial (= "trialing" (:status subscription)) go-to-manage-subscription @@ -324,22 +337,23 @@ href (str "payments/subscriptions/show?returnUrl=" href)] (st/emit! (rt/nav-raw :href href)))))] - [:div {:class (stl/css :team)} - [:div {:class (stl/css :team-label)} - (tr "subscription.dashboard.team-plan")] - [:span {:class (stl/css :team-text)} - (case subscription-type - "professional" (tr "subscription.settings.professional") - "unlimited" (if subscription-is-trial - (tr "subscription.settings.unlimited-trial") - (tr "subscription.settings.unlimited")) + (when (show-team-plan? is-owner team) + [:div {:class (stl/css :team)} + [:div {:class (stl/css :team-label)} + (tr "subscription.dashboard.team-plan")] + [:span {:class (stl/css :team-text)} + (case team-plan-type + "professional" (tr "subscription.settings.professional") + "unlimited" (if subscription-is-trial + (tr "subscription.settings.unlimited-trial") + (tr "subscription.settings.unlimited")) - "enterprise" (tr "subscription.settings.enterprise"))] - (when (and is-owner (not= subscription-type "professional")) - [:button {:class (stl/css :manage-subscription-link) - :on-click go-to-manage-subscription - :data-testid "manage-subscription-link"} - (tr "subscription.settings.manage-your-subscription")])])) + "enterprise" (tr "subscription.settings.enterprise"))] + (when (and is-owner (not= subscription-type "professional")) + [:button {:class (stl/css :manage-subscription-link) + :on-click go-to-manage-subscription + :data-testid "manage-subscription-link"} + (tr "subscription.settings.manage-your-subscription")])]))) (mf/defc menu-team-icon* [{:keys [subscription-type]}] diff --git a/frontend/test/frontend_tests/runner.cljs b/frontend/test/frontend_tests/runner.cljs index b0f699a220..38f5975de3 100644 --- a/frontend/test/frontend_tests/runner.cljs +++ b/frontend/test/frontend_tests/runner.cljs @@ -169,6 +169,7 @@ [frontend-tests.ui.sortable-auto-scroll-test] [frontend-tests.ui.static-test] [frontend-tests.ui.stroke-menu-test] + [frontend-tests.ui.subscription-test] [frontend-tests.ui.text-attrs-multiple-test] [frontend-tests.ui.viewport-top-bar-test] [frontend-tests.ui.workspace-libraries-test] diff --git a/frontend/test/frontend_tests/ui/subscription_test.cljs b/frontend/test/frontend_tests/ui/subscription_test.cljs new file mode 100644 index 0000000000..7517720806 --- /dev/null +++ b/frontend/test/frontend_tests/ui/subscription_test.cljs @@ -0,0 +1,40 @@ +;; 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 SUBSIDIARY SL + +(ns frontend-tests.ui.subscription-test + (:require + [app.main.ui.dashboard.subscription :as ds] + [cljs.test :as t :include-macros true])) + +(t/deftest team-plan-is-enterprise-while-team-belongs-to-an-organization + (doseq [owner-plan ["professional" "unlimited"]] + (t/is (= "enterprise" + (ds/get-team-plan-type {:organization {:id "org-1"} + :subscription {:type owner-plan + :status "active"}}))))) + +(t/deftest team-plan-returns-to-owner-plan-after-leaving-organization + (doseq [owner-plan ["professional" "unlimited"]] + (t/is (= owner-plan + (ds/get-team-plan-type {:subscription {:type owner-plan + :status "active"}}))))) + +(t/deftest owner-enterprise-plan-is-hidden-for-team-outside-organization + (t/is (false? (ds/show-team-plan? true + {:subscription {:type "enterprise" + :status "active"}})))) + +(t/deftest team-plan-is-visible-for-other-owner-and-organization-cases + (t/is (true? (ds/show-team-plan? true + {:subscription {:type "professional" + :status "active"}}))) + (t/is (true? (ds/show-team-plan? true + {:subscription {:type "enterprise" + :status "active"} + :organization {:id "org-1"}}))) + (t/is (true? (ds/show-team-plan? false + {:subscription {:type "enterprise" + :status "active"}}))))