Skip to content

Commit

Permalink
Page descriptions copy
Browse files Browse the repository at this point in the history
* default copy: with link to external content-analysis
* both features disabled but still indexables: with link to internal site features
* no indexables: default copy but with info alert
  • Loading branch information
igorschoester committed Nov 25, 2024
1 parent 5826db4 commit 66a57fa
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
6 changes: 4 additions & 2 deletions packages/js/src/dashboard/components/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ 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
*/

/**
Expand All @@ -13,12 +14,13 @@ import { PageTitle } from "./page-title";
* @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 } ) => {
export const Dashboard = ( { contentTypes, userName, features, endpoints, headers, links } ) => {
return (
<>
<PageTitle userName={ userName } features={ features } />
<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 } />
Expand Down
22 changes: 18 additions & 4 deletions packages/js/src/dashboard/components/page-title.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
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 } ) => (
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">
Expand All @@ -25,7 +28,7 @@ export const PageTitle = ( { userName, features } ) => (
? createInterpolateElement(
sprintf(
/* translators: %1$s and %2$s expand to an opening and closing anchor tag. */
__( "It seems that the SEO analysis and the Readability analysis are currently disabled in your %1$sSite features%2$s. Once you enable these features, you'll be able to see the insights you need right here!", "wordpress-seo" ),
__( "It looks like the SEO analysis and the Readability analysis are currently turned off in your %1$sSite features%2$s. Enable these features to start seeing all the insights you need right here!", "wordpress-seo" ),
"<link>",
"</link>"
),
Expand All @@ -34,12 +37,23 @@ export const PageTitle = ( { userName, features } ) => (
link: <Link href="admin.php?page=wpseo_page_settings#/site-features"> </Link>,
}
)
: __( "Welcome to our SEO dashboard!", "wordpress-seo" )
: 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 on how to improve your content with our content analysis tool%2$s.", "wordpress-seo" ),
"<link>",
"</link>"
),
{
// Added dummy space as content to prevent children prop warnings in the console.
link: <OutboundLink href={ links.contentAnalysis }> </OutboundLink>,
}
)
}
</p>
{ ! features.indexables && (
<Alert type="info">
{ __( "The overview of your SEO scores and Readability scores is not available because you're on a non-production environment.", "wordpress-seo" ) }
{ __( "Oops! You can’t see the overview of your SEO scores and readability scores right now because youre in a non-production environment.", "wordpress-seo" ) }
</Alert>
) }
</Paper.Content>
Expand Down
5 changes: 5 additions & 0 deletions packages/js/src/dashboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,8 @@ export { Dashboard } from "./components/dashboard";
* @property {string} seoScores The endpoint for SEO scores.
* @property {string} readabilityScores The endpoint for readability scores.
*/

/**
* @typedef {Object} Links The links.
* @property {string} contentAnalysis The content analysis information link.
*/
6 changes: 6 additions & 0 deletions packages/js/src/general/initialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ domReady( () => {
"X-Wp-Nonce": get( window, "wpseoScriptData.dashboard.nonce", "" ),
};

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

const router = createHashRouter(
createRoutesFromElements(
<Route path="/" element={ <App /> } errorElement={ <RouteErrorFallback className="yst-m-8" /> }>
Expand All @@ -75,6 +80,7 @@ domReady( () => {
features={ features }
endpoints={ endpoints }
headers={ headers }
links={ links }
/>
<ConnectedPremiumUpsellList />
</SidebarLayout>
Expand Down

0 comments on commit 66a57fa

Please sign in to comment.