-
Notifications
You must be signed in to change notification settings - Fork 909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
402 implement site kit setup flow #21978
Open
vraja-pro
wants to merge
76
commits into
trunk
Choose a base branch
from
402-implement-site-kit-setup-flow
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 48 commits
Commits
Show all changes
76 commits
Select commit
Hold shift + click to select a range
35e9827
stepper for ui-library
vraja-pro 32e9938
implement the stepper and design
vraja-pro c8daeaa
implement stepper and gsk status
vraja-pro bce65d9
reduce complexity and add link params
vraja-pro 0af104a
fix php cs
vraja-pro 7e9e035
add the remove widget ui
vraja-pro 442008b
fix stepper labels colors
vraja-pro e9150b2
fix link and current step
vraja-pro ace9438
fix padding in gsk widget
vraja-pro 8a0c64e
dd todo comments for permanently dismissing the widget
vraja-pro 2f3bf02
reduce eslint threshold and fix js lint
vraja-pro a952648
add tests and fix accessibility
vraja-pro d29b748
update svg
vraja-pro aacdf7e
fixed the links, buttons and isComplete
vraja-pro f82bd8c
rename props and fix isComplete variable
vraja-pro cc9cfa8
fix is complete
vraja-pro 37e38ae
simplify step and add animation to progress bar
vraja-pro 42ddef4
fix check icon size and animation
vraja-pro 7bb273d
fix stepper animation
vraja-pro 937da2c
fix stepper order of animation
vraja-pro ec0318b
fix stepper
vraja-pro 412899c
added the dropdown menu
vraja-pro 719f0c9
fix dropdown menu
vraja-pro 1600141
implement dropdown menu
vraja-pro 5dda8d5
Switch to camel case
vraja-pro 45f936c
fix php cs
vraja-pro 423398c
refactor step
vraja-pro 53aaa0b
use ui library progress bar in stepper
vraja-pro 7173c0c
fix js docs for stepper
vraja-pro 8820a9c
Fix js doc comments
vraja-pro 4eaa7de
renaming variables and cleaning Stepper
vraja-pro 9116a18
Add comment about the positioning f the progress bar
vraja-pro 1bd29d0
remove unused prop
vraja-pro ce56c25
implement component Stepper
vraja-pro 4f201d3
fixing dropdown menu docs.
vraja-pro ebba34f
fix stepper story
vraja-pro cf63008
darken the icon when menu is open
vraja-pro b44e945
fix documentation for Dropdown Menu
vraja-pro 1e26176
update widget tests
vraja-pro 1fae71a
abstract the learn more link
vraja-pro 372448a
renamed to google site kit set up widget
vraja-pro 608e131
rename to site kit setup widget
vraja-pro 1f5e8d3
Merge remote-tracking branch 'origin/trunk' into 402-implement-site-k…
vraja-pro ccf0c7f
fix renaming and implement site kit configuration data
vraja-pro 6bffd65
fix renaming setup completed variable
vraja-pro fd3b96f
php fixed cs
vraja-pro 9bb0d69
rename site kit integration
vraja-pro d7065dd
fix site kit configuration
vraja-pro df695a7
Update packages/ui-library/src/components/dropdown-menu/index.js
vraja-pro 104e63b
spread props to menu
vraja-pro a61753f
finetune tests
vraja-pro 303d30b
adds BEM id name
vraja-pro e13cb70
adds props to dropdown menu
vraja-pro 2f95f47
fix styling and formatting
vraja-pro 5c31075
adds missing class name docs
vraja-pro 3d61b5a
fix tests for the menu item buttons
vraja-pro 69a00a7
fix menu return docs
vraja-pro ad43745
format props for readability
vraja-pro 5e9ead6
fix screen reader text
vraja-pro cca64f0
fix screen reader text and css
vraja-pro 650c8dc
adds gap between buttons
vraja-pro a532bca
fix dropdown menu story docs
vraja-pro 1a9e5ac
use gap instead of margin
vraja-pro 1acc88b
fix docs for dropdown storybook
vraja-pro 5368c5e
adds props spread to list
vraja-pro e22a6e4
Added screen reader prop as required
vraja-pro 9d57dd2
fix doc for button item
vraja-pro c183c9d
moved styling outside the ui library
vraja-pro 1cf1273
add the styling from the ui library
vraja-pro 017ce91
move width outside ui library for flexability
vraja-pro 83113ac
Adds default to stepper context and expose it
vraja-pro 20e12dc
fix step props
vraja-pro c4abeb3
fix context
vraja-pro 2c8ea36
remove number of steps
vraja-pro 2332c7f
fix docs for stepper
vraja-pro 2ab3a14
Merge remote-tracking branch 'origin/trunk' into 402-implement-site-k…
vraja-pro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,5 +1,10 @@ | ||
import { Scores } from "../scores/components/scores"; | ||
import { PageTitle } from "./page-title"; | ||
import { SiteKitSetupWidget } from "./site-kit-setup-widget"; | ||
import { get } from "lodash"; | ||
import { useCallback } from "@wordpress/element"; | ||
import { useToggleState } from "@yoast/ui-library"; | ||
import { useSelect } from "@wordpress/data"; | ||
|
||
/** | ||
* @type {import("../index").ContentType} ContentType | ||
|
@@ -15,13 +20,38 @@ import { PageTitle } from "./page-title"; | |
* @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. | ||
*/ | ||
// The complexity is cause by the google site kit feature flag which is temporary. | ||
// eslint-disable-next-line complexity | ||
export const Dashboard = ( { contentTypes, userName, features, endpoints, headers, links } ) => { | ||
const siteKitConfiguration = get( window, "wpseoScriptData.dashboard.siteKitConfiguration", { | ||
isInstalled: false, | ||
isActive: false, | ||
isSetupCompleted: false, | ||
isConnected: false, | ||
installUrl: "", | ||
activateUrl: "", | ||
setupUrl: "", | ||
isFeatureEnabled: false, | ||
} ); | ||
const [ showGoogleSiteKit, , , , setRemoveGoogleSiteKit ] = useToggleState( true ); | ||
const learnMorelink = useSelect( select => select( "@yoast/general" ).selectLink( "https://yoa.st/google-site-kit-learn-more" ), [] ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is tying the Dashboard to the |
||
const handleRemovePermanently = useCallback( ()=>{ | ||
/* eslint-disable-next-line */ | ||
// TODO: Implement the remove permanently functionality. | ||
setRemoveGoogleSiteKit(); | ||
}, [ setRemoveGoogleSiteKit ] ); | ||
|
||
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"> | ||
{ showGoogleSiteKit && siteKitConfiguration.isFeatureEnabled && <SiteKitSetupWidget | ||
{ ...siteKitConfiguration } learnMoreLink={ learnMorelink } | ||
onRemove={ setRemoveGoogleSiteKit } onRemovePermanently={ handleRemovePermanently } | ||
/> } | ||
vraja-pro marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ features.indexables && features.seoAnalysis && ( | ||
<Scores analysisType="seo" contentTypes={ contentTypes } endpoint={ endpoints.seoScores } headers={ headers } /> | ||
) } | ||
|
148 changes: 148 additions & 0 deletions
148
packages/js/src/dashboard/components/site-kit-setup-widget.js
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,148 @@ | ||
import { Button, Paper, Stepper, Title, DropdownMenu } from "@yoast/ui-library"; | ||
import { ReactComponent as YoastConnectSiteKit } from "../../../images/yoast-connect-google-site-kit.svg"; | ||
import { __ } from "@wordpress/i18n"; | ||
import { CheckCircleIcon } from "@heroicons/react/solid"; | ||
import { ArrowRightIcon, XIcon, TrashIcon } from "@heroicons/react/outline"; | ||
|
||
/** | ||
* Get the button and stepper props based on the current state. | ||
* | ||
* @param {boolean} isInstalled Whether the plugin is isInstalled. | ||
* @param {boolean} isActive Whether the feature is active. | ||
* @param {boolean} isSetupCompleted Whether the setup is complete. | ||
* @param {boolean} isConnected Whether the connection is active. | ||
* @param {string} installUrl The URL to install Site Kit. | ||
* @param {string} activateUrl The URL to activate Site Kit. | ||
* @param {string} setupUrl The URL to setup Site Kit. | ||
* | ||
* @returns {Object} The button and stepper props. | ||
*/ | ||
const getButtonAndStepperProps = ( isInstalled, isActive, isSetupCompleted, isConnected, installUrl, activateUrl, setupUrl ) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll point to my unanswered previous comment: #21978 (comment) |
||
let buttonProps; | ||
let currentStep; | ||
let isComplete = false; | ||
|
||
switch ( true ) { | ||
case ( ! isInstalled ): | ||
currentStep = 1; | ||
buttonProps = { | ||
children: __( "Install Site Kit by Google", "wordpress-seo" ), | ||
as: "a", | ||
href: installUrl, | ||
}; | ||
break; | ||
case ( ! isActive ): | ||
currentStep = 2; | ||
buttonProps = { | ||
children: __( "Activate Site Kit by Google", "wordpress-seo" ), | ||
as: "a", | ||
href: activateUrl, | ||
}; | ||
break; | ||
case ( ! isSetupCompleted ): | ||
currentStep = 3; | ||
buttonProps = { | ||
children: __( "Set up Site Kit by Google", "wordpress-seo" ), | ||
as: "a", | ||
href: setupUrl, | ||
}; | ||
break; | ||
case ( ! isConnected ): | ||
currentStep = 4; | ||
buttonProps = { children: __( "Connect Site Kit by Google", "wordpress-seo" ) }; | ||
break; | ||
case isConnected: | ||
isComplete = true; | ||
currentStep = 4; | ||
buttonProps = { children: "Take a quick tour" }; | ||
break; | ||
} | ||
return { buttonProps, currentStep, isComplete }; | ||
}; | ||
|
||
const steps = [ | ||
__( "INSTALL", "wordpress-seo" ), | ||
__( "ACTIVATE", "wordpress-seo" ), | ||
__( "SET UP", "wordpress-seo" ), | ||
__( "CONNECT", "wordpress-seo" ), | ||
]; | ||
|
||
/** | ||
* The google site kit connection guide widget. | ||
* | ||
* @param {boolean} isInstalled Whether the plugin is installed. | ||
* @param {boolean} isActive Whether the feature is active. | ||
* @param {boolean} isSetupCompleted Whether the setup is complete. | ||
* @param {boolean} isConnected Whether the connection is active. | ||
* @param {string} installUrl The URL to install Site Kit. | ||
* @param {string} activateUrl The URL to activate Site Kit. | ||
* @param {string} setupUrl The URL to setup Site Kit. | ||
* @param {function} onRemove The function to call when the widget is removed. | ||
* @param {function} onRemovePermanently The function to call when the widget is removed permanently. | ||
* @param {string} learnMorelink The URL to learn more about the feature. | ||
* | ||
* @returns {JSX.Element} The widget. | ||
*/ | ||
export const SiteKitSetupWidget = ( { | ||
installUrl, | ||
activateUrl, | ||
setupUrl, | ||
isConnected, | ||
isActive, | ||
isSetupCompleted, | ||
isInstalled, | ||
onRemove, | ||
onRemovePermanently, | ||
learnMorelink, | ||
} ) => { | ||
const { buttonProps, currentStep, isComplete } = getButtonAndStepperProps( | ||
isInstalled, isActive, isSetupCompleted, isConnected, installUrl, activateUrl, setupUrl ); | ||
return <Paper className="yst-@container yst-grow yst-max-w-screen-sm yst-p-8 yst-shadow-md yst-relative"> | ||
<DropdownMenu className="yst-absolute yst-top-4 yst-end-4"> | ||
vraja-pro marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<DropdownMenu.IconTrigger screenReaderTriggerLabel={ __( "Open menu", "wordpress-seo" ) } className="yst-absolute yst-top-0 yst-end-0" /> | ||
vraja-pro marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<DropdownMenu.List className="yst-absolute yst-top-5 yst-end-0"> | ||
vraja-pro marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<DropdownMenu.ButtonItem className="yst-text-slate-600" onClick={ onRemove }> | ||
<XIcon className="yst-w-4 yst-text-slate-400" /> | ||
{ __( "Remove until next visit", "wordpress-seo" ) } | ||
</DropdownMenu.ButtonItem> | ||
<DropdownMenu.ButtonItem className="yst-text-red-500" onClick={ onRemovePermanently }> | ||
<TrashIcon className="yst-w-4" /> | ||
{ __( "Remove permanently", "wordpress-seo" ) } | ||
</DropdownMenu.ButtonItem> | ||
</DropdownMenu.List> | ||
</DropdownMenu> | ||
|
||
<div className="yst-flex yst-justify-center yst-mb-6 yst-mt-4"><YoastConnectSiteKit /></div> | ||
<Stepper steps={ steps } currentStep={ currentStep } numberOfSteps={ steps.length }> | ||
{ steps.map( ( label, index ) => ( <Stepper.Step | ||
key={ label } | ||
label={ label } | ||
isActive={ currentStep === index + 1 } | ||
isComplete={ isComplete } | ||
isStepComplete={ currentStep > index + 1 || isComplete } | ||
/> ) ) } | ||
</Stepper> | ||
<hr className="yst-bg-slate-200 yst-my-6" /> | ||
<Title size="2">{ __( "Expand your dashboard with insights from Google!", "wordpress-seo" ) }</Title> | ||
<p className="yst-my-4">{ __( "Bring together powerful tools like Google Analytics and Search Console for a complete overview of your website's performance, all in one seamless dashboard.", "wordpress-seo" ) }</p> | ||
|
||
<span className="yst-text-slate-800 yst-font-medium">{ __( "What you'll get:", "wordpress-seo" ) }</span> | ||
<ul> | ||
<li className="yst-gap-2 yst-flex yst-mt-2"><CheckCircleIcon className="yst-w-5 yst-text-green-400" /> | ||
{ __( "Actionable insights into traffic, SEO, and user behavior to grow your audience.", "wordpress-seo" ) }</li> | ||
<li className="yst-gap-2 yst-flex yst-mt-2"><CheckCircleIcon className="yst-w-5 yst-text-green-400" /> | ||
{ __( "Key performance metrics to fine-tune your website and optimize like a pro.", "wordpress-seo" ) }</li> | ||
vraja-pro marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</ul> | ||
<div className="yst-flex yst-gap-0.5 yst-mt-6 yst-items-center"> | ||
vraja-pro marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<Button { ...buttonProps } /> | ||
|
||
{ isConnected ? <Button>{ __( "Dismiss", "wordpress-seo" ) }</Button> | ||
: <Button as="a" variant="tertiary" href={ learnMorelink }>{ __( "Learn more", "wordpress-seo" ) } | ||
<ArrowRightIcon className="yst-w-3 yst-ml-2 yst-text-primary-500" /> | ||
vraja-pro marked this conversation as resolved.
Show resolved
Hide resolved
vraja-pro marked this conversation as resolved.
Show resolved
Hide resolved
vraja-pro marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</Button> | ||
} | ||
</div> | ||
</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
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
56 changes: 56 additions & 0 deletions
56
packages/js/tests/dashboard/components/site-kit-setup-widget.test.js
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,56 @@ | ||
import { render, screen, fireEvent } from "@testing-library/react"; | ||
import { SiteKitSetupWidget } from "../../../src/dashboard/components/site-kit-setup-widget"; | ||
|
||
describe( "SiteKitSetupWidget", () => { | ||
const defaultProps = { | ||
installUrl: "https://example.com/install", | ||
activateUrl: "https://example.com/activate", | ||
setupUrl: "https://example.com/isSetup", | ||
isConnected: false, | ||
isActive: false, | ||
isSetupCompleted: false, | ||
isInstalled: false, | ||
onRemove: jest.fn(), | ||
onRemovePermanently: jest.fn(), | ||
learnMoreLink: "https://example.com/learn-more", | ||
}; | ||
|
||
it( "renders the widget with install button", () => { | ||
render( <SiteKitSetupWidget { ...defaultProps } /> ); | ||
expect( screen.getByText( "Install Site Kit by Google" ) ).toBeInTheDocument(); | ||
vraja-pro marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} ); | ||
|
||
it( "renders the widget with activate button", () => { | ||
render( <SiteKitSetupWidget { ...defaultProps } isInstalled={ true } /> ); | ||
expect( screen.getByText( "Activate Site Kit by Google" ) ).toBeInTheDocument(); | ||
} ); | ||
|
||
it( "renders the widget with setup button", () => { | ||
render( <SiteKitSetupWidget { ...defaultProps } isInstalled={ true } isActive={ true } /> ); | ||
expect( screen.getByText( "Set up Site Kit by Google" ) ).toBeInTheDocument(); | ||
} ); | ||
|
||
it( "renders the widget with connect button", () => { | ||
render( <SiteKitSetupWidget { ...defaultProps } isInstalled={ true } isActive={ true } isSetupCompleted={ true } /> ); | ||
expect( screen.getByText( "Connect Site Kit by Google" ) ).toBeInTheDocument(); | ||
} ); | ||
|
||
it( "renders the widget with dismiss button when connected", () => { | ||
render( <SiteKitSetupWidget { ...defaultProps } isInstalled={ true } isActive={ true } isSetupCompleted={ true } isConnected={ true } /> ); | ||
expect( screen.getByText( "Dismiss" ) ).toBeInTheDocument(); | ||
} ); | ||
|
||
it( "opens the menu and calls onRemove when 'Remove until next visit' is clicked", () => { | ||
render( <SiteKitSetupWidget { ...defaultProps } /> ); | ||
fireEvent.click( screen.getByRole( "button", { name: /open menu/i } ) ); | ||
fireEvent.click( screen.getByText( "Remove until next visit" ) ); | ||
expect( defaultProps.onRemove ).toHaveBeenCalled(); | ||
} ); | ||
|
||
it( "opens the menu and calls onRemovePermanently when 'Remove permanently' is clicked", () => { | ||
render( <SiteKitSetupWidget { ...defaultProps } /> ); | ||
fireEvent.click( screen.getByRole( "button", { name: /open menu/i } ) ); | ||
fireEvent.click( screen.getByText( "Remove permanently" ) ); | ||
vraja-pro marked this conversation as resolved.
Show resolved
Hide resolved
|
||
expect( defaultProps.onRemovePermanently ).toHaveBeenCalled(); | ||
} ); | ||
} ); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please answer: #21978 (comment)