• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Yoast / wordpress-seo / 288b805388e31ecb55dff883f9700a1f6517ff30

25 Nov 2024 03:26PM CUT coverage: 54.166% (-0.001%) from 54.167%
288b805388e31ecb55dff883f9700a1f6517ff30

Pull #21862

github

web-flow
Merge 66a57fa3a into b00849231
Pull Request #21862: Dashboard: move to final copy

7593 of 13672 branches covered (55.54%)

Branch coverage included in aggregate %.

0 of 3 new or added lines in 3 files covered. (0.0%)

1 existing line in 1 file now uncovered.

29764 of 55295 relevant lines covered (53.83%)

41506.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/packages/js/src/general/initialize.js
1
import { SlotFillProvider } from "@wordpress/components";
2
import { select } from "@wordpress/data";
3
import domReady from "@wordpress/dom-ready";
4
import { render } from "@wordpress/element";
5
import { Root } from "@yoast/ui-library";
6
import { get } from "lodash";
7
import { createHashRouter, createRoutesFromElements, Navigate, Route, RouterProvider } from "react-router-dom";
8
import { Dashboard } from "../dashboard";
9
import { LINK_PARAMS_NAME } from "../shared-admin/store";
10
import App from "./app";
11
import { RouteErrorFallback } from "./components";
12
import { ConnectedPremiumUpsellList } from "./components/connected-premium-upsell-list";
13
import { SidebarLayout } from "./components/sidebar-layout";
14
import { STORE_NAME } from "./constants";
15
import { AlertCenter, FirstTimeConfiguration, ROUTES } from "./routes";
16
import registerStore from "./store";
17
import { ALERT_CENTER_NAME } from "./store/alert-center";
18
import { FTC_NAME } from "./store/first-time-configuration";
19

20
/**
21
 * @type {import("../index").ContentType} ContentType
22
 * @type {import("../index").Features} Features
23
 * @type {import("../index").Links} Links
24
 * @type {import("../index").Endpoints} Endpoints
25
 */
26

27
domReady( () => {
×
28
        const root = document.getElementById( "yoast-seo-general" );
×
29
        if ( ! root ) {
×
30
                return;
×
31
        }
32
        registerStore( {
×
33
                initialState: {
34
                        [ LINK_PARAMS_NAME ]: get( window, "wpseoScriptData.linkParams", {} ),
35
                        [ ALERT_CENTER_NAME ]: { alerts: get( window, "wpseoScriptData.alerts", [] ) },
36
                        currentPromotions: { promotions: get( window, "wpseoScriptData.currentPromotions", [] ) },
37
                        dismissedAlerts: get( window, "wpseoScriptData.dismissedAlerts", {} ),
38
                        isPremium: get( window, "wpseoScriptData.preferences.isPremium", false ),
39
                        [ FTC_NAME ]: { resolvedNotices: [] },
40
                },
41
        } );
42
        const isRtl = select( STORE_NAME ).selectPreference( "isRtl", false );
×
43

44
        /** @type {ContentType[]} */
45
        const contentTypes = get( window, "wpseoScriptData.dashboard.contentTypes", [] );
×
46
        /** @type {string} */
47
        const userName = get( window, "wpseoScriptData.dashboard.displayName", "User" );
×
48
        /** @type {Features} */
49
        const features = {
×
50
                indexables: get( window, "wpseoScriptData.dashboard.indexablesEnabled", false ),
51
                seoAnalysis: get( window, "wpseoScriptData.dashboard.enabledAnalysisFeatures.keyphraseAnalysis", false ),
52
                readabilityAnalysis: get( window, "wpseoScriptData.dashboard.enabledAnalysisFeatures.readabilityAnalysis", false ),
53
        };
54

55
        /** @type {Endpoints} */
56
        const endpoints = {
×
57
                seoScores: get( window, "wpseoScriptData.dashboard.endpoints.seoScores", "" ),
58
                readabilityScores: get( window, "wpseoScriptData.dashboard.endpoints.readabilityScores", "" ),
59
        };
60
        /** @type {Object<string,string>} */
61
        const headers = {
×
62
                "X-Wp-Nonce": get( window, "wpseoScriptData.dashboard.nonce", "" ),
63
        };
64

65
        /** @type {{contentAnalysis: string}} */
NEW
66
        const links = {
×
67
                contentAnalysis: select( STORE_NAME ).selectLink( "https://yoa.st/content-analysis-tool" ),
68
        };
69

UNCOV
70
        const router = createHashRouter(
×
71
                createRoutesFromElements(
72
                        <Route path="/" element={ <App /> } errorElement={ <RouteErrorFallback className="yst-m-8" /> }>
73
                                <Route
74
                                        path={ ROUTES.dashboard }
75
                                        element={
76
                                                <SidebarLayout>
77
                                                        <Dashboard
78
                                                                contentTypes={ contentTypes }
79
                                                                userName={ userName }
80
                                                                features={ features }
81
                                                                endpoints={ endpoints }
82
                                                                headers={ headers }
83
                                                                links={ links }
84
                                                        />
85
                                                        <ConnectedPremiumUpsellList />
86
                                                </SidebarLayout>
87
                                        }
88
                                        errorElement={ <RouteErrorFallback /> }
89
                                />
90
                                <Route
91
                                        path={ ROUTES.alertCenter }
92
                                        element={ <SidebarLayout><AlertCenter /><ConnectedPremiumUpsellList /></SidebarLayout> }
93
                                        errorElement={ <RouteErrorFallback /> }
94
                                />
95
                                <Route path={ ROUTES.firstTimeConfiguration } element={ <FirstTimeConfiguration /> } errorElement={ <RouteErrorFallback /> } />
96
                                {
97
                                        /**
98
                                         * Fallback route: redirect to the dashboard.
99
                                         * A redirect is used to support the activePath in the menu. E.g. `pathname` matches exactly.
100
                                         * It replaces the current path to not introduce invalid history in the browser (that would just redirect again).
101
                                         */
102
                                }
103
                                <Route path="*" element={ <Navigate to={ ROUTES.dashboard } replace={ true } /> } />
104
                        </Route>
105
                )
106
        );
107

108
        render(
×
109
                <Root context={ { isRtl } }>
110
                        <SlotFillProvider>
111
                                <RouterProvider router={ router } />
112
                        </SlotFillProvider>
113
                </Root>,
114
                root
115
        );
116
} );
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc