-
Notifications
You must be signed in to change notification settings - Fork 902
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
134 changed files
with
5,004 additions
and
282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Scores } from "../scores/components/scores"; | ||
import { PageTitle } from "./page-title"; | ||
|
||
/** | ||
* @type {import("../index").ContentType} ContentType | ||
* @type {import("../index").Features} Features | ||
* @type {import("../index").Endpoints} Endpoints | ||
* @type {import("../index").Links} Links | ||
*/ | ||
|
||
/** | ||
* @param {ContentType[]} contentTypes The content types. | ||
* @param {string} userName The user name. | ||
* @param {Features} features Whether features are enabled. | ||
* @param {Endpoints} endpoints The endpoints. | ||
* @param {Object<string,string>} headers The headers for the score requests. | ||
* @param {Links} links The links. | ||
* @returns {JSX.Element} The element. | ||
*/ | ||
export const Dashboard = ( { contentTypes, userName, features, endpoints, headers, links } ) => { | ||
return ( | ||
<> | ||
<PageTitle userName={ userName } features={ features } links={ links } /> | ||
<div className="yst-flex yst-flex-col @7xl:yst-flex-row yst-gap-6 yst-my-6"> | ||
{ features.indexables && features.seoAnalysis && ( | ||
<Scores analysisType="seo" contentTypes={ contentTypes } endpoint={ endpoints.seoScores } headers={ headers } /> | ||
) } | ||
{ features.indexables && features.readabilityAnalysis && ( | ||
<Scores analysisType="readability" contentTypes={ contentTypes } endpoint={ endpoints.readabilityScores } headers={ headers } /> | ||
) } | ||
</div> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { createInterpolateElement } from "@wordpress/element"; | ||
import { __, sprintf } from "@wordpress/i18n"; | ||
import { Alert, Link, Paper, Title } from "@yoast/ui-library"; | ||
import { OutboundLink } from "../../shared-admin/components"; | ||
|
||
/** | ||
* @type {import("../index").Features} Features | ||
* @type {import("../index").Links} Links | ||
*/ | ||
|
||
/** | ||
* @param {string} userName The user name. | ||
* @param {Features} features Whether features are enabled. | ||
* @param {Links} links The links. | ||
* @returns {JSX.Element} The element. | ||
*/ | ||
export const PageTitle = ( { userName, features, links } ) => ( | ||
<Paper> | ||
<Paper.Content className="yst-flex yst-flex-col yst-gap-y-4 yst-max-w-screen-sm"> | ||
<Title as="h1"> | ||
{ sprintf( | ||
__( "Hi %s,", "wordpress-seo" ), | ||
userName | ||
) } | ||
</Title> | ||
<p className="yst-text-tiny"> | ||
{ features.indexables && ! features.seoAnalysis && ! features.readabilityAnalysis | ||
? createInterpolateElement( | ||
sprintf( | ||
/** | ||
* translators: %1$s and %2$s expand to an opening and closing anchor tag, to the site features page. | ||
* %3$s and %4$s expand to an opening and closing anchor tag, to the user profile page. | ||
**/ | ||
__( "It looks like the ‘SEO analysis’ and the ‘Readability analysis’ are currently disabled in your %1$sSite features%2$s or your %3$suser profile settings%4$s. Enable these features to start seeing all the insights you need right here!", "wordpress-seo" ), | ||
"<link>", | ||
"</link>", | ||
"<profilelink>", | ||
"</profilelink>" | ||
), | ||
{ | ||
// Added dummy space as content to prevent children prop warnings in the console. | ||
link: <Link href="admin.php?page=wpseo_page_settings#/site-features"> </Link>, | ||
profilelink: <Link href="profile.php"> </Link>, | ||
} | ||
) | ||
: createInterpolateElement( | ||
sprintf( | ||
/* translators: %1$s and %2$s expand to an opening and closing anchor tag. */ | ||
__( "Welcome to your dashboard! Check your content's SEO performance, readability, and overall strengths and opportunities. %1$sLearn more about the dashboard%2$s.", "wordpress-seo" ), | ||
"<link>", | ||
"</link>" | ||
), | ||
{ | ||
// Added dummy space as content to prevent children prop warnings in the console. | ||
link: <OutboundLink href={ links.dashboardLearnMore }> </OutboundLink>, | ||
} | ||
) | ||
} | ||
</p> | ||
{ ! features.indexables && ( | ||
<Alert type="info"> | ||
{ __( "Oops! You can’t see the overview of your SEO scores and readability scores right now because you’re in a non-production environment.", "wordpress-seo" ) } | ||
</Alert> | ||
) } | ||
</Paper.Content> | ||
</Paper> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { getResponseError } from "./get-response-error"; | ||
|
||
/** | ||
* @param {string|URL} url The URL to fetch from. | ||
* @param {RequestInit} options The request options. | ||
* @returns {Promise<any|Error>} The promise of a result, or an error. | ||
*/ | ||
export const fetchJson = async( url, options ) => { | ||
try { | ||
const response = await fetch( url, options ); | ||
if ( ! response.ok ) { | ||
throw getResponseError( response ); | ||
} | ||
return response.json(); | ||
} catch ( e ) { | ||
return Promise.reject( e ); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { TimeoutError } from "./timeout-error"; | ||
|
||
/** | ||
* @param {Response} response The response. | ||
* @returns {Error} The error that corresponds to the response. | ||
*/ | ||
export const getResponseError = ( response ) => { | ||
switch ( response.status ) { | ||
case 408: | ||
return new TimeoutError( "request timed out" ); | ||
default: | ||
return new Error( "not ok" ); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* Represents a timeout error. | ||
*/ | ||
export class TimeoutError extends Error { | ||
/** | ||
* @param {string} message The error message. | ||
*/ | ||
constructor( message ) { | ||
super( message ); | ||
this.name = "TimeoutError"; | ||
} | ||
} |
Oops, something went wrong.