🐛 Hide standalone Enterprise plans for team owners (#13017)

This commit is contained in:
Marina López 2026-11-12 14:54:56 +01:00 committed by GitHub
parent 9d42ed29ce
commit 029283b1f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 70 additions and 15 deletions

View File

@ -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]}]

View File

@ -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]

View File

@ -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"}}))))