Download wp-calypso/client/sites-dashboard/utils.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 4.2 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/sites-dashboard/utils.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/sites-dashboard/utils.ts
-
curl -L -o utils.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/sites-dashboard/utils.ts
4.2 kB
| import { | |
| PLAN_MIGRATION_TRIAL_MONTHLY, | |
| PLAN_ECOMMERCE_TRIAL_MONTHLY, | |
| PLAN_HOSTING_TRIAL_MONTHLY, | |
| } from '@automattic/calypso-products'; | |
| import type { SiteExcerptData, SiteExcerptNetworkData } from '@automattic/sites'; | |
| export const TRACK_SOURCE_NAME = 'sites-dashboard'; | |
| export const getLaunchpadUrl = ( slug: string, flow: string ) => { | |
| return `/setup/${ flow }/launchpad?siteSlug=${ slug }`; | |
| }; | |
| export const getDashboardUrl = ( slug: string ) => { | |
| return `/home/${ slug }`; | |
| }; | |
| export const getPluginsUrl = ( slug: string ) => { | |
| return `/plugins/${ slug }`; | |
| }; | |
| export const getManagePluginsUrl = ( slug: string ) => { | |
| return `/plugins/manage/${ slug }`; | |
| }; | |
| export const getHostingConfigUrl = ( slug: string ) => { | |
| return `/hosting-config/${ slug }`; | |
| }; | |
| export const displaySiteUrl = ( siteUrl: string ) => { | |
| return siteUrl.replace( 'https://', '' ).replace( 'http://', '' ); | |
| }; | |
| export function isCustomDomain( siteSlug: string | null | undefined ): boolean { | |
| if ( ! siteSlug ) { | |
| return false; | |
| } | |
| return ! siteSlug.endsWith( '.wordpress.com' ) && ! siteSlug.endsWith( '.wpcomstaging.com' ); | |
| } | |
| export function getSiteAdminUrl( site: SiteExcerptNetworkData ) { | |
| return site.options?.admin_url ?? ''; | |
| } | |
| export const isNotAtomicJetpack = ( site: SiteExcerptNetworkData ) => { | |
| return site.jetpack && ! site?.is_wpcom_atomic; | |
| }; | |
| // Sites connected through A4A plugin are listed on wordpress.com/sites even when Jetpack is deactivated. | |
| export const isDisconnectedJetpackAndNotAtomic = ( site: SiteExcerptNetworkData ) => { | |
| return ! site?.is_wpcom_atomic && site?.jetpack_connection && ! site?.jetpack; | |
| }; | |
| export const isSimpleSite = ( site: SiteExcerptNetworkData ) => { | |
| return ! site?.jetpack && ! site?.is_wpcom_atomic; | |
| }; | |
| export const isP2Site = ( site: SiteExcerptNetworkData ) => { | |
| return site.options?.is_wpforteams_site; | |
| }; | |
| export const isStagingSite = ( site: SiteExcerptNetworkData | undefined ) => { | |
| return site?.is_wpcom_staging_site; | |
| }; | |
| export const isMigrationTrialSite = ( site: SiteExcerptNetworkData ) => { | |
| return site?.plan?.product_slug === PLAN_MIGRATION_TRIAL_MONTHLY; | |
| }; | |
| export const isHostingTrialSite = ( site: SiteExcerptNetworkData ) => { | |
| return site?.plan?.product_slug === PLAN_HOSTING_TRIAL_MONTHLY; | |
| }; | |
| export const isECommerceTrialSite = ( site: SiteExcerptNetworkData ) => { | |
| return site?.plan?.product_slug === PLAN_ECOMMERCE_TRIAL_MONTHLY; | |
| }; | |
| export const isBusinessTrialSite = ( site: SiteExcerptNetworkData ) => { | |
| return isMigrationTrialSite( site ) || isHostingTrialSite( site ); | |
| }; | |
| export const isTrialSite = ( site: SiteExcerptNetworkData ) => { | |
| return isBusinessTrialSite( site ) || isECommerceTrialSite( site ); | |
| }; | |
| export const getAdminInterface = ( site: SiteExcerptNetworkData ) => { | |
| return site?.options?.wpcom_admin_interface; | |
| }; | |
| export const siteUsesWpAdminInterface = ( site: SiteExcerptNetworkData ) => { | |
| return ( site.jetpack && ! site.is_wpcom_atomic ) || getAdminInterface( site ) === 'wp-admin'; | |
| }; | |
| export const isSitePreviewPaneEligible = ( site: SiteExcerptData, canManageOptions: boolean ) => { | |
| return ( | |
| ! isDisconnectedJetpackAndNotAtomic( site ) && | |
| ! isNotAtomicJetpack( site ) && | |
| ! isP2Site( site ) && | |
| canManageOptions | |
| ); | |
| }; | |
| export interface InterfaceURLFragment { | |
| calypso: `/${ string }`; | |
| wpAdmin: `/${ string }`; | |
| } | |
| export const generateSiteInterfaceLink = ( | |
| site: SiteExcerptData, | |
| urlFragment: InterfaceURLFragment | |
| ) => { | |
| const targetLink = siteUsesWpAdminInterface( site ) | |
| ? `${ site.URL }/wp-admin${ urlFragment.wpAdmin }` | |
| : `${ urlFragment.calypso }/${ site.slug }`; | |
| return targetLink; | |
| }; | |
| export const SMALL_MEDIA_QUERY = 'screen and ( max-width: 600px )'; | |
| export const MEDIA_QUERIES = { | |
| small: `@media ${ SMALL_MEDIA_QUERY }`, | |
| mediumOrSmaller: '@media screen and ( max-width: 781px )', | |
| mediumOrLarger: '@media screen and ( min-width: 660px )', | |
| hideTableRows: '@media screen and ( max-width: 1100px )', | |
| large: '@media screen and ( min-width: 960px )', | |
| wide: '@media screen and ( min-width: 1280px )', | |
| }; | |
| export const PLAN_RENEW_NAG_EVENT_NAMES = { | |
| IN_VIEW: 'calypso_sites_dashboard_plan_renew_nag_inview', | |
| ON_CLICK: 'calypso_sites_dashboard_plan_renew_nag_click', | |
| }; | |