File size: 1,978 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
import page, { Context as PageJSContext } from '@automattic/calypso-router';
import { addQueryArgs } from '@wordpress/url';
import {
makeLayout,
render as clientRender,
redirectIfP2,
redirectIfCurrentUserCannot,
} from 'calypso/controller';
import {
hostingConfiguration,
redirectToServerSettingsIfDuplicatedView,
} from 'calypso/hosting/overview/controller';
import { handleHostingPanelRedirect } from 'calypso/hosting/server-settings/controller';
import { navigation, siteSelection, sites } from 'calypso/my-sites/controller';
import {
HOSTING_CONFIG,
HOSTING_FEATURES,
} from 'calypso/sites/components/site-preview-pane/constants';
import { redirectToHostingFeaturesIfNotAtomic, siteDashboard } from 'calypso/sites/controller';
import { getSelectedSite } from 'calypso/state/ui/selectors';
import { hostingFeatures } from './controller';
const redirectForNonSimpleSite = ( context: PageJSContext, next: () => void ) => {
const state = context.store.getState();
const site = getSelectedSite( state );
if ( site && site.jetpack && ! site.plan?.expired ) {
return page.redirect( addQueryArgs( `/overview/${ context.params.site }`, context.query ) );
}
return next();
};
export default function () {
page( '/hosting-config', siteSelection, sites, makeLayout, clientRender );
page(
'/hosting-config/:site_id',
siteSelection,
navigation,
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
redirectIfCurrentUserCannot( 'manage_options' ),
redirectToHostingFeaturesIfNotAtomic,
redirectToServerSettingsIfDuplicatedView,
handleHostingPanelRedirect,
hostingConfiguration,
siteDashboard( HOSTING_CONFIG ),
makeLayout,
clientRender
);
page( '/hosting-features', siteSelection, sites, makeLayout, clientRender );
page(
'/hosting-features/:site',
siteSelection,
navigation,
redirectForNonSimpleSite,
redirectIfP2,
hostingFeatures,
siteDashboard( HOSTING_FEATURES ),
makeLayout,
clientRender
);
}
|