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

Yoast / wordpress-seo / a7886492b145fdf70261f7ca2cb0fbcb3562b15b

25 Nov 2024 01:47PM UTC coverage: 54.184% (-0.03%) from 54.215%
a7886492b145fdf70261f7ca2cb0fbcb3562b15b

Pull #21852

github

web-flow
Merge b930e736a into 16577a01e
Pull Request #21852: 339 dashboard use request to get the actual scores

7593 of 13670 branches covered (55.54%)

Branch coverage included in aggregate %.

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

989 existing lines in 3 files now uncovered.

29764 of 55275 relevant lines covered (53.85%)

41521.03 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} */
NEW
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>} */
NEW
61
        const headers = {
×
62
                "X-Wp-Nonce": get( window, "wpseoScriptData.dashboard.nonce", "" ),
63
        };
64

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

102
        render(
×
103
                <Root context={ { isRtl } }>
104
                        <SlotFillProvider>
105
                                <RouterProvider router={ router } />
106
                        </SlotFillProvider>
107
                </Root>,
108
                root
109
        );
110
} );
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