Download wp-calypso/client/sites/hosting/features.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.27 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/sites/hosting/features.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/sites/hosting/features.ts
-
curl -L -o features.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/sites/hosting/features.ts
1.27 kB
| import { FEATURE_SFTP } from '@automattic/calypso-products'; | |
| import { SiteExcerptData } from '@automattic/sites'; | |
| import { useSelector } from 'calypso/state'; | |
| import getSiteFeatures from 'calypso/state/selectors/get-site-features'; | |
| import siteHasFeature from 'calypso/state/selectors/site-has-feature'; | |
| import { getSelectedSite } from 'calypso/state/ui/selectors'; | |
| import { AppState } from 'calypso/types'; | |
| export function areHostingFeaturesSupported( site?: SiteExcerptData | null ) { | |
| const isAtomicSite = !! site?.is_wpcom_atomic || !! site?.is_wpcom_staging_site; | |
| const isPlanExpired = site?.plan?.expired; | |
| return isAtomicSite && ! isPlanExpired; | |
| } | |
| export function useAreHostingFeaturesSupported() { | |
| const site = useSelector( getSelectedSite ); | |
| return areHostingFeaturesSupported( site ); | |
| } | |
| export function areAdvancedHostingFeaturesSupported( state: AppState ) { | |
| const site = getSelectedSite( state ); | |
| const features = getSiteFeatures( state, site?.ID ); | |
| const hasSftpFeature = siteHasFeature( state, site?.ID, FEATURE_SFTP ); | |
| if ( ! features ) { | |
| return null; | |
| } | |
| return areHostingFeaturesSupported( site ) && hasSftpFeature; | |
| } | |
| export function useAreAdvancedHostingFeaturesSupported() { | |
| return useSelector( areAdvancedHostingFeaturesSupported ); | |
| } | |