Skip to content

Commit

Permalink
Protect: add home page
Browse files Browse the repository at this point in the history
Rebase on admin hero section refactor

Revert accidental type changes

Remove testing code

Init project branch

Protect: Add ShieldIcon Component (#40402)

Refactor AdminSectionHero component
  • Loading branch information
Dean Kmyta authored and nateweller committed Dec 10, 2024
1 parent 101900b commit bc78984
Show file tree
Hide file tree
Showing 18 changed files with 447 additions and 293 deletions.
13 changes: 10 additions & 3 deletions projects/js-packages/components/components/stat-card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ import type React from 'react';
* @param {StatCardProps} props - Component props.
* @return {React.ReactNode} - StatCard react component.
*/
const StatCard = ( { className, icon, label, value, variant = 'square' }: StatCardProps ) => {
const StatCard = ( {
className,
icon,
label,
value,
variant = 'square',
hideValue = false,
}: StatCardProps ) => {
const formattedValue = numberFormat( value );
const compactValue = numberFormat( value, {
notation: 'compact',
Expand All @@ -33,12 +40,12 @@ const StatCard = ( { className, icon, label, value, variant = 'square' }: StatCa
{ variant === 'square' ? (
<Tooltip text={ formattedValue } placement="top">
<Text variant="headline-small" className={ clsx( styles.value ) }>
{ compactValue }
{ hideValue ? '-' : compactValue }
</Text>
</Tooltip>
) : (
<Text variant="title-medium-semi-bold" className={ clsx( styles.value ) }>
{ formattedValue }
{ hideValue ? '-' : formattedValue }
</Text>
) }
</div>
Expand Down
5 changes: 5 additions & 0 deletions projects/js-packages/components/components/stat-card/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ export type StatCardProps = {
* @default 'square'
*/
variant?: 'square' | 'horizontal';

/**
* Whether to hide the value.
*/
hideValue?: boolean;
};
4 changes: 4 additions & 0 deletions projects/plugins/protect/changelog/add-protect-home
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Adds a Home page and StatCards
3 changes: 2 additions & 1 deletion projects/plugins/protect/src/class-jetpack-protect.php
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,9 @@ public static function get_waf_stats() {
}

return array(
'blockedRequests' => Plan::has_required_plan() ? Waf_Stats::get_blocked_requests() : false,
'blockedRequests' => Waf_Stats::get_blocked_requests(),
'automaticRulesLastUpdated' => Waf_Stats::get_automatic_rules_last_updated(),
'blockedLogins' => (int) get_option( 'jetpack_protect_blocked_attempts', 0 ),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const AdminPage = ( { children } ) => {
{ notice && <Notice floating={ true } dismissable={ true } { ...notice } /> }
<Container horizontalSpacing={ 0 }>
<Tabs className={ styles.navigation }>
<Tab link="/" label={ __( 'Home', 'jetpack-protect' ) } />
<Tab
link="/scan"
label={
Expand Down

This file was deleted.

68 changes: 0 additions & 68 deletions projects/plugins/protect/src/js/components/form-toggle/index.jsx

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const ConnectedPricingTable = () => {
const getProtectFree = useCallback( async () => {
recordEvent( 'jetpack_protect_connected_product_activated' );
await connectSiteMutation.mutateAsync();
navigate( '/scan' );
navigate( '/' );
}, [ connectSiteMutation, recordEvent, navigate ] );

const args = {
Expand Down

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion projects/plugins/protect/src/js/hooks/use-plan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default function usePlan( { redirectUrl }: { redirectUrl?: string } = {}

const { run: checkout } = useProductCheckoutWorkflow( {
productSlug: JETPACK_SCAN_SLUG,
redirectUrl: redirectUrl || adminUrl,
redirectUrl: redirectUrl || adminUrl + '#/scan',
siteProductAvailabilityHandler: API.checkPlan,
useBlogIdSuffix: true,
connectAfterCheckout: false,
Expand Down
4 changes: 3 additions & 1 deletion projects/plugins/protect/src/js/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { NoticeProvider } from './hooks/use-notices';
import { OnboardingRenderedContextProvider } from './hooks/use-onboarding';
import { CheckoutProvider } from './hooks/use-plan';
import FirewallRoute from './routes/firewall';
import HomeRoute from './routes/home';
import ScanRoute from './routes/scan';
import SetupRoute from './routes/setup';
import './styles.module.scss';
Expand Down Expand Up @@ -56,6 +57,7 @@ function render() {
<ScrollToTop />
<Routes>
<Route path="/setup" element={ <SetupRoute /> } />
<Route path="/" element={ <HomeRoute /> } />
<Route path="/scan" element={ <ScanRoute /> } />
<Route
path="/scan/history"
Expand All @@ -74,7 +76,7 @@ function render() {
}
/>
<Route path="/firewall" element={ <FirewallRoute /> } />
<Route path="*" element={ <Navigate to="/scan" replace /> } />
<Route path="*" element={ <Navigate to="/" replace /> } />
</Routes>
</HashRouter>
<Modal />
Expand Down
Loading

0 comments on commit bc78984

Please sign in to comment.