Skip to content

Commit

Permalink
Merge branch 'trunk' into add/redirect-root-to-sites
Browse files Browse the repository at this point in the history
  • Loading branch information
rcrdortiz committed Nov 28, 2024
2 parents e92d530 + 3db330b commit c9c212d
Show file tree
Hide file tree
Showing 79 changed files with 1,704 additions and 789 deletions.
19 changes: 12 additions & 7 deletions client/blocks/login/login-form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,13 @@ export class LoginForm extends Component {
const shouldRenderForgotPasswordLink =
! isPasswordHidden && isWoo && ! isPartnerSignup && ! isWooPasswordless;

const signUpUrlWithEmail = addQueryArgs(
{
user_email: this.state.usernameOrEmail,
},
signupUrl
);

return (
<form
className={ clsx( {
Expand Down Expand Up @@ -1026,19 +1033,17 @@ export class LoginForm extends Component {
{ requestError && requestError.field === 'usernameOrEmail' && (
<FormInputValidation isError text={ requestError.message }>
{ 'unknown_user' === requestError.code &&
! this.props.isWooPasswordlessJPC &&
this.props.translate(
' Would you like to {{newAccountLink}}create a new account{{/newAccountLink}}?',
{
components: {
newAccountLink: (
<a
href={ addQueryArgs(
{
user_email: this.state.usernameOrEmail,
},
signupUrl
) }
onClick={ ( e ) => {
e.preventDefault();
window.location.href = signUpUrlWithEmail;
} }
href={ signUpUrlWithEmail }
/>
),
},
Expand Down
5 changes: 5 additions & 0 deletions client/components/chart/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ function Chart( {
}
}, [ maxBars, onChangeMaxBars ] );

useEffect( () => {
// Invalidate (hide) the tooltip if the underlying data changes.
setTooltip( { isTooltipVisible: false } );
}, [ data ] );

// Memoize data calculations to avoid performing them too often.
const { chartData, isEmptyChart, yMax } = useMemo( () => {
const nextData = ( () => {
Expand Down
4 changes: 4 additions & 0 deletions client/components/panel/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
padding: 0;
}

.upsell-nudge {
width: 100%;
}

// TODO: remove after the untangling/hosting-menu flag is enabled
#primary > & {
margin-left: auto;
Expand Down
24 changes: 23 additions & 1 deletion client/components/stats-date-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,32 @@ const StatsDateControl = ( {
const moment = useLocalizedMoment();
const isOdysseyStats = config.isEnabled( 'is_running_in_jetpack_site' );

/**
* Remove start date from query params if it's out of range.
* @param queryParamsObject
* @param startDate
* @param endDate
*/
const removeOutOfRangeStartDate = (
queryParamsObject: Record< string, any >,
startDate: string,
endDate: string
): void => {
const selectedStartDate = queryParamsObject.startDate as string | undefined;

if ( selectedStartDate && ( selectedStartDate < startDate || selectedStartDate > endDate ) ) {
// When there is no selected date, it takes today by default.
delete queryParamsObject.startDate;
}
};

// Shared link generation helper.
const generateNewLink = ( period: string, startDate: string, endDate: string ) => {
const queryParamsObject = qs.parse( queryParams );
removeOutOfRangeStartDate( queryParamsObject, startDate, endDate );

const newRangeQuery = qs.stringify(
Object.assign( {}, queryParams, { chartStart: startDate, chartEnd: endDate } ),
Object.assign( {}, queryParamsObject, { chartStart: startDate, chartEnd: endDate } ),
{
addQueryPrefix: true,
}
Expand Down
110 changes: 65 additions & 45 deletions client/hosting/deployments/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import page from '@automattic/calypso-router';
import { isEnabled } from '@automattic/calypso-config';
import page, { type Context } from '@automattic/calypso-router';
import {
makeLayout,
render as clientRender,
Expand All @@ -18,51 +19,70 @@ import {
export default function () {
page( '/github-deployments', siteSelection, sites, makeLayout, clientRender );

page(
'/github-deployments/:site',
siteSelection,
redirectToHostingPromoIfNotAtomic,
redirectHomeIfIneligible,
navigation,
deploymentsList,
siteDashboard( DOTCOM_GITHUB_DEPLOYMENTS ),
makeLayout,
clientRender
);
if ( isEnabled( 'untangling/hosting-menu' ) ) {
page( '/github-deployments/:site', ( context: Context ) => {
page.redirect( `/sites/tools/deployments/${ context.params.site }` );
} );
page( '/github-deployments/:site/create', ( context: Context ) => {
page.redirect( `/sites/tools/deployments/${ context.params.site }/create` );
} );
page( '/github-deployments/:site/manage/:deploymentId', ( context: Context ) => {
page.redirect(
`/sites/tools/deployments/${ context.params.site }/manage/${ context.params.deploymentId }`
);
} );
page( '/github-deployments/:site/logs/:deploymentId', ( context: Context ) => {
page.redirect(
`/sites/tools/deployments/${ context.params.site }/logs/${ context.params.deploymentId }`
);
} );
} else {
page(
'/github-deployments/:site',
siteSelection,
redirectToHostingPromoIfNotAtomic,
redirectHomeIfIneligible,
navigation,
deploymentsList,
siteDashboard( DOTCOM_GITHUB_DEPLOYMENTS ),
makeLayout,
clientRender
);

page(
'/github-deployments/:site/create',
siteSelection,
redirectToHostingPromoIfNotAtomic,
redirectHomeIfIneligible,
navigation,
deploymentCreation,
siteDashboard( DOTCOM_GITHUB_DEPLOYMENTS ),
makeLayout,
clientRender
);
page(
'/github-deployments/:site/create',
siteSelection,
redirectToHostingPromoIfNotAtomic,
redirectHomeIfIneligible,
navigation,
deploymentCreation,
siteDashboard( DOTCOM_GITHUB_DEPLOYMENTS ),
makeLayout,
clientRender
);

page(
'/github-deployments/:site/manage/:deploymentId',
siteSelection,
redirectToHostingPromoIfNotAtomic,
redirectHomeIfIneligible,
navigation,
deploymentManagement,
siteDashboard( DOTCOM_GITHUB_DEPLOYMENTS ),
makeLayout,
clientRender
);
page(
'/github-deployments/:site/manage/:deploymentId',
siteSelection,
redirectToHostingPromoIfNotAtomic,
redirectHomeIfIneligible,
navigation,
deploymentManagement,
siteDashboard( DOTCOM_GITHUB_DEPLOYMENTS ),
makeLayout,
clientRender
);

page(
'/github-deployments/:site/logs/:deploymentId',
siteSelection,
redirectToHostingPromoIfNotAtomic,
redirectHomeIfIneligible,
navigation,
deploymentRunLogs,
siteDashboard( DOTCOM_GITHUB_DEPLOYMENTS ),
makeLayout,
clientRender
);
page(
'/github-deployments/:site/logs/:deploymentId',
siteSelection,
redirectToHostingPromoIfNotAtomic,
redirectHomeIfIneligible,
navigation,
deploymentRunLogs,
siteDashboard( DOTCOM_GITHUB_DEPLOYMENTS ),
makeLayout,
clientRender
);
}
}
30 changes: 19 additions & 11 deletions client/hosting/hosting-features/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { isEnabled } from '@automattic/calypso-config';
import page, { Context as PageJSContext } from '@automattic/calypso-router';
import { addQueryArgs } from '@wordpress/url';
import { makeLayout, render as clientRender, redirectIfP2 } from 'calypso/controller';
Expand All @@ -18,15 +19,22 @@ const redirectForNonSimpleSite = ( context: PageJSContext, next: () => void ) =>

export default function () {
page( '/hosting-features', siteSelection, sites, makeLayout, clientRender );
page(
'/hosting-features/:site',
siteSelection,
navigation,
redirectForNonSimpleSite,
redirectIfP2,
hostingFeatures,
siteDashboard( DOTCOM_HOSTING_FEATURES ),
makeLayout,
clientRender
);

if ( isEnabled( 'untangling/hosting-menu' ) ) {
page( '/hosting-features/:site', ( context: PageJSContext ) => {
page.redirect( `/sites/tools/${ context.params.site }` );
} );
} else {
page(
'/hosting-features/:site',
siteSelection,
navigation,
redirectForNonSimpleSite,
redirectIfP2,
hostingFeatures,
siteDashboard( DOTCOM_HOSTING_FEATURES ),
makeLayout,
clientRender
);
}
}
64 changes: 37 additions & 27 deletions client/hosting/logs/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import page, { type Callback } from '@automattic/calypso-router';
import { isEnabled } from '@automattic/calypso-config';
import page, { type Callback, type Context } from '@automattic/calypso-router';
import {
makeLayout,
render as clientRender,
Expand All @@ -16,31 +17,40 @@ import { phpErrorLogs, webServerLogs } from './controller';
export default function () {
page( '/site-logs', siteSelection, sites, makeLayout, clientRender );

const redirectSiteLogsToPhp: Callback = ( context ) => {
context.page.replace( `/site-logs/${ context.params.site }/php` );
};
page( '/site-logs/:site', redirectSiteLogsToPhp );
if ( isEnabled( 'untangling/hosting-menu' ) ) {
page( '/site-logs/:site', ( context: Context ) => {
page.redirect( `/sites/tools/logs/${ context.params.site }` );
} );
page( '/site-logs/:site/:type', ( context: Context ) => {
page.redirect( `/sites/tools/logs/${ context.params.site }/${ context.params.type }` );
} );
} else {
const redirectSiteLogsToPhp: Callback = ( context ) => {
context.page.replace( `/site-logs/${ context.params.site }/php` );
};
page( '/site-logs/:site', redirectSiteLogsToPhp );

page(
'/site-logs/:site/php',
siteSelection,
redirectToHostingPromoIfNotAtomic,
redirectHomeIfIneligible,
navigation,
phpErrorLogs,
siteDashboard( DOTCOM_LOGS_PHP ),
makeLayout,
clientRender
);
page(
'/site-logs/:site/web',
siteSelection,
redirectToHostingPromoIfNotAtomic,
redirectHomeIfIneligible,
navigation,
webServerLogs,
siteDashboard( DOTCOM_LOGS_WEB ),
makeLayout,
clientRender
);
page(
'/site-logs/:site/php',
siteSelection,
redirectToHostingPromoIfNotAtomic,
redirectHomeIfIneligible,
navigation,
phpErrorLogs,
siteDashboard( DOTCOM_LOGS_PHP ),
makeLayout,
clientRender
);
page(
'/site-logs/:site/web',
siteSelection,
redirectToHostingPromoIfNotAtomic,
redirectHomeIfIneligible,
navigation,
webServerLogs,
siteDashboard( DOTCOM_LOGS_WEB ),
makeLayout,
clientRender
);
}
}
31 changes: 19 additions & 12 deletions client/hosting/monitoring/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import page from '@automattic/calypso-router';
import { isEnabled } from '@automattic/calypso-config';
import page, { type Context } from '@automattic/calypso-router';
import {
makeLayout,
render as clientRender,
Expand All @@ -12,15 +13,21 @@ import { redirectHomeIfIneligible, siteMonitoring } from './controller';
export default function () {
page( '/site-monitoring', siteSelection, sites, makeLayout, clientRender );

page(
'/site-monitoring/:site',
siteSelection,
redirectToHostingPromoIfNotAtomic,
redirectHomeIfIneligible,
navigation,
siteMonitoring,
siteDashboard( DOTCOM_MONITORING ),
makeLayout,
clientRender
);
if ( isEnabled( 'untangling/hosting-menu' ) ) {
page( '/site-monitoring/:site', ( context: Context ) => {
page.redirect( `/sites/tools/monitoring/${ context.params.site }` );
} );
} else {
page(
'/site-monitoring/:site',
siteSelection,
redirectToHostingPromoIfNotAtomic,
redirectHomeIfIneligible,
navigation,
siteMonitoring,
siteDashboard( DOTCOM_MONITORING ),
makeLayout,
clientRender
);
}
}
Loading

0 comments on commit c9c212d

Please sign in to comment.