Skip to content

Commit

Permalink
feat(organizations): org role logic for usage page plan update button…
Browse files Browse the repository at this point in the history
… TASK-999 (#5296)

### 📣 Summary
Adds logic to only display "See plans" button for organization owners.
Role check is behind a feature flag.

### 👀 Preview steps

1. Create an MMO, add an admin.
2. View usage page with `ff_mmosEnabled=true` as admin. You should not
see the "See plans" button.
3. View the usage page as organization owner. You should see the "See
plans" button".
  • Loading branch information
jamesrkiger authored Dec 2, 2024
1 parent 6992e8a commit 522eb19
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions jsapp/js/account/usage/yourPlan.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {
import {ProductsContext} from '../useProducts.hook';
import {getSubscriptionChangeDetails} from '../stripe.utils';
import {ACCOUNT_ROUTES} from 'js/account/routes.constants';
import {useOrganizationQuery} from '../organization/organizationQuery';
import {FeatureFlag, useFeatureFlag} from 'jsapp/js/featureFlags';

const BADGE_COLOR_KEYS: {[key in SubscriptionChangeType]: BadgeColor} = {
[SubscriptionChangeType.RENEWAL]: 'light-blue',
Expand All @@ -32,6 +34,8 @@ export const YourPlan = () => {
const [env] = useState(() => envStore);
const [session] = useState(() => sessionStore);
const [productsContext] = useContext(ProductsContext);
const orgQuery = useOrganizationQuery();
const areMmosEnabled = useFeatureFlag(FeatureFlag.mmosEnabled);

const planName = subscriptions.planName;

Expand All @@ -58,6 +62,10 @@ export const YourPlan = () => {
}
}, [env.isReady, subscriptions.isInitialised]);

const showPlanUpdateLink = areMmosEnabled
? orgQuery.data?.request_user_role === 'owner'
: true;

const subscriptionUpdate = useMemo(() => {
return getSubscriptionChangeDetails(currentPlan, productsContext.products);
}, [currentPlan, productsContext.isLoaded]);
Expand Down Expand Up @@ -116,20 +124,22 @@ export const YourPlan = () => {
/>
)}
</div>
<nav>
<BillingButton
label={'See plans'}
type='secondary'
onClick={() => window.location.assign('#' + ACCOUNT_ROUTES.PLAN)}
/>
{/* This is commented out until the add-ons tab on the Plans page is implemented
<BillingButton
label={'get add-ons'}
// TODO: change this to point to the add-ons tab
onClick={() => window.location.assign('#' + ACCOUNT_ROUTES.PLAN)}
/>
*/}
</nav>
{showPlanUpdateLink && (
<nav>
<BillingButton
label={'See plans'}
type='secondary'
onClick={() => window.location.assign('#' + ACCOUNT_ROUTES.PLAN)}
/>
{/* This is commented out until the add-ons tab on the Plans page is implemented
<BillingButton
label={'get add-ons'}
// TODO: change this to point to the add-ons tab
onClick={() => window.location.assign('#' + ACCOUNT_ROUTES.PLAN)}
/>
*/}
</nav>
)}
</section>
{subscriptionUpdate?.type === SubscriptionChangeType.CANCELLATION && (
<div className={styles.subscriptionChangeNotice}>
Expand Down

0 comments on commit 522eb19

Please sign in to comment.