Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(hosting-server-settings): move to the right place, rename and a bit clean up #94545

Merged
merged 3 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { FC, ReactNode, FocusEvent, useState } from 'react';
import { useIsEligibleForFeature } from 'calypso/blocks/plugins-scheduled-updates/hooks/use-is-eligible-for-feature';
import Notice from 'calypso/components/notice';
import NoticeAction from 'calypso/components/notice/notice-action';
import HostingActivateStatus from 'calypso/my-sites/hosting/hosting-activate-status';
import HostingActivateStatus from 'calypso/hosting/server-settings/hosting-activate-status';
import { useDispatch, useSelector } from 'calypso/state';
import { transferInProgress } from 'calypso/state/automated-transfer/constants';
import { getAutomatedTransferStatus } from 'calypso/state/automated-transfer/selectors';
Expand Down
2 changes: 1 addition & 1 deletion client/hosting/overview/components/hosting-overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ActiveDomainsCard from 'calypso/hosting/overview/components/active-domain
import PlanCard from 'calypso/hosting/overview/components/plan-card';
import QuickActionsCard from 'calypso/hosting/overview/components/quick-actions-card';
import SiteBackupCard from 'calypso/hosting/overview/components/site-backup-card';
import SupportCard from 'calypso/my-sites/hosting/support-card';
import SupportCard from 'calypso/hosting/server-settings/support-card';
import { isNotAtomicJetpack } from 'calypso/sites-dashboard/utils';
import { useSelector } from 'calypso/state';
import { getSelectedSite } from 'calypso/state/ui/selectors';
Expand Down
4 changes: 2 additions & 2 deletions client/hosting/overview/controller.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Context as PageJSContext } from '@automattic/calypso-router';
import HostingOverview from 'calypso/hosting/overview/components/hosting-overview';
import HostingActivate from 'calypso/my-sites/hosting/hosting-activate';
import Hosting from 'calypso/my-sites/hosting/main';
import HostingActivate from 'calypso/hosting/server-settings/hosting-activate';
import Hosting from 'calypso/hosting/server-settings/main';

