-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Site Dashboard: Add the Staging Sites tab (#91276)
* Site Dashboard: Add the Staging Sites tab * Refactor * Add tests * Fix types * Update styles * Fix styles * Add the upsell nudge * Redirect to dev tool for simple sites * Redirect to overview when people want to manage the staging site
- Loading branch information
1 parent
f62995b
commit 5cc52b0
Showing
16 changed files
with
321 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 9 additions & 3 deletions
12
client/my-sites/hosting/staging-site-card/card-content/card-content-wrapper.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
client/staging-site/components/staging-site-upsell-nudge/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { PLAN_BUSINESS, getPlan, FEATURE_SITE_STAGING_SITES } from '@automattic/calypso-products'; | ||
import { addQueryArgs } from '@wordpress/url'; | ||
import { useTranslate } from 'i18n-calypso'; | ||
import UpsellNudge from 'calypso/blocks/upsell-nudge'; | ||
import InlineSupportLink from 'calypso/components/inline-support-link'; | ||
import { CardContentWrapper } from 'calypso/my-sites/hosting/staging-site-card/card-content/card-content-wrapper'; | ||
import { useSelector } from 'calypso/state'; | ||
import { getSelectedSiteId } from 'calypso/state/ui/selectors'; | ||
|
||
const StagingSiteUpsellNudge = () => { | ||
const translate = useTranslate(); | ||
const siteId = useSelector( ( state ) => getSelectedSiteId( state ) ) ?? 0; | ||
const href = addQueryArgs( `/checkout/${ siteId }/business`, { | ||
redirect_to: `/staging-site/${ siteId }`, | ||
} ); | ||
|
||
return ( | ||
<CardContentWrapper className="is-borderless"> | ||
<p> | ||
{ translate( | ||
'Your staging site lets you preview and troubleshoot changes before updating the production site. {{a}}Learn more{{/a}}.', | ||
{ | ||
components: { | ||
a: <InlineSupportLink supportContext="hosting-staging-site" showIcon={ false } />, | ||
}, | ||
} | ||
) } | ||
</p> | ||
<UpsellNudge | ||
className="staging-site-upsell-nudge" | ||
title={ translate( 'Upgrade to the %(businessPlanName)s plan to add a staging site.', { | ||
args: { businessPlanName: getPlan( PLAN_BUSINESS )?.getTitle() ?? '' }, | ||
} ) } | ||
tracksImpressionName="calypso_staging_site_upgrade_impression" | ||
event="calypso_staging_site_upgrade_upsell" | ||
tracksClickName="calypso_staging_site_upgrade_click" | ||
href={ href } | ||
callToAction={ translate( 'Upgrade' ) } | ||
plan={ PLAN_BUSINESS } | ||
showIcon | ||
feature={ FEATURE_SITE_STAGING_SITES } | ||
/> | ||
</CardContentWrapper> | ||
); | ||
}; | ||
|
||
export default StagingSiteUpsellNudge; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { FEATURE_SITE_STAGING_SITES, WPCOM_FEATURES_ATOMIC } from '@automattic/calypso-products'; | ||
import StagingSiteCard from 'calypso/my-sites/hosting/staging-site-card'; | ||
import StagingSiteProductionCard from 'calypso/my-sites/hosting/staging-site-card/staging-site-production-card'; | ||
import { useSelector } from 'calypso/state'; | ||
import isSiteWpcomStaging from 'calypso/state/selectors/is-site-wpcom-staging'; | ||
import siteHasFeature from 'calypso/state/selectors/site-has-feature'; | ||
import { getSelectedSiteId } from 'calypso/state/ui/selectors'; | ||
import StagingSiteUpsellNudge from '../staging-site-upsell-nudge'; | ||
import './style.scss'; | ||
|
||
const StagingSite = () => { | ||
const siteId = useSelector( ( state ) => getSelectedSiteId( state ) ) ?? 0; | ||
const hasAtomicFeature = useSelector( ( state ) => | ||
siteHasFeature( state, siteId, WPCOM_FEATURES_ATOMIC ) | ||
); | ||
const hasStagingSitesFeature = useSelector( ( state ) => | ||
siteHasFeature( state, siteId, FEATURE_SITE_STAGING_SITES ) | ||
); | ||
const isWpcomStagingSite = useSelector( ( state ) => isSiteWpcomStaging( state, siteId ) ); | ||
|
||
if ( ! hasAtomicFeature && ! hasStagingSitesFeature ) { | ||
return <StagingSiteUpsellNudge />; | ||
} | ||
|
||
if ( isWpcomStagingSite ) { | ||
return <StagingSiteProductionCard siteId={ siteId } isBorderless />; | ||
} | ||
|
||
return <StagingSiteCard isBorderless />; | ||
}; | ||
|
||
export default StagingSite; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.wpcom-site .is-section-staging-site .staging-site-card { | ||
.hosting-card__title, | ||
.card-heading { | ||
margin-bottom: 4px; | ||
font-size: 1.25rem; | ||
line-height: 26px; | ||
text-transform: capitalize; | ||
|
||
& ~ p { | ||
margin-bottom: 32px; | ||
font-size: 0.875rem; | ||
line-height: 20px; | ||
color: var(--color-neutral-60); | ||
} | ||
} | ||
|
||
> svg.gridicon.gridicons-science { | ||
width: 24px; | ||
height: 24px; | ||
margin-inline-end: 8px; | ||
margin-bottom: 4px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { createElement } from 'react'; | ||
import StagingSite from './components/staging-site'; | ||
|
||
export function renderStagingSite( context, next ) { | ||
context.primary = createElement( StagingSite ); | ||
next(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import page from '@automattic/calypso-router'; | ||
import { | ||
makeLayout, | ||
render as clientRender, | ||
redirectIfCurrentUserCannot, | ||
redirectToDevToolsPromoIfNotAtomic, | ||
} from 'calypso/controller'; | ||
import { navigation, siteSelection, sites } from 'calypso/my-sites/controller'; | ||
import { handleHostingPanelRedirect } from 'calypso/my-sites/hosting/controller'; | ||
import { siteDashboard } from 'calypso/sites-dashboard-v2/controller'; | ||
import { DOTCOM_STAGING_SITE } from 'calypso/sites-dashboard-v2/site-preview-pane/constants'; | ||
import { renderStagingSite } from './controller'; | ||
|
||
export default function () { | ||
page( '/staging-site', siteSelection, sites, makeLayout, clientRender ); | ||
|
||
page( | ||
'/staging-site/:site', | ||
siteSelection, | ||
navigation, | ||
redirectToDevToolsPromoIfNotAtomic, | ||
redirectIfCurrentUserCannot( 'manage_options' ), | ||
handleHostingPanelRedirect, | ||
renderStagingSite, | ||
siteDashboard( DOTCOM_STAGING_SITE ), | ||
makeLayout, | ||
clientRender | ||
); | ||
} |
Oops, something went wrong.