0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-03-17 22:31:28 -05:00

feat(console): hide entrance for creating SAML apps (#6948)

This commit is contained in:
Darcy Ye 2025-01-17 13:45:59 +08:00 committed by GitHub
parent 6a5e395dc6
commit 7a0d5f97ab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 37 additions and 6 deletions

View file

@ -1,8 +1,10 @@
import { useCallback, useMemo } from 'react';
import { ApplicationType } from '@logto/schemas';
import { useCallback, useMemo, useContext } from 'react';
import { guides } from '@/assets/docs/guides';
import { type Guide } from '@/assets/docs/guides/types';
import { isCloud as isCloudEnv, isDevFeaturesEnabled } from '@/consts/env';
import { SubscriptionDataContext } from '@/contexts/SubscriptionDataProvider';
import {
thirdPartyAppCategory,
type AppGuideCategory,
@ -34,12 +36,28 @@ export const useAppGuideMetadata = (): {
filters?: FilterOptions
) => Record<AppGuideCategory, readonly Guide[]>;
} => {
const { currentSubscriptionQuota } = useContext(SubscriptionDataContext);
const appGuides = useMemo(
() =>
guides.filter(
({ metadata: { target, isCloud, isDevFeature } }) =>
target !== 'API' && (isCloudEnv || !isCloud) && (isDevFeaturesEnabled || !isDevFeature)
),
guides
.filter(
({ metadata: { target, isCloud, isDevFeature } }) =>
target !== 'API' && (isCloudEnv || !isCloud) && (isDevFeaturesEnabled || !isDevFeature)
/**
* Show SAML guides when it is:
* 1. Cloud env
* 2. `isDevFeatureEnabled` is true
* 3. `quota.samlApplicationsLimit` is not 0.
*/
)
.filter(
({ metadata: { target } }) =>
target !== ApplicationType.SAML ||
(isCloudEnv &&
isDevFeaturesEnabled &&
currentSubscriptionQuota.samlApplicationsLimit !== 0)
),
[]
);

View file

@ -10,7 +10,7 @@ import FeatureTag from '@/components/FeatureTag';
import { type SelectedGuide } from '@/components/Guide/GuideCard';
import GuideCardGroup from '@/components/Guide/GuideCardGroup';
import { useAppGuideMetadata } from '@/components/Guide/hooks';
import { isCloud } from '@/consts/env';
import { isDevFeaturesEnabled, isCloud } from '@/consts/env';
import { latestProPlanId } from '@/consts/subscriptions';
import { SubscriptionDataContext } from '@/contexts/SubscriptionDataProvider';
import { CheckboxGroup } from '@/ds-components/Checkbox';
@ -93,6 +93,19 @@ function GuideLibrary({ className, hasCardBorder, hasCardButton, onSelectGuide }
<CheckboxGroup
className={styles.checkboxGroup}
options={allAppGuideCategories
/**
* Show SAML guides when it is:
* 1. Cloud env
* 2. `isDevFeatureEnabled` is true
* 3. `quota.samlApplicationsLimit` is not 0.
*/
.filter(
(category) =>
category !== 'SAML' ||
(isCloud &&
isDevFeaturesEnabled &&
currentSubscriptionQuota.samlApplicationsLimit !== 0)
)
.filter((category) => isCloud || category !== 'Protected')
.map((category) => ({
title: `guide.categories.${category}`,