export function hostingOverview( context: PageJSContext, next: () => void ) {
context.primary = <HostingOverview />;
Expand Down
2 changes: 1 addition & 1 deletion client/hosting/overview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import {
redirectIfP2,
redirectIfJetpackNonAtomic,
} from 'calypso/controller';
import { handleHostingPanelRedirect } from 'calypso/hosting/server-settings/controller';
import {
DOTCOM_HOSTING_CONFIG,
DOTCOM_OVERVIEW,
} from 'calypso/hosting/sites/components/site-preview-pane/constants';
import { siteDashboard } from 'calypso/hosting/sites/controller';
import { navigation, siteSelection, sites } from 'calypso/my-sites/controller';
import { handleHostingPanelRedirect } from 'calypso/my-sites/hosting/controller';
import { hostingOverview, hostingConfiguration, hostingActivate } from './controller';

export default function () {
Expand Down
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is deleted in #94538, can we skip this in this PR? Also, as it-is, it will compile error because of this line import { indexPage } from '../github-deployments/routes';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {
import { navigation, siteSelection, sites } from 'calypso/my-sites/controller';
import { handleHostingPanelRedirect, layout, activationLayout } from './controller';

// TODO: remove this old unused code
// Details - https://a8c.slack.com/archives/C06DN6QQVAQ/p1726157495064039
export default function () {
page( '/hosting-config', siteSelection, sites, makeLayout, clientRender );
page(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ import NoticeAction from 'calypso/components/notice/notice-action';
import { ScrollToAnchorOnMount } from 'calypso/components/scroll-to-anchor-on-mount';
import PageViewTracker from 'calypso/lib/analytics/page-view-tracker';
import TrackComponentView from 'calypso/lib/analytics/track-component-view';
import { TrialAcknowledgeModal } from 'calypso/my-sites/plans/trials/trial-acknowledge/acknowlege-modal';
import { WithOnclickTrialRequest } from 'calypso/my-sites/plans/trials/trial-acknowledge/with-onclick-trial-request';
import TrialBanner from 'calypso/my-sites/plans/trials/trial-banner';
import SiteAdminInterface from 'calypso/my-sites/site-settings/site-admin-interface';
import { recordTracksEvent } from 'calypso/state/analytics/actions';
import { fetchAutomatedTransferStatus } from 'calypso/state/automated-transfer/actions';
import { transferStates } from 'calypso/state/automated-transfer/constants';
Expand All @@ -39,9 +42,6 @@ import {
getSelectedSiteId,
getSelectedSiteSlug,
} from 'calypso/state/ui/selectors';
import { TrialAcknowledgeModal } from '../plans/trials/trial-acknowledge/acknowlege-modal';
import { WithOnclickTrialRequest } from '../plans/trials/trial-acknowledge/with-onclick-trial-request';
import SiteAdminInterface from '../site-settings/site-admin-interface';
import CacheCard from './cache-card';
import HostingActivateStatus from './hosting-activate-status';
import { HostingUpsellNudge } from './hosting-upsell-nudge';
Expand Down Expand Up @@ -119,7 +119,7 @@ const AllCards = ( { isAdvancedHostingDisabled, isBasicHostingDisabled, siteId,
return <ShowEnabledFeatureCards cards={ allCards } availableTypes={ availableTypes } />;
};

const Hosting = ( props ) => {
const ServerSettings = ( props ) => {
const {
clickActivate,
isECommerceTrial,
Expand Down Expand Up @@ -222,7 +222,7 @@ const Hosting = ( props ) => {
{ isSiteAtomic && <QuerySites siteId={ siteId } /> }
{ isJetpack && <QueryJetpackModules siteId={ siteId } /> }
<WrapperComponent>
<Layout className="hosting__layout">
<Layout className="page-server-settings__layout">
<AllCards
isAdvancedHostingDisabled={ ! hasSftpFeature || ! isSiteAtomic }
isBasicHostingDisabled={ ! hasAtomicFeature || ! isSiteAtomic }
Expand All @@ -246,7 +246,7 @@ const Hosting = ( props ) => {
const banner = shouldShowUpgradeBanner ? getUpgradeBanner() : getAtomicActivationNotice();

return (
<Main wideLayout className="hosting hosting--is-two-columns">
<Main wideLayout className="page-server-settings">
{ ! isLoadingSftpData && (
<ScrollToAnchorOnMount
offset={ HEADING_OFFSET }
Expand Down Expand Up @@ -287,8 +287,7 @@ const Hosting = ( props ) => {
);
};

export const clickActivate = () =>
recordTracksEvent( 'calypso_hosting_configuration_activate_click' );
const clickActivate = () => recordTracksEvent( 'calypso_hosting_configuration_activate_click' );

export default connect(
( state ) => {
Expand Down Expand Up @@ -321,4 +320,4 @@ export default connect(
fetchAutomatedTransferStatus,
requestSiteById: requestSite,
}
)( localize( WithOnclickTrialRequest( Hosting ) ) );
)( localize( WithOnclickTrialRequest( ServerSettings ) ) );
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@

$areas: sftp, site-backup, support, phpmyadmin, staging-site, restore-plan-software, cache, web-server-settings, admin-interface-style;

.hosting {
.page-server-settings {
/* Rely on the standard spacing for the underlying elements. */
.feature-example {
margin-top: 0;
}

.hosting__layout .layout__column,
.hosting__layout .layout__column fieldset {
min-width: 0;
}

.hosting-card {
padding-left: 22px;
margin-bottom: 12px;
Expand All @@ -23,57 +18,40 @@ $areas: sftp, site-backup, support, phpmyadmin, staging-site, restore-plan-softw
margin-bottom: 32px;
}

&--is-two-columns {
.hosting__layout {
.card {
width: 100%;

@include breakpoint-deprecated( ">1280px" ) {
margin-bottom: 0;
min-width: 0;
.page-server-settings__layout {
.layout__column,
.layout__column fieldset {
min-width: 0;
}

fieldset {
min-width: 0;
}
}
}
.card {
width: 100%;

@include breakpoint-deprecated( ">1280px" ) {
@each $area in $areas {
.#{$area}-card {
grid-area: $area;
}
}
margin-bottom: 0;
min-width: 0;

box-sizing: border-box;
display: grid;
grid-template-columns: 1fr 1fr;
grid-template-areas:
"sftp phpmyadmin"
"sftp cache"
"restore-plan-software web-server-settings"
"admin-interface-style web-server-settings";
fieldset {
min-width: 0;
}
}
}
}

&:not(.hosting--is-two-columns) {
@include breakpoint-deprecated( ">1280px" ) {
.hosting__layout {
gap: 0;

.layout__column {
box-sizing: border-box;
flex-basis: 30%;
padding-left: 8px;

&.hosting__main-layout-col {
flex-basis: 70%;
padding-left: 0;
padding-right: 8px;
}
@each $area in $areas {
.#{$area}-card {
grid-area: $area;
}
}

box-sizing: border-box;
display: grid;
grid-template-columns: 1fr 1fr;
grid-template-areas:
"sftp phpmyadmin"
"sftp cache"
"restore-plan-software web-server-settings"
"admin-interface-style web-server-settings";
}
}

Expand Down
2 changes: 1 addition & 1 deletion client/hosting/staging-site/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import {
redirectIfCurrentUserCannot,
redirectToHostingPromoIfNotAtomic,
} from 'calypso/controller';
import { handleHostingPanelRedirect } from 'calypso/hosting/server-settings/controller';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a follow-up (not in this PR) maybe we need to extract this logic somewhere. It's copy-pasted literally in each tab for now. 😂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, good point :)

import { DOTCOM_STAGING_SITE } from 'calypso/hosting/sites/components/site-preview-pane/constants';
import { siteDashboard } from 'calypso/hosting/sites/controller';
import { navigation, siteSelection, sites } from 'calypso/my-sites/controller';
import { handleHostingPanelRedirect } from 'calypso/my-sites/hosting/controller';
import { renderStagingSite } from './controller';

export default function () {
Expand Down
2 changes: 1 addition & 1 deletion client/me/security-ssh-key/use-update-ssh-key-mutation.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query';
import { useCallback } from 'react';
import { USE_ATOMIC_SSH_KEYS_QUERY_KEY } from 'calypso/hosting/server-settings/sftp-card/use-atomic-ssh-keys';
import wp from 'calypso/lib/wp';
import { USE_ATOMIC_SSH_KEYS_QUERY_KEY } from 'calypso/my-sites/hosting/sftp-card/use-atomic-ssh-keys';
import { SSH_KEY_QUERY_KEY } from './use-ssh-key-query';

interface MutationVariables {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Main from 'calypso/components/main';
import NavigationHeader from 'calypso/components/navigation-header';
import Notice from 'calypso/components/notice';
import NoticeAction from 'calypso/components/notice/notice-action';
import HostingActivateStatus from 'calypso/my-sites/hosting/hosting-activate-status';
import HostingActivateStatus from 'calypso/hosting/server-settings/hosting-activate-status';
import { useDispatch, useSelector } from 'calypso/state';
import { transferInProgress } from 'calypso/state/automated-transfer/constants';
import { getAutomatedTransferStatus } from 'calypso/state/automated-transfer/selectors';
Expand Down
2 changes: 1 addition & 1 deletion client/my-sites/plugins/plugin-upload/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import FeatureExample from 'calypso/components/feature-example';
import HeaderCake from 'calypso/components/header-cake';
import Main from 'calypso/components/main';
import NavigationHeader from 'calypso/components/navigation-header';
import HostingActivateStatus from 'calypso/hosting/server-settings/hosting-activate-status';
import PageViewTracker from 'calypso/lib/analytics/page-view-tracker';
import HostingActivateStatus from 'calypso/my-sites/hosting/hosting-activate-status';
import { TrialAcknowledgeModal } from 'calypso/my-sites/plans/trials/trial-acknowledge/acknowlege-modal';
import { WithOnclickTrialRequest } from 'calypso/my-sites/plans/trials/trial-acknowledge/with-onclick-trial-request';
import { isHostingTrialSite } from 'calypso/sites-dashboard/utils';
Expand Down
2 changes: 1 addition & 1 deletion client/my-sites/plugins/plugins-discovery-page/index.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useSelector } from 'react-redux';
import HostingActivateStatus from 'calypso/my-sites/hosting/hosting-activate-status';
import HostingActivateStatus from 'calypso/hosting/server-settings/hosting-activate-status';
import { TrialAcknowledgeModal } from 'calypso/my-sites/plans/trials/trial-acknowledge/acknowlege-modal';
import { WithOnclickTrialRequest } from 'calypso/my-sites/plans/trials/trial-acknowledge/with-onclick-trial-request';
import { isCompatiblePlugin } from 'calypso/my-sites/plugins/plugin-compatibility';
Expand Down
2 changes: 1 addition & 1 deletion client/my-sites/themes/theme-upload/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import InlineSupportLink from 'calypso/components/inline-support-link';
import Main from 'calypso/components/main';
import NavigationHeader from 'calypso/components/navigation-header';
import WpAdminAutoLogin from 'calypso/components/wpadmin-auto-login';
import HostingActivateStatus from 'calypso/hosting/server-settings/hosting-activate-status';
import PageViewTracker from 'calypso/lib/analytics/page-view-tracker';
import HostingActivateStatus from 'calypso/my-sites/hosting/hosting-activate-status';
import { TrialAcknowledgeModal } from 'calypso/my-sites/plans/trials/trial-acknowledge/acknowlege-modal';
import { WithOnclickTrialRequest } from 'calypso/my-sites/plans/trials/trial-acknowledge/with-onclick-trial-request';
import ActivationModal from 'calypso/my-sites/themes/activation-modal';
Expand Down
2 changes: 1 addition & 1 deletion client/sites-dashboard/components/wpcom-smp-commands.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {
useSetEdgeCacheMutation,
purgeEdgeCache,
} from 'calypso/data/hosting/use-cache';
import { useOpenPhpMyAdmin } from 'calypso/hosting/server-settings/phpmyadmin-card';
import { navigate } from 'calypso/lib/navigate';
import wpcom from 'calypso/lib/wp';
import { useOpenPhpMyAdmin } from 'calypso/my-sites/hosting/phpmyadmin-card';
import { useDispatch } from 'calypso/state';
import { clearWordPressCache } from 'calypso/state/hosting/actions';
import { createNotice, removeNotice } from 'calypso/state/notices/actions';
Expand Down
Loading